blob: 066cf4049b1dbf439cdac8c20a01cc744bc44dec [file] [log] [blame]
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001/*
2 * Copyright (c) 1991, 1992 Paul Kranenburg <pk@cs.few.eur.nl>
3 * Copyright (c) 1993 Branko Lankester <branko@hacktic.nl>
4 * Copyright (c) 1993, 1994, 1995, 1996 Rick Sladkey <jrs@world.std.com>
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 * 3. The name of the author may not be used to endorse or promote products
16 * derived from this software without specific prior written permission.
17 *
18 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
19 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
20 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
21 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
22 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
23 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
27 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 *
29 * $Id$
30 */
31
32#include "defs.h"
33
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000034#include <linux/version.h>
Wichert Akkermand856b992000-10-13 12:47:12 +000035#include <sys/timex.h>
Roland McGrathd83c50b2004-10-06 22:27:43 +000036#include <linux/ioctl.h>
37#include <linux/rtc.h>
Roland McGrath6afc5652007-07-24 01:57:11 +000038
39#ifndef UTIME_NOW
40#define UTIME_NOW ((1l << 30) - 1l)
41#endif
42#ifndef UTIME_OMIT
43#define UTIME_OMIT ((1l << 30) - 2l)
44#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000045
Dmitry V. Levina7945a32006-12-13 17:10:11 +000046struct timeval32
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000047{
Dmitry V. Levina7945a32006-12-13 17:10:11 +000048 u_int32_t tv_sec, tv_usec;
49};
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000050
Dmitry V. Levin1cad25d2006-12-13 17:14:36 +000051static void
52tprint_timeval32(struct tcb *tcp, const struct timeval32 *tv)
53{
54 tprintf("{%u, %u}", tv->tv_sec, tv->tv_usec);
55}
56
57static void
58tprint_timeval(struct tcb *tcp, const struct timeval *tv)
59{
60 tprintf("{%lu, %lu}",
61 (unsigned long) tv->tv_sec, (unsigned long) tv->tv_usec);
62}
63
Dmitry V. Levina7945a32006-12-13 17:10:11 +000064void
Roland McGrath6afc5652007-07-24 01:57:11 +000065printtv_bitness(struct tcb *tcp, long addr, enum bitness_t bitness, int special)
Dmitry V. Levina7945a32006-12-13 17:10:11 +000066{
Denys Vlasenkoa1d541e2012-01-20 11:04:04 +010067 char buf[TIMEVAL_TEXT_BUFSIZE];
68 sprinttv(buf, tcp, addr, bitness, special);
69 tprints(buf);
Dmitry V. Levina7945a32006-12-13 17:10:11 +000070}
Wichert Akkerman221f54f1999-11-18 17:26:45 +000071
Denys Vlasenko2fb4db32011-08-31 12:26:03 +020072char *
Denys Vlasenkoa1d541e2012-01-20 11:04:04 +010073sprinttv(char *buf, struct tcb *tcp, long addr, enum bitness_t bitness, int special)
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +000074{
Denys Vlasenko2fb4db32011-08-31 12:26:03 +020075 int rc;
76
Dmitry V. Levina7945a32006-12-13 17:10:11 +000077 if (addr == 0)
Denys Vlasenko2fb4db32011-08-31 12:26:03 +020078 return stpcpy(buf, "NULL");
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +000079
Denys Vlasenkob9c7ae62011-09-01 11:40:40 +020080 if (!verbose(tcp))
81 return buf + sprintf(buf, "%#lx", addr);
Denys Vlasenko2fb4db32011-08-31 12:26:03 +020082
83 if (bitness == BITNESS_32
Denys Vlasenko84703742012-02-25 02:38:52 +010084#if SUPPORTED_PERSONALITIES > 1
Denys Vlasenko2fb4db32011-08-31 12:26:03 +020085 || personality_wordsize[current_personality] == 4
86#endif
87 )
88 {
89 struct timeval32 tv;
90
91 rc = umove(tcp, addr, &tv);
Denys Vlasenkoa1d541e2012-01-20 11:04:04 +010092 if (rc >= 0) {
93 if (special && tv.tv_sec == 0) {
94 if (tv.tv_usec == UTIME_NOW)
95 return stpcpy(buf, "UTIME_NOW");
96 if (tv.tv_usec == UTIME_OMIT)
97 return stpcpy(buf, "UTIME_OMIT");
98 }
Denys Vlasenkob9c7ae62011-09-01 11:40:40 +020099 return buf + sprintf(buf, "{%u, %u}",
Denys Vlasenko2fb4db32011-08-31 12:26:03 +0200100 tv.tv_sec, tv.tv_usec);
Denys Vlasenkoa1d541e2012-01-20 11:04:04 +0100101 }
Denys Vlasenko2fb4db32011-08-31 12:26:03 +0200102 } else {
103 struct timeval tv;
104
105 rc = umove(tcp, addr, &tv);
Denys Vlasenkoa1d541e2012-01-20 11:04:04 +0100106 if (rc >= 0) {
107 if (special && tv.tv_sec == 0) {
108 if (tv.tv_usec == UTIME_NOW)
109 return stpcpy(buf, "UTIME_NOW");
110 if (tv.tv_usec == UTIME_OMIT)
111 return stpcpy(buf, "UTIME_OMIT");
112 }
Denys Vlasenkob9c7ae62011-09-01 11:40:40 +0200113 return buf + sprintf(buf, "{%lu, %lu}",
Denys Vlasenko2fb4db32011-08-31 12:26:03 +0200114 (unsigned long) tv.tv_sec,
115 (unsigned long) tv.tv_usec);
Denys Vlasenkoa1d541e2012-01-20 11:04:04 +0100116 }
Denys Vlasenko2fb4db32011-08-31 12:26:03 +0200117 }
Denys Vlasenko2fb4db32011-08-31 12:26:03 +0200118
Denys Vlasenkob9c7ae62011-09-01 11:40:40 +0200119 return stpcpy(buf, "{...}");
Dmitry V. Levina7945a32006-12-13 17:10:11 +0000120}
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +0000121
Denys Vlasenkoa1d541e2012-01-20 11:04:04 +0100122void
123print_timespec(struct tcb *tcp, long addr)
Roland McGrath6bc09da2007-11-01 21:50:54 +0000124{
Denys Vlasenkoa1d541e2012-01-20 11:04:04 +0100125 char buf[TIMESPEC_TEXT_BUFSIZE];
126 sprint_timespec(buf, tcp, addr);
127 tprints(buf);
Roland McGrath6bc09da2007-11-01 21:50:54 +0000128}
129
Denys Vlasenkoa1d541e2012-01-20 11:04:04 +0100130void
131sprint_timespec(char *buf, struct tcb *tcp, long addr)
Roland McGrath6bc09da2007-11-01 21:50:54 +0000132{
133 if (addr == 0)
134 strcpy(buf, "NULL");
135 else if (!verbose(tcp))
136 sprintf(buf, "%#lx", addr);
137 else {
Denys Vlasenko1d632462009-04-14 12:51:00 +0000138 int rc;
Roland McGrath6bc09da2007-11-01 21:50:54 +0000139
Denys Vlasenko84703742012-02-25 02:38:52 +0100140#if SUPPORTED_PERSONALITIES > 1
Denys Vlasenko1d632462009-04-14 12:51:00 +0000141 if (personality_wordsize[current_personality] == 4) {
Roland McGrath6bc09da2007-11-01 21:50:54 +0000142 struct timeval32 tv;
143
Denys Vlasenko5d645812011-08-20 12:48:18 +0200144 rc = umove(tcp, addr, &tv);
145 if (rc >= 0)
Roland McGrath6bc09da2007-11-01 21:50:54 +0000146 sprintf(buf, "{%u, %u}",
147 tv.tv_sec, tv.tv_usec);
148 } else
Roland McGrath6bc09da2007-11-01 21:50:54 +0000149#endif
Denys Vlasenko1d632462009-04-14 12:51:00 +0000150 {
Roland McGrath6bc09da2007-11-01 21:50:54 +0000151 struct timespec ts;
152
Denys Vlasenko5d645812011-08-20 12:48:18 +0200153 rc = umove(tcp, addr, &ts);
154 if (rc >= 0)
Roland McGrath6bc09da2007-11-01 21:50:54 +0000155 sprintf(buf, "{%lu, %lu}",
156 (unsigned long) ts.tv_sec,
157 (unsigned long) ts.tv_nsec);
Roland McGrath6bc09da2007-11-01 21:50:54 +0000158 }
Roland McGrath6bc09da2007-11-01 21:50:54 +0000159 if (rc < 0)
160 strcpy(buf, "{...}");
161 }
162}
163
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000164int
Denys Vlasenko12014262011-05-30 14:00:14 +0200165sys_time(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000166{
167 if (exiting(tcp)) {
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000168 printnum(tcp, tcp->u_arg[0], "%ld");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000169 }
170 return 0;
171}
172
173int
Denys Vlasenko12014262011-05-30 14:00:14 +0200174sys_stime(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000175{
176 if (exiting(tcp)) {
177 printnum(tcp, tcp->u_arg[0], "%ld");
178 }
179 return 0;
180}
181
182int
Denys Vlasenko12014262011-05-30 14:00:14 +0200183sys_gettimeofday(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000184{
185 if (exiting(tcp)) {
186 if (syserror(tcp)) {
187 tprintf("%#lx, %#lx",
188 tcp->u_arg[0], tcp->u_arg[1]);
189 return 0;
190 }
191 printtv(tcp, tcp->u_arg[0]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200192 tprints(", ");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000193 printtv(tcp, tcp->u_arg[1]);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000194 }
195 return 0;
196}
197
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +0000198#ifdef ALPHA
199int
Denys Vlasenko12014262011-05-30 14:00:14 +0200200sys_osf_gettimeofday(struct tcb *tcp)
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +0000201{
Denys Vlasenko1d632462009-04-14 12:51:00 +0000202 if (exiting(tcp)) {
203 if (syserror(tcp)) {
204 tprintf("%#lx, %#lx", tcp->u_arg[0], tcp->u_arg[1]);
205 return 0;
206 }
207 printtv_bitness(tcp, tcp->u_arg[0], BITNESS_32, 0);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200208 tprints(", ");
Denys Vlasenko1d632462009-04-14 12:51:00 +0000209 printtv_bitness(tcp, tcp->u_arg[1], BITNESS_32, 0);
Denys Vlasenko1d632462009-04-14 12:51:00 +0000210 }
211 return 0;
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +0000212}
213#endif
214
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000215int
Denys Vlasenko12014262011-05-30 14:00:14 +0200216sys_settimeofday(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000217{
218 if (entering(tcp)) {
219 printtv(tcp, tcp->u_arg[0]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200220 tprints(", ");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000221 printtv(tcp, tcp->u_arg[1]);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000222 }
223 return 0;
224}
225
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +0000226#ifdef ALPHA
227int
Denys Vlasenko12014262011-05-30 14:00:14 +0200228sys_osf_settimeofday(struct tcb *tcp)
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +0000229{
Denys Vlasenko1d632462009-04-14 12:51:00 +0000230 if (entering(tcp)) {
231 printtv_bitness(tcp, tcp->u_arg[0], BITNESS_32, 0);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200232 tprints(", ");
Denys Vlasenko1d632462009-04-14 12:51:00 +0000233 printtv_bitness(tcp, tcp->u_arg[1], BITNESS_32, 0);
Denys Vlasenko1d632462009-04-14 12:51:00 +0000234 }
235 return 0;
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +0000236}
237#endif
238
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000239int
Denys Vlasenko12014262011-05-30 14:00:14 +0200240sys_adjtime(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000241{
242 if (entering(tcp)) {
243 printtv(tcp, tcp->u_arg[0]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200244 tprints(", ");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000245 } else {
246 if (syserror(tcp))
247 tprintf("%#lx", tcp->u_arg[1]);
248 else
249 printtv(tcp, tcp->u_arg[1]);
250 }
251 return 0;
252}
253
Dmitry V. Levin2e55ff42008-09-03 01:02:46 +0000254int
255sys_nanosleep(struct tcb *tcp)
256{
257 if (entering(tcp)) {
258 print_timespec(tcp, tcp->u_arg[0]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200259 tprints(", ");
Dmitry V. Levin2e55ff42008-09-03 01:02:46 +0000260 } else {
Denys Vlasenko64acaa12012-01-28 02:29:36 +0100261 /* Second (returned) timespec is only significant
262 * if syscall was interrupted. We print only its address
263 * on _success_, since kernel doesn't modify its value.
264 */
265 if (is_restart_error(tcp) || !tcp->u_arg[1])
266 /* Interrupted (or NULL) */
Dmitry V. Levin2e55ff42008-09-03 01:02:46 +0000267 print_timespec(tcp, tcp->u_arg[1]);
268 else
Denys Vlasenko64acaa12012-01-28 02:29:36 +0100269 /* Success */
Dmitry V. Levin2e55ff42008-09-03 01:02:46 +0000270 tprintf("%#lx", tcp->u_arg[1]);
271 }
272 return 0;
273}
274
Roland McGrathd9f816f2004-09-04 03:39:20 +0000275static const struct xlat which[] = {
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000276 { ITIMER_REAL, "ITIMER_REAL" },
277 { ITIMER_VIRTUAL,"ITIMER_VIRTUAL"},
278 { ITIMER_PROF, "ITIMER_PROF" },
279 { 0, NULL },
280};
281
282static void
Dmitry V. Levin1cad25d2006-12-13 17:14:36 +0000283printitv_bitness(struct tcb *tcp, long addr, enum bitness_t bitness)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000284{
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000285 if (addr == 0)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200286 tprints("NULL");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000287 else if (!verbose(tcp))
288 tprintf("%#lx", addr);
Denys Vlasenko1d632462009-04-14 12:51:00 +0000289 else {
290 int rc;
Dmitry V. Levin1cad25d2006-12-13 17:14:36 +0000291
292 if (bitness == BITNESS_32
Denys Vlasenko84703742012-02-25 02:38:52 +0100293#if SUPPORTED_PERSONALITIES > 1
Dmitry V. Levin1cad25d2006-12-13 17:14:36 +0000294 || personality_wordsize[current_personality] == 4
295#endif
296 )
297 {
Denys Vlasenko1d632462009-04-14 12:51:00 +0000298 struct {
Dmitry V. Levin1cad25d2006-12-13 17:14:36 +0000299 struct timeval32 it_interval, it_value;
300 } itv;
301
Denys Vlasenko5d645812011-08-20 12:48:18 +0200302 rc = umove(tcp, addr, &itv);
303 if (rc >= 0) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200304 tprints("{it_interval=");
Dmitry V. Levin1cad25d2006-12-13 17:14:36 +0000305 tprint_timeval32(tcp, &itv.it_interval);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200306 tprints(", it_value=");
Dmitry V. Levin1cad25d2006-12-13 17:14:36 +0000307 tprint_timeval32(tcp, &itv.it_value);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200308 tprints("}");
Roland McGrathe4662342007-08-02 01:25:34 +0000309 }
Denys Vlasenko1d632462009-04-14 12:51:00 +0000310 } else {
Dmitry V. Levin1cad25d2006-12-13 17:14:36 +0000311 struct itimerval itv;
312
Denys Vlasenko5d645812011-08-20 12:48:18 +0200313 rc = umove(tcp, addr, &itv);
314 if (rc >= 0) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200315 tprints("{it_interval=");
Dmitry V. Levin1cad25d2006-12-13 17:14:36 +0000316 tprint_timeval(tcp, &itv.it_interval);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200317 tprints(", it_value=");
Dmitry V. Levin1cad25d2006-12-13 17:14:36 +0000318 tprint_timeval(tcp, &itv.it_value);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200319 tprints("}");
Roland McGrathe4662342007-08-02 01:25:34 +0000320 }
Dmitry V. Levin1cad25d2006-12-13 17:14:36 +0000321 }
Dmitry V. Levin1cad25d2006-12-13 17:14:36 +0000322 if (rc < 0)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200323 tprints("{...}");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000324 }
325}
326
Dmitry V. Levin1cad25d2006-12-13 17:14:36 +0000327#define printitv(tcp, addr) \
328 printitv_bitness((tcp), (addr), BITNESS_CURRENT)
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +0000329
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000330int
Denys Vlasenko12014262011-05-30 14:00:14 +0200331sys_getitimer(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000332{
333 if (entering(tcp)) {
334 printxval(which, tcp->u_arg[0], "ITIMER_???");
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200335 tprints(", ");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000336 } else {
337 if (syserror(tcp))
338 tprintf("%#lx", tcp->u_arg[1]);
339 else
340 printitv(tcp, tcp->u_arg[1]);
341 }
342 return 0;
343}
344
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +0000345#ifdef ALPHA
346int
Denys Vlasenko12014262011-05-30 14:00:14 +0200347sys_osf_getitimer(struct tcb *tcp)
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +0000348{
Denys Vlasenko1d632462009-04-14 12:51:00 +0000349 if (entering(tcp)) {
350 printxval(which, tcp->u_arg[0], "ITIMER_???");
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200351 tprints(", ");
Denys Vlasenko1d632462009-04-14 12:51:00 +0000352 } else {
353 if (syserror(tcp))
354 tprintf("%#lx", tcp->u_arg[1]);
355 else
356 printitv_bitness(tcp, tcp->u_arg[1], BITNESS_32);
357 }
358 return 0;
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +0000359}
360#endif
361
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000362int
Denys Vlasenko12014262011-05-30 14:00:14 +0200363sys_setitimer(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000364{
365 if (entering(tcp)) {
366 printxval(which, tcp->u_arg[0], "ITIMER_???");
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200367 tprints(", ");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000368 printitv(tcp, tcp->u_arg[1]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200369 tprints(", ");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000370 } else {
371 if (syserror(tcp))
372 tprintf("%#lx", tcp->u_arg[2]);
373 else
374 printitv(tcp, tcp->u_arg[2]);
375 }
376 return 0;
377}
378
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +0000379#ifdef ALPHA
380int
Denys Vlasenko12014262011-05-30 14:00:14 +0200381sys_osf_setitimer(struct tcb *tcp)
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +0000382{
Denys Vlasenko1d632462009-04-14 12:51:00 +0000383 if (entering(tcp)) {
384 printxval(which, tcp->u_arg[0], "ITIMER_???");
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200385 tprints(", ");
Denys Vlasenko1d632462009-04-14 12:51:00 +0000386 printitv_bitness(tcp, tcp->u_arg[1], BITNESS_32);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200387 tprints(", ");
Denys Vlasenko1d632462009-04-14 12:51:00 +0000388 } else {
389 if (syserror(tcp))
390 tprintf("%#lx", tcp->u_arg[2]);
391 else
392 printitv_bitness(tcp, tcp->u_arg[2], BITNESS_32);
393 }
394 return 0;
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +0000395}
396#endif
397
Dmitry V. Levin1a684d62006-12-13 17:42:32 +0000398static const struct xlat adjtimex_modes[] = {
399 { 0, "0" },
400#ifdef ADJ_OFFSET
401 { ADJ_OFFSET, "ADJ_OFFSET" },
402#endif
403#ifdef ADJ_FREQUENCY
404 { ADJ_FREQUENCY, "ADJ_FREQUENCY" },
405#endif
406#ifdef ADJ_MAXERROR
407 { ADJ_MAXERROR, "ADJ_MAXERROR" },
408#endif
409#ifdef ADJ_ESTERROR
410 { ADJ_ESTERROR, "ADJ_ESTERROR" },
411#endif
412#ifdef ADJ_STATUS
413 { ADJ_STATUS, "ADJ_STATUS" },
414#endif
415#ifdef ADJ_TIMECONST
416 { ADJ_TIMECONST, "ADJ_TIMECONST" },
417#endif
418#ifdef ADJ_TICK
419 { ADJ_TICK, "ADJ_TICK" },
420#endif
421#ifdef ADJ_OFFSET_SINGLESHOT
422 { ADJ_OFFSET_SINGLESHOT, "ADJ_OFFSET_SINGLESHOT" },
423#endif
424 { 0, NULL }
425};
426
427static const struct xlat adjtimex_status[] = {
428#ifdef STA_PLL
429 { STA_PLL, "STA_PLL" },
430#endif
431#ifdef STA_PPSFREQ
432 { STA_PPSFREQ, "STA_PPSFREQ" },
433#endif
434#ifdef STA_PPSTIME
435 { STA_PPSTIME, "STA_PPSTIME" },
436#endif
437#ifdef STA_FLL
438 { STA_FLL, "STA_FLL" },
439#endif
440#ifdef STA_INS
441 { STA_INS, "STA_INS" },
442#endif
443#ifdef STA_DEL
444 { STA_DEL, "STA_DEL" },
445#endif
446#ifdef STA_UNSYNC
447 { STA_UNSYNC, "STA_UNSYNC" },
448#endif
449#ifdef STA_FREQHOLD
450 { STA_FREQHOLD, "STA_FREQHOLD" },
451#endif
452#ifdef STA_PPSSIGNAL
453 { STA_PPSSIGNAL, "STA_PPSSIGNAL" },
454#endif
455#ifdef STA_PPSJITTER
456 { STA_PPSJITTER, "STA_PPSJITTER" },
457#endif
458#ifdef STA_PPSWANDER
459 { STA_PPSWANDER, "STA_PPSWANDER" },
460#endif
461#ifdef STA_PPSERROR
462 { STA_PPSERROR, "STA_PPSERROR" },
463#endif
464#ifdef STA_CLOCKERR
465 { STA_CLOCKERR, "STA_CLOCKERR" },
466#endif
467 { 0, NULL }
468};
469
470static const struct xlat adjtimex_state[] = {
471#ifdef TIME_OK
472 { TIME_OK, "TIME_OK" },
473#endif
474#ifdef TIME_INS
475 { TIME_INS, "TIME_INS" },
476#endif
477#ifdef TIME_DEL
478 { TIME_DEL, "TIME_DEL" },
479#endif
480#ifdef TIME_OOP
481 { TIME_OOP, "TIME_OOP" },
482#endif
483#ifdef TIME_WAIT
484 { TIME_WAIT, "TIME_WAIT" },
485#endif
486#ifdef TIME_ERROR
487 { TIME_ERROR, "TIME_ERROR" },
488#endif
489 { 0, NULL }
490};
491
Dmitry V. Levin165b15d2006-12-13 17:43:45 +0000492#if SUPPORTED_PERSONALITIES > 1
493static int
494tprint_timex32(struct tcb *tcp, long addr)
495{
Denys Vlasenko1d632462009-04-14 12:51:00 +0000496 struct {
Dmitry V. Levin165b15d2006-12-13 17:43:45 +0000497 unsigned int modes;
498 int offset;
499 int freq;
500 int maxerror;
501 int esterror;
502 int status;
503 int constant;
504 int precision;
505 int tolerance;
506 struct timeval32 time;
507 int tick;
508 int ppsfreq;
509 int jitter;
510 int shift;
511 int stabil;
512 int jitcnt;
513 int calcnt;
514 int errcnt;
515 int stbcnt;
516 } tx;
517
518 if (umove(tcp, addr, &tx) < 0)
519 return -1;
520
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200521 tprints("{modes=");
Dmitry V. Levin71d70892007-01-13 11:17:38 +0000522 printflags(adjtimex_modes, tx.modes, "ADJ_???");
Dmitry V. Levin165b15d2006-12-13 17:43:45 +0000523 tprintf(", offset=%d, freq=%d, maxerror=%d, ",
524 tx.offset, tx.freq, tx.maxerror);
525 tprintf("esterror=%u, status=", tx.esterror);
526 printflags(adjtimex_status, tx.status, "STA_???");
527 tprintf(", constant=%d, precision=%u, ",
528 tx.constant, tx.precision);
529 tprintf("tolerance=%d, time=", tx.tolerance);
530 tprint_timeval32(tcp, &tx.time);
531 tprintf(", tick=%d, ppsfreq=%d, jitter=%d",
532 tx.tick, tx.ppsfreq, tx.jitter);
533 tprintf(", shift=%d, stabil=%d, jitcnt=%d",
534 tx.shift, tx.stabil, tx.jitcnt);
535 tprintf(", calcnt=%d, errcnt=%d, stbcnt=%d",
536 tx.calcnt, tx.errcnt, tx.stbcnt);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200537 tprints("}");
Dmitry V. Levin165b15d2006-12-13 17:43:45 +0000538 return 0;
539}
540#endif /* SUPPORTED_PERSONALITIES > 1 */
541
542static int
543tprint_timex(struct tcb *tcp, long addr)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000544{
Dmitry V. Levin1a684d62006-12-13 17:42:32 +0000545 struct timex tx;
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000546
Dmitry V. Levin165b15d2006-12-13 17:43:45 +0000547#if SUPPORTED_PERSONALITIES > 1
548 if (personality_wordsize[current_personality] == 4)
549 return tprint_timex32(tcp, addr);
550#endif
551 if (umove(tcp, addr, &tx) < 0)
552 return -1;
553
554#if LINUX_VERSION_CODE < 66332
555 tprintf("{mode=%d, offset=%ld, frequency=%ld, ",
556 tx.mode, tx.offset, tx.frequency);
557 tprintf("maxerror=%ld, esterror=%lu, status=%u, ",
558 tx.maxerror, tx.esterror, tx.status);
559 tprintf("time_constant=%ld, precision=%lu, ",
560 tx.time_constant, tx.precision);
561 tprintf("tolerance=%ld, time=", tx.tolerance);
562 tprint_timeval(tcp, &tx.time);
563#else
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200564 tprints("{modes=");
Dmitry V. Levin71d70892007-01-13 11:17:38 +0000565 printflags(adjtimex_modes, tx.modes, "ADJ_???");
Dmitry V. Levin165b15d2006-12-13 17:43:45 +0000566 tprintf(", offset=%ld, freq=%ld, maxerror=%ld, ",
H.J. Lu0b315b62012-02-03 10:16:03 -0800567 (long) tx.offset, (long) tx.freq, (long) tx.maxerror);
568 tprintf("esterror=%lu, status=", (long) tx.esterror);
Dmitry V. Levin165b15d2006-12-13 17:43:45 +0000569 printflags(adjtimex_status, tx.status, "STA_???");
570 tprintf(", constant=%ld, precision=%lu, ",
H.J. Lu0b315b62012-02-03 10:16:03 -0800571 (long) tx.constant, (long) tx.precision);
572 tprintf("tolerance=%ld, time=", (long) tx.tolerance);
Dmitry V. Levin165b15d2006-12-13 17:43:45 +0000573 tprint_timeval(tcp, &tx.time);
574 tprintf(", tick=%ld, ppsfreq=%ld, jitter=%ld",
H.J. Lu0b315b62012-02-03 10:16:03 -0800575 (long) tx.tick, (long) tx.ppsfreq, (long) tx.jitter);
Dmitry V. Levin165b15d2006-12-13 17:43:45 +0000576 tprintf(", shift=%d, stabil=%ld, jitcnt=%ld",
H.J. Lu0b315b62012-02-03 10:16:03 -0800577 tx.shift, (long) tx.stabil, (long) tx.jitcnt);
Dmitry V. Levin165b15d2006-12-13 17:43:45 +0000578 tprintf(", calcnt=%ld, errcnt=%ld, stbcnt=%ld",
H.J. Lu0b315b62012-02-03 10:16:03 -0800579 (long) tx.calcnt, (long) tx.errcnt, (long) tx.stbcnt);
Dmitry V. Levin165b15d2006-12-13 17:43:45 +0000580#endif
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200581 tprints("}");
Dmitry V. Levin165b15d2006-12-13 17:43:45 +0000582 return 0;
583}
584
585int
586sys_adjtimex(struct tcb *tcp)
587{
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000588 if (exiting(tcp)) {
589 if (tcp->u_arg[0] == 0)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200590 tprints("NULL");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000591 else if (syserror(tcp) || !verbose(tcp))
592 tprintf("%#lx", tcp->u_arg[0]);
Dmitry V. Levin165b15d2006-12-13 17:43:45 +0000593 else if (tprint_timex(tcp, tcp->u_arg[0]) < 0)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200594 tprints("{...}");
Dmitry V. Levin21a75342008-09-03 01:22:18 +0000595 if (syserror(tcp))
596 return 0;
Dmitry V. Levin1a684d62006-12-13 17:42:32 +0000597 tcp->auxstr = xlookup(adjtimex_state, tcp->u_rval);
598 if (tcp->auxstr)
599 return RVAL_STR;
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000600 }
601 return 0;
602}
Roland McGrath1e356792003-03-30 23:52:28 +0000603
Roland McGrathd9f816f2004-09-04 03:39:20 +0000604static const struct xlat clockflags[] = {
Roland McGrath1e356792003-03-30 23:52:28 +0000605 { TIMER_ABSTIME, "TIMER_ABSTIME" },
606 { 0, NULL }
607};
608
Roland McGrathd9f816f2004-09-04 03:39:20 +0000609static const struct xlat clocknames[] = {
Roland McGrath55a00f82004-08-31 08:26:39 +0000610#ifdef CLOCK_REALTIME
Roland McGrath54a4edd2004-08-31 06:52:45 +0000611 { CLOCK_REALTIME, "CLOCK_REALTIME" },
Roland McGrath55a00f82004-08-31 08:26:39 +0000612#endif
613#ifdef CLOCK_MONOTONIC
Roland McGrath54a4edd2004-08-31 06:52:45 +0000614 { CLOCK_MONOTONIC, "CLOCK_MONOTONIC" },
Roland McGrath55a00f82004-08-31 08:26:39 +0000615#endif
Dmitry V. Levincbaaf792010-09-17 09:19:49 +0000616#ifdef CLOCK_PROCESS_CPUTIME_ID
617 { CLOCK_PROCESS_CPUTIME_ID, "CLOCK_PROCESS_CPUTIME_ID" },
618#endif
619#ifdef CLOCK_THREAD_CPUTIME_ID
620 { CLOCK_THREAD_CPUTIME_ID, "CLOCK_THREAD_CPUTIME_ID" },
621#endif
622#ifdef CLOCK_MONOTONIC_RAW
623 { CLOCK_MONOTONIC_RAW, "CLOCK_MONOTONIC_RAW" },
624#endif
625#ifdef CLOCK_REALTIME_COARSE
626 { CLOCK_REALTIME_COARSE, "CLOCK_REALTIME_COARSE" },
627#endif
628#ifdef CLOCK_MONOTONIC_COARSE
629 { CLOCK_MONOTONIC_COARSE, "CLOCK_MONOTONIC_COARSE" },
630#endif
631 { 0, NULL }
Roland McGrath54a4edd2004-08-31 06:52:45 +0000632};
633
Roland McGrath1e356792003-03-30 23:52:28 +0000634int
Denys Vlasenko12014262011-05-30 14:00:14 +0200635sys_clock_settime(struct tcb *tcp)
Roland McGrath1e356792003-03-30 23:52:28 +0000636{
637 if (entering(tcp)) {
Roland McGrath54a4edd2004-08-31 06:52:45 +0000638 printxval(clocknames, tcp->u_arg[0], "CLOCK_???");
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200639 tprints(", ");
Roland McGrath1e356792003-03-30 23:52:28 +0000640 printtv(tcp, tcp->u_arg[1]);
641 }
642 return 0;
643}
644
645int
Denys Vlasenko12014262011-05-30 14:00:14 +0200646sys_clock_gettime(struct tcb *tcp)
Roland McGrath1e356792003-03-30 23:52:28 +0000647{
648 if (entering(tcp)) {
Roland McGrath54a4edd2004-08-31 06:52:45 +0000649 printxval(clocknames, tcp->u_arg[0], "CLOCK_???");
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200650 tprints(", ");
Roland McGrath1e356792003-03-30 23:52:28 +0000651 } else {
652 if (syserror(tcp))
653 tprintf("%#lx", tcp->u_arg[1]);
654 else
655 printtv(tcp, tcp->u_arg[1]);
656 }
657 return 0;
658}
659
660int
Denys Vlasenko12014262011-05-30 14:00:14 +0200661sys_clock_nanosleep(struct tcb *tcp)
Roland McGrath1e356792003-03-30 23:52:28 +0000662{
663 if (entering(tcp)) {
Roland McGrath54a4edd2004-08-31 06:52:45 +0000664 printxval(clocknames, tcp->u_arg[0], "CLOCK_???");
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200665 tprints(", ");
Roland McGrathb2dee132005-06-01 19:02:36 +0000666 printflags(clockflags, tcp->u_arg[1], "TIMER_???");
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200667 tprints(", ");
Roland McGrath1e356792003-03-30 23:52:28 +0000668 printtv(tcp, tcp->u_arg[2]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200669 tprints(", ");
Roland McGrath1e356792003-03-30 23:52:28 +0000670 } else {
671 if (syserror(tcp))
672 tprintf("%#lx", tcp->u_arg[3]);
673 else
674 printtv(tcp, tcp->u_arg[3]);
675 }
676 return 0;
677}
678
679#ifndef SIGEV_THREAD_ID
680# define SIGEV_THREAD_ID 4
681#endif
Roland McGrathd9f816f2004-09-04 03:39:20 +0000682static const struct xlat sigev_value[] = {
Roland McGrath1e356792003-03-30 23:52:28 +0000683 { SIGEV_SIGNAL+1, "SIGEV_SIGNAL" },
684 { SIGEV_NONE+1, "SIGEV_NONE" },
685 { SIGEV_THREAD+1, "SIGEV_THREAD" },
686 { SIGEV_THREAD_ID+1, "SIGEV_THREAD_ID" },
687 { 0, NULL }
688};
689
Dmitry V. Levind3cb3922006-12-13 17:45:02 +0000690#if SUPPORTED_PERSONALITIES > 1
691static void
692printsigevent32(struct tcb *tcp, long arg)
693{
Denys Vlasenko1d632462009-04-14 12:51:00 +0000694 struct {
Dmitry V. Levind3cb3922006-12-13 17:45:02 +0000695 int sigev_value;
696 int sigev_signo;
697 int sigev_notify;
698
Denys Vlasenko1d632462009-04-14 12:51:00 +0000699 union {
Dmitry V. Levind3cb3922006-12-13 17:45:02 +0000700 int tid;
Denys Vlasenko1d632462009-04-14 12:51:00 +0000701 struct {
Dmitry V. Levind3cb3922006-12-13 17:45:02 +0000702 int function, attribute;
703 } thread;
704 } un;
705 } sev;
706
707 if (umove(tcp, arg, &sev) < 0)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200708 tprints("{...}");
Denys Vlasenko1d632462009-04-14 12:51:00 +0000709 else {
Dmitry V. Levind3cb3922006-12-13 17:45:02 +0000710 tprintf("{%#x, ", sev.sigev_value);
711 if (sev.sigev_notify == SIGEV_SIGNAL)
712 tprintf("%s, ", signame(sev.sigev_signo));
713 else
714 tprintf("%u, ", sev.sigev_signo);
715 printxval(sigev_value, sev.sigev_notify + 1, "SIGEV_???");
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200716 tprints(", ");
Dmitry V. Levind3cb3922006-12-13 17:45:02 +0000717 if (sev.sigev_notify == SIGEV_THREAD_ID)
718 tprintf("{%d}", sev.un.tid);
719 else if (sev.sigev_notify == SIGEV_THREAD)
720 tprintf("{%#x, %#x}",
721 sev.un.thread.function,
722 sev.un.thread.attribute);
723 else
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200724 tprints("{...}");
725 tprints("}");
Dmitry V. Levind3cb3922006-12-13 17:45:02 +0000726 }
727}
728#endif
729
Roland McGrath1e356792003-03-30 23:52:28 +0000730void
Dmitry V. Levind3cb3922006-12-13 17:45:02 +0000731printsigevent(struct tcb *tcp, long arg)
Roland McGrath1e356792003-03-30 23:52:28 +0000732{
733 struct sigevent sev;
Dmitry V. Levind3cb3922006-12-13 17:45:02 +0000734
735#if SUPPORTED_PERSONALITIES > 1
Denys Vlasenko7b609d52011-06-22 14:32:43 +0200736 if (personality_wordsize[current_personality] == 4) {
Dmitry V. Levind3cb3922006-12-13 17:45:02 +0000737 printsigevent32(tcp, arg);
738 return;
739 }
740#endif
Denys Vlasenkob63256e2011-06-07 12:13:24 +0200741 if (umove(tcp, arg, &sev) < 0)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200742 tprints("{...}");
Roland McGrath1e356792003-03-30 23:52:28 +0000743 else {
Roland McGrath675d4a62004-09-11 08:12:45 +0000744 tprintf("{%p, ", sev.sigev_value.sival_ptr);
745 if (sev.sigev_notify == SIGEV_SIGNAL)
746 tprintf("%s, ", signame(sev.sigev_signo));
747 else
748 tprintf("%u, ", sev.sigev_signo);
Roland McGrath1e356792003-03-30 23:52:28 +0000749 printxval(sigev_value, sev.sigev_notify+1, "SIGEV_???");
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200750 tprints(", ");
Roland McGrath1e356792003-03-30 23:52:28 +0000751 if (sev.sigev_notify == SIGEV_THREAD_ID)
752 /* _pad[0] is the _tid field which might not be
753 present in the userlevel definition of the
754 struct. */
755 tprintf("{%d}", sev._sigev_un._pad[0]);
Roland McGrathd4c85eb2004-04-16 21:48:44 +0000756 else if (sev.sigev_notify == SIGEV_THREAD)
757 tprintf("{%p, %p}", sev.sigev_notify_function,
758 sev.sigev_notify_attributes);
Roland McGrath1e356792003-03-30 23:52:28 +0000759 else
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200760 tprints("{...}");
761 tprints("}");
Roland McGrath1e356792003-03-30 23:52:28 +0000762 }
763}
764
765int
Denys Vlasenko12014262011-05-30 14:00:14 +0200766sys_timer_create(struct tcb *tcp)
Roland McGrath1e356792003-03-30 23:52:28 +0000767{
768 if (entering(tcp)) {
Roland McGrath675d4a62004-09-11 08:12:45 +0000769 printxval(clocknames, tcp->u_arg[0], "CLOCK_???");
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200770 tprints(", ");
Roland McGrath1e356792003-03-30 23:52:28 +0000771 printsigevent(tcp, tcp->u_arg[1]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200772 tprints(", ");
Roland McGrath1e356792003-03-30 23:52:28 +0000773 } else {
Andi Kleen732f3962011-06-13 21:37:40 +0000774 int timer_id;
Dmitry V. Levinac518d12006-12-13 17:03:02 +0000775
Andi Kleen732f3962011-06-13 21:37:40 +0000776 if (syserror(tcp) || umove(tcp, tcp->u_arg[2], &timer_id) < 0)
Roland McGrath1e356792003-03-30 23:52:28 +0000777 tprintf("%#lx", tcp->u_arg[2]);
Dmitry V. Levinac518d12006-12-13 17:03:02 +0000778 else
Andi Kleen732f3962011-06-13 21:37:40 +0000779 tprintf("{%d}", timer_id);
Roland McGrath1e356792003-03-30 23:52:28 +0000780 }
781 return 0;
782}
783
784int
Denys Vlasenko12014262011-05-30 14:00:14 +0200785sys_timer_settime(struct tcb *tcp)
Roland McGrath1e356792003-03-30 23:52:28 +0000786{
787 if (entering(tcp)) {
788 tprintf("%#lx, ", tcp->u_arg[0]);
Roland McGrathb2dee132005-06-01 19:02:36 +0000789 printflags(clockflags, tcp->u_arg[1], "TIMER_???");
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200790 tprints(", ");
Roland McGrath1e356792003-03-30 23:52:28 +0000791 printitv(tcp, tcp->u_arg[2]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200792 tprints(", ");
Roland McGrath1e356792003-03-30 23:52:28 +0000793 } else {
794 if (syserror(tcp))
795 tprintf("%#lx", tcp->u_arg[3]);
796 else
797 printitv(tcp, tcp->u_arg[3]);
798 }
799 return 0;
800}
801
802int
Denys Vlasenko12014262011-05-30 14:00:14 +0200803sys_timer_gettime(struct tcb *tcp)
Roland McGrath1e356792003-03-30 23:52:28 +0000804{
805 if (entering(tcp)) {
806 tprintf("%#lx, ", tcp->u_arg[0]);
807 } else {
808 if (syserror(tcp))
809 tprintf("%#lx", tcp->u_arg[1]);
810 else
811 printitv(tcp, tcp->u_arg[1]);
812 }
813 return 0;
814}
Roland McGrathd83c50b2004-10-06 22:27:43 +0000815
816static void
Denys Vlasenko12014262011-05-30 14:00:14 +0200817print_rtc(struct tcb *tcp, const struct rtc_time *rt)
Roland McGrathd83c50b2004-10-06 22:27:43 +0000818{
819 tprintf("{tm_sec=%d, tm_min=%d, tm_hour=%d, "
820 "tm_mday=%d, tm_mon=%d, tm_year=%d, ",
821 rt->tm_sec, rt->tm_min, rt->tm_hour,
822 rt->tm_mday, rt->tm_mon, rt->tm_year);
823 if (!abbrev(tcp))
824 tprintf("tm_wday=%d, tm_yday=%d, tm_isdst=%d}",
825 rt->tm_wday, rt->tm_yday, rt->tm_isdst);
826 else
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200827 tprints("...}");
Roland McGrathd83c50b2004-10-06 22:27:43 +0000828}
829
830int
Denys Vlasenko12014262011-05-30 14:00:14 +0200831rtc_ioctl(struct tcb *tcp, long code, long arg)
Roland McGrathd83c50b2004-10-06 22:27:43 +0000832{
833 switch (code) {
834 case RTC_ALM_SET:
835 case RTC_SET_TIME:
836 if (entering(tcp)) {
837 struct rtc_time rt;
838 if (umove(tcp, arg, &rt) < 0)
839 tprintf(", %#lx", arg);
840 else {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200841 tprints(", ");
Roland McGrathd83c50b2004-10-06 22:27:43 +0000842 print_rtc(tcp, &rt);
843 }
844 }
845 break;
846 case RTC_ALM_READ:
847 case RTC_RD_TIME:
848 if (exiting(tcp)) {
849 struct rtc_time rt;
850 if (syserror(tcp) || umove(tcp, arg, &rt) < 0)
851 tprintf(", %#lx", arg);
852 else {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200853 tprints(", ");
Roland McGrathd83c50b2004-10-06 22:27:43 +0000854 print_rtc(tcp, &rt);
855 }
856 }
857 break;
858 case RTC_IRQP_SET:
859 case RTC_EPOCH_SET:
860 if (entering(tcp))
861 tprintf(", %lu", arg);
862 break;
863 case RTC_IRQP_READ:
864 case RTC_EPOCH_READ:
865 if (exiting(tcp))
866 tprintf(", %lu", arg);
867 break;
868 case RTC_WKALM_SET:
869 if (entering(tcp)) {
870 struct rtc_wkalrm wk;
871 if (umove(tcp, arg, &wk) < 0)
872 tprintf(", %#lx", arg);
873 else {
874 tprintf(", {enabled=%d, pending=%d, ",
875 wk.enabled, wk.pending);
876 print_rtc(tcp, &wk.time);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200877 tprints("}");
Roland McGrathd83c50b2004-10-06 22:27:43 +0000878 }
879 }
880 break;
881 case RTC_WKALM_RD:
882 if (exiting(tcp)) {
883 struct rtc_wkalrm wk;
884 if (syserror(tcp) || umove(tcp, arg, &wk) < 0)
885 tprintf(", %#lx", arg);
886 else {
887 tprintf(", {enabled=%d, pending=%d, ",
888 wk.enabled, wk.pending);
889 print_rtc(tcp, &wk.time);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200890 tprints("}");
Roland McGrathd83c50b2004-10-06 22:27:43 +0000891 }
892 }
893 break;
894 default:
895 if (entering(tcp))
896 tprintf(", %#lx", arg);
897 break;
898 }
899 return 1;
900}
Roland McGrathe4662342007-08-02 01:25:34 +0000901
902#ifndef TFD_TIMER_ABSTIME
903#define TFD_TIMER_ABSTIME (1 << 0)
904#endif
905
906static const struct xlat timerfdflags[] = {
907 { TFD_TIMER_ABSTIME, "TFD_TIMER_ABSTIME" },
908 { 0, NULL }
909};
910
911int
Denys Vlasenko12014262011-05-30 14:00:14 +0200912sys_timerfd(struct tcb *tcp)
Roland McGrathe4662342007-08-02 01:25:34 +0000913{
914 if (entering(tcp)) {
915 /* It does not matter that the kernel uses itimerspec. */
916 tprintf("%ld, ", tcp->u_arg[0]);
917 printxval(clocknames, tcp->u_arg[1], "CLOCK_???");
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200918 tprints(", ");
Roland McGrathe4662342007-08-02 01:25:34 +0000919 printflags(timerfdflags, tcp->u_arg[2], "TFD_???");
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200920 tprints(", ");
Roland McGrathe4662342007-08-02 01:25:34 +0000921 printitv(tcp, tcp->u_arg[3]);
922 }
923 return 0;
924}
Roland McGrathde328e62008-05-20 04:56:13 +0000925
926int
927sys_timerfd_create(struct tcb *tcp)
928{
929 if (entering(tcp)) {
930 printxval(clocknames, tcp->u_arg[0], "CLOCK_???");
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200931 tprints(", ");
Roland McGrathde328e62008-05-20 04:56:13 +0000932 printflags(timerfdflags, tcp->u_arg[1], "TFD_???");
933 }
934 return 0;
935}
936
937int
938sys_timerfd_settime(struct tcb *tcp)
939{
940 if (entering(tcp)) {
Dmitry V. Levin31382132011-03-04 05:08:02 +0300941 printfd(tcp, tcp->u_arg[0]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200942 tprints(", ");
Roland McGrathde328e62008-05-20 04:56:13 +0000943 printflags(timerfdflags, tcp->u_arg[1], "TFD_???");
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200944 tprints(", ");
Roland McGrathde328e62008-05-20 04:56:13 +0000945 printitv(tcp, tcp->u_arg[2]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200946 tprints(", ");
Roland McGrathde328e62008-05-20 04:56:13 +0000947 printitv(tcp, tcp->u_arg[3]);
948 }
949 return 0;
950}
951
952int
953sys_timerfd_gettime(struct tcb *tcp)
954{
955 if (entering(tcp)) {
Dmitry V. Levin31382132011-03-04 05:08:02 +0300956 printfd(tcp, tcp->u_arg[0]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200957 tprints(", ");
Roland McGrathde328e62008-05-20 04:56:13 +0000958 printitv(tcp, tcp->u_arg[1]);
959 }
960 return 0;
961}