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



commit 0a2d629d2bbbaca87551f6a64832b33115fc0c64
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 | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)
---
diff --git a/gio/gio-tool-info.c b/gio/gio-tool-info.c
index 7fb8ece03..f3869d6a2 100644
--- a/gio/gio-tool-info.c
+++ b/gio/gio-tool-info.c
@@ -178,16 +178,26 @@ show_info (GFile *file, GFileInfo *info)
       if (entry != NULL)
         {
           g_autofree gchar *device = NULL;
+          const gchar *root = NULL;
+          g_autofree gchar *root_escaped = NULL;
+          g_autofree gchar *root_string = NULL;
           g_autofree gchar *mount = NULL;
           g_autofree gchar *fs = NULL;
           g_autofree gchar *options = NULL;
 
           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)
+            {
+              root_escaped = g_strescape (root, NULL);
+              root_string = g_strconcat ("[", root_escaped, "]", NULL);
+            }
           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_unix_mount_free (entry);
         }


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