Merge branch 'getfsent_lock2' into 'main'

_g_get_unix_mount_points(): reduce syscalls inside loop

See merge request GNOME/glib!2783
This commit is contained in:
Philip Withnall 2022-06-27 11:14:01 +00:00
commit 3c47fa6e20

View File

@ -1412,6 +1412,7 @@ _g_get_unix_mount_points (void)
GUnixMountPoint *mount_point; GUnixMountPoint *mount_point;
GList *return_list; GList *return_list;
#ifdef HAVE_SYS_SYSCTL_H #ifdef HAVE_SYS_SYSCTL_H
uid_t uid = getuid ();
int usermnt = 0; int usermnt = 0;
struct stat sb; struct stat sb;
#endif #endif
@ -1463,10 +1464,9 @@ _g_get_unix_mount_points (void)
#ifdef HAVE_SYS_SYSCTL_H #ifdef HAVE_SYS_SYSCTL_H
if (usermnt != 0) if (usermnt != 0)
{ {
uid_t uid = getuid (); if (uid == 0 ||
if (stat (fstab->fs_file, &sb) == 0) (stat (fstab->fs_file, &sb) == 0 && sb.st_uid == uid))
{ {
if (uid == 0 || sb.st_uid == uid)
is_user_mountable = TRUE; is_user_mountable = TRUE;
} }
} }