blob: 897af3be754f7e91c515023cc787353dfc349ff7 [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{
Denys Vlasenkoa1d541e2012-01-20 11:04:04 +010069 char buf[TIMEVAL_TEXT_BUFSIZE];
70 sprinttv(buf, tcp, addr, bitness, special);
71 tprints(buf);
Dmitry V. Levina7945a32006-12-13 17:10:11 +000072}
Wichert Akkerman221f54f1999-11-18 17:26:45 +000073
Denys Vlasenko2fb4db32011-08-31 12:26:03 +020074char *
Denys Vlasenkoa1d541e2012-01-20 11:04:04 +010075sprinttv(char *buf, struct tcb *tcp, long addr, enum bitness_t bitness, int special)
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +000076{
Denys Vlasenko2fb4db32011-08-31 12:26:03 +020077 int rc;
78
Dmitry V. Levina7945a32006-12-13 17:10:11 +000079 if (addr == 0)
Denys Vlasenko2fb4db32011-08-31 12:26:03 +020080 return stpcpy(buf, "NULL");
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +000081
Denys Vlasenkob9c7ae62011-09-01 11:40:40 +020082 if (!verbose(tcp))
83 return buf + sprintf(buf, "%#lx", addr);
Denys Vlasenko2fb4db32011-08-31 12:26:03 +020084
85 if (bitness == BITNESS_32
86#if defined(LINUX) && SUPPORTED_PERSONALITIES > 1
87 || personality_wordsize[current_personality] == 4
88#endif
89 )
90 {
91 struct timeval32 tv;
92
93 rc = umove(tcp, addr, &tv);
Denys Vlasenkoa1d541e2012-01-20 11:04:04 +010094 if (rc >= 0) {
95 if (special && tv.tv_sec == 0) {
96 if (tv.tv_usec == UTIME_NOW)
97 return stpcpy(buf, "UTIME_NOW");
98 if (tv.tv_usec == UTIME_OMIT)
99 return stpcpy(buf, "UTIME_OMIT");
100 }
Denys Vlasenkob9c7ae62011-09-01 11:40:40 +0200101 return buf + sprintf(buf, "{%u, %u}",
Denys Vlasenko2fb4db32011-08-31 12:26:03 +0200102 tv.tv_sec, tv.tv_usec);
Denys Vlasenkoa1d541e2012-01-20 11:04:04 +0100103 }
Denys Vlasenko2fb4db32011-08-31 12:26:03 +0200104 } else {
105 struct timeval tv;
106
107 rc = umove(tcp, addr, &tv);
Denys Vlasenkoa1d541e2012-01-20 11:04:04 +0100108 if (rc >= 0) {
109 if (special && tv.tv_sec == 0) {
110 if (tv.tv_usec == UTIME_NOW)
111 return stpcpy(buf, "UTIME_NOW");
112 if (tv.tv_usec == UTIME_OMIT)
113 return stpcpy(buf, "UTIME_OMIT");
114 }
Denys Vlasenkob9c7ae62011-09-01 11:40:40 +0200115 return buf + sprintf(buf, "{%lu, %lu}",
Denys Vlasenko2fb4db32011-08-31 12:26:03 +0200116 (unsigned long) tv.tv_sec,
117 (unsigned long) tv.tv_usec);
Denys Vlasenkoa1d541e2012-01-20 11:04:04 +0100118 }
Denys Vlasenko2fb4db32011-08-31 12:26:03 +0200119 }
Denys Vlasenko2fb4db32011-08-31 12:26:03 +0200120
Denys Vlasenkob9c7ae62011-09-01 11:40:40 +0200121 return stpcpy(buf, "{...}");
Dmitry V. Levina7945a32006-12-13 17:10:11 +0000122}
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +0000123
Denys Vlasenkoa1d541e2012-01-20 11:04:04 +0100124void
125print_timespec(struct tcb *tcp, long addr)
Roland McGrath6bc09da2007-11-01 21:50:54 +0000126{
Denys Vlasenkoa1d541e2012-01-20 11:04:04 +0100127 char buf[TIMESPEC_TEXT_BUFSIZE];
128 sprint_timespec(buf, tcp, addr);
129 tprints(buf);
Roland McGrath6bc09da2007-11-01 21:50:54 +0000130}
131
Denys Vlasenkoa1d541e2012-01-20 11:04:04 +0100132void
133sprint_timespec(char *buf, struct tcb *tcp, long addr)
Roland McGrath6bc09da2007-11-01 21:50:54 +0000134{
135 if (addr == 0)
136 strcpy(buf, "NULL");
137 else if (!verbose(tcp))
138 sprintf(buf, "%#lx", addr);
139 else {
Denys Vlasenko1d632462009-04-14 12:51:00 +0000140 int rc;
Roland McGrath6bc09da2007-11-01 21:50:54 +0000141
142#if defined(LINUX) && SUPPORTED_PERSONALITIES > 1
Denys Vlasenko1d632462009-04-14 12:51:00 +0000143 if (personality_wordsize[current_personality] == 4) {
Roland McGrath6bc09da2007-11-01 21:50:54 +0000144 struct timeval32 tv;
145
Denys Vlasenko5d645812011-08-20 12:48:18 +0200146 rc = umove(tcp, addr, &tv);
147 if (rc >= 0)
Roland McGrath6bc09da2007-11-01 21:50:54 +0000148 sprintf(buf, "{%u, %u}",
149 tv.tv_sec, tv.tv_usec);
150 } else
Roland McGrath6bc09da2007-11-01 21:50:54 +0000151#endif
Denys Vlasenko1d632462009-04-14 12:51:00 +0000152 {
Roland McGrath6bc09da2007-11-01 21:50:54 +0000153 struct timespec ts;
154
Denys Vlasenko5d645812011-08-20 12:48:18 +0200155 rc = umove(tcp, addr, &ts);
156 if (rc >= 0)
Roland McGrath6bc09da2007-11-01 21:50:54 +0000157 sprintf(buf, "{%lu, %lu}",
158 (unsigned long) ts.tv_sec,
159 (unsigned long) ts.tv_nsec);
Roland McGrath6bc09da2007-11-01 21:50:54 +0000160 }
Roland McGrath6bc09da2007-11-01 21:50:54 +0000161 if (rc < 0)
162 strcpy(buf, "{...}");
163 }
164}
165
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000166int
Denys Vlasenko12014262011-05-30 14:00:14 +0200167sys_time(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000168{
169 if (exiting(tcp)) {
170#ifndef SVR4
171 printnum(tcp, tcp->u_arg[0], "%ld");
172#endif /* SVR4 */
173 }
174 return 0;
175}
176
177int
Denys Vlasenko12014262011-05-30 14:00:14 +0200178sys_stime(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000179{
180 if (exiting(tcp)) {
181 printnum(tcp, tcp->u_arg[0], "%ld");
182 }
183 return 0;
184}
185
186int
Denys Vlasenko12014262011-05-30 14:00:14 +0200187sys_gettimeofday(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000188{
189 if (exiting(tcp)) {
190 if (syserror(tcp)) {
191 tprintf("%#lx, %#lx",
192 tcp->u_arg[0], tcp->u_arg[1]);
193 return 0;
194 }
195 printtv(tcp, tcp->u_arg[0]);
196#ifndef SVR4
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200197 tprints(", ");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000198 printtv(tcp, tcp->u_arg[1]);
199#endif /* !SVR4 */
200 }
201 return 0;
202}
203
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +0000204
205#ifdef ALPHA
206int
Denys Vlasenko12014262011-05-30 14:00:14 +0200207sys_osf_gettimeofday(struct tcb *tcp)
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +0000208{
Denys Vlasenko1d632462009-04-14 12:51:00 +0000209 if (exiting(tcp)) {
210 if (syserror(tcp)) {
211 tprintf("%#lx, %#lx", tcp->u_arg[0], tcp->u_arg[1]);
212 return 0;
213 }
214 printtv_bitness(tcp, tcp->u_arg[0], BITNESS_32, 0);
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +0000215#ifndef SVR4
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200216 tprints(", ");
Denys Vlasenko1d632462009-04-14 12:51:00 +0000217 printtv_bitness(tcp, tcp->u_arg[1], BITNESS_32, 0);
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +0000218#endif /* !SVR4 */
Denys Vlasenko1d632462009-04-14 12:51:00 +0000219 }
220 return 0;
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +0000221}
222#endif
223
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000224int
Denys Vlasenko12014262011-05-30 14:00:14 +0200225sys_settimeofday(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000226{
227 if (entering(tcp)) {
228 printtv(tcp, tcp->u_arg[0]);
229#ifndef SVR4
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200230 tprints(", ");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000231 printtv(tcp, tcp->u_arg[1]);
232#endif /* !SVR4 */
233 }
234 return 0;
235}
236
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +0000237#ifdef ALPHA
238int
Denys Vlasenko12014262011-05-30 14:00:14 +0200239sys_osf_settimeofday(struct tcb *tcp)
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +0000240{
Denys Vlasenko1d632462009-04-14 12:51:00 +0000241 if (entering(tcp)) {
242 printtv_bitness(tcp, tcp->u_arg[0], BITNESS_32, 0);
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +0000243#ifndef SVR4
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200244 tprints(", ");
Denys Vlasenko1d632462009-04-14 12:51:00 +0000245 printtv_bitness(tcp, tcp->u_arg[1], BITNESS_32, 0);
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +0000246#endif /* !SVR4 */
Denys Vlasenko1d632462009-04-14 12:51:00 +0000247 }
248 return 0;
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +0000249}
250#endif
251
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000252int
Denys Vlasenko12014262011-05-30 14:00:14 +0200253sys_adjtime(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000254{
255 if (entering(tcp)) {
256 printtv(tcp, tcp->u_arg[0]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200257 tprints(", ");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000258 } else {
259 if (syserror(tcp))
260 tprintf("%#lx", tcp->u_arg[1]);
261 else
262 printtv(tcp, tcp->u_arg[1]);
263 }
264 return 0;
265}
266
Dmitry V. Levin2e55ff42008-09-03 01:02:46 +0000267int
268sys_nanosleep(struct tcb *tcp)
269{
270 if (entering(tcp)) {
271 print_timespec(tcp, tcp->u_arg[0]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200272 tprints(", ");
Dmitry V. Levin2e55ff42008-09-03 01:02:46 +0000273 } else {
Denys Vlasenko64acaa12012-01-28 02:29:36 +0100274 /* Second (returned) timespec is only significant
275 * if syscall was interrupted. We print only its address
276 * on _success_, since kernel doesn't modify its value.
277 */
278 if (is_restart_error(tcp) || !tcp->u_arg[1])
279 /* Interrupted (or NULL) */
Dmitry V. Levin2e55ff42008-09-03 01:02:46 +0000280 print_timespec(tcp, tcp->u_arg[1]);
281 else
Denys Vlasenko64acaa12012-01-28 02:29:36 +0100282 /* Success */
Dmitry V. Levin2e55ff42008-09-03 01:02:46 +0000283 tprintf("%#lx", tcp->u_arg[1]);
284 }
285 return 0;
286}
287
Roland McGrathd9f816f2004-09-04 03:39:20 +0000288static const struct xlat which[] = {
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000289 { ITIMER_REAL, "ITIMER_REAL" },
290 { ITIMER_VIRTUAL,"ITIMER_VIRTUAL"},
291 { ITIMER_PROF, "ITIMER_PROF" },
292 { 0, NULL },
293};
294
295static void
Dmitry V. Levin1cad25d2006-12-13 17:14:36 +0000296printitv_bitness(struct tcb *tcp, long addr, enum bitness_t bitness)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000297{
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000298 if (addr == 0)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200299 tprints("NULL");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000300 else if (!verbose(tcp))
301 tprintf("%#lx", addr);
Denys Vlasenko1d632462009-04-14 12:51:00 +0000302 else {
303 int rc;
Dmitry V. Levin1cad25d2006-12-13 17:14:36 +0000304
305 if (bitness == BITNESS_32
306#if defined(LINUX) && SUPPORTED_PERSONALITIES > 1
307 || personality_wordsize[current_personality] == 4
308#endif
309 )
310 {
Denys Vlasenko1d632462009-04-14 12:51:00 +0000311 struct {
Dmitry V. Levin1cad25d2006-12-13 17:14:36 +0000312 struct timeval32 it_interval, it_value;
313 } itv;
314
Denys Vlasenko5d645812011-08-20 12:48:18 +0200315 rc = umove(tcp, addr, &itv);
316 if (rc >= 0) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200317 tprints("{it_interval=");
Dmitry V. Levin1cad25d2006-12-13 17:14:36 +0000318 tprint_timeval32(tcp, &itv.it_interval);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200319 tprints(", it_value=");
Dmitry V. Levin1cad25d2006-12-13 17:14:36 +0000320 tprint_timeval32(tcp, &itv.it_value);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200321 tprints("}");
Roland McGrathe4662342007-08-02 01:25:34 +0000322 }
Denys Vlasenko1d632462009-04-14 12:51:00 +0000323 } else {
Dmitry V. Levin1cad25d2006-12-13 17:14:36 +0000324 struct itimerval itv;
325
Denys Vlasenko5d645812011-08-20 12:48:18 +0200326 rc = umove(tcp, addr, &itv);
327 if (rc >= 0) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200328 tprints("{it_interval=");
Dmitry V. Levin1cad25d2006-12-13 17:14:36 +0000329 tprint_timeval(tcp, &itv.it_interval);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200330 tprints(", it_value=");
Dmitry V. Levin1cad25d2006-12-13 17:14:36 +0000331 tprint_timeval(tcp, &itv.it_value);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200332 tprints("}");
Roland McGrathe4662342007-08-02 01:25:34 +0000333 }
Dmitry V. Levin1cad25d2006-12-13 17:14:36 +0000334 }
Dmitry V. Levin1cad25d2006-12-13 17:14:36 +0000335 if (rc < 0)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200336 tprints("{...}");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000337 }
338}
339
Dmitry V. Levin1cad25d2006-12-13 17:14:36 +0000340#define printitv(tcp, addr) \
341 printitv_bitness((tcp), (addr), BITNESS_CURRENT)
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +0000342
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000343int
Denys Vlasenko12014262011-05-30 14:00:14 +0200344sys_getitimer(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000345{
346 if (entering(tcp)) {
347 printxval(which, tcp->u_arg[0], "ITIMER_???");
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200348 tprints(", ");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000349 } else {
350 if (syserror(tcp))
351 tprintf("%#lx", tcp->u_arg[1]);
352 else
353 printitv(tcp, tcp->u_arg[1]);
354 }
355 return 0;
356}
357
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +0000358
359#ifdef ALPHA
360int
Denys Vlasenko12014262011-05-30 14:00:14 +0200361sys_osf_getitimer(struct tcb *tcp)
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +0000362{
Denys Vlasenko1d632462009-04-14 12:51:00 +0000363 if (entering(tcp)) {
364 printxval(which, tcp->u_arg[0], "ITIMER_???");
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200365 tprints(", ");
Denys Vlasenko1d632462009-04-14 12:51:00 +0000366 } else {
367 if (syserror(tcp))
368 tprintf("%#lx", tcp->u_arg[1]);
369 else
370 printitv_bitness(tcp, tcp->u_arg[1], BITNESS_32);
371 }
372 return 0;
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +0000373}
374#endif
375
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000376int
Denys Vlasenko12014262011-05-30 14:00:14 +0200377sys_setitimer(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000378{
379 if (entering(tcp)) {
380 printxval(which, tcp->u_arg[0], "ITIMER_???");
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200381 tprints(", ");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000382 printitv(tcp, tcp->u_arg[1]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200383 tprints(", ");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000384 } else {
385 if (syserror(tcp))
386 tprintf("%#lx", tcp->u_arg[2]);
387 else
388 printitv(tcp, tcp->u_arg[2]);
389 }
390 return 0;
391}
392
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +0000393#ifdef ALPHA
394int
Denys Vlasenko12014262011-05-30 14:00:14 +0200395sys_osf_setitimer(struct tcb *tcp)
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +0000396{
Denys Vlasenko1d632462009-04-14 12:51:00 +0000397 if (entering(tcp)) {
398 printxval(which, tcp->u_arg[0], "ITIMER_???");
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200399 tprints(", ");
Denys Vlasenko1d632462009-04-14 12:51:00 +0000400 printitv_bitness(tcp, tcp->u_arg[1], BITNESS_32);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200401 tprints(", ");
Denys Vlasenko1d632462009-04-14 12:51:00 +0000402 } else {
403 if (syserror(tcp))
404 tprintf("%#lx", tcp->u_arg[2]);
405 else
406 printitv_bitness(tcp, tcp->u_arg[2], BITNESS_32);
407 }
408 return 0;
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +0000409}
410#endif
411
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000412#ifdef LINUX
413
Dmitry V. Levin1a684d62006-12-13 17:42:32 +0000414static const struct xlat adjtimex_modes[] = {
415 { 0, "0" },
416#ifdef ADJ_OFFSET
417 { ADJ_OFFSET, "ADJ_OFFSET" },
418#endif
419#ifdef ADJ_FREQUENCY
420 { ADJ_FREQUENCY, "ADJ_FREQUENCY" },
421#endif
422#ifdef ADJ_MAXERROR
423 { ADJ_MAXERROR, "ADJ_MAXERROR" },
424#endif
425#ifdef ADJ_ESTERROR
426 { ADJ_ESTERROR, "ADJ_ESTERROR" },
427#endif
428#ifdef ADJ_STATUS
429 { ADJ_STATUS, "ADJ_STATUS" },
430#endif
431#ifdef ADJ_TIMECONST
432 { ADJ_TIMECONST, "ADJ_TIMECONST" },
433#endif
434#ifdef ADJ_TICK
435 { ADJ_TICK, "ADJ_TICK" },
436#endif
437#ifdef ADJ_OFFSET_SINGLESHOT
438 { ADJ_OFFSET_SINGLESHOT, "ADJ_OFFSET_SINGLESHOT" },
439#endif
440 { 0, NULL }
441};
442
443static const struct xlat adjtimex_status[] = {
444#ifdef STA_PLL
445 { STA_PLL, "STA_PLL" },
446#endif
447#ifdef STA_PPSFREQ
448 { STA_PPSFREQ, "STA_PPSFREQ" },
449#endif
450#ifdef STA_PPSTIME
451 { STA_PPSTIME, "STA_PPSTIME" },
452#endif
453#ifdef STA_FLL
454 { STA_FLL, "STA_FLL" },
455#endif
456#ifdef STA_INS
457 { STA_INS, "STA_INS" },
458#endif
459#ifdef STA_DEL
460 { STA_DEL, "STA_DEL" },
461#endif
462#ifdef STA_UNSYNC
463 { STA_UNSYNC, "STA_UNSYNC" },
464#endif
465#ifdef STA_FREQHOLD
466 { STA_FREQHOLD, "STA_FREQHOLD" },
467#endif
468#ifdef STA_PPSSIGNAL
469 { STA_PPSSIGNAL, "STA_PPSSIGNAL" },
470#endif
471#ifdef STA_PPSJITTER
472 { STA_PPSJITTER, "STA_PPSJITTER" },
473#endif
474#ifdef STA_PPSWANDER
475 { STA_PPSWANDER, "STA_PPSWANDER" },
476#endif
477#ifdef STA_PPSERROR
478 { STA_PPSERROR, "STA_PPSERROR" },
479#endif
480#ifdef STA_CLOCKERR
481 { STA_CLOCKERR, "STA_CLOCKERR" },
482#endif
483 { 0, NULL }
484};
485
486static const struct xlat adjtimex_state[] = {
487#ifdef TIME_OK
488 { TIME_OK, "TIME_OK" },
489#endif
490#ifdef TIME_INS
491 { TIME_INS, "TIME_INS" },
492#endif
493#ifdef TIME_DEL
494 { TIME_DEL, "TIME_DEL" },
495#endif
496#ifdef TIME_OOP
497 { TIME_OOP, "TIME_OOP" },
498#endif
499#ifdef TIME_WAIT
500 { TIME_WAIT, "TIME_WAIT" },
501#endif
502#ifdef TIME_ERROR
503 { TIME_ERROR, "TIME_ERROR" },
504#endif
505 { 0, NULL }
506};
507
Dmitry V. Levin165b15d2006-12-13 17:43:45 +0000508#if SUPPORTED_PERSONALITIES > 1
509static int
510tprint_timex32(struct tcb *tcp, long addr)
511{
Denys Vlasenko1d632462009-04-14 12:51:00 +0000512 struct {
Dmitry V. Levin165b15d2006-12-13 17:43:45 +0000513 unsigned int modes;
514 int offset;
515 int freq;
516 int maxerror;
517 int esterror;
518 int status;
519 int constant;
520 int precision;
521 int tolerance;
522 struct timeval32 time;
523 int tick;
524 int ppsfreq;
525 int jitter;
526 int shift;
527 int stabil;
528 int jitcnt;
529 int calcnt;
530 int errcnt;
531 int stbcnt;
532 } tx;
533
534 if (umove(tcp, addr, &tx) < 0)
535 return -1;
536
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200537 tprints("{modes=");
Dmitry V. Levin71d70892007-01-13 11:17:38 +0000538 printflags(adjtimex_modes, tx.modes, "ADJ_???");
Dmitry V. Levin165b15d2006-12-13 17:43:45 +0000539 tprintf(", offset=%d, freq=%d, maxerror=%d, ",
540 tx.offset, tx.freq, tx.maxerror);
541 tprintf("esterror=%u, status=", tx.esterror);
542 printflags(adjtimex_status, tx.status, "STA_???");
543 tprintf(", constant=%d, precision=%u, ",
544 tx.constant, tx.precision);
545 tprintf("tolerance=%d, time=", tx.tolerance);
546 tprint_timeval32(tcp, &tx.time);
547 tprintf(", tick=%d, ppsfreq=%d, jitter=%d",
548 tx.tick, tx.ppsfreq, tx.jitter);
549 tprintf(", shift=%d, stabil=%d, jitcnt=%d",
550 tx.shift, tx.stabil, tx.jitcnt);
551 tprintf(", calcnt=%d, errcnt=%d, stbcnt=%d",
552 tx.calcnt, tx.errcnt, tx.stbcnt);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200553 tprints("}");
Dmitry V. Levin165b15d2006-12-13 17:43:45 +0000554 return 0;
555}
556#endif /* SUPPORTED_PERSONALITIES > 1 */
557
558static int
559tprint_timex(struct tcb *tcp, long addr)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000560{
Dmitry V. Levin1a684d62006-12-13 17:42:32 +0000561 struct timex tx;
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000562
Dmitry V. Levin165b15d2006-12-13 17:43:45 +0000563#if SUPPORTED_PERSONALITIES > 1
564 if (personality_wordsize[current_personality] == 4)
565 return tprint_timex32(tcp, addr);
566#endif
567 if (umove(tcp, addr, &tx) < 0)
568 return -1;
569
570#if LINUX_VERSION_CODE < 66332
571 tprintf("{mode=%d, offset=%ld, frequency=%ld, ",
572 tx.mode, tx.offset, tx.frequency);
573 tprintf("maxerror=%ld, esterror=%lu, status=%u, ",
574 tx.maxerror, tx.esterror, tx.status);
575 tprintf("time_constant=%ld, precision=%lu, ",
576 tx.time_constant, tx.precision);
577 tprintf("tolerance=%ld, time=", tx.tolerance);
578 tprint_timeval(tcp, &tx.time);
579#else
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200580 tprints("{modes=");
Dmitry V. Levin71d70892007-01-13 11:17:38 +0000581 printflags(adjtimex_modes, tx.modes, "ADJ_???");
Dmitry V. Levin165b15d2006-12-13 17:43:45 +0000582 tprintf(", offset=%ld, freq=%ld, maxerror=%ld, ",
H.J. Lu0b315b62012-02-03 10:16:03 -0800583 (long) tx.offset, (long) tx.freq, (long) tx.maxerror);
584 tprintf("esterror=%lu, status=", (long) tx.esterror);
Dmitry V. Levin165b15d2006-12-13 17:43:45 +0000585 printflags(adjtimex_status, tx.status, "STA_???");
586 tprintf(", constant=%ld, precision=%lu, ",
H.J. Lu0b315b62012-02-03 10:16:03 -0800587 (long) tx.constant, (long) tx.precision);
588 tprintf("tolerance=%ld, time=", (long) tx.tolerance);
Dmitry V. Levin165b15d2006-12-13 17:43:45 +0000589 tprint_timeval(tcp, &tx.time);
590 tprintf(", tick=%ld, ppsfreq=%ld, jitter=%ld",
H.J. Lu0b315b62012-02-03 10:16:03 -0800591 (long) tx.tick, (long) tx.ppsfreq, (long) tx.jitter);
Dmitry V. Levin165b15d2006-12-13 17:43:45 +0000592 tprintf(", shift=%d, stabil=%ld, jitcnt=%ld",
H.J. Lu0b315b62012-02-03 10:16:03 -0800593 tx.shift, (long) tx.stabil, (long) tx.jitcnt);
Dmitry V. Levin165b15d2006-12-13 17:43:45 +0000594 tprintf(", calcnt=%ld, errcnt=%ld, stbcnt=%ld",
H.J. Lu0b315b62012-02-03 10:16:03 -0800595 (long) tx.calcnt, (long) tx.errcnt, (long) tx.stbcnt);
Dmitry V. Levin165b15d2006-12-13 17:43:45 +0000596#endif
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200597 tprints("}");
Dmitry V. Levin165b15d2006-12-13 17:43:45 +0000598 return 0;
599}
600
601int
602sys_adjtimex(struct tcb *tcp)
603{
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000604 if (exiting(tcp)) {
605 if (tcp->u_arg[0] == 0)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200606 tprints("NULL");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000607 else if (syserror(tcp) || !verbose(tcp))
608 tprintf("%#lx", tcp->u_arg[0]);
Dmitry V. Levin165b15d2006-12-13 17:43:45 +0000609 else if (tprint_timex(tcp, tcp->u_arg[0]) < 0)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200610 tprints("{...}");
Dmitry V. Levin21a75342008-09-03 01:22:18 +0000611 if (syserror(tcp))
612 return 0;
Dmitry V. Levin1a684d62006-12-13 17:42:32 +0000613 tcp->auxstr = xlookup(adjtimex_state, tcp->u_rval);
614 if (tcp->auxstr)
615 return RVAL_STR;
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000616 }
617 return 0;
618}
Roland McGrath1e356792003-03-30 23:52:28 +0000619
Roland McGrathd9f816f2004-09-04 03:39:20 +0000620static const struct xlat clockflags[] = {
Roland McGrath1e356792003-03-30 23:52:28 +0000621 { TIMER_ABSTIME, "TIMER_ABSTIME" },
622 { 0, NULL }
623};
624
Roland McGrathd9f816f2004-09-04 03:39:20 +0000625static const struct xlat clocknames[] = {
Roland McGrath55a00f82004-08-31 08:26:39 +0000626#ifdef CLOCK_REALTIME
Roland McGrath54a4edd2004-08-31 06:52:45 +0000627 { CLOCK_REALTIME, "CLOCK_REALTIME" },
Roland McGrath55a00f82004-08-31 08:26:39 +0000628#endif
629#ifdef CLOCK_MONOTONIC
Roland McGrath54a4edd2004-08-31 06:52:45 +0000630 { CLOCK_MONOTONIC, "CLOCK_MONOTONIC" },
Roland McGrath55a00f82004-08-31 08:26:39 +0000631#endif
Dmitry V. Levincbaaf792010-09-17 09:19:49 +0000632#ifdef CLOCK_PROCESS_CPUTIME_ID
633 { CLOCK_PROCESS_CPUTIME_ID, "CLOCK_PROCESS_CPUTIME_ID" },
634#endif
635#ifdef CLOCK_THREAD_CPUTIME_ID
636 { CLOCK_THREAD_CPUTIME_ID, "CLOCK_THREAD_CPUTIME_ID" },
637#endif
638#ifdef CLOCK_MONOTONIC_RAW
639 { CLOCK_MONOTONIC_RAW, "CLOCK_MONOTONIC_RAW" },
640#endif
641#ifdef CLOCK_REALTIME_COARSE
642 { CLOCK_REALTIME_COARSE, "CLOCK_REALTIME_COARSE" },
643#endif
644#ifdef CLOCK_MONOTONIC_COARSE
645 { CLOCK_MONOTONIC_COARSE, "CLOCK_MONOTONIC_COARSE" },
646#endif
647 { 0, NULL }
Roland McGrath54a4edd2004-08-31 06:52:45 +0000648};
649
Roland McGrath1e356792003-03-30 23:52:28 +0000650int
Denys Vlasenko12014262011-05-30 14:00:14 +0200651sys_clock_settime(struct tcb *tcp)
Roland McGrath1e356792003-03-30 23:52:28 +0000652{
653 if (entering(tcp)) {
Roland McGrath54a4edd2004-08-31 06:52:45 +0000654 printxval(clocknames, tcp->u_arg[0], "CLOCK_???");
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200655 tprints(", ");
Roland McGrath1e356792003-03-30 23:52:28 +0000656 printtv(tcp, tcp->u_arg[1]);
657 }
658 return 0;
659}
660
661int
Denys Vlasenko12014262011-05-30 14:00:14 +0200662sys_clock_gettime(struct tcb *tcp)
Roland McGrath1e356792003-03-30 23:52:28 +0000663{
664 if (entering(tcp)) {
Roland McGrath54a4edd2004-08-31 06:52:45 +0000665 printxval(clocknames, tcp->u_arg[0], "CLOCK_???");
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200666 tprints(", ");
Roland McGrath1e356792003-03-30 23:52:28 +0000667 } else {
668 if (syserror(tcp))
669 tprintf("%#lx", tcp->u_arg[1]);
670 else
671 printtv(tcp, tcp->u_arg[1]);
672 }
673 return 0;
674}
675
676int
Denys Vlasenko12014262011-05-30 14:00:14 +0200677sys_clock_nanosleep(struct tcb *tcp)
Roland McGrath1e356792003-03-30 23:52:28 +0000678{
679 if (entering(tcp)) {
Roland McGrath54a4edd2004-08-31 06:52:45 +0000680 printxval(clocknames, tcp->u_arg[0], "CLOCK_???");
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200681 tprints(", ");
Roland McGrathb2dee132005-06-01 19:02:36 +0000682 printflags(clockflags, tcp->u_arg[1], "TIMER_???");
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200683 tprints(", ");
Roland McGrath1e356792003-03-30 23:52:28 +0000684 printtv(tcp, tcp->u_arg[2]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200685 tprints(", ");
Roland McGrath1e356792003-03-30 23:52:28 +0000686 } else {
687 if (syserror(tcp))
688 tprintf("%#lx", tcp->u_arg[3]);
689 else
690 printtv(tcp, tcp->u_arg[3]);
691 }
692 return 0;
693}
694
695#ifndef SIGEV_THREAD_ID
696# define SIGEV_THREAD_ID 4
697#endif
Roland McGrathd9f816f2004-09-04 03:39:20 +0000698static const struct xlat sigev_value[] = {
Roland McGrath1e356792003-03-30 23:52:28 +0000699 { SIGEV_SIGNAL+1, "SIGEV_SIGNAL" },
700 { SIGEV_NONE+1, "SIGEV_NONE" },
701 { SIGEV_THREAD+1, "SIGEV_THREAD" },
702 { SIGEV_THREAD_ID+1, "SIGEV_THREAD_ID" },
703 { 0, NULL }
704};
705
Dmitry V. Levind3cb3922006-12-13 17:45:02 +0000706#if SUPPORTED_PERSONALITIES > 1
707static void
708printsigevent32(struct tcb *tcp, long arg)
709{
Denys Vlasenko1d632462009-04-14 12:51:00 +0000710 struct {
Dmitry V. Levind3cb3922006-12-13 17:45:02 +0000711 int sigev_value;
712 int sigev_signo;
713 int sigev_notify;
714
Denys Vlasenko1d632462009-04-14 12:51:00 +0000715 union {
Dmitry V. Levind3cb3922006-12-13 17:45:02 +0000716 int tid;
Denys Vlasenko1d632462009-04-14 12:51:00 +0000717 struct {
Dmitry V. Levind3cb3922006-12-13 17:45:02 +0000718 int function, attribute;
719 } thread;
720 } un;
721 } sev;
722
723 if (umove(tcp, arg, &sev) < 0)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200724 tprints("{...}");
Denys Vlasenko1d632462009-04-14 12:51:00 +0000725 else {
Dmitry V. Levind3cb3922006-12-13 17:45:02 +0000726 tprintf("{%#x, ", sev.sigev_value);
727 if (sev.sigev_notify == SIGEV_SIGNAL)
728 tprintf("%s, ", signame(sev.sigev_signo));
729 else
730 tprintf("%u, ", sev.sigev_signo);
731 printxval(sigev_value, sev.sigev_notify + 1, "SIGEV_???");
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200732 tprints(", ");
Dmitry V. Levind3cb3922006-12-13 17:45:02 +0000733 if (sev.sigev_notify == SIGEV_THREAD_ID)
734 tprintf("{%d}", sev.un.tid);
735 else if (sev.sigev_notify == SIGEV_THREAD)
736 tprintf("{%#x, %#x}",
737 sev.un.thread.function,
738 sev.un.thread.attribute);
739 else
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200740 tprints("{...}");
741 tprints("}");
Dmitry V. Levind3cb3922006-12-13 17:45:02 +0000742 }
743}
744#endif
745
Roland McGrath1e356792003-03-30 23:52:28 +0000746void
Dmitry V. Levind3cb3922006-12-13 17:45:02 +0000747printsigevent(struct tcb *tcp, long arg)
Roland McGrath1e356792003-03-30 23:52:28 +0000748{
749 struct sigevent sev;
Dmitry V. Levind3cb3922006-12-13 17:45:02 +0000750
751#if SUPPORTED_PERSONALITIES > 1
Denys Vlasenko7b609d52011-06-22 14:32:43 +0200752 if (personality_wordsize[current_personality] == 4) {
Dmitry V. Levind3cb3922006-12-13 17:45:02 +0000753 printsigevent32(tcp, arg);
754 return;
755 }
756#endif
Denys Vlasenkob63256e2011-06-07 12:13:24 +0200757 if (umove(tcp, arg, &sev) < 0)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200758 tprints("{...}");
Roland McGrath1e356792003-03-30 23:52:28 +0000759 else {
Roland McGrath675d4a62004-09-11 08:12:45 +0000760 tprintf("{%p, ", sev.sigev_value.sival_ptr);
761 if (sev.sigev_notify == SIGEV_SIGNAL)
762 tprintf("%s, ", signame(sev.sigev_signo));
763 else
764 tprintf("%u, ", sev.sigev_signo);
Roland McGrath1e356792003-03-30 23:52:28 +0000765 printxval(sigev_value, sev.sigev_notify+1, "SIGEV_???");
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200766 tprints(", ");
Roland McGrath1e356792003-03-30 23:52:28 +0000767 if (sev.sigev_notify == SIGEV_THREAD_ID)
768 /* _pad[0] is the _tid field which might not be
769 present in the userlevel definition of the
770 struct. */
771 tprintf("{%d}", sev._sigev_un._pad[0]);
Roland McGrathd4c85eb2004-04-16 21:48:44 +0000772 else if (sev.sigev_notify == SIGEV_THREAD)
773 tprintf("{%p, %p}", sev.sigev_notify_function,
774 sev.sigev_notify_attributes);
Roland McGrath1e356792003-03-30 23:52:28 +0000775 else
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200776 tprints("{...}");
777 tprints("}");
Roland McGrath1e356792003-03-30 23:52:28 +0000778 }
779}
780
781int
Denys Vlasenko12014262011-05-30 14:00:14 +0200782sys_timer_create(struct tcb *tcp)
Roland McGrath1e356792003-03-30 23:52:28 +0000783{
784 if (entering(tcp)) {
Roland McGrath675d4a62004-09-11 08:12:45 +0000785 printxval(clocknames, tcp->u_arg[0], "CLOCK_???");
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200786 tprints(", ");
Roland McGrath1e356792003-03-30 23:52:28 +0000787 printsigevent(tcp, tcp->u_arg[1]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200788 tprints(", ");
Roland McGrath1e356792003-03-30 23:52:28 +0000789 } else {
Andi Kleen732f3962011-06-13 21:37:40 +0000790 int timer_id;
Dmitry V. Levinac518d12006-12-13 17:03:02 +0000791
Andi Kleen732f3962011-06-13 21:37:40 +0000792 if (syserror(tcp) || umove(tcp, tcp->u_arg[2], &timer_id) < 0)
Roland McGrath1e356792003-03-30 23:52:28 +0000793 tprintf("%#lx", tcp->u_arg[2]);
Dmitry V. Levinac518d12006-12-13 17:03:02 +0000794 else
Andi Kleen732f3962011-06-13 21:37:40 +0000795 tprintf("{%d}", timer_id);
Roland McGrath1e356792003-03-30 23:52:28 +0000796 }
797 return 0;
798}
799
800int
Denys Vlasenko12014262011-05-30 14:00:14 +0200801sys_timer_settime(struct tcb *tcp)
Roland McGrath1e356792003-03-30 23:52:28 +0000802{
803 if (entering(tcp)) {
804 tprintf("%#lx, ", tcp->u_arg[0]);
Roland McGrathb2dee132005-06-01 19:02:36 +0000805 printflags(clockflags, tcp->u_arg[1], "TIMER_???");
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200806 tprints(", ");
Roland McGrath1e356792003-03-30 23:52:28 +0000807 printitv(tcp, tcp->u_arg[2]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200808 tprints(", ");
Roland McGrath1e356792003-03-30 23:52:28 +0000809 } else {
810 if (syserror(tcp))
811 tprintf("%#lx", tcp->u_arg[3]);
812 else
813 printitv(tcp, tcp->u_arg[3]);
814 }
815 return 0;
816}
817
818int
Denys Vlasenko12014262011-05-30 14:00:14 +0200819sys_timer_gettime(struct tcb *tcp)
Roland McGrath1e356792003-03-30 23:52:28 +0000820{
821 if (entering(tcp)) {
822 tprintf("%#lx, ", tcp->u_arg[0]);
823 } else {
824 if (syserror(tcp))
825 tprintf("%#lx", tcp->u_arg[1]);
826 else
827 printitv(tcp, tcp->u_arg[1]);
828 }
829 return 0;
830}
Roland McGrathd83c50b2004-10-06 22:27:43 +0000831
832static void
Denys Vlasenko12014262011-05-30 14:00:14 +0200833print_rtc(struct tcb *tcp, const struct rtc_time *rt)
Roland McGrathd83c50b2004-10-06 22:27:43 +0000834{
835 tprintf("{tm_sec=%d, tm_min=%d, tm_hour=%d, "
836 "tm_mday=%d, tm_mon=%d, tm_year=%d, ",
837 rt->tm_sec, rt->tm_min, rt->tm_hour,
838 rt->tm_mday, rt->tm_mon, rt->tm_year);
839 if (!abbrev(tcp))
840 tprintf("tm_wday=%d, tm_yday=%d, tm_isdst=%d}",
841 rt->tm_wday, rt->tm_yday, rt->tm_isdst);
842 else
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200843 tprints("...}");
Roland McGrathd83c50b2004-10-06 22:27:43 +0000844}
845
846int
Denys Vlasenko12014262011-05-30 14:00:14 +0200847rtc_ioctl(struct tcb *tcp, long code, long arg)
Roland McGrathd83c50b2004-10-06 22:27:43 +0000848{
849 switch (code) {
850 case RTC_ALM_SET:
851 case RTC_SET_TIME:
852 if (entering(tcp)) {
853 struct rtc_time rt;
854 if (umove(tcp, arg, &rt) < 0)
855 tprintf(", %#lx", arg);
856 else {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200857 tprints(", ");
Roland McGrathd83c50b2004-10-06 22:27:43 +0000858 print_rtc(tcp, &rt);
859 }
860 }
861 break;
862 case RTC_ALM_READ:
863 case RTC_RD_TIME:
864 if (exiting(tcp)) {
865 struct rtc_time rt;
866 if (syserror(tcp) || umove(tcp, arg, &rt) < 0)
867 tprintf(", %#lx", arg);
868 else {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200869 tprints(", ");
Roland McGrathd83c50b2004-10-06 22:27:43 +0000870 print_rtc(tcp, &rt);
871 }
872 }
873 break;
874 case RTC_IRQP_SET:
875 case RTC_EPOCH_SET:
876 if (entering(tcp))
877 tprintf(", %lu", arg);
878 break;
879 case RTC_IRQP_READ:
880 case RTC_EPOCH_READ:
881 if (exiting(tcp))
882 tprintf(", %lu", arg);
883 break;
884 case RTC_WKALM_SET:
885 if (entering(tcp)) {
886 struct rtc_wkalrm wk;
887 if (umove(tcp, arg, &wk) < 0)
888 tprintf(", %#lx", arg);
889 else {
890 tprintf(", {enabled=%d, pending=%d, ",
891 wk.enabled, wk.pending);
892 print_rtc(tcp, &wk.time);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200893 tprints("}");
Roland McGrathd83c50b2004-10-06 22:27:43 +0000894 }
895 }
896 break;
897 case RTC_WKALM_RD:
898 if (exiting(tcp)) {
899 struct rtc_wkalrm wk;
900 if (syserror(tcp) || umove(tcp, arg, &wk) < 0)
901 tprintf(", %#lx", arg);
902 else {
903 tprintf(", {enabled=%d, pending=%d, ",
904 wk.enabled, wk.pending);
905 print_rtc(tcp, &wk.time);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200906 tprints("}");
Roland McGrathd83c50b2004-10-06 22:27:43 +0000907 }
908 }
909 break;
910 default:
911 if (entering(tcp))
912 tprintf(", %#lx", arg);
913 break;
914 }
915 return 1;
916}
Roland McGrathe4662342007-08-02 01:25:34 +0000917
918#ifndef TFD_TIMER_ABSTIME
919#define TFD_TIMER_ABSTIME (1 << 0)
920#endif
921
922static const struct xlat timerfdflags[] = {
923 { TFD_TIMER_ABSTIME, "TFD_TIMER_ABSTIME" },
924 { 0, NULL }
925};
926
927int
Denys Vlasenko12014262011-05-30 14:00:14 +0200928sys_timerfd(struct tcb *tcp)
Roland McGrathe4662342007-08-02 01:25:34 +0000929{
930 if (entering(tcp)) {
931 /* It does not matter that the kernel uses itimerspec. */
932 tprintf("%ld, ", tcp->u_arg[0]);
933 printxval(clocknames, tcp->u_arg[1], "CLOCK_???");
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200934 tprints(", ");
Roland McGrathe4662342007-08-02 01:25:34 +0000935 printflags(timerfdflags, tcp->u_arg[2], "TFD_???");
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200936 tprints(", ");
Roland McGrathe4662342007-08-02 01:25:34 +0000937 printitv(tcp, tcp->u_arg[3]);
938 }
939 return 0;
940}
Roland McGrathde328e62008-05-20 04:56:13 +0000941
942int
943sys_timerfd_create(struct tcb *tcp)
944{
945 if (entering(tcp)) {
946 printxval(clocknames, tcp->u_arg[0], "CLOCK_???");
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200947 tprints(", ");
Roland McGrathde328e62008-05-20 04:56:13 +0000948 printflags(timerfdflags, tcp->u_arg[1], "TFD_???");
949 }
950 return 0;
951}
952
953int
954sys_timerfd_settime(struct tcb *tcp)
955{
956 if (entering(tcp)) {
Dmitry V. Levin31382132011-03-04 05:08:02 +0300957 printfd(tcp, tcp->u_arg[0]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200958 tprints(", ");
Roland McGrathde328e62008-05-20 04:56:13 +0000959 printflags(timerfdflags, tcp->u_arg[1], "TFD_???");
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200960 tprints(", ");
Roland McGrathde328e62008-05-20 04:56:13 +0000961 printitv(tcp, tcp->u_arg[2]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200962 tprints(", ");
Roland McGrathde328e62008-05-20 04:56:13 +0000963 printitv(tcp, tcp->u_arg[3]);
964 }
965 return 0;
966}
967
968int
969sys_timerfd_gettime(struct tcb *tcp)
970{
971 if (entering(tcp)) {
Dmitry V. Levin31382132011-03-04 05:08:02 +0300972 printfd(tcp, tcp->u_arg[0]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200973 tprints(", ");
Roland McGrathde328e62008-05-20 04:56:13 +0000974 printitv(tcp, tcp->u_arg[1]);
975 }
976 return 0;
977}
978
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000979#endif /* LINUX */