1 /*
2  * fchmodat() for uClibc
3  *
4  * Copyright (C) 2009 Analog Devices Inc.
5  * Copyright (C) 2012 Mike Frysinger
6  *
7  * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
8  */
9 
10 #include <fcntl.h>
11 #include <sys/syscall.h>
12 #include <sys/stat.h>
13 
14 #ifdef __NR_fchmodat
15 /*
16  * The kernel takes 3 args, but userland takes 4.
17  * We have to process all the flags ourselves.
18  */
fchmodat(int fd,const char * file,mode_t mode,int flag)19 int fchmodat(int fd, const char *file, mode_t mode, int flag)
20 {
21 	/* We only support one flag atm ... */
22 	if (flag & ~AT_SYMLINK_NOFOLLOW) {
23 		__set_errno(EINVAL);
24 		return -1;
25 	}
26 
27 	/* ... but Linux doesn't support perms on symlinks. */
28 	if (flag & AT_SYMLINK_NOFOLLOW) {
29 		__set_errno(ENOTSUP);
30 		return -1;
31 	}
32 
33 	return INLINE_SYSCALL(fchmodat, 3, fd, file, mode);
34 }
35 libc_hidden_def(fchmodat)
36 #else
37 /* should add emulation with fchmod() and /proc/self/fd/ ... */
38 #endif
39