diff options
author | Liwei Song <liwei.song@windriver.com> | 2020-02-20 11:50:45 +0800 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2020-02-21 09:39:00 +0000 |
commit | 791e0f5d1c645909793db608c76bb730af1fcf78 (patch) | |
tree | 410c1822b46fb44b686481f5f229120cdf758a11 | |
parent | 028d5c616dce1bd2839a9d9a7eab9434b487ec2b (diff) | |
download | poky-791e0f5d1c645909793db608c76bb730af1fcf78.tar.gz |
util-linux: fix hwclock settimeofday error
The change of settimeofday() systemcall since Glibc 2.31
will cause "hwclock -s" doesn't work with error:
"hwclock: settimeofday() failed: Invalid argument"
Backport a upstream patch to fix this issue.
(From OE-Core rev: b80bf70748609b92ce766d11380353fdfbb1d916)
Signed-off-by: Liwei Song <liwei.song@windriver.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r-- | meta/recipes-core/util-linux/util-linux/0001-hwclock-fix-for-glibc-2.31-settimeofday.patch | 112 | ||||
-rw-r--r-- | meta/recipes-core/util-linux/util-linux_2.34.bb | 1 |
2 files changed, 113 insertions, 0 deletions
diff --git a/meta/recipes-core/util-linux/util-linux/0001-hwclock-fix-for-glibc-2.31-settimeofday.patch b/meta/recipes-core/util-linux/util-linux/0001-hwclock-fix-for-glibc-2.31-settimeofday.patch new file mode 100644 index 0000000000..0672c3546a --- /dev/null +++ b/meta/recipes-core/util-linux/util-linux/0001-hwclock-fix-for-glibc-2.31-settimeofday.patch | |||
@@ -0,0 +1,112 @@ | |||
1 | From ee85d3967ea09b215fcea5efdd90bbbf5e74a681 Mon Sep 17 00:00:00 2001 | ||
2 | From: Karel Zak <kzak@redhat.com> | ||
3 | Date: Wed, 19 Feb 2020 15:50:47 +0100 | ||
4 | Subject: [PATCH] hwclock: fix for glibc 2.31 settimeofday() | ||
5 | |||
6 | glibc announce: | ||
7 | ... settimeofday can no longer be used to set the time and the offset | ||
8 | simultaneously. If both of its two arguments are non-null, the call | ||
9 | will fail (setting errno to EINVAL). | ||
10 | |||
11 | It means we need to call settimeofday(NULL, tz) and settimeofday(tv, NULL). | ||
12 | |||
13 | Unfortunately, settimeofday(NULL, tz) has very special warp-clock | ||
14 | semantic if used as the very first settimeofday() call. It means we | ||
15 | have to be sure that we do not touch warp-clock if we need only need | ||
16 | to modify system TZ. So, let's always call settimeofday(NULL, 0) | ||
17 | before settimeofday(NULL, tz) for UTC rtc mode when modify system TZ. | ||
18 | |||
19 | Upstream-Status: Backport [https://github.com/karelzak/util-linux/commit/ee85d3967ea09b215fcea5efdd90bbbf5e74a681] | ||
20 | |||
21 | CC: J William Piggott <elseifthen@gmx.com> | ||
22 | Signed-off-by: Karel Zak <kzak@redhat.com> | ||
23 | Addresses: https://github.com/karelzak/util-linux/issues/957 | ||
24 | Signed-off-by: Liwei Song <liwei.song@windriver.com> | ||
25 | --- | ||
26 | sys-utils/hwclock.c | 49 ++++++++++++++++++++++++++------------------- | ||
27 | 1 file changed, 28 insertions(+), 21 deletions(-) | ||
28 | |||
29 | diff --git a/sys-utils/hwclock.c b/sys-utils/hwclock.c | ||
30 | index e736da7179f8..16576bc186ff 100644 | ||
31 | --- a/sys-utils/hwclock.c | ||
32 | +++ b/sys-utils/hwclock.c | ||
33 | @@ -658,6 +658,9 @@ display_time(struct timeval hwctime) | ||
34 | * PCIL: persistent_clock_is_local, sets the "11 minute mode" timescale. | ||
35 | * firsttime: locks the warp_clock function (initialized to 1 at boot). | ||
36 | * | ||
37 | + * Note that very first settimeofday(NULL, tz) modifies warp-clock as well as | ||
38 | + * system TZ. | ||
39 | + * | ||
40 | * +---------------------------------------------------------------------------+ | ||
41 | * | op | RTC scale | settimeofday calls | | ||
42 | * |---------|-----------|-----------------------------------------------------| | ||
43 | @@ -675,41 +678,45 @@ set_system_clock(const struct hwclock_control *ctl, | ||
44 | struct tm broken; | ||
45 | int minuteswest; | ||
46 | int rc = 0; | ||
47 | - const struct timezone tz_utc = { 0 }; | ||
48 | |||
49 | localtime_r(&newtime.tv_sec, &broken); | ||
50 | minuteswest = -get_gmtoff(&broken) / 60; | ||
51 | |||
52 | if (ctl->verbose) { | ||
53 | - if (ctl->hctosys && !ctl->universal) | ||
54 | - printf(_("Calling settimeofday(NULL, %d) to set " | ||
55 | - "persistent_clock_is_local.\n"), minuteswest); | ||
56 | - if (ctl->systz && ctl->universal) | ||
57 | + if (ctl->universal) | ||
58 | puts(_("Calling settimeofday(NULL, 0) " | ||
59 | - "to lock the warp function.")); | ||
60 | + "to lock the warp function.")); | ||
61 | + else | ||
62 | + printf(_("Calling settimeofday(NULL, %d) to set " | ||
63 | + "persistent_clock_is_local and " | ||
64 | + "the kernel timezone.\n"), minuteswest); | ||
65 | + | ||
66 | + if (ctl->universal && minuteswest) | ||
67 | + printf(_("Calling settimeofday(NULL, %d) to set " | ||
68 | + "the kernel timezone.\n"), minuteswest); | ||
69 | + | ||
70 | if (ctl->hctosys) | ||
71 | - printf(_("Calling settimeofday(%ld.%06ld, %d)\n"), | ||
72 | - newtime.tv_sec, newtime.tv_usec, minuteswest); | ||
73 | - else { | ||
74 | - printf(_("Calling settimeofday(NULL, %d) "), minuteswest); | ||
75 | - if (ctl->universal) | ||
76 | - puts(_("to set the kernel timezone.")); | ||
77 | - else | ||
78 | - puts(_("to warp System time.")); | ||
79 | - } | ||
80 | + printf(_("Calling settimeofday(%ld.%06ld, 0) to set " | ||
81 | + "the kernel time.\n"), newtime.tv_sec, newtime.tv_usec); | ||
82 | } | ||
83 | |||
84 | if (!ctl->testing) { | ||
85 | + const struct timezone tz_utc = { 0 }; | ||
86 | const struct timezone tz = { minuteswest }; | ||
87 | |||
88 | - if (ctl->hctosys && !ctl->universal) /* set PCIL */ | ||
89 | + /* warp-clock */ | ||
90 | + if (ctl->universal) | ||
91 | + rc = settimeofday(NULL, &tz_utc); /* lock to UTC */ | ||
92 | + else | ||
93 | + rc = settimeofday(NULL, &tz); /* set PCIL and TZ */ | ||
94 | + | ||
95 | + /* set timezone */ | ||
96 | + if (!rc && ctl->universal && minuteswest) | ||
97 | rc = settimeofday(NULL, &tz); | ||
98 | - if (ctl->systz && ctl->universal) /* lock warp_clock */ | ||
99 | - rc = settimeofday(NULL, &tz_utc); | ||
100 | + | ||
101 | + /* set time */ | ||
102 | if (!rc && ctl->hctosys) | ||
103 | - rc = settimeofday(&newtime, &tz); | ||
104 | - else if (!rc) | ||
105 | - rc = settimeofday(NULL, &tz); | ||
106 | + rc = settimeofday(&newtime, NULL); | ||
107 | |||
108 | if (rc) { | ||
109 | warn(_("settimeofday() failed")); | ||
110 | -- | ||
111 | 2.17.1 | ||
112 | |||
diff --git a/meta/recipes-core/util-linux/util-linux_2.34.bb b/meta/recipes-core/util-linux/util-linux_2.34.bb index e9c2d80e90..557449d140 100644 --- a/meta/recipes-core/util-linux/util-linux_2.34.bb +++ b/meta/recipes-core/util-linux/util-linux_2.34.bb | |||
@@ -8,6 +8,7 @@ SRC_URI += "file://configure-sbindir.patch \ | |||
8 | file://display_testname_for_subtest.patch \ | 8 | file://display_testname_for_subtest.patch \ |
9 | file://avoid_parallel_tests.patch \ | 9 | file://avoid_parallel_tests.patch \ |
10 | file://0001-lsblk-force-to-print-PKNAME-for-partition.patch \ | 10 | file://0001-lsblk-force-to-print-PKNAME-for-partition.patch \ |
11 | file://0001-hwclock-fix-for-glibc-2.31-settimeofday.patch \ | ||
11 | " | 12 | " |
12 | SRC_URI[md5sum] = "a78cbeaed9c39094b96a48ba8f891d50" | 13 | SRC_URI[md5sum] = "a78cbeaed9c39094b96a48ba8f891d50" |
13 | SRC_URI[sha256sum] = "743f9d0c7252b6db246b659c1e1ce0bd45d8d4508b4dfa427bbb4a3e9b9f62b5" | 14 | SRC_URI[sha256sum] = "743f9d0c7252b6db246b659c1e1ce0bd45d8d4508b4dfa427bbb4a3e9b9f62b5" |