blob: 31f0846ee316c9fd486ac01ef30ef682700b800f [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.
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000028 */
29
30#include "defs.h"
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000031#include <linux/version.h>
Wichert Akkermand856b992000-10-13 12:47:12 +000032#include <sys/timex.h>
Roland McGrathd83c50b2004-10-06 22:27:43 +000033#include <linux/ioctl.h>
34#include <linux/rtc.h>
Roland McGrath6afc5652007-07-24 01:57:11 +000035
36#ifndef UTIME_NOW
37#define UTIME_NOW ((1l << 30) - 1l)
38#endif
39#ifndef UTIME_OMIT
40#define UTIME_OMIT ((1l << 30) - 2l)
41#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000042
Dmitry V. Levina7945a32006-12-13 17:10:11 +000043struct timeval32
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000044{
Dmitry V. Levina7945a32006-12-13 17:10:11 +000045 u_int32_t tv_sec, tv_usec;
46};
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000047
Dmitry V. Levin1cad25d2006-12-13 17:14:36 +000048static void
49tprint_timeval32(struct tcb *tcp, const struct timeval32 *tv)
50{
51 tprintf("{%u, %u}", tv->tv_sec, tv->tv_usec);
52}
53
54static void
55tprint_timeval(struct tcb *tcp, const struct timeval *tv)
56{
57 tprintf("{%lu, %lu}",
58 (unsigned long) tv->tv_sec, (unsigned long) tv->tv_usec);
59}
60
Dmitry V. Levina7945a32006-12-13 17:10:11 +000061void
Roland McGrath6afc5652007-07-24 01:57:11 +000062printtv_bitness(struct tcb *tcp, long addr, enum bitness_t bitness, int special)
Dmitry V. Levina7945a32006-12-13 17:10:11 +000063{
Denys Vlasenkoa1d541e2012-01-20 11:04:04 +010064 char buf[TIMEVAL_TEXT_BUFSIZE];
65 sprinttv(buf, tcp, addr, bitness, special);
66 tprints(buf);
Dmitry V. Levina7945a32006-12-13 17:10:11 +000067}
Wichert Akkerman221f54f1999-11-18 17:26:45 +000068
Dmitry V. Levinee21a5b2014-12-26 23:55:38 +000069static char *
70do_sprinttv(char *buf, const unsigned long sec, const unsigned long usec,
71 const int special)
72{
73 if (special) {
74 switch (usec) {
75 case UTIME_NOW:
76 return stpcpy(buf, "UTIME_NOW");
77 case UTIME_OMIT:
78 return stpcpy(buf, "UTIME_OMIT");
79 }
80 }
81 return buf + sprintf(buf, "{%lu, %lu}", sec, usec);
82}
83
Denys Vlasenko2fb4db32011-08-31 12:26:03 +020084char *
Denys Vlasenkoa1d541e2012-01-20 11:04:04 +010085sprinttv(char *buf, struct tcb *tcp, long addr, enum bitness_t bitness, int special)
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +000086{
Dmitry V. Levina7945a32006-12-13 17:10:11 +000087 if (addr == 0)
Denys Vlasenko2fb4db32011-08-31 12:26:03 +020088 return stpcpy(buf, "NULL");
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +000089
Denys Vlasenkob9c7ae62011-09-01 11:40:40 +020090 if (!verbose(tcp))
91 return buf + sprintf(buf, "%#lx", addr);
Denys Vlasenko2fb4db32011-08-31 12:26:03 +020092
93 if (bitness == BITNESS_32
Denys Vlasenko84703742012-02-25 02:38:52 +010094#if SUPPORTED_PERSONALITIES > 1
Denys Vlasenko9fd4f962012-03-19 09:36:42 +010095 || current_wordsize == 4
Denys Vlasenko2fb4db32011-08-31 12:26:03 +020096#endif
97 )
98 {
99 struct timeval32 tv;
100
Dmitry V. Levinee21a5b2014-12-26 23:55:38 +0000101 if (umove(tcp, addr, &tv) >= 0)
102 return do_sprinttv(buf, tv.tv_sec, tv.tv_usec, special);
Denys Vlasenko2fb4db32011-08-31 12:26:03 +0200103 } else {
104 struct timeval tv;
105
Dmitry V. Levinee21a5b2014-12-26 23:55:38 +0000106 if (umove(tcp, addr, &tv) >= 0)
107 return do_sprinttv(buf, tv.tv_sec, tv.tv_usec, special);
Denys Vlasenko2fb4db32011-08-31 12:26:03 +0200108 }
Denys Vlasenko2fb4db32011-08-31 12:26:03 +0200109
Denys Vlasenkob9c7ae62011-09-01 11:40:40 +0200110 return stpcpy(buf, "{...}");
Dmitry V. Levina7945a32006-12-13 17:10:11 +0000111}
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +0000112
Denys Vlasenkoa1d541e2012-01-20 11:04:04 +0100113void
114print_timespec(struct tcb *tcp, long addr)
Roland McGrath6bc09da2007-11-01 21:50:54 +0000115{
Denys Vlasenkoa1d541e2012-01-20 11:04:04 +0100116 char buf[TIMESPEC_TEXT_BUFSIZE];
117 sprint_timespec(buf, tcp, addr);
118 tprints(buf);
Roland McGrath6bc09da2007-11-01 21:50:54 +0000119}
120
Denys Vlasenkoa1d541e2012-01-20 11:04:04 +0100121void
122sprint_timespec(char *buf, struct tcb *tcp, long addr)
Roland McGrath6bc09da2007-11-01 21:50:54 +0000123{
124 if (addr == 0)
125 strcpy(buf, "NULL");
126 else if (!verbose(tcp))
127 sprintf(buf, "%#lx", addr);
128 else {
Denys Vlasenko1d632462009-04-14 12:51:00 +0000129 int rc;
Roland McGrath6bc09da2007-11-01 21:50:54 +0000130
Denys Vlasenko84703742012-02-25 02:38:52 +0100131#if SUPPORTED_PERSONALITIES > 1
Denys Vlasenko9fd4f962012-03-19 09:36:42 +0100132 if (current_wordsize == 4) {
Roland McGrath6bc09da2007-11-01 21:50:54 +0000133 struct timeval32 tv;
134
Denys Vlasenko5d645812011-08-20 12:48:18 +0200135 rc = umove(tcp, addr, &tv);
136 if (rc >= 0)
Roland McGrath6bc09da2007-11-01 21:50:54 +0000137 sprintf(buf, "{%u, %u}",
138 tv.tv_sec, tv.tv_usec);
139 } else
Roland McGrath6bc09da2007-11-01 21:50:54 +0000140#endif
Denys Vlasenko1d632462009-04-14 12:51:00 +0000141 {
Roland McGrath6bc09da2007-11-01 21:50:54 +0000142 struct timespec ts;
143
Denys Vlasenko5d645812011-08-20 12:48:18 +0200144 rc = umove(tcp, addr, &ts);
145 if (rc >= 0)
Roland McGrath6bc09da2007-11-01 21:50:54 +0000146 sprintf(buf, "{%lu, %lu}",
147 (unsigned long) ts.tv_sec,
148 (unsigned long) ts.tv_nsec);
Roland McGrath6bc09da2007-11-01 21:50:54 +0000149 }
Roland McGrath6bc09da2007-11-01 21:50:54 +0000150 if (rc < 0)
151 strcpy(buf, "{...}");
152 }
153}
154
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000155int
Denys Vlasenko12014262011-05-30 14:00:14 +0200156sys_time(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000157{
158 if (exiting(tcp)) {
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000159 printnum(tcp, tcp->u_arg[0], "%ld");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000160 }
161 return 0;
162}
163
164int
Denys Vlasenko12014262011-05-30 14:00:14 +0200165sys_gettimeofday(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000166{
167 if (exiting(tcp)) {
168 if (syserror(tcp)) {
169 tprintf("%#lx, %#lx",
170 tcp->u_arg[0], tcp->u_arg[1]);
171 return 0;
172 }
173 printtv(tcp, tcp->u_arg[0]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200174 tprints(", ");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000175 printtv(tcp, tcp->u_arg[1]);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000176 }
177 return 0;
178}
179
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +0000180#ifdef ALPHA
181int
Denys Vlasenko12014262011-05-30 14:00:14 +0200182sys_osf_gettimeofday(struct tcb *tcp)
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +0000183{
Denys Vlasenko1d632462009-04-14 12:51:00 +0000184 if (exiting(tcp)) {
185 if (syserror(tcp)) {
186 tprintf("%#lx, %#lx", tcp->u_arg[0], tcp->u_arg[1]);
187 return 0;
188 }
189 printtv_bitness(tcp, tcp->u_arg[0], BITNESS_32, 0);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200190 tprints(", ");
Denys Vlasenko1d632462009-04-14 12:51:00 +0000191 printtv_bitness(tcp, tcp->u_arg[1], BITNESS_32, 0);
Denys Vlasenko1d632462009-04-14 12:51:00 +0000192 }
193 return 0;
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +0000194}
195#endif
196
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000197int
Denys Vlasenko12014262011-05-30 14:00:14 +0200198sys_settimeofday(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000199{
200 if (entering(tcp)) {
201 printtv(tcp, tcp->u_arg[0]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200202 tprints(", ");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000203 printtv(tcp, tcp->u_arg[1]);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000204 }
205 return 0;
206}
207
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +0000208#ifdef ALPHA
209int
Denys Vlasenko12014262011-05-30 14:00:14 +0200210sys_osf_settimeofday(struct tcb *tcp)
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +0000211{
Denys Vlasenko1d632462009-04-14 12:51:00 +0000212 if (entering(tcp)) {
213 printtv_bitness(tcp, tcp->u_arg[0], BITNESS_32, 0);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200214 tprints(", ");
Denys Vlasenko1d632462009-04-14 12:51:00 +0000215 printtv_bitness(tcp, tcp->u_arg[1], BITNESS_32, 0);
Denys Vlasenko1d632462009-04-14 12:51:00 +0000216 }
217 return 0;
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +0000218}
219#endif
220
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000221int
Denys Vlasenko12014262011-05-30 14:00:14 +0200222sys_adjtime(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000223{
224 if (entering(tcp)) {
225 printtv(tcp, tcp->u_arg[0]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200226 tprints(", ");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000227 } else {
228 if (syserror(tcp))
229 tprintf("%#lx", tcp->u_arg[1]);
230 else
231 printtv(tcp, tcp->u_arg[1]);
232 }
233 return 0;
234}
235
Dmitry V. Levin2e55ff42008-09-03 01:02:46 +0000236int
237sys_nanosleep(struct tcb *tcp)
238{
239 if (entering(tcp)) {
240 print_timespec(tcp, tcp->u_arg[0]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200241 tprints(", ");
Dmitry V. Levin2e55ff42008-09-03 01:02:46 +0000242 } else {
Denys Vlasenko64acaa12012-01-28 02:29:36 +0100243 /* Second (returned) timespec is only significant
Denys Vlasenko47932212013-06-30 23:53:49 +0200244 * if syscall was interrupted. On success, we print
245 * only its address, since kernel doesn't modify it,
246 * and printing the value may show uninitialized data.
Denys Vlasenko64acaa12012-01-28 02:29:36 +0100247 */
Denys Vlasenko47932212013-06-30 23:53:49 +0200248 switch (tcp->u_error) {
249 default:
250 /* Not interrupted (slept entire interval) */
251 if (tcp->u_arg[1]) {
252 tprintf("%#lx", tcp->u_arg[1]);
253 break;
254 }
255 /* Fall through: print_timespec(NULL) prints "NULL" */
256 case ERESTARTSYS:
257 case ERESTARTNOINTR:
258 case ERESTARTNOHAND:
259 case ERESTART_RESTARTBLOCK:
260 /* Interrupted */
Dmitry V. Levin2e55ff42008-09-03 01:02:46 +0000261 print_timespec(tcp, tcp->u_arg[1]);
Denys Vlasenko47932212013-06-30 23:53:49 +0200262 }
Dmitry V. Levin2e55ff42008-09-03 01:02:46 +0000263 }
264 return 0;
265}
266
Dmitry V. Levin0ed617b2014-04-25 23:30:54 +0000267#include "xlat/itimer_which.h"
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000268
269static void
Dmitry V. Levin1cad25d2006-12-13 17:14:36 +0000270printitv_bitness(struct tcb *tcp, long addr, enum bitness_t bitness)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000271{
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000272 if (addr == 0)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200273 tprints("NULL");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000274 else if (!verbose(tcp))
275 tprintf("%#lx", addr);
Denys Vlasenko1d632462009-04-14 12:51:00 +0000276 else {
277 int rc;
Dmitry V. Levin1cad25d2006-12-13 17:14:36 +0000278
279 if (bitness == BITNESS_32
Denys Vlasenko84703742012-02-25 02:38:52 +0100280#if SUPPORTED_PERSONALITIES > 1
Denys Vlasenko9fd4f962012-03-19 09:36:42 +0100281 || current_wordsize == 4
Dmitry V. Levin1cad25d2006-12-13 17:14:36 +0000282#endif
283 )
284 {
Denys Vlasenko1d632462009-04-14 12:51:00 +0000285 struct {
Dmitry V. Levin1cad25d2006-12-13 17:14:36 +0000286 struct timeval32 it_interval, it_value;
287 } itv;
288
Denys Vlasenko5d645812011-08-20 12:48:18 +0200289 rc = umove(tcp, addr, &itv);
290 if (rc >= 0) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200291 tprints("{it_interval=");
Dmitry V. Levin1cad25d2006-12-13 17:14:36 +0000292 tprint_timeval32(tcp, &itv.it_interval);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200293 tprints(", it_value=");
Dmitry V. Levin1cad25d2006-12-13 17:14:36 +0000294 tprint_timeval32(tcp, &itv.it_value);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200295 tprints("}");
Roland McGrathe4662342007-08-02 01:25:34 +0000296 }
Denys Vlasenko1d632462009-04-14 12:51:00 +0000297 } else {
Dmitry V. Levin1cad25d2006-12-13 17:14:36 +0000298 struct itimerval itv;
299
Denys Vlasenko5d645812011-08-20 12:48:18 +0200300 rc = umove(tcp, addr, &itv);
301 if (rc >= 0) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200302 tprints("{it_interval=");
Dmitry V. Levin1cad25d2006-12-13 17:14:36 +0000303 tprint_timeval(tcp, &itv.it_interval);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200304 tprints(", it_value=");
Dmitry V. Levin1cad25d2006-12-13 17:14:36 +0000305 tprint_timeval(tcp, &itv.it_value);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200306 tprints("}");
Roland McGrathe4662342007-08-02 01:25:34 +0000307 }
Dmitry V. Levin1cad25d2006-12-13 17:14:36 +0000308 }
Dmitry V. Levin1cad25d2006-12-13 17:14:36 +0000309 if (rc < 0)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200310 tprints("{...}");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000311 }
312}
313
Dmitry V. Levin1cad25d2006-12-13 17:14:36 +0000314#define printitv(tcp, addr) \
315 printitv_bitness((tcp), (addr), BITNESS_CURRENT)
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +0000316
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000317int
Denys Vlasenko12014262011-05-30 14:00:14 +0200318sys_getitimer(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000319{
320 if (entering(tcp)) {
Dmitry V. Levin297b5942014-04-25 23:39:20 +0000321 printxval(itimer_which, tcp->u_arg[0], "ITIMER_???");
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200322 tprints(", ");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000323 } else {
324 if (syserror(tcp))
325 tprintf("%#lx", tcp->u_arg[1]);
326 else
327 printitv(tcp, tcp->u_arg[1]);
328 }
329 return 0;
330}
331
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +0000332#ifdef ALPHA
333int
Denys Vlasenko12014262011-05-30 14:00:14 +0200334sys_osf_getitimer(struct tcb *tcp)
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +0000335{
Denys Vlasenko1d632462009-04-14 12:51:00 +0000336 if (entering(tcp)) {
Dmitry V. Levin297b5942014-04-25 23:39:20 +0000337 printxval(itimer_which, tcp->u_arg[0], "ITIMER_???");
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200338 tprints(", ");
Denys Vlasenko1d632462009-04-14 12:51:00 +0000339 } else {
340 if (syserror(tcp))
341 tprintf("%#lx", tcp->u_arg[1]);
342 else
343 printitv_bitness(tcp, tcp->u_arg[1], BITNESS_32);
344 }
345 return 0;
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +0000346}
347#endif
348
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000349int
Denys Vlasenko12014262011-05-30 14:00:14 +0200350sys_setitimer(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000351{
352 if (entering(tcp)) {
Dmitry V. Levin297b5942014-04-25 23:39:20 +0000353 printxval(itimer_which, tcp->u_arg[0], "ITIMER_???");
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200354 tprints(", ");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000355 printitv(tcp, tcp->u_arg[1]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200356 tprints(", ");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000357 } else {
358 if (syserror(tcp))
359 tprintf("%#lx", tcp->u_arg[2]);
360 else
361 printitv(tcp, tcp->u_arg[2]);
362 }
363 return 0;
364}
365
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +0000366#ifdef ALPHA
367int
Denys Vlasenko12014262011-05-30 14:00:14 +0200368sys_osf_setitimer(struct tcb *tcp)
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +0000369{
Denys Vlasenko1d632462009-04-14 12:51:00 +0000370 if (entering(tcp)) {
Dmitry V. Levin297b5942014-04-25 23:39:20 +0000371 printxval(itimer_which, tcp->u_arg[0], "ITIMER_???");
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200372 tprints(", ");
Denys Vlasenko1d632462009-04-14 12:51:00 +0000373 printitv_bitness(tcp, tcp->u_arg[1], BITNESS_32);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200374 tprints(", ");
Denys Vlasenko1d632462009-04-14 12:51:00 +0000375 } else {
376 if (syserror(tcp))
377 tprintf("%#lx", tcp->u_arg[2]);
378 else
379 printitv_bitness(tcp, tcp->u_arg[2], BITNESS_32);
380 }
381 return 0;
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +0000382}
383#endif
384
Dmitry V. Levin0ed617b2014-04-25 23:30:54 +0000385#include "xlat/adjtimex_modes.h"
Dmitry V. Levin0ed617b2014-04-25 23:30:54 +0000386#include "xlat/adjtimex_status.h"
Dmitry V. Levin0ed617b2014-04-25 23:30:54 +0000387#include "xlat/adjtimex_state.h"
Dmitry V. Levin1a684d62006-12-13 17:42:32 +0000388
Dmitry V. Levin165b15d2006-12-13 17:43:45 +0000389#if SUPPORTED_PERSONALITIES > 1
390static int
391tprint_timex32(struct tcb *tcp, long addr)
392{
Denys Vlasenko1d632462009-04-14 12:51:00 +0000393 struct {
Dmitry V. Levin165b15d2006-12-13 17:43:45 +0000394 unsigned int modes;
395 int offset;
396 int freq;
397 int maxerror;
398 int esterror;
399 int status;
400 int constant;
401 int precision;
402 int tolerance;
403 struct timeval32 time;
404 int tick;
405 int ppsfreq;
406 int jitter;
407 int shift;
408 int stabil;
409 int jitcnt;
410 int calcnt;
411 int errcnt;
412 int stbcnt;
413 } tx;
414
415 if (umove(tcp, addr, &tx) < 0)
416 return -1;
417
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200418 tprints("{modes=");
Dmitry V. Levin71d70892007-01-13 11:17:38 +0000419 printflags(adjtimex_modes, tx.modes, "ADJ_???");
Dmitry V. Levin165b15d2006-12-13 17:43:45 +0000420 tprintf(", offset=%d, freq=%d, maxerror=%d, ",
421 tx.offset, tx.freq, tx.maxerror);
422 tprintf("esterror=%u, status=", tx.esterror);
423 printflags(adjtimex_status, tx.status, "STA_???");
424 tprintf(", constant=%d, precision=%u, ",
425 tx.constant, tx.precision);
426 tprintf("tolerance=%d, time=", tx.tolerance);
427 tprint_timeval32(tcp, &tx.time);
428 tprintf(", tick=%d, ppsfreq=%d, jitter=%d",
429 tx.tick, tx.ppsfreq, tx.jitter);
430 tprintf(", shift=%d, stabil=%d, jitcnt=%d",
431 tx.shift, tx.stabil, tx.jitcnt);
432 tprintf(", calcnt=%d, errcnt=%d, stbcnt=%d",
433 tx.calcnt, tx.errcnt, tx.stbcnt);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200434 tprints("}");
Dmitry V. Levin165b15d2006-12-13 17:43:45 +0000435 return 0;
436}
437#endif /* SUPPORTED_PERSONALITIES > 1 */
438
439static int
440tprint_timex(struct tcb *tcp, long addr)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000441{
Dmitry V. Levin1a684d62006-12-13 17:42:32 +0000442 struct timex tx;
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000443
Dmitry V. Levin165b15d2006-12-13 17:43:45 +0000444#if SUPPORTED_PERSONALITIES > 1
Denys Vlasenko9fd4f962012-03-19 09:36:42 +0100445 if (current_wordsize == 4)
Dmitry V. Levin165b15d2006-12-13 17:43:45 +0000446 return tprint_timex32(tcp, addr);
447#endif
448 if (umove(tcp, addr, &tx) < 0)
449 return -1;
450
451#if LINUX_VERSION_CODE < 66332
452 tprintf("{mode=%d, offset=%ld, frequency=%ld, ",
453 tx.mode, tx.offset, tx.frequency);
454 tprintf("maxerror=%ld, esterror=%lu, status=%u, ",
455 tx.maxerror, tx.esterror, tx.status);
456 tprintf("time_constant=%ld, precision=%lu, ",
457 tx.time_constant, tx.precision);
458 tprintf("tolerance=%ld, time=", tx.tolerance);
459 tprint_timeval(tcp, &tx.time);
460#else
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200461 tprints("{modes=");
Dmitry V. Levin71d70892007-01-13 11:17:38 +0000462 printflags(adjtimex_modes, tx.modes, "ADJ_???");
Dmitry V. Levin165b15d2006-12-13 17:43:45 +0000463 tprintf(", offset=%ld, freq=%ld, maxerror=%ld, ",
H.J. Lu0b315b62012-02-03 10:16:03 -0800464 (long) tx.offset, (long) tx.freq, (long) tx.maxerror);
465 tprintf("esterror=%lu, status=", (long) tx.esterror);
Dmitry V. Levin165b15d2006-12-13 17:43:45 +0000466 printflags(adjtimex_status, tx.status, "STA_???");
467 tprintf(", constant=%ld, precision=%lu, ",
H.J. Lu0b315b62012-02-03 10:16:03 -0800468 (long) tx.constant, (long) tx.precision);
469 tprintf("tolerance=%ld, time=", (long) tx.tolerance);
Dmitry V. Levin165b15d2006-12-13 17:43:45 +0000470 tprint_timeval(tcp, &tx.time);
471 tprintf(", tick=%ld, ppsfreq=%ld, jitter=%ld",
H.J. Lu0b315b62012-02-03 10:16:03 -0800472 (long) tx.tick, (long) tx.ppsfreq, (long) tx.jitter);
Dmitry V. Levin165b15d2006-12-13 17:43:45 +0000473 tprintf(", shift=%d, stabil=%ld, jitcnt=%ld",
H.J. Lu0b315b62012-02-03 10:16:03 -0800474 tx.shift, (long) tx.stabil, (long) tx.jitcnt);
Dmitry V. Levin165b15d2006-12-13 17:43:45 +0000475 tprintf(", calcnt=%ld, errcnt=%ld, stbcnt=%ld",
H.J. Lu0b315b62012-02-03 10:16:03 -0800476 (long) tx.calcnt, (long) tx.errcnt, (long) tx.stbcnt);
Dmitry V. Levin165b15d2006-12-13 17:43:45 +0000477#endif
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200478 tprints("}");
Dmitry V. Levin165b15d2006-12-13 17:43:45 +0000479 return 0;
480}
481
Dmitry V. Levin73215472012-03-11 21:25:51 +0000482static int
483do_adjtimex(struct tcb *tcp, long addr)
484{
485 if (addr == 0)
486 tprints("NULL");
487 else if (syserror(tcp) || !verbose(tcp))
488 tprintf("%#lx", addr);
489 else if (tprint_timex(tcp, addr) < 0)
490 tprints("{...}");
491 if (syserror(tcp))
492 return 0;
493 tcp->auxstr = xlookup(adjtimex_state, tcp->u_rval);
494 if (tcp->auxstr)
495 return RVAL_STR;
496 return 0;
497}
498
Dmitry V. Levin165b15d2006-12-13 17:43:45 +0000499int
500sys_adjtimex(struct tcb *tcp)
501{
Dmitry V. Levin73215472012-03-11 21:25:51 +0000502 if (exiting(tcp))
503 return do_adjtimex(tcp, tcp->u_arg[0]);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000504 return 0;
505}
Roland McGrath1e356792003-03-30 23:52:28 +0000506
Dmitry V. Levin0ed617b2014-04-25 23:30:54 +0000507#include "xlat/clockflags.h"
Dmitry V. Levin0ed617b2014-04-25 23:30:54 +0000508#include "xlat/clocknames.h"
Roland McGrath54a4edd2004-08-31 06:52:45 +0000509
Stefan Sørensena5fea902014-02-03 10:01:27 +0100510static void
511printclockname(int clockid)
512{
513#ifdef CLOCKID_TO_FD
Dmitry V. Levind35bdca2014-04-26 18:10:19 +0000514# include "xlat/cpuclocknames.h"
515
Stefan Sørensena5fea902014-02-03 10:01:27 +0100516 if (clockid < 0) {
517 if ((clockid & CLOCKFD_MASK) == CLOCKFD)
518 tprintf("FD_TO_CLOCKID(%d)", CLOCKID_TO_FD(clockid));
519 else {
520 if(CPUCLOCK_PERTHREAD(clockid))
521 tprintf("MAKE_THREAD_CPUCLOCK(%d,", CPUCLOCK_PID(clockid));
522 else
523 tprintf("MAKE_PROCESS_CPUCLOCK(%d,", CPUCLOCK_PID(clockid));
524 printxval(cpuclocknames, clockid & CLOCKFD_MASK, "CPUCLOCK_???");
525 tprints(")");
526 }
527 }
528 else
529#endif
530 printxval(clocknames, clockid, "CLOCK_???");
531}
532
Roland McGrath1e356792003-03-30 23:52:28 +0000533int
Denys Vlasenko12014262011-05-30 14:00:14 +0200534sys_clock_settime(struct tcb *tcp)
Roland McGrath1e356792003-03-30 23:52:28 +0000535{
536 if (entering(tcp)) {
Stefan Sørensena5fea902014-02-03 10:01:27 +0100537 printclockname(tcp->u_arg[0]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200538 tprints(", ");
Roland McGrath1e356792003-03-30 23:52:28 +0000539 printtv(tcp, tcp->u_arg[1]);
540 }
541 return 0;
542}
543
544int
Denys Vlasenko12014262011-05-30 14:00:14 +0200545sys_clock_gettime(struct tcb *tcp)
Roland McGrath1e356792003-03-30 23:52:28 +0000546{
547 if (entering(tcp)) {
Stefan Sørensena5fea902014-02-03 10:01:27 +0100548 printclockname(tcp->u_arg[0]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200549 tprints(", ");
Roland McGrath1e356792003-03-30 23:52:28 +0000550 } else {
551 if (syserror(tcp))
552 tprintf("%#lx", tcp->u_arg[1]);
553 else
554 printtv(tcp, tcp->u_arg[1]);
555 }
556 return 0;
557}
558
559int
Denys Vlasenko12014262011-05-30 14:00:14 +0200560sys_clock_nanosleep(struct tcb *tcp)
Roland McGrath1e356792003-03-30 23:52:28 +0000561{
562 if (entering(tcp)) {
Stefan Sørensena5fea902014-02-03 10:01:27 +0100563 printclockname(tcp->u_arg[0]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200564 tprints(", ");
Roland McGrathb2dee132005-06-01 19:02:36 +0000565 printflags(clockflags, tcp->u_arg[1], "TIMER_???");
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200566 tprints(", ");
Roland McGrath1e356792003-03-30 23:52:28 +0000567 printtv(tcp, tcp->u_arg[2]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200568 tprints(", ");
Roland McGrath1e356792003-03-30 23:52:28 +0000569 } else {
570 if (syserror(tcp))
571 tprintf("%#lx", tcp->u_arg[3]);
572 else
573 printtv(tcp, tcp->u_arg[3]);
574 }
575 return 0;
576}
577
Dmitry V. Levin73215472012-03-11 21:25:51 +0000578int
579sys_clock_adjtime(struct tcb *tcp)
580{
581 if (exiting(tcp))
582 return do_adjtimex(tcp, tcp->u_arg[1]);
Stefan Sørensena5fea902014-02-03 10:01:27 +0100583 printclockname(tcp->u_arg[0]);
Dmitry V. Levin73215472012-03-11 21:25:51 +0000584 tprints(", ");
585 return 0;
586}
587
Roland McGrath1e356792003-03-30 23:52:28 +0000588#ifndef SIGEV_THREAD_ID
589# define SIGEV_THREAD_ID 4
590#endif
Dmitry V. Levin0ed617b2014-04-25 23:30:54 +0000591#include "xlat/sigev_value.h"
Roland McGrath1e356792003-03-30 23:52:28 +0000592
Dmitry V. Levind3cb3922006-12-13 17:45:02 +0000593#if SUPPORTED_PERSONALITIES > 1
594static void
595printsigevent32(struct tcb *tcp, long arg)
596{
Denys Vlasenko1d632462009-04-14 12:51:00 +0000597 struct {
Dmitry V. Levind3cb3922006-12-13 17:45:02 +0000598 int sigev_value;
599 int sigev_signo;
600 int sigev_notify;
601
Denys Vlasenko1d632462009-04-14 12:51:00 +0000602 union {
Dmitry V. Levind3cb3922006-12-13 17:45:02 +0000603 int tid;
Denys Vlasenko1d632462009-04-14 12:51:00 +0000604 struct {
Dmitry V. Levind3cb3922006-12-13 17:45:02 +0000605 int function, attribute;
606 } thread;
607 } un;
608 } sev;
609
610 if (umove(tcp, arg, &sev) < 0)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200611 tprints("{...}");
Denys Vlasenko1d632462009-04-14 12:51:00 +0000612 else {
Dmitry V. Levind3cb3922006-12-13 17:45:02 +0000613 tprintf("{%#x, ", sev.sigev_value);
614 if (sev.sigev_notify == SIGEV_SIGNAL)
615 tprintf("%s, ", signame(sev.sigev_signo));
616 else
617 tprintf("%u, ", sev.sigev_signo);
Dmitry V. Levinbae549e2014-02-05 01:46:10 +0000618 printxval(sigev_value, sev.sigev_notify, "SIGEV_???");
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200619 tprints(", ");
Dmitry V. Levind3cb3922006-12-13 17:45:02 +0000620 if (sev.sigev_notify == SIGEV_THREAD_ID)
621 tprintf("{%d}", sev.un.tid);
622 else if (sev.sigev_notify == SIGEV_THREAD)
623 tprintf("{%#x, %#x}",
624 sev.un.thread.function,
625 sev.un.thread.attribute);
626 else
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200627 tprints("{...}");
628 tprints("}");
Dmitry V. Levind3cb3922006-12-13 17:45:02 +0000629 }
630}
631#endif
632
Roland McGrath1e356792003-03-30 23:52:28 +0000633void
Dmitry V. Levind3cb3922006-12-13 17:45:02 +0000634printsigevent(struct tcb *tcp, long arg)
Roland McGrath1e356792003-03-30 23:52:28 +0000635{
636 struct sigevent sev;
Dmitry V. Levind3cb3922006-12-13 17:45:02 +0000637
638#if SUPPORTED_PERSONALITIES > 1
Denys Vlasenko9fd4f962012-03-19 09:36:42 +0100639 if (current_wordsize == 4) {
Dmitry V. Levind3cb3922006-12-13 17:45:02 +0000640 printsigevent32(tcp, arg);
641 return;
642 }
643#endif
Denys Vlasenkob63256e2011-06-07 12:13:24 +0200644 if (umove(tcp, arg, &sev) < 0)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200645 tprints("{...}");
Roland McGrath1e356792003-03-30 23:52:28 +0000646 else {
Roland McGrath675d4a62004-09-11 08:12:45 +0000647 tprintf("{%p, ", sev.sigev_value.sival_ptr);
648 if (sev.sigev_notify == SIGEV_SIGNAL)
649 tprintf("%s, ", signame(sev.sigev_signo));
650 else
651 tprintf("%u, ", sev.sigev_signo);
Dmitry V. Levinbae549e2014-02-05 01:46:10 +0000652 printxval(sigev_value, sev.sigev_notify, "SIGEV_???");
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200653 tprints(", ");
Roland McGrath1e356792003-03-30 23:52:28 +0000654 if (sev.sigev_notify == SIGEV_THREAD_ID)
Dmitry V. Levinae5aa472013-11-11 23:54:30 +0000655#if defined(HAVE_STRUCT_SIGEVENT__SIGEV_UN__PAD)
Roland McGrath1e356792003-03-30 23:52:28 +0000656 /* _pad[0] is the _tid field which might not be
657 present in the userlevel definition of the
658 struct. */
659 tprintf("{%d}", sev._sigev_un._pad[0]);
Dmitry V. Levinae5aa472013-11-11 23:54:30 +0000660#elif defined(HAVE_STRUCT_SIGEVENT___PAD)
661 tprintf("{%d}", sev.__pad[0]);
662#else
663# warning unfamiliar struct sigevent => incomplete SIGEV_THREAD_ID decoding
664 tprints("{...}");
665#endif
Roland McGrathd4c85eb2004-04-16 21:48:44 +0000666 else if (sev.sigev_notify == SIGEV_THREAD)
667 tprintf("{%p, %p}", sev.sigev_notify_function,
668 sev.sigev_notify_attributes);
Roland McGrath1e356792003-03-30 23:52:28 +0000669 else
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200670 tprints("{...}");
671 tprints("}");
Roland McGrath1e356792003-03-30 23:52:28 +0000672 }
673}
674
675int
Denys Vlasenko12014262011-05-30 14:00:14 +0200676sys_timer_create(struct tcb *tcp)
Roland McGrath1e356792003-03-30 23:52:28 +0000677{
678 if (entering(tcp)) {
Stefan Sørensena5fea902014-02-03 10:01:27 +0100679 printclockname(tcp->u_arg[0]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200680 tprints(", ");
Roland McGrath1e356792003-03-30 23:52:28 +0000681 printsigevent(tcp, tcp->u_arg[1]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200682 tprints(", ");
Roland McGrath1e356792003-03-30 23:52:28 +0000683 } else {
Andi Kleen732f3962011-06-13 21:37:40 +0000684 int timer_id;
Dmitry V. Levinac518d12006-12-13 17:03:02 +0000685
Andi Kleen732f3962011-06-13 21:37:40 +0000686 if (syserror(tcp) || umove(tcp, tcp->u_arg[2], &timer_id) < 0)
Roland McGrath1e356792003-03-30 23:52:28 +0000687 tprintf("%#lx", tcp->u_arg[2]);
Dmitry V. Levinac518d12006-12-13 17:03:02 +0000688 else
Andi Kleen732f3962011-06-13 21:37:40 +0000689 tprintf("{%d}", timer_id);
Roland McGrath1e356792003-03-30 23:52:28 +0000690 }
691 return 0;
692}
693
694int
Denys Vlasenko12014262011-05-30 14:00:14 +0200695sys_timer_settime(struct tcb *tcp)
Roland McGrath1e356792003-03-30 23:52:28 +0000696{
697 if (entering(tcp)) {
698 tprintf("%#lx, ", tcp->u_arg[0]);
Roland McGrathb2dee132005-06-01 19:02:36 +0000699 printflags(clockflags, tcp->u_arg[1], "TIMER_???");
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200700 tprints(", ");
Roland McGrath1e356792003-03-30 23:52:28 +0000701 printitv(tcp, tcp->u_arg[2]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200702 tprints(", ");
Roland McGrath1e356792003-03-30 23:52:28 +0000703 } else {
704 if (syserror(tcp))
705 tprintf("%#lx", tcp->u_arg[3]);
706 else
707 printitv(tcp, tcp->u_arg[3]);
708 }
709 return 0;
710}
711
712int
Denys Vlasenko12014262011-05-30 14:00:14 +0200713sys_timer_gettime(struct tcb *tcp)
Roland McGrath1e356792003-03-30 23:52:28 +0000714{
715 if (entering(tcp)) {
716 tprintf("%#lx, ", tcp->u_arg[0]);
717 } else {
718 if (syserror(tcp))
719 tprintf("%#lx", tcp->u_arg[1]);
720 else
721 printitv(tcp, tcp->u_arg[1]);
722 }
723 return 0;
724}
Roland McGrathd83c50b2004-10-06 22:27:43 +0000725
726static void
Denys Vlasenko12014262011-05-30 14:00:14 +0200727print_rtc(struct tcb *tcp, const struct rtc_time *rt)
Roland McGrathd83c50b2004-10-06 22:27:43 +0000728{
729 tprintf("{tm_sec=%d, tm_min=%d, tm_hour=%d, "
730 "tm_mday=%d, tm_mon=%d, tm_year=%d, ",
731 rt->tm_sec, rt->tm_min, rt->tm_hour,
732 rt->tm_mday, rt->tm_mon, rt->tm_year);
733 if (!abbrev(tcp))
734 tprintf("tm_wday=%d, tm_yday=%d, tm_isdst=%d}",
735 rt->tm_wday, rt->tm_yday, rt->tm_isdst);
736 else
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200737 tprints("...}");
Roland McGrathd83c50b2004-10-06 22:27:43 +0000738}
739
740int
Denys Vlasenko12014262011-05-30 14:00:14 +0200741rtc_ioctl(struct tcb *tcp, long code, long arg)
Roland McGrathd83c50b2004-10-06 22:27:43 +0000742{
743 switch (code) {
744 case RTC_ALM_SET:
745 case RTC_SET_TIME:
746 if (entering(tcp)) {
747 struct rtc_time rt;
748 if (umove(tcp, arg, &rt) < 0)
749 tprintf(", %#lx", arg);
750 else {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200751 tprints(", ");
Roland McGrathd83c50b2004-10-06 22:27:43 +0000752 print_rtc(tcp, &rt);
753 }
754 }
755 break;
756 case RTC_ALM_READ:
757 case RTC_RD_TIME:
758 if (exiting(tcp)) {
759 struct rtc_time rt;
760 if (syserror(tcp) || umove(tcp, arg, &rt) < 0)
761 tprintf(", %#lx", arg);
762 else {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200763 tprints(", ");
Roland McGrathd83c50b2004-10-06 22:27:43 +0000764 print_rtc(tcp, &rt);
765 }
766 }
767 break;
768 case RTC_IRQP_SET:
769 case RTC_EPOCH_SET:
770 if (entering(tcp))
771 tprintf(", %lu", arg);
772 break;
773 case RTC_IRQP_READ:
774 case RTC_EPOCH_READ:
775 if (exiting(tcp))
776 tprintf(", %lu", arg);
777 break;
778 case RTC_WKALM_SET:
779 if (entering(tcp)) {
780 struct rtc_wkalrm wk;
781 if (umove(tcp, arg, &wk) < 0)
782 tprintf(", %#lx", arg);
783 else {
784 tprintf(", {enabled=%d, pending=%d, ",
785 wk.enabled, wk.pending);
786 print_rtc(tcp, &wk.time);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200787 tprints("}");
Roland McGrathd83c50b2004-10-06 22:27:43 +0000788 }
789 }
790 break;
791 case RTC_WKALM_RD:
792 if (exiting(tcp)) {
793 struct rtc_wkalrm wk;
794 if (syserror(tcp) || umove(tcp, arg, &wk) < 0)
795 tprintf(", %#lx", arg);
796 else {
797 tprintf(", {enabled=%d, pending=%d, ",
798 wk.enabled, wk.pending);
799 print_rtc(tcp, &wk.time);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200800 tprints("}");
Roland McGrathd83c50b2004-10-06 22:27:43 +0000801 }
802 }
803 break;
804 default:
805 if (entering(tcp))
806 tprintf(", %#lx", arg);
807 break;
808 }
809 return 1;
810}
Roland McGrathe4662342007-08-02 01:25:34 +0000811
812#ifndef TFD_TIMER_ABSTIME
813#define TFD_TIMER_ABSTIME (1 << 0)
814#endif
815
Dmitry V. Levin0ed617b2014-04-25 23:30:54 +0000816#include "xlat/timerfdflags.h"
Roland McGrathe4662342007-08-02 01:25:34 +0000817
818int
Denys Vlasenko12014262011-05-30 14:00:14 +0200819sys_timerfd(struct tcb *tcp)
Roland McGrathe4662342007-08-02 01:25:34 +0000820{
821 if (entering(tcp)) {
822 /* It does not matter that the kernel uses itimerspec. */
823 tprintf("%ld, ", tcp->u_arg[0]);
Stefan Sørensena5fea902014-02-03 10:01:27 +0100824 printclockname(tcp->u_arg[0]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200825 tprints(", ");
Roland McGrathe4662342007-08-02 01:25:34 +0000826 printflags(timerfdflags, tcp->u_arg[2], "TFD_???");
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200827 tprints(", ");
Roland McGrathe4662342007-08-02 01:25:34 +0000828 printitv(tcp, tcp->u_arg[3]);
829 }
830 return 0;
831}
Roland McGrathde328e62008-05-20 04:56:13 +0000832
833int
834sys_timerfd_create(struct tcb *tcp)
835{
836 if (entering(tcp)) {
Stefan Sørensena5fea902014-02-03 10:01:27 +0100837 printclockname(tcp->u_arg[0]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200838 tprints(", ");
Roland McGrathde328e62008-05-20 04:56:13 +0000839 printflags(timerfdflags, tcp->u_arg[1], "TFD_???");
840 }
841 return 0;
842}
843
844int
845sys_timerfd_settime(struct tcb *tcp)
846{
847 if (entering(tcp)) {
Dmitry V. Levin31382132011-03-04 05:08:02 +0300848 printfd(tcp, tcp->u_arg[0]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200849 tprints(", ");
Roland McGrathde328e62008-05-20 04:56:13 +0000850 printflags(timerfdflags, tcp->u_arg[1], "TFD_???");
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200851 tprints(", ");
Roland McGrathde328e62008-05-20 04:56:13 +0000852 printitv(tcp, tcp->u_arg[2]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200853 tprints(", ");
Roland McGrathde328e62008-05-20 04:56:13 +0000854 printitv(tcp, tcp->u_arg[3]);
855 }
856 return 0;
857}
858
859int
860sys_timerfd_gettime(struct tcb *tcp)
861{
862 if (entering(tcp)) {
Dmitry V. Levin31382132011-03-04 05:08:02 +0300863 printfd(tcp, tcp->u_arg[0]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200864 tprints(", ");
Roland McGrathde328e62008-05-20 04:56:13 +0000865 printitv(tcp, tcp->u_arg[1]);
866 }
867 return 0;
868}