blob: d8e72712cc1b560cbc7a5ce040a483ec834da7af [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"
Mike Frysingerf1639d82014-12-30 19:08:50 -050031#include <fcntl.h>
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000032#include <linux/version.h>
Wichert Akkermand856b992000-10-13 12:47:12 +000033#include <sys/timex.h>
Roland McGrathd83c50b2004-10-06 22:27:43 +000034#include <linux/ioctl.h>
35#include <linux/rtc.h>
Roland McGrath6afc5652007-07-24 01:57:11 +000036
37#ifndef UTIME_NOW
38#define UTIME_NOW ((1l << 30) - 1l)
39#endif
40#ifndef UTIME_OMIT
41#define UTIME_OMIT ((1l << 30) - 2l)
42#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000043
Dmitry V. Levina7945a32006-12-13 17:10:11 +000044struct timeval32
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000045{
Dmitry V. Levina7945a32006-12-13 17:10:11 +000046 u_int32_t tv_sec, tv_usec;
47};
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000048
Dmitry V. Levin1cad25d2006-12-13 17:14:36 +000049static void
50tprint_timeval32(struct tcb *tcp, const struct timeval32 *tv)
51{
52 tprintf("{%u, %u}", tv->tv_sec, tv->tv_usec);
53}
54
55static void
56tprint_timeval(struct tcb *tcp, const struct timeval *tv)
57{
58 tprintf("{%lu, %lu}",
59 (unsigned long) tv->tv_sec, (unsigned long) tv->tv_usec);
60}
61
Dmitry V. Levina7945a32006-12-13 17:10:11 +000062void
Roland McGrath6afc5652007-07-24 01:57:11 +000063printtv_bitness(struct tcb *tcp, long addr, enum bitness_t bitness, int special)
Dmitry V. Levina7945a32006-12-13 17:10:11 +000064{
Denys Vlasenkoa1d541e2012-01-20 11:04:04 +010065 char buf[TIMEVAL_TEXT_BUFSIZE];
66 sprinttv(buf, tcp, addr, bitness, special);
67 tprints(buf);
Dmitry V. Levina7945a32006-12-13 17:10:11 +000068}
Wichert Akkerman221f54f1999-11-18 17:26:45 +000069
Dmitry V. Levinee21a5b2014-12-26 23:55:38 +000070static char *
71do_sprinttv(char *buf, const unsigned long sec, const unsigned long usec,
72 const int special)
73{
74 if (special) {
75 switch (usec) {
76 case UTIME_NOW:
77 return stpcpy(buf, "UTIME_NOW");
78 case UTIME_OMIT:
79 return stpcpy(buf, "UTIME_OMIT");
80 }
81 }
82 return buf + sprintf(buf, "{%lu, %lu}", sec, usec);
83}
84
Denys Vlasenko2fb4db32011-08-31 12:26:03 +020085char *
Denys Vlasenkoa1d541e2012-01-20 11:04:04 +010086sprinttv(char *buf, struct tcb *tcp, long addr, enum bitness_t bitness, int special)
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +000087{
Dmitry V. Levina7945a32006-12-13 17:10:11 +000088 if (addr == 0)
Denys Vlasenko2fb4db32011-08-31 12:26:03 +020089 return stpcpy(buf, "NULL");
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +000090
Denys Vlasenkob9c7ae62011-09-01 11:40:40 +020091 if (!verbose(tcp))
92 return buf + sprintf(buf, "%#lx", addr);
Denys Vlasenko2fb4db32011-08-31 12:26:03 +020093
94 if (bitness == BITNESS_32
Denys Vlasenko84703742012-02-25 02:38:52 +010095#if SUPPORTED_PERSONALITIES > 1
Denys Vlasenko9fd4f962012-03-19 09:36:42 +010096 || current_wordsize == 4
Denys Vlasenko2fb4db32011-08-31 12:26:03 +020097#endif
98 )
99 {
100 struct timeval32 tv;
101
Dmitry V. Levinee21a5b2014-12-26 23:55:38 +0000102 if (umove(tcp, addr, &tv) >= 0)
103 return do_sprinttv(buf, tv.tv_sec, tv.tv_usec, special);
Denys Vlasenko2fb4db32011-08-31 12:26:03 +0200104 } else {
105 struct timeval tv;
106
Dmitry V. Levinee21a5b2014-12-26 23:55:38 +0000107 if (umove(tcp, addr, &tv) >= 0)
108 return do_sprinttv(buf, tv.tv_sec, tv.tv_usec, special);
Denys Vlasenko2fb4db32011-08-31 12:26:03 +0200109 }
Denys Vlasenko2fb4db32011-08-31 12:26:03 +0200110
Denys Vlasenkob9c7ae62011-09-01 11:40:40 +0200111 return stpcpy(buf, "{...}");
Dmitry V. Levina7945a32006-12-13 17:10:11 +0000112}
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +0000113
Denys Vlasenkoa1d541e2012-01-20 11:04:04 +0100114void
115print_timespec(struct tcb *tcp, long addr)
Roland McGrath6bc09da2007-11-01 21:50:54 +0000116{
Denys Vlasenkoa1d541e2012-01-20 11:04:04 +0100117 char buf[TIMESPEC_TEXT_BUFSIZE];
118 sprint_timespec(buf, tcp, addr);
119 tprints(buf);
Roland McGrath6bc09da2007-11-01 21:50:54 +0000120}
121
Denys Vlasenkoa1d541e2012-01-20 11:04:04 +0100122void
123sprint_timespec(char *buf, struct tcb *tcp, long addr)
Roland McGrath6bc09da2007-11-01 21:50:54 +0000124{
125 if (addr == 0)
126 strcpy(buf, "NULL");
127 else if (!verbose(tcp))
128 sprintf(buf, "%#lx", addr);
129 else {
Denys Vlasenko1d632462009-04-14 12:51:00 +0000130 int rc;
Roland McGrath6bc09da2007-11-01 21:50:54 +0000131
Denys Vlasenko84703742012-02-25 02:38:52 +0100132#if SUPPORTED_PERSONALITIES > 1
Denys Vlasenko9fd4f962012-03-19 09:36:42 +0100133 if (current_wordsize == 4) {
Roland McGrath6bc09da2007-11-01 21:50:54 +0000134 struct timeval32 tv;
135
Denys Vlasenko5d645812011-08-20 12:48:18 +0200136 rc = umove(tcp, addr, &tv);
137 if (rc >= 0)
Roland McGrath6bc09da2007-11-01 21:50:54 +0000138 sprintf(buf, "{%u, %u}",
139 tv.tv_sec, tv.tv_usec);
140 } else
Roland McGrath6bc09da2007-11-01 21:50:54 +0000141#endif
Denys Vlasenko1d632462009-04-14 12:51:00 +0000142 {
Roland McGrath6bc09da2007-11-01 21:50:54 +0000143 struct timespec ts;
144
Denys Vlasenko5d645812011-08-20 12:48:18 +0200145 rc = umove(tcp, addr, &ts);
146 if (rc >= 0)
Roland McGrath6bc09da2007-11-01 21:50:54 +0000147 sprintf(buf, "{%lu, %lu}",
148 (unsigned long) ts.tv_sec,
149 (unsigned long) ts.tv_nsec);
Roland McGrath6bc09da2007-11-01 21:50:54 +0000150 }
Roland McGrath6bc09da2007-11-01 21:50:54 +0000151 if (rc < 0)
152 strcpy(buf, "{...}");
153 }
154}
155
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000156int
Denys Vlasenko12014262011-05-30 14:00:14 +0200157sys_time(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000158{
159 if (exiting(tcp)) {
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000160 printnum(tcp, tcp->u_arg[0], "%ld");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000161 }
162 return 0;
163}
164
165int
Denys Vlasenko12014262011-05-30 14:00:14 +0200166sys_gettimeofday(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000167{
168 if (exiting(tcp)) {
169 if (syserror(tcp)) {
170 tprintf("%#lx, %#lx",
171 tcp->u_arg[0], tcp->u_arg[1]);
172 return 0;
173 }
174 printtv(tcp, tcp->u_arg[0]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200175 tprints(", ");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000176 printtv(tcp, tcp->u_arg[1]);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000177 }
178 return 0;
179}
180
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +0000181#ifdef ALPHA
182int
Denys Vlasenko12014262011-05-30 14:00:14 +0200183sys_osf_gettimeofday(struct tcb *tcp)
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +0000184{
Denys Vlasenko1d632462009-04-14 12:51:00 +0000185 if (exiting(tcp)) {
186 if (syserror(tcp)) {
187 tprintf("%#lx, %#lx", tcp->u_arg[0], tcp->u_arg[1]);
188 return 0;
189 }
190 printtv_bitness(tcp, tcp->u_arg[0], BITNESS_32, 0);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200191 tprints(", ");
Denys Vlasenko1d632462009-04-14 12:51:00 +0000192 printtv_bitness(tcp, tcp->u_arg[1], BITNESS_32, 0);
Denys Vlasenko1d632462009-04-14 12:51:00 +0000193 }
194 return 0;
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +0000195}
196#endif
197
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000198int
Denys Vlasenko12014262011-05-30 14:00:14 +0200199sys_settimeofday(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000200{
201 if (entering(tcp)) {
202 printtv(tcp, tcp->u_arg[0]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200203 tprints(", ");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000204 printtv(tcp, tcp->u_arg[1]);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000205 }
206 return 0;
207}
208
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +0000209#ifdef ALPHA
210int
Denys Vlasenko12014262011-05-30 14:00:14 +0200211sys_osf_settimeofday(struct tcb *tcp)
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +0000212{
Denys Vlasenko1d632462009-04-14 12:51:00 +0000213 if (entering(tcp)) {
214 printtv_bitness(tcp, tcp->u_arg[0], BITNESS_32, 0);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200215 tprints(", ");
Denys Vlasenko1d632462009-04-14 12:51:00 +0000216 printtv_bitness(tcp, tcp->u_arg[1], BITNESS_32, 0);
Denys Vlasenko1d632462009-04-14 12:51:00 +0000217 }
218 return 0;
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +0000219}
220#endif
221
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000222int
Denys Vlasenko12014262011-05-30 14:00:14 +0200223sys_adjtime(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000224{
225 if (entering(tcp)) {
226 printtv(tcp, tcp->u_arg[0]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200227 tprints(", ");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000228 } else {
229 if (syserror(tcp))
230 tprintf("%#lx", tcp->u_arg[1]);
231 else
232 printtv(tcp, tcp->u_arg[1]);
233 }
234 return 0;
235}
236
Dmitry V. Levin2e55ff42008-09-03 01:02:46 +0000237int
238sys_nanosleep(struct tcb *tcp)
239{
240 if (entering(tcp)) {
241 print_timespec(tcp, tcp->u_arg[0]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200242 tprints(", ");
Dmitry V. Levin2e55ff42008-09-03 01:02:46 +0000243 } else {
Denys Vlasenko64acaa12012-01-28 02:29:36 +0100244 /* Second (returned) timespec is only significant
Denys Vlasenko47932212013-06-30 23:53:49 +0200245 * if syscall was interrupted. On success, we print
246 * only its address, since kernel doesn't modify it,
247 * and printing the value may show uninitialized data.
Denys Vlasenko64acaa12012-01-28 02:29:36 +0100248 */
Denys Vlasenko47932212013-06-30 23:53:49 +0200249 switch (tcp->u_error) {
250 default:
251 /* Not interrupted (slept entire interval) */
252 if (tcp->u_arg[1]) {
253 tprintf("%#lx", tcp->u_arg[1]);
254 break;
255 }
256 /* Fall through: print_timespec(NULL) prints "NULL" */
257 case ERESTARTSYS:
258 case ERESTARTNOINTR:
259 case ERESTARTNOHAND:
260 case ERESTART_RESTARTBLOCK:
261 /* Interrupted */
Dmitry V. Levin2e55ff42008-09-03 01:02:46 +0000262 print_timespec(tcp, tcp->u_arg[1]);
Denys Vlasenko47932212013-06-30 23:53:49 +0200263 }
Dmitry V. Levin2e55ff42008-09-03 01:02:46 +0000264 }
265 return 0;
266}
267
Dmitry V. Levin0ed617b2014-04-25 23:30:54 +0000268#include "xlat/itimer_which.h"
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000269
270static void
Dmitry V. Levin1cad25d2006-12-13 17:14:36 +0000271printitv_bitness(struct tcb *tcp, long addr, enum bitness_t bitness)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000272{
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000273 if (addr == 0)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200274 tprints("NULL");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000275 else if (!verbose(tcp))
276 tprintf("%#lx", addr);
Denys Vlasenko1d632462009-04-14 12:51:00 +0000277 else {
278 int rc;
Dmitry V. Levin1cad25d2006-12-13 17:14:36 +0000279
280 if (bitness == BITNESS_32
Denys Vlasenko84703742012-02-25 02:38:52 +0100281#if SUPPORTED_PERSONALITIES > 1
Denys Vlasenko9fd4f962012-03-19 09:36:42 +0100282 || current_wordsize == 4
Dmitry V. Levin1cad25d2006-12-13 17:14:36 +0000283#endif
284 )
285 {
Denys Vlasenko1d632462009-04-14 12:51:00 +0000286 struct {
Dmitry V. Levin1cad25d2006-12-13 17:14:36 +0000287 struct timeval32 it_interval, it_value;
288 } itv;
289
Denys Vlasenko5d645812011-08-20 12:48:18 +0200290 rc = umove(tcp, addr, &itv);
291 if (rc >= 0) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200292 tprints("{it_interval=");
Dmitry V. Levin1cad25d2006-12-13 17:14:36 +0000293 tprint_timeval32(tcp, &itv.it_interval);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200294 tprints(", it_value=");
Dmitry V. Levin1cad25d2006-12-13 17:14:36 +0000295 tprint_timeval32(tcp, &itv.it_value);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200296 tprints("}");
Roland McGrathe4662342007-08-02 01:25:34 +0000297 }
Denys Vlasenko1d632462009-04-14 12:51:00 +0000298 } else {
Dmitry V. Levin1cad25d2006-12-13 17:14:36 +0000299 struct itimerval itv;
300
Denys Vlasenko5d645812011-08-20 12:48:18 +0200301 rc = umove(tcp, addr, &itv);
302 if (rc >= 0) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200303 tprints("{it_interval=");
Dmitry V. Levin1cad25d2006-12-13 17:14:36 +0000304 tprint_timeval(tcp, &itv.it_interval);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200305 tprints(", it_value=");
Dmitry V. Levin1cad25d2006-12-13 17:14:36 +0000306 tprint_timeval(tcp, &itv.it_value);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200307 tprints("}");
Roland McGrathe4662342007-08-02 01:25:34 +0000308 }
Dmitry V. Levin1cad25d2006-12-13 17:14:36 +0000309 }
Dmitry V. Levin1cad25d2006-12-13 17:14:36 +0000310 if (rc < 0)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200311 tprints("{...}");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000312 }
313}
314
Dmitry V. Levin1cad25d2006-12-13 17:14:36 +0000315#define printitv(tcp, addr) \
316 printitv_bitness((tcp), (addr), BITNESS_CURRENT)
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +0000317
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000318int
Denys Vlasenko12014262011-05-30 14:00:14 +0200319sys_getitimer(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000320{
321 if (entering(tcp)) {
Dmitry V. Levin297b5942014-04-25 23:39:20 +0000322 printxval(itimer_which, tcp->u_arg[0], "ITIMER_???");
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200323 tprints(", ");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000324 } else {
325 if (syserror(tcp))
326 tprintf("%#lx", tcp->u_arg[1]);
327 else
328 printitv(tcp, tcp->u_arg[1]);
329 }
330 return 0;
331}
332
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +0000333#ifdef ALPHA
334int
Denys Vlasenko12014262011-05-30 14:00:14 +0200335sys_osf_getitimer(struct tcb *tcp)
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +0000336{
Denys Vlasenko1d632462009-04-14 12:51:00 +0000337 if (entering(tcp)) {
Dmitry V. Levin297b5942014-04-25 23:39:20 +0000338 printxval(itimer_which, tcp->u_arg[0], "ITIMER_???");
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200339 tprints(", ");
Denys Vlasenko1d632462009-04-14 12:51:00 +0000340 } else {
341 if (syserror(tcp))
342 tprintf("%#lx", tcp->u_arg[1]);
343 else
344 printitv_bitness(tcp, tcp->u_arg[1], BITNESS_32);
345 }
346 return 0;
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +0000347}
348#endif
349
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000350int
Denys Vlasenko12014262011-05-30 14:00:14 +0200351sys_setitimer(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000352{
353 if (entering(tcp)) {
Dmitry V. Levin297b5942014-04-25 23:39:20 +0000354 printxval(itimer_which, tcp->u_arg[0], "ITIMER_???");
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200355 tprints(", ");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000356 printitv(tcp, tcp->u_arg[1]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200357 tprints(", ");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000358 } else {
359 if (syserror(tcp))
360 tprintf("%#lx", tcp->u_arg[2]);
361 else
362 printitv(tcp, tcp->u_arg[2]);
363 }
364 return 0;
365}
366
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +0000367#ifdef ALPHA
368int
Denys Vlasenko12014262011-05-30 14:00:14 +0200369sys_osf_setitimer(struct tcb *tcp)
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +0000370{
Denys Vlasenko1d632462009-04-14 12:51:00 +0000371 if (entering(tcp)) {
Dmitry V. Levin297b5942014-04-25 23:39:20 +0000372 printxval(itimer_which, tcp->u_arg[0], "ITIMER_???");
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200373 tprints(", ");
Denys Vlasenko1d632462009-04-14 12:51:00 +0000374 printitv_bitness(tcp, tcp->u_arg[1], BITNESS_32);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200375 tprints(", ");
Denys Vlasenko1d632462009-04-14 12:51:00 +0000376 } else {
377 if (syserror(tcp))
378 tprintf("%#lx", tcp->u_arg[2]);
379 else
380 printitv_bitness(tcp, tcp->u_arg[2], BITNESS_32);
381 }
382 return 0;
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +0000383}
384#endif
385
Dmitry V. Levin0ed617b2014-04-25 23:30:54 +0000386#include "xlat/adjtimex_modes.h"
Dmitry V. Levin0ed617b2014-04-25 23:30:54 +0000387#include "xlat/adjtimex_status.h"
Dmitry V. Levin0ed617b2014-04-25 23:30:54 +0000388#include "xlat/adjtimex_state.h"
Dmitry V. Levin1a684d62006-12-13 17:42:32 +0000389
Dmitry V. Levin165b15d2006-12-13 17:43:45 +0000390#if SUPPORTED_PERSONALITIES > 1
391static int
392tprint_timex32(struct tcb *tcp, long addr)
393{
Denys Vlasenko1d632462009-04-14 12:51:00 +0000394 struct {
Dmitry V. Levin165b15d2006-12-13 17:43:45 +0000395 unsigned int modes;
396 int offset;
397 int freq;
398 int maxerror;
399 int esterror;
400 int status;
401 int constant;
402 int precision;
403 int tolerance;
404 struct timeval32 time;
405 int tick;
406 int ppsfreq;
407 int jitter;
408 int shift;
409 int stabil;
410 int jitcnt;
411 int calcnt;
412 int errcnt;
413 int stbcnt;
414 } tx;
415
416 if (umove(tcp, addr, &tx) < 0)
417 return -1;
418
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200419 tprints("{modes=");
Dmitry V. Levin71d70892007-01-13 11:17:38 +0000420 printflags(adjtimex_modes, tx.modes, "ADJ_???");
Dmitry V. Levin165b15d2006-12-13 17:43:45 +0000421 tprintf(", offset=%d, freq=%d, maxerror=%d, ",
422 tx.offset, tx.freq, tx.maxerror);
423 tprintf("esterror=%u, status=", tx.esterror);
424 printflags(adjtimex_status, tx.status, "STA_???");
425 tprintf(", constant=%d, precision=%u, ",
426 tx.constant, tx.precision);
427 tprintf("tolerance=%d, time=", tx.tolerance);
428 tprint_timeval32(tcp, &tx.time);
429 tprintf(", tick=%d, ppsfreq=%d, jitter=%d",
430 tx.tick, tx.ppsfreq, tx.jitter);
431 tprintf(", shift=%d, stabil=%d, jitcnt=%d",
432 tx.shift, tx.stabil, tx.jitcnt);
433 tprintf(", calcnt=%d, errcnt=%d, stbcnt=%d",
434 tx.calcnt, tx.errcnt, tx.stbcnt);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200435 tprints("}");
Dmitry V. Levin165b15d2006-12-13 17:43:45 +0000436 return 0;
437}
438#endif /* SUPPORTED_PERSONALITIES > 1 */
439
440static int
441tprint_timex(struct tcb *tcp, long addr)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000442{
Dmitry V. Levin1a684d62006-12-13 17:42:32 +0000443 struct timex tx;
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000444
Dmitry V. Levin165b15d2006-12-13 17:43:45 +0000445#if SUPPORTED_PERSONALITIES > 1
Denys Vlasenko9fd4f962012-03-19 09:36:42 +0100446 if (current_wordsize == 4)
Dmitry V. Levin165b15d2006-12-13 17:43:45 +0000447 return tprint_timex32(tcp, addr);
448#endif
449 if (umove(tcp, addr, &tx) < 0)
450 return -1;
451
452#if LINUX_VERSION_CODE < 66332
453 tprintf("{mode=%d, offset=%ld, frequency=%ld, ",
454 tx.mode, tx.offset, tx.frequency);
455 tprintf("maxerror=%ld, esterror=%lu, status=%u, ",
456 tx.maxerror, tx.esterror, tx.status);
457 tprintf("time_constant=%ld, precision=%lu, ",
458 tx.time_constant, tx.precision);
459 tprintf("tolerance=%ld, time=", tx.tolerance);
460 tprint_timeval(tcp, &tx.time);
461#else
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200462 tprints("{modes=");
Dmitry V. Levin71d70892007-01-13 11:17:38 +0000463 printflags(adjtimex_modes, tx.modes, "ADJ_???");
Dmitry V. Levin165b15d2006-12-13 17:43:45 +0000464 tprintf(", offset=%ld, freq=%ld, maxerror=%ld, ",
H.J. Lu0b315b62012-02-03 10:16:03 -0800465 (long) tx.offset, (long) tx.freq, (long) tx.maxerror);
466 tprintf("esterror=%lu, status=", (long) tx.esterror);
Dmitry V. Levin165b15d2006-12-13 17:43:45 +0000467 printflags(adjtimex_status, tx.status, "STA_???");
468 tprintf(", constant=%ld, precision=%lu, ",
H.J. Lu0b315b62012-02-03 10:16:03 -0800469 (long) tx.constant, (long) tx.precision);
470 tprintf("tolerance=%ld, time=", (long) tx.tolerance);
Dmitry V. Levin165b15d2006-12-13 17:43:45 +0000471 tprint_timeval(tcp, &tx.time);
472 tprintf(", tick=%ld, ppsfreq=%ld, jitter=%ld",
H.J. Lu0b315b62012-02-03 10:16:03 -0800473 (long) tx.tick, (long) tx.ppsfreq, (long) tx.jitter);
Dmitry V. Levin165b15d2006-12-13 17:43:45 +0000474 tprintf(", shift=%d, stabil=%ld, jitcnt=%ld",
H.J. Lu0b315b62012-02-03 10:16:03 -0800475 tx.shift, (long) tx.stabil, (long) tx.jitcnt);
Dmitry V. Levin165b15d2006-12-13 17:43:45 +0000476 tprintf(", calcnt=%ld, errcnt=%ld, stbcnt=%ld",
H.J. Lu0b315b62012-02-03 10:16:03 -0800477 (long) tx.calcnt, (long) tx.errcnt, (long) tx.stbcnt);
Dmitry V. Levin165b15d2006-12-13 17:43:45 +0000478#endif
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200479 tprints("}");
Dmitry V. Levin165b15d2006-12-13 17:43:45 +0000480 return 0;
481}
482
Dmitry V. Levin73215472012-03-11 21:25:51 +0000483static int
484do_adjtimex(struct tcb *tcp, long addr)
485{
486 if (addr == 0)
487 tprints("NULL");
488 else if (syserror(tcp) || !verbose(tcp))
489 tprintf("%#lx", addr);
490 else if (tprint_timex(tcp, addr) < 0)
491 tprints("{...}");
492 if (syserror(tcp))
493 return 0;
494 tcp->auxstr = xlookup(adjtimex_state, tcp->u_rval);
495 if (tcp->auxstr)
496 return RVAL_STR;
497 return 0;
498}
499
Dmitry V. Levin165b15d2006-12-13 17:43:45 +0000500int
501sys_adjtimex(struct tcb *tcp)
502{
Dmitry V. Levin73215472012-03-11 21:25:51 +0000503 if (exiting(tcp))
504 return do_adjtimex(tcp, tcp->u_arg[0]);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000505 return 0;
506}
Roland McGrath1e356792003-03-30 23:52:28 +0000507
Dmitry V. Levin0ed617b2014-04-25 23:30:54 +0000508#include "xlat/clockflags.h"
Dmitry V. Levin0ed617b2014-04-25 23:30:54 +0000509#include "xlat/clocknames.h"
Roland McGrath54a4edd2004-08-31 06:52:45 +0000510
Stefan Sørensena5fea902014-02-03 10:01:27 +0100511static void
512printclockname(int clockid)
513{
514#ifdef CLOCKID_TO_FD
Dmitry V. Levind35bdca2014-04-26 18:10:19 +0000515# include "xlat/cpuclocknames.h"
516
Stefan Sørensena5fea902014-02-03 10:01:27 +0100517 if (clockid < 0) {
518 if ((clockid & CLOCKFD_MASK) == CLOCKFD)
519 tprintf("FD_TO_CLOCKID(%d)", CLOCKID_TO_FD(clockid));
520 else {
521 if(CPUCLOCK_PERTHREAD(clockid))
522 tprintf("MAKE_THREAD_CPUCLOCK(%d,", CPUCLOCK_PID(clockid));
523 else
524 tprintf("MAKE_PROCESS_CPUCLOCK(%d,", CPUCLOCK_PID(clockid));
525 printxval(cpuclocknames, clockid & CLOCKFD_MASK, "CPUCLOCK_???");
526 tprints(")");
527 }
528 }
529 else
530#endif
531 printxval(clocknames, clockid, "CLOCK_???");
532}
533
Roland McGrath1e356792003-03-30 23:52:28 +0000534int
Denys Vlasenko12014262011-05-30 14:00:14 +0200535sys_clock_settime(struct tcb *tcp)
Roland McGrath1e356792003-03-30 23:52:28 +0000536{
537 if (entering(tcp)) {
Stefan Sørensena5fea902014-02-03 10:01:27 +0100538 printclockname(tcp->u_arg[0]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200539 tprints(", ");
Roland McGrath1e356792003-03-30 23:52:28 +0000540 printtv(tcp, tcp->u_arg[1]);
541 }
542 return 0;
543}
544
545int
Denys Vlasenko12014262011-05-30 14:00:14 +0200546sys_clock_gettime(struct tcb *tcp)
Roland McGrath1e356792003-03-30 23:52:28 +0000547{
548 if (entering(tcp)) {
Stefan Sørensena5fea902014-02-03 10:01:27 +0100549 printclockname(tcp->u_arg[0]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200550 tprints(", ");
Roland McGrath1e356792003-03-30 23:52:28 +0000551 } else {
552 if (syserror(tcp))
553 tprintf("%#lx", tcp->u_arg[1]);
554 else
555 printtv(tcp, tcp->u_arg[1]);
556 }
557 return 0;
558}
559
560int
Denys Vlasenko12014262011-05-30 14:00:14 +0200561sys_clock_nanosleep(struct tcb *tcp)
Roland McGrath1e356792003-03-30 23:52:28 +0000562{
563 if (entering(tcp)) {
Stefan Sørensena5fea902014-02-03 10:01:27 +0100564 printclockname(tcp->u_arg[0]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200565 tprints(", ");
Roland McGrathb2dee132005-06-01 19:02:36 +0000566 printflags(clockflags, tcp->u_arg[1], "TIMER_???");
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200567 tprints(", ");
Roland McGrath1e356792003-03-30 23:52:28 +0000568 printtv(tcp, tcp->u_arg[2]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200569 tprints(", ");
Roland McGrath1e356792003-03-30 23:52:28 +0000570 } else {
571 if (syserror(tcp))
572 tprintf("%#lx", tcp->u_arg[3]);
573 else
574 printtv(tcp, tcp->u_arg[3]);
575 }
576 return 0;
577}
578
Dmitry V. Levin73215472012-03-11 21:25:51 +0000579int
580sys_clock_adjtime(struct tcb *tcp)
581{
582 if (exiting(tcp))
583 return do_adjtimex(tcp, tcp->u_arg[1]);
Stefan Sørensena5fea902014-02-03 10:01:27 +0100584 printclockname(tcp->u_arg[0]);
Dmitry V. Levin73215472012-03-11 21:25:51 +0000585 tprints(", ");
586 return 0;
587}
588
Roland McGrath1e356792003-03-30 23:52:28 +0000589#ifndef SIGEV_THREAD_ID
590# define SIGEV_THREAD_ID 4
591#endif
Dmitry V. Levin0ed617b2014-04-25 23:30:54 +0000592#include "xlat/sigev_value.h"
Roland McGrath1e356792003-03-30 23:52:28 +0000593
Dmitry V. Levind3cb3922006-12-13 17:45:02 +0000594#if SUPPORTED_PERSONALITIES > 1
595static void
596printsigevent32(struct tcb *tcp, long arg)
597{
Denys Vlasenko1d632462009-04-14 12:51:00 +0000598 struct {
Dmitry V. Levind3cb3922006-12-13 17:45:02 +0000599 int sigev_value;
600 int sigev_signo;
601 int sigev_notify;
602
Denys Vlasenko1d632462009-04-14 12:51:00 +0000603 union {
Dmitry V. Levind3cb3922006-12-13 17:45:02 +0000604 int tid;
Denys Vlasenko1d632462009-04-14 12:51:00 +0000605 struct {
Dmitry V. Levind3cb3922006-12-13 17:45:02 +0000606 int function, attribute;
607 } thread;
608 } un;
609 } sev;
610
611 if (umove(tcp, arg, &sev) < 0)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200612 tprints("{...}");
Denys Vlasenko1d632462009-04-14 12:51:00 +0000613 else {
Dmitry V. Levind3cb3922006-12-13 17:45:02 +0000614 tprintf("{%#x, ", sev.sigev_value);
615 if (sev.sigev_notify == SIGEV_SIGNAL)
616 tprintf("%s, ", signame(sev.sigev_signo));
617 else
618 tprintf("%u, ", sev.sigev_signo);
Dmitry V. Levinbae549e2014-02-05 01:46:10 +0000619 printxval(sigev_value, sev.sigev_notify, "SIGEV_???");
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200620 tprints(", ");
Dmitry V. Levind3cb3922006-12-13 17:45:02 +0000621 if (sev.sigev_notify == SIGEV_THREAD_ID)
622 tprintf("{%d}", sev.un.tid);
623 else if (sev.sigev_notify == SIGEV_THREAD)
624 tprintf("{%#x, %#x}",
625 sev.un.thread.function,
626 sev.un.thread.attribute);
627 else
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200628 tprints("{...}");
629 tprints("}");
Dmitry V. Levind3cb3922006-12-13 17:45:02 +0000630 }
631}
632#endif
633
Roland McGrath1e356792003-03-30 23:52:28 +0000634void
Dmitry V. Levind3cb3922006-12-13 17:45:02 +0000635printsigevent(struct tcb *tcp, long arg)
Roland McGrath1e356792003-03-30 23:52:28 +0000636{
637 struct sigevent sev;
Dmitry V. Levind3cb3922006-12-13 17:45:02 +0000638
639#if SUPPORTED_PERSONALITIES > 1
Denys Vlasenko9fd4f962012-03-19 09:36:42 +0100640 if (current_wordsize == 4) {
Dmitry V. Levind3cb3922006-12-13 17:45:02 +0000641 printsigevent32(tcp, arg);
642 return;
643 }
644#endif
Denys Vlasenkob63256e2011-06-07 12:13:24 +0200645 if (umove(tcp, arg, &sev) < 0)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200646 tprints("{...}");
Roland McGrath1e356792003-03-30 23:52:28 +0000647 else {
Roland McGrath675d4a62004-09-11 08:12:45 +0000648 tprintf("{%p, ", sev.sigev_value.sival_ptr);
649 if (sev.sigev_notify == SIGEV_SIGNAL)
650 tprintf("%s, ", signame(sev.sigev_signo));
651 else
652 tprintf("%u, ", sev.sigev_signo);
Dmitry V. Levinbae549e2014-02-05 01:46:10 +0000653 printxval(sigev_value, sev.sigev_notify, "SIGEV_???");
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200654 tprints(", ");
Roland McGrath1e356792003-03-30 23:52:28 +0000655 if (sev.sigev_notify == SIGEV_THREAD_ID)
Dmitry V. Levinae5aa472013-11-11 23:54:30 +0000656#if defined(HAVE_STRUCT_SIGEVENT__SIGEV_UN__PAD)
Roland McGrath1e356792003-03-30 23:52:28 +0000657 /* _pad[0] is the _tid field which might not be
658 present in the userlevel definition of the
659 struct. */
660 tprintf("{%d}", sev._sigev_un._pad[0]);
Dmitry V. Levinae5aa472013-11-11 23:54:30 +0000661#elif defined(HAVE_STRUCT_SIGEVENT___PAD)
662 tprintf("{%d}", sev.__pad[0]);
663#else
664# warning unfamiliar struct sigevent => incomplete SIGEV_THREAD_ID decoding
665 tprints("{...}");
666#endif
Roland McGrathd4c85eb2004-04-16 21:48:44 +0000667 else if (sev.sigev_notify == SIGEV_THREAD)
668 tprintf("{%p, %p}", sev.sigev_notify_function,
669 sev.sigev_notify_attributes);
Roland McGrath1e356792003-03-30 23:52:28 +0000670 else
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200671 tprints("{...}");
672 tprints("}");
Roland McGrath1e356792003-03-30 23:52:28 +0000673 }
674}
675
676int
Denys Vlasenko12014262011-05-30 14:00:14 +0200677sys_timer_create(struct tcb *tcp)
Roland McGrath1e356792003-03-30 23:52:28 +0000678{
679 if (entering(tcp)) {
Stefan Sørensena5fea902014-02-03 10:01:27 +0100680 printclockname(tcp->u_arg[0]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200681 tprints(", ");
Roland McGrath1e356792003-03-30 23:52:28 +0000682 printsigevent(tcp, tcp->u_arg[1]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200683 tprints(", ");
Roland McGrath1e356792003-03-30 23:52:28 +0000684 } else {
Andi Kleen732f3962011-06-13 21:37:40 +0000685 int timer_id;
Dmitry V. Levinac518d12006-12-13 17:03:02 +0000686
Andi Kleen732f3962011-06-13 21:37:40 +0000687 if (syserror(tcp) || umove(tcp, tcp->u_arg[2], &timer_id) < 0)
Roland McGrath1e356792003-03-30 23:52:28 +0000688 tprintf("%#lx", tcp->u_arg[2]);
Dmitry V. Levinac518d12006-12-13 17:03:02 +0000689 else
Andi Kleen732f3962011-06-13 21:37:40 +0000690 tprintf("{%d}", timer_id);
Roland McGrath1e356792003-03-30 23:52:28 +0000691 }
692 return 0;
693}
694
695int
Denys Vlasenko12014262011-05-30 14:00:14 +0200696sys_timer_settime(struct tcb *tcp)
Roland McGrath1e356792003-03-30 23:52:28 +0000697{
698 if (entering(tcp)) {
699 tprintf("%#lx, ", tcp->u_arg[0]);
Roland McGrathb2dee132005-06-01 19:02:36 +0000700 printflags(clockflags, tcp->u_arg[1], "TIMER_???");
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200701 tprints(", ");
Roland McGrath1e356792003-03-30 23:52:28 +0000702 printitv(tcp, tcp->u_arg[2]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200703 tprints(", ");
Roland McGrath1e356792003-03-30 23:52:28 +0000704 } else {
705 if (syserror(tcp))
706 tprintf("%#lx", tcp->u_arg[3]);
707 else
708 printitv(tcp, tcp->u_arg[3]);
709 }
710 return 0;
711}
712
713int
Denys Vlasenko12014262011-05-30 14:00:14 +0200714sys_timer_gettime(struct tcb *tcp)
Roland McGrath1e356792003-03-30 23:52:28 +0000715{
716 if (entering(tcp)) {
717 tprintf("%#lx, ", tcp->u_arg[0]);
718 } else {
719 if (syserror(tcp))
720 tprintf("%#lx", tcp->u_arg[1]);
721 else
722 printitv(tcp, tcp->u_arg[1]);
723 }
724 return 0;
725}
Roland McGrathd83c50b2004-10-06 22:27:43 +0000726
727static void
Denys Vlasenko12014262011-05-30 14:00:14 +0200728print_rtc(struct tcb *tcp, const struct rtc_time *rt)
Roland McGrathd83c50b2004-10-06 22:27:43 +0000729{
730 tprintf("{tm_sec=%d, tm_min=%d, tm_hour=%d, "
731 "tm_mday=%d, tm_mon=%d, tm_year=%d, ",
732 rt->tm_sec, rt->tm_min, rt->tm_hour,
733 rt->tm_mday, rt->tm_mon, rt->tm_year);
734 if (!abbrev(tcp))
735 tprintf("tm_wday=%d, tm_yday=%d, tm_isdst=%d}",
736 rt->tm_wday, rt->tm_yday, rt->tm_isdst);
737 else
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200738 tprints("...}");
Roland McGrathd83c50b2004-10-06 22:27:43 +0000739}
740
741int
Dmitry V. Levinc7afb482015-01-19 18:44:21 +0000742rtc_ioctl(struct tcb *tcp, const unsigned int code, long arg)
Roland McGrathd83c50b2004-10-06 22:27:43 +0000743{
744 switch (code) {
745 case RTC_ALM_SET:
746 case RTC_SET_TIME:
747 if (entering(tcp)) {
748 struct rtc_time rt;
749 if (umove(tcp, arg, &rt) < 0)
750 tprintf(", %#lx", arg);
751 else {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200752 tprints(", ");
Roland McGrathd83c50b2004-10-06 22:27:43 +0000753 print_rtc(tcp, &rt);
754 }
755 }
756 break;
757 case RTC_ALM_READ:
758 case RTC_RD_TIME:
759 if (exiting(tcp)) {
760 struct rtc_time rt;
761 if (syserror(tcp) || umove(tcp, arg, &rt) < 0)
762 tprintf(", %#lx", arg);
763 else {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200764 tprints(", ");
Roland McGrathd83c50b2004-10-06 22:27:43 +0000765 print_rtc(tcp, &rt);
766 }
767 }
768 break;
769 case RTC_IRQP_SET:
770 case RTC_EPOCH_SET:
771 if (entering(tcp))
772 tprintf(", %lu", arg);
773 break;
774 case RTC_IRQP_READ:
775 case RTC_EPOCH_READ:
776 if (exiting(tcp))
777 tprintf(", %lu", arg);
778 break;
779 case RTC_WKALM_SET:
780 if (entering(tcp)) {
781 struct rtc_wkalrm wk;
782 if (umove(tcp, arg, &wk) < 0)
783 tprintf(", %#lx", arg);
784 else {
785 tprintf(", {enabled=%d, pending=%d, ",
786 wk.enabled, wk.pending);
787 print_rtc(tcp, &wk.time);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200788 tprints("}");
Roland McGrathd83c50b2004-10-06 22:27:43 +0000789 }
790 }
791 break;
792 case RTC_WKALM_RD:
793 if (exiting(tcp)) {
794 struct rtc_wkalrm wk;
795 if (syserror(tcp) || umove(tcp, arg, &wk) < 0)
796 tprintf(", %#lx", arg);
797 else {
798 tprintf(", {enabled=%d, pending=%d, ",
799 wk.enabled, wk.pending);
800 print_rtc(tcp, &wk.time);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200801 tprints("}");
Roland McGrathd83c50b2004-10-06 22:27:43 +0000802 }
803 }
804 break;
805 default:
806 if (entering(tcp))
807 tprintf(", %#lx", arg);
808 break;
809 }
810 return 1;
811}
Roland McGrathe4662342007-08-02 01:25:34 +0000812
Dmitry V. Levin0ed617b2014-04-25 23:30:54 +0000813#include "xlat/timerfdflags.h"
Roland McGrathe4662342007-08-02 01:25:34 +0000814
815int
Denys Vlasenko12014262011-05-30 14:00:14 +0200816sys_timerfd(struct tcb *tcp)
Roland McGrathe4662342007-08-02 01:25:34 +0000817{
818 if (entering(tcp)) {
819 /* It does not matter that the kernel uses itimerspec. */
820 tprintf("%ld, ", tcp->u_arg[0]);
Stefan Sørensena5fea902014-02-03 10:01:27 +0100821 printclockname(tcp->u_arg[0]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200822 tprints(", ");
Roland McGrathe4662342007-08-02 01:25:34 +0000823 printflags(timerfdflags, tcp->u_arg[2], "TFD_???");
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200824 tprints(", ");
Roland McGrathe4662342007-08-02 01:25:34 +0000825 printitv(tcp, tcp->u_arg[3]);
826 }
827 return 0;
828}
Roland McGrathde328e62008-05-20 04:56:13 +0000829
830int
831sys_timerfd_create(struct tcb *tcp)
832{
833 if (entering(tcp)) {
Stefan Sørensena5fea902014-02-03 10:01:27 +0100834 printclockname(tcp->u_arg[0]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200835 tprints(", ");
Roland McGrathde328e62008-05-20 04:56:13 +0000836 printflags(timerfdflags, tcp->u_arg[1], "TFD_???");
837 }
838 return 0;
839}
840
841int
842sys_timerfd_settime(struct tcb *tcp)
843{
844 if (entering(tcp)) {
Dmitry V. Levin31382132011-03-04 05:08:02 +0300845 printfd(tcp, tcp->u_arg[0]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200846 tprints(", ");
Roland McGrathde328e62008-05-20 04:56:13 +0000847 printflags(timerfdflags, tcp->u_arg[1], "TFD_???");
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200848 tprints(", ");
Roland McGrathde328e62008-05-20 04:56:13 +0000849 printitv(tcp, tcp->u_arg[2]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200850 tprints(", ");
Roland McGrathde328e62008-05-20 04:56:13 +0000851 printitv(tcp, tcp->u_arg[3]);
852 }
853 return 0;
854}
855
856int
857sys_timerfd_gettime(struct tcb *tcp)
858{
859 if (entering(tcp)) {
Dmitry V. Levin31382132011-03-04 05:08:02 +0300860 printfd(tcp, tcp->u_arg[0]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200861 tprints(", ");
Roland McGrathde328e62008-05-20 04:56:13 +0000862 printitv(tcp, tcp->u_arg[1]);
863 }
864 return 0;
865}