mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-04-01 21:33:09 +02:00
Merge branch 'wip/oholy/gio-info-mount' into 'master'
gio-tool-info: Print unix mount information where available See merge request GNOME/glib!1345
This commit is contained in:
commit
f6abc575e2
@ -22,8 +22,11 @@
|
|||||||
#include <gio/gio.h>
|
#include <gio/gio.h>
|
||||||
#include <gi18n.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 writable = FALSE;
|
||||||
static gboolean filesystem = FALSE;
|
static gboolean filesystem = FALSE;
|
||||||
@ -120,6 +123,10 @@ show_info (GFile *file, GFileInfo *info)
|
|||||||
const char *name, *type;
|
const char *name, *type;
|
||||||
char *escaped, *uri;
|
char *escaped, *uri;
|
||||||
goffset size;
|
goffset size;
|
||||||
|
const char *path;
|
||||||
|
#ifdef G_OS_UNIX
|
||||||
|
GUnixMountEntry *entry;
|
||||||
|
#endif
|
||||||
|
|
||||||
name = g_file_info_get_display_name (info);
|
name = g_file_info_get_display_name (info);
|
||||||
if (name)
|
if (name)
|
||||||
@ -159,6 +166,50 @@ show_info (GFile *file, GFileInfo *info)
|
|||||||
g_print (_("uri: %s\n"), uri);
|
g_print (_("uri: %s\n"), uri);
|
||||||
g_free (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;
|
||||||
|
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 %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);
|
||||||
|
|
||||||
|
g_unix_mount_free (entry);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
show_attributes (info);
|
show_attributes (info);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user