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



commit 3e10ce89f454372da8a902e4483d2f50f35ff8c4
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 mount points, but
    that information can be useful when debugging issues in facilities that
    depend on knowing about mount points, such as the trash API.
    
    Signed-off-by: Simon McVittie <smcv collabora com>
    Co-authored-by: Ondrej Holy <oholy redhat com>

 gio/gio-tool-info.c | 42 +++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 41 insertions(+), 1 deletion(-)
---
diff --git a/gio/gio-tool-info.c b/gio/gio-tool-info.c
index d6fc6b46c..3d37268d4 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,39 @@ 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)
+        {
+          gchar *device;
+          gchar *mount;
+          gchar *fs;
+          gchar *options;
+
+          device = g_strescape (g_unix_mount_get_device_path (entry), 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_free (device);
+          g_free (mount);
+          g_free (fs);
+          g_free (options);
+
+          g_unix_mount_free (entry);
+        }
+#endif
+    }
+
   show_attributes (info);
 }
 


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