0011-linux-user-remove-host-stime-syscall.patch 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. From 0f1f2d4596aee037d3ccbcf10592466daa54107f Mon Sep 17 00:00:00 2001
  2. From: Laurent Vivier <laurent@vivier.eu>
  3. Date: Tue, 12 Nov 2019 15:25:56 +0100
  4. Subject: [PATCH] linux-user: remove host stime() syscall
  5. stime() has been withdrawn from glibc
  6. (12cbde1dae6f "Use clock_settime to implement stime; withdraw stime.")
  7. Implement the target stime() syscall using host
  8. clock_settime(CLOCK_REALTIME, ...) as it is done internally in glibc.
  9. Tested qemu-ppc/x86_64 with:
  10. #include <time.h>
  11. #include <stdio.h>
  12. int main(void)
  13. {
  14. time_t t;
  15. int ret;
  16. /* date -u -d"2019-11-12T15:11:00" "+%s" */
  17. t = 1573571460;
  18. ret = stime(&t);
  19. printf("ret %d\n", ret);
  20. return 0;
  21. }
  22. # date; ./stime; date
  23. Tue Nov 12 14:18:32 UTC 2019
  24. ret 0
  25. Tue Nov 12 15:11:00 UTC 2019
  26. Upstream-Status: Backport [https://git.qemu.org/?p=qemu.git;a=commit;h=0f1f2d4596aee037d3ccbcf10592466daa54107f]
  27. Buglink: https://bugs.launchpad.net/qemu/+bug/1852115
  28. Reported-by: Cole Robinson <crobinso@redhat.com>
  29. Signed-off-by: Laurent Vivier <laurent@vivier.eu>
  30. Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
  31. Message-Id: <20191112142556.6335-1-laurent@vivier.eu>
  32. ---
  33. linux-user/syscall.c | 8 +++++---
  34. 1 file changed, 5 insertions(+), 3 deletions(-)
  35. Index: qemu-3.0.0/linux-user/syscall.c
  36. ===================================================================
  37. --- qemu-3.0.0.orig/linux-user/syscall.c
  38. +++ qemu-3.0.0/linux-user/syscall.c
  39. @@ -8520,10 +8520,11 @@ abi_long do_syscall(void *cpu_env, int n
  40. #ifdef TARGET_NR_stime /* not on alpha */
  41. case TARGET_NR_stime:
  42. {
  43. - time_t host_time;
  44. - if (get_user_sal(host_time, arg1))
  45. + struct timespec ts;
  46. + ts.tv_nsec = 0;
  47. + if (get_user_sal(ts.tv_sec, arg1))
  48. goto efault;
  49. - ret = get_errno(stime(&host_time));
  50. + ret = get_errno(clock_settime(CLOCK_REALTIME, &ts));
  51. }
  52. break;
  53. #endif