diff options
author | Denis Vlasenko <vda.linux@googlemail.com> | 2007-03-07 23:02:50 +0000 |
---|---|---|
committer | Denis Vlasenko <vda.linux@googlemail.com> | 2007-03-07 23:02:50 +0000 |
commit | 673d4bbab6d6731a88611ff3174e199641389349 (patch) | |
tree | 14efc204d49a4c246b1411a802b15e8e56df5515 /util-linux/hwclock.c | |
parent | 7fb8a00341e40579ef8d95155669d33afb749faa (diff) | |
download | busybox-w32-673d4bbab6d6731a88611ff3174e199641389349.tar.gz busybox-w32-673d4bbab6d6731a88611ff3174e199641389349.tar.bz2 busybox-w32-673d4bbab6d6731a88611ff3174e199641389349.zip |
hwclock: support /dev/rtc0 etc
Diffstat (limited to 'util-linux/hwclock.c')
-rw-r--r-- | util-linux/hwclock.c | 22 |
1 files changed, 15 insertions, 7 deletions
diff --git a/util-linux/hwclock.c b/util-linux/hwclock.c index ca4238f9e..86235e989 100644 --- a/util-linux/hwclock.c +++ b/util-linux/hwclock.c | |||
@@ -35,16 +35,22 @@ struct linux_rtc_time { | |||
35 | # endif | 35 | # endif |
36 | #endif | 36 | #endif |
37 | 37 | ||
38 | static const char *rtcname; | ||
39 | |||
38 | static int xopen_rtc(int flags) | 40 | static int xopen_rtc(int flags) |
39 | { | 41 | { |
40 | int rtc; | 42 | int rtc; |
41 | rtc = open("/dev/rtc", flags); | 43 | |
42 | if (rtc < 0) { | 44 | if (!rtcname) { |
43 | rtc = open("/dev/misc/rtc", flags); | 45 | rtc = open("/dev/rtc", flags); |
44 | if (rtc < 0) | 46 | if (rtc >= 0) |
45 | bb_perror_msg_and_die("cannot access RTC"); | 47 | return rtc; |
48 | rtc = open("/dev/rtc0", flags); | ||
49 | if (rtc >= 0) | ||
50 | return rtc; | ||
51 | rtcname = "/dev/misc/rtc"; | ||
46 | } | 52 | } |
47 | return rtc; | 53 | return xopen(rtcname, flags); |
48 | } | 54 | } |
49 | 55 | ||
50 | static time_t read_rtc(int utc) | 56 | static time_t read_rtc(int utc) |
@@ -175,6 +181,7 @@ static int check_utc(void) | |||
175 | #define HWCLOCK_OPT_SHOW 0x04 | 181 | #define HWCLOCK_OPT_SHOW 0x04 |
176 | #define HWCLOCK_OPT_HCTOSYS 0x08 | 182 | #define HWCLOCK_OPT_HCTOSYS 0x08 |
177 | #define HWCLOCK_OPT_SYSTOHC 0x10 | 183 | #define HWCLOCK_OPT_SYSTOHC 0x10 |
184 | #define HWCLOCK_OPT_RTCFILE 0x20 | ||
178 | 185 | ||
179 | int hwclock_main(int argc, char **argv ); | 186 | int hwclock_main(int argc, char **argv ); |
180 | int hwclock_main(int argc, char **argv ) | 187 | int hwclock_main(int argc, char **argv ) |
@@ -189,12 +196,13 @@ int hwclock_main(int argc, char **argv ) | |||
189 | { "show", 0, 0, 'r' }, | 196 | { "show", 0, 0, 'r' }, |
190 | { "hctosys", 0, 0, 's' }, | 197 | { "hctosys", 0, 0, 's' }, |
191 | { "systohc", 0, 0, 'w' }, | 198 | { "systohc", 0, 0, 'w' }, |
199 | { "file", 1, 0, 'f' }, | ||
192 | { 0, 0, 0, 0 } | 200 | { 0, 0, 0, 0 } |
193 | }; | 201 | }; |
194 | applet_long_options = hwclock_long_options; | 202 | applet_long_options = hwclock_long_options; |
195 | #endif | 203 | #endif |
196 | opt_complementary = "?:r--ws:w--rs:s--wr:l--u:u--l"; | 204 | opt_complementary = "?:r--ws:w--rs:s--wr:l--u:u--l"; |
197 | opt = getopt32(argc, argv, "lursw"); | 205 | opt = getopt32(argc, argv, "lurswf:", &rtcname); |
198 | 206 | ||
199 | /* If -u or -l wasn't given check if we are using utc */ | 207 | /* If -u or -l wasn't given check if we are using utc */ |
200 | if (opt & (HWCLOCK_OPT_UTC | HWCLOCK_OPT_LOCALTIME)) | 208 | if (opt & (HWCLOCK_OPT_UTC | HWCLOCK_OPT_LOCALTIME)) |