blob: e457a5ff06a14cce29aa37b4646c8e64e0cb4f57 [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
259 * if syscall was interrupted. We print only its address
260 * on _success_, since kernel doesn't modify its value.
261 */
262 if (is_restart_error(tcp) || !tcp->u_arg[1])
263 /* Interrupted (or NULL) */
Dmitry V. Levin2e55ff42008-09-03 01:02:46 +0000264 print_timespec(tcp, tcp->u_arg[1]);
265 else
Denys Vlasenko64acaa12012-01-28 02:29:36 +0100266 /* Success */
Dmitry V. Levin2e55ff42008-09-03 01:02:46 +0000267 tprintf("%#lx", tcp->u_arg[1]);
268 }
269 return 0;
270}
271
Roland McGrathd9f816f2004-09-04 03:39:20 +0000272static const struct xlat which[] = {
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000273 { ITIMER_REAL, "ITIMER_REAL" },
274 { ITIMER_VIRTUAL,"ITIMER_VIRTUAL"},
275 { ITIMER_PROF, "ITIMER_PROF" },
276 { 0, NULL },
277};
278
279static void
Dmitry V. Levin1cad25d2006-12-13 17:14:36 +0000280printitv_bitness(struct tcb *tcp, long addr, enum bitness_t bitness)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000281{
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000282 if (addr == 0)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200283 tprints("NULL");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000284 else if (!verbose(tcp))
285 tprintf("%#lx", addr);
Denys Vlasenko1d632462009-04-14 12:51:00 +0000286 else {
287 int rc;
Dmitry V. Levin1cad25d2006-12-13 17:14:36 +0000288
289 if (bitness == BITNESS_32
Denys Vlasenko84703742012-02-25 02:38:52 +0100290#if SUPPORTED_PERSONALITIES > 1
Denys Vlasenko9fd4f962012-03-19 09:36:42 +0100291 || current_wordsize == 4
Dmitry V. Levin1cad25d2006-12-13 17:14:36 +0000292#endif
293 )
294 {
Denys Vlasenko1d632462009-04-14 12:51:00 +0000295 struct {
Dmitry V. Levin1cad25d2006-12-13 17:14:36 +0000296 struct timeval32 it_interval, it_value;
297 } itv;
298
Denys Vlasenko5d645812011-08-20 12:48:18 +0200299 rc = umove(tcp, addr, &itv);
300 if (rc >= 0) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200301 tprints("{it_interval=");
Dmitry V. Levin1cad25d2006-12-13 17:14:36 +0000302 tprint_timeval32(tcp, &itv.it_interval);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200303 tprints(", it_value=");
Dmitry V. Levin1cad25d2006-12-13 17:14:36 +0000304 tprint_timeval32(tcp, &itv.it_value);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200305 tprints("}");
Roland McGrathe4662342007-08-02 01:25:34 +0000306 }
Denys Vlasenko1d632462009-04-14 12:51:00 +0000307 } else {
Dmitry V. Levin1cad25d2006-12-13 17:14:36 +0000308 struct itimerval itv;
309
Denys Vlasenko5d645812011-08-20 12:48:18 +0200310 rc = umove(tcp, addr, &itv);
311 if (rc >= 0) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200312 tprints("{it_interval=");
Dmitry V. Levin1cad25d2006-12-13 17:14:36 +0000313 tprint_timeval(tcp, &itv.it_interval);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200314 tprints(", it_value=");
Dmitry V. Levin1cad25d2006-12-13 17:14:36 +0000315 tprint_timeval(tcp, &itv.it_value);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200316 tprints("}");
Roland McGrathe4662342007-08-02 01:25:34 +0000317 }
Dmitry V. Levin1cad25d2006-12-13 17:14:36 +0000318 }
Dmitry V. Levin1cad25d2006-12-13 17:14:36 +0000319 if (rc < 0)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200320 tprints("{...}");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000321 }
322}
323
Dmitry V. Levin1cad25d2006-12-13 17:14:36 +0000324#define printitv(tcp, addr) \
325 printitv_bitness((tcp), (addr), BITNESS_CURRENT)
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +0000326
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000327int
Denys Vlasenko12014262011-05-30 14:00:14 +0200328sys_getitimer(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000329{
330 if (entering(tcp)) {
331 printxval(which, tcp->u_arg[0], "ITIMER_???");
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200332 tprints(", ");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000333 } else {
334 if (syserror(tcp))
335 tprintf("%#lx", tcp->u_arg[1]);
336 else
337 printitv(tcp, tcp->u_arg[1]);
338 }
339 return 0;
340}
341
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +0000342#ifdef ALPHA
343int
Denys Vlasenko12014262011-05-30 14:00:14 +0200344sys_osf_getitimer(struct tcb *tcp)
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +0000345{
Denys Vlasenko1d632462009-04-14 12:51:00 +0000346 if (entering(tcp)) {
347 printxval(which, tcp->u_arg[0], "ITIMER_???");
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200348 tprints(", ");
Denys Vlasenko1d632462009-04-14 12:51:00 +0000349 } else {
350 if (syserror(tcp))
351 tprintf("%#lx", tcp->u_arg[1]);
352 else
353 printitv_bitness(tcp, tcp->u_arg[1], BITNESS_32);
354 }
355 return 0;
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +0000356}
357#endif
358
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000359int
Denys Vlasenko12014262011-05-30 14:00:14 +0200360sys_setitimer(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000361{
362 if (entering(tcp)) {
363 printxval(which, tcp->u_arg[0], "ITIMER_???");
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200364 tprints(", ");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000365 printitv(tcp, tcp->u_arg[1]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200366 tprints(", ");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000367 } else {
368 if (syserror(tcp))
369 tprintf("%#lx", tcp->u_arg[2]);
370 else
371 printitv(tcp, tcp->u_arg[2]);
372 }
373 return 0;
374}
375
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +0000376#ifdef ALPHA
377int
Denys Vlasenko12014262011-05-30 14:00:14 +0200378sys_osf_setitimer(struct tcb *tcp)
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +0000379{
Denys Vlasenko1d632462009-04-14 12:51:00 +0000380 if (entering(tcp)) {
381 printxval(which, tcp->u_arg[0], "ITIMER_???");
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200382 tprints(", ");
Denys Vlasenko1d632462009-04-14 12:51:00 +0000383 printitv_bitness(tcp, tcp->u_arg[1], BITNESS_32);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200384 tprints(", ");
Denys Vlasenko1d632462009-04-14 12:51:00 +0000385 } else {
386 if (syserror(tcp))
387 tprintf("%#lx", tcp->u_arg[2]);
388 else
389 printitv_bitness(tcp, tcp->u_arg[2], BITNESS_32);
390 }
391 return 0;
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +0000392}
393#endif
394
Dmitry V. Levin1a684d62006-12-13 17:42:32 +0000395static const struct xlat adjtimex_modes[] = {
Denys Vlasenko3e3490a2012-03-17 01:27:37 +0100396 { 0, "0" },
Dmitry V. Levin1a684d62006-12-13 17:42:32 +0000397#ifdef ADJ_OFFSET
Denys Vlasenko3e3490a2012-03-17 01:27:37 +0100398 { ADJ_OFFSET, "ADJ_OFFSET" },
Dmitry V. Levin1a684d62006-12-13 17:42:32 +0000399#endif
400#ifdef ADJ_FREQUENCY
Denys Vlasenko3e3490a2012-03-17 01:27:37 +0100401 { ADJ_FREQUENCY, "ADJ_FREQUENCY" },
Dmitry V. Levin1a684d62006-12-13 17:42:32 +0000402#endif
403#ifdef ADJ_MAXERROR
Denys Vlasenko3e3490a2012-03-17 01:27:37 +0100404 { ADJ_MAXERROR, "ADJ_MAXERROR" },
Dmitry V. Levin1a684d62006-12-13 17:42:32 +0000405#endif
406#ifdef ADJ_ESTERROR
Denys Vlasenko3e3490a2012-03-17 01:27:37 +0100407 { ADJ_ESTERROR, "ADJ_ESTERROR" },
Dmitry V. Levin1a684d62006-12-13 17:42:32 +0000408#endif
409#ifdef ADJ_STATUS
Denys Vlasenko3e3490a2012-03-17 01:27:37 +0100410 { ADJ_STATUS, "ADJ_STATUS" },
Dmitry V. Levin1a684d62006-12-13 17:42:32 +0000411#endif
412#ifdef ADJ_TIMECONST
Denys Vlasenko3e3490a2012-03-17 01:27:37 +0100413 { ADJ_TIMECONST, "ADJ_TIMECONST" },
Dmitry V. Levin1a684d62006-12-13 17:42:32 +0000414#endif
415#ifdef ADJ_TICK
Denys Vlasenko3e3490a2012-03-17 01:27:37 +0100416 { ADJ_TICK, "ADJ_TICK" },
Dmitry V. Levin1a684d62006-12-13 17:42:32 +0000417#endif
418#ifdef ADJ_OFFSET_SINGLESHOT
Denys Vlasenko3e3490a2012-03-17 01:27:37 +0100419 { ADJ_OFFSET_SINGLESHOT, "ADJ_OFFSET_SINGLESHOT" },
Dmitry V. Levin1a684d62006-12-13 17:42:32 +0000420#endif
Denys Vlasenko3e3490a2012-03-17 01:27:37 +0100421 { 0, NULL }
Dmitry V. Levin1a684d62006-12-13 17:42:32 +0000422};
423
424static const struct xlat adjtimex_status[] = {
425#ifdef STA_PLL
Denys Vlasenko3e3490a2012-03-17 01:27:37 +0100426 { STA_PLL, "STA_PLL" },
Dmitry V. Levin1a684d62006-12-13 17:42:32 +0000427#endif
428#ifdef STA_PPSFREQ
Denys Vlasenko3e3490a2012-03-17 01:27:37 +0100429 { STA_PPSFREQ, "STA_PPSFREQ" },
Dmitry V. Levin1a684d62006-12-13 17:42:32 +0000430#endif
431#ifdef STA_PPSTIME
Denys Vlasenko3e3490a2012-03-17 01:27:37 +0100432 { STA_PPSTIME, "STA_PPSTIME" },
Dmitry V. Levin1a684d62006-12-13 17:42:32 +0000433#endif
434#ifdef STA_FLL
Denys Vlasenko3e3490a2012-03-17 01:27:37 +0100435 { STA_FLL, "STA_FLL" },
Dmitry V. Levin1a684d62006-12-13 17:42:32 +0000436#endif
437#ifdef STA_INS
Denys Vlasenko3e3490a2012-03-17 01:27:37 +0100438 { STA_INS, "STA_INS" },
Dmitry V. Levin1a684d62006-12-13 17:42:32 +0000439#endif
440#ifdef STA_DEL
Denys Vlasenko3e3490a2012-03-17 01:27:37 +0100441 { STA_DEL, "STA_DEL" },
Dmitry V. Levin1a684d62006-12-13 17:42:32 +0000442#endif
443#ifdef STA_UNSYNC
Denys Vlasenko3e3490a2012-03-17 01:27:37 +0100444 { STA_UNSYNC, "STA_UNSYNC" },
Dmitry V. Levin1a684d62006-12-13 17:42:32 +0000445#endif
446#ifdef STA_FREQHOLD
Denys Vlasenko3e3490a2012-03-17 01:27:37 +0100447 { STA_FREQHOLD, "STA_FREQHOLD" },
Dmitry V. Levin1a684d62006-12-13 17:42:32 +0000448#endif
449#ifdef STA_PPSSIGNAL
Denys Vlasenko3e3490a2012-03-17 01:27:37 +0100450 { STA_PPSSIGNAL, "STA_PPSSIGNAL" },
Dmitry V. Levin1a684d62006-12-13 17:42:32 +0000451#endif
452#ifdef STA_PPSJITTER
Denys Vlasenko3e3490a2012-03-17 01:27:37 +0100453 { STA_PPSJITTER, "STA_PPSJITTER" },
Dmitry V. Levin1a684d62006-12-13 17:42:32 +0000454#endif
455#ifdef STA_PPSWANDER
Denys Vlasenko3e3490a2012-03-17 01:27:37 +0100456 { STA_PPSWANDER, "STA_PPSWANDER" },
Dmitry V. Levin1a684d62006-12-13 17:42:32 +0000457#endif
458#ifdef STA_PPSERROR
Denys Vlasenko3e3490a2012-03-17 01:27:37 +0100459 { STA_PPSERROR, "STA_PPSERROR" },
Dmitry V. Levin1a684d62006-12-13 17:42:32 +0000460#endif
461#ifdef STA_CLOCKERR
Denys Vlasenko3e3490a2012-03-17 01:27:37 +0100462 { STA_CLOCKERR, "STA_CLOCKERR" },
Dmitry V. Levin1a684d62006-12-13 17:42:32 +0000463#endif
Dmitry V. Levina28fbfd2012-05-01 21:17:51 +0000464#ifdef STA_NANO
465 { STA_NANO, "STA_NANO" },
466#endif
467#ifdef STA_MODE
468 { STA_MODE, "STA_MODE" },
469#endif
470#ifdef STA_CLK
471 { STA_CLK, "STA_CLK" },
472#endif
Denys Vlasenko3e3490a2012-03-17 01:27:37 +0100473 { 0, NULL }
Dmitry V. Levin1a684d62006-12-13 17:42:32 +0000474};
475
476static const struct xlat adjtimex_state[] = {
477#ifdef TIME_OK
Denys Vlasenko3e3490a2012-03-17 01:27:37 +0100478 { TIME_OK, "TIME_OK" },
Dmitry V. Levin1a684d62006-12-13 17:42:32 +0000479#endif
480#ifdef TIME_INS
Denys Vlasenko3e3490a2012-03-17 01:27:37 +0100481 { TIME_INS, "TIME_INS" },
Dmitry V. Levin1a684d62006-12-13 17:42:32 +0000482#endif
483#ifdef TIME_DEL
Denys Vlasenko3e3490a2012-03-17 01:27:37 +0100484 { TIME_DEL, "TIME_DEL" },
Dmitry V. Levin1a684d62006-12-13 17:42:32 +0000485#endif
486#ifdef TIME_OOP
Denys Vlasenko3e3490a2012-03-17 01:27:37 +0100487 { TIME_OOP, "TIME_OOP" },
Dmitry V. Levin1a684d62006-12-13 17:42:32 +0000488#endif
489#ifdef TIME_WAIT
Denys Vlasenko3e3490a2012-03-17 01:27:37 +0100490 { TIME_WAIT, "TIME_WAIT" },
Dmitry V. Levin1a684d62006-12-13 17:42:32 +0000491#endif
492#ifdef TIME_ERROR
Denys Vlasenko3e3490a2012-03-17 01:27:37 +0100493 { TIME_ERROR, "TIME_ERROR" },
Dmitry V. Levin1a684d62006-12-13 17:42:32 +0000494#endif
Denys Vlasenko3e3490a2012-03-17 01:27:37 +0100495 { 0, NULL }
Dmitry V. Levin1a684d62006-12-13 17:42:32 +0000496};
497
Dmitry V. Levin165b15d2006-12-13 17:43:45 +0000498#if SUPPORTED_PERSONALITIES > 1
499static int
500tprint_timex32(struct tcb *tcp, long addr)
501{
Denys Vlasenko1d632462009-04-14 12:51:00 +0000502 struct {
Dmitry V. Levin165b15d2006-12-13 17:43:45 +0000503 unsigned int modes;
504 int offset;
505 int freq;
506 int maxerror;
507 int esterror;
508 int status;
509 int constant;
510 int precision;
511 int tolerance;
512 struct timeval32 time;
513 int tick;
514 int ppsfreq;
515 int jitter;
516 int shift;
517 int stabil;
518 int jitcnt;
519 int calcnt;
520 int errcnt;
521 int stbcnt;
522 } tx;
523
524 if (umove(tcp, addr, &tx) < 0)
525 return -1;
526
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200527 tprints("{modes=");
Dmitry V. Levin71d70892007-01-13 11:17:38 +0000528 printflags(adjtimex_modes, tx.modes, "ADJ_???");
Dmitry V. Levin165b15d2006-12-13 17:43:45 +0000529 tprintf(", offset=%d, freq=%d, maxerror=%d, ",
530 tx.offset, tx.freq, tx.maxerror);
531 tprintf("esterror=%u, status=", tx.esterror);
532 printflags(adjtimex_status, tx.status, "STA_???");
533 tprintf(", constant=%d, precision=%u, ",
534 tx.constant, tx.precision);
535 tprintf("tolerance=%d, time=", tx.tolerance);
536 tprint_timeval32(tcp, &tx.time);
537 tprintf(", tick=%d, ppsfreq=%d, jitter=%d",
538 tx.tick, tx.ppsfreq, tx.jitter);
539 tprintf(", shift=%d, stabil=%d, jitcnt=%d",
540 tx.shift, tx.stabil, tx.jitcnt);
541 tprintf(", calcnt=%d, errcnt=%d, stbcnt=%d",
542 tx.calcnt, tx.errcnt, tx.stbcnt);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200543 tprints("}");
Dmitry V. Levin165b15d2006-12-13 17:43:45 +0000544 return 0;
545}
546#endif /* SUPPORTED_PERSONALITIES > 1 */
547
548static int
549tprint_timex(struct tcb *tcp, long addr)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000550{
Dmitry V. Levin1a684d62006-12-13 17:42:32 +0000551 struct timex tx;
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000552
Dmitry V. Levin165b15d2006-12-13 17:43:45 +0000553#if SUPPORTED_PERSONALITIES > 1
Denys Vlasenko9fd4f962012-03-19 09:36:42 +0100554 if (current_wordsize == 4)
Dmitry V. Levin165b15d2006-12-13 17:43:45 +0000555 return tprint_timex32(tcp, addr);
556#endif
557 if (umove(tcp, addr, &tx) < 0)
558 return -1;
559
560#if LINUX_VERSION_CODE < 66332
561 tprintf("{mode=%d, offset=%ld, frequency=%ld, ",
562 tx.mode, tx.offset, tx.frequency);
563 tprintf("maxerror=%ld, esterror=%lu, status=%u, ",
564 tx.maxerror, tx.esterror, tx.status);
565 tprintf("time_constant=%ld, precision=%lu, ",
566 tx.time_constant, tx.precision);
567 tprintf("tolerance=%ld, time=", tx.tolerance);
568 tprint_timeval(tcp, &tx.time);
569#else
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200570 tprints("{modes=");
Dmitry V. Levin71d70892007-01-13 11:17:38 +0000571 printflags(adjtimex_modes, tx.modes, "ADJ_???");
Dmitry V. Levin165b15d2006-12-13 17:43:45 +0000572 tprintf(", offset=%ld, freq=%ld, maxerror=%ld, ",
H.J. Lu0b315b62012-02-03 10:16:03 -0800573 (long) tx.offset, (long) tx.freq, (long) tx.maxerror);
574 tprintf("esterror=%lu, status=", (long) tx.esterror);
Dmitry V. Levin165b15d2006-12-13 17:43:45 +0000575 printflags(adjtimex_status, tx.status, "STA_???");
576 tprintf(", constant=%ld, precision=%lu, ",
H.J. Lu0b315b62012-02-03 10:16:03 -0800577 (long) tx.constant, (long) tx.precision);
578 tprintf("tolerance=%ld, time=", (long) tx.tolerance);
Dmitry V. Levin165b15d2006-12-13 17:43:45 +0000579 tprint_timeval(tcp, &tx.time);
580 tprintf(", tick=%ld, ppsfreq=%ld, jitter=%ld",
H.J. Lu0b315b62012-02-03 10:16:03 -0800581 (long) tx.tick, (long) tx.ppsfreq, (long) tx.jitter);
Dmitry V. Levin165b15d2006-12-13 17:43:45 +0000582 tprintf(", shift=%d, stabil=%ld, jitcnt=%ld",
H.J. Lu0b315b62012-02-03 10:16:03 -0800583 tx.shift, (long) tx.stabil, (long) tx.jitcnt);
Dmitry V. Levin165b15d2006-12-13 17:43:45 +0000584 tprintf(", calcnt=%ld, errcnt=%ld, stbcnt=%ld",
H.J. Lu0b315b62012-02-03 10:16:03 -0800585 (long) tx.calcnt, (long) tx.errcnt, (long) tx.stbcnt);
Dmitry V. Levin165b15d2006-12-13 17:43:45 +0000586#endif
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200587 tprints("}");
Dmitry V. Levin165b15d2006-12-13 17:43:45 +0000588 return 0;
589}
590
Dmitry V. Levin73215472012-03-11 21:25:51 +0000591static int
592do_adjtimex(struct tcb *tcp, long addr)
593{
594 if (addr == 0)
595 tprints("NULL");
596 else if (syserror(tcp) || !verbose(tcp))
597 tprintf("%#lx", addr);
598 else if (tprint_timex(tcp, addr) < 0)
599 tprints("{...}");
600 if (syserror(tcp))
601 return 0;
602 tcp->auxstr = xlookup(adjtimex_state, tcp->u_rval);
603 if (tcp->auxstr)
604 return RVAL_STR;
605 return 0;
606}
607
Dmitry V. Levin165b15d2006-12-13 17:43:45 +0000608int
609sys_adjtimex(struct tcb *tcp)
610{
Dmitry V. Levin73215472012-03-11 21:25:51 +0000611 if (exiting(tcp))
612 return do_adjtimex(tcp, tcp->u_arg[0]);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000613 return 0;
614}
Roland McGrath1e356792003-03-30 23:52:28 +0000615
Roland McGrathd9f816f2004-09-04 03:39:20 +0000616static const struct xlat clockflags[] = {
Denys Vlasenko3e3490a2012-03-17 01:27:37 +0100617 { TIMER_ABSTIME, "TIMER_ABSTIME" },
618 { 0, NULL }
Roland McGrath1e356792003-03-30 23:52:28 +0000619};
620
Roland McGrathd9f816f2004-09-04 03:39:20 +0000621static const struct xlat clocknames[] = {
Roland McGrath55a00f82004-08-31 08:26:39 +0000622#ifdef CLOCK_REALTIME
Denys Vlasenko3e3490a2012-03-17 01:27:37 +0100623 { CLOCK_REALTIME, "CLOCK_REALTIME" },
Roland McGrath55a00f82004-08-31 08:26:39 +0000624#endif
625#ifdef CLOCK_MONOTONIC
Denys Vlasenko3e3490a2012-03-17 01:27:37 +0100626 { CLOCK_MONOTONIC, "CLOCK_MONOTONIC" },
Roland McGrath55a00f82004-08-31 08:26:39 +0000627#endif
Dmitry V. Levincbaaf792010-09-17 09:19:49 +0000628#ifdef CLOCK_PROCESS_CPUTIME_ID
Denys Vlasenko3e3490a2012-03-17 01:27:37 +0100629 { CLOCK_PROCESS_CPUTIME_ID, "CLOCK_PROCESS_CPUTIME_ID" },
Dmitry V. Levincbaaf792010-09-17 09:19:49 +0000630#endif
631#ifdef CLOCK_THREAD_CPUTIME_ID
Denys Vlasenko3e3490a2012-03-17 01:27:37 +0100632 { CLOCK_THREAD_CPUTIME_ID, "CLOCK_THREAD_CPUTIME_ID" },
Dmitry V. Levincbaaf792010-09-17 09:19:49 +0000633#endif
634#ifdef CLOCK_MONOTONIC_RAW
Denys Vlasenko3e3490a2012-03-17 01:27:37 +0100635 { CLOCK_MONOTONIC_RAW, "CLOCK_MONOTONIC_RAW" },
Dmitry V. Levincbaaf792010-09-17 09:19:49 +0000636#endif
637#ifdef CLOCK_REALTIME_COARSE
Denys Vlasenko3e3490a2012-03-17 01:27:37 +0100638 { CLOCK_REALTIME_COARSE, "CLOCK_REALTIME_COARSE" },
Dmitry V. Levincbaaf792010-09-17 09:19:49 +0000639#endif
640#ifdef CLOCK_MONOTONIC_COARSE
Denys Vlasenko3e3490a2012-03-17 01:27:37 +0100641 { CLOCK_MONOTONIC_COARSE, "CLOCK_MONOTONIC_COARSE" },
Dmitry V. Levincbaaf792010-09-17 09:19:49 +0000642#endif
Denys Vlasenko3e3490a2012-03-17 01:27:37 +0100643 { 0, NULL }
Roland McGrath54a4edd2004-08-31 06:52:45 +0000644};
645
Roland McGrath1e356792003-03-30 23:52:28 +0000646int
Denys Vlasenko12014262011-05-30 14:00:14 +0200647sys_clock_settime(struct tcb *tcp)
Roland McGrath1e356792003-03-30 23:52:28 +0000648{
649 if (entering(tcp)) {
Roland McGrath54a4edd2004-08-31 06:52:45 +0000650 printxval(clocknames, tcp->u_arg[0], "CLOCK_???");
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200651 tprints(", ");
Roland McGrath1e356792003-03-30 23:52:28 +0000652 printtv(tcp, tcp->u_arg[1]);
653 }
654 return 0;
655}
656
657int
Denys Vlasenko12014262011-05-30 14:00:14 +0200658sys_clock_gettime(struct tcb *tcp)
Roland McGrath1e356792003-03-30 23:52:28 +0000659{
660 if (entering(tcp)) {
Roland McGrath54a4edd2004-08-31 06:52:45 +0000661 printxval(clocknames, tcp->u_arg[0], "CLOCK_???");
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200662 tprints(", ");
Roland McGrath1e356792003-03-30 23:52:28 +0000663 } else {
664 if (syserror(tcp))
665 tprintf("%#lx", tcp->u_arg[1]);
666 else
667 printtv(tcp, tcp->u_arg[1]);
668 }
669 return 0;
670}
671
672int
Denys Vlasenko12014262011-05-30 14:00:14 +0200673sys_clock_nanosleep(struct tcb *tcp)
Roland McGrath1e356792003-03-30 23:52:28 +0000674{
675 if (entering(tcp)) {
Roland McGrath54a4edd2004-08-31 06:52:45 +0000676 printxval(clocknames, tcp->u_arg[0], "CLOCK_???");
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200677 tprints(", ");
Roland McGrathb2dee132005-06-01 19:02:36 +0000678 printflags(clockflags, tcp->u_arg[1], "TIMER_???");
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200679 tprints(", ");
Roland McGrath1e356792003-03-30 23:52:28 +0000680 printtv(tcp, tcp->u_arg[2]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200681 tprints(", ");
Roland McGrath1e356792003-03-30 23:52:28 +0000682 } else {
683 if (syserror(tcp))
684 tprintf("%#lx", tcp->u_arg[3]);
685 else
686 printtv(tcp, tcp->u_arg[3]);
687 }
688 return 0;
689}
690
Dmitry V. Levin73215472012-03-11 21:25:51 +0000691int
692sys_clock_adjtime(struct tcb *tcp)
693{
694 if (exiting(tcp))
695 return do_adjtimex(tcp, tcp->u_arg[1]);
696 printxval(clocknames, tcp->u_arg[0], "CLOCK_???");
697 tprints(", ");
698 return 0;
699}
700
Roland McGrath1e356792003-03-30 23:52:28 +0000701#ifndef SIGEV_THREAD_ID
702# define SIGEV_THREAD_ID 4
703#endif
Roland McGrathd9f816f2004-09-04 03:39:20 +0000704static const struct xlat sigev_value[] = {
Roland McGrath1e356792003-03-30 23:52:28 +0000705 { SIGEV_SIGNAL+1, "SIGEV_SIGNAL" },
706 { SIGEV_NONE+1, "SIGEV_NONE" },
707 { SIGEV_THREAD+1, "SIGEV_THREAD" },
708 { SIGEV_THREAD_ID+1, "SIGEV_THREAD_ID" },
709 { 0, NULL }
710};
711
Dmitry V. Levind3cb3922006-12-13 17:45:02 +0000712#if SUPPORTED_PERSONALITIES > 1
713static void
714printsigevent32(struct tcb *tcp, long arg)
715{
Denys Vlasenko1d632462009-04-14 12:51:00 +0000716 struct {
Dmitry V. Levind3cb3922006-12-13 17:45:02 +0000717 int sigev_value;
718 int sigev_signo;
719 int sigev_notify;
720
Denys Vlasenko1d632462009-04-14 12:51:00 +0000721 union {
Dmitry V. Levind3cb3922006-12-13 17:45:02 +0000722 int tid;
Denys Vlasenko1d632462009-04-14 12:51:00 +0000723 struct {
Dmitry V. Levind3cb3922006-12-13 17:45:02 +0000724 int function, attribute;
725 } thread;
726 } un;
727 } sev;
728
729 if (umove(tcp, arg, &sev) < 0)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200730 tprints("{...}");
Denys Vlasenko1d632462009-04-14 12:51:00 +0000731 else {
Dmitry V. Levind3cb3922006-12-13 17:45:02 +0000732 tprintf("{%#x, ", sev.sigev_value);
733 if (sev.sigev_notify == SIGEV_SIGNAL)
734 tprintf("%s, ", signame(sev.sigev_signo));
735 else
736 tprintf("%u, ", sev.sigev_signo);
737 printxval(sigev_value, sev.sigev_notify + 1, "SIGEV_???");
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200738 tprints(", ");
Dmitry V. Levind3cb3922006-12-13 17:45:02 +0000739 if (sev.sigev_notify == SIGEV_THREAD_ID)
740 tprintf("{%d}", sev.un.tid);
741 else if (sev.sigev_notify == SIGEV_THREAD)
742 tprintf("{%#x, %#x}",
743 sev.un.thread.function,
744 sev.un.thread.attribute);
745 else
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200746 tprints("{...}");
747 tprints("}");
Dmitry V. Levind3cb3922006-12-13 17:45:02 +0000748 }
749}
750#endif
751
Roland McGrath1e356792003-03-30 23:52:28 +0000752void
Dmitry V. Levind3cb3922006-12-13 17:45:02 +0000753printsigevent(struct tcb *tcp, long arg)
Roland McGrath1e356792003-03-30 23:52:28 +0000754{
755 struct sigevent sev;
Dmitry V. Levind3cb3922006-12-13 17:45:02 +0000756
757#if SUPPORTED_PERSONALITIES > 1
Denys Vlasenko9fd4f962012-03-19 09:36:42 +0100758 if (current_wordsize == 4) {
Dmitry V. Levind3cb3922006-12-13 17:45:02 +0000759 printsigevent32(tcp, arg);
760 return;
761 }
762#endif
Denys Vlasenkob63256e2011-06-07 12:13:24 +0200763 if (umove(tcp, arg, &sev) < 0)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200764 tprints("{...}");
Roland McGrath1e356792003-03-30 23:52:28 +0000765 else {
Roland McGrath675d4a62004-09-11 08:12:45 +0000766 tprintf("{%p, ", sev.sigev_value.sival_ptr);
767 if (sev.sigev_notify == SIGEV_SIGNAL)
768 tprintf("%s, ", signame(sev.sigev_signo));
769 else
770 tprintf("%u, ", sev.sigev_signo);
Roland McGrath1e356792003-03-30 23:52:28 +0000771 printxval(sigev_value, sev.sigev_notify+1, "SIGEV_???");
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200772 tprints(", ");
Roland McGrath1e356792003-03-30 23:52:28 +0000773 if (sev.sigev_notify == SIGEV_THREAD_ID)
774 /* _pad[0] is the _tid field which might not be
775 present in the userlevel definition of the
776 struct. */
777 tprintf("{%d}", sev._sigev_un._pad[0]);
Roland McGrathd4c85eb2004-04-16 21:48:44 +0000778 else if (sev.sigev_notify == SIGEV_THREAD)
779 tprintf("{%p, %p}", sev.sigev_notify_function,
780 sev.sigev_notify_attributes);
Roland McGrath1e356792003-03-30 23:52:28 +0000781 else
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200782 tprints("{...}");
783 tprints("}");
Roland McGrath1e356792003-03-30 23:52:28 +0000784 }
785}
786
787int
Denys Vlasenko12014262011-05-30 14:00:14 +0200788sys_timer_create(struct tcb *tcp)
Roland McGrath1e356792003-03-30 23:52:28 +0000789{
790 if (entering(tcp)) {
Roland McGrath675d4a62004-09-11 08:12:45 +0000791 printxval(clocknames, tcp->u_arg[0], "CLOCK_???");
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200792 tprints(", ");
Roland McGrath1e356792003-03-30 23:52:28 +0000793 printsigevent(tcp, tcp->u_arg[1]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200794 tprints(", ");
Roland McGrath1e356792003-03-30 23:52:28 +0000795 } else {
Andi Kleen732f3962011-06-13 21:37:40 +0000796 int timer_id;
Dmitry V. Levinac518d12006-12-13 17:03:02 +0000797
Andi Kleen732f3962011-06-13 21:37:40 +0000798 if (syserror(tcp) || umove(tcp, tcp->u_arg[2], &timer_id) < 0)
Roland McGrath1e356792003-03-30 23:52:28 +0000799 tprintf("%#lx", tcp->u_arg[2]);
Dmitry V. Levinac518d12006-12-13 17:03:02 +0000800 else
Andi Kleen732f3962011-06-13 21:37:40 +0000801 tprintf("{%d}", timer_id);
Roland McGrath1e356792003-03-30 23:52:28 +0000802 }
803 return 0;
804}
805
806int
Denys Vlasenko12014262011-05-30 14:00:14 +0200807sys_timer_settime(struct tcb *tcp)
Roland McGrath1e356792003-03-30 23:52:28 +0000808{
809 if (entering(tcp)) {
810 tprintf("%#lx, ", tcp->u_arg[0]);
Roland McGrathb2dee132005-06-01 19:02:36 +0000811 printflags(clockflags, tcp->u_arg[1], "TIMER_???");
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200812 tprints(", ");
Roland McGrath1e356792003-03-30 23:52:28 +0000813 printitv(tcp, tcp->u_arg[2]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200814 tprints(", ");
Roland McGrath1e356792003-03-30 23:52:28 +0000815 } else {
816 if (syserror(tcp))
817 tprintf("%#lx", tcp->u_arg[3]);
818 else
819 printitv(tcp, tcp->u_arg[3]);
820 }
821 return 0;
822}
823
824int
Denys Vlasenko12014262011-05-30 14:00:14 +0200825sys_timer_gettime(struct tcb *tcp)
Roland McGrath1e356792003-03-30 23:52:28 +0000826{
827 if (entering(tcp)) {
828 tprintf("%#lx, ", tcp->u_arg[0]);
829 } else {
830 if (syserror(tcp))
831 tprintf("%#lx", tcp->u_arg[1]);
832 else
833 printitv(tcp, tcp->u_arg[1]);
834 }
835 return 0;
836}
Roland McGrathd83c50b2004-10-06 22:27:43 +0000837
838static void
Denys Vlasenko12014262011-05-30 14:00:14 +0200839print_rtc(struct tcb *tcp, const struct rtc_time *rt)
Roland McGrathd83c50b2004-10-06 22:27:43 +0000840{
841 tprintf("{tm_sec=%d, tm_min=%d, tm_hour=%d, "
842 "tm_mday=%d, tm_mon=%d, tm_year=%d, ",
843 rt->tm_sec, rt->tm_min, rt->tm_hour,
844 rt->tm_mday, rt->tm_mon, rt->tm_year);
845 if (!abbrev(tcp))
846 tprintf("tm_wday=%d, tm_yday=%d, tm_isdst=%d}",
847 rt->tm_wday, rt->tm_yday, rt->tm_isdst);
848 else
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200849 tprints("...}");
Roland McGrathd83c50b2004-10-06 22:27:43 +0000850}
851
852int
Denys Vlasenko12014262011-05-30 14:00:14 +0200853rtc_ioctl(struct tcb *tcp, long code, long arg)
Roland McGrathd83c50b2004-10-06 22:27:43 +0000854{
855 switch (code) {
856 case RTC_ALM_SET:
857 case RTC_SET_TIME:
858 if (entering(tcp)) {
859 struct rtc_time rt;
860 if (umove(tcp, arg, &rt) < 0)
861 tprintf(", %#lx", arg);
862 else {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200863 tprints(", ");
Roland McGrathd83c50b2004-10-06 22:27:43 +0000864 print_rtc(tcp, &rt);
865 }
866 }
867 break;
868 case RTC_ALM_READ:
869 case RTC_RD_TIME:
870 if (exiting(tcp)) {
871 struct rtc_time rt;
872 if (syserror(tcp) || umove(tcp, arg, &rt) < 0)
873 tprintf(", %#lx", arg);
874 else {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200875 tprints(", ");
Roland McGrathd83c50b2004-10-06 22:27:43 +0000876 print_rtc(tcp, &rt);
877 }
878 }
879 break;
880 case RTC_IRQP_SET:
881 case RTC_EPOCH_SET:
882 if (entering(tcp))
883 tprintf(", %lu", arg);
884 break;
885 case RTC_IRQP_READ:
886 case RTC_EPOCH_READ:
887 if (exiting(tcp))
888 tprintf(", %lu", arg);
889 break;
890 case RTC_WKALM_SET:
891 if (entering(tcp)) {
892 struct rtc_wkalrm wk;
893 if (umove(tcp, arg, &wk) < 0)
894 tprintf(", %#lx", arg);
895 else {
896 tprintf(", {enabled=%d, pending=%d, ",
897 wk.enabled, wk.pending);
898 print_rtc(tcp, &wk.time);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200899 tprints("}");
Roland McGrathd83c50b2004-10-06 22:27:43 +0000900 }
901 }
902 break;
903 case RTC_WKALM_RD:
904 if (exiting(tcp)) {
905 struct rtc_wkalrm wk;
906 if (syserror(tcp) || umove(tcp, arg, &wk) < 0)
907 tprintf(", %#lx", arg);
908 else {
909 tprintf(", {enabled=%d, pending=%d, ",
910 wk.enabled, wk.pending);
911 print_rtc(tcp, &wk.time);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200912 tprints("}");
Roland McGrathd83c50b2004-10-06 22:27:43 +0000913 }
914 }
915 break;
916 default:
917 if (entering(tcp))
918 tprintf(", %#lx", arg);
919 break;
920 }
921 return 1;
922}
Roland McGrathe4662342007-08-02 01:25:34 +0000923
924#ifndef TFD_TIMER_ABSTIME
925#define TFD_TIMER_ABSTIME (1 << 0)
926#endif
927
928static const struct xlat timerfdflags[] = {
929 { TFD_TIMER_ABSTIME, "TFD_TIMER_ABSTIME" },
930 { 0, NULL }
931};
932
933int
Denys Vlasenko12014262011-05-30 14:00:14 +0200934sys_timerfd(struct tcb *tcp)
Roland McGrathe4662342007-08-02 01:25:34 +0000935{
936 if (entering(tcp)) {
937 /* It does not matter that the kernel uses itimerspec. */
938 tprintf("%ld, ", tcp->u_arg[0]);
939 printxval(clocknames, tcp->u_arg[1], "CLOCK_???");
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200940 tprints(", ");
Roland McGrathe4662342007-08-02 01:25:34 +0000941 printflags(timerfdflags, tcp->u_arg[2], "TFD_???");
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200942 tprints(", ");
Roland McGrathe4662342007-08-02 01:25:34 +0000943 printitv(tcp, tcp->u_arg[3]);
944 }
945 return 0;
946}
Roland McGrathde328e62008-05-20 04:56:13 +0000947
948int
949sys_timerfd_create(struct tcb *tcp)
950{
951 if (entering(tcp)) {
952 printxval(clocknames, tcp->u_arg[0], "CLOCK_???");
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200953 tprints(", ");
Roland McGrathde328e62008-05-20 04:56:13 +0000954 printflags(timerfdflags, tcp->u_arg[1], "TFD_???");
955 }
956 return 0;
957}
958
959int
960sys_timerfd_settime(struct tcb *tcp)
961{
962 if (entering(tcp)) {
Dmitry V. Levin31382132011-03-04 05:08:02 +0300963 printfd(tcp, tcp->u_arg[0]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200964 tprints(", ");
Roland McGrathde328e62008-05-20 04:56:13 +0000965 printflags(timerfdflags, tcp->u_arg[1], "TFD_???");
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200966 tprints(", ");
Roland McGrathde328e62008-05-20 04:56:13 +0000967 printitv(tcp, tcp->u_arg[2]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200968 tprints(", ");
Roland McGrathde328e62008-05-20 04:56:13 +0000969 printitv(tcp, tcp->u_arg[3]);
970 }
971 return 0;
972}
973
974int
975sys_timerfd_gettime(struct tcb *tcp)
976{
977 if (entering(tcp)) {
Dmitry V. Levin31382132011-03-04 05:08:02 +0300978 printfd(tcp, tcp->u_arg[0]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200979 tprints(", ");
Roland McGrathde328e62008-05-20 04:56:13 +0000980 printitv(tcp, tcp->u_arg[1]);
981 }
982 return 0;
983}