fchmod.c 489 字节
Newer Older
R
Rich Felker 已提交
1
#include <sys/stat.h>
2
#include <errno.h>
3
#include <fcntl.h>
W
w00349915 已提交
4 5
#include <unsupported_api.h>

R
Rich Felker 已提交
6 7 8 9
#include "syscall.h"

int fchmod(int fd, mode_t mode)
{
W
w00349915 已提交
10
	unsupported_api(__FUNCTION__);
11
	int ret = __syscall(SYS_fchmod, fd, mode);
12 13
	if (ret != -EBADF || __syscall(SYS_fcntl, fd, F_GETFD) < 0)
		return __syscall_ret(ret);
14 15 16

	char buf[15+3*sizeof(int)];
	__procfdname(buf, fd);
17
#ifdef SYS_chmod
18
	return syscall(SYS_chmod, buf, mode);
19 20 21
#else
	return syscall(SYS_fchmodat, AT_FDCWD, buf, mode);
#endif
R
Rich Felker 已提交
22
}