diff options
author | Mario Sanchez Prada <mario@endlessm.com> | 2016-05-20 16:59:02 +0100 |
---|---|---|
committer | Mario Sanchez Prada <mario@endlessm.com> | 2016-07-19 13:31:24 +0100 |
commit | cc5a9009544b6b1d00d2187249cd66e641e92e69 (patch) | |
tree | 5c0cbbd46e9f83d35c94de80694ca91ba065575a | |
parent | efeaf537019935cad99bdfbaf241b506299c4ef5 (diff) | |
download | glib-wip/msanchez/libmount.tar.gz |
Monitor /proc/self/mountinfo when using libmountwip/msanchez/libmount
https://bugzilla.gnome.org/show_bug.cgi?id=522053
-rw-r--r-- | gio/gunixmounts.c | 32 |
1 files changed, 28 insertions, 4 deletions
diff --git a/gio/gunixmounts.c b/gio/gunixmounts.c index 8de44b5b8..e11178826 100644 --- a/gio/gunixmounts.c +++ b/gio/gunixmounts.c @@ -375,6 +375,11 @@ create_unix_mount_point (const char *device_path, #ifdef HAVE_LIBMOUNT +/* For documentation on /proc/self/mountinfo see + * http://www.kernel.org/doc/Documentation/filesystems/proc.txt + */ +#define PROC_MOUNTINFO_PATH "/proc/self/mountinfo" + static GList * _g_get_unix_mounts (void) { @@ -386,7 +391,7 @@ _g_get_unix_mounts (void) GList *return_list = NULL; ctxt = mnt_new_context (); - mnt_context_get_table (ctxt, "/proc/self/mountinfo", &table); + mnt_context_get_table (ctxt, PROC_MOUNTINFO_PATH, &table); if (!table) mnt_context_get_mtab (ctxt, &table); @@ -537,15 +542,34 @@ _g_get_unix_mounts (void) static char * get_mtab_monitor_file (void) { + static char *mountinfo_path = NULL; +#ifdef HAVE_LIBMOUNT + struct stat buf; +#endif + + if (mountinfo_path != NULL) + return mountinfo_path; + +#ifdef HAVE_LIBMOUNT + /* If using libmount we'll have the logic in place to read mountinfo */ + if (stat (PROC_MOUNTINFO_PATH, &buf) == 0) + { + mountinfo_path = PROC_MOUNTINFO_PATH; + return mountinfo_path; + } +#endif + #ifdef _PATH_MOUNTED # ifdef __linux__ - return "/proc/mounts"; + mountinfo_path = "/proc/mounts"; # else - return _PATH_MOUNTED; + mountinfo_path = _PATH_MOUNTED; # endif #else - return "/etc/mtab"; + mountinfo_path = "/etc/mtab"; #endif + + return mountinfo_path; } /* mnttab.h {{{2 */ |