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>
This commit is contained in:
Simon McVittie 2019-01-08 13:43:18 +00:00 committed by Philip Withnall
parent 260cff0e5f
commit 3e10ce89f4

View File

@ -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);
}