mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2024-12-27 07:56:14 +01:00
Monitor /proc/self/mountinfo when using libmount
https://bugzilla.gnome.org/show_bug.cgi?id=522053
This commit is contained in:
parent
97f799b53a
commit
f885c4dd0d
@ -375,6 +375,11 @@ create_unix_mount_point (const char *device_path,
|
|||||||
|
|
||||||
#ifdef HAVE_LIBMOUNT
|
#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 *
|
static GList *
|
||||||
_g_get_unix_mounts (void)
|
_g_get_unix_mounts (void)
|
||||||
{
|
{
|
||||||
@ -386,7 +391,7 @@ _g_get_unix_mounts (void)
|
|||||||
GList *return_list = NULL;
|
GList *return_list = NULL;
|
||||||
|
|
||||||
ctxt = mnt_new_context ();
|
ctxt = mnt_new_context ();
|
||||||
mnt_context_get_table (ctxt, "/proc/self/mountinfo", &table);
|
mnt_context_get_table (ctxt, PROC_MOUNTINFO_PATH, &table);
|
||||||
if (!table)
|
if (!table)
|
||||||
mnt_context_get_mtab (ctxt, &table);
|
mnt_context_get_mtab (ctxt, &table);
|
||||||
|
|
||||||
@ -537,15 +542,34 @@ _g_get_unix_mounts (void)
|
|||||||
static char *
|
static char *
|
||||||
get_mtab_monitor_file (void)
|
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 _PATH_MOUNTED
|
||||||
# ifdef __linux__
|
# ifdef __linux__
|
||||||
return "/proc/mounts";
|
mountinfo_path = "/proc/mounts";
|
||||||
# else
|
# else
|
||||||
return _PATH_MOUNTED;
|
mountinfo_path = _PATH_MOUNTED;
|
||||||
# endif
|
# endif
|
||||||
#else
|
#else
|
||||||
return "/etc/mtab";
|
mountinfo_path = "/etc/mtab";
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
return mountinfo_path;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* mnttab.h {{{2 */
|
/* mnttab.h {{{2 */
|
||||||
|
Loading…
Reference in New Issue
Block a user