Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1 | /* |
| 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 Akkerman | d856b99 | 2000-10-13 12:47:12 +0000 | [diff] [blame] | 36 | #include <sys/timex.h> |
Roland McGrath | d83c50b | 2004-10-06 22:27:43 +0000 | [diff] [blame] | 37 | #include <linux/ioctl.h> |
| 38 | #include <linux/rtc.h> |
Roland McGrath | 6afc565 | 2007-07-24 01:57:11 +0000 | [diff] [blame] | 39 | |
| 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 Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 46 | #endif /* LINUX */ |
| 47 | |
Dmitry V. Levin | a7945a3 | 2006-12-13 17:10:11 +0000 | [diff] [blame] | 48 | struct timeval32 |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 49 | { |
Dmitry V. Levin | a7945a3 | 2006-12-13 17:10:11 +0000 | [diff] [blame] | 50 | u_int32_t tv_sec, tv_usec; |
| 51 | }; |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 52 | |
Dmitry V. Levin | 1cad25d | 2006-12-13 17:14:36 +0000 | [diff] [blame] | 53 | static void |
| 54 | tprint_timeval32(struct tcb *tcp, const struct timeval32 *tv) |
| 55 | { |
| 56 | tprintf("{%u, %u}", tv->tv_sec, tv->tv_usec); |
| 57 | } |
| 58 | |
| 59 | static void |
| 60 | tprint_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. Levin | a7945a3 | 2006-12-13 17:10:11 +0000 | [diff] [blame] | 66 | void |
Roland McGrath | 6afc565 | 2007-07-24 01:57:11 +0000 | [diff] [blame] | 67 | printtv_bitness(struct tcb *tcp, long addr, enum bitness_t bitness, int special) |
Dmitry V. Levin | a7945a3 | 2006-12-13 17:10:11 +0000 | [diff] [blame] | 68 | { |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 69 | if (addr == 0) |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 70 | tprints("NULL"); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 71 | else if (!verbose(tcp)) |
| 72 | tprintf("%#lx", addr); |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 73 | else { |
| 74 | int rc; |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 75 | |
Dmitry V. Levin | a7945a3 | 2006-12-13 17:10:11 +0000 | [diff] [blame] | 76 | 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 Vlasenko | 5d64581 | 2011-08-20 12:48:18 +0200 | [diff] [blame] | 84 | rc = umove(tcp, addr, &tv); |
| 85 | if (rc >= 0) { |
Roland McGrath | 4138339 | 2007-07-24 01:58:52 +0000 | [diff] [blame] | 86 | if (special && tv.tv_sec == 0 && |
| 87 | tv.tv_usec == UTIME_NOW) |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 88 | tprints("UTIME_NOW"); |
Roland McGrath | 4138339 | 2007-07-24 01:58:52 +0000 | [diff] [blame] | 89 | else if (special && tv.tv_sec == 0 && |
| 90 | tv.tv_usec == UTIME_OMIT) |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 91 | tprints("UTIME_OMIT"); |
Roland McGrath | 6afc565 | 2007-07-24 01:57:11 +0000 | [diff] [blame] | 92 | else |
| 93 | tprint_timeval32(tcp, &tv); |
| 94 | } |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 95 | } else { |
Dmitry V. Levin | a7945a3 | 2006-12-13 17:10:11 +0000 | [diff] [blame] | 96 | struct timeval tv; |
| 97 | |
Denys Vlasenko | 5d64581 | 2011-08-20 12:48:18 +0200 | [diff] [blame] | 98 | rc = umove(tcp, addr, &tv); |
| 99 | if (rc >= 0) { |
Roland McGrath | 4138339 | 2007-07-24 01:58:52 +0000 | [diff] [blame] | 100 | if (special && tv.tv_sec == 0 && |
| 101 | tv.tv_usec == UTIME_NOW) |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 102 | tprints("UTIME_NOW"); |
Roland McGrath | 4138339 | 2007-07-24 01:58:52 +0000 | [diff] [blame] | 103 | else if (special && tv.tv_sec == 0 && |
| 104 | tv.tv_usec == UTIME_OMIT) |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 105 | tprints("UTIME_OMIT"); |
Roland McGrath | 6afc565 | 2007-07-24 01:57:11 +0000 | [diff] [blame] | 106 | else |
| 107 | tprint_timeval(tcp, &tv); |
| 108 | } |
Dmitry V. Levin | a7945a3 | 2006-12-13 17:10:11 +0000 | [diff] [blame] | 109 | } |
Dmitry V. Levin | a7945a3 | 2006-12-13 17:10:11 +0000 | [diff] [blame] | 110 | if (rc < 0) |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 111 | tprints("{...}"); |
Dmitry V. Levin | a7945a3 | 2006-12-13 17:10:11 +0000 | [diff] [blame] | 112 | } |
| 113 | } |
Wichert Akkerman | 221f54f | 1999-11-18 17:26:45 +0000 | [diff] [blame] | 114 | |
Denys Vlasenko | 2fb4db3 | 2011-08-31 12:26:03 +0200 | [diff] [blame] | 115 | char * |
Dmitry V. Levin | a7945a3 | 2006-12-13 17:10:11 +0000 | [diff] [blame] | 116 | sprinttv(struct tcb *tcp, long addr, enum bitness_t bitness, char *buf) |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 117 | { |
Denys Vlasenko | 2fb4db3 | 2011-08-31 12:26:03 +0200 | [diff] [blame] | 118 | int rc; |
| 119 | |
Dmitry V. Levin | a7945a3 | 2006-12-13 17:10:11 +0000 | [diff] [blame] | 120 | if (addr == 0) |
Denys Vlasenko | 2fb4db3 | 2011-08-31 12:26:03 +0200 | [diff] [blame] | 121 | return stpcpy(buf, "NULL"); |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 122 | |
Denys Vlasenko | 2fb4db3 | 2011-08-31 12:26:03 +0200 | [diff] [blame] | 123 | if (!verbose(tcp)) { |
| 124 | buf += sprintf(buf, "%#lx", addr); |
| 125 | return buf; |
Dmitry V. Levin | a7945a3 | 2006-12-13 17:10:11 +0000 | [diff] [blame] | 126 | } |
Denys Vlasenko | 2fb4db3 | 2011-08-31 12:26:03 +0200 | [diff] [blame] | 127 | |
| 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. Levin | a7945a3 | 2006-12-13 17:10:11 +0000 | [diff] [blame] | 153 | } |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 154 | |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 155 | void print_timespec(struct tcb *tcp, long addr) |
Roland McGrath | 6bc09da | 2007-11-01 21:50:54 +0000 | [diff] [blame] | 156 | { |
| 157 | if (addr == 0) |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 158 | tprints("NULL"); |
Roland McGrath | 6bc09da | 2007-11-01 21:50:54 +0000 | [diff] [blame] | 159 | else if (!verbose(tcp)) |
| 160 | tprintf("%#lx", addr); |
| 161 | else { |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 162 | int rc; |
Roland McGrath | 6bc09da | 2007-11-01 21:50:54 +0000 | [diff] [blame] | 163 | |
| 164 | #if defined(LINUX) && SUPPORTED_PERSONALITIES > 1 |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 165 | if (personality_wordsize[current_personality] == 4) { |
Roland McGrath | 6bc09da | 2007-11-01 21:50:54 +0000 | [diff] [blame] | 166 | struct timeval32 tv; |
| 167 | |
Denys Vlasenko | 5d64581 | 2011-08-20 12:48:18 +0200 | [diff] [blame] | 168 | rc = umove(tcp, addr, &tv); |
| 169 | if (rc >= 0) |
Roland McGrath | 6bc09da | 2007-11-01 21:50:54 +0000 | [diff] [blame] | 170 | tprintf("{%u, %u}", |
| 171 | tv.tv_sec, tv.tv_usec); |
| 172 | } else |
Roland McGrath | 6bc09da | 2007-11-01 21:50:54 +0000 | [diff] [blame] | 173 | #endif |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 174 | { |
Roland McGrath | 6bc09da | 2007-11-01 21:50:54 +0000 | [diff] [blame] | 175 | struct timespec ts; |
| 176 | |
Denys Vlasenko | 5d64581 | 2011-08-20 12:48:18 +0200 | [diff] [blame] | 177 | rc = umove(tcp, addr, &ts); |
| 178 | if (rc >= 0) |
Roland McGrath | 6bc09da | 2007-11-01 21:50:54 +0000 | [diff] [blame] | 179 | tprintf("{%lu, %lu}", |
| 180 | (unsigned long) ts.tv_sec, |
| 181 | (unsigned long) ts.tv_nsec); |
Roland McGrath | 6bc09da | 2007-11-01 21:50:54 +0000 | [diff] [blame] | 182 | } |
Roland McGrath | 6bc09da | 2007-11-01 21:50:54 +0000 | [diff] [blame] | 183 | if (rc < 0) |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 184 | tprints("{...}"); |
Roland McGrath | 6bc09da | 2007-11-01 21:50:54 +0000 | [diff] [blame] | 185 | } |
| 186 | } |
| 187 | |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 188 | void sprint_timespec(char *buf, struct tcb *tcp, long addr) |
Roland McGrath | 6bc09da | 2007-11-01 21:50:54 +0000 | [diff] [blame] | 189 | { |
| 190 | if (addr == 0) |
| 191 | strcpy(buf, "NULL"); |
| 192 | else if (!verbose(tcp)) |
| 193 | sprintf(buf, "%#lx", addr); |
| 194 | else { |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 195 | int rc; |
Roland McGrath | 6bc09da | 2007-11-01 21:50:54 +0000 | [diff] [blame] | 196 | |
| 197 | #if defined(LINUX) && SUPPORTED_PERSONALITIES > 1 |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 198 | if (personality_wordsize[current_personality] == 4) { |
Roland McGrath | 6bc09da | 2007-11-01 21:50:54 +0000 | [diff] [blame] | 199 | struct timeval32 tv; |
| 200 | |
Denys Vlasenko | 5d64581 | 2011-08-20 12:48:18 +0200 | [diff] [blame] | 201 | rc = umove(tcp, addr, &tv); |
| 202 | if (rc >= 0) |
Roland McGrath | 6bc09da | 2007-11-01 21:50:54 +0000 | [diff] [blame] | 203 | sprintf(buf, "{%u, %u}", |
| 204 | tv.tv_sec, tv.tv_usec); |
| 205 | } else |
Roland McGrath | 6bc09da | 2007-11-01 21:50:54 +0000 | [diff] [blame] | 206 | #endif |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 207 | { |
Roland McGrath | 6bc09da | 2007-11-01 21:50:54 +0000 | [diff] [blame] | 208 | struct timespec ts; |
| 209 | |
Denys Vlasenko | 5d64581 | 2011-08-20 12:48:18 +0200 | [diff] [blame] | 210 | rc = umove(tcp, addr, &ts); |
| 211 | if (rc >= 0) |
Roland McGrath | 6bc09da | 2007-11-01 21:50:54 +0000 | [diff] [blame] | 212 | sprintf(buf, "{%lu, %lu}", |
| 213 | (unsigned long) ts.tv_sec, |
| 214 | (unsigned long) ts.tv_nsec); |
Roland McGrath | 6bc09da | 2007-11-01 21:50:54 +0000 | [diff] [blame] | 215 | } |
Roland McGrath | 6bc09da | 2007-11-01 21:50:54 +0000 | [diff] [blame] | 216 | if (rc < 0) |
| 217 | strcpy(buf, "{...}"); |
| 218 | } |
| 219 | } |
| 220 | |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 221 | int |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 222 | sys_time(struct tcb *tcp) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 223 | { |
| 224 | if (exiting(tcp)) { |
| 225 | #ifndef SVR4 |
| 226 | printnum(tcp, tcp->u_arg[0], "%ld"); |
| 227 | #endif /* SVR4 */ |
| 228 | } |
| 229 | return 0; |
| 230 | } |
| 231 | |
| 232 | int |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 233 | sys_stime(struct tcb *tcp) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 234 | { |
| 235 | if (exiting(tcp)) { |
| 236 | printnum(tcp, tcp->u_arg[0], "%ld"); |
| 237 | } |
| 238 | return 0; |
| 239 | } |
| 240 | |
| 241 | int |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 242 | sys_gettimeofday(struct tcb *tcp) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 243 | { |
| 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 Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 252 | tprints(", "); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 253 | printtv(tcp, tcp->u_arg[1]); |
| 254 | #endif /* !SVR4 */ |
| 255 | } |
| 256 | return 0; |
| 257 | } |
| 258 | |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 259 | |
| 260 | #ifdef ALPHA |
| 261 | int |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 262 | sys_osf_gettimeofday(struct tcb *tcp) |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 263 | { |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 264 | 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 Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 270 | #ifndef SVR4 |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 271 | tprints(", "); |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 272 | printtv_bitness(tcp, tcp->u_arg[1], BITNESS_32, 0); |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 273 | #endif /* !SVR4 */ |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 274 | } |
| 275 | return 0; |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 276 | } |
| 277 | #endif |
| 278 | |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 279 | int |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 280 | sys_settimeofday(struct tcb *tcp) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 281 | { |
| 282 | if (entering(tcp)) { |
| 283 | printtv(tcp, tcp->u_arg[0]); |
| 284 | #ifndef SVR4 |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 285 | tprints(", "); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 286 | printtv(tcp, tcp->u_arg[1]); |
| 287 | #endif /* !SVR4 */ |
| 288 | } |
| 289 | return 0; |
| 290 | } |
| 291 | |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 292 | #ifdef ALPHA |
| 293 | int |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 294 | sys_osf_settimeofday(struct tcb *tcp) |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 295 | { |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 296 | if (entering(tcp)) { |
| 297 | printtv_bitness(tcp, tcp->u_arg[0], BITNESS_32, 0); |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 298 | #ifndef SVR4 |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 299 | tprints(", "); |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 300 | printtv_bitness(tcp, tcp->u_arg[1], BITNESS_32, 0); |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 301 | #endif /* !SVR4 */ |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 302 | } |
| 303 | return 0; |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 304 | } |
| 305 | #endif |
| 306 | |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 307 | int |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 308 | sys_adjtime(struct tcb *tcp) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 309 | { |
| 310 | if (entering(tcp)) { |
| 311 | printtv(tcp, tcp->u_arg[0]); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 312 | tprints(", "); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 313 | } 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. Levin | 2e55ff4 | 2008-09-03 01:02:46 +0000 | [diff] [blame] | 322 | int |
| 323 | sys_nanosleep(struct tcb *tcp) |
| 324 | { |
| 325 | if (entering(tcp)) { |
| 326 | print_timespec(tcp, tcp->u_arg[0]); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 327 | tprints(", "); |
Dmitry V. Levin | 2e55ff4 | 2008-09-03 01:02:46 +0000 | [diff] [blame] | 328 | } 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 McGrath | d9f816f | 2004-09-04 03:39:20 +0000 | [diff] [blame] | 337 | static const struct xlat which[] = { |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 338 | { ITIMER_REAL, "ITIMER_REAL" }, |
| 339 | { ITIMER_VIRTUAL,"ITIMER_VIRTUAL"}, |
| 340 | { ITIMER_PROF, "ITIMER_PROF" }, |
| 341 | { 0, NULL }, |
| 342 | }; |
| 343 | |
| 344 | static void |
Dmitry V. Levin | 1cad25d | 2006-12-13 17:14:36 +0000 | [diff] [blame] | 345 | printitv_bitness(struct tcb *tcp, long addr, enum bitness_t bitness) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 346 | { |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 347 | if (addr == 0) |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 348 | tprints("NULL"); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 349 | else if (!verbose(tcp)) |
| 350 | tprintf("%#lx", addr); |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 351 | else { |
| 352 | int rc; |
Dmitry V. Levin | 1cad25d | 2006-12-13 17:14:36 +0000 | [diff] [blame] | 353 | |
| 354 | if (bitness == BITNESS_32 |
| 355 | #if defined(LINUX) && SUPPORTED_PERSONALITIES > 1 |
| 356 | || personality_wordsize[current_personality] == 4 |
| 357 | #endif |
| 358 | ) |
| 359 | { |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 360 | struct { |
Dmitry V. Levin | 1cad25d | 2006-12-13 17:14:36 +0000 | [diff] [blame] | 361 | struct timeval32 it_interval, it_value; |
| 362 | } itv; |
| 363 | |
Denys Vlasenko | 5d64581 | 2011-08-20 12:48:18 +0200 | [diff] [blame] | 364 | rc = umove(tcp, addr, &itv); |
| 365 | if (rc >= 0) { |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 366 | tprints("{it_interval="); |
Dmitry V. Levin | 1cad25d | 2006-12-13 17:14:36 +0000 | [diff] [blame] | 367 | tprint_timeval32(tcp, &itv.it_interval); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 368 | tprints(", it_value="); |
Dmitry V. Levin | 1cad25d | 2006-12-13 17:14:36 +0000 | [diff] [blame] | 369 | tprint_timeval32(tcp, &itv.it_value); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 370 | tprints("}"); |
Roland McGrath | e466234 | 2007-08-02 01:25:34 +0000 | [diff] [blame] | 371 | } |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 372 | } else { |
Dmitry V. Levin | 1cad25d | 2006-12-13 17:14:36 +0000 | [diff] [blame] | 373 | struct itimerval itv; |
| 374 | |
Denys Vlasenko | 5d64581 | 2011-08-20 12:48:18 +0200 | [diff] [blame] | 375 | rc = umove(tcp, addr, &itv); |
| 376 | if (rc >= 0) { |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 377 | tprints("{it_interval="); |
Dmitry V. Levin | 1cad25d | 2006-12-13 17:14:36 +0000 | [diff] [blame] | 378 | tprint_timeval(tcp, &itv.it_interval); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 379 | tprints(", it_value="); |
Dmitry V. Levin | 1cad25d | 2006-12-13 17:14:36 +0000 | [diff] [blame] | 380 | tprint_timeval(tcp, &itv.it_value); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 381 | tprints("}"); |
Roland McGrath | e466234 | 2007-08-02 01:25:34 +0000 | [diff] [blame] | 382 | } |
Dmitry V. Levin | 1cad25d | 2006-12-13 17:14:36 +0000 | [diff] [blame] | 383 | } |
Dmitry V. Levin | 1cad25d | 2006-12-13 17:14:36 +0000 | [diff] [blame] | 384 | if (rc < 0) |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 385 | tprints("{...}"); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 386 | } |
| 387 | } |
| 388 | |
Dmitry V. Levin | 1cad25d | 2006-12-13 17:14:36 +0000 | [diff] [blame] | 389 | #define printitv(tcp, addr) \ |
| 390 | printitv_bitness((tcp), (addr), BITNESS_CURRENT) |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 391 | |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 392 | int |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 393 | sys_getitimer(struct tcb *tcp) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 394 | { |
| 395 | if (entering(tcp)) { |
| 396 | printxval(which, tcp->u_arg[0], "ITIMER_???"); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 397 | tprints(", "); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 398 | } 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 Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 407 | |
| 408 | #ifdef ALPHA |
| 409 | int |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 410 | sys_osf_getitimer(struct tcb *tcp) |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 411 | { |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 412 | if (entering(tcp)) { |
| 413 | printxval(which, tcp->u_arg[0], "ITIMER_???"); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 414 | tprints(", "); |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 415 | } 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 Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 422 | } |
| 423 | #endif |
| 424 | |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 425 | int |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 426 | sys_setitimer(struct tcb *tcp) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 427 | { |
| 428 | if (entering(tcp)) { |
| 429 | printxval(which, tcp->u_arg[0], "ITIMER_???"); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 430 | tprints(", "); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 431 | printitv(tcp, tcp->u_arg[1]); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 432 | tprints(", "); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 433 | } 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 Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 442 | #ifdef ALPHA |
| 443 | int |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 444 | sys_osf_setitimer(struct tcb *tcp) |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 445 | { |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 446 | if (entering(tcp)) { |
| 447 | printxval(which, tcp->u_arg[0], "ITIMER_???"); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 448 | tprints(", "); |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 449 | printitv_bitness(tcp, tcp->u_arg[1], BITNESS_32); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 450 | tprints(", "); |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 451 | } 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 Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 458 | } |
| 459 | #endif |
| 460 | |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 461 | #ifdef LINUX |
| 462 | |
Dmitry V. Levin | 1a684d6 | 2006-12-13 17:42:32 +0000 | [diff] [blame] | 463 | static 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 | |
| 492 | static 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 | |
| 535 | static 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. Levin | 165b15d | 2006-12-13 17:43:45 +0000 | [diff] [blame] | 557 | #if SUPPORTED_PERSONALITIES > 1 |
| 558 | static int |
| 559 | tprint_timex32(struct tcb *tcp, long addr) |
| 560 | { |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 561 | struct { |
Dmitry V. Levin | 165b15d | 2006-12-13 17:43:45 +0000 | [diff] [blame] | 562 | 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 Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 586 | tprints("{modes="); |
Dmitry V. Levin | 71d7089 | 2007-01-13 11:17:38 +0000 | [diff] [blame] | 587 | printflags(adjtimex_modes, tx.modes, "ADJ_???"); |
Dmitry V. Levin | 165b15d | 2006-12-13 17:43:45 +0000 | [diff] [blame] | 588 | 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 Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 602 | tprints("}"); |
Dmitry V. Levin | 165b15d | 2006-12-13 17:43:45 +0000 | [diff] [blame] | 603 | return 0; |
| 604 | } |
| 605 | #endif /* SUPPORTED_PERSONALITIES > 1 */ |
| 606 | |
| 607 | static int |
| 608 | tprint_timex(struct tcb *tcp, long addr) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 609 | { |
Dmitry V. Levin | 1a684d6 | 2006-12-13 17:42:32 +0000 | [diff] [blame] | 610 | struct timex tx; |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 611 | |
Dmitry V. Levin | 165b15d | 2006-12-13 17:43:45 +0000 | [diff] [blame] | 612 | #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 Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 629 | tprints("{modes="); |
Dmitry V. Levin | 71d7089 | 2007-01-13 11:17:38 +0000 | [diff] [blame] | 630 | printflags(adjtimex_modes, tx.modes, "ADJ_???"); |
Dmitry V. Levin | 165b15d | 2006-12-13 17:43:45 +0000 | [diff] [blame] | 631 | 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 Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 646 | tprints("}"); |
Dmitry V. Levin | 165b15d | 2006-12-13 17:43:45 +0000 | [diff] [blame] | 647 | return 0; |
| 648 | } |
| 649 | |
| 650 | int |
| 651 | sys_adjtimex(struct tcb *tcp) |
| 652 | { |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 653 | if (exiting(tcp)) { |
| 654 | if (tcp->u_arg[0] == 0) |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 655 | tprints("NULL"); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 656 | else if (syserror(tcp) || !verbose(tcp)) |
| 657 | tprintf("%#lx", tcp->u_arg[0]); |
Dmitry V. Levin | 165b15d | 2006-12-13 17:43:45 +0000 | [diff] [blame] | 658 | else if (tprint_timex(tcp, tcp->u_arg[0]) < 0) |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 659 | tprints("{...}"); |
Dmitry V. Levin | 21a7534 | 2008-09-03 01:22:18 +0000 | [diff] [blame] | 660 | if (syserror(tcp)) |
| 661 | return 0; |
Dmitry V. Levin | 1a684d6 | 2006-12-13 17:42:32 +0000 | [diff] [blame] | 662 | tcp->auxstr = xlookup(adjtimex_state, tcp->u_rval); |
| 663 | if (tcp->auxstr) |
| 664 | return RVAL_STR; |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 665 | } |
| 666 | return 0; |
| 667 | } |
Roland McGrath | 1e35679 | 2003-03-30 23:52:28 +0000 | [diff] [blame] | 668 | |
Roland McGrath | d9f816f | 2004-09-04 03:39:20 +0000 | [diff] [blame] | 669 | static const struct xlat clockflags[] = { |
Roland McGrath | 1e35679 | 2003-03-30 23:52:28 +0000 | [diff] [blame] | 670 | { TIMER_ABSTIME, "TIMER_ABSTIME" }, |
| 671 | { 0, NULL } |
| 672 | }; |
| 673 | |
Roland McGrath | d9f816f | 2004-09-04 03:39:20 +0000 | [diff] [blame] | 674 | static const struct xlat clocknames[] = { |
Roland McGrath | 55a00f8 | 2004-08-31 08:26:39 +0000 | [diff] [blame] | 675 | #ifdef CLOCK_REALTIME |
Roland McGrath | 54a4edd | 2004-08-31 06:52:45 +0000 | [diff] [blame] | 676 | { CLOCK_REALTIME, "CLOCK_REALTIME" }, |
Roland McGrath | 55a00f8 | 2004-08-31 08:26:39 +0000 | [diff] [blame] | 677 | #endif |
| 678 | #ifdef CLOCK_MONOTONIC |
Roland McGrath | 54a4edd | 2004-08-31 06:52:45 +0000 | [diff] [blame] | 679 | { CLOCK_MONOTONIC, "CLOCK_MONOTONIC" }, |
Roland McGrath | 55a00f8 | 2004-08-31 08:26:39 +0000 | [diff] [blame] | 680 | #endif |
Dmitry V. Levin | cbaaf79 | 2010-09-17 09:19:49 +0000 | [diff] [blame] | 681 | #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 McGrath | 54a4edd | 2004-08-31 06:52:45 +0000 | [diff] [blame] | 697 | }; |
| 698 | |
Roland McGrath | 1e35679 | 2003-03-30 23:52:28 +0000 | [diff] [blame] | 699 | int |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 700 | sys_clock_settime(struct tcb *tcp) |
Roland McGrath | 1e35679 | 2003-03-30 23:52:28 +0000 | [diff] [blame] | 701 | { |
| 702 | if (entering(tcp)) { |
Roland McGrath | 54a4edd | 2004-08-31 06:52:45 +0000 | [diff] [blame] | 703 | printxval(clocknames, tcp->u_arg[0], "CLOCK_???"); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 704 | tprints(", "); |
Roland McGrath | 1e35679 | 2003-03-30 23:52:28 +0000 | [diff] [blame] | 705 | printtv(tcp, tcp->u_arg[1]); |
| 706 | } |
| 707 | return 0; |
| 708 | } |
| 709 | |
| 710 | int |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 711 | sys_clock_gettime(struct tcb *tcp) |
Roland McGrath | 1e35679 | 2003-03-30 23:52:28 +0000 | [diff] [blame] | 712 | { |
| 713 | if (entering(tcp)) { |
Roland McGrath | 54a4edd | 2004-08-31 06:52:45 +0000 | [diff] [blame] | 714 | printxval(clocknames, tcp->u_arg[0], "CLOCK_???"); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 715 | tprints(", "); |
Roland McGrath | 1e35679 | 2003-03-30 23:52:28 +0000 | [diff] [blame] | 716 | } 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 | |
| 725 | int |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 726 | sys_clock_nanosleep(struct tcb *tcp) |
Roland McGrath | 1e35679 | 2003-03-30 23:52:28 +0000 | [diff] [blame] | 727 | { |
| 728 | if (entering(tcp)) { |
Roland McGrath | 54a4edd | 2004-08-31 06:52:45 +0000 | [diff] [blame] | 729 | printxval(clocknames, tcp->u_arg[0], "CLOCK_???"); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 730 | tprints(", "); |
Roland McGrath | b2dee13 | 2005-06-01 19:02:36 +0000 | [diff] [blame] | 731 | printflags(clockflags, tcp->u_arg[1], "TIMER_???"); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 732 | tprints(", "); |
Roland McGrath | 1e35679 | 2003-03-30 23:52:28 +0000 | [diff] [blame] | 733 | printtv(tcp, tcp->u_arg[2]); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 734 | tprints(", "); |
Roland McGrath | 1e35679 | 2003-03-30 23:52:28 +0000 | [diff] [blame] | 735 | } 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 McGrath | d9f816f | 2004-09-04 03:39:20 +0000 | [diff] [blame] | 747 | static const struct xlat sigev_value[] = { |
Roland McGrath | 1e35679 | 2003-03-30 23:52:28 +0000 | [diff] [blame] | 748 | { 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. Levin | d3cb392 | 2006-12-13 17:45:02 +0000 | [diff] [blame] | 755 | #if SUPPORTED_PERSONALITIES > 1 |
| 756 | static void |
| 757 | printsigevent32(struct tcb *tcp, long arg) |
| 758 | { |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 759 | struct { |
Dmitry V. Levin | d3cb392 | 2006-12-13 17:45:02 +0000 | [diff] [blame] | 760 | int sigev_value; |
| 761 | int sigev_signo; |
| 762 | int sigev_notify; |
| 763 | |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 764 | union { |
Dmitry V. Levin | d3cb392 | 2006-12-13 17:45:02 +0000 | [diff] [blame] | 765 | int tid; |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 766 | struct { |
Dmitry V. Levin | d3cb392 | 2006-12-13 17:45:02 +0000 | [diff] [blame] | 767 | int function, attribute; |
| 768 | } thread; |
| 769 | } un; |
| 770 | } sev; |
| 771 | |
| 772 | if (umove(tcp, arg, &sev) < 0) |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 773 | tprints("{...}"); |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 774 | else { |
Dmitry V. Levin | d3cb392 | 2006-12-13 17:45:02 +0000 | [diff] [blame] | 775 | 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 Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 781 | tprints(", "); |
Dmitry V. Levin | d3cb392 | 2006-12-13 17:45:02 +0000 | [diff] [blame] | 782 | 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 Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 789 | tprints("{...}"); |
| 790 | tprints("}"); |
Dmitry V. Levin | d3cb392 | 2006-12-13 17:45:02 +0000 | [diff] [blame] | 791 | } |
| 792 | } |
| 793 | #endif |
| 794 | |
Roland McGrath | 1e35679 | 2003-03-30 23:52:28 +0000 | [diff] [blame] | 795 | void |
Dmitry V. Levin | d3cb392 | 2006-12-13 17:45:02 +0000 | [diff] [blame] | 796 | printsigevent(struct tcb *tcp, long arg) |
Roland McGrath | 1e35679 | 2003-03-30 23:52:28 +0000 | [diff] [blame] | 797 | { |
| 798 | struct sigevent sev; |
Dmitry V. Levin | d3cb392 | 2006-12-13 17:45:02 +0000 | [diff] [blame] | 799 | |
| 800 | #if SUPPORTED_PERSONALITIES > 1 |
Denys Vlasenko | 7b609d5 | 2011-06-22 14:32:43 +0200 | [diff] [blame] | 801 | if (personality_wordsize[current_personality] == 4) { |
Dmitry V. Levin | d3cb392 | 2006-12-13 17:45:02 +0000 | [diff] [blame] | 802 | printsigevent32(tcp, arg); |
| 803 | return; |
| 804 | } |
| 805 | #endif |
Denys Vlasenko | b63256e | 2011-06-07 12:13:24 +0200 | [diff] [blame] | 806 | if (umove(tcp, arg, &sev) < 0) |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 807 | tprints("{...}"); |
Roland McGrath | 1e35679 | 2003-03-30 23:52:28 +0000 | [diff] [blame] | 808 | else { |
Roland McGrath | 675d4a6 | 2004-09-11 08:12:45 +0000 | [diff] [blame] | 809 | 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 McGrath | 1e35679 | 2003-03-30 23:52:28 +0000 | [diff] [blame] | 814 | printxval(sigev_value, sev.sigev_notify+1, "SIGEV_???"); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 815 | tprints(", "); |
Roland McGrath | 1e35679 | 2003-03-30 23:52:28 +0000 | [diff] [blame] | 816 | 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 McGrath | d4c85eb | 2004-04-16 21:48:44 +0000 | [diff] [blame] | 821 | else if (sev.sigev_notify == SIGEV_THREAD) |
| 822 | tprintf("{%p, %p}", sev.sigev_notify_function, |
| 823 | sev.sigev_notify_attributes); |
Roland McGrath | 1e35679 | 2003-03-30 23:52:28 +0000 | [diff] [blame] | 824 | else |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 825 | tprints("{...}"); |
| 826 | tprints("}"); |
Roland McGrath | 1e35679 | 2003-03-30 23:52:28 +0000 | [diff] [blame] | 827 | } |
| 828 | } |
| 829 | |
| 830 | int |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 831 | sys_timer_create(struct tcb *tcp) |
Roland McGrath | 1e35679 | 2003-03-30 23:52:28 +0000 | [diff] [blame] | 832 | { |
| 833 | if (entering(tcp)) { |
Roland McGrath | 675d4a6 | 2004-09-11 08:12:45 +0000 | [diff] [blame] | 834 | printxval(clocknames, tcp->u_arg[0], "CLOCK_???"); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 835 | tprints(", "); |
Roland McGrath | 1e35679 | 2003-03-30 23:52:28 +0000 | [diff] [blame] | 836 | printsigevent(tcp, tcp->u_arg[1]); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 837 | tprints(", "); |
Roland McGrath | 1e35679 | 2003-03-30 23:52:28 +0000 | [diff] [blame] | 838 | } else { |
Andi Kleen | 732f396 | 2011-06-13 21:37:40 +0000 | [diff] [blame] | 839 | int timer_id; |
Dmitry V. Levin | ac518d1 | 2006-12-13 17:03:02 +0000 | [diff] [blame] | 840 | |
Andi Kleen | 732f396 | 2011-06-13 21:37:40 +0000 | [diff] [blame] | 841 | if (syserror(tcp) || umove(tcp, tcp->u_arg[2], &timer_id) < 0) |
Roland McGrath | 1e35679 | 2003-03-30 23:52:28 +0000 | [diff] [blame] | 842 | tprintf("%#lx", tcp->u_arg[2]); |
Dmitry V. Levin | ac518d1 | 2006-12-13 17:03:02 +0000 | [diff] [blame] | 843 | else |
Andi Kleen | 732f396 | 2011-06-13 21:37:40 +0000 | [diff] [blame] | 844 | tprintf("{%d}", timer_id); |
Roland McGrath | 1e35679 | 2003-03-30 23:52:28 +0000 | [diff] [blame] | 845 | } |
| 846 | return 0; |
| 847 | } |
| 848 | |
| 849 | int |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 850 | sys_timer_settime(struct tcb *tcp) |
Roland McGrath | 1e35679 | 2003-03-30 23:52:28 +0000 | [diff] [blame] | 851 | { |
| 852 | if (entering(tcp)) { |
| 853 | tprintf("%#lx, ", tcp->u_arg[0]); |
Roland McGrath | b2dee13 | 2005-06-01 19:02:36 +0000 | [diff] [blame] | 854 | printflags(clockflags, tcp->u_arg[1], "TIMER_???"); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 855 | tprints(", "); |
Roland McGrath | 1e35679 | 2003-03-30 23:52:28 +0000 | [diff] [blame] | 856 | printitv(tcp, tcp->u_arg[2]); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 857 | tprints(", "); |
Roland McGrath | 1e35679 | 2003-03-30 23:52:28 +0000 | [diff] [blame] | 858 | } 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 | |
| 867 | int |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 868 | sys_timer_gettime(struct tcb *tcp) |
Roland McGrath | 1e35679 | 2003-03-30 23:52:28 +0000 | [diff] [blame] | 869 | { |
| 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 McGrath | d83c50b | 2004-10-06 22:27:43 +0000 | [diff] [blame] | 880 | |
| 881 | static void |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 882 | print_rtc(struct tcb *tcp, const struct rtc_time *rt) |
Roland McGrath | d83c50b | 2004-10-06 22:27:43 +0000 | [diff] [blame] | 883 | { |
| 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 Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 892 | tprints("...}"); |
Roland McGrath | d83c50b | 2004-10-06 22:27:43 +0000 | [diff] [blame] | 893 | } |
| 894 | |
| 895 | int |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 896 | rtc_ioctl(struct tcb *tcp, long code, long arg) |
Roland McGrath | d83c50b | 2004-10-06 22:27:43 +0000 | [diff] [blame] | 897 | { |
| 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 Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 906 | tprints(", "); |
Roland McGrath | d83c50b | 2004-10-06 22:27:43 +0000 | [diff] [blame] | 907 | 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 Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 918 | tprints(", "); |
Roland McGrath | d83c50b | 2004-10-06 22:27:43 +0000 | [diff] [blame] | 919 | 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 Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 942 | tprints("}"); |
Roland McGrath | d83c50b | 2004-10-06 22:27:43 +0000 | [diff] [blame] | 943 | } |
| 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 Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 955 | tprints("}"); |
Roland McGrath | d83c50b | 2004-10-06 22:27:43 +0000 | [diff] [blame] | 956 | } |
| 957 | } |
| 958 | break; |
| 959 | default: |
| 960 | if (entering(tcp)) |
| 961 | tprintf(", %#lx", arg); |
| 962 | break; |
| 963 | } |
| 964 | return 1; |
| 965 | } |
Roland McGrath | e466234 | 2007-08-02 01:25:34 +0000 | [diff] [blame] | 966 | |
| 967 | #ifndef TFD_TIMER_ABSTIME |
| 968 | #define TFD_TIMER_ABSTIME (1 << 0) |
| 969 | #endif |
| 970 | |
| 971 | static const struct xlat timerfdflags[] = { |
| 972 | { TFD_TIMER_ABSTIME, "TFD_TIMER_ABSTIME" }, |
| 973 | { 0, NULL } |
| 974 | }; |
| 975 | |
| 976 | int |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 977 | sys_timerfd(struct tcb *tcp) |
Roland McGrath | e466234 | 2007-08-02 01:25:34 +0000 | [diff] [blame] | 978 | { |
| 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 Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 983 | tprints(", "); |
Roland McGrath | e466234 | 2007-08-02 01:25:34 +0000 | [diff] [blame] | 984 | printflags(timerfdflags, tcp->u_arg[2], "TFD_???"); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 985 | tprints(", "); |
Roland McGrath | e466234 | 2007-08-02 01:25:34 +0000 | [diff] [blame] | 986 | printitv(tcp, tcp->u_arg[3]); |
| 987 | } |
| 988 | return 0; |
| 989 | } |
Roland McGrath | de328e6 | 2008-05-20 04:56:13 +0000 | [diff] [blame] | 990 | |
| 991 | int |
| 992 | sys_timerfd_create(struct tcb *tcp) |
| 993 | { |
| 994 | if (entering(tcp)) { |
| 995 | printxval(clocknames, tcp->u_arg[0], "CLOCK_???"); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 996 | tprints(", "); |
Roland McGrath | de328e6 | 2008-05-20 04:56:13 +0000 | [diff] [blame] | 997 | printflags(timerfdflags, tcp->u_arg[1], "TFD_???"); |
| 998 | } |
| 999 | return 0; |
| 1000 | } |
| 1001 | |
| 1002 | int |
| 1003 | sys_timerfd_settime(struct tcb *tcp) |
| 1004 | { |
| 1005 | if (entering(tcp)) { |
Dmitry V. Levin | 3138213 | 2011-03-04 05:08:02 +0300 | [diff] [blame] | 1006 | printfd(tcp, tcp->u_arg[0]); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 1007 | tprints(", "); |
Roland McGrath | de328e6 | 2008-05-20 04:56:13 +0000 | [diff] [blame] | 1008 | printflags(timerfdflags, tcp->u_arg[1], "TFD_???"); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 1009 | tprints(", "); |
Roland McGrath | de328e6 | 2008-05-20 04:56:13 +0000 | [diff] [blame] | 1010 | printitv(tcp, tcp->u_arg[2]); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 1011 | tprints(", "); |
Roland McGrath | de328e6 | 2008-05-20 04:56:13 +0000 | [diff] [blame] | 1012 | printitv(tcp, tcp->u_arg[3]); |
| 1013 | } |
| 1014 | return 0; |
| 1015 | } |
| 1016 | |
| 1017 | int |
| 1018 | sys_timerfd_gettime(struct tcb *tcp) |
| 1019 | { |
| 1020 | if (entering(tcp)) { |
Dmitry V. Levin | 3138213 | 2011-03-04 05:08:02 +0300 | [diff] [blame] | 1021 | printfd(tcp, tcp->u_arg[0]); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 1022 | tprints(", "); |
Roland McGrath | de328e6 | 2008-05-20 04:56:13 +0000 | [diff] [blame] | 1023 | printitv(tcp, tcp->u_arg[1]); |
| 1024 | } |
| 1025 | return 0; |
| 1026 | } |
| 1027 | |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1028 | #endif /* LINUX */ |