blob: 932c71f7e72b918e262e1730300a79463617cb4e [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.
28 *
29 * $Id$
30 */
31
32#include "defs.h"
33
34#ifdef LINUX
35#include <linux/version.h>
Wichert Akkermand856b992000-10-13 12:47:12 +000036#include <sys/timex.h>
Roland McGrathd83c50b2004-10-06 22:27:43 +000037#include <linux/ioctl.h>
38#include <linux/rtc.h>
Roland McGrath6afc5652007-07-24 01:57:11 +000039
40#ifndef UTIME_NOW
41#define UTIME_NOW ((1l << 30) - 1l)
42#endif
43#ifndef UTIME_OMIT
44#define UTIME_OMIT ((1l << 30) - 2l)
45#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000046#endif /* LINUX */
47
Dmitry V. Levina7945a32006-12-13 17:10:11 +000048struct timeval32
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000049{
Dmitry V. Levina7945a32006-12-13 17:10:11 +000050 u_int32_t tv_sec, tv_usec;
51};
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000052
Dmitry V. Levin1cad25d2006-12-13 17:14:36 +000053static void
54tprint_timeval32(struct tcb *tcp, const struct timeval32 *tv)
55{
56 tprintf("{%u, %u}", tv->tv_sec, tv->tv_usec);
57}
58
59static void
60tprint_timeval(struct tcb *tcp, const struct timeval *tv)
61{
62 tprintf("{%lu, %lu}",
63 (unsigned long) tv->tv_sec, (unsigned long) tv->tv_usec);
64}
65
Dmitry V. Levina7945a32006-12-13 17:10:11 +000066void
Roland McGrath6afc5652007-07-24 01:57:11 +000067printtv_bitness(struct tcb *tcp, long addr, enum bitness_t bitness, int special)
Dmitry V. Levina7945a32006-12-13 17:10:11 +000068{
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000069 if (addr == 0)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +020070 tprints("NULL");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000071 else if (!verbose(tcp))
72 tprintf("%#lx", addr);
Denys Vlasenko1d632462009-04-14 12:51:00 +000073 else {
74 int rc;
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000075
Dmitry V. Levina7945a32006-12-13 17:10:11 +000076 if (bitness == BITNESS_32
77#if defined(LINUX) && SUPPORTED_PERSONALITIES > 1
78 || personality_wordsize[current_personality] == 4
79#endif
80 )
81 {
82 struct timeval32 tv;
83
Denys Vlasenko5d645812011-08-20 12:48:18 +020084 rc = umove(tcp, addr, &tv);
85 if (rc >= 0) {
Roland McGrath41383392007-07-24 01:58:52 +000086 if (special && tv.tv_sec == 0 &&
87 tv.tv_usec == UTIME_NOW)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +020088 tprints("UTIME_NOW");
Roland McGrath41383392007-07-24 01:58:52 +000089 else if (special && tv.tv_sec == 0 &&
90 tv.tv_usec == UTIME_OMIT)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +020091 tprints("UTIME_OMIT");
Roland McGrath6afc5652007-07-24 01:57:11 +000092 else
93 tprint_timeval32(tcp, &tv);
94 }
Denys Vlasenko1d632462009-04-14 12:51:00 +000095 } else {
Dmitry V. Levina7945a32006-12-13 17:10:11 +000096 struct timeval tv;
97
Denys Vlasenko5d645812011-08-20 12:48:18 +020098 rc = umove(tcp, addr, &tv);
99 if (rc >= 0) {
Roland McGrath41383392007-07-24 01:58:52 +0000100 if (special && tv.tv_sec == 0 &&
101 tv.tv_usec == UTIME_NOW)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200102 tprints("UTIME_NOW");
Roland McGrath41383392007-07-24 01:58:52 +0000103 else if (special && tv.tv_sec == 0 &&
104 tv.tv_usec == UTIME_OMIT)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200105 tprints("UTIME_OMIT");
Roland McGrath6afc5652007-07-24 01:57:11 +0000106 else
107 tprint_timeval(tcp, &tv);
108 }
Dmitry V. Levina7945a32006-12-13 17:10:11 +0000109 }
Dmitry V. Levina7945a32006-12-13 17:10:11 +0000110 if (rc < 0)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200111 tprints("{...}");
Dmitry V. Levina7945a32006-12-13 17:10:11 +0000112 }
113}
Wichert Akkerman221f54f1999-11-18 17:26:45 +0000114
Denys Vlasenko2fb4db32011-08-31 12:26:03 +0200115char *
Dmitry V. Levina7945a32006-12-13 17:10:11 +0000116sprinttv(struct tcb *tcp, long addr, enum bitness_t bitness, char *buf)
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +0000117{
Denys Vlasenko2fb4db32011-08-31 12:26:03 +0200118 int rc;
119
Dmitry V. Levina7945a32006-12-13 17:10:11 +0000120 if (addr == 0)
Denys Vlasenko2fb4db32011-08-31 12:26:03 +0200121 return stpcpy(buf, "NULL");
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +0000122
Denys Vlasenko2fb4db32011-08-31 12:26:03 +0200123 if (!verbose(tcp)) {
124 buf += sprintf(buf, "%#lx", addr);
125 return buf;
Dmitry V. Levina7945a32006-12-13 17:10:11 +0000126 }
Denys Vlasenko2fb4db32011-08-31 12:26:03 +0200127
128 if (bitness == BITNESS_32
129#if defined(LINUX) && SUPPORTED_PERSONALITIES > 1
130 || personality_wordsize[current_personality] == 4
131#endif
132 )
133 {
134 struct timeval32 tv;
135
136 rc = umove(tcp, addr, &tv);
137 if (rc >= 0)
138 buf += sprintf(buf, "{%u, %u}",
139 tv.tv_sec, tv.tv_usec);
140 } else {
141 struct timeval tv;
142
143 rc = umove(tcp, addr, &tv);
144 if (rc >= 0)
145 buf += sprintf(buf, "{%lu, %lu}",
146 (unsigned long) tv.tv_sec,
147 (unsigned long) tv.tv_usec);
148 }
149 if (rc < 0)
150 buf = stpcpy(buf, "{...}");
151
152 return buf;
Dmitry V. Levina7945a32006-12-13 17:10:11 +0000153}
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +0000154
Denys Vlasenko1d632462009-04-14 12:51:00 +0000155void print_timespec(struct tcb *tcp, long addr)
Roland McGrath6bc09da2007-11-01 21:50:54 +0000156{
157 if (addr == 0)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200158 tprints("NULL");
Roland McGrath6bc09da2007-11-01 21:50:54 +0000159 else if (!verbose(tcp))
160 tprintf("%#lx", addr);
161 else {
Denys Vlasenko1d632462009-04-14 12:51:00 +0000162 int rc;
Roland McGrath6bc09da2007-11-01 21:50:54 +0000163
164#if defined(LINUX) && SUPPORTED_PERSONALITIES > 1
Denys Vlasenko1d632462009-04-14 12:51:00 +0000165 if (personality_wordsize[current_personality] == 4) {
Roland McGrath6bc09da2007-11-01 21:50:54 +0000166 struct timeval32 tv;
167
Denys Vlasenko5d645812011-08-20 12:48:18 +0200168 rc = umove(tcp, addr, &tv);
169 if (rc >= 0)
Roland McGrath6bc09da2007-11-01 21:50:54 +0000170 tprintf("{%u, %u}",
171 tv.tv_sec, tv.tv_usec);
172 } else
Roland McGrath6bc09da2007-11-01 21:50:54 +0000173#endif
Denys Vlasenko1d632462009-04-14 12:51:00 +0000174 {
Roland McGrath6bc09da2007-11-01 21:50:54 +0000175 struct timespec ts;
176
Denys Vlasenko5d645812011-08-20 12:48:18 +0200177 rc = umove(tcp, addr, &ts);
178 if (rc >= 0)
Roland McGrath6bc09da2007-11-01 21:50:54 +0000179 tprintf("{%lu, %lu}",
180 (unsigned long) ts.tv_sec,
181 (unsigned long) ts.tv_nsec);
Roland McGrath6bc09da2007-11-01 21:50:54 +0000182 }
Roland McGrath6bc09da2007-11-01 21:50:54 +0000183 if (rc < 0)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200184 tprints("{...}");
Roland McGrath6bc09da2007-11-01 21:50:54 +0000185 }
186}
187
Denys Vlasenko1d632462009-04-14 12:51:00 +0000188void sprint_timespec(char *buf, struct tcb *tcp, long addr)
Roland McGrath6bc09da2007-11-01 21:50:54 +0000189{
190 if (addr == 0)
191 strcpy(buf, "NULL");
192 else if (!verbose(tcp))
193 sprintf(buf, "%#lx", addr);
194 else {
Denys Vlasenko1d632462009-04-14 12:51:00 +0000195 int rc;
Roland McGrath6bc09da2007-11-01 21:50:54 +0000196
197#if defined(LINUX) && SUPPORTED_PERSONALITIES > 1
Denys Vlasenko1d632462009-04-14 12:51:00 +0000198 if (personality_wordsize[current_personality] == 4) {
Roland McGrath6bc09da2007-11-01 21:50:54 +0000199 struct timeval32 tv;
200
Denys Vlasenko5d645812011-08-20 12:48:18 +0200201 rc = umove(tcp, addr, &tv);
202 if (rc >= 0)
Roland McGrath6bc09da2007-11-01 21:50:54 +0000203 sprintf(buf, "{%u, %u}",
204 tv.tv_sec, tv.tv_usec);
205 } else
Roland McGrath6bc09da2007-11-01 21:50:54 +0000206#endif
Denys Vlasenko1d632462009-04-14 12:51:00 +0000207 {
Roland McGrath6bc09da2007-11-01 21:50:54 +0000208 struct timespec ts;
209
Denys Vlasenko5d645812011-08-20 12:48:18 +0200210 rc = umove(tcp, addr, &ts);
211 if (rc >= 0)
Roland McGrath6bc09da2007-11-01 21:50:54 +0000212 sprintf(buf, "{%lu, %lu}",
213 (unsigned long) ts.tv_sec,
214 (unsigned long) ts.tv_nsec);
Roland McGrath6bc09da2007-11-01 21:50:54 +0000215 }
Roland McGrath6bc09da2007-11-01 21:50:54 +0000216 if (rc < 0)
217 strcpy(buf, "{...}");
218 }
219}
220
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000221int
Denys Vlasenko12014262011-05-30 14:00:14 +0200222sys_time(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000223{
224 if (exiting(tcp)) {
225#ifndef SVR4
226 printnum(tcp, tcp->u_arg[0], "%ld");
227#endif /* SVR4 */
228 }
229 return 0;
230}
231
232int
Denys Vlasenko12014262011-05-30 14:00:14 +0200233sys_stime(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000234{
235 if (exiting(tcp)) {
236 printnum(tcp, tcp->u_arg[0], "%ld");
237 }
238 return 0;
239}
240
241int
Denys Vlasenko12014262011-05-30 14:00:14 +0200242sys_gettimeofday(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000243{
244 if (exiting(tcp)) {
245 if (syserror(tcp)) {
246 tprintf("%#lx, %#lx",
247 tcp->u_arg[0], tcp->u_arg[1]);
248 return 0;
249 }
250 printtv(tcp, tcp->u_arg[0]);
251#ifndef SVR4
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200252 tprints(", ");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000253 printtv(tcp, tcp->u_arg[1]);
254#endif /* !SVR4 */
255 }
256 return 0;
257}
258
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +0000259
260#ifdef ALPHA
261int
Denys Vlasenko12014262011-05-30 14:00:14 +0200262sys_osf_gettimeofday(struct tcb *tcp)
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +0000263{
Denys Vlasenko1d632462009-04-14 12:51:00 +0000264 if (exiting(tcp)) {
265 if (syserror(tcp)) {
266 tprintf("%#lx, %#lx", tcp->u_arg[0], tcp->u_arg[1]);
267 return 0;
268 }
269 printtv_bitness(tcp, tcp->u_arg[0], BITNESS_32, 0);
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +0000270#ifndef SVR4
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200271 tprints(", ");
Denys Vlasenko1d632462009-04-14 12:51:00 +0000272 printtv_bitness(tcp, tcp->u_arg[1], BITNESS_32, 0);
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +0000273#endif /* !SVR4 */
Denys Vlasenko1d632462009-04-14 12:51:00 +0000274 }
275 return 0;
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +0000276}
277#endif
278
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000279int
Denys Vlasenko12014262011-05-30 14:00:14 +0200280sys_settimeofday(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000281{
282 if (entering(tcp)) {
283 printtv(tcp, tcp->u_arg[0]);
284#ifndef SVR4
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200285 tprints(", ");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000286 printtv(tcp, tcp->u_arg[1]);
287#endif /* !SVR4 */
288 }
289 return 0;
290}
291
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +0000292#ifdef ALPHA
293int
Denys Vlasenko12014262011-05-30 14:00:14 +0200294sys_osf_settimeofday(struct tcb *tcp)
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +0000295{
Denys Vlasenko1d632462009-04-14 12:51:00 +0000296 if (entering(tcp)) {
297 printtv_bitness(tcp, tcp->u_arg[0], BITNESS_32, 0);
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +0000298#ifndef SVR4
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200299 tprints(", ");
Denys Vlasenko1d632462009-04-14 12:51:00 +0000300 printtv_bitness(tcp, tcp->u_arg[1], BITNESS_32, 0);
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +0000301#endif /* !SVR4 */
Denys Vlasenko1d632462009-04-14 12:51:00 +0000302 }
303 return 0;
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +0000304}
305#endif
306
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000307int
Denys Vlasenko12014262011-05-30 14:00:14 +0200308sys_adjtime(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000309{
310 if (entering(tcp)) {
311 printtv(tcp, tcp->u_arg[0]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200312 tprints(", ");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000313 } else {
314 if (syserror(tcp))
315 tprintf("%#lx", tcp->u_arg[1]);
316 else
317 printtv(tcp, tcp->u_arg[1]);
318 }
319 return 0;
320}
321
Dmitry V. Levin2e55ff42008-09-03 01:02:46 +0000322int
323sys_nanosleep(struct tcb *tcp)
324{
325 if (entering(tcp)) {
326 print_timespec(tcp, tcp->u_arg[0]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200327 tprints(", ");
Dmitry V. Levin2e55ff42008-09-03 01:02:46 +0000328 } else {
329 if (!tcp->u_arg[1] || is_restart_error(tcp))
330 print_timespec(tcp, tcp->u_arg[1]);
331 else
332 tprintf("%#lx", tcp->u_arg[1]);
333 }
334 return 0;
335}
336
Roland McGrathd9f816f2004-09-04 03:39:20 +0000337static const struct xlat which[] = {
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000338 { ITIMER_REAL, "ITIMER_REAL" },
339 { ITIMER_VIRTUAL,"ITIMER_VIRTUAL"},
340 { ITIMER_PROF, "ITIMER_PROF" },
341 { 0, NULL },
342};
343
344static void
Dmitry V. Levin1cad25d2006-12-13 17:14:36 +0000345printitv_bitness(struct tcb *tcp, long addr, enum bitness_t bitness)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000346{
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000347 if (addr == 0)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200348 tprints("NULL");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000349 else if (!verbose(tcp))
350 tprintf("%#lx", addr);
Denys Vlasenko1d632462009-04-14 12:51:00 +0000351 else {
352 int rc;
Dmitry V. Levin1cad25d2006-12-13 17:14:36 +0000353
354 if (bitness == BITNESS_32
355#if defined(LINUX) && SUPPORTED_PERSONALITIES > 1
356 || personality_wordsize[current_personality] == 4
357#endif
358 )
359 {
Denys Vlasenko1d632462009-04-14 12:51:00 +0000360 struct {
Dmitry V. Levin1cad25d2006-12-13 17:14:36 +0000361 struct timeval32 it_interval, it_value;
362 } itv;
363
Denys Vlasenko5d645812011-08-20 12:48:18 +0200364 rc = umove(tcp, addr, &itv);
365 if (rc >= 0) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200366 tprints("{it_interval=");
Dmitry V. Levin1cad25d2006-12-13 17:14:36 +0000367 tprint_timeval32(tcp, &itv.it_interval);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200368 tprints(", it_value=");
Dmitry V. Levin1cad25d2006-12-13 17:14:36 +0000369 tprint_timeval32(tcp, &itv.it_value);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200370 tprints("}");
Roland McGrathe4662342007-08-02 01:25:34 +0000371 }
Denys Vlasenko1d632462009-04-14 12:51:00 +0000372 } else {
Dmitry V. Levin1cad25d2006-12-13 17:14:36 +0000373 struct itimerval itv;
374
Denys Vlasenko5d645812011-08-20 12:48:18 +0200375 rc = umove(tcp, addr, &itv);
376 if (rc >= 0) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200377 tprints("{it_interval=");
Dmitry V. Levin1cad25d2006-12-13 17:14:36 +0000378 tprint_timeval(tcp, &itv.it_interval);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200379 tprints(", it_value=");
Dmitry V. Levin1cad25d2006-12-13 17:14:36 +0000380 tprint_timeval(tcp, &itv.it_value);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200381 tprints("}");
Roland McGrathe4662342007-08-02 01:25:34 +0000382 }
Dmitry V. Levin1cad25d2006-12-13 17:14:36 +0000383 }
Dmitry V. Levin1cad25d2006-12-13 17:14:36 +0000384 if (rc < 0)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200385 tprints("{...}");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000386 }
387}
388
Dmitry V. Levin1cad25d2006-12-13 17:14:36 +0000389#define printitv(tcp, addr) \
390 printitv_bitness((tcp), (addr), BITNESS_CURRENT)
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +0000391
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000392int
Denys Vlasenko12014262011-05-30 14:00:14 +0200393sys_getitimer(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000394{
395 if (entering(tcp)) {
396 printxval(which, tcp->u_arg[0], "ITIMER_???");
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200397 tprints(", ");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000398 } else {
399 if (syserror(tcp))
400 tprintf("%#lx", tcp->u_arg[1]);
401 else
402 printitv(tcp, tcp->u_arg[1]);
403 }
404 return 0;
405}
406
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +0000407
408#ifdef ALPHA
409int
Denys Vlasenko12014262011-05-30 14:00:14 +0200410sys_osf_getitimer(struct tcb *tcp)
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +0000411{
Denys Vlasenko1d632462009-04-14 12:51:00 +0000412 if (entering(tcp)) {
413 printxval(which, tcp->u_arg[0], "ITIMER_???");
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200414 tprints(", ");
Denys Vlasenko1d632462009-04-14 12:51:00 +0000415 } else {
416 if (syserror(tcp))
417 tprintf("%#lx", tcp->u_arg[1]);
418 else
419 printitv_bitness(tcp, tcp->u_arg[1], BITNESS_32);
420 }
421 return 0;
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +0000422}
423#endif
424
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000425int
Denys Vlasenko12014262011-05-30 14:00:14 +0200426sys_setitimer(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000427{
428 if (entering(tcp)) {
429 printxval(which, tcp->u_arg[0], "ITIMER_???");
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200430 tprints(", ");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000431 printitv(tcp, tcp->u_arg[1]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200432 tprints(", ");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000433 } else {
434 if (syserror(tcp))
435 tprintf("%#lx", tcp->u_arg[2]);
436 else
437 printitv(tcp, tcp->u_arg[2]);
438 }
439 return 0;
440}
441
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +0000442#ifdef ALPHA
443int
Denys Vlasenko12014262011-05-30 14:00:14 +0200444sys_osf_setitimer(struct tcb *tcp)
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +0000445{
Denys Vlasenko1d632462009-04-14 12:51:00 +0000446 if (entering(tcp)) {
447 printxval(which, tcp->u_arg[0], "ITIMER_???");
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200448 tprints(", ");
Denys Vlasenko1d632462009-04-14 12:51:00 +0000449 printitv_bitness(tcp, tcp->u_arg[1], BITNESS_32);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200450 tprints(", ");
Denys Vlasenko1d632462009-04-14 12:51:00 +0000451 } else {
452 if (syserror(tcp))
453 tprintf("%#lx", tcp->u_arg[2]);
454 else
455 printitv_bitness(tcp, tcp->u_arg[2], BITNESS_32);
456 }
457 return 0;
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +0000458}
459#endif
460
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000461#ifdef LINUX
462
Dmitry V. Levin1a684d62006-12-13 17:42:32 +0000463static const struct xlat adjtimex_modes[] = {
464 { 0, "0" },
465#ifdef ADJ_OFFSET
466 { ADJ_OFFSET, "ADJ_OFFSET" },
467#endif
468#ifdef ADJ_FREQUENCY
469 { ADJ_FREQUENCY, "ADJ_FREQUENCY" },
470#endif
471#ifdef ADJ_MAXERROR
472 { ADJ_MAXERROR, "ADJ_MAXERROR" },
473#endif
474#ifdef ADJ_ESTERROR
475 { ADJ_ESTERROR, "ADJ_ESTERROR" },
476#endif
477#ifdef ADJ_STATUS
478 { ADJ_STATUS, "ADJ_STATUS" },
479#endif
480#ifdef ADJ_TIMECONST
481 { ADJ_TIMECONST, "ADJ_TIMECONST" },
482#endif
483#ifdef ADJ_TICK
484 { ADJ_TICK, "ADJ_TICK" },
485#endif
486#ifdef ADJ_OFFSET_SINGLESHOT
487 { ADJ_OFFSET_SINGLESHOT, "ADJ_OFFSET_SINGLESHOT" },
488#endif
489 { 0, NULL }
490};
491
492static const struct xlat adjtimex_status[] = {
493#ifdef STA_PLL
494 { STA_PLL, "STA_PLL" },
495#endif
496#ifdef STA_PPSFREQ
497 { STA_PPSFREQ, "STA_PPSFREQ" },
498#endif
499#ifdef STA_PPSTIME
500 { STA_PPSTIME, "STA_PPSTIME" },
501#endif
502#ifdef STA_FLL
503 { STA_FLL, "STA_FLL" },
504#endif
505#ifdef STA_INS
506 { STA_INS, "STA_INS" },
507#endif
508#ifdef STA_DEL
509 { STA_DEL, "STA_DEL" },
510#endif
511#ifdef STA_UNSYNC
512 { STA_UNSYNC, "STA_UNSYNC" },
513#endif
514#ifdef STA_FREQHOLD
515 { STA_FREQHOLD, "STA_FREQHOLD" },
516#endif
517#ifdef STA_PPSSIGNAL
518 { STA_PPSSIGNAL, "STA_PPSSIGNAL" },
519#endif
520#ifdef STA_PPSJITTER
521 { STA_PPSJITTER, "STA_PPSJITTER" },
522#endif
523#ifdef STA_PPSWANDER
524 { STA_PPSWANDER, "STA_PPSWANDER" },
525#endif
526#ifdef STA_PPSERROR
527 { STA_PPSERROR, "STA_PPSERROR" },
528#endif
529#ifdef STA_CLOCKERR
530 { STA_CLOCKERR, "STA_CLOCKERR" },
531#endif
532 { 0, NULL }
533};
534
535static const struct xlat adjtimex_state[] = {
536#ifdef TIME_OK
537 { TIME_OK, "TIME_OK" },
538#endif
539#ifdef TIME_INS
540 { TIME_INS, "TIME_INS" },
541#endif
542#ifdef TIME_DEL
543 { TIME_DEL, "TIME_DEL" },
544#endif
545#ifdef TIME_OOP
546 { TIME_OOP, "TIME_OOP" },
547#endif
548#ifdef TIME_WAIT
549 { TIME_WAIT, "TIME_WAIT" },
550#endif
551#ifdef TIME_ERROR
552 { TIME_ERROR, "TIME_ERROR" },
553#endif
554 { 0, NULL }
555};
556
Dmitry V. Levin165b15d2006-12-13 17:43:45 +0000557#if SUPPORTED_PERSONALITIES > 1
558static int
559tprint_timex32(struct tcb *tcp, long addr)
560{
Denys Vlasenko1d632462009-04-14 12:51:00 +0000561 struct {
Dmitry V. Levin165b15d2006-12-13 17:43:45 +0000562 unsigned int modes;
563 int offset;
564 int freq;
565 int maxerror;
566 int esterror;
567 int status;
568 int constant;
569 int precision;
570 int tolerance;
571 struct timeval32 time;
572 int tick;
573 int ppsfreq;
574 int jitter;
575 int shift;
576 int stabil;
577 int jitcnt;
578 int calcnt;
579 int errcnt;
580 int stbcnt;
581 } tx;
582
583 if (umove(tcp, addr, &tx) < 0)
584 return -1;
585
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200586 tprints("{modes=");
Dmitry V. Levin71d70892007-01-13 11:17:38 +0000587 printflags(adjtimex_modes, tx.modes, "ADJ_???");
Dmitry V. Levin165b15d2006-12-13 17:43:45 +0000588 tprintf(", offset=%d, freq=%d, maxerror=%d, ",
589 tx.offset, tx.freq, tx.maxerror);
590 tprintf("esterror=%u, status=", tx.esterror);
591 printflags(adjtimex_status, tx.status, "STA_???");
592 tprintf(", constant=%d, precision=%u, ",
593 tx.constant, tx.precision);
594 tprintf("tolerance=%d, time=", tx.tolerance);
595 tprint_timeval32(tcp, &tx.time);
596 tprintf(", tick=%d, ppsfreq=%d, jitter=%d",
597 tx.tick, tx.ppsfreq, tx.jitter);
598 tprintf(", shift=%d, stabil=%d, jitcnt=%d",
599 tx.shift, tx.stabil, tx.jitcnt);
600 tprintf(", calcnt=%d, errcnt=%d, stbcnt=%d",
601 tx.calcnt, tx.errcnt, tx.stbcnt);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200602 tprints("}");
Dmitry V. Levin165b15d2006-12-13 17:43:45 +0000603 return 0;
604}
605#endif /* SUPPORTED_PERSONALITIES > 1 */
606
607static int
608tprint_timex(struct tcb *tcp, long addr)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000609{
Dmitry V. Levin1a684d62006-12-13 17:42:32 +0000610 struct timex tx;
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000611
Dmitry V. Levin165b15d2006-12-13 17:43:45 +0000612#if SUPPORTED_PERSONALITIES > 1
613 if (personality_wordsize[current_personality] == 4)
614 return tprint_timex32(tcp, addr);
615#endif
616 if (umove(tcp, addr, &tx) < 0)
617 return -1;
618
619#if LINUX_VERSION_CODE < 66332
620 tprintf("{mode=%d, offset=%ld, frequency=%ld, ",
621 tx.mode, tx.offset, tx.frequency);
622 tprintf("maxerror=%ld, esterror=%lu, status=%u, ",
623 tx.maxerror, tx.esterror, tx.status);
624 tprintf("time_constant=%ld, precision=%lu, ",
625 tx.time_constant, tx.precision);
626 tprintf("tolerance=%ld, time=", tx.tolerance);
627 tprint_timeval(tcp, &tx.time);
628#else
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200629 tprints("{modes=");
Dmitry V. Levin71d70892007-01-13 11:17:38 +0000630 printflags(adjtimex_modes, tx.modes, "ADJ_???");
Dmitry V. Levin165b15d2006-12-13 17:43:45 +0000631 tprintf(", offset=%ld, freq=%ld, maxerror=%ld, ",
632 tx.offset, tx.freq, tx.maxerror);
633 tprintf("esterror=%lu, status=", tx.esterror);
634 printflags(adjtimex_status, tx.status, "STA_???");
635 tprintf(", constant=%ld, precision=%lu, ",
636 tx.constant, tx.precision);
637 tprintf("tolerance=%ld, time=", tx.tolerance);
638 tprint_timeval(tcp, &tx.time);
639 tprintf(", tick=%ld, ppsfreq=%ld, jitter=%ld",
640 tx.tick, tx.ppsfreq, tx.jitter);
641 tprintf(", shift=%d, stabil=%ld, jitcnt=%ld",
642 tx.shift, tx.stabil, tx.jitcnt);
643 tprintf(", calcnt=%ld, errcnt=%ld, stbcnt=%ld",
644 tx.calcnt, tx.errcnt, tx.stbcnt);
645#endif
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200646 tprints("}");
Dmitry V. Levin165b15d2006-12-13 17:43:45 +0000647 return 0;
648}
649
650int
651sys_adjtimex(struct tcb *tcp)
652{
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000653 if (exiting(tcp)) {
654 if (tcp->u_arg[0] == 0)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200655 tprints("NULL");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000656 else if (syserror(tcp) || !verbose(tcp))
657 tprintf("%#lx", tcp->u_arg[0]);
Dmitry V. Levin165b15d2006-12-13 17:43:45 +0000658 else if (tprint_timex(tcp, tcp->u_arg[0]) < 0)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200659 tprints("{...}");
Dmitry V. Levin21a75342008-09-03 01:22:18 +0000660 if (syserror(tcp))
661 return 0;
Dmitry V. Levin1a684d62006-12-13 17:42:32 +0000662 tcp->auxstr = xlookup(adjtimex_state, tcp->u_rval);
663 if (tcp->auxstr)
664 return RVAL_STR;
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000665 }
666 return 0;
667}
Roland McGrath1e356792003-03-30 23:52:28 +0000668
Roland McGrathd9f816f2004-09-04 03:39:20 +0000669static const struct xlat clockflags[] = {
Roland McGrath1e356792003-03-30 23:52:28 +0000670 { TIMER_ABSTIME, "TIMER_ABSTIME" },
671 { 0, NULL }
672};
673
Roland McGrathd9f816f2004-09-04 03:39:20 +0000674static const struct xlat clocknames[] = {
Roland McGrath55a00f82004-08-31 08:26:39 +0000675#ifdef CLOCK_REALTIME
Roland McGrath54a4edd2004-08-31 06:52:45 +0000676 { CLOCK_REALTIME, "CLOCK_REALTIME" },
Roland McGrath55a00f82004-08-31 08:26:39 +0000677#endif
678#ifdef CLOCK_MONOTONIC
Roland McGrath54a4edd2004-08-31 06:52:45 +0000679 { CLOCK_MONOTONIC, "CLOCK_MONOTONIC" },
Roland McGrath55a00f82004-08-31 08:26:39 +0000680#endif
Dmitry V. Levincbaaf792010-09-17 09:19:49 +0000681#ifdef CLOCK_PROCESS_CPUTIME_ID
682 { CLOCK_PROCESS_CPUTIME_ID, "CLOCK_PROCESS_CPUTIME_ID" },
683#endif
684#ifdef CLOCK_THREAD_CPUTIME_ID
685 { CLOCK_THREAD_CPUTIME_ID, "CLOCK_THREAD_CPUTIME_ID" },
686#endif
687#ifdef CLOCK_MONOTONIC_RAW
688 { CLOCK_MONOTONIC_RAW, "CLOCK_MONOTONIC_RAW" },
689#endif
690#ifdef CLOCK_REALTIME_COARSE
691 { CLOCK_REALTIME_COARSE, "CLOCK_REALTIME_COARSE" },
692#endif
693#ifdef CLOCK_MONOTONIC_COARSE
694 { CLOCK_MONOTONIC_COARSE, "CLOCK_MONOTONIC_COARSE" },
695#endif
696 { 0, NULL }
Roland McGrath54a4edd2004-08-31 06:52:45 +0000697};
698
Roland McGrath1e356792003-03-30 23:52:28 +0000699int
Denys Vlasenko12014262011-05-30 14:00:14 +0200700sys_clock_settime(struct tcb *tcp)
Roland McGrath1e356792003-03-30 23:52:28 +0000701{
702 if (entering(tcp)) {
Roland McGrath54a4edd2004-08-31 06:52:45 +0000703 printxval(clocknames, tcp->u_arg[0], "CLOCK_???");
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200704 tprints(", ");
Roland McGrath1e356792003-03-30 23:52:28 +0000705 printtv(tcp, tcp->u_arg[1]);
706 }
707 return 0;
708}
709
710int
Denys Vlasenko12014262011-05-30 14:00:14 +0200711sys_clock_gettime(struct tcb *tcp)
Roland McGrath1e356792003-03-30 23:52:28 +0000712{
713 if (entering(tcp)) {
Roland McGrath54a4edd2004-08-31 06:52:45 +0000714 printxval(clocknames, tcp->u_arg[0], "CLOCK_???");
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200715 tprints(", ");
Roland McGrath1e356792003-03-30 23:52:28 +0000716 } else {
717 if (syserror(tcp))
718 tprintf("%#lx", tcp->u_arg[1]);
719 else
720 printtv(tcp, tcp->u_arg[1]);
721 }
722 return 0;
723}
724
725int
Denys Vlasenko12014262011-05-30 14:00:14 +0200726sys_clock_nanosleep(struct tcb *tcp)
Roland McGrath1e356792003-03-30 23:52:28 +0000727{
728 if (entering(tcp)) {
Roland McGrath54a4edd2004-08-31 06:52:45 +0000729 printxval(clocknames, tcp->u_arg[0], "CLOCK_???");
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200730 tprints(", ");
Roland McGrathb2dee132005-06-01 19:02:36 +0000731 printflags(clockflags, tcp->u_arg[1], "TIMER_???");
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200732 tprints(", ");
Roland McGrath1e356792003-03-30 23:52:28 +0000733 printtv(tcp, tcp->u_arg[2]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200734 tprints(", ");
Roland McGrath1e356792003-03-30 23:52:28 +0000735 } else {
736 if (syserror(tcp))
737 tprintf("%#lx", tcp->u_arg[3]);
738 else
739 printtv(tcp, tcp->u_arg[3]);
740 }
741 return 0;
742}
743
744#ifndef SIGEV_THREAD_ID
745# define SIGEV_THREAD_ID 4
746#endif
Roland McGrathd9f816f2004-09-04 03:39:20 +0000747static const struct xlat sigev_value[] = {
Roland McGrath1e356792003-03-30 23:52:28 +0000748 { SIGEV_SIGNAL+1, "SIGEV_SIGNAL" },
749 { SIGEV_NONE+1, "SIGEV_NONE" },
750 { SIGEV_THREAD+1, "SIGEV_THREAD" },
751 { SIGEV_THREAD_ID+1, "SIGEV_THREAD_ID" },
752 { 0, NULL }
753};
754
Dmitry V. Levind3cb3922006-12-13 17:45:02 +0000755#if SUPPORTED_PERSONALITIES > 1
756static void
757printsigevent32(struct tcb *tcp, long arg)
758{
Denys Vlasenko1d632462009-04-14 12:51:00 +0000759 struct {
Dmitry V. Levind3cb3922006-12-13 17:45:02 +0000760 int sigev_value;
761 int sigev_signo;
762 int sigev_notify;
763
Denys Vlasenko1d632462009-04-14 12:51:00 +0000764 union {
Dmitry V. Levind3cb3922006-12-13 17:45:02 +0000765 int tid;
Denys Vlasenko1d632462009-04-14 12:51:00 +0000766 struct {
Dmitry V. Levind3cb3922006-12-13 17:45:02 +0000767 int function, attribute;
768 } thread;
769 } un;
770 } sev;
771
772 if (umove(tcp, arg, &sev) < 0)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200773 tprints("{...}");
Denys Vlasenko1d632462009-04-14 12:51:00 +0000774 else {
Dmitry V. Levind3cb3922006-12-13 17:45:02 +0000775 tprintf("{%#x, ", sev.sigev_value);
776 if (sev.sigev_notify == SIGEV_SIGNAL)
777 tprintf("%s, ", signame(sev.sigev_signo));
778 else
779 tprintf("%u, ", sev.sigev_signo);
780 printxval(sigev_value, sev.sigev_notify + 1, "SIGEV_???");
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200781 tprints(", ");
Dmitry V. Levind3cb3922006-12-13 17:45:02 +0000782 if (sev.sigev_notify == SIGEV_THREAD_ID)
783 tprintf("{%d}", sev.un.tid);
784 else if (sev.sigev_notify == SIGEV_THREAD)
785 tprintf("{%#x, %#x}",
786 sev.un.thread.function,
787 sev.un.thread.attribute);
788 else
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200789 tprints("{...}");
790 tprints("}");
Dmitry V. Levind3cb3922006-12-13 17:45:02 +0000791 }
792}
793#endif
794
Roland McGrath1e356792003-03-30 23:52:28 +0000795void
Dmitry V. Levind3cb3922006-12-13 17:45:02 +0000796printsigevent(struct tcb *tcp, long arg)
Roland McGrath1e356792003-03-30 23:52:28 +0000797{
798 struct sigevent sev;
Dmitry V. Levind3cb3922006-12-13 17:45:02 +0000799
800#if SUPPORTED_PERSONALITIES > 1
Denys Vlasenko7b609d52011-06-22 14:32:43 +0200801 if (personality_wordsize[current_personality] == 4) {
Dmitry V. Levind3cb3922006-12-13 17:45:02 +0000802 printsigevent32(tcp, arg);
803 return;
804 }
805#endif
Denys Vlasenkob63256e2011-06-07 12:13:24 +0200806 if (umove(tcp, arg, &sev) < 0)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200807 tprints("{...}");
Roland McGrath1e356792003-03-30 23:52:28 +0000808 else {
Roland McGrath675d4a62004-09-11 08:12:45 +0000809 tprintf("{%p, ", sev.sigev_value.sival_ptr);
810 if (sev.sigev_notify == SIGEV_SIGNAL)
811 tprintf("%s, ", signame(sev.sigev_signo));
812 else
813 tprintf("%u, ", sev.sigev_signo);
Roland McGrath1e356792003-03-30 23:52:28 +0000814 printxval(sigev_value, sev.sigev_notify+1, "SIGEV_???");
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200815 tprints(", ");
Roland McGrath1e356792003-03-30 23:52:28 +0000816 if (sev.sigev_notify == SIGEV_THREAD_ID)
817 /* _pad[0] is the _tid field which might not be
818 present in the userlevel definition of the
819 struct. */
820 tprintf("{%d}", sev._sigev_un._pad[0]);
Roland McGrathd4c85eb2004-04-16 21:48:44 +0000821 else if (sev.sigev_notify == SIGEV_THREAD)
822 tprintf("{%p, %p}", sev.sigev_notify_function,
823 sev.sigev_notify_attributes);
Roland McGrath1e356792003-03-30 23:52:28 +0000824 else
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200825 tprints("{...}");
826 tprints("}");
Roland McGrath1e356792003-03-30 23:52:28 +0000827 }
828}
829
830int
Denys Vlasenko12014262011-05-30 14:00:14 +0200831sys_timer_create(struct tcb *tcp)
Roland McGrath1e356792003-03-30 23:52:28 +0000832{
833 if (entering(tcp)) {
Roland McGrath675d4a62004-09-11 08:12:45 +0000834 printxval(clocknames, tcp->u_arg[0], "CLOCK_???");
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200835 tprints(", ");
Roland McGrath1e356792003-03-30 23:52:28 +0000836 printsigevent(tcp, tcp->u_arg[1]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200837 tprints(", ");
Roland McGrath1e356792003-03-30 23:52:28 +0000838 } else {
Andi Kleen732f3962011-06-13 21:37:40 +0000839 int timer_id;
Dmitry V. Levinac518d12006-12-13 17:03:02 +0000840
Andi Kleen732f3962011-06-13 21:37:40 +0000841 if (syserror(tcp) || umove(tcp, tcp->u_arg[2], &timer_id) < 0)
Roland McGrath1e356792003-03-30 23:52:28 +0000842 tprintf("%#lx", tcp->u_arg[2]);
Dmitry V. Levinac518d12006-12-13 17:03:02 +0000843 else
Andi Kleen732f3962011-06-13 21:37:40 +0000844 tprintf("{%d}", timer_id);
Roland McGrath1e356792003-03-30 23:52:28 +0000845 }
846 return 0;
847}
848
849int
Denys Vlasenko12014262011-05-30 14:00:14 +0200850sys_timer_settime(struct tcb *tcp)
Roland McGrath1e356792003-03-30 23:52:28 +0000851{
852 if (entering(tcp)) {
853 tprintf("%#lx, ", tcp->u_arg[0]);
Roland McGrathb2dee132005-06-01 19:02:36 +0000854 printflags(clockflags, tcp->u_arg[1], "TIMER_???");
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200855 tprints(", ");
Roland McGrath1e356792003-03-30 23:52:28 +0000856 printitv(tcp, tcp->u_arg[2]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200857 tprints(", ");
Roland McGrath1e356792003-03-30 23:52:28 +0000858 } else {
859 if (syserror(tcp))
860 tprintf("%#lx", tcp->u_arg[3]);
861 else
862 printitv(tcp, tcp->u_arg[3]);
863 }
864 return 0;
865}
866
867int
Denys Vlasenko12014262011-05-30 14:00:14 +0200868sys_timer_gettime(struct tcb *tcp)
Roland McGrath1e356792003-03-30 23:52:28 +0000869{
870 if (entering(tcp)) {
871 tprintf("%#lx, ", tcp->u_arg[0]);
872 } else {
873 if (syserror(tcp))
874 tprintf("%#lx", tcp->u_arg[1]);
875 else
876 printitv(tcp, tcp->u_arg[1]);
877 }
878 return 0;
879}
Roland McGrathd83c50b2004-10-06 22:27:43 +0000880
881static void
Denys Vlasenko12014262011-05-30 14:00:14 +0200882print_rtc(struct tcb *tcp, const struct rtc_time *rt)
Roland McGrathd83c50b2004-10-06 22:27:43 +0000883{
884 tprintf("{tm_sec=%d, tm_min=%d, tm_hour=%d, "
885 "tm_mday=%d, tm_mon=%d, tm_year=%d, ",
886 rt->tm_sec, rt->tm_min, rt->tm_hour,
887 rt->tm_mday, rt->tm_mon, rt->tm_year);
888 if (!abbrev(tcp))
889 tprintf("tm_wday=%d, tm_yday=%d, tm_isdst=%d}",
890 rt->tm_wday, rt->tm_yday, rt->tm_isdst);
891 else
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200892 tprints("...}");
Roland McGrathd83c50b2004-10-06 22:27:43 +0000893}
894
895int
Denys Vlasenko12014262011-05-30 14:00:14 +0200896rtc_ioctl(struct tcb *tcp, long code, long arg)
Roland McGrathd83c50b2004-10-06 22:27:43 +0000897{
898 switch (code) {
899 case RTC_ALM_SET:
900 case RTC_SET_TIME:
901 if (entering(tcp)) {
902 struct rtc_time rt;
903 if (umove(tcp, arg, &rt) < 0)
904 tprintf(", %#lx", arg);
905 else {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200906 tprints(", ");
Roland McGrathd83c50b2004-10-06 22:27:43 +0000907 print_rtc(tcp, &rt);
908 }
909 }
910 break;
911 case RTC_ALM_READ:
912 case RTC_RD_TIME:
913 if (exiting(tcp)) {
914 struct rtc_time rt;
915 if (syserror(tcp) || umove(tcp, arg, &rt) < 0)
916 tprintf(", %#lx", arg);
917 else {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200918 tprints(", ");
Roland McGrathd83c50b2004-10-06 22:27:43 +0000919 print_rtc(tcp, &rt);
920 }
921 }
922 break;
923 case RTC_IRQP_SET:
924 case RTC_EPOCH_SET:
925 if (entering(tcp))
926 tprintf(", %lu", arg);
927 break;
928 case RTC_IRQP_READ:
929 case RTC_EPOCH_READ:
930 if (exiting(tcp))
931 tprintf(", %lu", arg);
932 break;
933 case RTC_WKALM_SET:
934 if (entering(tcp)) {
935 struct rtc_wkalrm wk;
936 if (umove(tcp, arg, &wk) < 0)
937 tprintf(", %#lx", arg);
938 else {
939 tprintf(", {enabled=%d, pending=%d, ",
940 wk.enabled, wk.pending);
941 print_rtc(tcp, &wk.time);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200942 tprints("}");
Roland McGrathd83c50b2004-10-06 22:27:43 +0000943 }
944 }
945 break;
946 case RTC_WKALM_RD:
947 if (exiting(tcp)) {
948 struct rtc_wkalrm wk;
949 if (syserror(tcp) || umove(tcp, arg, &wk) < 0)
950 tprintf(", %#lx", arg);
951 else {
952 tprintf(", {enabled=%d, pending=%d, ",
953 wk.enabled, wk.pending);
954 print_rtc(tcp, &wk.time);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200955 tprints("}");
Roland McGrathd83c50b2004-10-06 22:27:43 +0000956 }
957 }
958 break;
959 default:
960 if (entering(tcp))
961 tprintf(", %#lx", arg);
962 break;
963 }
964 return 1;
965}
Roland McGrathe4662342007-08-02 01:25:34 +0000966
967#ifndef TFD_TIMER_ABSTIME
968#define TFD_TIMER_ABSTIME (1 << 0)
969#endif
970
971static const struct xlat timerfdflags[] = {
972 { TFD_TIMER_ABSTIME, "TFD_TIMER_ABSTIME" },
973 { 0, NULL }
974};
975
976int
Denys Vlasenko12014262011-05-30 14:00:14 +0200977sys_timerfd(struct tcb *tcp)
Roland McGrathe4662342007-08-02 01:25:34 +0000978{
979 if (entering(tcp)) {
980 /* It does not matter that the kernel uses itimerspec. */
981 tprintf("%ld, ", tcp->u_arg[0]);
982 printxval(clocknames, tcp->u_arg[1], "CLOCK_???");
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200983 tprints(", ");
Roland McGrathe4662342007-08-02 01:25:34 +0000984 printflags(timerfdflags, tcp->u_arg[2], "TFD_???");
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200985 tprints(", ");
Roland McGrathe4662342007-08-02 01:25:34 +0000986 printitv(tcp, tcp->u_arg[3]);
987 }
988 return 0;
989}
Roland McGrathde328e62008-05-20 04:56:13 +0000990
991int
992sys_timerfd_create(struct tcb *tcp)
993{
994 if (entering(tcp)) {
995 printxval(clocknames, tcp->u_arg[0], "CLOCK_???");
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200996 tprints(", ");
Roland McGrathde328e62008-05-20 04:56:13 +0000997 printflags(timerfdflags, tcp->u_arg[1], "TFD_???");
998 }
999 return 0;
1000}
1001
1002int
1003sys_timerfd_settime(struct tcb *tcp)
1004{
1005 if (entering(tcp)) {
Dmitry V. Levin31382132011-03-04 05:08:02 +03001006 printfd(tcp, tcp->u_arg[0]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001007 tprints(", ");
Roland McGrathde328e62008-05-20 04:56:13 +00001008 printflags(timerfdflags, tcp->u_arg[1], "TFD_???");
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001009 tprints(", ");
Roland McGrathde328e62008-05-20 04:56:13 +00001010 printitv(tcp, tcp->u_arg[2]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001011 tprints(", ");
Roland McGrathde328e62008-05-20 04:56:13 +00001012 printitv(tcp, tcp->u_arg[3]);
1013 }
1014 return 0;
1015}
1016
1017int
1018sys_timerfd_gettime(struct tcb *tcp)
1019{
1020 if (entering(tcp)) {
Dmitry V. Levin31382132011-03-04 05:08:02 +03001021 printfd(tcp, tcp->u_arg[0]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001022 tprints(", ");
Roland McGrathde328e62008-05-20 04:56:13 +00001023 printitv(tcp, tcp->u_arg[1]);
1024 }
1025 return 0;
1026}
1027
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001028#endif /* LINUX */