* Known details include
* <literal>block-device</literal>
* (of type <link linkend="G-VARIANT-TYPE-UINT64:CAPS">'t'</link>) that is the #dev_t
- * for the mounted device and
+ * for the mounted device,
* <literal>mounted-by-uid</literal>
* (of type <link linkend="G-VARIANT-TYPE-UINT32:CAPS">'u'</link>) that is the #uid_t
- * of the user who mounted the device.
+ * of the user who mounted the device, and
+ * <literal>fstab-mount</literal>
+ * (of type <link linkend="G-VARIANT-TYPE-BOOLEAN:CAPS">'b'</link>) that is %TRUE
+ * if the device was mounted via an entry in /etc/fstab.
* </entry>
* </row>
* <row>
GVariant *details;
GVariant *block_device_value;
dev_t block_device;
+ GVariant *fstab_mount_value;
+ gboolean fstab_mount;
gboolean keep;
gchar *s;
GList *mounts;
device_to_be_cleaned = FALSE;
attempt_no_cleanup = FALSE;
block_device_value = NULL;
+ fstab_mount_value = NULL;
+ fstab_mount = FALSE;
details = NULL;
monitor = udisks_daemon_get_mount_monitor (cleanup->daemon);
}
block_device = g_variant_get_uint64 (block_device_value);
+ fstab_mount_value = lookup_asv (details, "fstab-mount");
+ if (fstab_mount_value == NULL)
+ {
+ s = g_variant_print (value, TRUE);
+ udisks_error ("mounted-fs entry %s is invalid: no fstab-mount key/value pair", s);
+ g_free (s);
+ attempt_no_cleanup = FALSE;
+ goto out;
+ }
+ fstab_mount = g_variant_get_boolean (fstab_mount_value);
+
/* udisks_debug ("Validating mounted-fs entry for mount point %s", mount_point); */
/* Figure out if still mounted */
}
/* remove directory */
- if (g_file_test (mount_point, G_FILE_TEST_EXISTS | G_FILE_TEST_IS_DIR))
+ if (!fstab_mount)
{
- if (g_rmdir (mount_point) != 0)
+ if (g_file_test (mount_point, G_FILE_TEST_EXISTS | G_FILE_TEST_IS_DIR))
{
- udisks_error ("Error cleaning up mount point %s: Error removing directory: %m",
- mount_point);
- /* keep the entry so we can clean it up later */
- keep = TRUE;
- goto out2;
+ if (g_rmdir (mount_point) != 0)
+ {
+ udisks_error ("Error cleaning up mount point %s: Error removing directory: %m",
+ mount_point);
+ /* keep the entry so we can clean it up later */
+ keep = TRUE;
+ goto out2;
+ }
}
}
}
out2:
+ if (fstab_mount_value != NULL)
+ g_variant_unref (fstab_mount_value);
if (block_device_value != NULL)
g_variant_unref (block_device_value);
if (details != NULL)
* @block_device: The block device.
* @mount_point: The mount point.
* @uid: The user id of the process requesting the device to be mounted.
+ * @fstab_mount: %TRUE if the device was mounted via /etc/fstab.
* @error: Return location for error or %NULL.
*
* Adds a new entry to the
const gchar *mount_point,
dev_t block_device,
uid_t uid,
+ gboolean fstab_mount,
GError **error)
{
gboolean ret;
"{sv}",
"mounted-by-uid",
g_variant_new_uint32 (uid));
+ g_variant_builder_add (&details_builder,
+ "{sv}",
+ "fstab-mount",
+ g_variant_new_boolean (fstab_mount));
details_value = g_variant_builder_end (&details_builder);
/* finally add the new entry */
* @cleanup: A #UDisksCleanup.
* @block_device: The block device.
* @out_uid: Return location for the user id who mounted the device or %NULL.
+ * @out_fstab_mount: Return location for whether the device was a fstab mount or %NULL.
* @error: Return location for error or %NULL.
*
* Gets the mount point for @block_device, if it exists in the
udisks_cleanup_find_mounted_fs (UDisksCleanup *cleanup,
dev_t block_device,
uid_t *out_uid,
+ gboolean *out_fstab_mount,
GError **error)
{
gchar *ret;
g_variant_unref (value);
}
}
+ if (out_fstab_mount != NULL)
+ {
+ GVariant *value;
+ value = lookup_asv (details, "fstab-mount");
+ *out_fstab_mount = FALSE;
+ if (value != NULL)
+ {
+ *out_fstab_mount = g_variant_get_boolean (value);
+ g_variant_unref (value);
+ }
+ }
g_variant_unref (block_device_value);
g_variant_unref (details);
g_variant_unref (child);
goto out;
}
}
+
escaped_mount_point_to_use = g_strescape (mount_point_to_use, NULL);
if (!udisks_daemon_launch_spawned_job_sync (daemon,
NULL, /* GCancellable */
udisks_block_device_get_device (block),
mount_point_to_use,
caller_uid);
+
+ /* update the mounted-fs file */
+ if (!udisks_cleanup_add_mounted_fs (cleanup,
+ mount_point_to_use,
+ makedev (udisks_block_device_get_major (block), udisks_block_device_get_minor (block)),
+ caller_uid,
+ TRUE, /* fstab_mounted */
+ &error))
+ {
+ g_dbus_method_invocation_take_error (invocation, error);
+ goto out;
+ }
+
udisks_filesystem_complete_mount (filesystem, invocation, mount_point_to_use);
goto out;
}
mount_point_to_use,
makedev (udisks_block_device_get_major (block), udisks_block_device_get_minor (block)),
caller_uid,
+ FALSE, /* fstab_mounted */
&error))
- goto out;
+ {
+ g_dbus_method_invocation_take_error (invocation, error);
+ goto out;
+ }
escaped_fs_type_to_use = g_strescape (fs_type_to_use, NULL);
escaped_mount_options_to_use = g_strescape (mount_options_to_use, NULL);
gboolean opt_force;
gboolean rc;
gboolean system_managed;
+ gboolean fstab_mounted;
mount_point = NULL;
escaped_mount_point = NULL;
}
/* if system-managed (e.g. referenced in /etc/fstab or similar), just
- * run mount(8) as the calling user
+ * run umount(8) as the calling user
*/
if (system_managed)
{
mount_point = udisks_cleanup_find_mounted_fs (cleanup,
makedev (udisks_block_device_get_major (block), udisks_block_device_get_minor (block)),
&mounted_by_uid,
+ &fstab_mounted,
&error);
if (error != NULL)
{