]> granicus.if.org Git - strace/commitdiff
time.c: move rtc ioctl parser to a separate file
authorDmitry V. Levin <ldv@altlinux.org>
Sat, 4 Jul 2015 08:56:21 +0000 (08:56 +0000)
committerDmitry V. Levin <ldv@altlinux.org>
Sun, 5 Jul 2015 21:37:26 +0000 (21:37 +0000)
* rtc.c: new file
* Makefile.am (strace_SOURCES): Add it.
* time.c (print_rtc, rtc_ioctl): Move to rtc.c.

Makefile.am
rtc.c [new file with mode: 0644]
time.c

index e2a0f747f1dc970b7a7f8327042143ff2859747a..4790f3257e9f3c027317fe1f3cc9b7b883d43779 100644 (file)
@@ -90,6 +90,7 @@ strace_SOURCES =      \
        regs.h          \
        renameat.c      \
        resource.c      \
+       rtc.c           \
        sched.c         \
        scsi.c          \
        seccomp.c       \
diff --git a/rtc.c b/rtc.c
new file mode 100644 (file)
index 0000000..f72f98a
--- /dev/null
+++ b/rtc.c
@@ -0,0 +1,115 @@
+/*
+ * Copyright (c) 2004 Ulrich Drepper <drepper@redhat.com>
+ * Copyright (c) 2004 Dmitry V. Levin <ldv@altlinux.org>
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote products
+ *    derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "defs.h"
+#include <linux/ioctl.h>
+#include <linux/rtc.h>
+
+static void
+print_rtc(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
+               tprints("...}");
+}
+
+int
+rtc_ioctl(struct tcb *tcp, const unsigned int code, const 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 {
+                               tprints(", ");
+                               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 {
+                               tprints(", ");
+                               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);
+                               tprints("}");
+                       }
+               }
+               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);
+                               tprints("}");
+                       }
+               }
+               break;
+       default:
+               return 0;
+       }
+       return 1;
+}
diff --git a/time.c b/time.c
index b30fd0f2a93d133e9189fb47d571fdf1f417ffc8..f315f5daea6bd3f2ffb1d2e448ed91e48488023d 100644 (file)
--- a/time.c
+++ b/time.c
@@ -31,8 +31,6 @@
 #include <fcntl.h>
 #include <linux/version.h>
 #include <sys/timex.h>
-#include <linux/ioctl.h>
-#include <linux/rtc.h>
 
 #ifndef UTIME_NOW
 #define UTIME_NOW ((1l << 30) - 1l)
@@ -704,92 +702,6 @@ SYS_FUNC(timer_gettime)
        return 0;
 }
 
-static void
-print_rtc(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
-               tprints("...}");
-}
-
-int
-rtc_ioctl(struct tcb *tcp, const unsigned int 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 {
-                               tprints(", ");
-                               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 {
-                               tprints(", ");
-                               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);
-                               tprints("}");
-                       }
-               }
-               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);
-                               tprints("}");
-                       }
-               }
-               break;
-       default:
-               if (entering(tcp))
-                       tprintf(", %#lx", arg);
-               break;
-       }
-       return 1;
-}
-
 #include "xlat/timerfdflags.h"
 
 SYS_FUNC(timerfd)