• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1From 02d0d6497b92d05d1145d1077654ad2453938b6c Mon Sep 17 00:00:00 2001
2From: Rozhuk Ivan <rozhuk.im@gmail.com>
3Date: Sat, 25 Jun 2022 19:01:30 +0300
4Subject: [PATCH] [PATCH] _g_get_unix_mount_points(): reduce syscalls inside
5 loop
6
7Conflict:NA
8Reference:https://gitlab.gnome.org/GNOME/glib/-/commit/02d0d6497b92d05d1145d1077654ad2453938b6c
9
10---
11 gio/gunixmounts.c | 16 ++++++++--------
12 1 file changed, 8 insertions(+), 8 deletions(-)
13diff --git a/gio/gunixmounts.c b/gio/gunixmounts.c
14index ba08245..92ab163 100644
15--- a/gio/gunixmounts.c
16+++ b/gio/gunixmounts.c
17@@ -1414,6 +1414,7 @@ _g_get_unix_mount_points (void)
18   GList *return_list = NULL;
19   G_LOCK_DEFINE_STATIC (fsent);
20 #ifdef HAVE_SYS_SYSCTL_H
21+  uid_t uid = getuid ();
22   int usermnt = 0;
23   struct stat sb;
24 #endif
25@@ -1466,14 +1467,13 @@ _g_get_unix_mount_points (void)
26
27 #ifdef HAVE_SYS_SYSCTL_H
28       if (usermnt != 0)
29-	{
30-	  uid_t uid = getuid ();
31-	  if (stat (fstab->fs_file, &sb) == 0)
32-	    {
33-	      if (uid == 0 || sb.st_uid == uid)
34-		is_user_mountable = TRUE;
35-	    }
36-	}
37+        {
38+          if (uid == 0 ||
39+              (stat (fstab->fs_file, &sb) == 0 && sb.st_uid == uid))
40+            {
41+              is_user_mountable = TRUE;
42+            }
43+        }
44 #endif
45
46       mount_point = create_unix_mount_point (fstab->fs_spec,
47