about summary refs log tree commit diff
path: root/sysdeps/unix/sysv/linux/i386/chown.c
diff options
context:
space:
mode:
Diffstat (limited to 'sysdeps/unix/sysv/linux/i386/chown.c')
-rw-r--r--sysdeps/unix/sysv/linux/i386/chown.c46
1 files changed, 45 insertions, 1 deletions
diff --git a/sysdeps/unix/sysv/linux/i386/chown.c b/sysdeps/unix/sysv/linux/i386/chown.c
index 9ab03e3a7c..9addfd0598 100644
--- a/sysdeps/unix/sysv/linux/i386/chown.c
+++ b/sysdeps/unix/sysv/linux/i386/chown.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1998, 1999 Free Software Foundation, Inc.
+/* Copyright (C) 1998, 1999, 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,6 +23,9 @@
 #include <sys/syscall.h>
 
 #include <kernel-features.h>
+#include <linux/posix_types.h>
+
+
 
 /*
   In Linux 2.1.x the chown functions have been changed.  A new function lchown
@@ -39,6 +42,15 @@ extern int __syscall_chown (const char *__file,
 #if defined __NR_lchown || __ASSUME_LCHOWN_SYSCALL > 0
 /* Running under Linux > 2.1.80.  */
 
+# ifdef __NR_chown32
+extern int __syscall_chown32 (const char *__file,
+			      __kernel_uid32_t owner, __kernel_gid32_t group);
+#  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_chown32 */
 
 int
 __real_chown (const char *file, uid_t owner, gid_t group)
@@ -50,6 +62,20 @@ __real_chown (const char *file, uid_t owner, gid_t group)
   if (!__libc_old_chown)
     {
       int saved_errno = errno;
+#  ifdef __NR_chown32
+      if (!__libc_missing_32bit_uids)
+	{
+	  int result;
+	  int saved_errno = errno;
+
+	  result = INLINE_SYSCALL (chown32, 3, file, owner, group);
+	  if (result == 0 || errno != ENOSYS)
+	    return result;
+
+	  __set_errno (saved_errno);
+	  __libc_missing_32bit_uids = 1;
+	}
+#  endif /* __NR_chown32 */
       result = INLINE_SYSCALL (chown, 3, file, owner, group);
 
       if (result >= 0 || errno != ENOSYS)
@@ -60,7 +86,25 @@ __real_chown (const char *file, uid_t owner, gid_t group)
     }
 
   return __lchown (file, owner, group);
+# elif __ASSUME_32BITUIDS
+  /* This implies __ASSUME_LCHOWN_SYSCALL.  */
+  return INLINE_SYSCALL (chown32, 3, file, owner, group);
 # else
+  /* !__ASSUME_32BITUIDS && ASSUME_LCHOWN_SYSCALL  */
+#  ifdef __NR_chown32
+  if (!__libc_missing_32bit_uids)
+    {
+      int result;
+      int saved_errno = errno;
+
+      result = INLINE_SYSCALL (chown32, 3, file, owner, group);
+      if (result == 0 || errno != ENOSYS)
+	return result;
+
+      __set_errno (saved_errno);
+      __libc_missing_32bit_uids = 1;
+    }
+#  endif /* __NR_chown32 */
   return INLINE_SYSCALL (chown, 3, file, owner, group);
 # endif
 }