[glib/wip/oholy/gio-info-mount: 2/2] gio-tool-info: Print also root path if available



commit a74585350c8ce19a39d8843e4a08c0d2a488a08f
Author: Ondrej Holy <oholy redhat com>
Date:   Mon Feb 3 11:50:32 2020 +0100

    gio-tool-info: Print also root path if available
    
    "gio info" got support to print information about mount points,
    let's print also root path similarly as it is done by findmnt.

 gio/gio-tool-info.c | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)
---
diff --git a/gio/gio-tool-info.c b/gio/gio-tool-info.c
index 3d37268d4..7cf568370 100644
--- a/gio/gio-tool-info.c
+++ b/gio/gio-tool-info.c
@@ -178,18 +178,29 @@ show_info (GFile *file, GFileInfo *info)
       if (entry != NULL)
         {
           gchar *device;
+          const gchar *root;
+          gchar *root_string = NULL;
           gchar *mount;
           gchar *fs;
           gchar *options;
 
           device = g_strescape (g_unix_mount_get_device_path (entry), NULL);
+          root = g_unix_mount_get_root_path (entry);
+          if (root != NULL && g_strcmp0 (root, "/") != 0)
+            {
+              escaped = g_strescape (root, NULL);
+              root_string = g_strconcat ("[", escaped, "]", NULL);
+              g_free (escaped);
+            }
           mount = g_strescape (g_unix_mount_get_mount_path (entry), NULL);
           fs = g_strescape (g_unix_mount_get_fs_type (entry), NULL);
           options = g_strescape (g_unix_mount_get_options (entry), NULL);
 
-          g_print (_("unix mount: %s %s %s %s\n"), device, mount, fs, options);
+          g_print (_("unix mount: %s%s %s %s %s\n"), device,
+                   root_string ? root_string : "", mount, fs, options);
 
           g_free (device);
+          g_free (root_string);
           g_free (mount);
           g_free (fs);
           g_free (options);


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