From: Stacey Son <sson@FreeBSD.org>
Implement the stat conversion functions:
h2t_freebds11_statfs
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>
Signed-off-by: Warner Losh <imp@bsdimp.com>
---
bsd-user/freebsd/os-stat.c | 41 ++++++++++++++++++++++++++++++++++++++
1 file changed, 41 insertions(+)
diff --git a/bsd-user/freebsd/os-stat.c b/bsd-user/freebsd/os-stat.c
index 6716cee3e22..9eb01bf6645 100644
--- a/bsd-user/freebsd/os-stat.c
+++ b/bsd-user/freebsd/os-stat.c
@@ -129,3 +129,44 @@ abi_long h2t_freebsd_fhandle(abi_ulong target_addr, fhandle_t *host_fh)
return 0;
}
+/*
+ * file system stat
+ */
+abi_long h2t_freebsd11_statfs(abi_ulong target_addr,
+ struct freebsd11_statfs *host_statfs)
+{
+ struct target_freebsd11_statfs *target_statfs;
+
+ if (!lock_user_struct(VERIFY_WRITE, target_statfs, target_addr, 0)) {
+ return -TARGET_EFAULT;
+ }
+ __put_user(host_statfs->f_version, &target_statfs->f_version);
+ __put_user(host_statfs->f_type, &target_statfs->f_type);
+ __put_user(host_statfs->f_flags, &target_statfs->f_flags);
+ __put_user(host_statfs->f_bsize, &target_statfs->f_bsize);
+ __put_user(host_statfs->f_iosize, &target_statfs->f_iosize);
+ __put_user(host_statfs->f_blocks, &target_statfs->f_blocks);
+ __put_user(host_statfs->f_bfree, &target_statfs->f_bfree);
+ __put_user(host_statfs->f_bavail, &target_statfs->f_bavail);
+ __put_user(host_statfs->f_files, &target_statfs->f_files);
+ __put_user(host_statfs->f_ffree, &target_statfs->f_ffree);
+ __put_user(host_statfs->f_syncwrites, &target_statfs->f_syncwrites);
+ __put_user(host_statfs->f_asyncwrites, &target_statfs->f_asyncwrites);
+ __put_user(host_statfs->f_syncreads, &target_statfs->f_syncreads);
+ __put_user(host_statfs->f_asyncreads, &target_statfs->f_asyncreads);
+ /* uint64_t f_spare[10]; */
+ __put_user(host_statfs->f_namemax, &target_statfs->f_namemax);
+ __put_user(host_statfs->f_owner, &target_statfs->f_owner);
+ __put_user(host_statfs->f_fsid.val[0], &target_statfs->f_fsid.val[0]);
+ __put_user(host_statfs->f_fsid.val[1], &target_statfs->f_fsid.val[1]);
+ /* char f_charspace[80]; */
+ strncpy(target_statfs->f_fstypename, host_statfs->f_fstypename,
+ sizeof(target_statfs->f_fstypename));
+ strncpy(target_statfs->f_mntfromname, host_statfs->f_mntfromname,
+ sizeof(target_statfs->f_mntfromname));
+ strncpy(target_statfs->f_mntonname, host_statfs->f_mntonname,
+ sizeof(target_statfs->f_mntonname));
+ unlock_user_struct(target_statfs, target_addr, 1);
+ return 0;
+}
+
--
2.41.0