This is the mail archive of the
libc-alpha@sourceware.cygnus.com
mailing list for the glibc project.
32bit UID support, next patch
- To: libc-alpha Mailinglist <libc-alpha at sourceware dot cygnus dot com>
- Subject: 32bit UID support, next patch
- From: Andreas Jaeger <aj at suse dot de>
- Date: 12 Jan 2000 18:47:27 +0100
- Cc: Chris Wing <wingc at engin dot umich dot edu>
This patch adds 32bit UID support for most functions to glibc 2.2.
Missing are (this might come tomorrow):
- stat etc.
- msgctl, semctl, shmctl
The patches is essentially Chris' patch with __ASSUME_32BITUIDS added
and a bit of reformating. Chris, the __ASSUME_32BITUIDS allows to
configure [1] with e.g. --enable-kernel=2.3.40. This way all
compatibility stuff will be removed and only the new syscalls will be
used. But this features makes the code a bit more complicated. On
the other side I could simplify your patch a bit, since stat32 was not
added to the kernel.
I'd appreciate if some people could review the patch carefully.
Thanks Chris for your patches,
Andreas
Footnotes:
[1] This only works with glibc 2.2, 2.1 doesn't support it.
2000-01-12 Andreas Jaeger <aj@suse.de>
* sysdeps/unix/sysv/linux/kernel-features.h (__ASSUME_32BITUIDS):
Added for Linux 2.3.39+.
* sysdeps/unix/sysv/linux/getresgid.c: Support 32bit UIDs and
32bit GIDs.
* sysdeps/unix/sysv/linux/getresuid.c: Likewise.
* sysdeps/unix/sysv/linux/i386/chown.c: Likewise.
* sysdeps/unix/sysv/linux/i386/getgroups.c: Likewise.
* sysdeps/unix/sysv/linux/i386/setegid.c: Likewise.
* sysdeps/unix/sysv/linux/i386/seteuid.c: Likewise.
* sysdeps/unix/sysv/linux/i386/setfsgid.c: Likewise.
* sysdeps/unix/sysv/linux/i386/setfsuid.c: Likewise.
* sysdeps/unix/sysv/linux/i386/setgid.c: Likewise.
* sysdeps/unix/sysv/linux/i386/setgroups.c: Likewise.
* sysdeps/unix/sysv/linux/i386/setregid.c: Likewise.
* sysdeps/unix/sysv/linux/i386/setresgid.c: Likewise.
* sysdeps/unix/sysv/linux/i386/setresuid.c: Likewise.
* sysdeps/unix/sysv/linux/i386/setreuid.c: Likewise.
* sysdeps/unix/sysv/linux/i386/setuid.c: Likewise.
* sysdeps/unix/sysv/linux/setegid.c: Likewise.
* sysdeps/unix/sysv/linux/arm/chown.c: New file.
* sysdeps/unix/sysv/linux/arm/fchown.c: New file.
* sysdeps/unix/sysv/linux/arm/geteuid.c: New file.
* sysdeps/unix/sysv/linux/arm/getegid.c: New file.
* sysdeps/unix/sysv/linux/arm/getuid.c: New file.
* sysdeps/unix/sysv/linux/arm/getgid.c: New file.
* sysdeps/unix/sysv/linux/arm/lchown.c: New file.
* sysdeps/unix/sysv/linux/i386/fchown.c: New file.
* sysdeps/unix/sysv/linux/i386/getegid.c: New file.
* sysdeps/unix/sysv/linux/i386/geteuid.c: New file.
* sysdeps/unix/sysv/linux/i386/getgid.c: New file.
* sysdeps/unix/sysv/linux/i386/getuid.c: New file.
* sysdeps/unix/sysv/linux/i386/lchown.c: New file.
* sysdeps/unix/sysv/linux/m68k/chown.c: New file.
* sysdeps/unix/sysv/linux/m68k/fchown.c: New file.
* sysdeps/unix/sysv/linux/m68k/getegid.c: New file.
* sysdeps/unix/sysv/linux/m68k/geteuid.c: New file.
* sysdeps/unix/sysv/linux/m68k/getgid.c: New file.
* sysdeps/unix/sysv/linux/m68k/getuid.c: New file.
* sysdeps/unix/sysv/linux/m68k/lchown.c: New file.
* sysdeps/unix/sysv/linux/sparc/sparc32/chown.c: New file.
* sysdeps/unix/sysv/linux/sparc/sparc32/fchown.c: New file.
* sysdeps/unix/sysv/linux/sparc/sparc32/getegid.c: New file.
* sysdeps/unix/sysv/linux/sparc/sparc32/geteuid.c: New file.
* sysdeps/unix/sysv/linux/sparc/sparc32/getgid.c: New file.
* sysdeps/unix/sysv/linux/sparc/sparc32/getuid.c: New file.
* sysdeps/unix/sysv/linux/sparc/sparc32/lchown.c: New file.
Based on a patch by Chris Wing <wingc@engin.umich.edu>.
============================================================
Index: sysdeps/unix/sysv/linux/kernel-features.h
--- sysdeps/unix/sysv/linux/kernel-features.h 2000/01/03 23:22:27 1.8
+++ sysdeps/unix/sysv/linux/kernel-features.h 2000/01/12 17:30:12
@@ -102,3 +102,8 @@
# define __ASSUME_MMAP2_SYSCALL 1
# define __ASSUME_STAT64_SYSCALL 1
#endif
+
+/* Linux 2.3.39 introduced 32bit UID/GIDs. */
+#if __LINUX_KERNEL_VERSION >= 131879
+# define __ASSUME_32BITUIDS 1
+#endif
============================================================
Index: sysdeps/unix/sysv/linux/getresgid.c
--- sysdeps/unix/sysv/linux/getresgid.c 1998/10/21 15:10:14 1.3
+++ sysdeps/unix/sysv/linux/getresgid.c 2000/01/12 17:30:12
@@ -1,4 +1,4 @@
-/* Copyright (C) 1998 Free Software Foundation, Inc.
+/* Copyright (C) 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
@@ -24,16 +24,47 @@
#include <sysdep.h>
#include <sys/syscall.h>
+#include "kernel-features.h"
+
#ifdef __NR_getresgid
extern int __syscall_getresgid (__kernel_gid_t *rgid, __kernel_gid_t *egid,
__kernel_gid_t *sgid);
+# ifdef __NR_getresgid32
+extern int __syscall_getresgid32 (__kernel_gid32_t *rgid, __kernel_gid32_t *egid,
+ __kernel_gid32_t *sgid);
+
+# 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_getresgid32 */
+
+
int
getresgid (gid_t *rgid, gid_t *egid, gid_t *sgid)
{
+# if __ASSUME_32BITUIDS > 0
+ return INLINE_SYSCALL (getresgid32, 3, rgid, egid, sgid);
+# else
__kernel_gid_t k_rgid, k_egid, k_sgid;
int result;
+# ifdef __NR_getresgid32
+ if (!__libc_missing_32bit_uids)
+ {
+ int r;
+ int saved_errno = errno;
+
+ r = INLINE_SYSCALL (getresgid32, 3, rgid, egid, sgid);
+ if (r == 0 || errno != ENOSYS)
+ return r;
+
+ __set_errno (saved_errno);
+ __libc_missing_32bit_uids = 1;
+ }
+# endif /* __NR_getresgid32 */
result = INLINE_SYSCALL (getresgid, 3, &k_rgid, &k_egid, &k_sgid);
@@ -45,6 +76,7 @@
}
return result;
+# endif
}
#else
# include <sysdeps/generic/getresgid.c>
============================================================
Index: sysdeps/unix/sysv/linux/getresuid.c
--- sysdeps/unix/sysv/linux/getresuid.c 1998/10/21 15:10:22 1.3
+++ sysdeps/unix/sysv/linux/getresuid.c 2000/01/12 17:30:12
@@ -1,4 +1,4 @@
-/* Copyright (C) 1998 Free Software Foundation, Inc.
+/* Copyright (C) 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
@@ -24,16 +24,46 @@
#include <sysdep.h>
#include <sys/syscall.h>
+
+#include "kernel-features.h"
+
#ifdef __NR_getresuid
extern int __syscall_getresuid (__kernel_uid_t *ruid, __kernel_uid_t *euid,
__kernel_uid_t *suid);
+# ifdef __NR_getresuid32
+extern int __syscall_getresuid32 (__kernel_uid32_t *ruid, __kernel_uid32_t *euid,
+ __kernel_uid32_t *suid);
+# 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_getresuid32 */
+
int
getresuid (uid_t *ruid, uid_t *euid, uid_t *suid)
{
+# if __ASSUME_32BITUIDS > 0
+ return INLINE_SYSCALL (getresuid32, 3, ruid, euid, suid);
+# else
__kernel_uid_t k_ruid, k_euid, k_suid;
int result;
+# ifdef __NR_getresuid32
+ if (!__libc_missing_32bit_uids)
+ {
+ int r;
+ int saved_errno = errno;
+
+ r = INLINE_SYSCALL (getresuid32, 3, ruid, euid, suid);
+ if (r == 0 || errno != ENOSYS)
+ return r;
+
+ __set_errno (saved_errno);
+ __libc_missing_32bit_uids = 1;
+ }
+# endif /* __NR_getresuid32 */
result = INLINE_SYSCALL (getresuid, 3, &k_ruid, &k_euid, &k_suid);
@@ -45,6 +75,7 @@
}
return result;
+# endif
}
#else
# include <sysdeps/generic/getresuid.c>
============================================================
Index: sysdeps/unix/sysv/linux/setegid.c
--- sysdeps/unix/sysv/linux/setegid.c 1995/09/08 14:01:33 1.1
+++ sysdeps/unix/sysv/linux/setegid.c 2000/01/12 17:30:12
@@ -1 +1,51 @@
-#include <sysdeps/unix/bsd/setegid.c>
+/* Copyright (C) 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
+ modify it under the terms of the GNU Library General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with the GNU C Library; see the file COPYING.LIB. If not,
+ write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA. */
+
+#include <errno.h>
+#include <sys/syscall.h>
+#include <sys/types.h>
+#include <unistd.h>
+
+#ifdef __NR_setresgid
+
+extern int __setresgid (gid_t rgid, gid_t egid, gid_t sgid);
+
+int
+setegid (gid_t gid)
+{
+ int result;
+
+ if (gid == (gid_t) ~0)
+ {
+ __set_errno (EINVAL);
+ return -1;
+ }
+
+ /* First try the syscall. */
+ result = __setresgid (-1, gid, -1);
+ if (result == -1 && errno == ENOSYS)
+ /* No system call available. Use emulation. This may not work
+ since `setregid' also sets the saved group ID when GID is not
+ equal to the real group ID, making it impossible to switch back. */
+ result = __setregid (-1, gid);
+
+ return result;
+}
+#else
+# include <sysdeps/unix/bsd/setegid.c>
+#endif
============================================================
Index: sysdeps/unix/sysv/linux/i386/chown.c
--- sysdeps/unix/sysv/linux/i386/chown.c 1999/05/26 23:35:30 1.6
+++ sysdeps/unix/sysv/linux/i386/chown.c 2000/01/12 17:30:12
@@ -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,7 +23,10 @@
#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
was introduced. The new chown now follows symlinks - the old chown and the
@@ -39,6 +42,15 @@
#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 @@
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 @@
}
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
}
============================================================
Index: sysdeps/unix/sysv/linux/i386/getgroups.c
--- sysdeps/unix/sysv/linux/i386/getgroups.c 1998/10/22 11:47:31 1.3
+++ sysdeps/unix/sysv/linux/i386/getgroups.c 2000/01/12 17:30:12
@@ -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 @@
}
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 @@
return ngids;
}
+#endif
}
weak_alias (__getgroups, getgroups)
============================================================
Index: sysdeps/unix/sysv/linux/i386/setegid.c
--- sysdeps/unix/sysv/linux/i386/setegid.c 1998/10/16 16:25:41 1.1
+++ sysdeps/unix/sysv/linux/i386/setegid.c 2000/01/12 17:30:12
@@ -1,4 +1,4 @@
-/* Copyright (C) 1995, 1996, 1997, 1998 Free Software Foundation, Inc.
+/* Copyright (C) 1995, 96, 97, 98, 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
@@ -16,22 +16,12 @@
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
-#include <errno.h>
#include <unistd.h>
#include <sys/types.h>
-#include <linux/posix_types.h>
-
int
setegid (gid)
gid_t gid;
{
- if (gid == (gid_t) ~0
- || gid != (gid_t) ((__kernel_gid_t) gid))
- {
- __set_errno (EINVAL);
- return -1;
- }
-
return __setregid (-1, gid);
}
============================================================
Index: sysdeps/unix/sysv/linux/i386/seteuid.c
--- sysdeps/unix/sysv/linux/i386/seteuid.c 1998/10/16 16:25:45 1.1
+++ sysdeps/unix/sysv/linux/i386/seteuid.c 2000/01/12 17:30:12
@@ -1,4 +1,4 @@
-/* Copyright (C) 1998 Free Software Foundation, Inc.
+/* Copyright (C) 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
@@ -21,7 +21,6 @@
#include <sys/types.h>
#include <unistd.h>
-#include <linux/posix_types.h>
#ifdef __NR_setresuid
extern int __setresuid (uid_t ruid, uid_t euid, uid_t suid);
@@ -31,14 +30,6 @@
seteuid (uid_t uid)
{
int result;
-
- if (uid == (uid_t) ~0
- || uid != (uid_t) ((__kernel_uid_t) uid))
- {
- __set_errno (EINVAL);
- return -1;
- }
-
/* First try the syscall. */
#ifdef __NR_setresuid
result = __setresuid (-1, uid, -1);
============================================================
Index: sysdeps/unix/sysv/linux/i386/setfsgid.c
--- sysdeps/unix/sysv/linux/i386/setfsgid.c 1998/11/30 14:21:33 1.3
+++ sysdeps/unix/sysv/linux/i386/setfsgid.c 2000/01/12 17:30:12
@@ -1,4 +1,4 @@
-/* Copyright (C) 1998 Free Software Foundation, Inc.
+/* Copyright (C) 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
@@ -22,15 +22,43 @@
#include <sysdep.h>
#include <sys/syscall.h>
-
#include <linux/posix_types.h>
+#include "kernel-features.h"
+
#ifdef __NR_setfsgid
+
extern int __syscall_setfsgid (__kernel_gid_t);
+# ifdef __NR_setfsgid32
+extern int __syscall_setfsgid32 (__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_setfsgid32 */
+
int
setfsgid (gid_t gid)
{
+# if __ASSUME_32BITUIDS > 0
+ return INLINE_SYSCALL (setfsgid32, 1, gid);
+# else
+# ifdef __NR_setfsgid32
+ if (!__libc_missing_32bit_uids)
+ {
+ int result;
+ int saved_errno = errno;
+
+ result = INLINE_SYSCALL (setfsgid32, 1, gid);
+ if (result == 0 || errno != ENOSYS)
+ return result;
+
+ __set_errno (saved_errno);
+ __libc_missing_32bit_uids = 1;
+ }
+# endif /* __NR_setfsgid32 */
if (gid != (gid_t) ((__kernel_gid_t) gid))
{
__set_errno (EINVAL);
@@ -38,5 +66,6 @@
}
return INLINE_SYSCALL (setfsgid, 1, gid);
+# endif
}
#endif
============================================================
Index: sysdeps/unix/sysv/linux/i386/setfsuid.c
--- sysdeps/unix/sysv/linux/i386/setfsuid.c 1998/11/30 14:21:34 1.3
+++ sysdeps/unix/sysv/linux/i386/setfsuid.c 2000/01/12 17:30:12
@@ -1,4 +1,4 @@
-/* Copyright (C) 1998 Free Software Foundation, Inc.
+/* Copyright (C) 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
@@ -24,13 +24,42 @@
#include <sys/syscall.h>
#include <linux/posix_types.h>
+#include "kernel-features.h"
#ifdef __NR_setfsuid
+
extern int __syscall_setfsuid (__kernel_uid_t);
+# ifdef __NR_setfsuid32
+extern int __syscall_setfsuid32 (__kernel_uid32_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_setfsuid32 */
+
int
setfsuid (uid_t uid)
{
+# if __ASSUME_32BITUIDS > 0
+ return INLINE_SYSCALL (setfsuid32, 1, uid);
+# else
+# ifdef __NR_setfsuid32
+ if (!__libc_missing_32bit_uids)
+ {
+ int result;
+ int saved_errno = errno;
+
+ result = INLINE_SYSCALL (setfsuid32, 1, uid);
+ if (result == 0 || errno != ENOSYS)
+ return result;
+
+ __set_errno (saved_errno);
+ __libc_missing_32bit_uids = 1;
+ }
+# endif /* __NR_setfsuid32 */
+
if (uid != (uid_t) ((__kernel_uid_t) uid))
{
__set_errno (EINVAL);
@@ -38,5 +67,6 @@
}
return INLINE_SYSCALL (setfsuid, 1, uid);
+# endif
}
#endif
============================================================
Index: sysdeps/unix/sysv/linux/i386/setgid.c
--- sysdeps/unix/sysv/linux/i386/setgid.c 1998/10/21 15:20:39 1.2
+++ sysdeps/unix/sysv/linux/i386/setgid.c 2000/01/12 17:30:12
@@ -1,4 +1,4 @@
-/* Copyright (C) 1998 Free Software Foundation, Inc.
+/* Copyright (C) 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
@@ -25,11 +25,41 @@
#include <linux/posix_types.h>
+#include "kernel-features.h"
+
extern int __syscall_setgid (__kernel_gid_t);
+#ifdef __NR_setgid32
+extern int __syscall_setgid32 (__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_setgid32 */
+
int
__setgid (gid_t gid)
{
+#if __ASSUME_32BITUIDS > 0
+ return INLINE_SYSCALL (setgid32, 1, gid);
+#else
+# ifdef __NR_setgid32
+ if (!__libc_missing_32bit_uids)
+ {
+ int result;
+ int saved_errno = errno;
+
+ result = INLINE_SYSCALL (setgid32, 1, gid);
+
+ if (result == 0 || errno != ENOSYS)
+ return result;
+
+ __set_errno (saved_errno);
+ __libc_missing_32bit_uids = 1;
+ }
+# endif /* __NR_setgid32 */
+
if (gid == (gid_t) ~0
|| gid != (gid_t) ((__kernel_gid_t) gid))
{
@@ -38,5 +68,6 @@
}
return INLINE_SYSCALL (setgid, 1, gid);
+#endif
}
weak_alias (__setgid, setgid)
============================================================
Index: sysdeps/unix/sysv/linux/i386/setgroups.c
--- sysdeps/unix/sysv/linux/i386/setgroups.c 1998/11/02 10:04:58 1.6
+++ sysdeps/unix/sysv/linux/i386/setgroups.c 2000/01/12 17:30:12
@@ -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,18 +23,26 @@
#include <sysdep.h>
#include <sys/syscall.h>
-
#include <linux/posix_types.h>
+#include "kernel-features.h"
+
+
+extern int __syscall_setgroups (int, const __kernel_gid_t *);
-extern int __syscall_setgroups __P ((int, const __kernel_gid_t *));
+#ifdef __NR_setgroups32
+extern int __syscall_setgroups32 __P ((int, const __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_setgroups32 */
/* Set the group set for the current user to GROUPS (N of them). For
Linux we must convert the array of groups into the format that the
kernel expects. */
int
-setgroups (n, groups)
- size_t n;
- const gid_t *groups;
+setgroups (size_t n, const gid_t *groups)
{
if (n > (size_t) __sysconf (_SC_NGROUPS_MAX))
{
@@ -43,9 +51,25 @@
}
else
{
+#if __ASSUME_32BITUIDS > 0
+ return INLINE_SYSCALL (setgroups32, 2, n, groups);
+#else
size_t i;
__kernel_gid_t kernel_groups[n];
+# ifdef __NR_setgroups32
+ if (!__libc_missing_32bit_uids)
+ {
+ int result;
+ int saved_errno = errno;
+
+ result = INLINE_SYSCALL (setgroups32, 2, n, groups);
+ if (result == 0 || errno != ENOSYS)
+ return result;
+ __set_errno (saved_errno);
+ __libc_missing_32bit_uids = 1;
+ }
+# endif /* __NR_setgroups32 */
for (i = 0; i < n; i++)
{
kernel_groups[i] = groups[i];
@@ -58,4 +82,5 @@
return INLINE_SYSCALL (setgroups, 2, n, kernel_groups);
}
+#endif
}
============================================================
Index: sysdeps/unix/sysv/linux/i386/setregid.c
--- sysdeps/unix/sysv/linux/i386/setregid.c 1998/10/21 15:21:09 1.1
+++ sysdeps/unix/sysv/linux/i386/setregid.c 2000/01/12 17:30:12
@@ -1,4 +1,4 @@
-/* Copyright (C) 1998 Free Software Foundation, Inc.
+/* Copyright (C) 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
@@ -24,12 +24,41 @@
#include <sys/syscall.h>
#include <linux/posix_types.h>
+#include "kernel-features.h"
+
extern int __syscall_setregid (__kernel_gid_t, __kernel_gid_t);
+#ifdef __NR_setregid32
+extern int __syscall_setregid32 (__kernel_gid32_t, __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_setregid32 */
+
int
__setregid (gid_t rgid, gid_t egid)
{
+#if __ASSUME_32BITUIDS > 0
+ return INLINE_SYSCALL (setregid32, 2, rgid, egid);
+#else
+# ifdef __NR_setregid32
+ if (!__libc_missing_32bit_uids)
+ {
+ int result;
+ int saved_errno = errno;
+
+ result = INLINE_SYSCALL (setregid32, 2, rgid, egid);
+
+ if (result == 0 || errno != ENOSYS)
+ return result;
+
+ __set_errno (saved_errno);
+ __libc_missing_32bit_uids = 1;
+ }
+# endif /* __NR_setregid32 */
if ((rgid != (gid_t) -1 && rgid != (gid_t) (__kernel_gid_t) rgid)
|| (egid != (gid_t) -1 && egid != (gid_t) (__kernel_gid_t) egid))
{
@@ -38,5 +67,6 @@
}
return INLINE_SYSCALL (setregid, 2, rgid, egid);
+#endif
}
weak_alias (__setregid, setregid)
============================================================
Index: sysdeps/unix/sysv/linux/i386/setresgid.c
--- sysdeps/unix/sysv/linux/i386/setresgid.c 1998/10/21 15:25:36 1.3
+++ sysdeps/unix/sysv/linux/i386/setresgid.c 2000/01/12 17:30:12
@@ -1,4 +1,4 @@
-/* Copyright (C) 1998 Free Software Foundation, Inc.
+/* Copyright (C) 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
@@ -24,14 +24,44 @@
#include <sysdep.h>
#include <sys/syscall.h>
+#include "kernel-features.h"
+
#ifdef __NR_setresgid
extern int __syscall_setresgid (__kernel_gid_t rgid, __kernel_gid_t egid,
__kernel_gid_t sgid);
+# ifdef __NR_setresgid32
+extern int __syscall_setresgid32 (__kernel_gid32_t rgid, __kernel_gid32_t egid,
+ __kernel_gid32_t sgid);
+# 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_setresgid32 */
+
int
setresgid (gid_t rgid, gid_t egid, gid_t sgid)
{
+# if __ASSUME_32BITUIDS > 0
+ return INLINE_SYSCALL (setresgid32, 3, rgid, egid, sgid);
+# else
+# ifdef __NR_setresgid32
+ if (!__libc_missing_32bit_uids)
+ {
+ int result;
+ int saved_errno = errno;
+
+ result = INLINE_SYSCALL (setresgid32, 3, rgid, egid, sgid);
+ if (result == 0 || errno != ENOSYS)
+ return result;
+
+ __set_errno (saved_errno);
+ __libc_missing_32bit_uids = 1;
+ }
+# endif /* __NR_setresgid32 */
+
if ((rgid != (gid_t) -1 && rgid != (gid_t) (__kernel_gid_t) rgid)
|| (egid != (gid_t) -1 && egid != (gid_t) (__kernel_gid_t) egid)
|| (sgid != (gid_t) -1 && sgid != (gid_t) (__kernel_gid_t) sgid))
@@ -41,5 +71,6 @@
}
return INLINE_SYSCALL (setresgid, 3, rgid, egid, sgid);
+# endif
}
#endif
============================================================
Index: sysdeps/unix/sysv/linux/i386/setresuid.c
--- sysdeps/unix/sysv/linux/i386/setresuid.c 1998/10/21 15:25:37 1.4
+++ sysdeps/unix/sysv/linux/i386/setresuid.c 2000/01/12 17:30:13
@@ -1,4 +1,4 @@
-/* Copyright (C) 1998 Free Software Foundation, Inc.
+/* Copyright (C) 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
@@ -24,14 +24,44 @@
#include <sysdep.h>
#include <sys/syscall.h>
+#include "kernel-features.h"
+
#ifdef __NR_setresuid
extern int __syscall_setresuid (__kernel_uid_t rgid, __kernel_uid_t egid,
__kernel_uid_t sgid);
+# ifdef __NR_setresuid32
+extern int __syscall_setresuid32 (__kernel_uid32_t rgid, __kernel_uid32_t egid,
+ __kernel_uid32_t sgid);
+# 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_setresuid32 */
+
int
__setresuid (uid_t ruid, uid_t euid, uid_t suid)
{
+# if __ASSUME_32BITUIDS > 0
+ return INLINE_SYSCALL (setresuid32, 3, ruid, euid, suid);
+# else
+# ifdef __NR_setresuid32
+ if (!__libc_missing_32bit_uids)
+ {
+ int result;
+ int saved_errno = errno;
+
+ result = INLINE_SYSCALL (setresuid32, 3, ruid, euid, suid);
+ if (result == 0 || errno != ENOSYS)
+ return result;
+
+ __set_errno (saved_errno);
+ __libc_missing_32bit_uids = 1;
+ }
+# endif /* __NR_setresuid32 */
+
if ((ruid != (uid_t) -1 && ruid != (uid_t) (__kernel_uid_t) ruid)
|| (euid != (uid_t) -1 && euid != (uid_t) (__kernel_uid_t) euid)
|| (suid != (uid_t) -1 && suid != (uid_t) (__kernel_uid_t) suid))
@@ -41,6 +71,7 @@
}
return INLINE_SYSCALL (setresuid, 3, ruid, euid, suid);
+# endif
}
weak_alias (__setresuid, setresuid)
#endif
============================================================
Index: sysdeps/unix/sysv/linux/i386/setreuid.c
--- sysdeps/unix/sysv/linux/i386/setreuid.c 1998/10/21 15:21:15 1.1
+++ sysdeps/unix/sysv/linux/i386/setreuid.c 2000/01/12 17:30:13
@@ -1,4 +1,4 @@
-/* Copyright (C) 1998 Free Software Foundation, Inc.
+/* Copyright (C) 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
@@ -24,12 +24,41 @@
#include <sys/syscall.h>
#include <linux/posix_types.h>
+#include "kernel-features.h"
+
extern int __syscall_setreuid (__kernel_uid_t, __kernel_uid_t);
+#ifdef __NR_setreuid32
+extern int __syscall_setreuid32 (__kernel_uid32_t, __kernel_uid32_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_setreuid32 */
+
int
__setreuid (uid_t ruid, uid_t euid)
{
+#if __ASSUME_32BITUIDS > 0
+ return INLINE_SYSCALL (setreuid32, 2, ruid, euid);
+#else
+# ifdef __NR_setreuid32
+ if (!__libc_missing_32bit_uids)
+ {
+ int result;
+ int saved_errno = errno;
+
+ result = INLINE_SYSCALL (setreuid32, 2, ruid, euid);
+
+ if (result == 0 || errno != ENOSYS)
+ return result;
+
+ __set_errno (saved_errno);
+ __libc_missing_32bit_uids = 1;
+ }
+# endif /* __NR_setreuid32 */
if ((ruid != (uid_t) -1 && ruid != (uid_t) (__kernel_uid_t) ruid)
|| (euid != (uid_t) -1 && euid != (uid_t) (__kernel_uid_t) euid))
{
@@ -38,5 +67,6 @@
}
return INLINE_SYSCALL (setreuid, 2, ruid, euid);
+#endif
}
weak_alias (__setreuid, setreuid)
============================================================
Index: sysdeps/unix/sysv/linux/i386/setuid.c
--- sysdeps/unix/sysv/linux/i386/setuid.c 1998/10/21 15:25:45 1.2
+++ sysdeps/unix/sysv/linux/i386/setuid.c 2000/01/12 17:30:13
@@ -1,4 +1,4 @@
-/* Copyright (C) 1998 Free Software Foundation, Inc.
+/* Copyright (C) 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
@@ -24,12 +24,40 @@
#include <sys/syscall.h>
#include <linux/posix_types.h>
+#include "kernel-features.h"
extern int __syscall_setuid (__kernel_uid_t);
+#ifdef __NR_setuid32
+extern int __syscall_setuid32 (__kernel_uid32_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_setuid32 */
+
int
__setuid (uid_t uid)
{
+#if __ASSUME_32BITUIDS > 0
+ return INLINE_SYSCALL (setuid32, 1, uid);
+#else
+# ifdef __NR_setuid32
+ if (!__libc_missing_32bit_uids)
+ {
+ int result;
+ int saved_errno = errno;
+
+ result = INLINE_SYSCALL (setuid32, 1, uid);
+ if (result == 0 || errno != ENOSYS)
+ return result;
+
+ __set_errno (saved_errno);
+ __libc_missing_32bit_uids = 1;
+ }
+# endif /* __NR_setuid32 */
+
if (uid == (uid_t) ~0
|| uid != (uid_t) ((__kernel_uid_t) uid))
{
@@ -38,5 +66,6 @@
}
return INLINE_SYSCALL (setuid, 1, uid);
+#endif
}
weak_alias (__setuid, setuid)
============================================================
Index: sysdeps/unix/sysv/linux/arm/chown.c
--- sysdeps/unix/sysv/linux/arm/chown.c created
+++ sysdeps/unix/sysv/linux/arm/chown.c Wed Jan 12 16:53:23 2000 1.1
@@ -0,0 +1 @@
+#include <sysdeps/unix/sysv/linux/m68k/chown.c>
============================================================
Index: sysdeps/unix/sysv/linux/arm/fchown.c
--- sysdeps/unix/sysv/linux/arm/fchown.c created
+++ sysdeps/unix/sysv/linux/arm/fchown.c Wed Jan 12 16:53:23 2000 1.1
@@ -0,0 +1 @@
+#include <sysdeps/unix/sysv/linux/i386/fchown.c>
============================================================
Index: sysdeps/unix/sysv/linux/arm/geteuid.c
--- sysdeps/unix/sysv/linux/arm/geteuid.c created
+++ sysdeps/unix/sysv/linux/arm/geteuid.c Wed Jan 12 16:53:23 2000 1.1
@@ -0,0 +1 @@
+#include <sysdeps/unix/sysv/linux/i386/geteuid.c>
============================================================
Index: sysdeps/unix/sysv/linux/arm/getegid.c
--- sysdeps/unix/sysv/linux/arm/getegid.c created
+++ sysdeps/unix/sysv/linux/arm/getegid.c Wed Jan 12 16:53:23 2000 1.1
@@ -0,0 +1 @@
+#include <sysdeps/unix/sysv/linux/i386/getegid.c>
============================================================
Index: sysdeps/unix/sysv/linux/arm/getuid.c
--- sysdeps/unix/sysv/linux/arm/getuid.c created
+++ sysdeps/unix/sysv/linux/arm/getuid.c Wed Jan 12 16:53:23 2000 1.1
@@ -0,0 +1 @@
+#include <sysdeps/unix/sysv/linux/i386/getuid.c>
============================================================
Index: sysdeps/unix/sysv/linux/arm/getgid.c
--- sysdeps/unix/sysv/linux/arm/getgid.c created
+++ sysdeps/unix/sysv/linux/arm/getgid.c Wed Jan 12 16:53:23 2000 1.1
@@ -0,0 +1 @@
+#include <sysdeps/unix/sysv/linux/i386/getgid.c>
============================================================
Index: sysdeps/unix/sysv/linux/arm/lchown.c
--- sysdeps/unix/sysv/linux/arm/lchown.c created
+++ sysdeps/unix/sysv/linux/arm/lchown.c Wed Jan 12 16:53:23 2000 1.1
@@ -0,0 +1 @@
+#include <sysdeps/unix/sysv/linux/i386/lchown.c>
============================================================
Index: sysdeps/unix/sysv/linux/i386/fchown.c
--- sysdeps/unix/sysv/linux/i386/fchown.c created
+++ sysdeps/unix/sysv/linux/i386/fchown.c Wed Jan 12 17:38:45 2000 1.1
@@ -0,0 +1,73 @@
+/* Copyright (C) 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
+ modify it under the terms of the GNU Library General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with the GNU C Library; see the file COPYING.LIB. If not,
+ write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA. */
+
+#include <errno.h>
+#include <unistd.h>
+
+#include <sysdep.h>
+#include <sys/syscall.h>
+
+#include <linux/posix_types.h>
+#include "kernel-features.h"
+
+extern int __syscall_fchown (int __fd,
+ __kernel_uid_t __owner, __kernel_gid_t __group);
+
+#ifdef __NR_fchown32
+extern int __syscall_fchown32 (int __fd,
+ __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_fchown32 */
+
+int
+__fchown (int fd, uid_t owner, gid_t group)
+{
+#if __ASSUME_32BITUIDS > 0
+ return INLINE_SYSCALL (fchown32, 3, fd, owner, group);
+#else
+# ifdef __NR_fchown32
+ if (!__libc_missing_32bit_uids)
+ {
+ int result;
+ int saved_errno = errno;
+
+ result = INLINE_SYSCALL (fchown32, 3, fd, owner, group);
+ if (result == 0 || errno != ENOSYS)
+ return result;
+
+ __set_errno (saved_errno);
+ __libc_missing_32bit_uids = 1;
+ }
+# endif /* __NR_fchown32 */
+
+ if ( (owner != (uid_t) ((__kernel_uid_t) owner)) ||
+ (group != (gid_t) ((__kernel_gid_t) group)) )
+ {
+ __set_errno (EINVAL);
+ return -1;
+ }
+
+ return INLINE_SYSCALL (fchown, 3, fd, owner, group);
+#endif
+}
+
+weak_alias (__fchown, fchown)
============================================================
Index: sysdeps/unix/sysv/linux/i386/getegid.c
--- sysdeps/unix/sysv/linux/i386/getegid.c created
+++ sysdeps/unix/sysv/linux/i386/getegid.c Wed Jan 12 18:18:23 2000 1.1
@@ -0,0 +1,62 @@
+/* Copyright (C) 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
+ modify it under the terms of the GNU Library General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with the GNU C Library; see the file COPYING.LIB. If not,
+ write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA. */
+
+#include <errno.h>
+#include <unistd.h>
+
+#include <sysdep.h>
+#include <sys/syscall.h>
+#include "kernel-features.h"
+
+extern int __syscall_getegid (void);
+
+#ifdef __NR_getegid32
+extern int __syscall_getegid32 (void);
+# 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_getegid32 */
+
+gid_t
+__getegid (void)
+{
+#if __ASSUME_32BITUIDS > 0
+ return INLINE_SYSCALL (getegid32, 0);
+#else
+# ifdef __NR_getegid32
+ if (!__libc_missing_32bit_uids)
+ {
+ int result;
+ int saved_errno = errno;
+
+ result = INLINE_SYSCALL (getegid32, 0);
+ if (result == 0 || errno != ENOSYS)
+ return result;
+
+ __set_errno (saved_errno);
+ __libc_missing_32bit_uids = 1;
+ }
+# endif /* __NR_getegid32 */
+
+ return INLINE_SYSCALL (getegid, 0);
+#endif
+}
+
+weak_alias (__getegid, getegid)
============================================================
Index: sysdeps/unix/sysv/linux/i386/geteuid.c
--- sysdeps/unix/sysv/linux/i386/geteuid.c created
+++ sysdeps/unix/sysv/linux/i386/geteuid.c Wed Jan 12 18:18:45 2000 1.1
@@ -0,0 +1,62 @@
+/* Copyright (C) 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
+ modify it under the terms of the GNU Library General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with the GNU C Library; see the file COPYING.LIB. If not,
+ write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA. */
+
+#include <errno.h>
+#include <unistd.h>
+
+#include <sysdep.h>
+#include <sys/syscall.h>
+#include "kernel-features.h"
+
+extern int __syscall_geteuid (void);
+
+#ifdef __NR_geteuid32
+extern int __syscall_geteuid32 (void);
+# 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_geteuid32 */
+
+uid_t
+__geteuid (void)
+{
+#if __ASSUME_32BITUIDS > 0
+ return INLINE_SYSCALL (geteuid32, 0);
+#else
+# ifdef __NR_geteuid32
+ if (!__libc_missing_32bit_uids)
+ {
+ int result;
+ int saved_errno = errno;
+
+ result = INLINE_SYSCALL (geteuid32, 0);
+ if (result == 0 || errno != ENOSYS)
+ return result;
+
+ __set_errno (saved_errno);
+ __libc_missing_32bit_uids = 1;
+ }
+# endif /* __NR_geteuid32 */
+
+ return INLINE_SYSCALL (geteuid, 0);
+#endif
+}
+
+weak_alias (__geteuid, geteuid)
============================================================
Index: sysdeps/unix/sysv/linux/i386/getgid.c
--- sysdeps/unix/sysv/linux/i386/getgid.c created
+++ sysdeps/unix/sysv/linux/i386/getgid.c Wed Jan 12 17:42:31 2000 1.1
@@ -0,0 +1,63 @@
+/* Copyright (C) 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
+ modify it under the terms of the GNU Library General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with the GNU C Library; see the file COPYING.LIB. If not,
+ write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA. */
+
+#include <errno.h>
+#include <unistd.h>
+
+#include <sysdep.h>
+#include <sys/syscall.h>
+
+#include "kernel-features.h"
+
+extern int __syscall_getgid (void);
+
+#ifdef __NR_getgid32
+extern int __syscall_getgid32 (void);
+# 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_getgid32 */
+
+gid_t
+__getgid (void)
+{
+#if __ASSUME_32BITUIDS > 0
+ return INLINE_SYSCALL (getgid32, 0);
+#else
+# ifdef __NR_getgid32
+ if (!__libc_missing_32bit_uids)
+ {
+ int result;
+ int saved_errno = errno;
+
+ result = INLINE_SYSCALL (getgid32, 0);
+ if (result == 0 || errno != ENOSYS)
+ return result;
+
+ __set_errno (saved_errno);
+ __libc_missing_32bit_uids = 1;
+ }
+# endif /* __NR_getgid32 */
+
+ return INLINE_SYSCALL (getgid, 0);
+#endif
+}
+
+weak_alias (__getgid, getgid)
============================================================
Index: sysdeps/unix/sysv/linux/i386/getuid.c
--- sysdeps/unix/sysv/linux/i386/getuid.c created
+++ sysdeps/unix/sysv/linux/i386/getuid.c Wed Jan 12 17:44:04 2000 1.1
@@ -0,0 +1,63 @@
+/* Copyright (C) 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
+ modify it under the terms of the GNU Library General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with the GNU C Library; see the file COPYING.LIB. If not,
+ write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA. */
+
+#include <errno.h>
+#include <unistd.h>
+
+#include <sysdep.h>
+#include <sys/syscall.h>
+
+#include "kernel-features.h"
+
+extern int __syscall_getuid (void);
+
+#ifdef __NR_getuid32
+extern int __syscall_getuid32 (void);
+# if __ASSUME_32BITUIDS == 0
+/* This variable is shared with all files that need to check for 32bit
+ uids. This is the definition */
+int __libc_missing_32bit_uids;
+# endif
+#endif /* __NR_getuid32 */
+
+uid_t
+__getuid (void)
+{
+#if __ASSUME_32BITUIDS > 0
+ return INLINE_SYSCALL (getuid32, 0);
+#else
+# ifdef __NR_getuid32
+ if (!__libc_missing_32bit_uids)
+ {
+ int result;
+ int saved_errno = errno;
+
+ result = INLINE_SYSCALL (getuid32, 0);
+ if (result == 0 || errno != ENOSYS)
+ return result;
+
+ __set_errno (saved_errno);
+ __libc_missing_32bit_uids = 1;
+ }
+# endif /* __NR_getuid32 */
+
+ return INLINE_SYSCALL (getuid, 0);
+#endif
+}
+
+weak_alias (__getuid, getuid)
============================================================
Index: sysdeps/unix/sysv/linux/i386/lchown.c
--- sysdeps/unix/sysv/linux/i386/lchown.c created
+++ sysdeps/unix/sysv/linux/i386/lchown.c Wed Jan 12 17:57:23 2000 1.1
@@ -0,0 +1,79 @@
+/* Copyright (C) 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
+ modify it under the terms of the GNU Library General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with the GNU C Library; see the file COPYING.LIB. If not,
+ write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA. */
+
+#include <errno.h>
+#include <unistd.h>
+
+#include <sysdep.h>
+#include <sys/syscall.h>
+
+#include <linux/posix_types.h>
+#include "kernel-features.h"
+
+#ifdef __NR_lchown
+extern int __syscall_lchown (const char *__file,
+ __kernel_uid_t __owner, __kernel_gid_t __group);
+
+# ifdef __NR_lchown32
+extern int __syscall_lchown32 (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_lchown32 */
+
+int
+__lchown (const char *file, uid_t owner, gid_t group)
+{
+# if __ASSUME_32BITUIDS > 0
+ return INLINE_SYSCALL (lchown32, 3, file, owner, group);
+# else
+# ifdef __NR_lchown32
+ if (!__libc_missing_32bit_uids)
+ {
+ int result;
+ int saved_errno = errno;
+
+ result = INLINE_SYSCALL (lchown32, 3, file, owner, group);
+ if (result == 0 || errno != ENOSYS)
+ return result;
+
+ __set_errno (saved_errno);
+ __libc_missing_32bit_uids = 1;
+ }
+# endif /* __NR_lchown32 */
+
+ if ( (owner != (uid_t) ((__kernel_uid_t) owner)) ||
+ (group != (gid_t) ((__kernel_gid_t) group)) )
+ {
+ __set_errno (EINVAL);
+ return -1;
+ }
+
+ return INLINE_SYSCALL (lchown, 3, file, owner, group);
+# endif
+}
+
+weak_alias (__lchown, lchown)
+
+#else
+# include <sysdeps/generic/lchown.c>
+#endif
+
============================================================
Index: sysdeps/unix/sysv/linux/m68k/chown.c
--- sysdeps/unix/sysv/linux/m68k/chown.c created
+++ sysdeps/unix/sysv/linux/m68k/chown.c Wed Jan 12 16:53:23 2000 1.1
@@ -0,0 +1,57 @@
+/* Copyright (C) 1998 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
+ modify it under the terms of the GNU Library General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with the GNU C Library; see the file COPYING.LIB. If not,
+ write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA. */
+
+#include <errno.h>
+#include <unistd.h>
+
+#include <sysdep.h>
+#include <sys/syscall.h>
+
+#include <linux/posix_types.h>
+
+#include <sysdeps/unix/sysv/linux/32bit_uid_compat.h>
+
+extern int __syscall_chown (const char *__file,
+ uid_t __owner, gid_t __group);
+
+#ifdef __NR_chown32
+extern int __syscall_chown32 (const char *__file,
+ __kernel_uid32_t owner, __kernel_gid32_t group);
+#endif /* __NR_chown32 */
+
+int
+__chown (const char *file, uid_t owner, gid_t group)
+{
+#ifdef __NR_chown32
+ if (__libc_missing_32bit_uids != NO_HIGHUIDS)
+ {
+ 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 = NO_HIGHUIDS;
+ }
+#endif /* __NR_chown32 */
+
+ return INLINE_SYSCALL (chown, 3, file, owner, group);
+}
+weak_alias (__chown, chown)
============================================================
Index: sysdeps/unix/sysv/linux/m68k/fchown.c
--- sysdeps/unix/sysv/linux/m68k/fchown.c created
+++ sysdeps/unix/sysv/linux/m68k/fchown.c Wed Jan 12 16:53:23 2000 1.1
@@ -0,0 +1 @@
+#include <sysdeps/unix/sysv/linux/i386/fchown.c>
============================================================
Index: sysdeps/unix/sysv/linux/m68k/getegid.c
--- sysdeps/unix/sysv/linux/m68k/getegid.c created
+++ sysdeps/unix/sysv/linux/m68k/getegid.c Wed Jan 12 16:53:23 2000 1.1
@@ -0,0 +1 @@
+#include <sysdeps/unix/sysv/linux/i386/getegid.c>
============================================================
Index: sysdeps/unix/sysv/linux/m68k/geteuid.c
--- sysdeps/unix/sysv/linux/m68k/geteuid.c created
+++ sysdeps/unix/sysv/linux/m68k/geteuid.c Wed Jan 12 16:53:23 2000 1.1
@@ -0,0 +1 @@
+#include <sysdeps/unix/sysv/linux/i386/geteuid.c>
============================================================
Index: sysdeps/unix/sysv/linux/m68k/getgid.c
--- sysdeps/unix/sysv/linux/m68k/getgid.c created
+++ sysdeps/unix/sysv/linux/m68k/getgid.c Wed Jan 12 16:53:23 2000 1.1
@@ -0,0 +1 @@
+#include <sysdeps/unix/sysv/linux/i386/getgid.c>
============================================================
Index: sysdeps/unix/sysv/linux/m68k/getuid.c
--- sysdeps/unix/sysv/linux/m68k/getuid.c created
+++ sysdeps/unix/sysv/linux/m68k/getuid.c Wed Jan 12 16:53:23 2000 1.1
@@ -0,0 +1 @@
+#include <sysdeps/unix/sysv/linux/i386/getuid.c>
============================================================
Index: sysdeps/unix/sysv/linux/m68k/lchown.c
--- sysdeps/unix/sysv/linux/m68k/lchown.c created
+++ sysdeps/unix/sysv/linux/m68k/lchown.c Wed Jan 12 16:53:23 2000 1.1
@@ -0,0 +1 @@
+#include <sysdeps/unix/sysv/linux/i386/lchown.c>
============================================================
Index: sysdeps/unix/sysv/linux/sparc/sparc32/chown.c
--- sysdeps/unix/sysv/linux/sparc/sparc32/chown.c created
+++ sysdeps/unix/sysv/linux/sparc/sparc32/chown.c Wed Jan 12 16:53:23 2000 1.1
@@ -0,0 +1 @@
+#include <sysdeps/unix/sysv/linux/m68k/chown.c>
============================================================
Index: sysdeps/unix/sysv/linux/sparc/sparc32/fchown.c
--- sysdeps/unix/sysv/linux/sparc/sparc32/fchown.c created
+++ sysdeps/unix/sysv/linux/sparc/sparc32/fchown.c Wed Jan 12 16:53:23 2000 1.1
@@ -0,0 +1 @@
+#include <sysdeps/unix/sysv/linux/i386/fchown.c>
============================================================
Index: sysdeps/unix/sysv/linux/sparc/sparc32/getegid.c
--- sysdeps/unix/sysv/linux/sparc/sparc32/getegid.c created
+++ sysdeps/unix/sysv/linux/sparc/sparc32/getegid.c Wed Jan 12 16:53:23 2000 1.1
@@ -0,0 +1 @@
+#include <sysdeps/unix/sysv/linux/i386/getegid.c>
============================================================
Index: sysdeps/unix/sysv/linux/sparc/sparc32/geteuid.c
--- sysdeps/unix/sysv/linux/sparc/sparc32/geteuid.c created
+++ sysdeps/unix/sysv/linux/sparc/sparc32/geteuid.c Wed Jan 12 16:53:23 2000 1.1
@@ -0,0 +1 @@
+#include <sysdeps/unix/sysv/linux/i386/geteuid.c>
============================================================
Index: sysdeps/unix/sysv/linux/sparc/sparc32/getgid.c
--- sysdeps/unix/sysv/linux/sparc/sparc32/getgid.c created
+++ sysdeps/unix/sysv/linux/sparc/sparc32/getgid.c Wed Jan 12 16:53:23 2000 1.1
@@ -0,0 +1 @@
+#include <sysdeps/unix/sysv/linux/i386/getgid.c>
============================================================
Index: sysdeps/unix/sysv/linux/sparc/sparc32/getuid.c
--- sysdeps/unix/sysv/linux/sparc/sparc32/getuid.c created
+++ sysdeps/unix/sysv/linux/sparc/sparc32/getuid.c Wed Jan 12 16:53:23 2000 1.1
@@ -0,0 +1 @@
+#include <sysdeps/unix/sysv/linux/i386/getuid.c>
============================================================
Index: sysdeps/unix/sysv/linux/sparc/sparc32/lchown.c
--- sysdeps/unix/sysv/linux/sparc/sparc32/lchown.c created
+++ sysdeps/unix/sysv/linux/sparc/sparc32/lchown.c Wed Jan 12 16:53:23 2000 1.1
@@ -0,0 +1 @@
+#include <sysdeps/unix/sysv/linux/i386/lchown.c>
--
Andreas Jaeger
SuSE Labs aj@suse.de
private aj@arthur.rhein-neckar.de