about summary refs log tree commit diff
path: root/sysdeps/unix/sysv/linux/i386/getgroups.c
diff options
context:
space:
mode:
Diffstat (limited to 'sysdeps/unix/sysv/linux/i386/getgroups.c')
-rw-r--r--sysdeps/unix/sysv/linux/i386/getgroups.c38
1 files changed, 32 insertions, 6 deletions
diff --git a/sysdeps/unix/sysv/linux/i386/getgroups.c b/sysdeps/unix/sysv/linux/i386/getgroups.c
index 5484f72f1c..b538f8f79a 100644
--- a/sysdeps/unix/sysv/linux/i386/getgroups.c
+++ b/sysdeps/unix/sysv/linux/i386/getgroups.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1997, 1998 Free Software Foundation, Inc.
+/* Copyright (C) 1997, 1998, 2000 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
    The GNU C Library is free software; you can redistribute it and/or
@@ -23,17 +23,25 @@
 
 #include <sysdep.h>
 #include <sys/syscall.h>
-
 #include <linux/posix_types.h>
+#include <kernel-features.h>
+
+
+extern int __syscall_getgroups(int, __kernel_gid_t *);
 
-extern int __syscall_getgroups __P ((int, __kernel_gid_t *));
+#ifdef __NR_getgroups32
+extern int __syscall_getgroups32 (int, __kernel_gid32_t *);
+# if __ASSUME_32BITUIDS == 0
+/* This variable is shared with all files that need to check for 32bit
+   uids.  */
+extern int __libc_missing_32bit_uids;
+# endif
+#endif /* __NR_getgroups32 */
 
 /* For Linux we must convert the array of groups from the format that the
    kernel returns.  */
 int
-__getgroups (n, groups)
-     int n;
-     gid_t *groups;
+__getgroups (int n, gid_t *groups)
 {
   if (n < 0)
     {
@@ -42,8 +50,25 @@ __getgroups (n, groups)
     }
   else
     {
+#if __ASSUME_32BITUIDS > 0
+      return INLINE_SYSCALL (getgroups32, 2, n, groups);
+#else
       int i, ngids;
       __kernel_gid_t kernel_groups[n = MIN (n, __sysconf (_SC_NGROUPS_MAX))];
+# ifdef __NR_getgroups32
+      if (!__libc_missing_32bit_uids)
+	{
+	  int result;
+	  int saved_errno = errno;
+
+	  result = INLINE_SYSCALL (getgroups32, 2, n, groups);
+	  if (result == 0 || errno != ENOSYS)
+	    return result;
+
+	  __set_errno (saved_errno);
+	  __libc_missing_32bit_uids = 1;
+	}
+# endif /* __NR_getgroups32 */
 
       ngids = INLINE_SYSCALL (getgroups, 2, n, kernel_groups);
       if (n != 0 && ngids > 0)
@@ -52,6 +77,7 @@ __getgroups (n, groups)
 
       return ngids;
     }
+#endif
 }
 
 weak_alias (__getgroups, getgroups)