blob: 6db35635df637f77610244d061d508f947324abd [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. Levine61086f2015-02-27 21:46:42 +000044#if SUPPORTED_PERSONALITIES > 1
45# if defined X86_64 || defined X32
46# define current_time_t_is_compat (current_personality == 1)
47# else
48# define current_time_t_is_compat (current_wordsize == 4)
49# endif
50#else
51# define current_time_t_is_compat 0
52#endif
53
Dmitry V. Levina7945a32006-12-13 17:10:11 +000054struct timeval32
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000055{
Dmitry V. Levina7945a32006-12-13 17:10:11 +000056 u_int32_t tv_sec, tv_usec;
57};
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000058
Dmitry V. Levin1cad25d2006-12-13 17:14:36 +000059static void
60tprint_timeval32(struct tcb *tcp, const struct timeval32 *tv)
61{
62 tprintf("{%u, %u}", tv->tv_sec, tv->tv_usec);
63}
64
65static void
66tprint_timeval(struct tcb *tcp, const struct timeval *tv)
67{
Dmitry V. Levine61086f2015-02-27 21:46:42 +000068 tprintf("{%ju, %ju}", (uintmax_t) tv->tv_sec, (uintmax_t) tv->tv_usec);
Dmitry V. Levin1cad25d2006-12-13 17:14:36 +000069}
70
Dmitry V. Levina7945a32006-12-13 17:10:11 +000071void
Roland McGrath6afc5652007-07-24 01:57:11 +000072printtv_bitness(struct tcb *tcp, long addr, enum bitness_t bitness, int special)
Dmitry V. Levina7945a32006-12-13 17:10:11 +000073{
Denys Vlasenkoa1d541e2012-01-20 11:04:04 +010074 char buf[TIMEVAL_TEXT_BUFSIZE];
75 sprinttv(buf, tcp, addr, bitness, special);
76 tprints(buf);
Dmitry V. Levina7945a32006-12-13 17:10:11 +000077}
Wichert Akkerman221f54f1999-11-18 17:26:45 +000078
Dmitry V. Levinee21a5b2014-12-26 23:55:38 +000079static char *
Dmitry V. Levine61086f2015-02-27 21:46:42 +000080do_sprinttv(char *buf, const uintmax_t sec, const uintmax_t usec,
Dmitry V. Levinee21a5b2014-12-26 23:55:38 +000081 const int special)
82{
83 if (special) {
84 switch (usec) {
85 case UTIME_NOW:
86 return stpcpy(buf, "UTIME_NOW");
87 case UTIME_OMIT:
88 return stpcpy(buf, "UTIME_OMIT");
89 }
90 }
Dmitry V. Levine61086f2015-02-27 21:46:42 +000091 return buf + sprintf(buf, "{%ju, %ju}", sec, usec);
Dmitry V. Levinee21a5b2014-12-26 23:55:38 +000092}
93
Denys Vlasenko2fb4db32011-08-31 12:26:03 +020094char *
Denys Vlasenkoa1d541e2012-01-20 11:04:04 +010095sprinttv(char *buf, struct tcb *tcp, long addr, enum bitness_t bitness, int special)
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +000096{
Dmitry V. Levina7945a32006-12-13 17:10:11 +000097 if (addr == 0)
Denys Vlasenko2fb4db32011-08-31 12:26:03 +020098 return stpcpy(buf, "NULL");
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +000099
Denys Vlasenkob9c7ae62011-09-01 11:40:40 +0200100 if (!verbose(tcp))
101 return buf + sprintf(buf, "%#lx", addr);
Denys Vlasenko2fb4db32011-08-31 12:26:03 +0200102
Dmitry V. Levine61086f2015-02-27 21:46:42 +0000103 if (bitness == BITNESS_32 || current_time_t_is_compat)
Denys Vlasenko2fb4db32011-08-31 12:26:03 +0200104 {
105 struct timeval32 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 } else {
110 struct timeval tv;
111
Dmitry V. Levinee21a5b2014-12-26 23:55:38 +0000112 if (umove(tcp, addr, &tv) >= 0)
113 return do_sprinttv(buf, tv.tv_sec, tv.tv_usec, special);
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
Dmitry V. Levine61086f2015-02-27 21:46:42 +0000138 if (current_time_t_is_compat) {
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)
Dmitry V. Levine61086f2015-02-27 21:46:42 +0000152 sprintf(buf, "{%ju, %ju}",
153 (uintmax_t) ts.tv_sec,
154 (uintmax_t) 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)) {
Dmitry V. Levin1c603a92015-02-17 22:03:17 +0000165 printnum_long(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)) {
Dmitry V. Levine61086f2015-02-27 21:46:42 +0000175 tprintf("%#lx, %#lx", tcp->u_arg[0], tcp->u_arg[1]);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000176 return 0;
177 }
178 printtv(tcp, tcp->u_arg[0]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200179 tprints(", ");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000180 printtv(tcp, tcp->u_arg[1]);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000181 }
182 return 0;
183}
184
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +0000185#ifdef ALPHA
186int
Denys Vlasenko12014262011-05-30 14:00:14 +0200187sys_osf_gettimeofday(struct tcb *tcp)
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +0000188{
Denys Vlasenko1d632462009-04-14 12:51:00 +0000189 if (exiting(tcp)) {
190 if (syserror(tcp)) {
191 tprintf("%#lx, %#lx", tcp->u_arg[0], tcp->u_arg[1]);
192 return 0;
193 }
194 printtv_bitness(tcp, tcp->u_arg[0], BITNESS_32, 0);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200195 tprints(", ");
Denys Vlasenko1d632462009-04-14 12:51:00 +0000196 printtv_bitness(tcp, tcp->u_arg[1], BITNESS_32, 0);
Denys Vlasenko1d632462009-04-14 12:51:00 +0000197 }
198 return 0;
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +0000199}
200#endif
201
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000202int
Denys Vlasenko12014262011-05-30 14:00:14 +0200203sys_settimeofday(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000204{
205 if (entering(tcp)) {
206 printtv(tcp, tcp->u_arg[0]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200207 tprints(", ");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000208 printtv(tcp, tcp->u_arg[1]);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000209 }
210 return 0;
211}
212
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +0000213#ifdef ALPHA
214int
Denys Vlasenko12014262011-05-30 14:00:14 +0200215sys_osf_settimeofday(struct tcb *tcp)
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +0000216{
Denys Vlasenko1d632462009-04-14 12:51:00 +0000217 if (entering(tcp)) {
218 printtv_bitness(tcp, tcp->u_arg[0], BITNESS_32, 0);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200219 tprints(", ");
Denys Vlasenko1d632462009-04-14 12:51:00 +0000220 printtv_bitness(tcp, tcp->u_arg[1], BITNESS_32, 0);
Denys Vlasenko1d632462009-04-14 12:51:00 +0000221 }
222 return 0;
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +0000223}
224#endif
225
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000226int
Denys Vlasenko12014262011-05-30 14:00:14 +0200227sys_adjtime(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000228{
229 if (entering(tcp)) {
230 printtv(tcp, tcp->u_arg[0]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200231 tprints(", ");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000232 } else {
233 if (syserror(tcp))
234 tprintf("%#lx", tcp->u_arg[1]);
235 else
236 printtv(tcp, tcp->u_arg[1]);
237 }
238 return 0;
239}
240
Dmitry V. Levin2e55ff42008-09-03 01:02:46 +0000241int
242sys_nanosleep(struct tcb *tcp)
243{
244 if (entering(tcp)) {
245 print_timespec(tcp, tcp->u_arg[0]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200246 tprints(", ");
Dmitry V. Levin2e55ff42008-09-03 01:02:46 +0000247 } else {
Denys Vlasenko64acaa12012-01-28 02:29:36 +0100248 /* Second (returned) timespec is only significant
Denys Vlasenko47932212013-06-30 23:53:49 +0200249 * if syscall was interrupted. On success, we print
250 * only its address, since kernel doesn't modify it,
251 * and printing the value may show uninitialized data.
Denys Vlasenko64acaa12012-01-28 02:29:36 +0100252 */
Denys Vlasenko47932212013-06-30 23:53:49 +0200253 switch (tcp->u_error) {
254 default:
255 /* Not interrupted (slept entire interval) */
256 if (tcp->u_arg[1]) {
257 tprintf("%#lx", tcp->u_arg[1]);
258 break;
259 }
260 /* Fall through: print_timespec(NULL) prints "NULL" */
261 case ERESTARTSYS:
262 case ERESTARTNOINTR:
263 case ERESTARTNOHAND:
264 case ERESTART_RESTARTBLOCK:
265 /* Interrupted */
Dmitry V. Levin2e55ff42008-09-03 01:02:46 +0000266 print_timespec(tcp, tcp->u_arg[1]);
Denys Vlasenko47932212013-06-30 23:53:49 +0200267 }
Dmitry V. Levin2e55ff42008-09-03 01:02:46 +0000268 }
269 return 0;
270}
271
Dmitry V. Levin0ed617b2014-04-25 23:30:54 +0000272#include "xlat/itimer_which.h"
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000273
274static void
Dmitry V. Levin1cad25d2006-12-13 17:14:36 +0000275printitv_bitness(struct tcb *tcp, long addr, enum bitness_t bitness)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000276{
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000277 if (addr == 0)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200278 tprints("NULL");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000279 else if (!verbose(tcp))
280 tprintf("%#lx", addr);
Denys Vlasenko1d632462009-04-14 12:51:00 +0000281 else {
282 int rc;
Dmitry V. Levin1cad25d2006-12-13 17:14:36 +0000283
Dmitry V. Levine61086f2015-02-27 21:46:42 +0000284 if (bitness == BITNESS_32 || current_time_t_is_compat) {
Denys Vlasenko1d632462009-04-14 12:51:00 +0000285 struct {
Dmitry V. Levin1cad25d2006-12-13 17:14:36 +0000286 struct timeval32 it_interval, it_value;
287 } itv;
288
Denys Vlasenko5d645812011-08-20 12:48:18 +0200289 rc = umove(tcp, addr, &itv);
290 if (rc >= 0) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200291 tprints("{it_interval=");
Dmitry V. Levin1cad25d2006-12-13 17:14:36 +0000292 tprint_timeval32(tcp, &itv.it_interval);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200293 tprints(", it_value=");
Dmitry V. Levin1cad25d2006-12-13 17:14:36 +0000294 tprint_timeval32(tcp, &itv.it_value);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200295 tprints("}");
Roland McGrathe4662342007-08-02 01:25:34 +0000296 }
Denys Vlasenko1d632462009-04-14 12:51:00 +0000297 } else {
Dmitry V. Levin1cad25d2006-12-13 17:14:36 +0000298 struct itimerval itv;
299
Denys Vlasenko5d645812011-08-20 12:48:18 +0200300 rc = umove(tcp, addr, &itv);
301 if (rc >= 0) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200302 tprints("{it_interval=");
Dmitry V. Levin1cad25d2006-12-13 17:14:36 +0000303 tprint_timeval(tcp, &itv.it_interval);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200304 tprints(", it_value=");
Dmitry V. Levin1cad25d2006-12-13 17:14:36 +0000305 tprint_timeval(tcp, &itv.it_value);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200306 tprints("}");
Roland McGrathe4662342007-08-02 01:25:34 +0000307 }
Dmitry V. Levin1cad25d2006-12-13 17:14:36 +0000308 }
Dmitry V. Levin1cad25d2006-12-13 17:14:36 +0000309 if (rc < 0)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200310 tprints("{...}");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000311 }
312}
313
Dmitry V. Levin1cad25d2006-12-13 17:14:36 +0000314#define printitv(tcp, addr) \
315 printitv_bitness((tcp), (addr), BITNESS_CURRENT)
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +0000316
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000317int
Denys Vlasenko12014262011-05-30 14:00:14 +0200318sys_getitimer(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000319{
320 if (entering(tcp)) {
Dmitry V. Levin297b5942014-04-25 23:39:20 +0000321 printxval(itimer_which, tcp->u_arg[0], "ITIMER_???");
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200322 tprints(", ");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000323 } else {
324 if (syserror(tcp))
325 tprintf("%#lx", tcp->u_arg[1]);
326 else
327 printitv(tcp, tcp->u_arg[1]);
328 }
329 return 0;
330}
331
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +0000332#ifdef ALPHA
333int
Denys Vlasenko12014262011-05-30 14:00:14 +0200334sys_osf_getitimer(struct tcb *tcp)
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +0000335{
Denys Vlasenko1d632462009-04-14 12:51:00 +0000336 if (entering(tcp)) {
Dmitry V. Levin297b5942014-04-25 23:39:20 +0000337 printxval(itimer_which, tcp->u_arg[0], "ITIMER_???");
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200338 tprints(", ");
Denys Vlasenko1d632462009-04-14 12:51:00 +0000339 } else {
340 if (syserror(tcp))
341 tprintf("%#lx", tcp->u_arg[1]);
342 else
343 printitv_bitness(tcp, tcp->u_arg[1], BITNESS_32);
344 }
345 return 0;
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +0000346}
347#endif
348
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000349int
Denys Vlasenko12014262011-05-30 14:00:14 +0200350sys_setitimer(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000351{
352 if (entering(tcp)) {
Dmitry V. Levin297b5942014-04-25 23:39:20 +0000353 printxval(itimer_which, tcp->u_arg[0], "ITIMER_???");
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200354 tprints(", ");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000355 printitv(tcp, tcp->u_arg[1]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200356 tprints(", ");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000357 } else {
358 if (syserror(tcp))
359 tprintf("%#lx", tcp->u_arg[2]);
360 else
361 printitv(tcp, tcp->u_arg[2]);
362 }
363 return 0;
364}
365
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +0000366#ifdef ALPHA
367int
Denys Vlasenko12014262011-05-30 14:00:14 +0200368sys_osf_setitimer(struct tcb *tcp)
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +0000369{
Denys Vlasenko1d632462009-04-14 12:51:00 +0000370 if (entering(tcp)) {
Dmitry V. Levin297b5942014-04-25 23:39:20 +0000371 printxval(itimer_which, tcp->u_arg[0], "ITIMER_???");
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200372 tprints(", ");
Denys Vlasenko1d632462009-04-14 12:51:00 +0000373 printitv_bitness(tcp, tcp->u_arg[1], BITNESS_32);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200374 tprints(", ");
Denys Vlasenko1d632462009-04-14 12:51:00 +0000375 } else {
376 if (syserror(tcp))
377 tprintf("%#lx", tcp->u_arg[2]);
378 else
379 printitv_bitness(tcp, tcp->u_arg[2], BITNESS_32);
380 }
381 return 0;
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +0000382}
383#endif
384
Dmitry V. Levin0ed617b2014-04-25 23:30:54 +0000385#include "xlat/adjtimex_modes.h"
Dmitry V. Levin0ed617b2014-04-25 23:30:54 +0000386#include "xlat/adjtimex_status.h"
Dmitry V. Levin0ed617b2014-04-25 23:30:54 +0000387#include "xlat/adjtimex_state.h"
Dmitry V. Levin1a684d62006-12-13 17:42:32 +0000388
Dmitry V. Levin165b15d2006-12-13 17:43:45 +0000389#if SUPPORTED_PERSONALITIES > 1
390static int
391tprint_timex32(struct tcb *tcp, long addr)
392{
Denys Vlasenko1d632462009-04-14 12:51:00 +0000393 struct {
Dmitry V. Levin165b15d2006-12-13 17:43:45 +0000394 unsigned int modes;
395 int offset;
396 int freq;
397 int maxerror;
398 int esterror;
399 int status;
400 int constant;
401 int precision;
402 int tolerance;
403 struct timeval32 time;
404 int tick;
405 int ppsfreq;
406 int jitter;
407 int shift;
408 int stabil;
409 int jitcnt;
410 int calcnt;
411 int errcnt;
412 int stbcnt;
413 } tx;
414
415 if (umove(tcp, addr, &tx) < 0)
416 return -1;
417
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200418 tprints("{modes=");
Dmitry V. Levin71d70892007-01-13 11:17:38 +0000419 printflags(adjtimex_modes, tx.modes, "ADJ_???");
Dmitry V. Levin165b15d2006-12-13 17:43:45 +0000420 tprintf(", offset=%d, freq=%d, maxerror=%d, ",
421 tx.offset, tx.freq, tx.maxerror);
422 tprintf("esterror=%u, status=", tx.esterror);
423 printflags(adjtimex_status, tx.status, "STA_???");
424 tprintf(", constant=%d, precision=%u, ",
425 tx.constant, tx.precision);
426 tprintf("tolerance=%d, time=", tx.tolerance);
427 tprint_timeval32(tcp, &tx.time);
428 tprintf(", tick=%d, ppsfreq=%d, jitter=%d",
429 tx.tick, tx.ppsfreq, tx.jitter);
430 tprintf(", shift=%d, stabil=%d, jitcnt=%d",
431 tx.shift, tx.stabil, tx.jitcnt);
432 tprintf(", calcnt=%d, errcnt=%d, stbcnt=%d",
433 tx.calcnt, tx.errcnt, tx.stbcnt);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200434 tprints("}");
Dmitry V. Levin165b15d2006-12-13 17:43:45 +0000435 return 0;
436}
437#endif /* SUPPORTED_PERSONALITIES > 1 */
438
439static int
440tprint_timex(struct tcb *tcp, long addr)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000441{
Dmitry V. Levin1a684d62006-12-13 17:42:32 +0000442 struct timex tx;
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000443
Dmitry V. Levin165b15d2006-12-13 17:43:45 +0000444#if SUPPORTED_PERSONALITIES > 1
Dmitry V. Levine61086f2015-02-27 21:46:42 +0000445 if (current_time_t_is_compat)
Dmitry V. Levin165b15d2006-12-13 17:43:45 +0000446 return tprint_timex32(tcp, addr);
447#endif
448 if (umove(tcp, addr, &tx) < 0)
449 return -1;
450
451#if LINUX_VERSION_CODE < 66332
452 tprintf("{mode=%d, offset=%ld, frequency=%ld, ",
453 tx.mode, tx.offset, tx.frequency);
454 tprintf("maxerror=%ld, esterror=%lu, status=%u, ",
455 tx.maxerror, tx.esterror, tx.status);
456 tprintf("time_constant=%ld, precision=%lu, ",
457 tx.time_constant, tx.precision);
458 tprintf("tolerance=%ld, time=", tx.tolerance);
459 tprint_timeval(tcp, &tx.time);
460#else
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200461 tprints("{modes=");
Dmitry V. Levin71d70892007-01-13 11:17:38 +0000462 printflags(adjtimex_modes, tx.modes, "ADJ_???");
Dmitry V. Levine61086f2015-02-27 21:46:42 +0000463 tprintf(", offset=%jd, freq=%jd, maxerror=%ju, esterror=%ju, status=",
464 (intmax_t) tx.offset, (intmax_t) tx.freq,
465 (uintmax_t) tx.maxerror, (uintmax_t) tx.esterror);
Dmitry V. Levin165b15d2006-12-13 17:43:45 +0000466 printflags(adjtimex_status, tx.status, "STA_???");
Dmitry V. Levine61086f2015-02-27 21:46:42 +0000467 tprintf(", constant=%jd, precision=%ju, tolerance=%jd, time=",
468 (intmax_t) tx.constant, (uintmax_t) tx.precision,
469 (intmax_t) tx.tolerance);
Dmitry V. Levin165b15d2006-12-13 17:43:45 +0000470 tprint_timeval(tcp, &tx.time);
Dmitry V. Levine61086f2015-02-27 21:46:42 +0000471 tprintf(", tick=%jd, ppsfreq=%jd, jitter=%jd",
472 (intmax_t) tx.tick, (intmax_t) tx.ppsfreq, (intmax_t) tx.jitter);
473 tprintf(", shift=%d, stabil=%jd, jitcnt=%jd",
474 tx.shift, (intmax_t) tx.stabil, (intmax_t) tx.jitcnt);
475 tprintf(", calcnt=%jd, errcnt=%jd, stbcnt=%jd",
476 (intmax_t) tx.calcnt, (intmax_t) tx.errcnt, (intmax_t) tx.stbcnt);
Dmitry V. Levin165b15d2006-12-13 17:43:45 +0000477#endif
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200478 tprints("}");
Dmitry V. Levin165b15d2006-12-13 17:43:45 +0000479 return 0;
480}
481
Dmitry V. Levin73215472012-03-11 21:25:51 +0000482static int
483do_adjtimex(struct tcb *tcp, long addr)
484{
485 if (addr == 0)
486 tprints("NULL");
487 else if (syserror(tcp) || !verbose(tcp))
488 tprintf("%#lx", addr);
489 else if (tprint_timex(tcp, addr) < 0)
490 tprints("{...}");
491 if (syserror(tcp))
492 return 0;
493 tcp->auxstr = xlookup(adjtimex_state, tcp->u_rval);
494 if (tcp->auxstr)
495 return RVAL_STR;
496 return 0;
497}
498
Dmitry V. Levin165b15d2006-12-13 17:43:45 +0000499int
500sys_adjtimex(struct tcb *tcp)
501{
Dmitry V. Levin73215472012-03-11 21:25:51 +0000502 if (exiting(tcp))
503 return do_adjtimex(tcp, tcp->u_arg[0]);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000504 return 0;
505}
Roland McGrath1e356792003-03-30 23:52:28 +0000506
Dmitry V. Levin0ed617b2014-04-25 23:30:54 +0000507#include "xlat/clockflags.h"
Dmitry V. Levin0ed617b2014-04-25 23:30:54 +0000508#include "xlat/clocknames.h"
Roland McGrath54a4edd2004-08-31 06:52:45 +0000509
Stefan Sørensena5fea902014-02-03 10:01:27 +0100510static void
511printclockname(int clockid)
512{
513#ifdef CLOCKID_TO_FD
Dmitry V. Levind35bdca2014-04-26 18:10:19 +0000514# include "xlat/cpuclocknames.h"
515
Stefan Sørensena5fea902014-02-03 10:01:27 +0100516 if (clockid < 0) {
517 if ((clockid & CLOCKFD_MASK) == CLOCKFD)
518 tprintf("FD_TO_CLOCKID(%d)", CLOCKID_TO_FD(clockid));
519 else {
520 if(CPUCLOCK_PERTHREAD(clockid))
521 tprintf("MAKE_THREAD_CPUCLOCK(%d,", CPUCLOCK_PID(clockid));
522 else
523 tprintf("MAKE_PROCESS_CPUCLOCK(%d,", CPUCLOCK_PID(clockid));
524 printxval(cpuclocknames, clockid & CLOCKFD_MASK, "CPUCLOCK_???");
525 tprints(")");
526 }
527 }
528 else
529#endif
530 printxval(clocknames, clockid, "CLOCK_???");
531}
532
Roland McGrath1e356792003-03-30 23:52:28 +0000533int
Denys Vlasenko12014262011-05-30 14:00:14 +0200534sys_clock_settime(struct tcb *tcp)
Roland McGrath1e356792003-03-30 23:52:28 +0000535{
536 if (entering(tcp)) {
Stefan Sørensena5fea902014-02-03 10:01:27 +0100537 printclockname(tcp->u_arg[0]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200538 tprints(", ");
Roland McGrath1e356792003-03-30 23:52:28 +0000539 printtv(tcp, tcp->u_arg[1]);
540 }
541 return 0;
542}
543
544int
Denys Vlasenko12014262011-05-30 14:00:14 +0200545sys_clock_gettime(struct tcb *tcp)
Roland McGrath1e356792003-03-30 23:52:28 +0000546{
547 if (entering(tcp)) {
Stefan Sørensena5fea902014-02-03 10:01:27 +0100548 printclockname(tcp->u_arg[0]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200549 tprints(", ");
Roland McGrath1e356792003-03-30 23:52:28 +0000550 } else {
551 if (syserror(tcp))
552 tprintf("%#lx", tcp->u_arg[1]);
553 else
554 printtv(tcp, tcp->u_arg[1]);
555 }
556 return 0;
557}
558
559int
Denys Vlasenko12014262011-05-30 14:00:14 +0200560sys_clock_nanosleep(struct tcb *tcp)
Roland McGrath1e356792003-03-30 23:52:28 +0000561{
562 if (entering(tcp)) {
Stefan Sørensena5fea902014-02-03 10:01:27 +0100563 printclockname(tcp->u_arg[0]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200564 tprints(", ");
Roland McGrathb2dee132005-06-01 19:02:36 +0000565 printflags(clockflags, tcp->u_arg[1], "TIMER_???");
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200566 tprints(", ");
Roland McGrath1e356792003-03-30 23:52:28 +0000567 printtv(tcp, tcp->u_arg[2]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200568 tprints(", ");
Roland McGrath1e356792003-03-30 23:52:28 +0000569 } else {
570 if (syserror(tcp))
571 tprintf("%#lx", tcp->u_arg[3]);
572 else
573 printtv(tcp, tcp->u_arg[3]);
574 }
575 return 0;
576}
577
Dmitry V. Levin73215472012-03-11 21:25:51 +0000578int
579sys_clock_adjtime(struct tcb *tcp)
580{
581 if (exiting(tcp))
582 return do_adjtimex(tcp, tcp->u_arg[1]);
Stefan Sørensena5fea902014-02-03 10:01:27 +0100583 printclockname(tcp->u_arg[0]);
Dmitry V. Levin73215472012-03-11 21:25:51 +0000584 tprints(", ");
585 return 0;
586}
587
Roland McGrath1e356792003-03-30 23:52:28 +0000588#ifndef SIGEV_THREAD_ID
589# define SIGEV_THREAD_ID 4
590#endif
Dmitry V. Levin0ed617b2014-04-25 23:30:54 +0000591#include "xlat/sigev_value.h"
Roland McGrath1e356792003-03-30 23:52:28 +0000592
Dmitry V. Levind3cb3922006-12-13 17:45:02 +0000593#if SUPPORTED_PERSONALITIES > 1
594static void
595printsigevent32(struct tcb *tcp, long arg)
596{
Denys Vlasenko1d632462009-04-14 12:51:00 +0000597 struct {
Dmitry V. Levind3cb3922006-12-13 17:45:02 +0000598 int sigev_value;
599 int sigev_signo;
600 int sigev_notify;
601
Denys Vlasenko1d632462009-04-14 12:51:00 +0000602 union {
Dmitry V. Levind3cb3922006-12-13 17:45:02 +0000603 int tid;
Denys Vlasenko1d632462009-04-14 12:51:00 +0000604 struct {
Dmitry V. Levind3cb3922006-12-13 17:45:02 +0000605 int function, attribute;
606 } thread;
607 } un;
608 } sev;
609
610 if (umove(tcp, arg, &sev) < 0)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200611 tprints("{...}");
Denys Vlasenko1d632462009-04-14 12:51:00 +0000612 else {
Dmitry V. Levind3cb3922006-12-13 17:45:02 +0000613 tprintf("{%#x, ", sev.sigev_value);
614 if (sev.sigev_notify == SIGEV_SIGNAL)
615 tprintf("%s, ", signame(sev.sigev_signo));
616 else
617 tprintf("%u, ", sev.sigev_signo);
Dmitry V. Levinbae549e2014-02-05 01:46:10 +0000618 printxval(sigev_value, sev.sigev_notify, "SIGEV_???");
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200619 tprints(", ");
Dmitry V. Levind3cb3922006-12-13 17:45:02 +0000620 if (sev.sigev_notify == SIGEV_THREAD_ID)
621 tprintf("{%d}", sev.un.tid);
622 else if (sev.sigev_notify == SIGEV_THREAD)
623 tprintf("{%#x, %#x}",
624 sev.un.thread.function,
625 sev.un.thread.attribute);
626 else
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200627 tprints("{...}");
628 tprints("}");
Dmitry V. Levind3cb3922006-12-13 17:45:02 +0000629 }
630}
631#endif
632
Roland McGrath1e356792003-03-30 23:52:28 +0000633void
Dmitry V. Levind3cb3922006-12-13 17:45:02 +0000634printsigevent(struct tcb *tcp, long arg)
Roland McGrath1e356792003-03-30 23:52:28 +0000635{
636 struct sigevent sev;
Dmitry V. Levind3cb3922006-12-13 17:45:02 +0000637
638#if SUPPORTED_PERSONALITIES > 1
Denys Vlasenko9fd4f962012-03-19 09:36:42 +0100639 if (current_wordsize == 4) {
Dmitry V. Levind3cb3922006-12-13 17:45:02 +0000640 printsigevent32(tcp, arg);
641 return;
642 }
643#endif
Denys Vlasenkob63256e2011-06-07 12:13:24 +0200644 if (umove(tcp, arg, &sev) < 0)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200645 tprints("{...}");
Roland McGrath1e356792003-03-30 23:52:28 +0000646 else {
Roland McGrath675d4a62004-09-11 08:12:45 +0000647 tprintf("{%p, ", sev.sigev_value.sival_ptr);
648 if (sev.sigev_notify == SIGEV_SIGNAL)
649 tprintf("%s, ", signame(sev.sigev_signo));
650 else
651 tprintf("%u, ", sev.sigev_signo);
Dmitry V. Levinbae549e2014-02-05 01:46:10 +0000652 printxval(sigev_value, sev.sigev_notify, "SIGEV_???");
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200653 tprints(", ");
Roland McGrath1e356792003-03-30 23:52:28 +0000654 if (sev.sigev_notify == SIGEV_THREAD_ID)
Dmitry V. Levinae5aa472013-11-11 23:54:30 +0000655#if defined(HAVE_STRUCT_SIGEVENT__SIGEV_UN__PAD)
Roland McGrath1e356792003-03-30 23:52:28 +0000656 /* _pad[0] is the _tid field which might not be
657 present in the userlevel definition of the
658 struct. */
659 tprintf("{%d}", sev._sigev_un._pad[0]);
Dmitry V. Levinae5aa472013-11-11 23:54:30 +0000660#elif defined(HAVE_STRUCT_SIGEVENT___PAD)
661 tprintf("{%d}", sev.__pad[0]);
662#else
663# warning unfamiliar struct sigevent => incomplete SIGEV_THREAD_ID decoding
664 tprints("{...}");
665#endif
Roland McGrathd4c85eb2004-04-16 21:48:44 +0000666 else if (sev.sigev_notify == SIGEV_THREAD)
667 tprintf("{%p, %p}", sev.sigev_notify_function,
668 sev.sigev_notify_attributes);
Roland McGrath1e356792003-03-30 23:52:28 +0000669 else
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200670 tprints("{...}");
671 tprints("}");
Roland McGrath1e356792003-03-30 23:52:28 +0000672 }
673}
674
675int
Denys Vlasenko12014262011-05-30 14:00:14 +0200676sys_timer_create(struct tcb *tcp)
Roland McGrath1e356792003-03-30 23:52:28 +0000677{
678 if (entering(tcp)) {
Stefan Sørensena5fea902014-02-03 10:01:27 +0100679 printclockname(tcp->u_arg[0]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200680 tprints(", ");
Roland McGrath1e356792003-03-30 23:52:28 +0000681 printsigevent(tcp, tcp->u_arg[1]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200682 tprints(", ");
Roland McGrath1e356792003-03-30 23:52:28 +0000683 } else {
Andi Kleen732f3962011-06-13 21:37:40 +0000684 int timer_id;
Dmitry V. Levinac518d12006-12-13 17:03:02 +0000685
Andi Kleen732f3962011-06-13 21:37:40 +0000686 if (syserror(tcp) || umove(tcp, tcp->u_arg[2], &timer_id) < 0)
Roland McGrath1e356792003-03-30 23:52:28 +0000687 tprintf("%#lx", tcp->u_arg[2]);
Dmitry V. Levinac518d12006-12-13 17:03:02 +0000688 else
Andi Kleen732f3962011-06-13 21:37:40 +0000689 tprintf("{%d}", timer_id);
Roland McGrath1e356792003-03-30 23:52:28 +0000690 }
691 return 0;
692}
693
694int
Denys Vlasenko12014262011-05-30 14:00:14 +0200695sys_timer_settime(struct tcb *tcp)
Roland McGrath1e356792003-03-30 23:52:28 +0000696{
697 if (entering(tcp)) {
698 tprintf("%#lx, ", tcp->u_arg[0]);
Roland McGrathb2dee132005-06-01 19:02:36 +0000699 printflags(clockflags, tcp->u_arg[1], "TIMER_???");
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200700 tprints(", ");
Roland McGrath1e356792003-03-30 23:52:28 +0000701 printitv(tcp, tcp->u_arg[2]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200702 tprints(", ");
Roland McGrath1e356792003-03-30 23:52:28 +0000703 } else {
704 if (syserror(tcp))
705 tprintf("%#lx", tcp->u_arg[3]);
706 else
707 printitv(tcp, tcp->u_arg[3]);
708 }
709 return 0;
710}
711
712int
Denys Vlasenko12014262011-05-30 14:00:14 +0200713sys_timer_gettime(struct tcb *tcp)
Roland McGrath1e356792003-03-30 23:52:28 +0000714{
715 if (entering(tcp)) {
716 tprintf("%#lx, ", tcp->u_arg[0]);
717 } else {
718 if (syserror(tcp))
719 tprintf("%#lx", tcp->u_arg[1]);
720 else
721 printitv(tcp, tcp->u_arg[1]);
722 }
723 return 0;
724}
Roland McGrathd83c50b2004-10-06 22:27:43 +0000725
726static void
Denys Vlasenko12014262011-05-30 14:00:14 +0200727print_rtc(struct tcb *tcp, const struct rtc_time *rt)
Roland McGrathd83c50b2004-10-06 22:27:43 +0000728{
729 tprintf("{tm_sec=%d, tm_min=%d, tm_hour=%d, "
730 "tm_mday=%d, tm_mon=%d, tm_year=%d, ",
731 rt->tm_sec, rt->tm_min, rt->tm_hour,
732 rt->tm_mday, rt->tm_mon, rt->tm_year);
733 if (!abbrev(tcp))
734 tprintf("tm_wday=%d, tm_yday=%d, tm_isdst=%d}",
735 rt->tm_wday, rt->tm_yday, rt->tm_isdst);
736 else
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200737 tprints("...}");
Roland McGrathd83c50b2004-10-06 22:27:43 +0000738}
739
740int
Dmitry V. Levinc7afb482015-01-19 18:44:21 +0000741rtc_ioctl(struct tcb *tcp, const unsigned int code, long arg)
Roland McGrathd83c50b2004-10-06 22:27:43 +0000742{
743 switch (code) {
744 case RTC_ALM_SET:
745 case RTC_SET_TIME:
746 if (entering(tcp)) {
747 struct rtc_time rt;
748 if (umove(tcp, arg, &rt) < 0)
749 tprintf(", %#lx", arg);
750 else {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200751 tprints(", ");
Roland McGrathd83c50b2004-10-06 22:27:43 +0000752 print_rtc(tcp, &rt);
753 }
754 }
755 break;
756 case RTC_ALM_READ:
757 case RTC_RD_TIME:
758 if (exiting(tcp)) {
759 struct rtc_time rt;
760 if (syserror(tcp) || umove(tcp, arg, &rt) < 0)
761 tprintf(", %#lx", arg);
762 else {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200763 tprints(", ");
Roland McGrathd83c50b2004-10-06 22:27:43 +0000764 print_rtc(tcp, &rt);
765 }
766 }
767 break;
768 case RTC_IRQP_SET:
769 case RTC_EPOCH_SET:
770 if (entering(tcp))
771 tprintf(", %lu", arg);
772 break;
773 case RTC_IRQP_READ:
774 case RTC_EPOCH_READ:
775 if (exiting(tcp))
776 tprintf(", %lu", arg);
777 break;
778 case RTC_WKALM_SET:
779 if (entering(tcp)) {
780 struct rtc_wkalrm wk;
781 if (umove(tcp, arg, &wk) < 0)
782 tprintf(", %#lx", arg);
783 else {
784 tprintf(", {enabled=%d, pending=%d, ",
785 wk.enabled, wk.pending);
786 print_rtc(tcp, &wk.time);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200787 tprints("}");
Roland McGrathd83c50b2004-10-06 22:27:43 +0000788 }
789 }
790 break;
791 case RTC_WKALM_RD:
792 if (exiting(tcp)) {
793 struct rtc_wkalrm wk;
794 if (syserror(tcp) || umove(tcp, arg, &wk) < 0)
795 tprintf(", %#lx", arg);
796 else {
797 tprintf(", {enabled=%d, pending=%d, ",
798 wk.enabled, wk.pending);
799 print_rtc(tcp, &wk.time);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200800 tprints("}");
Roland McGrathd83c50b2004-10-06 22:27:43 +0000801 }
802 }
803 break;
804 default:
805 if (entering(tcp))
806 tprintf(", %#lx", arg);
807 break;
808 }
809 return 1;
810}
Roland McGrathe4662342007-08-02 01:25:34 +0000811
Dmitry V. Levin0ed617b2014-04-25 23:30:54 +0000812#include "xlat/timerfdflags.h"
Roland McGrathe4662342007-08-02 01:25:34 +0000813
814int
Denys Vlasenko12014262011-05-30 14:00:14 +0200815sys_timerfd(struct tcb *tcp)
Roland McGrathe4662342007-08-02 01:25:34 +0000816{
817 if (entering(tcp)) {
818 /* It does not matter that the kernel uses itimerspec. */
819 tprintf("%ld, ", tcp->u_arg[0]);
Stefan Sørensena5fea902014-02-03 10:01:27 +0100820 printclockname(tcp->u_arg[0]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200821 tprints(", ");
Roland McGrathe4662342007-08-02 01:25:34 +0000822 printflags(timerfdflags, tcp->u_arg[2], "TFD_???");
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200823 tprints(", ");
Roland McGrathe4662342007-08-02 01:25:34 +0000824 printitv(tcp, tcp->u_arg[3]);
825 }
826 return 0;
827}
Roland McGrathde328e62008-05-20 04:56:13 +0000828
829int
830sys_timerfd_create(struct tcb *tcp)
831{
832 if (entering(tcp)) {
Stefan Sørensena5fea902014-02-03 10:01:27 +0100833 printclockname(tcp->u_arg[0]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200834 tprints(", ");
Roland McGrathde328e62008-05-20 04:56:13 +0000835 printflags(timerfdflags, tcp->u_arg[1], "TFD_???");
836 }
837 return 0;
838}
839
840int
841sys_timerfd_settime(struct tcb *tcp)
842{
843 if (entering(tcp)) {
Dmitry V. Levin31382132011-03-04 05:08:02 +0300844 printfd(tcp, tcp->u_arg[0]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200845 tprints(", ");
Roland McGrathde328e62008-05-20 04:56:13 +0000846 printflags(timerfdflags, tcp->u_arg[1], "TFD_???");
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200847 tprints(", ");
Roland McGrathde328e62008-05-20 04:56:13 +0000848 printitv(tcp, tcp->u_arg[2]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200849 tprints(", ");
Roland McGrathde328e62008-05-20 04:56:13 +0000850 printitv(tcp, tcp->u_arg[3]);
851 }
852 return 0;
853}
854
855int
856sys_timerfd_gettime(struct tcb *tcp)
857{
858 if (entering(tcp)) {
Dmitry V. Levin31382132011-03-04 05:08:02 +0300859 printfd(tcp, tcp->u_arg[0]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200860 tprints(", ");
Roland McGrathde328e62008-05-20 04:56:13 +0000861 printitv(tcp, tcp->u_arg[1]);
862 }
863 return 0;
864}