[gvfs/wip/oholy/bind-mounts: 4/5] build: Use g_unix_mount_get_root_path conditionally



commit a041512cf791e8a827b94e805f8bdf192af977a2
Author: Ondrej Holy <oholy redhat com>
Date:   Fri Dec 7 12:02:51 2018 +0100

    build: Use g_unix_mount_get_root_path conditionally
    
    GLib hasn't been released with g_unix_mount_get_root_path support yet,
    so let's add macros to use this functionality only if available.

 meson.build                                |  2 ++
 monitor/udisks2/gvfsudisks2volumemonitor.c | 18 +++++++++++++++---
 2 files changed, 17 insertions(+), 3 deletions(-)
---
diff --git a/meson.build b/meson.build
index 26877b6c..356c3442 100644
--- a/meson.build
+++ b/meson.build
@@ -227,6 +227,8 @@ gio_unix_dep = dependency('gio-unix-2.0')
 glib_dep = dependency('glib-2.0', version: '>= 2.57.2')
 gobject_dep = dependency('gobject-2.0')
 
+config_h.set('HAVE_G_UNIX_MOUNT_GET_ROOT_PATH', cc.has_function('g_unix_mount_get_root_path', dependencies: 
gio_dep))
+
 # *** Check for libXML ***
 libxml_dep = dependency('libxml-2.0', required: false)
 have_libxml = libxml_dep.found()
diff --git a/monitor/udisks2/gvfsudisks2volumemonitor.c b/monitor/udisks2/gvfsudisks2volumemonitor.c
index 2b2285f9..0a5ce96e 100644
--- a/monitor/udisks2/gvfsudisks2volumemonitor.c
+++ b/monitor/udisks2/gvfsudisks2volumemonitor.c
@@ -760,7 +760,11 @@ should_include_volume_check_mount_points (GVfsUDisks2VolumeMonitor *monitor,
       mount_entry = g_unix_mount_at (mount_point, NULL);
       if (mount_entry != NULL)
         {
-          const gchar *root = g_unix_mount_get_root_path (mount_entry);
+          const gchar *root = NULL;
+
+#ifdef HAVE_G_UNIX_MOUNT_GET_ROOT_PATH
+          root = g_unix_mount_get_root_path (mount_entry);
+#endif
 
           if ((root == NULL || g_strcmp0 (root, "/") == 0) &&
               should_include_mount (monitor, mount_entry))
@@ -1709,7 +1713,11 @@ update_mounts (GVfsUDisks2VolumeMonitor  *monitor,
   for (l = added; l != NULL; l = l->next)
     {
       GUnixMountEntry *mount_entry = l->data;
-      const gchar *root = g_unix_mount_get_root_path (mount_entry);
+      const gchar *root = NULL;
+
+#ifdef HAVE_G_UNIX_MOUNT_GET_ROOT_PATH
+      root = g_unix_mount_get_root_path (mount_entry);
+#endif
 
       volume = NULL;
       if (root == NULL || g_strcmp0 (root, "/") == 0)
@@ -1745,7 +1753,11 @@ update_mounts (GVfsUDisks2VolumeMonitor  *monitor,
         }
       if (gvfs_udisks2_mount_get_volume (mount) == NULL)
         {
-          const gchar *root = g_unix_mount_get_root_path (mount_entry);
+          const gchar *root = NULL;
+
+#ifdef HAVE_G_UNIX_MOUNT_GET_ROOT_PATH
+          root = g_unix_mount_get_root_path (mount_entry);
+#endif
 
           volume = NULL;
           if (root == NULL || g_strcmp0 (root, "/") == 0)


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