blob: 4cc9c5910ebfe7fd2517dd7f620e969d92fd27ef [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
199#ifdef ALPHA
200int
Denys Vlasenko12014262011-05-30 14:00:14 +0200201sys_osf_gettimeofday(struct tcb *tcp)
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +0000202{
Denys Vlasenko1d632462009-04-14 12:51:00 +0000203 if (exiting(tcp)) {
204 if (syserror(tcp)) {
205 tprintf("%#lx, %#lx", tcp->u_arg[0], tcp->u_arg[1]);
206 return 0;
207 }
208 printtv_bitness(tcp, tcp->u_arg[0], BITNESS_32, 0);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200209 tprints(", ");
Denys Vlasenko1d632462009-04-14 12:51:00 +0000210 printtv_bitness(tcp, tcp->u_arg[1], BITNESS_32, 0);
Denys Vlasenko1d632462009-04-14 12:51:00 +0000211 }
212 return 0;
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +0000213}
214#endif
215
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000216int
Denys Vlasenko12014262011-05-30 14:00:14 +0200217sys_settimeofday(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000218{
219 if (entering(tcp)) {
220 printtv(tcp, tcp->u_arg[0]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200221 tprints(", ");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000222 printtv(tcp, tcp->u_arg[1]);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000223 }
224 return 0;
225}
226
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +0000227#ifdef ALPHA
228int
Denys Vlasenko12014262011-05-30 14:00:14 +0200229sys_osf_settimeofday(struct tcb *tcp)
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +0000230{
Denys Vlasenko1d632462009-04-14 12:51:00 +0000231 if (entering(tcp)) {
232 printtv_bitness(tcp, tcp->u_arg[0], BITNESS_32, 0);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200233 tprints(", ");
Denys Vlasenko1d632462009-04-14 12:51:00 +0000234 printtv_bitness(tcp, tcp->u_arg[1], BITNESS_32, 0);
Denys Vlasenko1d632462009-04-14 12:51:00 +0000235 }
236 return 0;
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +0000237}
238#endif
239
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000240int
Denys Vlasenko12014262011-05-30 14:00:14 +0200241sys_adjtime(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000242{
243 if (entering(tcp)) {
244 printtv(tcp, tcp->u_arg[0]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200245 tprints(", ");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000246 } else {
247 if (syserror(tcp))
248 tprintf("%#lx", tcp->u_arg[1]);
249 else
250 printtv(tcp, tcp->u_arg[1]);
251 }
252 return 0;
253}
254
Dmitry V. Levin2e55ff42008-09-03 01:02:46 +0000255int
256sys_nanosleep(struct tcb *tcp)
257{
258 if (entering(tcp)) {
259 print_timespec(tcp, tcp->u_arg[0]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200260 tprints(", ");
Dmitry V. Levin2e55ff42008-09-03 01:02:46 +0000261 } else {
Denys Vlasenko64acaa12012-01-28 02:29:36 +0100262 /* Second (returned) timespec is only significant
263 * if syscall was interrupted. We print only its address
264 * on _success_, since kernel doesn't modify its value.
265 */
266 if (is_restart_error(tcp) || !tcp->u_arg[1])
267 /* Interrupted (or NULL) */
Dmitry V. Levin2e55ff42008-09-03 01:02:46 +0000268 print_timespec(tcp, tcp->u_arg[1]);
269 else
Denys Vlasenko64acaa12012-01-28 02:29:36 +0100270 /* Success */
Dmitry V. Levin2e55ff42008-09-03 01:02:46 +0000271 tprintf("%#lx", tcp->u_arg[1]);
272 }
273 return 0;
274}
275
Roland McGrathd9f816f2004-09-04 03:39:20 +0000276static const struct xlat which[] = {
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000277 { ITIMER_REAL, "ITIMER_REAL" },
278 { ITIMER_VIRTUAL,"ITIMER_VIRTUAL"},
279 { ITIMER_PROF, "ITIMER_PROF" },
280 { 0, NULL },
281};
282
283static void
Dmitry V. Levin1cad25d2006-12-13 17:14:36 +0000284printitv_bitness(struct tcb *tcp, long addr, enum bitness_t bitness)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000285{
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000286 if (addr == 0)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200287 tprints("NULL");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000288 else if (!verbose(tcp))
289 tprintf("%#lx", addr);
Denys Vlasenko1d632462009-04-14 12:51:00 +0000290 else {
291 int rc;
Dmitry V. Levin1cad25d2006-12-13 17:14:36 +0000292
293 if (bitness == BITNESS_32
Denys Vlasenko84703742012-02-25 02:38:52 +0100294#if SUPPORTED_PERSONALITIES > 1
Dmitry V. Levin1cad25d2006-12-13 17:14:36 +0000295 || personality_wordsize[current_personality] == 4
296#endif
297 )
298 {
Denys Vlasenko1d632462009-04-14 12:51:00 +0000299 struct {
Dmitry V. Levin1cad25d2006-12-13 17:14:36 +0000300 struct timeval32 it_interval, it_value;
301 } itv;
302
Denys Vlasenko5d645812011-08-20 12:48:18 +0200303 rc = umove(tcp, addr, &itv);
304 if (rc >= 0) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200305 tprints("{it_interval=");
Dmitry V. Levin1cad25d2006-12-13 17:14:36 +0000306 tprint_timeval32(tcp, &itv.it_interval);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200307 tprints(", it_value=");
Dmitry V. Levin1cad25d2006-12-13 17:14:36 +0000308 tprint_timeval32(tcp, &itv.it_value);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200309 tprints("}");
Roland McGrathe4662342007-08-02 01:25:34 +0000310 }
Denys Vlasenko1d632462009-04-14 12:51:00 +0000311 } else {
Dmitry V. Levin1cad25d2006-12-13 17:14:36 +0000312 struct itimerval itv;
313
Denys Vlasenko5d645812011-08-20 12:48:18 +0200314 rc = umove(tcp, addr, &itv);
315 if (rc >= 0) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200316 tprints("{it_interval=");
Dmitry V. Levin1cad25d2006-12-13 17:14:36 +0000317 tprint_timeval(tcp, &itv.it_interval);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200318 tprints(", it_value=");
Dmitry V. Levin1cad25d2006-12-13 17:14:36 +0000319 tprint_timeval(tcp, &itv.it_value);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200320 tprints("}");
Roland McGrathe4662342007-08-02 01:25:34 +0000321 }
Dmitry V. Levin1cad25d2006-12-13 17:14:36 +0000322 }
Dmitry V. Levin1cad25d2006-12-13 17:14:36 +0000323 if (rc < 0)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200324 tprints("{...}");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000325 }
326}
327
Dmitry V. Levin1cad25d2006-12-13 17:14:36 +0000328#define printitv(tcp, addr) \
329 printitv_bitness((tcp), (addr), BITNESS_CURRENT)
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +0000330
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000331int
Denys Vlasenko12014262011-05-30 14:00:14 +0200332sys_getitimer(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000333{
334 if (entering(tcp)) {
335 printxval(which, tcp->u_arg[0], "ITIMER_???");
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200336 tprints(", ");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000337 } else {
338 if (syserror(tcp))
339 tprintf("%#lx", tcp->u_arg[1]);
340 else
341 printitv(tcp, tcp->u_arg[1]);
342 }
343 return 0;
344}
345
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +0000346
347#ifdef ALPHA
348int
Denys Vlasenko12014262011-05-30 14:00:14 +0200349sys_osf_getitimer(struct tcb *tcp)
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +0000350{
Denys Vlasenko1d632462009-04-14 12:51:00 +0000351 if (entering(tcp)) {
352 printxval(which, tcp->u_arg[0], "ITIMER_???");
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200353 tprints(", ");
Denys Vlasenko1d632462009-04-14 12:51:00 +0000354 } else {
355 if (syserror(tcp))
356 tprintf("%#lx", tcp->u_arg[1]);
357 else
358 printitv_bitness(tcp, tcp->u_arg[1], BITNESS_32);
359 }
360 return 0;
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +0000361}
362#endif
363
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000364int
Denys Vlasenko12014262011-05-30 14:00:14 +0200365sys_setitimer(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000366{
367 if (entering(tcp)) {
368 printxval(which, tcp->u_arg[0], "ITIMER_???");
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200369 tprints(", ");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000370 printitv(tcp, tcp->u_arg[1]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200371 tprints(", ");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000372 } else {
373 if (syserror(tcp))
374 tprintf("%#lx", tcp->u_arg[2]);
375 else
376 printitv(tcp, tcp->u_arg[2]);
377 }
378 return 0;
379}
380
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +0000381#ifdef ALPHA
382int
Denys Vlasenko12014262011-05-30 14:00:14 +0200383sys_osf_setitimer(struct tcb *tcp)
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +0000384{
Denys Vlasenko1d632462009-04-14 12:51:00 +0000385 if (entering(tcp)) {
386 printxval(which, tcp->u_arg[0], "ITIMER_???");
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200387 tprints(", ");
Denys Vlasenko1d632462009-04-14 12:51:00 +0000388 printitv_bitness(tcp, tcp->u_arg[1], BITNESS_32);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200389 tprints(", ");
Denys Vlasenko1d632462009-04-14 12:51:00 +0000390 } else {
391 if (syserror(tcp))
392 tprintf("%#lx", tcp->u_arg[2]);
393 else
394 printitv_bitness(tcp, tcp->u_arg[2], BITNESS_32);
395 }
396 return 0;
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +0000397}
398#endif
399
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000400
Dmitry V. Levin1a684d62006-12-13 17:42:32 +0000401static const struct xlat adjtimex_modes[] = {
402 { 0, "0" },
403#ifdef ADJ_OFFSET
404 { ADJ_OFFSET, "ADJ_OFFSET" },
405#endif
406#ifdef ADJ_FREQUENCY
407 { ADJ_FREQUENCY, "ADJ_FREQUENCY" },
408#endif
409#ifdef ADJ_MAXERROR
410 { ADJ_MAXERROR, "ADJ_MAXERROR" },
411#endif
412#ifdef ADJ_ESTERROR
413 { ADJ_ESTERROR, "ADJ_ESTERROR" },
414#endif
415#ifdef ADJ_STATUS
416 { ADJ_STATUS, "ADJ_STATUS" },
417#endif
418#ifdef ADJ_TIMECONST
419 { ADJ_TIMECONST, "ADJ_TIMECONST" },
420#endif
421#ifdef ADJ_TICK
422 { ADJ_TICK, "ADJ_TICK" },
423#endif
424#ifdef ADJ_OFFSET_SINGLESHOT
425 { ADJ_OFFSET_SINGLESHOT, "ADJ_OFFSET_SINGLESHOT" },
426#endif
427 { 0, NULL }
428};
429
430static const struct xlat adjtimex_status[] = {
431#ifdef STA_PLL
432 { STA_PLL, "STA_PLL" },
433#endif
434#ifdef STA_PPSFREQ
435 { STA_PPSFREQ, "STA_PPSFREQ" },
436#endif
437#ifdef STA_PPSTIME
438 { STA_PPSTIME, "STA_PPSTIME" },
439#endif
440#ifdef STA_FLL
441 { STA_FLL, "STA_FLL" },
442#endif
443#ifdef STA_INS
444 { STA_INS, "STA_INS" },
445#endif
446#ifdef STA_DEL
447 { STA_DEL, "STA_DEL" },
448#endif
449#ifdef STA_UNSYNC
450 { STA_UNSYNC, "STA_UNSYNC" },
451#endif
452#ifdef STA_FREQHOLD
453 { STA_FREQHOLD, "STA_FREQHOLD" },
454#endif
455#ifdef STA_PPSSIGNAL
456 { STA_PPSSIGNAL, "STA_PPSSIGNAL" },
457#endif
458#ifdef STA_PPSJITTER
459 { STA_PPSJITTER, "STA_PPSJITTER" },
460#endif
461#ifdef STA_PPSWANDER
462 { STA_PPSWANDER, "STA_PPSWANDER" },
463#endif
464#ifdef STA_PPSERROR
465 { STA_PPSERROR, "STA_PPSERROR" },
466#endif
467#ifdef STA_CLOCKERR
468 { STA_CLOCKERR, "STA_CLOCKERR" },
469#endif
470 { 0, NULL }
471};
472
473static const struct xlat adjtimex_state[] = {
474#ifdef TIME_OK
475 { TIME_OK, "TIME_OK" },
476#endif
477#ifdef TIME_INS
478 { TIME_INS, "TIME_INS" },
479#endif
480#ifdef TIME_DEL
481 { TIME_DEL, "TIME_DEL" },
482#endif
483#ifdef TIME_OOP
484 { TIME_OOP, "TIME_OOP" },
485#endif
486#ifdef TIME_WAIT
487 { TIME_WAIT, "TIME_WAIT" },
488#endif
489#ifdef TIME_ERROR
490 { TIME_ERROR, "TIME_ERROR" },
491#endif
492 { 0, NULL }
493};
494
Dmitry V. Levin165b15d2006-12-13 17:43:45 +0000495#if SUPPORTED_PERSONALITIES > 1
496static int
497tprint_timex32(struct tcb *tcp, long addr)
498{
Denys Vlasenko1d632462009-04-14 12:51:00 +0000499 struct {
Dmitry V. Levin165b15d2006-12-13 17:43:45 +0000500 unsigned int modes;
501 int offset;
502 int freq;
503 int maxerror;
504 int esterror;
505 int status;
506 int constant;
507 int precision;
508 int tolerance;
509 struct timeval32 time;
510 int tick;
511 int ppsfreq;
512 int jitter;
513 int shift;
514 int stabil;
515 int jitcnt;
516 int calcnt;
517 int errcnt;
518 int stbcnt;
519 } tx;
520
521 if (umove(tcp, addr, &tx) < 0)
522 return -1;
523
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200524 tprints("{modes=");
Dmitry V. Levin71d70892007-01-13 11:17:38 +0000525 printflags(adjtimex_modes, tx.modes, "ADJ_???");
Dmitry V. Levin165b15d2006-12-13 17:43:45 +0000526 tprintf(", offset=%d, freq=%d, maxerror=%d, ",
527 tx.offset, tx.freq, tx.maxerror);
528 tprintf("esterror=%u, status=", tx.esterror);
529 printflags(adjtimex_status, tx.status, "STA_???");
530 tprintf(", constant=%d, precision=%u, ",
531 tx.constant, tx.precision);
532 tprintf("tolerance=%d, time=", tx.tolerance);
533 tprint_timeval32(tcp, &tx.time);
534 tprintf(", tick=%d, ppsfreq=%d, jitter=%d",
535 tx.tick, tx.ppsfreq, tx.jitter);
536 tprintf(", shift=%d, stabil=%d, jitcnt=%d",
537 tx.shift, tx.stabil, tx.jitcnt);
538 tprintf(", calcnt=%d, errcnt=%d, stbcnt=%d",
539 tx.calcnt, tx.errcnt, tx.stbcnt);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200540 tprints("}");
Dmitry V. Levin165b15d2006-12-13 17:43:45 +0000541 return 0;
542}
543#endif /* SUPPORTED_PERSONALITIES > 1 */
544
545static int
546tprint_timex(struct tcb *tcp, long addr)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000547{
Dmitry V. Levin1a684d62006-12-13 17:42:32 +0000548 struct timex tx;
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000549
Dmitry V. Levin165b15d2006-12-13 17:43:45 +0000550#if SUPPORTED_PERSONALITIES > 1
551 if (personality_wordsize[current_personality] == 4)
552 return tprint_timex32(tcp, addr);
553#endif
554 if (umove(tcp, addr, &tx) < 0)
555 return -1;
556
557#if LINUX_VERSION_CODE < 66332
558 tprintf("{mode=%d, offset=%ld, frequency=%ld, ",
559 tx.mode, tx.offset, tx.frequency);
560 tprintf("maxerror=%ld, esterror=%lu, status=%u, ",
561 tx.maxerror, tx.esterror, tx.status);
562 tprintf("time_constant=%ld, precision=%lu, ",
563 tx.time_constant, tx.precision);
564 tprintf("tolerance=%ld, time=", tx.tolerance);
565 tprint_timeval(tcp, &tx.time);
566#else
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200567 tprints("{modes=");
Dmitry V. Levin71d70892007-01-13 11:17:38 +0000568 printflags(adjtimex_modes, tx.modes, "ADJ_???");
Dmitry V. Levin165b15d2006-12-13 17:43:45 +0000569 tprintf(", offset=%ld, freq=%ld, maxerror=%ld, ",
H.J. Lu0b315b62012-02-03 10:16:03 -0800570 (long) tx.offset, (long) tx.freq, (long) tx.maxerror);
571 tprintf("esterror=%lu, status=", (long) tx.esterror);
Dmitry V. Levin165b15d2006-12-13 17:43:45 +0000572 printflags(adjtimex_status, tx.status, "STA_???");
573 tprintf(", constant=%ld, precision=%lu, ",
H.J. Lu0b315b62012-02-03 10:16:03 -0800574 (long) tx.constant, (long) tx.precision);
575 tprintf("tolerance=%ld, time=", (long) tx.tolerance);
Dmitry V. Levin165b15d2006-12-13 17:43:45 +0000576 tprint_timeval(tcp, &tx.time);
577 tprintf(", tick=%ld, ppsfreq=%ld, jitter=%ld",
H.J. Lu0b315b62012-02-03 10:16:03 -0800578 (long) tx.tick, (long) tx.ppsfreq, (long) tx.jitter);
Dmitry V. Levin165b15d2006-12-13 17:43:45 +0000579 tprintf(", shift=%d, stabil=%ld, jitcnt=%ld",
H.J. Lu0b315b62012-02-03 10:16:03 -0800580 tx.shift, (long) tx.stabil, (long) tx.jitcnt);
Dmitry V. Levin165b15d2006-12-13 17:43:45 +0000581 tprintf(", calcnt=%ld, errcnt=%ld, stbcnt=%ld",
H.J. Lu0b315b62012-02-03 10:16:03 -0800582 (long) tx.calcnt, (long) tx.errcnt, (long) tx.stbcnt);
Dmitry V. Levin165b15d2006-12-13 17:43:45 +0000583#endif
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200584 tprints("}");
Dmitry V. Levin165b15d2006-12-13 17:43:45 +0000585 return 0;
586}
587
588int
589sys_adjtimex(struct tcb *tcp)
590{
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000591 if (exiting(tcp)) {
592 if (tcp->u_arg[0] == 0)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200593 tprints("NULL");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000594 else if (syserror(tcp) || !verbose(tcp))
595 tprintf("%#lx", tcp->u_arg[0]);
Dmitry V. Levin165b15d2006-12-13 17:43:45 +0000596 else if (tprint_timex(tcp, tcp->u_arg[0]) < 0)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200597 tprints("{...}");
Dmitry V. Levin21a75342008-09-03 01:22:18 +0000598 if (syserror(tcp))
599 return 0;
Dmitry V. Levin1a684d62006-12-13 17:42:32 +0000600 tcp->auxstr = xlookup(adjtimex_state, tcp->u_rval);
601 if (tcp->auxstr)
602 return RVAL_STR;
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000603 }
604 return 0;
605}
Roland McGrath1e356792003-03-30 23:52:28 +0000606
Roland McGrathd9f816f2004-09-04 03:39:20 +0000607static const struct xlat clockflags[] = {
Roland McGrath1e356792003-03-30 23:52:28 +0000608 { TIMER_ABSTIME, "TIMER_ABSTIME" },
609 { 0, NULL }
610};
611
Roland McGrathd9f816f2004-09-04 03:39:20 +0000612static const struct xlat clocknames[] = {
Roland McGrath55a00f82004-08-31 08:26:39 +0000613#ifdef CLOCK_REALTIME
Roland McGrath54a4edd2004-08-31 06:52:45 +0000614 { CLOCK_REALTIME, "CLOCK_REALTIME" },
Roland McGrath55a00f82004-08-31 08:26:39 +0000615#endif
616#ifdef CLOCK_MONOTONIC
Roland McGrath54a4edd2004-08-31 06:52:45 +0000617 { CLOCK_MONOTONIC, "CLOCK_MONOTONIC" },
Roland McGrath55a00f82004-08-31 08:26:39 +0000618#endif
Dmitry V. Levincbaaf792010-09-17 09:19:49 +0000619#ifdef CLOCK_PROCESS_CPUTIME_ID
620 { CLOCK_PROCESS_CPUTIME_ID, "CLOCK_PROCESS_CPUTIME_ID" },
621#endif
622#ifdef CLOCK_THREAD_CPUTIME_ID
623 { CLOCK_THREAD_CPUTIME_ID, "CLOCK_THREAD_CPUTIME_ID" },
624#endif
625#ifdef CLOCK_MONOTONIC_RAW
626 { CLOCK_MONOTONIC_RAW, "CLOCK_MONOTONIC_RAW" },
627#endif
628#ifdef CLOCK_REALTIME_COARSE
629 { CLOCK_REALTIME_COARSE, "CLOCK_REALTIME_COARSE" },
630#endif
631#ifdef CLOCK_MONOTONIC_COARSE
632 { CLOCK_MONOTONIC_COARSE, "CLOCK_MONOTONIC_COARSE" },
633#endif
634 { 0, NULL }
Roland McGrath54a4edd2004-08-31 06:52:45 +0000635};
636
Roland McGrath1e356792003-03-30 23:52:28 +0000637int
Denys Vlasenko12014262011-05-30 14:00:14 +0200638sys_clock_settime(struct tcb *tcp)
Roland McGrath1e356792003-03-30 23:52:28 +0000639{
640 if (entering(tcp)) {
Roland McGrath54a4edd2004-08-31 06:52:45 +0000641 printxval(clocknames, tcp->u_arg[0], "CLOCK_???");
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200642 tprints(", ");
Roland McGrath1e356792003-03-30 23:52:28 +0000643 printtv(tcp, tcp->u_arg[1]);
644 }
645 return 0;
646}
647
648int
Denys Vlasenko12014262011-05-30 14:00:14 +0200649sys_clock_gettime(struct tcb *tcp)
Roland McGrath1e356792003-03-30 23:52:28 +0000650{
651 if (entering(tcp)) {
Roland McGrath54a4edd2004-08-31 06:52:45 +0000652 printxval(clocknames, tcp->u_arg[0], "CLOCK_???");
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200653 tprints(", ");
Roland McGrath1e356792003-03-30 23:52:28 +0000654 } else {
655 if (syserror(tcp))
656 tprintf("%#lx", tcp->u_arg[1]);
657 else
658 printtv(tcp, tcp->u_arg[1]);
659 }
660 return 0;
661}
662
663int
Denys Vlasenko12014262011-05-30 14:00:14 +0200664sys_clock_nanosleep(struct tcb *tcp)
Roland McGrath1e356792003-03-30 23:52:28 +0000665{
666 if (entering(tcp)) {
Roland McGrath54a4edd2004-08-31 06:52:45 +0000667 printxval(clocknames, tcp->u_arg[0], "CLOCK_???");
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200668 tprints(", ");
Roland McGrathb2dee132005-06-01 19:02:36 +0000669 printflags(clockflags, tcp->u_arg[1], "TIMER_???");
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200670 tprints(", ");
Roland McGrath1e356792003-03-30 23:52:28 +0000671 printtv(tcp, tcp->u_arg[2]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200672 tprints(", ");
Roland McGrath1e356792003-03-30 23:52:28 +0000673 } else {
674 if (syserror(tcp))
675 tprintf("%#lx", tcp->u_arg[3]);
676 else
677 printtv(tcp, tcp->u_arg[3]);
678 }
679 return 0;
680}
681
682#ifndef SIGEV_THREAD_ID
683# define SIGEV_THREAD_ID 4
684#endif
Roland McGrathd9f816f2004-09-04 03:39:20 +0000685static const struct xlat sigev_value[] = {
Roland McGrath1e356792003-03-30 23:52:28 +0000686 { SIGEV_SIGNAL+1, "SIGEV_SIGNAL" },
687 { SIGEV_NONE+1, "SIGEV_NONE" },
688 { SIGEV_THREAD+1, "SIGEV_THREAD" },
689 { SIGEV_THREAD_ID+1, "SIGEV_THREAD_ID" },
690 { 0, NULL }
691};
692
Dmitry V. Levind3cb3922006-12-13 17:45:02 +0000693#if SUPPORTED_PERSONALITIES > 1
694static void
695printsigevent32(struct tcb *tcp, long arg)
696{
Denys Vlasenko1d632462009-04-14 12:51:00 +0000697 struct {
Dmitry V. Levind3cb3922006-12-13 17:45:02 +0000698 int sigev_value;
699 int sigev_signo;
700 int sigev_notify;
701
Denys Vlasenko1d632462009-04-14 12:51:00 +0000702 union {
Dmitry V. Levind3cb3922006-12-13 17:45:02 +0000703 int tid;
Denys Vlasenko1d632462009-04-14 12:51:00 +0000704 struct {
Dmitry V. Levind3cb3922006-12-13 17:45:02 +0000705 int function, attribute;
706 } thread;
707 } un;
708 } sev;
709
710 if (umove(tcp, arg, &sev) < 0)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200711 tprints("{...}");
Denys Vlasenko1d632462009-04-14 12:51:00 +0000712 else {
Dmitry V. Levind3cb3922006-12-13 17:45:02 +0000713 tprintf("{%#x, ", sev.sigev_value);
714 if (sev.sigev_notify == SIGEV_SIGNAL)
715 tprintf("%s, ", signame(sev.sigev_signo));
716 else
717 tprintf("%u, ", sev.sigev_signo);
718 printxval(sigev_value, sev.sigev_notify + 1, "SIGEV_???");
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200719 tprints(", ");
Dmitry V. Levind3cb3922006-12-13 17:45:02 +0000720 if (sev.sigev_notify == SIGEV_THREAD_ID)
721 tprintf("{%d}", sev.un.tid);
722 else if (sev.sigev_notify == SIGEV_THREAD)
723 tprintf("{%#x, %#x}",
724 sev.un.thread.function,
725 sev.un.thread.attribute);
726 else
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200727 tprints("{...}");
728 tprints("}");
Dmitry V. Levind3cb3922006-12-13 17:45:02 +0000729 }
730}
731#endif
732
Roland McGrath1e356792003-03-30 23:52:28 +0000733void
Dmitry V. Levind3cb3922006-12-13 17:45:02 +0000734printsigevent(struct tcb *tcp, long arg)
Roland McGrath1e356792003-03-30 23:52:28 +0000735{
736 struct sigevent sev;
Dmitry V. Levind3cb3922006-12-13 17:45:02 +0000737
738#if SUPPORTED_PERSONALITIES > 1
Denys Vlasenko7b609d52011-06-22 14:32:43 +0200739 if (personality_wordsize[current_personality] == 4) {
Dmitry V. Levind3cb3922006-12-13 17:45:02 +0000740 printsigevent32(tcp, arg);
741 return;
742 }
743#endif
Denys Vlasenkob63256e2011-06-07 12:13:24 +0200744 if (umove(tcp, arg, &sev) < 0)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200745 tprints("{...}");
Roland McGrath1e356792003-03-30 23:52:28 +0000746 else {
Roland McGrath675d4a62004-09-11 08:12:45 +0000747 tprintf("{%p, ", sev.sigev_value.sival_ptr);
748 if (sev.sigev_notify == SIGEV_SIGNAL)
749 tprintf("%s, ", signame(sev.sigev_signo));
750 else
751 tprintf("%u, ", sev.sigev_signo);
Roland McGrath1e356792003-03-30 23:52:28 +0000752 printxval(sigev_value, sev.sigev_notify+1, "SIGEV_???");
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200753 tprints(", ");
Roland McGrath1e356792003-03-30 23:52:28 +0000754 if (sev.sigev_notify == SIGEV_THREAD_ID)
755 /* _pad[0] is the _tid field which might not be
756 present in the userlevel definition of the
757 struct. */
758 tprintf("{%d}", sev._sigev_un._pad[0]);
Roland McGrathd4c85eb2004-04-16 21:48:44 +0000759 else if (sev.sigev_notify == SIGEV_THREAD)
760 tprintf("{%p, %p}", sev.sigev_notify_function,
761 sev.sigev_notify_attributes);
Roland McGrath1e356792003-03-30 23:52:28 +0000762 else
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200763 tprints("{...}");
764 tprints("}");
Roland McGrath1e356792003-03-30 23:52:28 +0000765 }
766}
767
768int
Denys Vlasenko12014262011-05-30 14:00:14 +0200769sys_timer_create(struct tcb *tcp)
Roland McGrath1e356792003-03-30 23:52:28 +0000770{
771 if (entering(tcp)) {
Roland McGrath675d4a62004-09-11 08:12:45 +0000772 printxval(clocknames, tcp->u_arg[0], "CLOCK_???");
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200773 tprints(", ");
Roland McGrath1e356792003-03-30 23:52:28 +0000774 printsigevent(tcp, tcp->u_arg[1]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200775 tprints(", ");
Roland McGrath1e356792003-03-30 23:52:28 +0000776 } else {
Andi Kleen732f3962011-06-13 21:37:40 +0000777 int timer_id;
Dmitry V. Levinac518d12006-12-13 17:03:02 +0000778
Andi Kleen732f3962011-06-13 21:37:40 +0000779 if (syserror(tcp) || umove(tcp, tcp->u_arg[2], &timer_id) < 0)
Roland McGrath1e356792003-03-30 23:52:28 +0000780 tprintf("%#lx", tcp->u_arg[2]);
Dmitry V. Levinac518d12006-12-13 17:03:02 +0000781 else
Andi Kleen732f3962011-06-13 21:37:40 +0000782 tprintf("{%d}", timer_id);
Roland McGrath1e356792003-03-30 23:52:28 +0000783 }
784 return 0;
785}
786
787int
Denys Vlasenko12014262011-05-30 14:00:14 +0200788sys_timer_settime(struct tcb *tcp)
Roland McGrath1e356792003-03-30 23:52:28 +0000789{
790 if (entering(tcp)) {
791 tprintf("%#lx, ", tcp->u_arg[0]);
Roland McGrathb2dee132005-06-01 19:02:36 +0000792 printflags(clockflags, tcp->u_arg[1], "TIMER_???");
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200793 tprints(", ");
Roland McGrath1e356792003-03-30 23:52:28 +0000794 printitv(tcp, tcp->u_arg[2]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200795 tprints(", ");
Roland McGrath1e356792003-03-30 23:52:28 +0000796 } else {
797 if (syserror(tcp))
798 tprintf("%#lx", tcp->u_arg[3]);
799 else
800 printitv(tcp, tcp->u_arg[3]);
801 }
802 return 0;
803}
804
805int
Denys Vlasenko12014262011-05-30 14:00:14 +0200806sys_timer_gettime(struct tcb *tcp)
Roland McGrath1e356792003-03-30 23:52:28 +0000807{
808 if (entering(tcp)) {
809 tprintf("%#lx, ", tcp->u_arg[0]);
810 } else {
811 if (syserror(tcp))
812 tprintf("%#lx", tcp->u_arg[1]);
813 else
814 printitv(tcp, tcp->u_arg[1]);
815 }
816 return 0;
817}
Roland McGrathd83c50b2004-10-06 22:27:43 +0000818
819static void
Denys Vlasenko12014262011-05-30 14:00:14 +0200820print_rtc(struct tcb *tcp, const struct rtc_time *rt)
Roland McGrathd83c50b2004-10-06 22:27:43 +0000821{
822 tprintf("{tm_sec=%d, tm_min=%d, tm_hour=%d, "
823 "tm_mday=%d, tm_mon=%d, tm_year=%d, ",
824 rt->tm_sec, rt->tm_min, rt->tm_hour,
825 rt->tm_mday, rt->tm_mon, rt->tm_year);
826 if (!abbrev(tcp))
827 tprintf("tm_wday=%d, tm_yday=%d, tm_isdst=%d}",
828 rt->tm_wday, rt->tm_yday, rt->tm_isdst);
829 else
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200830 tprints("...}");
Roland McGrathd83c50b2004-10-06 22:27:43 +0000831}
832
833int
Denys Vlasenko12014262011-05-30 14:00:14 +0200834rtc_ioctl(struct tcb *tcp, long code, long arg)
Roland McGrathd83c50b2004-10-06 22:27:43 +0000835{
836 switch (code) {
837 case RTC_ALM_SET:
838 case RTC_SET_TIME:
839 if (entering(tcp)) {
840 struct rtc_time rt;
841 if (umove(tcp, arg, &rt) < 0)
842 tprintf(", %#lx", arg);
843 else {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200844 tprints(", ");
Roland McGrathd83c50b2004-10-06 22:27:43 +0000845 print_rtc(tcp, &rt);
846 }
847 }
848 break;
849 case RTC_ALM_READ:
850 case RTC_RD_TIME:
851 if (exiting(tcp)) {
852 struct rtc_time rt;
853 if (syserror(tcp) || umove(tcp, arg, &rt) < 0)
854 tprintf(", %#lx", arg);
855 else {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200856 tprints(", ");
Roland McGrathd83c50b2004-10-06 22:27:43 +0000857 print_rtc(tcp, &rt);
858 }
859 }
860 break;
861 case RTC_IRQP_SET:
862 case RTC_EPOCH_SET:
863 if (entering(tcp))
864 tprintf(", %lu", arg);
865 break;
866 case RTC_IRQP_READ:
867 case RTC_EPOCH_READ:
868 if (exiting(tcp))
869 tprintf(", %lu", arg);
870 break;
871 case RTC_WKALM_SET:
872 if (entering(tcp)) {
873 struct rtc_wkalrm wk;
874 if (umove(tcp, arg, &wk) < 0)
875 tprintf(", %#lx", arg);
876 else {
877 tprintf(", {enabled=%d, pending=%d, ",
878 wk.enabled, wk.pending);
879 print_rtc(tcp, &wk.time);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200880 tprints("}");
Roland McGrathd83c50b2004-10-06 22:27:43 +0000881 }
882 }
883 break;
884 case RTC_WKALM_RD:
885 if (exiting(tcp)) {
886 struct rtc_wkalrm wk;
887 if (syserror(tcp) || umove(tcp, arg, &wk) < 0)
888 tprintf(", %#lx", arg);
889 else {
890 tprintf(", {enabled=%d, pending=%d, ",
891 wk.enabled, wk.pending);
892 print_rtc(tcp, &wk.time);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200893 tprints("}");
Roland McGrathd83c50b2004-10-06 22:27:43 +0000894 }
895 }
896 break;
897 default:
898 if (entering(tcp))
899 tprintf(", %#lx", arg);
900 break;
901 }
902 return 1;
903}
Roland McGrathe4662342007-08-02 01:25:34 +0000904
905#ifndef TFD_TIMER_ABSTIME
906#define TFD_TIMER_ABSTIME (1 << 0)
907#endif
908
909static const struct xlat timerfdflags[] = {
910 { TFD_TIMER_ABSTIME, "TFD_TIMER_ABSTIME" },
911 { 0, NULL }
912};
913
914int
Denys Vlasenko12014262011-05-30 14:00:14 +0200915sys_timerfd(struct tcb *tcp)
Roland McGrathe4662342007-08-02 01:25:34 +0000916{
917 if (entering(tcp)) {
918 /* It does not matter that the kernel uses itimerspec. */
919 tprintf("%ld, ", tcp->u_arg[0]);
920 printxval(clocknames, tcp->u_arg[1], "CLOCK_???");
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200921 tprints(", ");
Roland McGrathe4662342007-08-02 01:25:34 +0000922 printflags(timerfdflags, tcp->u_arg[2], "TFD_???");
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200923 tprints(", ");
Roland McGrathe4662342007-08-02 01:25:34 +0000924 printitv(tcp, tcp->u_arg[3]);
925 }
926 return 0;
927}
Roland McGrathde328e62008-05-20 04:56:13 +0000928
929int
930sys_timerfd_create(struct tcb *tcp)
931{
932 if (entering(tcp)) {
933 printxval(clocknames, tcp->u_arg[0], "CLOCK_???");
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200934 tprints(", ");
Roland McGrathde328e62008-05-20 04:56:13 +0000935 printflags(timerfdflags, tcp->u_arg[1], "TFD_???");
936 }
937 return 0;
938}
939
940int
941sys_timerfd_settime(struct tcb *tcp)
942{
943 if (entering(tcp)) {
Dmitry V. Levin31382132011-03-04 05:08:02 +0300944 printfd(tcp, tcp->u_arg[0]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200945 tprints(", ");
Roland McGrathde328e62008-05-20 04:56:13 +0000946 printflags(timerfdflags, tcp->u_arg[1], "TFD_???");
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200947 tprints(", ");
Roland McGrathde328e62008-05-20 04:56:13 +0000948 printitv(tcp, tcp->u_arg[2]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200949 tprints(", ");
Roland McGrathde328e62008-05-20 04:56:13 +0000950 printitv(tcp, tcp->u_arg[3]);
951 }
952 return 0;
953}
954
955int
956sys_timerfd_gettime(struct tcb *tcp)
957{
958 if (entering(tcp)) {
Dmitry V. Levin31382132011-03-04 05:08:02 +0300959 printfd(tcp, tcp->u_arg[0]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200960 tprints(", ");
Roland McGrathde328e62008-05-20 04:56:13 +0000961 printitv(tcp, tcp->u_arg[1]);
962 }
963 return 0;
964}
965