mirror of
				https://gitlab.gnome.org/GNOME/glib.git
				synced 2025-11-04 10:08:56 +01:00 
			
		
		
		
	[PATCH] _g_get_unix_mount_points(): reduce syscalls inside loop
This commit is contained in:
		@@ -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;
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user