GUnixMountPoint: expose options
authorDavid Zeuthen <davidz@redhat.com>
Fri, 30 Sep 2011 03:46:28 +0000 (23:46 -0400)
committerDavid Zeuthen <davidz@redhat.com>
Mon, 3 Oct 2011 18:06:47 +0000 (14:06 -0400)
Make the options from an /etc/fstab entry available as public API -
this can be used to support options such as

 comment=gvfs.name=Foo\040Bar

to e.g. set the name of an fstab mount in the UI to "Foo Bar".

https://bugzilla.gnome.org/show_bug.cgi?id=660536

Signed-off-by: David Zeuthen <davidz@redhat.com>
docs/reference/gio/gio-sections.txt
gio/gio.symbols
gio/gunixmounts.c
gio/gunixmounts.h

index 87beb77..f14fc3b 100644 (file)
@@ -1369,6 +1369,7 @@ g_unix_mount_point_compare
 g_unix_mount_point_get_mount_path
 g_unix_mount_point_get_device_path
 g_unix_mount_point_get_fs_type
+g_unix_mount_point_get_options
 g_unix_mount_point_is_readonly
 g_unix_mount_point_is_user_mountable
 g_unix_mount_point_is_loopback
index abe4b95..3bc3be5 100644 (file)
@@ -629,6 +629,7 @@ g_unix_mount_point_compare
 g_unix_mount_point_get_mount_path
 g_unix_mount_point_get_device_path
 g_unix_mount_point_get_fs_type
+g_unix_mount_point_get_options
 g_unix_mount_point_is_readonly
 g_unix_mount_point_is_user_mountable
 g_unix_mount_point_is_loopback
index 36201c6..4cc87cd 100644 (file)
@@ -135,6 +135,7 @@ struct _GUnixMountPoint {
   char *mount_path;
   char *device_path;
   char *filesystem_type;
+  char *options;
   gboolean is_read_only;
   gboolean is_user_mountable;
   gboolean is_loopback;
@@ -780,6 +781,7 @@ _g_get_unix_mount_points (void)
       else
         mount_entry->device_path = g_strdup (mntent->mnt_fsname);
       mount_entry->filesystem_type = g_strdup (mntent->mnt_type);
+      mount_entry->options = g_strdup (mntent->mnt_opts);
       
 #ifdef HAVE_HASMNTOPT
       if (hasmntopt (mntent, MNTOPT_RO) != NULL)
@@ -845,6 +847,7 @@ _g_get_unix_mount_points (void)
       mount_entry->mount_path = g_strdup (mntent.mnt_mountp);
       mount_entry->device_path = g_strdup (mntent.mnt_special);
       mount_entry->filesystem_type = g_strdup (mntent.mnt_fstype);
+      mount_entry->options = g_strdup (mntent.mnt_mntopts);
       
 #ifdef HAVE_HASMNTOPT
       if (hasmntopt (&mntent, MNTOPT_RO) != NULL)
@@ -1009,6 +1012,7 @@ _g_get_unix_mount_points (void)
          mount_entry->mount_path = g_strdup (mntent.mnt_mount);
          mount_entry->device_path = g_strdup (mntent.mnt_special);
          mount_entry->filesystem_type = g_strdup (mntent.mnt_fstype);
+         mount_entry->options = g_strdup (mntent.mnt_options);
          mount_entry->is_read_only = TRUE;
          mount_entry->is_user_mountable = TRUE;
          
@@ -1072,6 +1076,7 @@ _g_get_unix_mount_points (void)
       mount_entry->mount_path = g_strdup (fstab->fs_file);
       mount_entry->device_path = g_strdup (fstab->fs_spec);
       mount_entry->filesystem_type = g_strdup (fstab->fs_vfstype);
+      mount_entry->options = g_strdup (fstab->fs_mntops);
       
       if (strcmp (fstab->fs_type, "ro") == 0)
        mount_entry->is_read_only = TRUE;
@@ -1486,6 +1491,7 @@ g_unix_mount_point_free (GUnixMountPoint *mount_point)
   g_free (mount_point->mount_path);
   g_free (mount_point->device_path);
   g_free (mount_point->filesystem_type);
+  g_free (mount_point->options);
   g_free (mount_point);
 }
 
@@ -1636,6 +1642,10 @@ g_unix_mount_point_compare (GUnixMountPoint *mount1,
   if (res != 0) 
     return res;
 
+  res = g_strcmp0 (mount1->options, mount2->options);
+  if (res != 0) 
+    return res;
+
   res =  mount1->is_read_only - mount2->is_read_only;
   if (res != 0) 
     return res;
@@ -1700,6 +1710,24 @@ g_unix_mount_point_get_fs_type (GUnixMountPoint *mount_point)
 }
 
 /**
+ * g_unix_mount_point_get_options:
+ * @mount_point: a #GUnixMountPoint.
+ * 
+ * Gets the options for the mount point.
+ * 
+ * Returns: a string containing the options.
+ *
+ * Since: 2.32
+ */
+const gchar *
+g_unix_mount_point_get_options (GUnixMountPoint *mount_point)
+{
+  g_return_val_if_fail (mount_point != NULL, NULL);
+
+  return mount_point->options;
+}
+
+/**
  * g_unix_mount_point_is_readonly:
  * @mount_point: a #GUnixMountPoint.
  * 
index 55aa3cc..ea67244 100644 (file)
@@ -76,6 +76,7 @@ gint           g_unix_mount_point_compare           (GUnixMountPoint    *mount1,
 const char *   g_unix_mount_point_get_mount_path    (GUnixMountPoint    *mount_point);
 const char *   g_unix_mount_point_get_device_path   (GUnixMountPoint    *mount_point);
 const char *   g_unix_mount_point_get_fs_type       (GUnixMountPoint    *mount_point);
+const char *   g_unix_mount_point_get_options       (GUnixMountPoint    *mount_point);
 gboolean       g_unix_mount_point_is_readonly       (GUnixMountPoint    *mount_point);
 gboolean       g_unix_mount_point_is_user_mountable (GUnixMountPoint    *mount_point);
 gboolean       g_unix_mount_point_is_loopback       (GUnixMountPoint    *mount_point);