blob: 1ad90d9ad7ddba193583aa28356f5ce1408d168d [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
Denys Vlasenko2fb4db32011-08-31 12:26:03 +020069char *
Denys Vlasenkoa1d541e2012-01-20 11:04:04 +010070sprinttv(char *buf, struct tcb *tcp, long addr, enum bitness_t bitness, int special)
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +000071{
Denys Vlasenko2fb4db32011-08-31 12:26:03 +020072 int rc;
73
Dmitry V. Levina7945a32006-12-13 17:10:11 +000074 if (addr == 0)
Denys Vlasenko2fb4db32011-08-31 12:26:03 +020075 return stpcpy(buf, "NULL");
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +000076
Denys Vlasenkob9c7ae62011-09-01 11:40:40 +020077 if (!verbose(tcp))
78 return buf + sprintf(buf, "%#lx", addr);
Denys Vlasenko2fb4db32011-08-31 12:26:03 +020079
80 if (bitness == BITNESS_32
Denys Vlasenko84703742012-02-25 02:38:52 +010081#if SUPPORTED_PERSONALITIES > 1
Denys Vlasenko9fd4f962012-03-19 09:36:42 +010082 || current_wordsize == 4
Denys Vlasenko2fb4db32011-08-31 12:26:03 +020083#endif
84 )
85 {
86 struct timeval32 tv;
87
88 rc = umove(tcp, addr, &tv);
Denys Vlasenkoa1d541e2012-01-20 11:04:04 +010089 if (rc >= 0) {
90 if (special && tv.tv_sec == 0) {
91 if (tv.tv_usec == UTIME_NOW)
92 return stpcpy(buf, "UTIME_NOW");
93 if (tv.tv_usec == UTIME_OMIT)
94 return stpcpy(buf, "UTIME_OMIT");
95 }
Denys Vlasenkob9c7ae62011-09-01 11:40:40 +020096 return buf + sprintf(buf, "{%u, %u}",
Denys Vlasenko2fb4db32011-08-31 12:26:03 +020097 tv.tv_sec, tv.tv_usec);
Denys Vlasenkoa1d541e2012-01-20 11:04:04 +010098 }
Denys Vlasenko2fb4db32011-08-31 12:26:03 +020099 } else {
100 struct timeval tv;
101
102 rc = umove(tcp, addr, &tv);
Denys Vlasenkoa1d541e2012-01-20 11:04:04 +0100103 if (rc >= 0) {
104 if (special && tv.tv_sec == 0) {
105 if (tv.tv_usec == UTIME_NOW)
106 return stpcpy(buf, "UTIME_NOW");
107 if (tv.tv_usec == UTIME_OMIT)
108 return stpcpy(buf, "UTIME_OMIT");
109 }
Denys Vlasenkob9c7ae62011-09-01 11:40:40 +0200110 return buf + sprintf(buf, "{%lu, %lu}",
Denys Vlasenko2fb4db32011-08-31 12:26:03 +0200111 (unsigned long) tv.tv_sec,
112 (unsigned long) tv.tv_usec);
Denys Vlasenkoa1d541e2012-01-20 11:04:04 +0100113 }
Denys Vlasenko2fb4db32011-08-31 12:26:03 +0200114 }
Denys Vlasenko2fb4db32011-08-31 12:26:03 +0200115
Denys Vlasenkob9c7ae62011-09-01 11:40:40 +0200116 return stpcpy(buf, "{...}");
Dmitry V. Levina7945a32006-12-13 17:10:11 +0000117}
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +0000118
Denys Vlasenkoa1d541e2012-01-20 11:04:04 +0100119void
120print_timespec(struct tcb *tcp, long addr)
Roland McGrath6bc09da2007-11-01 21:50:54 +0000121{
Denys Vlasenkoa1d541e2012-01-20 11:04:04 +0100122 char buf[TIMESPEC_TEXT_BUFSIZE];
123 sprint_timespec(buf, tcp, addr);
124 tprints(buf);
Roland McGrath6bc09da2007-11-01 21:50:54 +0000125}
126
Denys Vlasenkoa1d541e2012-01-20 11:04:04 +0100127void
128sprint_timespec(char *buf, struct tcb *tcp, long addr)
Roland McGrath6bc09da2007-11-01 21:50:54 +0000129{
130 if (addr == 0)
131 strcpy(buf, "NULL");
132 else if (!verbose(tcp))
133 sprintf(buf, "%#lx", addr);
134 else {
Denys Vlasenko1d632462009-04-14 12:51:00 +0000135 int rc;
Roland McGrath6bc09da2007-11-01 21:50:54 +0000136
Denys Vlasenko84703742012-02-25 02:38:52 +0100137#if SUPPORTED_PERSONALITIES > 1
Denys Vlasenko9fd4f962012-03-19 09:36:42 +0100138 if (current_wordsize == 4) {
Roland McGrath6bc09da2007-11-01 21:50:54 +0000139 struct timeval32 tv;
140
Denys Vlasenko5d645812011-08-20 12:48:18 +0200141 rc = umove(tcp, addr, &tv);
142 if (rc >= 0)
Roland McGrath6bc09da2007-11-01 21:50:54 +0000143 sprintf(buf, "{%u, %u}",
144 tv.tv_sec, tv.tv_usec);
145 } else
Roland McGrath6bc09da2007-11-01 21:50:54 +0000146#endif
Denys Vlasenko1d632462009-04-14 12:51:00 +0000147 {
Roland McGrath6bc09da2007-11-01 21:50:54 +0000148 struct timespec ts;
149
Denys Vlasenko5d645812011-08-20 12:48:18 +0200150 rc = umove(tcp, addr, &ts);
151 if (rc >= 0)
Roland McGrath6bc09da2007-11-01 21:50:54 +0000152 sprintf(buf, "{%lu, %lu}",
153 (unsigned long) ts.tv_sec,
154 (unsigned long) ts.tv_nsec);
Roland McGrath6bc09da2007-11-01 21:50:54 +0000155 }
Roland McGrath6bc09da2007-11-01 21:50:54 +0000156 if (rc < 0)
157 strcpy(buf, "{...}");
158 }
159}
160
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000161int
Denys Vlasenko12014262011-05-30 14:00:14 +0200162sys_time(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000163{
164 if (exiting(tcp)) {
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000165 printnum(tcp, tcp->u_arg[0], "%ld");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000166 }
167 return 0;
168}
169
170int
Denys Vlasenko12014262011-05-30 14:00:14 +0200171sys_stime(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000172{
173 if (exiting(tcp)) {
174 printnum(tcp, tcp->u_arg[0], "%ld");
175 }
176 return 0;
177}
178
179int
Denys Vlasenko12014262011-05-30 14:00:14 +0200180sys_gettimeofday(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000181{
182 if (exiting(tcp)) {
183 if (syserror(tcp)) {
184 tprintf("%#lx, %#lx",
185 tcp->u_arg[0], tcp->u_arg[1]);
186 return 0;
187 }
188 printtv(tcp, tcp->u_arg[0]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200189 tprints(", ");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000190 printtv(tcp, tcp->u_arg[1]);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000191 }
192 return 0;
193}
194
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +0000195#ifdef ALPHA
196int
Denys Vlasenko12014262011-05-30 14:00:14 +0200197sys_osf_gettimeofday(struct tcb *tcp)
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +0000198{
Denys Vlasenko1d632462009-04-14 12:51:00 +0000199 if (exiting(tcp)) {
200 if (syserror(tcp)) {
201 tprintf("%#lx, %#lx", tcp->u_arg[0], tcp->u_arg[1]);
202 return 0;
203 }
204 printtv_bitness(tcp, tcp->u_arg[0], BITNESS_32, 0);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200205 tprints(", ");
Denys Vlasenko1d632462009-04-14 12:51:00 +0000206 printtv_bitness(tcp, tcp->u_arg[1], BITNESS_32, 0);
Denys Vlasenko1d632462009-04-14 12:51:00 +0000207 }
208 return 0;
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +0000209}
210#endif
211
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000212int
Denys Vlasenko12014262011-05-30 14:00:14 +0200213sys_settimeofday(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000214{
215 if (entering(tcp)) {
216 printtv(tcp, tcp->u_arg[0]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200217 tprints(", ");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000218 printtv(tcp, tcp->u_arg[1]);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000219 }
220 return 0;
221}
222
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +0000223#ifdef ALPHA
224int
Denys Vlasenko12014262011-05-30 14:00:14 +0200225sys_osf_settimeofday(struct tcb *tcp)
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +0000226{
Denys Vlasenko1d632462009-04-14 12:51:00 +0000227 if (entering(tcp)) {
228 printtv_bitness(tcp, tcp->u_arg[0], BITNESS_32, 0);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200229 tprints(", ");
Denys Vlasenko1d632462009-04-14 12:51:00 +0000230 printtv_bitness(tcp, tcp->u_arg[1], BITNESS_32, 0);
Denys Vlasenko1d632462009-04-14 12:51:00 +0000231 }
232 return 0;
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +0000233}
234#endif
235
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000236int
Denys Vlasenko12014262011-05-30 14:00:14 +0200237sys_adjtime(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000238{
239 if (entering(tcp)) {
240 printtv(tcp, tcp->u_arg[0]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200241 tprints(", ");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000242 } else {
243 if (syserror(tcp))
244 tprintf("%#lx", tcp->u_arg[1]);
245 else
246 printtv(tcp, tcp->u_arg[1]);
247 }
248 return 0;
249}
250
Dmitry V. Levin2e55ff42008-09-03 01:02:46 +0000251int
252sys_nanosleep(struct tcb *tcp)
253{
254 if (entering(tcp)) {
255 print_timespec(tcp, tcp->u_arg[0]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200256 tprints(", ");
Dmitry V. Levin2e55ff42008-09-03 01:02:46 +0000257 } else {
Denys Vlasenko64acaa12012-01-28 02:29:36 +0100258 /* Second (returned) timespec is only significant
Denys Vlasenko47932212013-06-30 23:53:49 +0200259 * if syscall was interrupted. On success, we print
260 * only its address, since kernel doesn't modify it,
261 * and printing the value may show uninitialized data.
Denys Vlasenko64acaa12012-01-28 02:29:36 +0100262 */
Denys Vlasenko47932212013-06-30 23:53:49 +0200263 switch (tcp->u_error) {
264 default:
265 /* Not interrupted (slept entire interval) */
266 if (tcp->u_arg[1]) {
267 tprintf("%#lx", tcp->u_arg[1]);
268 break;
269 }
270 /* Fall through: print_timespec(NULL) prints "NULL" */
271 case ERESTARTSYS:
272 case ERESTARTNOINTR:
273 case ERESTARTNOHAND:
274 case ERESTART_RESTARTBLOCK:
275 /* Interrupted */
Dmitry V. Levin2e55ff42008-09-03 01:02:46 +0000276 print_timespec(tcp, tcp->u_arg[1]);
Denys Vlasenko47932212013-06-30 23:53:49 +0200277 }
Dmitry V. Levin2e55ff42008-09-03 01:02:46 +0000278 }
279 return 0;
280}
281
Dmitry V. Levin0ed617b2014-04-25 23:30:54 +0000282#include "xlat/itimer_which.h"
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000283
284static void
Dmitry V. Levin1cad25d2006-12-13 17:14:36 +0000285printitv_bitness(struct tcb *tcp, long addr, enum bitness_t bitness)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000286{
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000287 if (addr == 0)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200288 tprints("NULL");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000289 else if (!verbose(tcp))
290 tprintf("%#lx", addr);
Denys Vlasenko1d632462009-04-14 12:51:00 +0000291 else {
292 int rc;
Dmitry V. Levin1cad25d2006-12-13 17:14:36 +0000293
294 if (bitness == BITNESS_32
Denys Vlasenko84703742012-02-25 02:38:52 +0100295#if SUPPORTED_PERSONALITIES > 1
Denys Vlasenko9fd4f962012-03-19 09:36:42 +0100296 || current_wordsize == 4
Dmitry V. Levin1cad25d2006-12-13 17:14:36 +0000297#endif
298 )
299 {
Denys Vlasenko1d632462009-04-14 12:51:00 +0000300 struct {
Dmitry V. Levin1cad25d2006-12-13 17:14:36 +0000301 struct timeval32 it_interval, it_value;
302 } itv;
303
Denys Vlasenko5d645812011-08-20 12:48:18 +0200304 rc = umove(tcp, addr, &itv);
305 if (rc >= 0) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200306 tprints("{it_interval=");
Dmitry V. Levin1cad25d2006-12-13 17:14:36 +0000307 tprint_timeval32(tcp, &itv.it_interval);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200308 tprints(", it_value=");
Dmitry V. Levin1cad25d2006-12-13 17:14:36 +0000309 tprint_timeval32(tcp, &itv.it_value);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200310 tprints("}");
Roland McGrathe4662342007-08-02 01:25:34 +0000311 }
Denys Vlasenko1d632462009-04-14 12:51:00 +0000312 } else {
Dmitry V. Levin1cad25d2006-12-13 17:14:36 +0000313 struct itimerval itv;
314
Denys Vlasenko5d645812011-08-20 12:48:18 +0200315 rc = umove(tcp, addr, &itv);
316 if (rc >= 0) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200317 tprints("{it_interval=");
Dmitry V. Levin1cad25d2006-12-13 17:14:36 +0000318 tprint_timeval(tcp, &itv.it_interval);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200319 tprints(", it_value=");
Dmitry V. Levin1cad25d2006-12-13 17:14:36 +0000320 tprint_timeval(tcp, &itv.it_value);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200321 tprints("}");
Roland McGrathe4662342007-08-02 01:25:34 +0000322 }
Dmitry V. Levin1cad25d2006-12-13 17:14:36 +0000323 }
Dmitry V. Levin1cad25d2006-12-13 17:14:36 +0000324 if (rc < 0)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200325 tprints("{...}");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000326 }
327}
328
Dmitry V. Levin1cad25d2006-12-13 17:14:36 +0000329#define printitv(tcp, addr) \
330 printitv_bitness((tcp), (addr), BITNESS_CURRENT)
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +0000331
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000332int
Denys Vlasenko12014262011-05-30 14:00:14 +0200333sys_getitimer(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000334{
335 if (entering(tcp)) {
Dmitry V. Levin297b5942014-04-25 23:39:20 +0000336 printxval(itimer_which, tcp->u_arg[0], "ITIMER_???");
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200337 tprints(", ");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000338 } else {
339 if (syserror(tcp))
340 tprintf("%#lx", tcp->u_arg[1]);
341 else
342 printitv(tcp, tcp->u_arg[1]);
343 }
344 return 0;
345}
346
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +0000347#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)) {
Dmitry V. Levin297b5942014-04-25 23:39:20 +0000352 printxval(itimer_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)) {
Dmitry V. Levin297b5942014-04-25 23:39:20 +0000368 printxval(itimer_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)) {
Dmitry V. Levin297b5942014-04-25 23:39:20 +0000386 printxval(itimer_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
Dmitry V. Levin0ed617b2014-04-25 23:30:54 +0000400#include "xlat/adjtimex_modes.h"
Dmitry V. Levin0ed617b2014-04-25 23:30:54 +0000401#include "xlat/adjtimex_status.h"
Dmitry V. Levin0ed617b2014-04-25 23:30:54 +0000402#include "xlat/adjtimex_state.h"
Dmitry V. Levin1a684d62006-12-13 17:42:32 +0000403
Dmitry V. Levin165b15d2006-12-13 17:43:45 +0000404#if SUPPORTED_PERSONALITIES > 1
405static int
406tprint_timex32(struct tcb *tcp, long addr)
407{
Denys Vlasenko1d632462009-04-14 12:51:00 +0000408 struct {
Dmitry V. Levin165b15d2006-12-13 17:43:45 +0000409 unsigned int modes;
410 int offset;
411 int freq;
412 int maxerror;
413 int esterror;
414 int status;
415 int constant;
416 int precision;
417 int tolerance;
418 struct timeval32 time;
419 int tick;
420 int ppsfreq;
421 int jitter;
422 int shift;
423 int stabil;
424 int jitcnt;
425 int calcnt;
426 int errcnt;
427 int stbcnt;
428 } tx;
429
430 if (umove(tcp, addr, &tx) < 0)
431 return -1;
432
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200433 tprints("{modes=");
Dmitry V. Levin71d70892007-01-13 11:17:38 +0000434 printflags(adjtimex_modes, tx.modes, "ADJ_???");
Dmitry V. Levin165b15d2006-12-13 17:43:45 +0000435 tprintf(", offset=%d, freq=%d, maxerror=%d, ",
436 tx.offset, tx.freq, tx.maxerror);
437 tprintf("esterror=%u, status=", tx.esterror);
438 printflags(adjtimex_status, tx.status, "STA_???");
439 tprintf(", constant=%d, precision=%u, ",
440 tx.constant, tx.precision);
441 tprintf("tolerance=%d, time=", tx.tolerance);
442 tprint_timeval32(tcp, &tx.time);
443 tprintf(", tick=%d, ppsfreq=%d, jitter=%d",
444 tx.tick, tx.ppsfreq, tx.jitter);
445 tprintf(", shift=%d, stabil=%d, jitcnt=%d",
446 tx.shift, tx.stabil, tx.jitcnt);
447 tprintf(", calcnt=%d, errcnt=%d, stbcnt=%d",
448 tx.calcnt, tx.errcnt, tx.stbcnt);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200449 tprints("}");
Dmitry V. Levin165b15d2006-12-13 17:43:45 +0000450 return 0;
451}
452#endif /* SUPPORTED_PERSONALITIES > 1 */
453
454static int
455tprint_timex(struct tcb *tcp, long addr)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000456{
Dmitry V. Levin1a684d62006-12-13 17:42:32 +0000457 struct timex tx;
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000458
Dmitry V. Levin165b15d2006-12-13 17:43:45 +0000459#if SUPPORTED_PERSONALITIES > 1
Denys Vlasenko9fd4f962012-03-19 09:36:42 +0100460 if (current_wordsize == 4)
Dmitry V. Levin165b15d2006-12-13 17:43:45 +0000461 return tprint_timex32(tcp, addr);
462#endif
463 if (umove(tcp, addr, &tx) < 0)
464 return -1;
465
466#if LINUX_VERSION_CODE < 66332
467 tprintf("{mode=%d, offset=%ld, frequency=%ld, ",
468 tx.mode, tx.offset, tx.frequency);
469 tprintf("maxerror=%ld, esterror=%lu, status=%u, ",
470 tx.maxerror, tx.esterror, tx.status);
471 tprintf("time_constant=%ld, precision=%lu, ",
472 tx.time_constant, tx.precision);
473 tprintf("tolerance=%ld, time=", tx.tolerance);
474 tprint_timeval(tcp, &tx.time);
475#else
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200476 tprints("{modes=");
Dmitry V. Levin71d70892007-01-13 11:17:38 +0000477 printflags(adjtimex_modes, tx.modes, "ADJ_???");
Dmitry V. Levin165b15d2006-12-13 17:43:45 +0000478 tprintf(", offset=%ld, freq=%ld, maxerror=%ld, ",
H.J. Lu0b315b62012-02-03 10:16:03 -0800479 (long) tx.offset, (long) tx.freq, (long) tx.maxerror);
480 tprintf("esterror=%lu, status=", (long) tx.esterror);
Dmitry V. Levin165b15d2006-12-13 17:43:45 +0000481 printflags(adjtimex_status, tx.status, "STA_???");
482 tprintf(", constant=%ld, precision=%lu, ",
H.J. Lu0b315b62012-02-03 10:16:03 -0800483 (long) tx.constant, (long) tx.precision);
484 tprintf("tolerance=%ld, time=", (long) tx.tolerance);
Dmitry V. Levin165b15d2006-12-13 17:43:45 +0000485 tprint_timeval(tcp, &tx.time);
486 tprintf(", tick=%ld, ppsfreq=%ld, jitter=%ld",
H.J. Lu0b315b62012-02-03 10:16:03 -0800487 (long) tx.tick, (long) tx.ppsfreq, (long) tx.jitter);
Dmitry V. Levin165b15d2006-12-13 17:43:45 +0000488 tprintf(", shift=%d, stabil=%ld, jitcnt=%ld",
H.J. Lu0b315b62012-02-03 10:16:03 -0800489 tx.shift, (long) tx.stabil, (long) tx.jitcnt);
Dmitry V. Levin165b15d2006-12-13 17:43:45 +0000490 tprintf(", calcnt=%ld, errcnt=%ld, stbcnt=%ld",
H.J. Lu0b315b62012-02-03 10:16:03 -0800491 (long) tx.calcnt, (long) tx.errcnt, (long) tx.stbcnt);
Dmitry V. Levin165b15d2006-12-13 17:43:45 +0000492#endif
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200493 tprints("}");
Dmitry V. Levin165b15d2006-12-13 17:43:45 +0000494 return 0;
495}
496
Dmitry V. Levin73215472012-03-11 21:25:51 +0000497static int
498do_adjtimex(struct tcb *tcp, long addr)
499{
500 if (addr == 0)
501 tprints("NULL");
502 else if (syserror(tcp) || !verbose(tcp))
503 tprintf("%#lx", addr);
504 else if (tprint_timex(tcp, addr) < 0)
505 tprints("{...}");
506 if (syserror(tcp))
507 return 0;
508 tcp->auxstr = xlookup(adjtimex_state, tcp->u_rval);
509 if (tcp->auxstr)
510 return RVAL_STR;
511 return 0;
512}
513
Dmitry V. Levin165b15d2006-12-13 17:43:45 +0000514int
515sys_adjtimex(struct tcb *tcp)
516{
Dmitry V. Levin73215472012-03-11 21:25:51 +0000517 if (exiting(tcp))
518 return do_adjtimex(tcp, tcp->u_arg[0]);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000519 return 0;
520}
Roland McGrath1e356792003-03-30 23:52:28 +0000521
Dmitry V. Levin0ed617b2014-04-25 23:30:54 +0000522#include "xlat/clockflags.h"
Dmitry V. Levin0ed617b2014-04-25 23:30:54 +0000523#include "xlat/clocknames.h"
Roland McGrath54a4edd2004-08-31 06:52:45 +0000524
Stefan Sørensena5fea902014-02-03 10:01:27 +0100525static void
526printclockname(int clockid)
527{
528#ifdef CLOCKID_TO_FD
Dmitry V. Levind35bdca2014-04-26 18:10:19 +0000529# include "xlat/cpuclocknames.h"
530
Stefan Sørensena5fea902014-02-03 10:01:27 +0100531 if (clockid < 0) {
532 if ((clockid & CLOCKFD_MASK) == CLOCKFD)
533 tprintf("FD_TO_CLOCKID(%d)", CLOCKID_TO_FD(clockid));
534 else {
535 if(CPUCLOCK_PERTHREAD(clockid))
536 tprintf("MAKE_THREAD_CPUCLOCK(%d,", CPUCLOCK_PID(clockid));
537 else
538 tprintf("MAKE_PROCESS_CPUCLOCK(%d,", CPUCLOCK_PID(clockid));
539 printxval(cpuclocknames, clockid & CLOCKFD_MASK, "CPUCLOCK_???");
540 tprints(")");
541 }
542 }
543 else
544#endif
545 printxval(clocknames, clockid, "CLOCK_???");
546}
547
Roland McGrath1e356792003-03-30 23:52:28 +0000548int
Denys Vlasenko12014262011-05-30 14:00:14 +0200549sys_clock_settime(struct tcb *tcp)
Roland McGrath1e356792003-03-30 23:52:28 +0000550{
551 if (entering(tcp)) {
Stefan Sørensena5fea902014-02-03 10:01:27 +0100552 printclockname(tcp->u_arg[0]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200553 tprints(", ");
Roland McGrath1e356792003-03-30 23:52:28 +0000554 printtv(tcp, tcp->u_arg[1]);
555 }
556 return 0;
557}
558
559int
Denys Vlasenko12014262011-05-30 14:00:14 +0200560sys_clock_gettime(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 McGrath1e356792003-03-30 23:52:28 +0000565 } else {
566 if (syserror(tcp))
567 tprintf("%#lx", tcp->u_arg[1]);
568 else
569 printtv(tcp, tcp->u_arg[1]);
570 }
571 return 0;
572}
573
574int
Denys Vlasenko12014262011-05-30 14:00:14 +0200575sys_clock_nanosleep(struct tcb *tcp)
Roland McGrath1e356792003-03-30 23:52:28 +0000576{
577 if (entering(tcp)) {
Stefan Sørensena5fea902014-02-03 10:01:27 +0100578 printclockname(tcp->u_arg[0]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200579 tprints(", ");
Roland McGrathb2dee132005-06-01 19:02:36 +0000580 printflags(clockflags, tcp->u_arg[1], "TIMER_???");
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200581 tprints(", ");
Roland McGrath1e356792003-03-30 23:52:28 +0000582 printtv(tcp, tcp->u_arg[2]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200583 tprints(", ");
Roland McGrath1e356792003-03-30 23:52:28 +0000584 } else {
585 if (syserror(tcp))
586 tprintf("%#lx", tcp->u_arg[3]);
587 else
588 printtv(tcp, tcp->u_arg[3]);
589 }
590 return 0;
591}
592
Dmitry V. Levin73215472012-03-11 21:25:51 +0000593int
594sys_clock_adjtime(struct tcb *tcp)
595{
596 if (exiting(tcp))
597 return do_adjtimex(tcp, tcp->u_arg[1]);
Stefan Sørensena5fea902014-02-03 10:01:27 +0100598 printclockname(tcp->u_arg[0]);
Dmitry V. Levin73215472012-03-11 21:25:51 +0000599 tprints(", ");
600 return 0;
601}
602
Roland McGrath1e356792003-03-30 23:52:28 +0000603#ifndef SIGEV_THREAD_ID
604# define SIGEV_THREAD_ID 4
605#endif
Dmitry V. Levin0ed617b2014-04-25 23:30:54 +0000606#include "xlat/sigev_value.h"
Roland McGrath1e356792003-03-30 23:52:28 +0000607
Dmitry V. Levind3cb3922006-12-13 17:45:02 +0000608#if SUPPORTED_PERSONALITIES > 1
609static void
610printsigevent32(struct tcb *tcp, long arg)
611{
Denys Vlasenko1d632462009-04-14 12:51:00 +0000612 struct {
Dmitry V. Levind3cb3922006-12-13 17:45:02 +0000613 int sigev_value;
614 int sigev_signo;
615 int sigev_notify;
616
Denys Vlasenko1d632462009-04-14 12:51:00 +0000617 union {
Dmitry V. Levind3cb3922006-12-13 17:45:02 +0000618 int tid;
Denys Vlasenko1d632462009-04-14 12:51:00 +0000619 struct {
Dmitry V. Levind3cb3922006-12-13 17:45:02 +0000620 int function, attribute;
621 } thread;
622 } un;
623 } sev;
624
625 if (umove(tcp, arg, &sev) < 0)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200626 tprints("{...}");
Denys Vlasenko1d632462009-04-14 12:51:00 +0000627 else {
Dmitry V. Levind3cb3922006-12-13 17:45:02 +0000628 tprintf("{%#x, ", sev.sigev_value);
629 if (sev.sigev_notify == SIGEV_SIGNAL)
630 tprintf("%s, ", signame(sev.sigev_signo));
631 else
632 tprintf("%u, ", sev.sigev_signo);
Dmitry V. Levinbae549e2014-02-05 01:46:10 +0000633 printxval(sigev_value, sev.sigev_notify, "SIGEV_???");
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200634 tprints(", ");
Dmitry V. Levind3cb3922006-12-13 17:45:02 +0000635 if (sev.sigev_notify == SIGEV_THREAD_ID)
636 tprintf("{%d}", sev.un.tid);
637 else if (sev.sigev_notify == SIGEV_THREAD)
638 tprintf("{%#x, %#x}",
639 sev.un.thread.function,
640 sev.un.thread.attribute);
641 else
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200642 tprints("{...}");
643 tprints("}");
Dmitry V. Levind3cb3922006-12-13 17:45:02 +0000644 }
645}
646#endif
647
Roland McGrath1e356792003-03-30 23:52:28 +0000648void
Dmitry V. Levind3cb3922006-12-13 17:45:02 +0000649printsigevent(struct tcb *tcp, long arg)
Roland McGrath1e356792003-03-30 23:52:28 +0000650{
651 struct sigevent sev;
Dmitry V. Levind3cb3922006-12-13 17:45:02 +0000652
653#if SUPPORTED_PERSONALITIES > 1
Denys Vlasenko9fd4f962012-03-19 09:36:42 +0100654 if (current_wordsize == 4) {
Dmitry V. Levind3cb3922006-12-13 17:45:02 +0000655 printsigevent32(tcp, arg);
656 return;
657 }
658#endif
Denys Vlasenkob63256e2011-06-07 12:13:24 +0200659 if (umove(tcp, arg, &sev) < 0)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200660 tprints("{...}");
Roland McGrath1e356792003-03-30 23:52:28 +0000661 else {
Roland McGrath675d4a62004-09-11 08:12:45 +0000662 tprintf("{%p, ", sev.sigev_value.sival_ptr);
663 if (sev.sigev_notify == SIGEV_SIGNAL)
664 tprintf("%s, ", signame(sev.sigev_signo));
665 else
666 tprintf("%u, ", sev.sigev_signo);
Dmitry V. Levinbae549e2014-02-05 01:46:10 +0000667 printxval(sigev_value, sev.sigev_notify, "SIGEV_???");
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200668 tprints(", ");
Roland McGrath1e356792003-03-30 23:52:28 +0000669 if (sev.sigev_notify == SIGEV_THREAD_ID)
Dmitry V. Levinae5aa472013-11-11 23:54:30 +0000670#if defined(HAVE_STRUCT_SIGEVENT__SIGEV_UN__PAD)
Roland McGrath1e356792003-03-30 23:52:28 +0000671 /* _pad[0] is the _tid field which might not be
672 present in the userlevel definition of the
673 struct. */
674 tprintf("{%d}", sev._sigev_un._pad[0]);
Dmitry V. Levinae5aa472013-11-11 23:54:30 +0000675#elif defined(HAVE_STRUCT_SIGEVENT___PAD)
676 tprintf("{%d}", sev.__pad[0]);
677#else
678# warning unfamiliar struct sigevent => incomplete SIGEV_THREAD_ID decoding
679 tprints("{...}");
680#endif
Roland McGrathd4c85eb2004-04-16 21:48:44 +0000681 else if (sev.sigev_notify == SIGEV_THREAD)
682 tprintf("{%p, %p}", sev.sigev_notify_function,
683 sev.sigev_notify_attributes);
Roland McGrath1e356792003-03-30 23:52:28 +0000684 else
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200685 tprints("{...}");
686 tprints("}");
Roland McGrath1e356792003-03-30 23:52:28 +0000687 }
688}
689
690int
Denys Vlasenko12014262011-05-30 14:00:14 +0200691sys_timer_create(struct tcb *tcp)
Roland McGrath1e356792003-03-30 23:52:28 +0000692{
693 if (entering(tcp)) {
Stefan Sørensena5fea902014-02-03 10:01:27 +0100694 printclockname(tcp->u_arg[0]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200695 tprints(", ");
Roland McGrath1e356792003-03-30 23:52:28 +0000696 printsigevent(tcp, tcp->u_arg[1]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200697 tprints(", ");
Roland McGrath1e356792003-03-30 23:52:28 +0000698 } else {
Andi Kleen732f3962011-06-13 21:37:40 +0000699 int timer_id;
Dmitry V. Levinac518d12006-12-13 17:03:02 +0000700
Andi Kleen732f3962011-06-13 21:37:40 +0000701 if (syserror(tcp) || umove(tcp, tcp->u_arg[2], &timer_id) < 0)
Roland McGrath1e356792003-03-30 23:52:28 +0000702 tprintf("%#lx", tcp->u_arg[2]);
Dmitry V. Levinac518d12006-12-13 17:03:02 +0000703 else
Andi Kleen732f3962011-06-13 21:37:40 +0000704 tprintf("{%d}", timer_id);
Roland McGrath1e356792003-03-30 23:52:28 +0000705 }
706 return 0;
707}
708
709int
Denys Vlasenko12014262011-05-30 14:00:14 +0200710sys_timer_settime(struct tcb *tcp)
Roland McGrath1e356792003-03-30 23:52:28 +0000711{
712 if (entering(tcp)) {
713 tprintf("%#lx, ", tcp->u_arg[0]);
Roland McGrathb2dee132005-06-01 19:02:36 +0000714 printflags(clockflags, tcp->u_arg[1], "TIMER_???");
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200715 tprints(", ");
Roland McGrath1e356792003-03-30 23:52:28 +0000716 printitv(tcp, tcp->u_arg[2]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200717 tprints(", ");
Roland McGrath1e356792003-03-30 23:52:28 +0000718 } else {
719 if (syserror(tcp))
720 tprintf("%#lx", tcp->u_arg[3]);
721 else
722 printitv(tcp, tcp->u_arg[3]);
723 }
724 return 0;
725}
726
727int
Denys Vlasenko12014262011-05-30 14:00:14 +0200728sys_timer_gettime(struct tcb *tcp)
Roland McGrath1e356792003-03-30 23:52:28 +0000729{
730 if (entering(tcp)) {
731 tprintf("%#lx, ", tcp->u_arg[0]);
732 } else {
733 if (syserror(tcp))
734 tprintf("%#lx", tcp->u_arg[1]);
735 else
736 printitv(tcp, tcp->u_arg[1]);
737 }
738 return 0;
739}
Roland McGrathd83c50b2004-10-06 22:27:43 +0000740
741static void
Denys Vlasenko12014262011-05-30 14:00:14 +0200742print_rtc(struct tcb *tcp, const struct rtc_time *rt)
Roland McGrathd83c50b2004-10-06 22:27:43 +0000743{
744 tprintf("{tm_sec=%d, tm_min=%d, tm_hour=%d, "
745 "tm_mday=%d, tm_mon=%d, tm_year=%d, ",
746 rt->tm_sec, rt->tm_min, rt->tm_hour,
747 rt->tm_mday, rt->tm_mon, rt->tm_year);
748 if (!abbrev(tcp))
749 tprintf("tm_wday=%d, tm_yday=%d, tm_isdst=%d}",
750 rt->tm_wday, rt->tm_yday, rt->tm_isdst);
751 else
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200752 tprints("...}");
Roland McGrathd83c50b2004-10-06 22:27:43 +0000753}
754
755int
Denys Vlasenko12014262011-05-30 14:00:14 +0200756rtc_ioctl(struct tcb *tcp, long code, long arg)
Roland McGrathd83c50b2004-10-06 22:27:43 +0000757{
758 switch (code) {
759 case RTC_ALM_SET:
760 case RTC_SET_TIME:
761 if (entering(tcp)) {
762 struct rtc_time rt;
763 if (umove(tcp, arg, &rt) < 0)
764 tprintf(", %#lx", arg);
765 else {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200766 tprints(", ");
Roland McGrathd83c50b2004-10-06 22:27:43 +0000767 print_rtc(tcp, &rt);
768 }
769 }
770 break;
771 case RTC_ALM_READ:
772 case RTC_RD_TIME:
773 if (exiting(tcp)) {
774 struct rtc_time rt;
775 if (syserror(tcp) || umove(tcp, arg, &rt) < 0)
776 tprintf(", %#lx", arg);
777 else {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200778 tprints(", ");
Roland McGrathd83c50b2004-10-06 22:27:43 +0000779 print_rtc(tcp, &rt);
780 }
781 }
782 break;
783 case RTC_IRQP_SET:
784 case RTC_EPOCH_SET:
785 if (entering(tcp))
786 tprintf(", %lu", arg);
787 break;
788 case RTC_IRQP_READ:
789 case RTC_EPOCH_READ:
790 if (exiting(tcp))
791 tprintf(", %lu", arg);
792 break;
793 case RTC_WKALM_SET:
794 if (entering(tcp)) {
795 struct rtc_wkalrm wk;
796 if (umove(tcp, arg, &wk) < 0)
797 tprintf(", %#lx", arg);
798 else {
799 tprintf(", {enabled=%d, pending=%d, ",
800 wk.enabled, wk.pending);
801 print_rtc(tcp, &wk.time);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200802 tprints("}");
Roland McGrathd83c50b2004-10-06 22:27:43 +0000803 }
804 }
805 break;
806 case RTC_WKALM_RD:
807 if (exiting(tcp)) {
808 struct rtc_wkalrm wk;
809 if (syserror(tcp) || umove(tcp, arg, &wk) < 0)
810 tprintf(", %#lx", arg);
811 else {
812 tprintf(", {enabled=%d, pending=%d, ",
813 wk.enabled, wk.pending);
814 print_rtc(tcp, &wk.time);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200815 tprints("}");
Roland McGrathd83c50b2004-10-06 22:27:43 +0000816 }
817 }
818 break;
819 default:
820 if (entering(tcp))
821 tprintf(", %#lx", arg);
822 break;
823 }
824 return 1;
825}
Roland McGrathe4662342007-08-02 01:25:34 +0000826
827#ifndef TFD_TIMER_ABSTIME
828#define TFD_TIMER_ABSTIME (1 << 0)
829#endif
830
Dmitry V. Levin0ed617b2014-04-25 23:30:54 +0000831#include "xlat/timerfdflags.h"
Roland McGrathe4662342007-08-02 01:25:34 +0000832
833int
Denys Vlasenko12014262011-05-30 14:00:14 +0200834sys_timerfd(struct tcb *tcp)
Roland McGrathe4662342007-08-02 01:25:34 +0000835{
836 if (entering(tcp)) {
837 /* It does not matter that the kernel uses itimerspec. */
838 tprintf("%ld, ", tcp->u_arg[0]);
Stefan Sørensena5fea902014-02-03 10:01:27 +0100839 printclockname(tcp->u_arg[0]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200840 tprints(", ");
Roland McGrathe4662342007-08-02 01:25:34 +0000841 printflags(timerfdflags, tcp->u_arg[2], "TFD_???");
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200842 tprints(", ");
Roland McGrathe4662342007-08-02 01:25:34 +0000843 printitv(tcp, tcp->u_arg[3]);
844 }
845 return 0;
846}
Roland McGrathde328e62008-05-20 04:56:13 +0000847
848int
849sys_timerfd_create(struct tcb *tcp)
850{
851 if (entering(tcp)) {
Stefan Sørensena5fea902014-02-03 10:01:27 +0100852 printclockname(tcp->u_arg[0]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200853 tprints(", ");
Roland McGrathde328e62008-05-20 04:56:13 +0000854 printflags(timerfdflags, tcp->u_arg[1], "TFD_???");
855 }
856 return 0;
857}
858
859int
860sys_timerfd_settime(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 printflags(timerfdflags, tcp->u_arg[1], "TFD_???");
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200866 tprints(", ");
Roland McGrathde328e62008-05-20 04:56:13 +0000867 printitv(tcp, tcp->u_arg[2]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200868 tprints(", ");
Roland McGrathde328e62008-05-20 04:56:13 +0000869 printitv(tcp, tcp->u_arg[3]);
870 }
871 return 0;
872}
873
874int
875sys_timerfd_gettime(struct tcb *tcp)
876{
877 if (entering(tcp)) {
Dmitry V. Levin31382132011-03-04 05:08:02 +0300878 printfd(tcp, tcp->u_arg[0]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200879 tprints(", ");
Roland McGrathde328e62008-05-20 04:56:13 +0000880 printitv(tcp, tcp->u_arg[1]);
881 }
882 return 0;
883}