It breaks compilation on musl 1.2.0 as the syscall name changed. According to one of the kernel developers working on removing the settimeofday syscall, setting the kernel timezone is rather pointless: https://github.com/systemd/systemd/issues/13305#issuecomment-520463236
The kernel generally only cares about the timezone in a few places: the rtc time warp for windows compatibility on x86 machines the timezone offset for file systems that require storing timestamps in local time (fat, udf, hpfs, hfs). These typically allow a 'time_offset' and/or 'timezone' mount option as an alternative. some drivers that save timestamps as local time in hardware buffers, typically scsi adapters. One can argue that these are just wrong, and we should not be doing it that way, as other drivers do the same thing using UTC. Also changed base-files which is the only user of this functionality. Signed-off-by: Rosen Penev <[email protected]> --- package/base-files/Makefile | 2 +- package/base-files/files/etc/init.d/system | 3 - package/utils/busybox/Makefile | 2 +- .../busybox/patches/250-date-k-flag.patch | 92 ------------------- 4 files changed, 2 insertions(+), 97 deletions(-) delete mode 100644 package/utils/busybox/patches/250-date-k-flag.patch diff --git a/package/base-files/Makefile b/package/base-files/Makefile index 107d53e74f..8e252153fe 100644 --- a/package/base-files/Makefile +++ b/package/base-files/Makefile @@ -12,7 +12,7 @@ include $(INCLUDE_DIR)/version.mk include $(INCLUDE_DIR)/feeds.mk PKG_NAME:=base-files -PKG_RELEASE:=214 +PKG_RELEASE:=215 PKG_FLAGS:=nonshared PKG_FILE_DEPENDS:=$(PLATFORM_DIR)/ $(GENERIC_PLATFORM_DIR)/base-files/ diff --git a/package/base-files/files/etc/init.d/system b/package/base-files/files/etc/init.d/system index 0e33c522b4..4c3a7b0f83 100755 --- a/package/base-files/files/etc/init.d/system +++ b/package/base-files/files/etc/init.d/system @@ -25,9 +25,6 @@ system_config() { echo "$timezone" > /tmp/TZ [ -n "$zonename" ] && [ -f "/usr/share/zoneinfo/$zonename" ] && \ ln -sf "/usr/share/zoneinfo/$zonename" /tmp/localtime && rm -f /tmp/TZ - - # apply timezone to kernel - busybox date -k } reload_service() { diff --git a/package/utils/busybox/Makefile b/package/utils/busybox/Makefile index 01441d1e87..baf375eb13 100644 --- a/package/utils/busybox/Makefile +++ b/package/utils/busybox/Makefile @@ -9,7 +9,7 @@ include $(TOPDIR)/rules.mk PKG_NAME:=busybox PKG_VERSION:=1.31.1 -PKG_RELEASE:=1 +PKG_RELEASE:=2 PKG_FLAGS:=essential PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2 diff --git a/package/utils/busybox/patches/250-date-k-flag.patch b/package/utils/busybox/patches/250-date-k-flag.patch deleted file mode 100644 index 5aadbb233c..0000000000 --- a/package/utils/busybox/patches/250-date-k-flag.patch +++ /dev/null @@ -1,92 +0,0 @@ ---- a/coreutils/date.c -+++ b/coreutils/date.c -@@ -123,6 +123,7 @@ - //usage: IF_FEATURE_DATE_ISOFMT( - //usage: "\n -D FMT Use FMT (strptime format) for -d TIME conversion" - //usage: ) -+//usage: "\n -k Set Kernel timezone from localtime and exit" - //usage: "\n" - //usage: "\nRecognized TIME formats:" - //usage: "\n hh:mm[:ss]" -@@ -139,9 +140,8 @@ - - #include "libbb.h" - #include "common_bufsiz.h" --#if ENABLE_FEATURE_DATE_NANO --# include <sys/syscall.h> --#endif -+#include <sys/time.h> -+#include <sys/syscall.h> - - enum { - OPT_RFC2822 = (1 << 0), /* R */ -@@ -149,8 +149,9 @@ enum { - OPT_UTC = (1 << 2), /* u */ - OPT_DATE = (1 << 3), /* d */ - OPT_REFERENCE = (1 << 4), /* r */ -- OPT_TIMESPEC = (1 << 5) * ENABLE_FEATURE_DATE_ISOFMT, /* I */ -- OPT_HINT = (1 << 6) * ENABLE_FEATURE_DATE_ISOFMT, /* D */ -+ OPT_KERNELTZ = (1 << 5), /* k */ -+ OPT_TIMESPEC = (1 << 6) * ENABLE_FEATURE_DATE_ISOFMT, /* I */ -+ OPT_HINT = (1 << 7) * ENABLE_FEATURE_DATE_ISOFMT, /* D */ - }; - - #if ENABLE_LONG_OPTS -@@ -162,6 +163,7 @@ static const char date_longopts[] ALIGN1 - /* "universal\0" No_argument "u" */ - "date\0" Required_argument "d" - "reference\0" Required_argument "r" -+ "set-kernel-tz\0" No_argument "k" - ; - #endif - -@@ -181,6 +183,8 @@ static void maybe_set_utc(int opt) - int date_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; - int date_main(int argc UNUSED_PARAM, char **argv) - { -+ time_t tt; -+ struct timezone tz; - struct timespec ts; - struct tm tm_time; - char buf_fmt_dt2str[64]; -@@ -193,7 +197,7 @@ int date_main(int argc UNUSED_PARAM, cha - char *isofmt_arg = NULL; - - opt = getopt32long(argv, "^" -- "Rs:ud:r:" -+ "Rs:ud:r:k" - IF_FEATURE_DATE_ISOFMT("I::D:") - "\0" - "d--s:s--d" -@@ -256,6 +260,31 @@ int date_main(int argc UNUSED_PARAM, cha - if (*argv) - bb_show_usage(); - -+ /* Setting of kernel timezone was requested */ -+ if (opt & OPT_KERNELTZ) { -+ tt = time(NULL); -+ localtime_r(&tt, &tm_time); -+ -+ /* workaround warp_clock() on first invocation */ -+ memset(&tz, 0, sizeof(tz)); -+ syscall(SYS_settimeofday, NULL, &tz); -+ -+ memset(&tz, 0, sizeof(tz)); -+#ifdef __USE_MISC -+ tz.tz_minuteswest = -(tm_time.tm_gmtoff / 60); -+#else -+ tz.tz_minuteswest = -(tm_time.__tm_gmtoff / 60); -+#endif -+ -+ if (syscall(SYS_settimeofday, NULL, &tz)) -+ { -+ bb_perror_msg("can't set kernel time zone"); -+ return EXIT_FAILURE; -+ } -+ -+ return EXIT_SUCCESS; -+ } -+ - /* Now we have parsed all the information except the date format - * which depends on whether the clock is being set or read */ - -- 2.25.1 _______________________________________________ openwrt-devel mailing list [email protected] https://lists.openwrt.org/mailman/listinfo/openwrt-devel
