summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Zeuthen <davidz@redhat.com>2010-10-06 15:39:46 -0400
committerDavid Zeuthen <davidz@redhat.com>2010-10-06 15:39:46 -0400
commit137ebd86e47c90c05563ce106819f71ec09c2496 (patch)
treece0cada1f873a507108216368d3314ffb2f40f31
parent4e1ada172b3c469f0c441e5c63a2d5c7f207add5 (diff)
Check if device is already ounted before mounting it
Signed-off-by: David Zeuthen <davidz@redhat.com>
-rw-r--r--stc/stcitem.c25
1 files changed, 21 insertions, 4 deletions
diff --git a/stc/stcitem.c b/stc/stcitem.c
index 8bd9326..1d2d2b7 100644
--- a/stc/stcitem.c
+++ b/stc/stcitem.c
@@ -1599,12 +1599,14 @@ _stc_item_start_filesystem (StcItem *item,
gboolean ret;
ret = FALSE;
+ mount_path = NULL;
+ device = NULL;
device = _stc_item_filesystem_get_device (item, &mount_path);
if (device != NULL)
{
- const gchar *mount_path;
+ const gchar *o_mount_path;
const gchar *device_file;
const gchar *options;
gchar *q_mount_path;
@@ -1612,13 +1614,24 @@ _stc_item_start_filesystem (StcItem *item,
gchar *q_options;
gchar *command_line;
- mount_path = g_hash_table_lookup (item->options, "Filesystem:mount_path");
+ if (mount_path != NULL)
+ {
+ g_set_error (error,
+ STC_ERROR,
+ STC_ERROR_FAILED,
+ "Device %s is already mounted at %s",
+ g_udev_device_get_device_file (device),
+ mount_path);
+ goto out;
+ }
+
+ o_mount_path = g_hash_table_lookup (item->options, "Filesystem:mount_path");
device_file = g_udev_device_get_device_file (device);
options = g_hash_table_lookup (item->options, "Filesystem:options");
- g_assert (mount_path != NULL);
+ g_assert (o_mount_path != NULL);
g_assert (device_file != NULL);
- q_mount_path = g_shell_quote (mount_path);
+ q_mount_path = g_shell_quote (o_mount_path);
q_device = g_shell_quote (device_file);
if (options != NULL)
q_options = g_shell_quote (options);
@@ -1652,6 +1665,10 @@ _stc_item_start_filesystem (StcItem *item,
ret = TRUE;
out:
+ if (device != NULL)
+ g_object_unref (device);
+ g_free (mount_path);
+
return ret;
}