]> git.ipfire.org Git - thirdparty/glibc.git/blame - sysdeps/unix/sysv/linux/i386/fchown.c
Replace FSF snail mail address with URLs.
[thirdparty/glibc.git] / sysdeps / unix / sysv / linux / i386 / fchown.c
CommitLineData
6ddd37a4 1/* Copyright (C) 2000, 2003, 2006 Free Software Foundation, Inc.
313fed01
UD
2 This file is part of the GNU C Library.
3
4 The GNU C Library is free software; you can redistribute it and/or
41bdb6e2
AJ
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
313fed01
UD
8
9 The GNU C Library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
41bdb6e2 12 Lesser General Public License for more details.
313fed01 13
41bdb6e2 14 You should have received a copy of the GNU Lesser General Public
59ba27a6
PE
15 License along with the GNU C Library; if not, see
16 <http://www.gnu.org/licenses/>. */
313fed01
UD
17
18#include <errno.h>
19#include <unistd.h>
20
21#include <sysdep.h>
22#include <sys/syscall.h>
23
24#include <linux/posix_types.h>
6ddd37a4 25#include <kernel-features.h>
313fed01 26
313fed01 27#ifdef __NR_fchown32
313fed01
UD
28# if __ASSUME_32BITUIDS == 0
29/* This variable is shared with all files that need to check for 32bit
30 uids. */
31extern int __libc_missing_32bit_uids;
32# endif
33#endif /* __NR_fchown32 */
34
35int
36__fchown (int fd, uid_t owner, gid_t group)
37{
38#if __ASSUME_32BITUIDS > 0
39 return INLINE_SYSCALL (fchown32, 3, fd, owner, group);
40#else
41# ifdef __NR_fchown32
cd090f71 42 if (__libc_missing_32bit_uids <= 0)
313fed01
UD
43 {
44 int result;
45 int saved_errno = errno;
46
47 result = INLINE_SYSCALL (fchown32, 3, fd, owner, group);
48 if (result == 0 || errno != ENOSYS)
49 return result;
50
51 __set_errno (saved_errno);
52 __libc_missing_32bit_uids = 1;
53 }
54# endif /* __NR_fchown32 */
55
0482576e
UD
56 if (((owner + 1) > (uid_t) ((__kernel_uid_t) -1U))
57 || ((group + 1) > (gid_t) ((__kernel_gid_t) -1U)))
313fed01
UD
58 {
59 __set_errno (EINVAL);
60 return -1;
61 }
62
63 return INLINE_SYSCALL (fchown, 3, fd, owner, group);
64#endif
65}
66
67weak_alias (__fchown, fchown)