blob: 58d46280aa392dc18e7ea349f05a1256a77423f6 [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_gettimeofday(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000172{
173 if (exiting(tcp)) {
174 if (syserror(tcp)) {
175 tprintf("%#lx, %#lx",
176 tcp->u_arg[0], tcp->u_arg[1]);
177 return 0;
178 }
179 printtv(tcp, tcp->u_arg[0]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200180 tprints(", ");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000181 printtv(tcp, tcp->u_arg[1]);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000182 }
183 return 0;
184}
185
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +0000186#ifdef ALPHA
187int
Denys Vlasenko12014262011-05-30 14:00:14 +0200188sys_osf_gettimeofday(struct tcb *tcp)
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +0000189{
Denys Vlasenko1d632462009-04-14 12:51:00 +0000190 if (exiting(tcp)) {
191 if (syserror(tcp)) {
192 tprintf("%#lx, %#lx", tcp->u_arg[0], tcp->u_arg[1]);
193 return 0;
194 }
195 printtv_bitness(tcp, tcp->u_arg[0], BITNESS_32, 0);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200196 tprints(", ");
Denys Vlasenko1d632462009-04-14 12:51:00 +0000197 printtv_bitness(tcp, tcp->u_arg[1], BITNESS_32, 0);
Denys Vlasenko1d632462009-04-14 12:51:00 +0000198 }
199 return 0;
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +0000200}
201#endif
202
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000203int
Denys Vlasenko12014262011-05-30 14:00:14 +0200204sys_settimeofday(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000205{
206 if (entering(tcp)) {
207 printtv(tcp, tcp->u_arg[0]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200208 tprints(", ");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000209 printtv(tcp, tcp->u_arg[1]);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000210 }
211 return 0;
212}
213
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +0000214#ifdef ALPHA
215int
Denys Vlasenko12014262011-05-30 14:00:14 +0200216sys_osf_settimeofday(struct tcb *tcp)
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +0000217{
Denys Vlasenko1d632462009-04-14 12:51:00 +0000218 if (entering(tcp)) {
219 printtv_bitness(tcp, tcp->u_arg[0], BITNESS_32, 0);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200220 tprints(", ");
Denys Vlasenko1d632462009-04-14 12:51:00 +0000221 printtv_bitness(tcp, tcp->u_arg[1], BITNESS_32, 0);
Denys Vlasenko1d632462009-04-14 12:51:00 +0000222 }
223 return 0;
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +0000224}
225#endif
226
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000227int
Denys Vlasenko12014262011-05-30 14:00:14 +0200228sys_adjtime(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000229{
230 if (entering(tcp)) {
231 printtv(tcp, tcp->u_arg[0]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200232 tprints(", ");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000233 } else {
234 if (syserror(tcp))
235 tprintf("%#lx", tcp->u_arg[1]);
236 else
237 printtv(tcp, tcp->u_arg[1]);
238 }
239 return 0;
240}
241
Dmitry V. Levin2e55ff42008-09-03 01:02:46 +0000242int
243sys_nanosleep(struct tcb *tcp)
244{
245 if (entering(tcp)) {
246 print_timespec(tcp, tcp->u_arg[0]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200247 tprints(", ");
Dmitry V. Levin2e55ff42008-09-03 01:02:46 +0000248 } else {
Denys Vlasenko64acaa12012-01-28 02:29:36 +0100249 /* Second (returned) timespec is only significant
Denys Vlasenko47932212013-06-30 23:53:49 +0200250 * if syscall was interrupted. On success, we print
251 * only its address, since kernel doesn't modify it,
252 * and printing the value may show uninitialized data.
Denys Vlasenko64acaa12012-01-28 02:29:36 +0100253 */
Denys Vlasenko47932212013-06-30 23:53:49 +0200254 switch (tcp->u_error) {
255 default:
256 /* Not interrupted (slept entire interval) */
257 if (tcp->u_arg[1]) {
258 tprintf("%#lx", tcp->u_arg[1]);
259 break;
260 }
261 /* Fall through: print_timespec(NULL) prints "NULL" */
262 case ERESTARTSYS:
263 case ERESTARTNOINTR:
264 case ERESTARTNOHAND:
265 case ERESTART_RESTARTBLOCK:
266 /* Interrupted */
Dmitry V. Levin2e55ff42008-09-03 01:02:46 +0000267 print_timespec(tcp, tcp->u_arg[1]);
Denys Vlasenko47932212013-06-30 23:53:49 +0200268 }
Dmitry V. Levin2e55ff42008-09-03 01:02:46 +0000269 }
270 return 0;
271}
272
Dmitry V. Levin0ed617b2014-04-25 23:30:54 +0000273#include "xlat/itimer_which.h"
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000274
275static void
Dmitry V. Levin1cad25d2006-12-13 17:14:36 +0000276printitv_bitness(struct tcb *tcp, long addr, enum bitness_t bitness)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000277{
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000278 if (addr == 0)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200279 tprints("NULL");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000280 else if (!verbose(tcp))
281 tprintf("%#lx", addr);
Denys Vlasenko1d632462009-04-14 12:51:00 +0000282 else {
283 int rc;
Dmitry V. Levin1cad25d2006-12-13 17:14:36 +0000284
285 if (bitness == BITNESS_32
Denys Vlasenko84703742012-02-25 02:38:52 +0100286#if SUPPORTED_PERSONALITIES > 1
Denys Vlasenko9fd4f962012-03-19 09:36:42 +0100287 || current_wordsize == 4
Dmitry V. Levin1cad25d2006-12-13 17:14:36 +0000288#endif
289 )
290 {
Denys Vlasenko1d632462009-04-14 12:51:00 +0000291 struct {
Dmitry V. Levin1cad25d2006-12-13 17:14:36 +0000292 struct timeval32 it_interval, it_value;
293 } itv;
294
Denys Vlasenko5d645812011-08-20 12:48:18 +0200295 rc = umove(tcp, addr, &itv);
296 if (rc >= 0) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200297 tprints("{it_interval=");
Dmitry V. Levin1cad25d2006-12-13 17:14:36 +0000298 tprint_timeval32(tcp, &itv.it_interval);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200299 tprints(", it_value=");
Dmitry V. Levin1cad25d2006-12-13 17:14:36 +0000300 tprint_timeval32(tcp, &itv.it_value);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200301 tprints("}");
Roland McGrathe4662342007-08-02 01:25:34 +0000302 }
Denys Vlasenko1d632462009-04-14 12:51:00 +0000303 } else {
Dmitry V. Levin1cad25d2006-12-13 17:14:36 +0000304 struct itimerval itv;
305
Denys Vlasenko5d645812011-08-20 12:48:18 +0200306 rc = umove(tcp, addr, &itv);
307 if (rc >= 0) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200308 tprints("{it_interval=");
Dmitry V. Levin1cad25d2006-12-13 17:14:36 +0000309 tprint_timeval(tcp, &itv.it_interval);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200310 tprints(", it_value=");
Dmitry V. Levin1cad25d2006-12-13 17:14:36 +0000311 tprint_timeval(tcp, &itv.it_value);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200312 tprints("}");
Roland McGrathe4662342007-08-02 01:25:34 +0000313 }
Dmitry V. Levin1cad25d2006-12-13 17:14:36 +0000314 }
Dmitry V. Levin1cad25d2006-12-13 17:14:36 +0000315 if (rc < 0)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200316 tprints("{...}");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000317 }
318}
319
Dmitry V. Levin1cad25d2006-12-13 17:14:36 +0000320#define printitv(tcp, addr) \
321 printitv_bitness((tcp), (addr), BITNESS_CURRENT)
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +0000322
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000323int
Denys Vlasenko12014262011-05-30 14:00:14 +0200324sys_getitimer(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000325{
326 if (entering(tcp)) {
Dmitry V. Levin297b5942014-04-25 23:39:20 +0000327 printxval(itimer_which, tcp->u_arg[0], "ITIMER_???");
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200328 tprints(", ");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000329 } else {
330 if (syserror(tcp))
331 tprintf("%#lx", tcp->u_arg[1]);
332 else
333 printitv(tcp, tcp->u_arg[1]);
334 }
335 return 0;
336}
337
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +0000338#ifdef ALPHA
339int
Denys Vlasenko12014262011-05-30 14:00:14 +0200340sys_osf_getitimer(struct tcb *tcp)
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +0000341{
Denys Vlasenko1d632462009-04-14 12:51:00 +0000342 if (entering(tcp)) {
Dmitry V. Levin297b5942014-04-25 23:39:20 +0000343 printxval(itimer_which, tcp->u_arg[0], "ITIMER_???");
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200344 tprints(", ");
Denys Vlasenko1d632462009-04-14 12:51:00 +0000345 } else {
346 if (syserror(tcp))
347 tprintf("%#lx", tcp->u_arg[1]);
348 else
349 printitv_bitness(tcp, tcp->u_arg[1], BITNESS_32);
350 }
351 return 0;
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +0000352}
353#endif
354
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000355int
Denys Vlasenko12014262011-05-30 14:00:14 +0200356sys_setitimer(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000357{
358 if (entering(tcp)) {
Dmitry V. Levin297b5942014-04-25 23:39:20 +0000359 printxval(itimer_which, tcp->u_arg[0], "ITIMER_???");
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200360 tprints(", ");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000361 printitv(tcp, tcp->u_arg[1]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200362 tprints(", ");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000363 } else {
364 if (syserror(tcp))
365 tprintf("%#lx", tcp->u_arg[2]);
366 else
367 printitv(tcp, tcp->u_arg[2]);
368 }
369 return 0;
370}
371
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +0000372#ifdef ALPHA
373int
Denys Vlasenko12014262011-05-30 14:00:14 +0200374sys_osf_setitimer(struct tcb *tcp)
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +0000375{
Denys Vlasenko1d632462009-04-14 12:51:00 +0000376 if (entering(tcp)) {
Dmitry V. Levin297b5942014-04-25 23:39:20 +0000377 printxval(itimer_which, tcp->u_arg[0], "ITIMER_???");
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200378 tprints(", ");
Denys Vlasenko1d632462009-04-14 12:51:00 +0000379 printitv_bitness(tcp, tcp->u_arg[1], BITNESS_32);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200380 tprints(", ");
Denys Vlasenko1d632462009-04-14 12:51:00 +0000381 } else {
382 if (syserror(tcp))
383 tprintf("%#lx", tcp->u_arg[2]);
384 else
385 printitv_bitness(tcp, tcp->u_arg[2], BITNESS_32);
386 }
387 return 0;
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +0000388}
389#endif
390
Dmitry V. Levin0ed617b2014-04-25 23:30:54 +0000391#include "xlat/adjtimex_modes.h"
Dmitry V. Levin0ed617b2014-04-25 23:30:54 +0000392#include "xlat/adjtimex_status.h"
Dmitry V. Levin0ed617b2014-04-25 23:30:54 +0000393#include "xlat/adjtimex_state.h"
Dmitry V. Levin1a684d62006-12-13 17:42:32 +0000394
Dmitry V. Levin165b15d2006-12-13 17:43:45 +0000395#if SUPPORTED_PERSONALITIES > 1
396static int
397tprint_timex32(struct tcb *tcp, long addr)
398{
Denys Vlasenko1d632462009-04-14 12:51:00 +0000399 struct {
Dmitry V. Levin165b15d2006-12-13 17:43:45 +0000400 unsigned int modes;
401 int offset;
402 int freq;
403 int maxerror;
404 int esterror;
405 int status;
406 int constant;
407 int precision;
408 int tolerance;
409 struct timeval32 time;
410 int tick;
411 int ppsfreq;
412 int jitter;
413 int shift;
414 int stabil;
415 int jitcnt;
416 int calcnt;
417 int errcnt;
418 int stbcnt;
419 } tx;
420
421 if (umove(tcp, addr, &tx) < 0)
422 return -1;
423
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200424 tprints("{modes=");
Dmitry V. Levin71d70892007-01-13 11:17:38 +0000425 printflags(adjtimex_modes, tx.modes, "ADJ_???");
Dmitry V. Levin165b15d2006-12-13 17:43:45 +0000426 tprintf(", offset=%d, freq=%d, maxerror=%d, ",
427 tx.offset, tx.freq, tx.maxerror);
428 tprintf("esterror=%u, status=", tx.esterror);
429 printflags(adjtimex_status, tx.status, "STA_???");
430 tprintf(", constant=%d, precision=%u, ",
431 tx.constant, tx.precision);
432 tprintf("tolerance=%d, time=", tx.tolerance);
433 tprint_timeval32(tcp, &tx.time);
434 tprintf(", tick=%d, ppsfreq=%d, jitter=%d",
435 tx.tick, tx.ppsfreq, tx.jitter);
436 tprintf(", shift=%d, stabil=%d, jitcnt=%d",
437 tx.shift, tx.stabil, tx.jitcnt);
438 tprintf(", calcnt=%d, errcnt=%d, stbcnt=%d",
439 tx.calcnt, tx.errcnt, tx.stbcnt);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200440 tprints("}");
Dmitry V. Levin165b15d2006-12-13 17:43:45 +0000441 return 0;
442}
443#endif /* SUPPORTED_PERSONALITIES > 1 */
444
445static int
446tprint_timex(struct tcb *tcp, long addr)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000447{
Dmitry V. Levin1a684d62006-12-13 17:42:32 +0000448 struct timex tx;
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000449
Dmitry V. Levin165b15d2006-12-13 17:43:45 +0000450#if SUPPORTED_PERSONALITIES > 1
Denys Vlasenko9fd4f962012-03-19 09:36:42 +0100451 if (current_wordsize == 4)
Dmitry V. Levin165b15d2006-12-13 17:43:45 +0000452 return tprint_timex32(tcp, addr);
453#endif
454 if (umove(tcp, addr, &tx) < 0)
455 return -1;
456
457#if LINUX_VERSION_CODE < 66332
458 tprintf("{mode=%d, offset=%ld, frequency=%ld, ",
459 tx.mode, tx.offset, tx.frequency);
460 tprintf("maxerror=%ld, esterror=%lu, status=%u, ",
461 tx.maxerror, tx.esterror, tx.status);
462 tprintf("time_constant=%ld, precision=%lu, ",
463 tx.time_constant, tx.precision);
464 tprintf("tolerance=%ld, time=", tx.tolerance);
465 tprint_timeval(tcp, &tx.time);
466#else
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200467 tprints("{modes=");
Dmitry V. Levin71d70892007-01-13 11:17:38 +0000468 printflags(adjtimex_modes, tx.modes, "ADJ_???");
Dmitry V. Levin165b15d2006-12-13 17:43:45 +0000469 tprintf(", offset=%ld, freq=%ld, maxerror=%ld, ",
H.J. Lu0b315b62012-02-03 10:16:03 -0800470 (long) tx.offset, (long) tx.freq, (long) tx.maxerror);
471 tprintf("esterror=%lu, status=", (long) tx.esterror);
Dmitry V. Levin165b15d2006-12-13 17:43:45 +0000472 printflags(adjtimex_status, tx.status, "STA_???");
473 tprintf(", constant=%ld, precision=%lu, ",
H.J. Lu0b315b62012-02-03 10:16:03 -0800474 (long) tx.constant, (long) tx.precision);
475 tprintf("tolerance=%ld, time=", (long) tx.tolerance);
Dmitry V. Levin165b15d2006-12-13 17:43:45 +0000476 tprint_timeval(tcp, &tx.time);
477 tprintf(", tick=%ld, ppsfreq=%ld, jitter=%ld",
H.J. Lu0b315b62012-02-03 10:16:03 -0800478 (long) tx.tick, (long) tx.ppsfreq, (long) tx.jitter);
Dmitry V. Levin165b15d2006-12-13 17:43:45 +0000479 tprintf(", shift=%d, stabil=%ld, jitcnt=%ld",
H.J. Lu0b315b62012-02-03 10:16:03 -0800480 tx.shift, (long) tx.stabil, (long) tx.jitcnt);
Dmitry V. Levin165b15d2006-12-13 17:43:45 +0000481 tprintf(", calcnt=%ld, errcnt=%ld, stbcnt=%ld",
H.J. Lu0b315b62012-02-03 10:16:03 -0800482 (long) tx.calcnt, (long) tx.errcnt, (long) tx.stbcnt);
Dmitry V. Levin165b15d2006-12-13 17:43:45 +0000483#endif
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200484 tprints("}");
Dmitry V. Levin165b15d2006-12-13 17:43:45 +0000485 return 0;
486}
487
Dmitry V. Levin73215472012-03-11 21:25:51 +0000488static int
489do_adjtimex(struct tcb *tcp, long addr)
490{
491 if (addr == 0)
492 tprints("NULL");
493 else if (syserror(tcp) || !verbose(tcp))
494 tprintf("%#lx", addr);
495 else if (tprint_timex(tcp, addr) < 0)
496 tprints("{...}");
497 if (syserror(tcp))
498 return 0;
499 tcp->auxstr = xlookup(adjtimex_state, tcp->u_rval);
500 if (tcp->auxstr)
501 return RVAL_STR;
502 return 0;
503}
504
Dmitry V. Levin165b15d2006-12-13 17:43:45 +0000505int
506sys_adjtimex(struct tcb *tcp)
507{
Dmitry V. Levin73215472012-03-11 21:25:51 +0000508 if (exiting(tcp))
509 return do_adjtimex(tcp, tcp->u_arg[0]);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000510 return 0;
511}
Roland McGrath1e356792003-03-30 23:52:28 +0000512
Dmitry V. Levin0ed617b2014-04-25 23:30:54 +0000513#include "xlat/clockflags.h"
Dmitry V. Levin0ed617b2014-04-25 23:30:54 +0000514#include "xlat/clocknames.h"
Roland McGrath54a4edd2004-08-31 06:52:45 +0000515
Stefan Sørensena5fea902014-02-03 10:01:27 +0100516static void
517printclockname(int clockid)
518{
519#ifdef CLOCKID_TO_FD
Dmitry V. Levind35bdca2014-04-26 18:10:19 +0000520# include "xlat/cpuclocknames.h"
521
Stefan Sørensena5fea902014-02-03 10:01:27 +0100522 if (clockid < 0) {
523 if ((clockid & CLOCKFD_MASK) == CLOCKFD)
524 tprintf("FD_TO_CLOCKID(%d)", CLOCKID_TO_FD(clockid));
525 else {
526 if(CPUCLOCK_PERTHREAD(clockid))
527 tprintf("MAKE_THREAD_CPUCLOCK(%d,", CPUCLOCK_PID(clockid));
528 else
529 tprintf("MAKE_PROCESS_CPUCLOCK(%d,", CPUCLOCK_PID(clockid));
530 printxval(cpuclocknames, clockid & CLOCKFD_MASK, "CPUCLOCK_???");
531 tprints(")");
532 }
533 }
534 else
535#endif
536 printxval(clocknames, clockid, "CLOCK_???");
537}
538
Roland McGrath1e356792003-03-30 23:52:28 +0000539int
Denys Vlasenko12014262011-05-30 14:00:14 +0200540sys_clock_settime(struct tcb *tcp)
Roland McGrath1e356792003-03-30 23:52:28 +0000541{
542 if (entering(tcp)) {
Stefan Sørensena5fea902014-02-03 10:01:27 +0100543 printclockname(tcp->u_arg[0]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200544 tprints(", ");
Roland McGrath1e356792003-03-30 23:52:28 +0000545 printtv(tcp, tcp->u_arg[1]);
546 }
547 return 0;
548}
549
550int
Denys Vlasenko12014262011-05-30 14:00:14 +0200551sys_clock_gettime(struct tcb *tcp)
Roland McGrath1e356792003-03-30 23:52:28 +0000552{
553 if (entering(tcp)) {
Stefan Sørensena5fea902014-02-03 10:01:27 +0100554 printclockname(tcp->u_arg[0]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200555 tprints(", ");
Roland McGrath1e356792003-03-30 23:52:28 +0000556 } else {
557 if (syserror(tcp))
558 tprintf("%#lx", tcp->u_arg[1]);
559 else
560 printtv(tcp, tcp->u_arg[1]);
561 }
562 return 0;
563}
564
565int
Denys Vlasenko12014262011-05-30 14:00:14 +0200566sys_clock_nanosleep(struct tcb *tcp)
Roland McGrath1e356792003-03-30 23:52:28 +0000567{
568 if (entering(tcp)) {
Stefan Sørensena5fea902014-02-03 10:01:27 +0100569 printclockname(tcp->u_arg[0]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200570 tprints(", ");
Roland McGrathb2dee132005-06-01 19:02:36 +0000571 printflags(clockflags, tcp->u_arg[1], "TIMER_???");
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200572 tprints(", ");
Roland McGrath1e356792003-03-30 23:52:28 +0000573 printtv(tcp, tcp->u_arg[2]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200574 tprints(", ");
Roland McGrath1e356792003-03-30 23:52:28 +0000575 } else {
576 if (syserror(tcp))
577 tprintf("%#lx", tcp->u_arg[3]);
578 else
579 printtv(tcp, tcp->u_arg[3]);
580 }
581 return 0;
582}
583
Dmitry V. Levin73215472012-03-11 21:25:51 +0000584int
585sys_clock_adjtime(struct tcb *tcp)
586{
587 if (exiting(tcp))
588 return do_adjtimex(tcp, tcp->u_arg[1]);
Stefan Sørensena5fea902014-02-03 10:01:27 +0100589 printclockname(tcp->u_arg[0]);
Dmitry V. Levin73215472012-03-11 21:25:51 +0000590 tprints(", ");
591 return 0;
592}
593
Roland McGrath1e356792003-03-30 23:52:28 +0000594#ifndef SIGEV_THREAD_ID
595# define SIGEV_THREAD_ID 4
596#endif
Dmitry V. Levin0ed617b2014-04-25 23:30:54 +0000597#include "xlat/sigev_value.h"
Roland McGrath1e356792003-03-30 23:52:28 +0000598
Dmitry V. Levind3cb3922006-12-13 17:45:02 +0000599#if SUPPORTED_PERSONALITIES > 1
600static void
601printsigevent32(struct tcb *tcp, long arg)
602{
Denys Vlasenko1d632462009-04-14 12:51:00 +0000603 struct {
Dmitry V. Levind3cb3922006-12-13 17:45:02 +0000604 int sigev_value;
605 int sigev_signo;
606 int sigev_notify;
607
Denys Vlasenko1d632462009-04-14 12:51:00 +0000608 union {
Dmitry V. Levind3cb3922006-12-13 17:45:02 +0000609 int tid;
Denys Vlasenko1d632462009-04-14 12:51:00 +0000610 struct {
Dmitry V. Levind3cb3922006-12-13 17:45:02 +0000611 int function, attribute;
612 } thread;
613 } un;
614 } sev;
615
616 if (umove(tcp, arg, &sev) < 0)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200617 tprints("{...}");
Denys Vlasenko1d632462009-04-14 12:51:00 +0000618 else {
Dmitry V. Levind3cb3922006-12-13 17:45:02 +0000619 tprintf("{%#x, ", sev.sigev_value);
620 if (sev.sigev_notify == SIGEV_SIGNAL)
621 tprintf("%s, ", signame(sev.sigev_signo));
622 else
623 tprintf("%u, ", sev.sigev_signo);
Dmitry V. Levinbae549e2014-02-05 01:46:10 +0000624 printxval(sigev_value, sev.sigev_notify, "SIGEV_???");
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200625 tprints(", ");
Dmitry V. Levind3cb3922006-12-13 17:45:02 +0000626 if (sev.sigev_notify == SIGEV_THREAD_ID)
627 tprintf("{%d}", sev.un.tid);
628 else if (sev.sigev_notify == SIGEV_THREAD)
629 tprintf("{%#x, %#x}",
630 sev.un.thread.function,
631 sev.un.thread.attribute);
632 else
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200633 tprints("{...}");
634 tprints("}");
Dmitry V. Levind3cb3922006-12-13 17:45:02 +0000635 }
636}
637#endif
638
Roland McGrath1e356792003-03-30 23:52:28 +0000639void
Dmitry V. Levind3cb3922006-12-13 17:45:02 +0000640printsigevent(struct tcb *tcp, long arg)
Roland McGrath1e356792003-03-30 23:52:28 +0000641{
642 struct sigevent sev;
Dmitry V. Levind3cb3922006-12-13 17:45:02 +0000643
644#if SUPPORTED_PERSONALITIES > 1
Denys Vlasenko9fd4f962012-03-19 09:36:42 +0100645 if (current_wordsize == 4) {
Dmitry V. Levind3cb3922006-12-13 17:45:02 +0000646 printsigevent32(tcp, arg);
647 return;
648 }
649#endif
Denys Vlasenkob63256e2011-06-07 12:13:24 +0200650 if (umove(tcp, arg, &sev) < 0)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200651 tprints("{...}");
Roland McGrath1e356792003-03-30 23:52:28 +0000652 else {
Roland McGrath675d4a62004-09-11 08:12:45 +0000653 tprintf("{%p, ", sev.sigev_value.sival_ptr);
654 if (sev.sigev_notify == SIGEV_SIGNAL)
655 tprintf("%s, ", signame(sev.sigev_signo));
656 else
657 tprintf("%u, ", sev.sigev_signo);
Dmitry V. Levinbae549e2014-02-05 01:46:10 +0000658 printxval(sigev_value, sev.sigev_notify, "SIGEV_???");
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200659 tprints(", ");
Roland McGrath1e356792003-03-30 23:52:28 +0000660 if (sev.sigev_notify == SIGEV_THREAD_ID)
Dmitry V. Levinae5aa472013-11-11 23:54:30 +0000661#if defined(HAVE_STRUCT_SIGEVENT__SIGEV_UN__PAD)
Roland McGrath1e356792003-03-30 23:52:28 +0000662 /* _pad[0] is the _tid field which might not be
663 present in the userlevel definition of the
664 struct. */
665 tprintf("{%d}", sev._sigev_un._pad[0]);
Dmitry V. Levinae5aa472013-11-11 23:54:30 +0000666#elif defined(HAVE_STRUCT_SIGEVENT___PAD)
667 tprintf("{%d}", sev.__pad[0]);
668#else
669# warning unfamiliar struct sigevent => incomplete SIGEV_THREAD_ID decoding
670 tprints("{...}");
671#endif
Roland McGrathd4c85eb2004-04-16 21:48:44 +0000672 else if (sev.sigev_notify == SIGEV_THREAD)
673 tprintf("{%p, %p}", sev.sigev_notify_function,
674 sev.sigev_notify_attributes);
Roland McGrath1e356792003-03-30 23:52:28 +0000675 else
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200676 tprints("{...}");
677 tprints("}");
Roland McGrath1e356792003-03-30 23:52:28 +0000678 }
679}
680
681int
Denys Vlasenko12014262011-05-30 14:00:14 +0200682sys_timer_create(struct tcb *tcp)
Roland McGrath1e356792003-03-30 23:52:28 +0000683{
684 if (entering(tcp)) {
Stefan Sørensena5fea902014-02-03 10:01:27 +0100685 printclockname(tcp->u_arg[0]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200686 tprints(", ");
Roland McGrath1e356792003-03-30 23:52:28 +0000687 printsigevent(tcp, tcp->u_arg[1]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200688 tprints(", ");
Roland McGrath1e356792003-03-30 23:52:28 +0000689 } else {
Andi Kleen732f3962011-06-13 21:37:40 +0000690 int timer_id;
Dmitry V. Levinac518d12006-12-13 17:03:02 +0000691
Andi Kleen732f3962011-06-13 21:37:40 +0000692 if (syserror(tcp) || umove(tcp, tcp->u_arg[2], &timer_id) < 0)
Roland McGrath1e356792003-03-30 23:52:28 +0000693 tprintf("%#lx", tcp->u_arg[2]);
Dmitry V. Levinac518d12006-12-13 17:03:02 +0000694 else
Andi Kleen732f3962011-06-13 21:37:40 +0000695 tprintf("{%d}", timer_id);
Roland McGrath1e356792003-03-30 23:52:28 +0000696 }
697 return 0;
698}
699
700int
Denys Vlasenko12014262011-05-30 14:00:14 +0200701sys_timer_settime(struct tcb *tcp)
Roland McGrath1e356792003-03-30 23:52:28 +0000702{
703 if (entering(tcp)) {
704 tprintf("%#lx, ", tcp->u_arg[0]);
Roland McGrathb2dee132005-06-01 19:02:36 +0000705 printflags(clockflags, tcp->u_arg[1], "TIMER_???");
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200706 tprints(", ");
Roland McGrath1e356792003-03-30 23:52:28 +0000707 printitv(tcp, tcp->u_arg[2]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200708 tprints(", ");
Roland McGrath1e356792003-03-30 23:52:28 +0000709 } else {
710 if (syserror(tcp))
711 tprintf("%#lx", tcp->u_arg[3]);
712 else
713 printitv(tcp, tcp->u_arg[3]);
714 }
715 return 0;
716}
717
718int
Denys Vlasenko12014262011-05-30 14:00:14 +0200719sys_timer_gettime(struct tcb *tcp)
Roland McGrath1e356792003-03-30 23:52:28 +0000720{
721 if (entering(tcp)) {
722 tprintf("%#lx, ", tcp->u_arg[0]);
723 } else {
724 if (syserror(tcp))
725 tprintf("%#lx", tcp->u_arg[1]);
726 else
727 printitv(tcp, tcp->u_arg[1]);
728 }
729 return 0;
730}
Roland McGrathd83c50b2004-10-06 22:27:43 +0000731
732static void
Denys Vlasenko12014262011-05-30 14:00:14 +0200733print_rtc(struct tcb *tcp, const struct rtc_time *rt)
Roland McGrathd83c50b2004-10-06 22:27:43 +0000734{
735 tprintf("{tm_sec=%d, tm_min=%d, tm_hour=%d, "
736 "tm_mday=%d, tm_mon=%d, tm_year=%d, ",
737 rt->tm_sec, rt->tm_min, rt->tm_hour,
738 rt->tm_mday, rt->tm_mon, rt->tm_year);
739 if (!abbrev(tcp))
740 tprintf("tm_wday=%d, tm_yday=%d, tm_isdst=%d}",
741 rt->tm_wday, rt->tm_yday, rt->tm_isdst);
742 else
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200743 tprints("...}");
Roland McGrathd83c50b2004-10-06 22:27:43 +0000744}
745
746int
Denys Vlasenko12014262011-05-30 14:00:14 +0200747rtc_ioctl(struct tcb *tcp, long code, long arg)
Roland McGrathd83c50b2004-10-06 22:27:43 +0000748{
749 switch (code) {
750 case RTC_ALM_SET:
751 case RTC_SET_TIME:
752 if (entering(tcp)) {
753 struct rtc_time rt;
754 if (umove(tcp, arg, &rt) < 0)
755 tprintf(", %#lx", arg);
756 else {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200757 tprints(", ");
Roland McGrathd83c50b2004-10-06 22:27:43 +0000758 print_rtc(tcp, &rt);
759 }
760 }
761 break;
762 case RTC_ALM_READ:
763 case RTC_RD_TIME:
764 if (exiting(tcp)) {
765 struct rtc_time rt;
766 if (syserror(tcp) || umove(tcp, arg, &rt) < 0)
767 tprintf(", %#lx", arg);
768 else {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200769 tprints(", ");
Roland McGrathd83c50b2004-10-06 22:27:43 +0000770 print_rtc(tcp, &rt);
771 }
772 }
773 break;
774 case RTC_IRQP_SET:
775 case RTC_EPOCH_SET:
776 if (entering(tcp))
777 tprintf(", %lu", arg);
778 break;
779 case RTC_IRQP_READ:
780 case RTC_EPOCH_READ:
781 if (exiting(tcp))
782 tprintf(", %lu", arg);
783 break;
784 case RTC_WKALM_SET:
785 if (entering(tcp)) {
786 struct rtc_wkalrm wk;
787 if (umove(tcp, arg, &wk) < 0)
788 tprintf(", %#lx", arg);
789 else {
790 tprintf(", {enabled=%d, pending=%d, ",
791 wk.enabled, wk.pending);
792 print_rtc(tcp, &wk.time);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200793 tprints("}");
Roland McGrathd83c50b2004-10-06 22:27:43 +0000794 }
795 }
796 break;
797 case RTC_WKALM_RD:
798 if (exiting(tcp)) {
799 struct rtc_wkalrm wk;
800 if (syserror(tcp) || umove(tcp, arg, &wk) < 0)
801 tprintf(", %#lx", arg);
802 else {
803 tprintf(", {enabled=%d, pending=%d, ",
804 wk.enabled, wk.pending);
805 print_rtc(tcp, &wk.time);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200806 tprints("}");
Roland McGrathd83c50b2004-10-06 22:27:43 +0000807 }
808 }
809 break;
810 default:
811 if (entering(tcp))
812 tprintf(", %#lx", arg);
813 break;
814 }
815 return 1;
816}
Roland McGrathe4662342007-08-02 01:25:34 +0000817
818#ifndef TFD_TIMER_ABSTIME
819#define TFD_TIMER_ABSTIME (1 << 0)
820#endif
821
Dmitry V. Levin0ed617b2014-04-25 23:30:54 +0000822#include "xlat/timerfdflags.h"
Roland McGrathe4662342007-08-02 01:25:34 +0000823
824int
Denys Vlasenko12014262011-05-30 14:00:14 +0200825sys_timerfd(struct tcb *tcp)
Roland McGrathe4662342007-08-02 01:25:34 +0000826{
827 if (entering(tcp)) {
828 /* It does not matter that the kernel uses itimerspec. */
829 tprintf("%ld, ", tcp->u_arg[0]);
Stefan Sørensena5fea902014-02-03 10:01:27 +0100830 printclockname(tcp->u_arg[0]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200831 tprints(", ");
Roland McGrathe4662342007-08-02 01:25:34 +0000832 printflags(timerfdflags, tcp->u_arg[2], "TFD_???");
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200833 tprints(", ");
Roland McGrathe4662342007-08-02 01:25:34 +0000834 printitv(tcp, tcp->u_arg[3]);
835 }
836 return 0;
837}
Roland McGrathde328e62008-05-20 04:56:13 +0000838
839int
840sys_timerfd_create(struct tcb *tcp)
841{
842 if (entering(tcp)) {
Stefan Sørensena5fea902014-02-03 10:01:27 +0100843 printclockname(tcp->u_arg[0]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200844 tprints(", ");
Roland McGrathde328e62008-05-20 04:56:13 +0000845 printflags(timerfdflags, tcp->u_arg[1], "TFD_???");
846 }
847 return 0;
848}
849
850int
851sys_timerfd_settime(struct tcb *tcp)
852{
853 if (entering(tcp)) {
Dmitry V. Levin31382132011-03-04 05:08:02 +0300854 printfd(tcp, tcp->u_arg[0]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200855 tprints(", ");
Roland McGrathde328e62008-05-20 04:56:13 +0000856 printflags(timerfdflags, tcp->u_arg[1], "TFD_???");
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200857 tprints(", ");
Roland McGrathde328e62008-05-20 04:56:13 +0000858 printitv(tcp, tcp->u_arg[2]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200859 tprints(", ");
Roland McGrathde328e62008-05-20 04:56:13 +0000860 printitv(tcp, tcp->u_arg[3]);
861 }
862 return 0;
863}
864
865int
866sys_timerfd_gettime(struct tcb *tcp)
867{
868 if (entering(tcp)) {
Dmitry V. Levin31382132011-03-04 05:08:02 +0300869 printfd(tcp, tcp->u_arg[0]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200870 tprints(", ");
Roland McGrathde328e62008-05-20 04:56:13 +0000871 printitv(tcp, tcp->u_arg[1]);
872 }
873 return 0;
874}