Commit ebc054881ff60643abe1995b4bcdc558264470f2

Authored by bellard
1 parent a20dd508

added utime syscall - fixed nanosleep exact behaviour


git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@393 c046a42c-6fe2-441c-8c8c-71466251a162
Showing 1 changed file with 66 additions and 2 deletions
linux-user/syscall.c
@@ -41,6 +41,7 @@ @@ -41,6 +41,7 @@
41 #include <sys/uio.h> 41 #include <sys/uio.h>
42 #include <sys/poll.h> 42 #include <sys/poll.h>
43 #include <sys/times.h> 43 #include <sys/times.h>
  44 +#include <utime.h>
44 //#include <sys/user.h> 45 //#include <sys/user.h>
45 #include <netinet/tcp.h> 46 #include <netinet/tcp.h>
46 47
@@ -1262,6 +1263,8 @@ int do_fork(CPUState *env, unsigned int flags, unsigned long newsp) @@ -1262,6 +1263,8 @@ int do_fork(CPUState *env, unsigned int flags, unsigned long newsp)
1262 newsp = env->regs[13]; 1263 newsp = env->regs[13];
1263 new_env->regs[13] = newsp; 1264 new_env->regs[13] = newsp;
1264 new_env->regs[0] = 0; 1265 new_env->regs[0] = 0;
  1266 +#elif defined(TARGET_SPARC)
  1267 + printf ("HELPME: %s:%d\n", __FILE__, __LINE__);
1265 #else 1268 #else
1266 #error unsupported target CPU 1269 #error unsupported target CPU
1267 #endif 1270 #endif
@@ -1472,10 +1475,14 @@ long do_syscall(void *cpu_env, int num, long arg1, long arg2, long arg3, @@ -1472,10 +1475,14 @@ long do_syscall(void *cpu_env, int num, long arg1, long arg2, long arg3,
1472 case TARGET_NR_lchown: 1475 case TARGET_NR_lchown:
1473 ret = get_errno(chown((const char *)arg1, arg2, arg3)); 1476 ret = get_errno(chown((const char *)arg1, arg2, arg3));
1474 break; 1477 break;
  1478 +#ifdef TARGET_NR_break
1475 case TARGET_NR_break: 1479 case TARGET_NR_break:
1476 goto unimplemented; 1480 goto unimplemented;
  1481 +#endif
  1482 +#ifdef TARGET_NR_oldstat
1477 case TARGET_NR_oldstat: 1483 case TARGET_NR_oldstat:
1478 goto unimplemented; 1484 goto unimplemented;
  1485 +#endif
1479 case TARGET_NR_lseek: 1486 case TARGET_NR_lseek:
1480 ret = get_errno(lseek(arg1, arg2, arg3)); 1487 ret = get_errno(lseek(arg1, arg2, arg3));
1481 break; 1488 break;
@@ -1507,25 +1514,40 @@ long do_syscall(void *cpu_env, int num, long arg1, long arg2, long arg3, @@ -1507,25 +1514,40 @@ long do_syscall(void *cpu_env, int num, long arg1, long arg2, long arg3,
1507 case TARGET_NR_alarm: 1514 case TARGET_NR_alarm:
1508 ret = alarm(arg1); 1515 ret = alarm(arg1);
1509 break; 1516 break;
  1517 +#ifdef TARGET_NR_oldfstat
1510 case TARGET_NR_oldfstat: 1518 case TARGET_NR_oldfstat:
1511 goto unimplemented; 1519 goto unimplemented;
  1520 +#endif
1512 case TARGET_NR_pause: 1521 case TARGET_NR_pause:
1513 ret = get_errno(pause()); 1522 ret = get_errno(pause());
1514 break; 1523 break;
1515 case TARGET_NR_utime: 1524 case TARGET_NR_utime:
1516 - goto unimplemented; 1525 + {
  1526 + struct utimbuf tbuf;
  1527 + struct target_utimbuf *target_tbuf = (void *)arg2;
  1528 + tbuf.actime = tswapl(target_tbuf->actime);
  1529 + tbuf.modtime = tswapl(target_tbuf->modtime);
  1530 + ret = get_errno(utime((const char *)arg1, &tbuf));
  1531 + }
  1532 + break;
  1533 +#ifdef TARGET_NR_stty
1517 case TARGET_NR_stty: 1534 case TARGET_NR_stty:
1518 goto unimplemented; 1535 goto unimplemented;
  1536 +#endif
  1537 +#ifdef TARGET_NR_gtty
1519 case TARGET_NR_gtty: 1538 case TARGET_NR_gtty:
1520 goto unimplemented; 1539 goto unimplemented;
  1540 +#endif
1521 case TARGET_NR_access: 1541 case TARGET_NR_access:
1522 ret = get_errno(access((const char *)arg1, arg2)); 1542 ret = get_errno(access((const char *)arg1, arg2));
1523 break; 1543 break;
1524 case TARGET_NR_nice: 1544 case TARGET_NR_nice:
1525 ret = get_errno(nice(arg1)); 1545 ret = get_errno(nice(arg1));
1526 break; 1546 break;
  1547 +#ifdef TARGET_NR_ftime
1527 case TARGET_NR_ftime: 1548 case TARGET_NR_ftime:
1528 goto unimplemented; 1549 goto unimplemented;
  1550 +#endif
1529 case TARGET_NR_sync: 1551 case TARGET_NR_sync:
1530 sync(); 1552 sync();
1531 ret = 0; 1553 ret = 0;
@@ -1570,8 +1592,10 @@ long do_syscall(void *cpu_env, int num, long arg1, long arg2, long arg3, @@ -1570,8 +1592,10 @@ long do_syscall(void *cpu_env, int num, long arg1, long arg2, long arg3,
1570 ret = host_to_target_clock_t(ret); 1592 ret = host_to_target_clock_t(ret);
1571 } 1593 }
1572 break; 1594 break;
  1595 +#ifdef TARGET_NR_prof
1573 case TARGET_NR_prof: 1596 case TARGET_NR_prof:
1574 goto unimplemented; 1597 goto unimplemented;
  1598 +#endif
1575 case TARGET_NR_setgid: 1599 case TARGET_NR_setgid:
1576 ret = get_errno(setgid(low2highgid(arg1))); 1600 ret = get_errno(setgid(low2highgid(arg1)));
1577 break; 1601 break;
@@ -1591,23 +1615,31 @@ long do_syscall(void *cpu_env, int num, long arg1, long arg2, long arg3, @@ -1591,23 +1615,31 @@ long do_syscall(void *cpu_env, int num, long arg1, long arg2, long arg3,
1591 case TARGET_NR_umount2: 1615 case TARGET_NR_umount2:
1592 ret = get_errno(umount2((const char *)arg1, arg2)); 1616 ret = get_errno(umount2((const char *)arg1, arg2));
1593 break; 1617 break;
  1618 +#ifdef TARGET_NR_lock
1594 case TARGET_NR_lock: 1619 case TARGET_NR_lock:
1595 goto unimplemented; 1620 goto unimplemented;
  1621 +#endif
1596 case TARGET_NR_ioctl: 1622 case TARGET_NR_ioctl:
1597 ret = do_ioctl(arg1, arg2, arg3); 1623 ret = do_ioctl(arg1, arg2, arg3);
1598 break; 1624 break;
1599 case TARGET_NR_fcntl: 1625 case TARGET_NR_fcntl:
1600 ret = get_errno(do_fcntl(arg1, arg2, arg3)); 1626 ret = get_errno(do_fcntl(arg1, arg2, arg3));
1601 break; 1627 break;
  1628 +#ifdef TARGET_NR_mpx
1602 case TARGET_NR_mpx: 1629 case TARGET_NR_mpx:
1603 goto unimplemented; 1630 goto unimplemented;
  1631 +#endif
1604 case TARGET_NR_setpgid: 1632 case TARGET_NR_setpgid:
1605 ret = get_errno(setpgid(arg1, arg2)); 1633 ret = get_errno(setpgid(arg1, arg2));
1606 break; 1634 break;
  1635 +#ifdef TARGET_NR_ulimit
1607 case TARGET_NR_ulimit: 1636 case TARGET_NR_ulimit:
1608 goto unimplemented; 1637 goto unimplemented;
  1638 +#endif
  1639 +#ifdef TARGET_NR_oldolduname
1609 case TARGET_NR_oldolduname: 1640 case TARGET_NR_oldolduname:
1610 goto unimplemented; 1641 goto unimplemented;
  1642 +#endif
1611 case TARGET_NR_umask: 1643 case TARGET_NR_umask:
1612 ret = get_errno(umask(arg1)); 1644 ret = get_errno(umask(arg1));
1613 break; 1645 break;
@@ -1917,8 +1949,10 @@ long do_syscall(void *cpu_env, int num, long arg1, long arg2, long arg3, @@ -1917,8 +1949,10 @@ long do_syscall(void *cpu_env, int num, long arg1, long arg2, long arg3,
1917 case TARGET_NR_symlink: 1949 case TARGET_NR_symlink:
1918 ret = get_errno(symlink((const char *)arg1, (const char *)arg2)); 1950 ret = get_errno(symlink((const char *)arg1, (const char *)arg2));
1919 break; 1951 break;
  1952 +#ifdef TARGET_NR_oldlstat
1920 case TARGET_NR_oldlstat: 1953 case TARGET_NR_oldlstat:
1921 goto unimplemented; 1954 goto unimplemented;
  1955 +#endif
1922 case TARGET_NR_readlink: 1956 case TARGET_NR_readlink:
1923 ret = get_errno(readlink(path((const char *)arg1), (char *)arg2, arg3)); 1957 ret = get_errno(readlink(path((const char *)arg1), (char *)arg2, arg3));
1924 break; 1958 break;
@@ -2001,8 +2035,10 @@ long do_syscall(void *cpu_env, int num, long arg1, long arg2, long arg3, @@ -2001,8 +2035,10 @@ long do_syscall(void *cpu_env, int num, long arg1, long arg2, long arg3,
2001 case TARGET_NR_setpriority: 2035 case TARGET_NR_setpriority:
2002 ret = get_errno(setpriority(arg1, arg2, arg3)); 2036 ret = get_errno(setpriority(arg1, arg2, arg3));
2003 break; 2037 break;
  2038 +#ifdef TARGET_NR_profil
2004 case TARGET_NR_profil: 2039 case TARGET_NR_profil:
2005 goto unimplemented; 2040 goto unimplemented;
  2041 +#endif
2006 case TARGET_NR_statfs: 2042 case TARGET_NR_statfs:
2007 stfs = (void *)arg2; 2043 stfs = (void *)arg2;
2008 ret = get_errno(sys_statfs(path((const char *)arg1), stfs)); 2044 ret = get_errno(sys_statfs(path((const char *)arg1), stfs));
@@ -2024,8 +2060,10 @@ long do_syscall(void *cpu_env, int num, long arg1, long arg2, long arg3, @@ -2024,8 +2060,10 @@ long do_syscall(void *cpu_env, int num, long arg1, long arg2, long arg3,
2024 stfs = (void *)arg2; 2060 stfs = (void *)arg2;
2025 ret = get_errno(sys_fstatfs(arg1, stfs)); 2061 ret = get_errno(sys_fstatfs(arg1, stfs));
2026 goto convert_statfs; 2062 goto convert_statfs;
  2063 +#ifdef TARGET_NR_ioperm
2027 case TARGET_NR_ioperm: 2064 case TARGET_NR_ioperm:
2028 goto unimplemented; 2065 goto unimplemented;
  2066 +#endif
2029 case TARGET_NR_socketcall: 2067 case TARGET_NR_socketcall:
2030 ret = do_socketcall(arg1, (int32_t *)arg2); 2068 ret = do_socketcall(arg1, (int32_t *)arg2);
2031 break; 2069 break;
@@ -2097,15 +2135,21 @@ long do_syscall(void *cpu_env, int num, long arg1, long arg2, long arg3, @@ -2097,15 +2135,21 @@ long do_syscall(void *cpu_env, int num, long arg1, long arg2, long arg3,
2097 } 2135 }
2098 } 2136 }
2099 break; 2137 break;
  2138 +#ifdef TARGET_NR_olduname
2100 case TARGET_NR_olduname: 2139 case TARGET_NR_olduname:
2101 goto unimplemented; 2140 goto unimplemented;
  2141 +#endif
  2142 +#ifdef TARGET_NR_iopl
2102 case TARGET_NR_iopl: 2143 case TARGET_NR_iopl:
2103 goto unimplemented; 2144 goto unimplemented;
  2145 +#endif
2104 case TARGET_NR_vhangup: 2146 case TARGET_NR_vhangup:
2105 ret = get_errno(vhangup()); 2147 ret = get_errno(vhangup());
2106 break; 2148 break;
  2149 +#ifdef TARGET_NR_idle
2107 case TARGET_NR_idle: 2150 case TARGET_NR_idle:
2108 goto unimplemented; 2151 goto unimplemented;
  2152 +#endif
2109 case TARGET_NR_wait4: 2153 case TARGET_NR_wait4:
2110 { 2154 {
2111 int status; 2155 int status;
@@ -2415,17 +2459,20 @@ long do_syscall(void *cpu_env, int num, long arg1, long arg2, long arg3, @@ -2415,17 +2459,20 @@ long do_syscall(void *cpu_env, int num, long arg1, long arg2, long arg3,
2415 req.tv_sec = tswapl(target_req->tv_sec); 2459 req.tv_sec = tswapl(target_req->tv_sec);
2416 req.tv_nsec = tswapl(target_req->tv_nsec); 2460 req.tv_nsec = tswapl(target_req->tv_nsec);
2417 ret = get_errno(nanosleep(&req, &rem)); 2461 ret = get_errno(nanosleep(&req, &rem));
2418 - if (target_rem) { 2462 + if (is_error(ret) && target_rem) {
2419 target_rem->tv_sec = tswapl(rem.tv_sec); 2463 target_rem->tv_sec = tswapl(rem.tv_sec);
2420 target_rem->tv_nsec = tswapl(rem.tv_nsec); 2464 target_rem->tv_nsec = tswapl(rem.tv_nsec);
2421 } 2465 }
2422 } 2466 }
2423 break; 2467 break;
  2468 +#ifdef TARGET_NR_setresuid
2424 case TARGET_NR_setresuid: 2469 case TARGET_NR_setresuid:
2425 ret = get_errno(setresuid(low2highuid(arg1), 2470 ret = get_errno(setresuid(low2highuid(arg1),
2426 low2highuid(arg2), 2471 low2highuid(arg2),
2427 low2highuid(arg3))); 2472 low2highuid(arg3)));
2428 break; 2473 break;
  2474 +#endif
  2475 +#ifdef TARGET_NR_getresuid
2429 case TARGET_NR_getresuid: 2476 case TARGET_NR_getresuid:
2430 { 2477 {
2431 int ruid, euid, suid; 2478 int ruid, euid, suid;
@@ -2437,11 +2484,15 @@ long do_syscall(void *cpu_env, int num, long arg1, long arg2, long arg3, @@ -2437,11 +2484,15 @@ long do_syscall(void *cpu_env, int num, long arg1, long arg2, long arg3,
2437 } 2484 }
2438 } 2485 }
2439 break; 2486 break;
  2487 +#endif
  2488 +#ifdef TARGET_NR_getresgid
2440 case TARGET_NR_setresgid: 2489 case TARGET_NR_setresgid:
2441 ret = get_errno(setresgid(low2highgid(arg1), 2490 ret = get_errno(setresgid(low2highgid(arg1),
2442 low2highgid(arg2), 2491 low2highgid(arg2),
2443 low2highgid(arg3))); 2492 low2highgid(arg3)));
2444 break; 2493 break;
  2494 +#endif
  2495 +#ifdef TARGET_NR_getresgid
2445 case TARGET_NR_getresgid: 2496 case TARGET_NR_getresgid:
2446 { 2497 {
2447 int rgid, egid, sgid; 2498 int rgid, egid, sgid;
@@ -2453,6 +2504,7 @@ long do_syscall(void *cpu_env, int num, long arg1, long arg2, long arg3, @@ -2453,6 +2504,7 @@ long do_syscall(void *cpu_env, int num, long arg1, long arg2, long arg3,
2453 } 2504 }
2454 } 2505 }
2455 break; 2506 break;
  2507 +#endif
2456 case TARGET_NR_query_module: 2508 case TARGET_NR_query_module:
2457 goto unimplemented; 2509 goto unimplemented;
2458 case TARGET_NR_nfsservctl: 2510 case TARGET_NR_nfsservctl:
@@ -2480,13 +2532,18 @@ long do_syscall(void *cpu_env, int num, long arg1, long arg2, long arg3, @@ -2480,13 +2532,18 @@ long do_syscall(void *cpu_env, int num, long arg1, long arg2, long arg3,
2480 goto unimplemented; 2532 goto unimplemented;
2481 case TARGET_NR_sendfile: 2533 case TARGET_NR_sendfile:
2482 goto unimplemented; 2534 goto unimplemented;
  2535 +#ifdef TARGET_NR_getpmsg
2483 case TARGET_NR_getpmsg: 2536 case TARGET_NR_getpmsg:
2484 goto unimplemented; 2537 goto unimplemented;
  2538 +#endif
  2539 +#ifdef TARGET_NR_putpmsg
2485 case TARGET_NR_putpmsg: 2540 case TARGET_NR_putpmsg:
2486 goto unimplemented; 2541 goto unimplemented;
  2542 +#endif
2487 case TARGET_NR_vfork: 2543 case TARGET_NR_vfork:
2488 ret = get_errno(do_fork(cpu_env, CLONE_VFORK | CLONE_VM | SIGCHLD, 0)); 2544 ret = get_errno(do_fork(cpu_env, CLONE_VFORK | CLONE_VM | SIGCHLD, 0));
2489 break; 2545 break;
  2546 +#ifdef TARGET_NR_ugetrlimit
2490 case TARGET_NR_ugetrlimit: 2547 case TARGET_NR_ugetrlimit:
2491 { 2548 {
2492 struct rlimit rlim; 2549 struct rlimit rlim;
@@ -2498,6 +2555,7 @@ long do_syscall(void *cpu_env, int num, long arg1, long arg2, long arg3, @@ -2498,6 +2555,7 @@ long do_syscall(void *cpu_env, int num, long arg1, long arg2, long arg3,
2498 } 2555 }
2499 break; 2556 break;
2500 } 2557 }
  2558 +#endif
2501 case TARGET_NR_truncate64: 2559 case TARGET_NR_truncate64:
2502 goto unimplemented; 2560 goto unimplemented;
2503 case TARGET_NR_ftruncate64: 2561 case TARGET_NR_ftruncate64:
@@ -2647,13 +2705,16 @@ long do_syscall(void *cpu_env, int num, long arg1, long arg2, long arg3, @@ -2647,13 +2705,16 @@ long do_syscall(void *cpu_env, int num, long arg1, long arg2, long arg3,
2647 break; 2705 break;
2648 } 2706 }
2649 #endif 2707 #endif
  2708 +#ifdef TARGET_NR_security
2650 case TARGET_NR_security: 2709 case TARGET_NR_security:
2651 goto unimplemented; 2710 goto unimplemented;
  2711 +#endif
2652 case TARGET_NR_gettid: 2712 case TARGET_NR_gettid:
2653 ret = get_errno(gettid()); 2713 ret = get_errno(gettid());
2654 break; 2714 break;
2655 case TARGET_NR_readahead: 2715 case TARGET_NR_readahead:
2656 goto unimplemented; 2716 goto unimplemented;
  2717 +#ifdef TARGET_NR_setxattr
2657 case TARGET_NR_setxattr: 2718 case TARGET_NR_setxattr:
2658 case TARGET_NR_lsetxattr: 2719 case TARGET_NR_lsetxattr:
2659 case TARGET_NR_fsetxattr: 2720 case TARGET_NR_fsetxattr:
@@ -2667,9 +2728,12 @@ long do_syscall(void *cpu_env, int num, long arg1, long arg2, long arg3, @@ -2667,9 +2728,12 @@ long do_syscall(void *cpu_env, int num, long arg1, long arg2, long arg3,
2667 case TARGET_NR_lremovexattr: 2728 case TARGET_NR_lremovexattr:
2668 case TARGET_NR_fremovexattr: 2729 case TARGET_NR_fremovexattr:
2669 goto unimplemented_nowarn; 2730 goto unimplemented_nowarn;
  2731 +#endif
  2732 +#ifdef TARGET_NR_set_thread_area
2670 case TARGET_NR_set_thread_area: 2733 case TARGET_NR_set_thread_area:
2671 case TARGET_NR_get_thread_area: 2734 case TARGET_NR_get_thread_area:
2672 goto unimplemented_nowarn; 2735 goto unimplemented_nowarn;
  2736 +#endif
2673 default: 2737 default:
2674 unimplemented: 2738 unimplemented:
2675 gemu_log("qemu: Unsupported syscall: %d\n", num); 2739 gemu_log("qemu: Unsupported syscall: %d\n", num);