[kdbus] KDBUS_ITEM_PAYLOAD_OFF items are (once again) relative to msg header
[platform/upstream/glib.git] / gio / gunixmounts.c
index a955e19..d8d2161 100644 (file)
@@ -15,9 +15,7 @@
  * Lesser General Public License for more details.
  *
  * You should have received a copy of the GNU Lesser General
- * Public License along with this library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place, Suite 330,
- * Boston, MA 02111-1307, USA.
+ * Public License along with this library; if not, see <http://www.gnu.org/licenses/>.
  *
  * Author: Alexander Larsson <alexl@redhat.com>
  */
 #ifdef HAVE_SYS_PARAM_H
 #include <sys/param.h>
 #endif
-#ifdef HAVE_SYS_POLL_H
-#include <sys/poll.h>
 #endif
-#endif
-#ifdef HAVE_POLL_H
+#ifdef HAVE_POLL
 #include <poll.h>
 #endif
 #include <stdio.h>
@@ -84,12 +79,12 @@ static const char *_resolve_dev_root (void);
  *
  * Routines for managing mounted UNIX mount points and paths.
  *
- * Note that <filename>&lt;gio/gunixmounts.h&gt;</filename> belongs to the
- * UNIX-specific GIO interfaces, thus you have to use the
- * <filename>gio-unix-2.0.pc</filename> pkg-config file when using it.
+ * Note that `<gio/gunixmounts.h>` belongs to the UNIX-specific GIO
+ * interfaces, thus you have to use the `gio-unix-2.0.pc` pkg-config
+ * file when using it.
  */
 
-/*
+/**
  * GUnixMountType:
  * @G_UNIX_MOUNT_TYPE_UNKNOWN: Unknown UNIX mount type.
  * @G_UNIX_MOUNT_TYPE_FLOPPY: Floppy disk UNIX mount type.
@@ -135,6 +130,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;
@@ -154,7 +150,8 @@ struct _GUnixMountMonitor {
   GFileMonitor *fstab_monitor;
   GFileMonitor *mtab_monitor;
 
-  GIOChannel *proc_mounts_channel;
+  GList *mount_poller_mounts;
+
   GSource *proc_mounts_watch_source;
 };
 
@@ -167,6 +164,8 @@ static GUnixMountMonitor *the_mount_monitor = NULL;
 static GList *_g_get_unix_mounts (void);
 static GList *_g_get_unix_mount_points (void);
 
+static guint64 mount_poller_time = 0;
+
 G_DEFINE_TYPE (GUnixMountMonitor, g_unix_mount_monitor, G_TYPE_OBJECT);
 
 #define MOUNT_POLL_INTERVAL 4000
@@ -193,6 +192,7 @@ G_DEFINE_TYPE (GUnixMountMonitor, g_unix_mount_monitor, G_TYPE_OBJECT);
 #endif
 
 #if (defined(HAVE_GETVFSSTAT) || defined(HAVE_GETFSSTAT)) && defined(HAVE_FSTAB_H) && defined(HAVE_SYS_MOUNT_H)
+#include <sys/param.h>
 #include <sys/ucred.h>
 #include <sys/mount.h>
 #include <fstab.h>
@@ -222,8 +222,7 @@ is_in (const char *value, const char *set[])
 
 /**
  * g_unix_is_mount_path_system_internal:
- * @mount_path: a mount path, e.g. <filename>/media/disk</filename> 
- *    or <filename>/usr</filename>
+ * @mount_path: a mount path, e.g. `/media/disk` or `/usr`
  *
  * Determines if @mount_path is considered an implementation of the
  * OS. This is primarily used for hiding mountable and mounted volumes
@@ -243,22 +242,31 @@ g_unix_is_mount_path_system_internal (const char *mount_path)
     "/",              /* we already have "Filesystem root" in Nautilus */ 
     "/bin",
     "/boot",
+    "/compat/linux/proc",
+    "/compat/linux/sys",
     "/dev",
     "/etc",
     "/home",
     "/lib",
     "/lib64",
+    "/libexec",
     "/live/cow",
     "/live/image",
     "/media",
     "/mnt",
     "/opt",
+    "/rescue",
     "/root",
     "/sbin",
     "/srv",
     "/tmp",
     "/usr",
+    "/usr/X11R6",
     "/usr/local",
+    "/usr/obj",
+    "/usr/ports",
+    "/usr/src",
+    "/usr/xobj",
     "/var",
     "/var/crash",
     "/var/local",
@@ -299,8 +307,11 @@ guess_system_internal (const char *mountpoint,
     "devfs",
     "devpts",
     "ecryptfs",
+    "fdescfs",
     "kernfs",
     "linprocfs",
+    "mfs",
+    "nullfs",
     "proc",
     "procfs",
     "ptyfs",
@@ -347,7 +358,7 @@ get_mtab_read_file (void)
 # else
   return _PATH_MOUNTED;
 # endif
-#else  
+#else
   return "/etc/mtab";
 #endif
 }
@@ -361,7 +372,7 @@ get_mtab_monitor_file (void)
 # else
   return _PATH_MOUNTED;
 # endif
-#else  
+#else
   return "/etc/mtab";
 #endif
 }
@@ -418,7 +429,7 @@ _g_get_unix_mounts (void)
       
       mount_entry = g_new0 (GUnixMountEntry, 1);
       mount_entry->mount_path = g_strdup (mntent->mnt_dir);
-      if (strcmp (mntent->mnt_fsname, "/dev/root") == 0)
+      if (g_strcmp0 (mntent->mnt_fsname, "/dev/root") == 0)
         mount_entry->device_path = g_strdup (_resolve_dev_root ());
       else
         mount_entry->device_path = g_strdup (mntent->mnt_fsname);
@@ -602,9 +613,9 @@ get_mtab_monitor_file (void)
 static GList *
 _g_get_unix_mounts (void)
 {
-#if defined(HAVE_GETVFSSTAT)
+#if defined(USE_STATVFS)
   struct statvfs *mntent = NULL;
-#elif defined(HAVE_GETFSSTAT)
+#elif defined(USE_STATFS)
   struct statfs *mntent = NULL;
 #else
   #error statfs juggling failed
@@ -615,9 +626,9 @@ _g_get_unix_mounts (void)
   GList *return_list;
   
   /* Pass NOWAIT to avoid blocking trying to update NFS mounts. */
-#if defined(HAVE_GETVFSSTAT)
+#if defined(USE_STATVFS) && defined(HAVE_GETVFSSTAT)
   num_mounts = getvfsstat (NULL, 0, ST_NOWAIT);
-#elif defined(HAVE_GETFSSTAT)
+#elif defined(USE_STATFS) && defined(HAVE_GETFSSTAT)
   num_mounts = getfsstat (NULL, 0, MNT_NOWAIT);
 #endif
   if (num_mounts == -1)
@@ -625,9 +636,9 @@ _g_get_unix_mounts (void)
 
   bufsize = num_mounts * sizeof (*mntent);
   mntent = g_malloc (bufsize);
-#if defined(HAVE_GETVFSSTAT)
+#if defined(USE_STATVFS) && defined(HAVE_GETVFSSTAT)
   num_mounts = getvfsstat (mntent, bufsize, ST_NOWAIT);
-#elif defined(HAVE_GETFSSTAT)
+#elif defined(USE_STATFS) && defined(HAVE_GETFSSTAT)
   num_mounts = getfsstat (mntent, bufsize, MNT_NOWAIT);
 #endif
   if (num_mounts == -1)
@@ -642,10 +653,13 @@ _g_get_unix_mounts (void)
       mount_entry->mount_path = g_strdup (mntent[i].f_mntonname);
       mount_entry->device_path = g_strdup (mntent[i].f_mntfromname);
       mount_entry->filesystem_type = g_strdup (mntent[i].f_fstypename);
-#if defined(HAVE_GETVFSSTAT)
+
+#if defined(USE_STATVFS)
       if (mntent[i].f_flag & ST_RDONLY)
-#elif defined(HAVE_GETFSSTAT)
+#elif defined(USE_STATFS)
       if (mntent[i].f_flags & MNT_RDONLY)
+#else
+      #error statfs juggling failed
 #endif
         mount_entry->is_read_only = TRUE;
 
@@ -774,6 +788,12 @@ _g_get_unix_mount_points (void)
           (strcmp (mntent->mnt_dir, "none") == 0))
        continue;
 
+#ifdef HAVE_HASMNTOPT
+      /* We ignore bind fstab entries, as we ignore bind mounts anyway */
+      if (hasmntopt (mntent, "bind"))
+        continue;
+#endif
+
       mount_entry = g_new0 (GUnixMountPoint, 1);
       mount_entry->mount_path = g_strdup (mntent->mnt_dir);
       if (strcmp (mntent->mnt_fsname, "/dev/root") == 0)
@@ -781,6 +801,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)
@@ -846,6 +867,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)
@@ -1010,6 +1032,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;
          
@@ -1073,6 +1096,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;
@@ -1116,7 +1140,11 @@ get_mounts_timestamp (void)
   if (monitor_file)
     {
       if (stat (monitor_file, &buf) == 0)
-       return (guint64)buf.st_mtime;
+        return (guint64)buf.st_mtime;
+    }
+  else
+    {
+      return mount_poller_time;
     }
   return 0;
 }
@@ -1131,7 +1159,7 @@ get_mount_points_timestamp (void)
   if (monitor_file)
     {
       if (stat (monitor_file, &buf) == 0)
-       return (guint64)buf.st_mtime;
+        return (guint64)buf.st_mtime;
     }
   return 0;
 }
@@ -1183,9 +1211,9 @@ g_unix_mount_at (const char *mount_path,
       mount_entry = l->data;
 
       if (!found && strcmp (mount_path, mount_entry->mount_path) == 0)
-       found = mount_entry;
+        found = mount_entry;
       else
-       g_unix_mount_free (mount_entry);
+        g_unix_mount_free (mount_entry);
     }
   g_list_free (mounts);
 
@@ -1254,8 +1282,6 @@ g_unix_mount_monitor_finalize (GObject *object)
       g_object_unref (monitor->fstab_monitor);
     }
   
-  if (monitor->proc_mounts_channel != NULL)
-    g_io_channel_unref (monitor->proc_mounts_channel);
   if (monitor->proc_mounts_watch_source != NULL)
     g_source_destroy (monitor->proc_mounts_watch_source);
 
@@ -1265,6 +1291,8 @@ g_unix_mount_monitor_finalize (GObject *object)
       g_object_unref (monitor->mtab_monitor);
     }
 
+  g_list_free_full (monitor->mount_poller_mounts, (GDestroyNotify)g_unix_mount_free);
+
   the_mount_monitor = NULL;
 
   G_OBJECT_CLASS (g_unix_mount_monitor_parent_class)->finalize (object);
@@ -1351,10 +1379,45 @@ proc_mounts_changed (GIOChannel   *channel,
                      gpointer      user_data)
 {
   GUnixMountMonitor *mount_monitor = G_UNIX_MOUNT_MONITOR (user_data);
-  if (cond & ~G_IO_ERR)
-    goto out;
-  g_signal_emit (mount_monitor, signals[MOUNTS_CHANGED], 0);
- out:
+  if (cond & G_IO_ERR)
+    g_signal_emit (mount_monitor, signals[MOUNTS_CHANGED], 0);
+  return TRUE;
+}
+
+static gboolean
+mount_change_poller (gpointer user_data)
+{
+  GUnixMountMonitor *mount_monitor;
+  GList *current_mounts, *new_it, *old_it;
+  gboolean has_changed = FALSE;
+
+  mount_monitor = user_data;
+  current_mounts = _g_get_unix_mounts ();
+
+  for ( new_it = current_mounts, old_it = mount_monitor->mount_poller_mounts;
+        new_it != NULL && old_it != NULL;
+        new_it = g_list_next (new_it), old_it = g_list_next (old_it) )
+    {
+      if (g_unix_mount_compare (new_it->data, old_it->data) != 0)
+        {
+          has_changed = TRUE;
+          break;
+        }
+    }
+  if (!(new_it == NULL && old_it == NULL))
+    has_changed = TRUE;
+
+  g_list_free_full (mount_monitor->mount_poller_mounts,
+                    (GDestroyNotify)g_unix_mount_free);
+
+  mount_monitor->mount_poller_mounts = current_mounts;
+
+  if (has_changed)
+    {
+      mount_poller_time = (guint64)g_get_monotonic_time ();
+      g_signal_emit (mount_monitor, signals[MOUNTS_CHANGED], 0);
+    }
+
   return TRUE;
 }
 
@@ -1377,27 +1440,53 @@ g_unix_mount_monitor_init (GUnixMountMonitor *monitor)
       const gchar *mtab_path;
 
       mtab_path = get_mtab_monitor_file ();
-      /* /proc/mounts monitoring is special - can't just use GFileMonitor */
+      /* /proc/mounts monitoring is special - can't just use GFileMonitor.
+       * See 'man proc' for more details.
+       */
       if (g_strcmp0 (mtab_path, "/proc/mounts") == 0)
         {
-          monitor->proc_mounts_channel = g_io_channel_new_file ("/proc/mounts", "r", NULL);
-          monitor->proc_mounts_watch_source = g_io_create_watch (monitor->proc_mounts_channel, G_IO_ERR);
-          g_source_set_callback (monitor->proc_mounts_watch_source,
-                                 (GSourceFunc) proc_mounts_changed,
-                                 monitor,
-                                 NULL);
-          g_source_attach (monitor->proc_mounts_watch_source,
-                           g_main_context_get_thread_default ());
-          g_source_unref (monitor->proc_mounts_watch_source);
+          GIOChannel *proc_mounts_channel;
+          GError *error = NULL;
+          proc_mounts_channel = g_io_channel_new_file ("/proc/mounts", "r", &error);
+          if (proc_mounts_channel == NULL)
+            {
+              g_warning ("Error creating IO channel for /proc/mounts: %s (%s, %d)",
+                         error->message, g_quark_to_string (error->domain), error->code);
+              g_error_free (error);
+            }
+          else
+            {
+              monitor->proc_mounts_watch_source = g_io_create_watch (proc_mounts_channel, G_IO_ERR);
+              g_source_set_callback (monitor->proc_mounts_watch_source,
+                                     (GSourceFunc) proc_mounts_changed,
+                                     monitor,
+                                     NULL);
+              g_source_attach (monitor->proc_mounts_watch_source,
+                               g_main_context_get_thread_default ());
+              g_source_unref (monitor->proc_mounts_watch_source);
+              g_io_channel_unref (proc_mounts_channel);
+            }
         }
       else
         {
-          file = g_file_new_for_path (get_mtab_monitor_file ());
+          file = g_file_new_for_path (mtab_path);
           monitor->mtab_monitor = g_file_monitor_file (file, 0, NULL, NULL);
           g_object_unref (file);
           g_signal_connect (monitor->mtab_monitor, "changed", (GCallback)mtab_file_changed, monitor);
         }
     }
+  else
+    {
+      monitor->proc_mounts_watch_source = g_timeout_source_new_seconds (3);
+      monitor->mount_poller_mounts = _g_get_unix_mounts ();
+      mount_poller_time = (guint64)g_get_monotonic_time ();
+      g_source_set_callback (monitor->proc_mounts_watch_source,
+                             (GSourceFunc)mount_change_poller,
+                             monitor, NULL);
+      g_source_attach (monitor->proc_mounts_watch_source,
+                       g_main_context_get_thread_default ());
+      g_source_unref (monitor->proc_mounts_watch_source);
+    }
 }
 
 /**
@@ -1448,7 +1537,7 @@ g_unix_mount_monitor_new (void)
 
 /**
  * g_unix_mount_free:
- * @mount_entry: a #GUnixMount.
+ * @mount_entry: a #GUnixMountEntry.
  * 
  * Frees a unix mount.
  */
@@ -1477,6 +1566,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);
 }
 
@@ -1627,6 +1717,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;
@@ -1691,6 +1785,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.
  * 
@@ -1818,7 +1930,7 @@ guess_mount_type (const char *mount_path,
   return type;
 }
 
-/*
+/**
  * g_unix_mount_guess_type:
  * @mount_entry: a #GUnixMount.
  * 
@@ -1840,7 +1952,7 @@ g_unix_mount_guess_type (GUnixMountEntry *mount_entry)
                           mount_entry->filesystem_type);
 }
 
-/*
+/**
  * g_unix_mount_point_guess_type:
  * @mount_point: a #GUnixMountPoint.
  * 
@@ -1864,7 +1976,7 @@ g_unix_mount_point_guess_type (GUnixMountPoint *mount_point)
 }
 
 static const char *
-type_to_icon (GUnixMountType type, gboolean is_mount_point)
+type_to_icon (GUnixMountType type, gboolean is_mount_point, gboolean use_symbolic)
 {
   const char *icon_name;
   
@@ -1872,55 +1984,51 @@ type_to_icon (GUnixMountType type, gboolean is_mount_point)
     {
     case G_UNIX_MOUNT_TYPE_HD:
       if (is_mount_point)
-        icon_name = "drive-removable-media";
+        icon_name = use_symbolic ? "drive-removable-media-symbolic" : "drive-removable-media";
       else
-        icon_name = "drive-harddisk";
+        icon_name = use_symbolic ? "drive-harddisk-symbolic" : "drive-harddisk";
       break;
     case G_UNIX_MOUNT_TYPE_FLOPPY:
     case G_UNIX_MOUNT_TYPE_ZIP:
     case G_UNIX_MOUNT_TYPE_JAZ:
       if (is_mount_point)
-        icon_name = "drive-removable-media";
+        icon_name = use_symbolic ? "drive-removable-media-symbolic" : "drive-removable-media";
       else
-        icon_name = "media-floppy";
+        icon_name = use_symbolic ? "media-removable-symbolic" : "media-floppy";
       break;
     case G_UNIX_MOUNT_TYPE_CDROM:
       if (is_mount_point)
-        icon_name = "drive-optical";
+        icon_name = use_symbolic ? "drive-optical-symbolic" : "drive-optical";
       else
-        icon_name = "media-optical";
+        icon_name = use_symbolic ? "media-optical-symbolic" : "media-optical";
       break;
     case G_UNIX_MOUNT_TYPE_NFS:
-      /* TODO: Would like a better icon here... */
-      if (is_mount_point)
-        icon_name = "drive-removable-media";
-      else
-        icon_name = "drive-harddisk";
+        icon_name = use_symbolic ? "folder-remote-symbolic" : "folder-remote";
       break;
     case G_UNIX_MOUNT_TYPE_MEMSTICK:
       if (is_mount_point)
-        icon_name = "drive-removable-media";
+        icon_name = use_symbolic ? "drive-removable-media-symbolic" : "drive-removable-media";
       else
-        icon_name = "media-flash";
+        icon_name = use_symbolic ? "media-removable-symbolic" : "media-flash";
       break;
     case G_UNIX_MOUNT_TYPE_CAMERA:
       if (is_mount_point)
-        icon_name = "drive-removable-media";
+        icon_name = use_symbolic ? "drive-removable-media-symbolic" : "drive-removable-media";
       else
-        icon_name = "camera-photo";
+        icon_name = use_symbolic ? "camera-photo-symbolic" : "camera-photo";
       break;
     case G_UNIX_MOUNT_TYPE_IPOD:
       if (is_mount_point)
-        icon_name = "drive-removable-media";
+        icon_name = use_symbolic ? "drive-removable-media-symbolic" : "drive-removable-media";
       else
-        icon_name = "multimedia-player";
+        icon_name = use_symbolic ? "multimedia-player-symbolic" : "multimedia-player";
       break;
     case G_UNIX_MOUNT_TYPE_UNKNOWN:
     default:
       if (is_mount_point)
-        icon_name = "drive-removable-media";
+        icon_name = use_symbolic ? "drive-removable-media-symbolic" : "drive-removable-media";
       else
-        icon_name = "drive-harddisk";
+        icon_name = use_symbolic ? "drive-harddisk-symbolic" : "drive-harddisk";
       break;
     }
 
@@ -1961,7 +2069,23 @@ g_unix_mount_guess_name (GUnixMountEntry *mount_entry)
 GIcon *
 g_unix_mount_guess_icon (GUnixMountEntry *mount_entry)
 {
-  return g_themed_icon_new_with_default_fallbacks (type_to_icon (g_unix_mount_guess_type (mount_entry), FALSE));
+  return g_themed_icon_new_with_default_fallbacks (type_to_icon (g_unix_mount_guess_type (mount_entry), FALSE, FALSE));
+}
+
+/**
+ * g_unix_mount_guess_symbolic_icon:
+ * @mount_entry: a #GUnixMountEntry
+ *
+ * Guesses the symbolic icon of a Unix mount.
+ *
+ * Returns: (transfer full): a #GIcon
+ *
+ * Since: 2.34
+ */
+GIcon *
+g_unix_mount_guess_symbolic_icon (GUnixMountEntry *mount_entry)
+{
+  return g_themed_icon_new_with_default_fallbacks (type_to_icon (g_unix_mount_guess_type (mount_entry), FALSE, TRUE));
 }
 
 /**
@@ -1998,7 +2122,23 @@ g_unix_mount_point_guess_name (GUnixMountPoint *mount_point)
 GIcon *
 g_unix_mount_point_guess_icon (GUnixMountPoint *mount_point)
 {
-  return g_themed_icon_new_with_default_fallbacks (type_to_icon (g_unix_mount_point_guess_type (mount_point), TRUE));
+  return g_themed_icon_new_with_default_fallbacks (type_to_icon (g_unix_mount_point_guess_type (mount_point), TRUE, FALSE));
+}
+
+/**
+ * g_unix_mount_point_guess_symbolic_icon:
+ * @mount_point: a #GUnixMountPoint
+ *
+ * Guesses the symbolic icon of a Unix mount point.
+ *
+ * Returns: (transfer full): a #GIcon
+ *
+ * Since: 2.34
+ */
+GIcon *
+g_unix_mount_point_guess_symbolic_icon (GUnixMountPoint *mount_point)
+{
+  return g_themed_icon_new_with_default_fallbacks (type_to_icon (g_unix_mount_point_guess_type (mount_point), TRUE, TRUE));
 }
 
 /**
@@ -2034,13 +2174,15 @@ gboolean
 g_unix_mount_guess_should_display (GUnixMountEntry *mount_entry)
 {
   const char *mount_path;
+  const gchar *user_name;
+  gsize user_name_len;
 
   /* Never display internal mountpoints */
   if (g_unix_mount_is_system_internal (mount_entry))
     return FALSE;
   
   /* Only display things in /media (which are generally user mountable)
-     and home dir (fuse stuff) and $XDG_RUNTIME_DIR */
+     and home dir (fuse stuff) and /run/media/$USER */
   mount_path = mount_entry->mount_path;
   if (mount_path != NULL)
     {
@@ -2049,7 +2191,12 @@ g_unix_mount_guess_should_display (GUnixMountEntry *mount_entry)
       if (g_strstr_len (mount_path, -1, "/.") != NULL)
         return FALSE;
 
-      if (g_getenv ("XDG_RUNTIME_DIR") != NULL && g_str_has_prefix (mount_path, g_get_user_runtime_dir ()))
+      /* Check /run/media/$USER/ */
+      user_name = g_get_user_name ();
+      user_name_len = strlen (user_name);
+      if (strncmp (mount_path, "/run/media/", sizeof ("/run/media/") - 1) == 0 &&
+          strncmp (mount_path + sizeof ("/run/media/") - 1, user_name, user_name_len) == 0 &&
+          mount_path[sizeof ("/run/media/") - 1 + user_name_len] == '/')
         is_in_runtime_dir = TRUE;
 
       if (is_in_runtime_dir || g_str_has_prefix (mount_path, "/media/"))
@@ -2239,7 +2386,6 @@ _resolve_dev_root (void)
         {
           dev_t root_dev = statbuf.st_dev;
           FILE *f;
-          char buf[1024];
       
           /* see if device with similar major:minor as /dev/root is mention
            * in /etc/mtab (it usually is) 
@@ -2250,6 +2396,7 @@ _resolve_dev_root (void)
              struct mntent *entp;
 #ifdef HAVE_GETMNTENT_R        
               struct mntent ent;
+              char buf[1024];
               while ((entp = getmntent_r (f, &ent, buf, sizeof (buf))) != NULL) 
                 {
 #else