fix: add fchmod api

add fchmod api and testcases

Change-Id: I310e9e9d79bbe3fa8dbab6080bbfce8a77b79bb3
Signed-off-by: wcc0 <917033401@qq.com>
This commit is contained in:
wcc0
2021-08-11 14:07:03 +08:00
parent 76507c05a8
commit 2f214bf4de
8 changed files with 182 additions and 17 deletions

View File

@@ -2268,6 +2268,34 @@ OUT:
return ret;
}
int SysFchmod(int fd, mode_t mode)
{
int ret;
int sysFd;
struct IATTR attr = {
.attr_chg_mode = mode,
.attr_chg_valid = CHG_MODE, /* change mode */
};
struct file *file = NULL;
sysFd = GetAssociatedSystemFd(fd);
if (sysFd < 0) {
return -EBADF;
}
ret = fs_getfilep(sysFd, &file);
if (ret < 0) {
return -get_errno();
}
ret = chattr(file->f_path, &attr);
if (ret < 0) {
return -get_errno();
}
return ret;
}
int SysFchownat(int fd, const char *path, uid_t owner, gid_t group, int flag)
{
int ret;

View File

@@ -234,6 +234,7 @@ extern int SysExecve(const char *fileName, char *const *argv, char *const *envp)
extern int SysChdir(const char *path);
extern int SysUtimensat(int fd, const char *path, struct timespec times[2], int flag);
extern int SysFchmodat(int fd, const char *path, mode_t mode, int flag);
extern int SysFchmod(int fd, mode_t mode);
extern int SysChmod(const char *path, mode_t mode);
extern int SysFchownat(int fd, const char *path, uid_t owner, gid_t group, int flag);
extern int SysFchown(int fd, uid_t owner, gid_t group);

View File

@@ -50,6 +50,7 @@ SYSCALL_HAND_DEF(__NR_sysinfo, SysInfo, int, ARG_NUM_1)
SYSCALL_HAND_DEF(__NR_chdir, SysChdir, int, ARG_NUM_1)
SYSCALL_HAND_DEF(__NR_utimensat, SysUtimensat, int, ARG_NUM_4)
SYSCALL_HAND_DEF(__NR_fchmodat, SysFchmodat, int, ARG_NUM_4)
SYSCALL_HAND_DEF(__NR_fchmod, SysFchmod, int, ARG_NUM_2)
SYSCALL_HAND_DEF(__NR_utimensat, SysUtimensat, int, ARG_NUM_4)
SYSCALL_HAND_DEF(__NR_chmod, SysChmod, int, ARG_NUM_2)
SYSCALL_HAND_DEF(__NR_lseek, SysLseek, off_t, ARG_NUM_7) /* current only support 32bit max 4G file */