diff mbox series

[PATCHv3,1/3] base-files: use hwclock --systz

Message ID 20210201001554.45919-1-rosenp@gmail.com
State Accepted
Delegated to: Hauke Mehrtens
Headers show
Series [PATCHv3,1/3] base-files: use hwclock --systz | expand

Commit Message

Rosen Penev Feb. 1, 2021, 12:15 a.m. UTC
The date -k patch is non standard and will be removed in the next
commit.

Tested behavior to be identical with a simple C program:

 #define _GNU_SOURCE
 #include <unistd.h>
 #include <stdio.h>
 #include <sys/time.h>
 #include <sys/syscall.h>

int main()
{
        struct timezone tt;
	struct timezone tz;

        int a = syscall(SYS_gettimeofday, NULL, &tt);
        int b = gettimeofday(NULL, &tz);
        printf("%d - %d, %d\n", a, tt.tz_minuteswest, tt.tz_dsttime);
        printf("%d - %d, %d\n", b, tz.tz_minuteswest, tz.tz_dsttime);
}

Signed-off-by: Rosen Penev <rosenp@gmail.com>
---
 v3: add -u to fix early log time
 v2: moved patch to the front for easier git bisect
 package/base-files/files/etc/init.d/system | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Hannu Nyman Feb. 1, 2021, 4:17 p.m. UTC | #1
Rosen Penev kirjoitti 1.2.2021 klo 2.15:
> The date -k patch is non standard and will be removed in the next
> commit.
>
> ...
> --- a/package/base-files/files/etc/init.d/system
> +++ b/package/base-files/files/etc/init.d/system
> @@ -27,7 +27,7 @@ system_config() {
>   		ln -sf "/usr/share/zoneinfo/$zonename" /tmp/localtime && rm -f /tmp/TZ
>   
>   	# apply timezone to kernel
> -	busybox date -k
> +	hwclock -u --systz


As discussed in connection of the musl update PR ( starting from 
https://github.com/openwrt/openwrt/pull/3004#issuecomment-764479005 ), the 
addition of "-u" to the hwclock options seems to fix the strange timestamps 
in early boot system logs that I noticed earlier.

I think that in the current form the busybox update to 1.33.0 works ok. I 
have been using it in my own builds since early January for ath79/WNDR3700, 
ipq806x/R7800 and mvebu/WRT3200ACM.

Would be great to have it in the tree before the 21.0x branching.


PS. this patch series is already actually v4, as patch v3 was sent on 7 Jan 2021.
diff mbox series

Patch

diff --git a/package/base-files/files/etc/init.d/system b/package/base-files/files/etc/init.d/system
index 0e33c522b4..585eeeef7e 100755
--- a/package/base-files/files/etc/init.d/system
+++ b/package/base-files/files/etc/init.d/system
@@ -27,7 +27,7 @@  system_config() {
 		ln -sf "/usr/share/zoneinfo/$zonename" /tmp/localtime && rm -f /tmp/TZ
 
 	# apply timezone to kernel
-	busybox date -k
+	hwclock -u --systz
 }
 
 reload_service() {