[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL v2 02/22] linux-user: Add support for ustat() syscall
From: |
riku . voipio |
Subject: |
[Qemu-devel] [PULL v2 02/22] linux-user: Add support for ustat() syscall |
Date: |
Tue, 18 Oct 2016 16:21:30 +0300 |
From: Aleksandar Markovic <address@hidden>
This patch implements Qemu user mode ustat() syscall support.
Syscall ustat() returns information about a mounted filesystem.
Its declaration is:
int ustat(dev_t dev, struct ustat *ubuf);
Its Linux kernel implementation is at fs/compat.c, line 334.
The Qemu implementation proposed in this patch is similar to the
Qemu implementations of statfs(), fstatfs() and other related syscalls.
It is based on invocation of host's ustat(), and its key part is in the
correspondent case segment of the main switch statement of the function
do_syscall(), in file linux-user/syscalls.c. All necessary conversions
of data structures from target to host and from host to target are
covered. Support for target_ustat is included. Sufficient support for
"-strace" option for this syscall is already present, and this patch
does not change it.
This patch also fixes failures of LTP tests ustat01, and ustat02, if
executed on Qemu-emulated systems.
Signed-off-by: Aleksandar Markovic <address@hidden>
Signed-off-by: Riku Voipio <address@hidden>
---
linux-user/syscall.c | 23 +++++++++++++++++++++--
linux-user/syscall_defs.h | 6 ++++++
2 files changed, 27 insertions(+), 2 deletions(-)
diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index 0379b8a..88007e0 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -48,6 +48,7 @@ int __clone2(int (*fn)(void *), void *child_stack_base,
#include <sys/shm.h>
#include <sys/sem.h>
#include <sys/statfs.h>
+#include <ustat.h>
#include <utime.h>
#include <sys/sysinfo.h>
#include <sys/signalfd.h>
@@ -8227,9 +8228,27 @@ abi_long do_syscall(void *cpu_env, int num, abi_long
arg1,
ret = get_errno(chroot(p));
unlock_user(p, arg1, 0);
break;
-#ifdef TARGET_NR_ustat
+#if defined(TARGET_NR_ustat)
case TARGET_NR_ustat:
- goto unimplemented;
+ {
+ struct ustat ust;
+
+ ret = get_errno(ustat(arg1, &ust));
+ if (!is_error(ret)) {
+ struct target_ustat *target_ust;
+
+ if (!lock_user_struct(VERIFY_WRITE, target_ust, arg2, 0)) {
+ goto efault;
+ }
+ __put_user(ust.f_tfree, &target_ust->f_tfree);
+ __put_user(ust.f_tinode, &target_ust->f_tinode);
+ memcpy(target_ust->f_fname, ust.f_fname, 6);
+ memcpy(target_ust->f_fpack, ust.f_fpack, 6);
+ unlock_user_struct(target_ust, arg2, 1);
+ }
+ }
+ break;
+
#endif
#ifdef TARGET_NR_dup2
case TARGET_NR_dup2:
diff --git a/linux-user/syscall_defs.h b/linux-user/syscall_defs.h
index ca8fa6e..7872b9d 100644
--- a/linux-user/syscall_defs.h
+++ b/linux-user/syscall_defs.h
@@ -2168,6 +2168,12 @@ struct target_statfs64 {
};
#endif
+struct target_ustat {
+ abi_ulong f_tfree;
+ abi_int f_tinode;
+ char f_fname[6];
+ char f_fpack[6];
+};
#define TARGET_F_DUPFD 0 /* dup */
#define TARGET_F_GETFD 1 /* get close_on_exec */
--
2.1.4
- [Qemu-devel] [PULL v2 00/22] linux-user changes, riku . voipio, 2016/10/18
- [Qemu-devel] [PULL v2 03/22] linux-user: Fix mq_open() syscall support, riku . voipio, 2016/10/18
- [Qemu-devel] [PULL v2 04/22] linux-user: Fix msgrcv() and msgsnd() syscalls support, riku . voipio, 2016/10/18
- [Qemu-devel] [PULL v2 02/22] linux-user: Add support for ustat() syscall,
riku . voipio <=
- [Qemu-devel] [PULL v2 01/22] linux-user: Add support for adjtimex() syscall, riku . voipio, 2016/10/18
- [Qemu-devel] [PULL v2 07/22] linux-user: Remove a duplicate item from strace.list, riku . voipio, 2016/10/18
- [Qemu-devel] [PULL v2 05/22] linux-user: Fix socketcall() syscall support, riku . voipio, 2016/10/18
- [Qemu-devel] [PULL v2 11/22] linux-user: Don't use alloca() for epoll_wait's epoll event array, riku . voipio, 2016/10/18
- [Qemu-devel] [PULL v2 08/22] linux-user: sparc64: Use correct target SHMLBA in shmat(), riku . voipio, 2016/10/18
- [Qemu-devel] [PULL v2 12/22] linux-user: use libc wrapper instead of direct mremap syscall, riku . voipio, 2016/10/18
- [Qemu-devel] [PULL v2 13/22] linux-user: Fix definition of target_sigevent for 32-bit guests, riku . voipio, 2016/10/18
- [Qemu-devel] [PULL v2 09/22] linux-user: add kcmp() syscall, riku . voipio, 2016/10/18
- [Qemu-devel] [PULL v2 16/22] linux-user: Update mips_syscall_args[] array in main.c, riku . voipio, 2016/10/18
- [Qemu-devel] [PULL v2 06/22] linux-user: Fix syslog() syscall support, riku . voipio, 2016/10/18