[PATCH] _g_get_unix_mount_points(): reduce syscalls inside loop

This commit is contained in:
Rozhuk Ivan 2022-06-25 19:01:30 +03:00
parent 99a7c6351c
commit 02d0d6497b

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