4 * Licensed under GPLv2, see file LICENSE in this tarball for details.
10 #if ENABLE_FEATURE_HWCLOCK_ADJTIME_FHS
11 # define ADJTIME_PATH "/var/lib/hwclock/adjtime"
13 # define ADJTIME_PATH "/etc/adjtime"
16 int FAST_FUNC rtc_adjtime_is_utc(void)
19 FILE *f = fopen_for_read(ADJTIME_PATH);
22 RESERVE_CONFIG_BUFFER(buffer, 128);
24 while (fgets(buffer, sizeof(buffer), f)) {
25 int len = strlen(buffer);
27 while (len && isspace(buffer[len - 1]))
32 if (strncmp(buffer, "UTC", 3) == 0) {
39 RELEASE_CONFIG_BUFFER(buffer);
45 int FAST_FUNC rtc_xopen(const char **default_rtc, int flags)
50 *default_rtc = "/dev/rtc";
51 rtc = open(*default_rtc, flags);
54 *default_rtc = "/dev/rtc0";
55 rtc = open(*default_rtc, flags);
58 *default_rtc = "/dev/misc/rtc";
61 return xopen(*default_rtc, flags);
64 time_t FAST_FUNC rtc_read_time(int fd, int utc)
70 memset(&tm, 0, sizeof(struct tm));
71 xioctl(fd, RTC_RD_TIME, &tm);
72 tm.tm_isdst = -1; /* not known */
76 putenv((char*)"TZ=UTC0");