@@ -2342,6 +2342,33 @@ print_kill(const struct syscallname *name,
}
#endif
+#ifdef TARGET_NR_sysfs
+static void
+print_sysfs(const struct syscallname *name,
+ abi_long arg0, abi_long arg1, abi_long arg2,
+ abi_long arg3, abi_long arg4, abi_long arg5)
+{
+ print_syscall_prologue(name);
+ /* arg0 is normally 1, 2, or 3 */
+ switch (arg0) {
+ case 1:
+ print_raw_param("%d", arg0, 0);
+ print_string(arg1, 1);
+ break;
+ case 2:
+ print_raw_param("%d", arg0, 0);
+ print_raw_param("%u", arg1, 0);
+ print_pointer(arg2, 1);
+ break;
+ /* if arg0 is 3, desired output is the same as default */
+ default:
+ print_raw_param("%d", arg0, 1);
+ break;
+ }
+ print_syscall_epilogue(name);
+}
+#endif
+
/*
* An array of all of the syscalls we know about
*/
@@ -1372,7 +1372,7 @@
{ TARGET_NR_sys_epoll_wait, "sys_epoll_wait" , NULL, NULL, NULL },
#endif
#ifdef TARGET_NR_sysfs
-{ TARGET_NR_sysfs, "sysfs" , NULL, NULL, NULL },
+{ TARGET_NR_sysfs, "sysfs" , NULL, print_sysfs, NULL },
#endif
#ifdef TARGET_NR_sysinfo
{ TARGET_NR_sysinfo, "sysinfo" , NULL, NULL, NULL },
@@ -7450,7 +7450,7 @@ static int do_openat(void *cpu_env, int dirfd, const char *pathname, int flags,
if (fake_open->filename) {
const char *tmpdir;
- char filename[PATH_MAX];
+ char filename[128];
int fd, r;
/* create temporary file to map stat to */
@@ -9666,9 +9666,42 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1,
case TARGET_NR_bdflush:
goto unimplemented;
#endif
-#ifdef TARGET_NR_sysfs
+#if defined(TARGET_NR_sysfs)
case TARGET_NR_sysfs:
- goto unimplemented;
+ switch (arg1) {
+ case 1:
+ {
+ p = lock_user_string(arg2);
+ if (!p) {
+ goto efault;
+ }
+ ret = get_errno(syscall(__NR_sysfs, arg1, p));
+ unlock_user(p, arg2, 0);
+ }
+ break;
+ case 2:
+ {
+ char buf[PATH_MAX];
+ memset(buf, 0, PATH_MAX);
+ ret = get_errno(syscall(__NR_sysfs, arg1, arg2, buf));
+ if (!is_error(ret)) {
+ int len = PATH_MAX;
+ if (len > strlen(buf)) {
+ len = strlen(buf);
+ }
+ if (copy_to_user(arg3, buf, len) != 0) {
+ goto efault;
+ }
+ }
+ }
+ break;
+ case 3:
+ ret = get_errno(syscall(__NR_sysfs, arg1));
+ break;
+ default:
+ ret = -EINVAL;
+ }
+ break;
#endif
case TARGET_NR_personality:
ret = get_errno(personality(arg1));