blob: c0f8ce76387c55790e0b0e2cc12ee5a88ec67597 [file] [log] [blame]
yuezonghe824eb0c2024-06-27 02:32:26 -07001/* vi: set sw=4 ts=4: */
2/*
3 * lchown() for uClibc
4 *
5 * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
6 *
7 * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
8 */
9
10#include <sys/syscall.h>
11#include <unistd.h>
12#include <bits/wordsize.h>
13
14#if (__WORDSIZE == 32 && defined(__NR_lchown32)) || __WORDSIZE == 64
15# ifdef __NR_lchown32
16# undef __NR_lchown
17# define __NR_lchown __NR_lchown32
18# endif
19
20_syscall3(int, lchown, const char *, path, uid_t, owner, gid_t, group)
21
22#else
23
24# define __NR___syscall_lchown __NR_lchown
25static __inline__ _syscall3(int, __syscall_lchown, const char *, path,
26 __kernel_uid_t, owner, __kernel_gid_t, group)
27
28int lchown(const char *path, uid_t owner, gid_t group)
29{
30 if (((owner + 1) > (uid_t) ((__kernel_uid_t) - 1U))
31 || ((group + 1) > (gid_t) ((__kernel_gid_t) - 1U))) {
32 __set_errno(EINVAL);
33 return -1;
34 }
35 return __syscall_lchown(path, owner, group);
36}
37
38#endif