Update copyright notices with scripts/update-copyrights
[glibc.git] / sysdeps / unix / sysv / linux / i386 / chown.c
blob4f63b2cc9e0e2f7e4684ee3505e397a557dc00e9
1 /* Copyright (C) 1998-2014 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
4 The GNU C Library is free software; you can redistribute it and/or
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.
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
12 Lesser General Public License for more details.
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, see
16 <http://www.gnu.org/licenses/>. */
18 #include <errno.h>
19 #include <unistd.h>
21 #include <sysdep.h>
22 #include <sys/syscall.h>
23 #include <shlib-compat.h>
25 #include <linux/posix_types.h>
28 In Linux 2.1.x the chown functions have been changed. A new function lchown
29 was introduced. The new chown now follows symlinks - the old chown and the
30 new lchown do not follow symlinks.
31 The new lchown function has the same number as the old chown had and the
32 new chown has a new number. When compiling with headers from Linux > 2.1.8x
33 it's impossible to run this libc with older kernels. In these cases libc
34 has therefore to route calls to chown to the old chown function.
37 extern int __chown_is_lchown (const char *__file, uid_t __owner,
38 gid_t __group);
39 extern int __real_chown (const char *__file, uid_t __owner, gid_t __group);
42 /* Consider moving to syscalls.list. */
44 int
45 __real_chown (const char *file, uid_t owner, gid_t group)
47 return INLINE_SYSCALL (chown32, 3, file, owner, group);
51 #if SHLIB_COMPAT (libc, GLIBC_2_0, GLIBC_2_1)
52 /* Compiling for compatibility. */
53 int
54 attribute_compat_text_section
55 __chown_is_lchown (const char *file, uid_t owner, gid_t group)
57 return __lchown (file, owner, group);
59 #endif
61 #if SHLIB_COMPAT (libc, GLIBC_2_0, GLIBC_2_1)
62 compat_symbol (libc, __chown_is_lchown, chown, GLIBC_2_0);
63 #endif
65 versioned_symbol (libc, __real_chown, chown, GLIBC_2_1);
66 strong_alias (__real_chown, __chown)
67 libc_hidden_def (__chown)