[hackers] [ubase] Use rtc_time || sin
commit e3d7ffa05c8b658cf79e406baa3dcfe111fe4928
Author: sin <sin_AT_2f30.org>
Date: Tue Jun 3 15:04:53 2014 +0100
Use rtc_time
diff --git a/hwclock.c b/hwclock.c
index 093d5bd..4193b62 100644
--- a/hwclock.c
+++ b/hwclock.c
_AT_@ -77,14 +77,36 @@ echotime(char *dev)
static void
readrtctm(struct tm *tm, int fd)
{
- memset(tm, 0, sizeof(*tm));
- ioctl(fd, RTC_RD_TIME, tm);
+ struct rtc_time rt;
+
+ memset(&rt, 0, sizeof(rt));
+ ioctl(fd, RTC_RD_TIME, &rt);
+ tm->tm_sec = rt.tm_sec;
+ tm->tm_min = rt.tm_min;
+ tm->tm_hour = rt.tm_hour;
+ tm->tm_mday = rt.tm_mday;
+ tm->tm_mon = rt.tm_mon;
+ tm->tm_year = rt.tm_year;
+ tm->tm_wday = rt.tm_wday;
+ tm->tm_yday = rt.tm_yday;
+ tm->tm_isdst = rt.tm_isdst;
}
static void
writertctm(struct tm *tm, int fd)
{
- ioctl(fd, RTC_SET_TIME, tm);
+ struct rtc_time rt;
+
+ rt.tm_sec = tm->tm_sec;
+ rt.tm_min = tm->tm_min;
+ rt.tm_hour = tm->tm_hour;
+ rt.tm_mday = tm->tm_mday;
+ rt.tm_mon = tm->tm_mon;
+ rt.tm_year = tm->tm_year;
+ rt.tm_wday = tm->tm_wday;
+ rt.tm_yday = tm->tm_yday;
+ rt.tm_isdst = tm->tm_isdst;
+ ioctl(fd, RTC_SET_TIME, &rt);
}
static void
diff --git a/rtc.h b/rtc.h
index 9dd76c1..e4135a7 100644
--- a/rtc.h
+++ b/rtc.h
_AT_@ -1,2 +1,20 @@
-#define RTC_RD_TIME _IOR('p', 0x09, struct tm) /* Read RTC time */
-#define RTC_SET_TIME _IOW('p', 0x0a, struct tm) /* Set RTC time */
+/*
+ * The struct used to pass data via the following ioctl. Similar to the
+ * struct tm in <time.h>, but it needs to be here so that the kernel
+ * source is self contained, allowing cross-compiles, etc. etc.
+ */
+
+struct rtc_time {
+ int tm_sec;
+ int tm_min;
+ int tm_hour;
+ int tm_mday;
+ int tm_mon;
+ int tm_year;
+ int tm_wday;
+ int tm_yday;
+ int tm_isdst;
+};
+
+#define RTC_RD_TIME _IOR('p', 0x09, struct rtc_time) /* Read RTC time */
+#define RTC_SET_TIME _IOW('p', 0x0a, struct rtc_time) /* Set RTC time */
Received on Tue Jun 03 2014 - 16:15:24 CEST
This archive was generated by hypermail 2.3.0
: Tue Jun 03 2014 - 16:24:07 CEST