[glib] GUnixMountPoint: expose options



commit 3f982cb9ab1dc9a435c5bba2f0438f165eba25dc
Author: David Zeuthen <davidz redhat com>
Date:   Thu Sep 29 23:46:28 2011 -0400

    GUnixMountPoint: expose options
    
    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 |    1 +
 gio/gio.symbols                     |    1 +
 gio/gunixmounts.c                   |   28 ++++++++++++++++++++++++++++
 gio/gunixmounts.h                   |    1 +
 4 files changed, 31 insertions(+), 0 deletions(-)
---
diff --git a/docs/reference/gio/gio-sections.txt b/docs/reference/gio/gio-sections.txt
index 87beb77..f14fc3b 100644
--- a/docs/reference/gio/gio-sections.txt
+++ b/docs/reference/gio/gio-sections.txt
@@ -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
diff --git a/gio/gio.symbols b/gio/gio.symbols
index abe4b95..3bc3be5 100644
--- a/gio/gio.symbols
+++ b/gio/gio.symbols
@@ -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
diff --git a/gio/gunixmounts.c b/gio/gunixmounts.c
index 36201c6..4cc87cd 100644
--- a/gio/gunixmounts.c
+++ b/gio/gunixmounts.c
@@ -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.
  * 
diff --git a/gio/gunixmounts.h b/gio/gunixmounts.h
index 55aa3cc..ea67244 100644
--- a/gio/gunixmounts.h
+++ b/gio/gunixmounts.h
@@ -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);



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]