Skip to content

Commit 1714828

Browse files
pm215Michael Tokarev
authored andcommitted
linux-user: Implement fchmodat2 syscall
The fchmodat2 syscall is new from Linux 6.6; it is like the existing fchmodat syscall except that it takes a flags parameter. Resolves: https://gitlab.com/qemu-project/qemu/-/issues/3019 Signed-off-by: Peter Maydell <[email protected]> Reviewed-by: Philippe Mathieu-Daudé <[email protected]> Reviewed-by: Richard Henderson <[email protected]> Signed-off-by: Richard Henderson <[email protected]> Message-ID: <[email protected]> (cherry picked from commit 6a3e132a1be8c9e649967a4eb341d00731be7f51) Signed-off-by: Michael Tokarev <[email protected]>
1 parent 676bc0f commit 1714828

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

linux-user/syscall.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -789,6 +789,10 @@ safe_syscall6(ssize_t, copy_file_range, int, infd, loff_t *, pinoff,
789789
int, outfd, loff_t *, poutoff, size_t, length,
790790
unsigned int, flags)
791791
#endif
792+
#if defined(TARGET_NR_fchmodat2) && defined(__NR_fchmodat2)
793+
safe_syscall4(int, fchmodat2, int, dfd, const char *, filename,
794+
unsigned short, mode, unsigned int, flags)
795+
#endif
792796

793797
/* We do ioctl like this rather than via safe_syscall3 to preserve the
794798
* "third argument might be integer or pointer or not present" behaviour of
@@ -10709,6 +10713,15 @@ static abi_long do_syscall1(CPUArchState *cpu_env, int num, abi_long arg1,
1070910713
ret = get_errno(fchmodat(arg1, p, arg3, 0));
1071010714
unlock_user(p, arg2, 0);
1071110715
return ret;
10716+
#endif
10717+
#if defined(TARGET_NR_fchmodat2) && defined(__NR_fchmodat2)
10718+
case TARGET_NR_fchmodat2:
10719+
if (!(p = lock_user_string(arg2))) {
10720+
return -TARGET_EFAULT;
10721+
}
10722+
ret = get_errno(safe_fchmodat2(arg1, p, arg3, arg4));
10723+
unlock_user(p, arg2, 0);
10724+
return ret;
1071210725
#endif
1071310726
case TARGET_NR_getpriority:
1071410727
/* Note that negative values are valid for getpriority, so we must

0 commit comments

Comments
 (0)