Commit a5448a7de5bb35553a97c4e337ef2ef6fe8d3ccc
1 parent
9231944d
sysinfo syscall (Francois Guimond)
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@930 c046a42c-6fe2-441c-8c8c-71466251a162
Showing
2 changed files
with
41 additions
and
1 deletions
linux-user/syscall.c
@@ -43,6 +43,7 @@ | @@ -43,6 +43,7 @@ | ||
43 | #include <sys/times.h> | 43 | #include <sys/times.h> |
44 | #include <sys/shm.h> | 44 | #include <sys/shm.h> |
45 | #include <utime.h> | 45 | #include <utime.h> |
46 | +#include <sys/sysinfo.h> | ||
46 | //#include <sys/user.h> | 47 | //#include <sys/user.h> |
47 | #include <netinet/ip.h> | 48 | #include <netinet/ip.h> |
48 | #include <netinet/tcp.h> | 49 | #include <netinet/tcp.h> |
@@ -2348,7 +2349,29 @@ long do_syscall(void *cpu_env, int num, long arg1, long arg2, long arg3, | @@ -2348,7 +2349,29 @@ long do_syscall(void *cpu_env, int num, long arg1, long arg2, long arg3, | ||
2348 | ret = get_errno(swapoff((const char *)arg1)); | 2349 | ret = get_errno(swapoff((const char *)arg1)); |
2349 | break; | 2350 | break; |
2350 | case TARGET_NR_sysinfo: | 2351 | case TARGET_NR_sysinfo: |
2351 | - goto unimplemented; | 2352 | + { |
2353 | + struct target_sysinfo *target_value = (void *)arg1; | ||
2354 | + struct sysinfo value; | ||
2355 | + ret = get_errno(sysinfo(&value)); | ||
2356 | + if (!is_error(ret) && target_value) | ||
2357 | + { | ||
2358 | + __put_user(value.uptime, &target_value->uptime); | ||
2359 | + __put_user(value.loads[0], &target_value->loads[0]); | ||
2360 | + __put_user(value.loads[1], &target_value->loads[1]); | ||
2361 | + __put_user(value.loads[2], &target_value->loads[2]); | ||
2362 | + __put_user(value.totalram, &target_value->totalram); | ||
2363 | + __put_user(value.freeram, &target_value->freeram); | ||
2364 | + __put_user(value.sharedram, &target_value->sharedram); | ||
2365 | + __put_user(value.bufferram, &target_value->bufferram); | ||
2366 | + __put_user(value.totalswap, &target_value->totalswap); | ||
2367 | + __put_user(value.freeswap, &target_value->freeswap); | ||
2368 | + __put_user(value.procs, &target_value->procs); | ||
2369 | + __put_user(value.totalhigh, &target_value->totalhigh); | ||
2370 | + __put_user(value.freehigh, &target_value->freehigh); | ||
2371 | + __put_user(value.mem_unit, &target_value->mem_unit); | ||
2372 | + } | ||
2373 | + } | ||
2374 | + break; | ||
2352 | case TARGET_NR_ipc: | 2375 | case TARGET_NR_ipc: |
2353 | ret = do_ipc(arg1, arg2, arg3, arg4, arg5, arg6); | 2376 | ret = do_ipc(arg1, arg2, arg3, arg4, arg5, arg6); |
2354 | break; | 2377 | break; |
linux-user/syscall_defs.h
@@ -1133,3 +1133,20 @@ struct target_flock64 { | @@ -1133,3 +1133,20 @@ struct target_flock64 { | ||
1133 | /* vfat ioctls */ | 1133 | /* vfat ioctls */ |
1134 | #define TARGET_VFAT_IOCTL_READDIR_BOTH TARGET_IORU('r', 1) | 1134 | #define TARGET_VFAT_IOCTL_READDIR_BOTH TARGET_IORU('r', 1) |
1135 | #define TARGET_VFAT_IOCTL_READDIR_SHORT TARGET_IORU('r', 2) | 1135 | #define TARGET_VFAT_IOCTL_READDIR_SHORT TARGET_IORU('r', 2) |
1136 | + | ||
1137 | +struct target_sysinfo { | ||
1138 | + target_long uptime; /* Seconds since boot */ | ||
1139 | + target_ulong loads[3]; /* 1, 5, and 15 minute load averages */ | ||
1140 | + target_ulong totalram; /* Total usable main memory size */ | ||
1141 | + target_ulong freeram; /* Available memory size */ | ||
1142 | + target_ulong sharedram; /* Amount of shared memory */ | ||
1143 | + target_ulong bufferram; /* Memory used by buffers */ | ||
1144 | + target_ulong totalswap; /* Total swap space size */ | ||
1145 | + target_ulong freeswap; /* swap space still available */ | ||
1146 | + unsigned short procs; /* Number of current processes */ | ||
1147 | + unsigned short pad; /* explicit padding for m68k */ | ||
1148 | + target_ulong totalhigh; /* Total high memory size */ | ||
1149 | + target_ulong freehigh; /* Available high memory size */ | ||
1150 | + unsigned int mem_unit; /* Memory unit size in bytes */ | ||
1151 | + char _f[20-2*sizeof(target_long)-sizeof(int)]; /* Padding: libc5 uses this.. */ | ||
1152 | +}; |