1/* 2 * Copyright 2002-2009, Axel Dörfler, axeld@pinc-software.de. 3 * Distributed under the terms of the MIT License. 4 */ 5 6 7#include <errno.h> 8#include <sys/stat.h> 9 10#include <NodeMonitor.h> 11 12#include <errno_private.h> 13#include <syscalls.h> 14#include <syscall_utils.h> 15 16 17int 18chmod(const char *path, mode_t mode) 19{ 20 struct stat stat; 21 status_t status; 22 23 stat.st_mode = mode; 24 status = _kern_write_stat(-1, path, true, &stat, sizeof(struct stat), 25 B_STAT_MODE); 26 27 RETURN_AND_SET_ERRNO(status); 28} 29 30 31int 32fchmod(int fd, mode_t mode) 33{ 34 struct stat stat; 35 status_t status; 36 37 stat.st_mode = mode; 38 status = _kern_write_stat(fd, NULL, false, &stat, sizeof(struct stat), 39 B_STAT_MODE); 40 41 RETURN_AND_SET_ERRNO(status); 42} 43 44 45int 46fchmodat(int fd, const char* path, mode_t mode, int flag) 47{ 48 struct stat stat; 49 status_t status; 50 51 stat.st_mode = mode; 52 status = _kern_write_stat(fd, path, (flag & AT_SYMLINK_NOFOLLOW) == 0, &stat, 53 sizeof(struct stat), B_STAT_MODE); 54 55 RETURN_AND_SET_ERRNO(status); 56} 57