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