[glib/wip/oholy/gio-info-mount] gio-tool-info: Print unix mount information where available



commit 6b17057dca505577cda21c30b005115234ebc6d3
Author: Simon McVittie <smcv collabora com>
Date:   Tue Jan 8 13:43:18 2019 +0000

    gio-tool-info: Print unix mount information where available
    
    "gio info" output doesn't contain any information about unix mounts, which
    is a pity, because such info can be used for debugging purposes as various
    functionality depends on g_unix_mount_at() resp. g_unix_mount_for(). Let's
    print unix mount info and local path if available.
    
    Signed-off-by: Simon McVittie <smcv collabora com>
    
    Updated by Ondrej Holy <oholy redhat com> to resolve various issues from
    https://gitlab.gnome.org/GNOME/glib/merge_requests/576.

 gio/gio-tool-info.c | 31 ++++++++++++++++++++++++++++++-
 1 file changed, 30 insertions(+), 1 deletion(-)
---
diff --git a/gio/gio-tool-info.c b/gio/gio-tool-info.c
index d6fc6b46c..133a333da 100644
--- a/gio/gio-tool-info.c
+++ b/gio/gio-tool-info.c
@@ -22,8 +22,11 @@
 #include <gio/gio.h>
 #include <gi18n.h>
 
-#include "gio-tool.h"
+#ifdef G_OS_UNIX
+#include <gio/gunixmounts.h>
+#endif
 
+#include "gio-tool.h"
 
 static gboolean writable = FALSE;
 static gboolean filesystem = FALSE;
@@ -120,6 +123,10 @@ show_info (GFile *file, GFileInfo *info)
   const char *name, *type;
   char *escaped, *uri;
   goffset size;
+  const char *path;
+#ifdef G_OS_UNIX
+  GUnixMountEntry *entry;
+#endif
 
   name = g_file_info_get_display_name (info);
   if (name)
@@ -159,6 +166,28 @@ show_info (GFile *file, GFileInfo *info)
   g_print (_("uri: %s\n"), uri);
   g_free (uri);
 
+  path = g_file_peek_path (file);
+  if (path)
+    {
+      g_print (_("local path: %s\n"), path);
+
+#ifdef G_OS_UNIX
+      entry = g_unix_mount_at (path, NULL);
+      if (entry == NULL)
+        entry = g_unix_mount_for (path, NULL);
+      if (entry != NULL)
+        {
+          g_print (_("unix mount: %s %s %s %s\n"),
+                   g_unix_mount_get_device_path (entry),
+                   g_unix_mount_get_mount_path (entry),
+                   g_unix_mount_get_fs_type (entry),
+                   g_unix_mount_get_options (entry));
+
+          g_unix_mount_free (entry);
+        }
+#endif
+    }
+
   show_attributes (info);
 }
 


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