[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v2 18/32] Implement stat related syscalls
From: |
Karim Taha |
Subject: |
[PATCH v2 18/32] Implement stat related syscalls |
Date: |
Sun, 13 Aug 2023 05:09:59 +0200 |
From: Stacey Son <sson@FreeBSD.org>
Implement the following syscalls:
getfh(2)
lgetfh(2)
fhopen(2)
fhstat(2)
fhstatfs(2)
Signed-off-by: Stacey Son <sson@FreeBSD.org>
Signed-off-by: Karim Taha <kariem.taha2.7@gmail.com>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
---
bsd-user/freebsd/os-stat.h | 83 ++++++++++++++++++++++++++++++++++++++
1 file changed, 83 insertions(+)
diff --git a/bsd-user/freebsd/os-stat.h b/bsd-user/freebsd/os-stat.h
index f8f99b4a72..935663c071 100644
--- a/bsd-user/freebsd/os-stat.h
+++ b/bsd-user/freebsd/os-stat.h
@@ -127,4 +127,87 @@ static abi_long do_freebsd11_nlstat(abi_long arg1,
abi_long arg2)
return ret;
}
+/* getfh(2) */
+static abi_long do_freebsd_getfh(abi_long arg1, abi_long arg2)
+{
+ abi_long ret;
+ void *p;
+ fhandle_t host_fh;
+
+ LOCK_PATH(p, arg1);
+ ret = get_errno(getfh(path(p), &host_fh));
+ UNLOCK_PATH(p, arg1);
+ if (is_error(ret)) {
+ return ret;
+ }
+ return h2t_freebsd_fhandle(arg2, &host_fh);
+}
+
+/* lgetfh(2) */
+static inline abi_long do_freebsd_lgetfh(abi_long arg1, abi_long arg2)
+{
+ abi_long ret;
+ void *p;
+ fhandle_t host_fh;
+
+ LOCK_PATH(p, arg1);
+ ret = get_errno(lgetfh(path(p), &host_fh));
+ UNLOCK_PATH(p, arg1);
+ if (is_error(ret)) {
+ return ret;
+ }
+ return h2t_freebsd_fhandle(arg2, &host_fh);
+}
+
+/* fhopen(2) */
+static inline abi_long do_freebsd_fhopen(abi_long arg1, abi_long arg2)
+{
+ abi_long ret;
+ fhandle_t host_fh;
+
+ ret = t2h_freebsd_fhandle(&host_fh, arg1);
+ if (is_error(ret)) {
+ return ret;
+ }
+
+ return get_errno(fhopen(&host_fh, arg2));
+}
+
+/* fhstat(2) */
+static inline abi_long do_freebsd_fhstat(abi_long arg1, abi_long arg2)
+{
+ abi_long ret;
+ fhandle_t host_fh;
+ struct stat host_sb;
+
+ ret = t2h_freebsd_fhandle(&host_fh, arg1);
+ if (is_error(ret)) {
+ return ret;
+ }
+ ret = get_errno(fhstat(&host_fh, &host_sb));
+ if (is_error(ret)) {
+ return ret;
+ }
+ return h2t_freebsd_stat(arg2, &host_sb);
+}
+
+/* fhstatfs(2) */
+static inline abi_long do_freebsd_fhstatfs(abi_ulong target_fhp_addr,
+ abi_ulong target_stfs_addr)
+{
+ abi_long ret;
+ fhandle_t host_fh;
+ struct statfs host_stfs;
+
+ ret = t2h_freebsd_fhandle(&host_fh, target_fhp_addr);
+ if (is_error(ret)) {
+ return ret;
+ }
+ ret = get_errno(fhstatfs(&host_fh, &host_stfs));
+ if (is_error(ret)) {
+ return ret;
+ }
+ return h2t_freebsd_statfs(target_stfs_addr, &host_stfs);
+}
+
#endif /* BSD_USER_FREEBSD_OS_STAT_H */
--
2.40.0
- [PATCH v2 10/32] Define safe_fcntl macro in bsd-user/syscall_defs.h, (continued)
- [PATCH v2 10/32] Define safe_fcntl macro in bsd-user/syscall_defs.h, Karim Taha, 2023/08/13
- [PATCH v2 11/32] Rename target_freebsd_time_t to target_time_t, Karim Taha, 2023/08/13
- [PATCH v2 09/32] Add struct target_freebsd_fhandle and fcntl flags to bsd-user/syscall_defs.h, Karim Taha, 2023/08/13
- [PATCH v2 13/32] Implement h2t_freebsd_fhandle t2h_freebsd_fhandle functions, Karim Taha, 2023/08/13
- [PATCH v2 15/32] Implement target_to_host_fcntl_cmd, Karim Taha, 2023/08/13
- [PATCH v2 17/32] Implement stat related syscalls, Karim Taha, 2023/08/13
- [PATCH v2 21/32] Implement stat related syscalls, Karim Taha, 2023/08/13
- [PATCH v2 12/32] Implement h2t_freebsd11_stat h2t_freebsd_nstat, Karim Taha, 2023/08/13
- [PATCH v2 14/32] Implement h2t_freebds11_statfs, Karim Taha, 2023/08/13
- [PATCH v2 16/32] Implement h2t_freebsd_stat and h2t_freebsd_statfs functions, Karim Taha, 2023/08/13
- [PATCH v2 18/32] Implement stat related syscalls,
Karim Taha <=
- [PATCH v2 26/32] Implement freebsd11 stat related syscalls, Karim Taha, 2023/08/13
- [PATCH v2 30/32] Add glue to call the following syscalls to the freebsd_syscall function:, Karim Taha, 2023/08/13
- [PATCH v2 31/32] Add glue to call the following syscalls to the freebsd_syscall function:, Karim Taha, 2023/08/13
- [PATCH v2 24/32] Implement freebsd11 stat related syscalls, Karim Taha, 2023/08/13
- [PATCH v2 32/32] Add glue to call the following syscalls to the freebsd_syscall function:, Karim Taha, 2023/08/13
- [PATCH v2 20/32] Implement stat related syscalls, Karim Taha, 2023/08/13
- [PATCH v2 29/32] Add glue to call the following syscalls to the freebsd_syscall function:, Karim Taha, 2023/08/13
- [PATCH v2 19/32] Implement stat related syscalls, Karim Taha, 2023/08/13
- [PATCH v2 22/32] Implement freebsd11 stat related syscalls, Karim Taha, 2023/08/13
- [PATCH v2 23/32] Implement freebsd11 stat related syscalls, Karim Taha, 2023/08/13