diff options
author | Ulrich Drepper <drepper@redhat.com> | 2006-09-25 15:33:09 +0000 |
---|---|---|
committer | Ulrich Drepper <drepper@redhat.com> | 2006-09-25 15:33:09 +0000 |
commit | f1122ec3ae47bbf40e38bec56d879502005397b1 (patch) | |
tree | 8ac3b9d7a104815f0f3ff1b6b796827823f2ac90 /sysdeps/unix/sysv/linux/powerpc/fchownat.c | |
parent | 457b559e2ec7bd66c6da9e99d27f0d1723da4874 (diff) | |
download | glibc-f1122ec3ae47bbf40e38bec56d879502005397b1.tar.gz glibc-f1122ec3ae47bbf40e38bec56d879502005397b1.tar.xz glibc-f1122ec3ae47bbf40e38bec56d879502005397b1.zip |
[BZ #3252, BZ #3253] cvs/fedora-glibc-20060925T1535
2006-09-25 Jakub Jelinek <jakub@redhat.com> [BZ #3252] * sysdeps/unix/sysv/linux/powerpc/fchownat.c (fchownat): Handle only fchownat syscall and __ASSUME_LCHOWN_SYSCALL case inline, call __{,l}chown to handle the rest. * sysdeps/unix/sysv/linux/i386/fchownat.c (fchownat): Handle only fchownat syscall and __ASSUME_32BITUIDS case inline, call __{,l}chown to handle the rest. * sysdeps/unix/sysv/linux/sparc/sparc32/fchownat.c: Include i386/fchownat.c. * sysdeps/unix/sysv/linux/s390/s390-32/fchownat.c: Likewise. * sysdeps/unix/sysv/linux/sh/fchownat.c: Likewise. [BZ #3253] * posix/glob.c (glob_in_dir): Don't alloca one struct globlink at a time, rather allocate increasingly bigger arrays of pointers, if possible with alloca, if too large with malloc. 2006-09-24 Jakub Jelinek <jakub@redhat.com> * sysdeps/powerpc/fpu/libm-test-ulps: Updated. * sysdeps/ieee754/ldbl-128/s_lrintl.c (__lrintl): Fix 2 typos.
Diffstat (limited to 'sysdeps/unix/sysv/linux/powerpc/fchownat.c')
-rw-r--r-- | sysdeps/unix/sysv/linux/powerpc/fchownat.c | 139 |
1 files changed, 13 insertions, 126 deletions
diff --git a/sysdeps/unix/sysv/linux/powerpc/fchownat.c b/sysdeps/unix/sysv/linux/powerpc/fchownat.c index f1b9b4db4a..67c570648a 100644 --- a/sysdeps/unix/sysv/linux/powerpc/fchownat.c +++ b/sysdeps/unix/sysv/linux/powerpc/fchownat.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2005 Free Software Foundation, Inc. +/* Copyright (C) 2005, 2006 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 @@ -81,143 +81,30 @@ fchownat (int fd, const char *file, uid_t owner, gid_t group, int flag) file = buf; } +# if __ASSUME_LCHOWN_SYSCALL INTERNAL_SYSCALL_DECL (err); -# if __ASSUME_LCHOWN_SYSCALL if (flag & AT_SYMLINK_NOFOLLOW) result = INTERNAL_SYSCALL (lchown, err, 3, file, owner, group); else result = INTERNAL_SYSCALL (chown, err, 3, file, owner, group); -# else - char link[PATH_MAX + 2]; - char path[2 * PATH_MAX + 4]; - int loopct; - size_t filelen; - static int libc_old_chown = 0 /* -1=old linux, 1=new linux, 0=unknown */; - - if (libc_old_chown == 1) - { - if (flag & AT_SYMLINK_NOFOLLOW) - result = INTERNAL_SYSCALL (lchown, err, 3, __ptrvalue (file), owner, - group); - else - result = INTERNAL_SYSCALL (chown, err, 3, __ptrvalue (file), owner, - group); - goto out; - } - -# ifdef __NR_lchown - if (flag & AT_SYMLINK_NOFOLLOW) - { - result = INTERNAL_SYSCALL (lchown, err, 3, __ptrvalue (file), owner, - group); - goto out; - } - - if (libc_old_chown == 0) - { - result = INTERNAL_SYSCALL (chown, err, 3, __ptrvalue (file), owner, - group); - if (__builtin_expect (!INTERNAL_SYSCALL_ERROR_P (result, err), 1)) - return result; - if (INTERNAL_SYSCALL_ERRNO (result, err) != ENOSYS) - { - libc_old_chown = 1; - goto fail; - } - libc_old_chown = -1; - } -# else - if (flag & AT_SYMLINK_NOFOLLOW) - { - result = INTERNAL_SYSCALL (chown, err, 3, __ptrvalue (file), owner, - group); - goto out; - } -# endif - - result = __readlink (file, link, PATH_MAX + 1); - if (result == -1) - { -# ifdef __NR_lchown - result = INTERNAL_SYSCALL (lchown, err, 3, __ptrvalue (file), owner, - group); -# else - result = INTERNAL_SYSCALL (chown, err, 3, __ptrvalue (file), owner, - group); -# endif - goto out; - } - - filelen = strlen (file) + 1; - if (filelen > sizeof (path)) - { - errno = ENAMETOOLONG; - return -1; - } - memcpy (path, file, filelen); - - /* 'The system has an arbitrary limit...' In practise, we'll hit - ENAMETOOLONG before this, usually. */ - for (loopct = 0; loopct < 128; ++loopct) - { - size_t linklen; - - if (result >= PATH_MAX + 1) - { - errno = ENAMETOOLONG; - return -1; - } - - link[result] = 0; /* Null-terminate string, just-in-case. */ - - linklen = strlen (link) + 1; - - if (link[0] == '/') - memcpy (path, link, linklen); - else - { - filelen = strlen (path); - - while (filelen > 1 && path[filelen - 1] == '/') - --filelen; - while (filelen > 0 && path[filelen - 1] != '/') - --filelen; - if (filelen + linklen > sizeof (path)) - { - errno = ENAMETOOLONG; - return -1; - } - memcpy (path + filelen, link, linklen); - } - - result = __readlink (path, link, PATH_MAX + 1); - - if (result == -1) - { -# ifdef __NR_lchown - result = INTERNAL_SYSCALL (lchown, err, 3, path, owner, group); -# else - result = INTERNAL_SYSCALL (chown, err, 3, path, owner, group); -# endif - goto out; - } - } - __set_errno (ELOOP); - return -1; - - out: -# endif if (__builtin_expect (INTERNAL_SYSCALL_ERROR_P (result, err), 0)) { -# if !__ASSUME_LCHOWN_SYSCALL - fail: -# endif __atfct_seterrno (INTERNAL_SYSCALL_ERRNO (result, err), fd, buf); - result = -1; + return -1; } +# else + /* Don't inline the rest to avoid unnecessary code duplication. */ + if (flag & AT_SYMLINK_NOFOLLOW) + result = __lchown (file, owner, group); + else + result = __chown (file, owner, group); + if (result < 0) + __atfct_seterrno (errno, fd, buf); +# endif return result; + #endif } |