2 * Copyright 2002-2009, Axel Dörfler, axeld@pinc-software.de.
3 * Distributed under the terms of the MIT License.
10 #include <NodeMonitor.h>
12 #include <errno_private.h>
14 #include <syscall_utils.h>
18 common_chown(int fd
, const char* path
, bool followLinks
, uid_t owner
,
25 if (owner
!= (uid_t
)-1) {
29 if (group
!= (gid_t
)-1) {
34 status
= _kern_write_stat(fd
, path
, followLinks
, &stat
,
35 sizeof(struct stat
), mask
);
37 RETURN_AND_SET_ERRNO(status
);
42 chown(const char *path
, uid_t owner
, gid_t group
)
44 return common_chown(-1, path
, true, owner
, group
);
49 lchown(const char *path
, uid_t owner
, gid_t group
)
51 return common_chown(-1, path
, false, owner
, group
);
56 fchown(int fd
, uid_t owner
, gid_t group
)
58 return common_chown(fd
, NULL
, false, owner
, group
);
63 fchownat(int fd
, const char* path
, uid_t owner
, gid_t group
, int flag
)
65 return common_chown(fd
, path
, (flag
& AT_SYMLINK_NOFOLLOW
) == 0, owner
,