009-Replace-obsolete-stime-API-with-clock_settime.patch 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. diff -Nur busybox-1.26.2.orig/coreutils/date.c busybox-1.26.2/coreutils/date.c
  2. --- busybox-1.26.2.orig/coreutils/date.c 2016-12-10 18:46:36.000000000 +0100
  3. +++ busybox-1.26.2/coreutils/date.c 2020-02-04 09:55:25.126083910 +0100
  4. @@ -267,6 +267,9 @@
  5. time(&ts.tv_sec);
  6. #endif
  7. }
  8. +#if !ENABLE_FEATURE_DATE_NANO
  9. + ts.tv_nsec = 0;
  10. +#endif
  11. localtime_r(&ts.tv_sec, &tm_time);
  12. /* If date string is given, update tm_time, and maybe set date */
  13. @@ -289,11 +292,12 @@
  14. if (date_str[0] != '@')
  15. tm_time.tm_isdst = -1;
  16. ts.tv_sec = validate_tm_time(date_str, &tm_time);
  17. + ts.tv_nsec = 0;
  18. maybe_set_utc(opt);
  19. /* if setting time, set it */
  20. - if ((opt & OPT_SET) && stime(&ts.tv_sec) < 0) {
  21. + if ((opt & OPT_SET) && clock_settime(CLOCK_REALTIME, &ts) < 0) {
  22. bb_perror_msg("can't set date");
  23. }
  24. }
  25. diff -Nur busybox-1.26.2.orig/libbb/missing_syscalls.c busybox-1.26.2/libbb/missing_syscalls.c
  26. --- busybox-1.26.2.orig/libbb/missing_syscalls.c 2016-09-27 18:53:50.000000000 +0200
  27. +++ busybox-1.26.2/libbb/missing_syscalls.c 2020-02-04 09:55:58.848244715 +0100
  28. @@ -16,14 +16,6 @@
  29. return syscall(__NR_getsid, pid);
  30. }
  31. -int stime(const time_t *t)
  32. -{
  33. - struct timeval tv;
  34. - tv.tv_sec = *t;
  35. - tv.tv_usec = 0;
  36. - return settimeofday(&tv, NULL);
  37. -}
  38. -
  39. int sethostname(const char *name, size_t len)
  40. {
  41. return syscall(__NR_sethostname, name, len);
  42. diff -Nur busybox-1.26.2.orig/util-linux/rdate.c busybox-1.26.2/util-linux/rdate.c
  43. --- busybox-1.26.2.orig/util-linux/rdate.c 2016-12-10 18:46:36.000000000 +0100
  44. +++ busybox-1.26.2/util-linux/rdate.c 2020-02-04 09:56:53.927774023 +0100
  45. @@ -79,9 +79,13 @@
  46. time(&current_time);
  47. if (current_time == remote_time)
  48. bb_error_msg("current time matches remote time");
  49. - else
  50. - if (stime(&remote_time) < 0)
  51. - bb_perror_msg_and_die("can't set time of day");
  52. + else {
  53. + struct timespec ts;
  54. + ts.tv_sec = remote_time;
  55. + ts.tv_nsec = 0;
  56. + if (clock_settime(CLOCK_REALTIME, &ts) < 0)
  57. + bb_perror_msg_and_die("can't set time of day");
  58. + }
  59. }
  60. if (flags != 1) /* not lone -s */