From d83c50b8e44db2a2e19d048ab7d1e1caf1fa1996 Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Wed, 6 Oct 2004 22:27:43 +0000 Subject: [PATCH] 2004-09-13 Ulrich Drepper , Dmitry V. Levin * time.c [LINUX] (print_rtc): New function, for printing rtc_time structure. [LINUX] (rtc_ioctl): New function, for parsing RTC_* ioctls. * ioctl.c [LINUX] (ioctl_decode): Call rtc_ioctl. * defs.h [LINUX]: Declare rtc_ioctl. Fixes RH#58606. --- defs.h | 3 ++ ioctl.c | 4 +++ time.c | 93 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 100 insertions(+) diff --git a/defs.h b/defs.h index 2158bf86..fd3a3800 100644 --- a/defs.h +++ b/defs.h @@ -476,6 +476,9 @@ extern int term_ioctl P((struct tcb *, long, long)); extern int sock_ioctl P((struct tcb *, long, long)); extern int proc_ioctl P((struct tcb *, int, int)); extern int stream_ioctl P((struct tcb *, int, int)); +#ifdef LINUX +extern int rtc_ioctl P((struct tcb *, long, long)); +#endif extern void tv_tv P((struct timeval *, int, int)); extern int tv_nz P((struct timeval *)); diff --git a/ioctl.c b/ioctl.c index 814caf0c..aba69c7f 100644 --- a/ioctl.c +++ b/ioctl.c @@ -149,6 +149,10 @@ long code, arg; case 'S': return stream_ioctl(tcp, code, arg); #endif /* HAVE_SYS_STREAM_H */ +#ifdef LINUX + case 'p': + return rtc_ioctl(tcp, code, arg); +#endif default: break; } diff --git a/time.c b/time.c index d273f0c8..5176f536 100644 --- a/time.c +++ b/time.c @@ -34,6 +34,8 @@ #ifdef LINUX #include #include +#include +#include #endif /* LINUX */ void @@ -519,4 +521,95 @@ struct tcb *tcp; } return 0; } + +static void +print_rtc(tcp, rt) +struct tcb *tcp; +const struct rtc_time *rt; +{ + tprintf("{tm_sec=%d, tm_min=%d, tm_hour=%d, " + "tm_mday=%d, tm_mon=%d, tm_year=%d, ", + rt->tm_sec, rt->tm_min, rt->tm_hour, + rt->tm_mday, rt->tm_mon, rt->tm_year); + if (!abbrev(tcp)) + tprintf("tm_wday=%d, tm_yday=%d, tm_isdst=%d}", + rt->tm_wday, rt->tm_yday, rt->tm_isdst); + else + tprintf("...}"); +} + +int +rtc_ioctl(tcp, code, arg) +struct tcb *tcp; +long code; +long arg; +{ + switch (code) { + case RTC_ALM_SET: + case RTC_SET_TIME: + if (entering(tcp)) { + struct rtc_time rt; + if (umove(tcp, arg, &rt) < 0) + tprintf(", %#lx", arg); + else { + tprintf(", "); + print_rtc(tcp, &rt); + } + } + break; + case RTC_ALM_READ: + case RTC_RD_TIME: + if (exiting(tcp)) { + struct rtc_time rt; + if (syserror(tcp) || umove(tcp, arg, &rt) < 0) + tprintf(", %#lx", arg); + else { + tprintf(", "); + print_rtc(tcp, &rt); + } + } + break; + case RTC_IRQP_SET: + case RTC_EPOCH_SET: + if (entering(tcp)) + tprintf(", %lu", arg); + break; + case RTC_IRQP_READ: + case RTC_EPOCH_READ: + if (exiting(tcp)) + tprintf(", %lu", arg); + break; + case RTC_WKALM_SET: + if (entering(tcp)) { + struct rtc_wkalrm wk; + if (umove(tcp, arg, &wk) < 0) + tprintf(", %#lx", arg); + else { + tprintf(", {enabled=%d, pending=%d, ", + wk.enabled, wk.pending); + print_rtc(tcp, &wk.time); + tprintf("}"); + } + } + break; + case RTC_WKALM_RD: + if (exiting(tcp)) { + struct rtc_wkalrm wk; + if (syserror(tcp) || umove(tcp, arg, &wk) < 0) + tprintf(", %#lx", arg); + else { + tprintf(", {enabled=%d, pending=%d, ", + wk.enabled, wk.pending); + print_rtc(tcp, &wk.time); + tprintf("}"); + } + } + break; + default: + if (entering(tcp)) + tprintf(", %#lx", arg); + break; + } + return 1; +} #endif /* LINUX */ -- 2.40.0