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) |
| 70 | tprintf("NULL"); |
| 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 | |
Roland McGrath | 6afc565 | 2007-07-24 01:57:11 +0000 | [diff] [blame] | 84 | if ((rc = umove(tcp, addr, &tv)) >= 0) { |
Roland McGrath | 4138339 | 2007-07-24 01:58:52 +0000 | [diff] [blame] | 85 | if (special && tv.tv_sec == 0 && |
| 86 | tv.tv_usec == UTIME_NOW) |
Roland McGrath | 6afc565 | 2007-07-24 01:57:11 +0000 | [diff] [blame] | 87 | tprintf("UTIME_NOW"); |
Roland McGrath | 4138339 | 2007-07-24 01:58:52 +0000 | [diff] [blame] | 88 | else if (special && tv.tv_sec == 0 && |
| 89 | tv.tv_usec == UTIME_OMIT) |
Roland McGrath | 6afc565 | 2007-07-24 01:57:11 +0000 | [diff] [blame] | 90 | tprintf("UTIME_OMIT"); |
| 91 | else |
| 92 | tprint_timeval32(tcp, &tv); |
| 93 | } |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 94 | } else { |
Dmitry V. Levin | a7945a3 | 2006-12-13 17:10:11 +0000 | [diff] [blame] | 95 | struct timeval tv; |
| 96 | |
Roland McGrath | 6afc565 | 2007-07-24 01:57:11 +0000 | [diff] [blame] | 97 | if ((rc = umove(tcp, addr, &tv)) >= 0) { |
Roland McGrath | 4138339 | 2007-07-24 01:58:52 +0000 | [diff] [blame] | 98 | if (special && tv.tv_sec == 0 && |
| 99 | tv.tv_usec == UTIME_NOW) |
Roland McGrath | 6afc565 | 2007-07-24 01:57:11 +0000 | [diff] [blame] | 100 | tprintf("UTIME_NOW"); |
Roland McGrath | 4138339 | 2007-07-24 01:58:52 +0000 | [diff] [blame] | 101 | else if (special && tv.tv_sec == 0 && |
| 102 | tv.tv_usec == UTIME_OMIT) |
Roland McGrath | 6afc565 | 2007-07-24 01:57:11 +0000 | [diff] [blame] | 103 | tprintf("UTIME_OMIT"); |
| 104 | else |
| 105 | tprint_timeval(tcp, &tv); |
| 106 | } |
Dmitry V. Levin | a7945a3 | 2006-12-13 17:10:11 +0000 | [diff] [blame] | 107 | } |
Dmitry V. Levin | a7945a3 | 2006-12-13 17:10:11 +0000 | [diff] [blame] | 108 | if (rc < 0) |
| 109 | tprintf("{...}"); |
| 110 | } |
| 111 | } |
Wichert Akkerman | 221f54f | 1999-11-18 17:26:45 +0000 | [diff] [blame] | 112 | |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 113 | void |
Dmitry V. Levin | a7945a3 | 2006-12-13 17:10:11 +0000 | [diff] [blame] | 114 | sprinttv(struct tcb *tcp, long addr, enum bitness_t bitness, char *buf) |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 115 | { |
Dmitry V. Levin | a7945a3 | 2006-12-13 17:10:11 +0000 | [diff] [blame] | 116 | if (addr == 0) |
| 117 | strcpy(buf, "NULL"); |
| 118 | else if (!verbose(tcp)) |
| 119 | sprintf(buf, "%#lx", addr); |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 120 | else { |
| 121 | int rc; |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 122 | |
Dmitry V. Levin | a7945a3 | 2006-12-13 17:10:11 +0000 | [diff] [blame] | 123 | if (bitness == BITNESS_32 |
| 124 | #if defined(LINUX) && SUPPORTED_PERSONALITIES > 1 |
| 125 | || personality_wordsize[current_personality] == 4 |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 126 | #endif |
Dmitry V. Levin | a7945a3 | 2006-12-13 17:10:11 +0000 | [diff] [blame] | 127 | ) |
| 128 | { |
| 129 | struct timeval32 tv; |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 130 | |
Dmitry V. Levin | a7945a3 | 2006-12-13 17:10:11 +0000 | [diff] [blame] | 131 | if ((rc = umove(tcp, addr, &tv)) >= 0) |
| 132 | sprintf(buf, "{%u, %u}", |
| 133 | tv.tv_sec, tv.tv_usec); |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 134 | } else { |
Dmitry V. Levin | a7945a3 | 2006-12-13 17:10:11 +0000 | [diff] [blame] | 135 | struct timeval tv; |
| 136 | |
| 137 | if ((rc = umove(tcp, addr, &tv)) >= 0) |
| 138 | sprintf(buf, "{%lu, %lu}", |
| 139 | (unsigned long) tv.tv_sec, |
| 140 | (unsigned long) tv.tv_usec); |
| 141 | } |
Dmitry V. Levin | a7945a3 | 2006-12-13 17:10:11 +0000 | [diff] [blame] | 142 | if (rc < 0) |
| 143 | strcpy(buf, "{...}"); |
| 144 | } |
| 145 | } |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 146 | |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 147 | void print_timespec(struct tcb *tcp, long addr) |
Roland McGrath | 6bc09da | 2007-11-01 21:50:54 +0000 | [diff] [blame] | 148 | { |
| 149 | if (addr == 0) |
| 150 | tprintf("NULL"); |
| 151 | else if (!verbose(tcp)) |
| 152 | tprintf("%#lx", addr); |
| 153 | else { |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 154 | int rc; |
Roland McGrath | 6bc09da | 2007-11-01 21:50:54 +0000 | [diff] [blame] | 155 | |
| 156 | #if defined(LINUX) && SUPPORTED_PERSONALITIES > 1 |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 157 | if (personality_wordsize[current_personality] == 4) { |
Roland McGrath | 6bc09da | 2007-11-01 21:50:54 +0000 | [diff] [blame] | 158 | struct timeval32 tv; |
| 159 | |
| 160 | if ((rc = umove(tcp, addr, &tv)) >= 0) |
| 161 | tprintf("{%u, %u}", |
| 162 | tv.tv_sec, tv.tv_usec); |
| 163 | } else |
Roland McGrath | 6bc09da | 2007-11-01 21:50:54 +0000 | [diff] [blame] | 164 | #endif |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 165 | { |
Roland McGrath | 6bc09da | 2007-11-01 21:50:54 +0000 | [diff] [blame] | 166 | struct timespec ts; |
| 167 | |
| 168 | if ((rc = umove(tcp, addr, &ts)) >= 0) |
| 169 | tprintf("{%lu, %lu}", |
| 170 | (unsigned long) ts.tv_sec, |
| 171 | (unsigned long) ts.tv_nsec); |
Roland McGrath | 6bc09da | 2007-11-01 21:50:54 +0000 | [diff] [blame] | 172 | } |
Roland McGrath | 6bc09da | 2007-11-01 21:50:54 +0000 | [diff] [blame] | 173 | if (rc < 0) |
| 174 | tprintf("{...}"); |
| 175 | } |
| 176 | } |
| 177 | |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 178 | void sprint_timespec(char *buf, struct tcb *tcp, long addr) |
Roland McGrath | 6bc09da | 2007-11-01 21:50:54 +0000 | [diff] [blame] | 179 | { |
| 180 | if (addr == 0) |
| 181 | strcpy(buf, "NULL"); |
| 182 | else if (!verbose(tcp)) |
| 183 | sprintf(buf, "%#lx", addr); |
| 184 | else { |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 185 | int rc; |
Roland McGrath | 6bc09da | 2007-11-01 21:50:54 +0000 | [diff] [blame] | 186 | |
| 187 | #if defined(LINUX) && SUPPORTED_PERSONALITIES > 1 |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 188 | if (personality_wordsize[current_personality] == 4) { |
Roland McGrath | 6bc09da | 2007-11-01 21:50:54 +0000 | [diff] [blame] | 189 | struct timeval32 tv; |
| 190 | |
| 191 | if ((rc = umove(tcp, addr, &tv)) >= 0) |
| 192 | sprintf(buf, "{%u, %u}", |
| 193 | tv.tv_sec, tv.tv_usec); |
| 194 | } else |
Roland McGrath | 6bc09da | 2007-11-01 21:50:54 +0000 | [diff] [blame] | 195 | #endif |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 196 | { |
Roland McGrath | 6bc09da | 2007-11-01 21:50:54 +0000 | [diff] [blame] | 197 | struct timespec ts; |
| 198 | |
| 199 | if ((rc = umove(tcp, addr, &ts)) >= 0) |
| 200 | sprintf(buf, "{%lu, %lu}", |
| 201 | (unsigned long) ts.tv_sec, |
| 202 | (unsigned long) ts.tv_nsec); |
Roland McGrath | 6bc09da | 2007-11-01 21:50:54 +0000 | [diff] [blame] | 203 | } |
Roland McGrath | 6bc09da | 2007-11-01 21:50:54 +0000 | [diff] [blame] | 204 | if (rc < 0) |
| 205 | strcpy(buf, "{...}"); |
| 206 | } |
| 207 | } |
| 208 | |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 209 | int |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 210 | sys_time(struct tcb *tcp) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 211 | { |
| 212 | if (exiting(tcp)) { |
| 213 | #ifndef SVR4 |
| 214 | printnum(tcp, tcp->u_arg[0], "%ld"); |
| 215 | #endif /* SVR4 */ |
| 216 | } |
| 217 | return 0; |
| 218 | } |
| 219 | |
| 220 | int |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 221 | sys_stime(struct tcb *tcp) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 222 | { |
| 223 | if (exiting(tcp)) { |
| 224 | printnum(tcp, tcp->u_arg[0], "%ld"); |
| 225 | } |
| 226 | return 0; |
| 227 | } |
| 228 | |
| 229 | int |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 230 | sys_gettimeofday(struct tcb *tcp) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 231 | { |
| 232 | if (exiting(tcp)) { |
| 233 | if (syserror(tcp)) { |
| 234 | tprintf("%#lx, %#lx", |
| 235 | tcp->u_arg[0], tcp->u_arg[1]); |
| 236 | return 0; |
| 237 | } |
| 238 | printtv(tcp, tcp->u_arg[0]); |
| 239 | #ifndef SVR4 |
| 240 | tprintf(", "); |
| 241 | printtv(tcp, tcp->u_arg[1]); |
| 242 | #endif /* !SVR4 */ |
| 243 | } |
| 244 | return 0; |
| 245 | } |
| 246 | |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 247 | |
| 248 | #ifdef ALPHA |
| 249 | int |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 250 | sys_osf_gettimeofday(struct tcb *tcp) |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 251 | { |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 252 | if (exiting(tcp)) { |
| 253 | if (syserror(tcp)) { |
| 254 | tprintf("%#lx, %#lx", tcp->u_arg[0], tcp->u_arg[1]); |
| 255 | return 0; |
| 256 | } |
| 257 | printtv_bitness(tcp, tcp->u_arg[0], BITNESS_32, 0); |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 258 | #ifndef SVR4 |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 259 | tprintf(", "); |
| 260 | printtv_bitness(tcp, tcp->u_arg[1], BITNESS_32, 0); |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 261 | #endif /* !SVR4 */ |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 262 | } |
| 263 | return 0; |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 264 | } |
| 265 | #endif |
| 266 | |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 267 | int |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 268 | sys_settimeofday(struct tcb *tcp) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 269 | { |
| 270 | if (entering(tcp)) { |
| 271 | printtv(tcp, tcp->u_arg[0]); |
| 272 | #ifndef SVR4 |
| 273 | tprintf(", "); |
| 274 | printtv(tcp, tcp->u_arg[1]); |
| 275 | #endif /* !SVR4 */ |
| 276 | } |
| 277 | return 0; |
| 278 | } |
| 279 | |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 280 | #ifdef ALPHA |
| 281 | int |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 282 | sys_osf_settimeofday(struct tcb *tcp) |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 283 | { |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 284 | if (entering(tcp)) { |
| 285 | printtv_bitness(tcp, tcp->u_arg[0], BITNESS_32, 0); |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 286 | #ifndef SVR4 |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 287 | tprintf(", "); |
| 288 | printtv_bitness(tcp, tcp->u_arg[1], BITNESS_32, 0); |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 289 | #endif /* !SVR4 */ |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 290 | } |
| 291 | return 0; |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 292 | } |
| 293 | #endif |
| 294 | |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 295 | int |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 296 | sys_adjtime(struct tcb *tcp) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 297 | { |
| 298 | if (entering(tcp)) { |
| 299 | printtv(tcp, tcp->u_arg[0]); |
| 300 | tprintf(", "); |
| 301 | } else { |
| 302 | if (syserror(tcp)) |
| 303 | tprintf("%#lx", tcp->u_arg[1]); |
| 304 | else |
| 305 | printtv(tcp, tcp->u_arg[1]); |
| 306 | } |
| 307 | return 0; |
| 308 | } |
| 309 | |
Dmitry V. Levin | 2e55ff4 | 2008-09-03 01:02:46 +0000 | [diff] [blame] | 310 | int |
| 311 | sys_nanosleep(struct tcb *tcp) |
| 312 | { |
| 313 | if (entering(tcp)) { |
| 314 | print_timespec(tcp, tcp->u_arg[0]); |
| 315 | tprintf(", "); |
| 316 | } else { |
| 317 | if (!tcp->u_arg[1] || is_restart_error(tcp)) |
| 318 | print_timespec(tcp, tcp->u_arg[1]); |
| 319 | else |
| 320 | tprintf("%#lx", tcp->u_arg[1]); |
| 321 | } |
| 322 | return 0; |
| 323 | } |
| 324 | |
Roland McGrath | d9f816f | 2004-09-04 03:39:20 +0000 | [diff] [blame] | 325 | static const struct xlat which[] = { |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 326 | { ITIMER_REAL, "ITIMER_REAL" }, |
| 327 | { ITIMER_VIRTUAL,"ITIMER_VIRTUAL"}, |
| 328 | { ITIMER_PROF, "ITIMER_PROF" }, |
| 329 | { 0, NULL }, |
| 330 | }; |
| 331 | |
| 332 | static void |
Dmitry V. Levin | 1cad25d | 2006-12-13 17:14:36 +0000 | [diff] [blame] | 333 | printitv_bitness(struct tcb *tcp, long addr, enum bitness_t bitness) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 334 | { |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 335 | if (addr == 0) |
| 336 | tprintf("NULL"); |
| 337 | else if (!verbose(tcp)) |
| 338 | tprintf("%#lx", addr); |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 339 | else { |
| 340 | int rc; |
Dmitry V. Levin | 1cad25d | 2006-12-13 17:14:36 +0000 | [diff] [blame] | 341 | |
| 342 | if (bitness == BITNESS_32 |
| 343 | #if defined(LINUX) && SUPPORTED_PERSONALITIES > 1 |
| 344 | || personality_wordsize[current_personality] == 4 |
| 345 | #endif |
| 346 | ) |
| 347 | { |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 348 | struct { |
Dmitry V. Levin | 1cad25d | 2006-12-13 17:14:36 +0000 | [diff] [blame] | 349 | struct timeval32 it_interval, it_value; |
| 350 | } itv; |
| 351 | |
Roland McGrath | e466234 | 2007-08-02 01:25:34 +0000 | [diff] [blame] | 352 | if ((rc = umove(tcp, addr, &itv)) >= 0) { |
Dmitry V. Levin | 1cad25d | 2006-12-13 17:14:36 +0000 | [diff] [blame] | 353 | tprintf("{it_interval="); |
| 354 | tprint_timeval32(tcp, &itv.it_interval); |
| 355 | tprintf(", it_value="); |
| 356 | tprint_timeval32(tcp, &itv.it_value); |
| 357 | tprintf("}"); |
Roland McGrath | e466234 | 2007-08-02 01:25:34 +0000 | [diff] [blame] | 358 | } |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 359 | } else { |
Dmitry V. Levin | 1cad25d | 2006-12-13 17:14:36 +0000 | [diff] [blame] | 360 | struct itimerval itv; |
| 361 | |
Roland McGrath | e466234 | 2007-08-02 01:25:34 +0000 | [diff] [blame] | 362 | if ((rc = umove(tcp, addr, &itv)) >= 0) { |
Dmitry V. Levin | 1cad25d | 2006-12-13 17:14:36 +0000 | [diff] [blame] | 363 | tprintf("{it_interval="); |
| 364 | tprint_timeval(tcp, &itv.it_interval); |
| 365 | tprintf(", it_value="); |
| 366 | tprint_timeval(tcp, &itv.it_value); |
| 367 | tprintf("}"); |
Roland McGrath | e466234 | 2007-08-02 01:25:34 +0000 | [diff] [blame] | 368 | } |
Dmitry V. Levin | 1cad25d | 2006-12-13 17:14:36 +0000 | [diff] [blame] | 369 | } |
Dmitry V. Levin | 1cad25d | 2006-12-13 17:14:36 +0000 | [diff] [blame] | 370 | if (rc < 0) |
| 371 | tprintf("{...}"); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 372 | } |
| 373 | } |
| 374 | |
Dmitry V. Levin | 1cad25d | 2006-12-13 17:14:36 +0000 | [diff] [blame] | 375 | #define printitv(tcp, addr) \ |
| 376 | printitv_bitness((tcp), (addr), BITNESS_CURRENT) |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 377 | |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 378 | int |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 379 | sys_getitimer(struct tcb *tcp) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 380 | { |
| 381 | if (entering(tcp)) { |
| 382 | printxval(which, tcp->u_arg[0], "ITIMER_???"); |
| 383 | tprintf(", "); |
| 384 | } else { |
| 385 | if (syserror(tcp)) |
| 386 | tprintf("%#lx", tcp->u_arg[1]); |
| 387 | else |
| 388 | printitv(tcp, tcp->u_arg[1]); |
| 389 | } |
| 390 | return 0; |
| 391 | } |
| 392 | |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 393 | |
| 394 | #ifdef ALPHA |
| 395 | int |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 396 | sys_osf_getitimer(struct tcb *tcp) |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 397 | { |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 398 | if (entering(tcp)) { |
| 399 | printxval(which, tcp->u_arg[0], "ITIMER_???"); |
| 400 | tprintf(", "); |
| 401 | } else { |
| 402 | if (syserror(tcp)) |
| 403 | tprintf("%#lx", tcp->u_arg[1]); |
| 404 | else |
| 405 | printitv_bitness(tcp, tcp->u_arg[1], BITNESS_32); |
| 406 | } |
| 407 | return 0; |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 408 | } |
| 409 | #endif |
| 410 | |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 411 | int |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 412 | sys_setitimer(struct tcb *tcp) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 413 | { |
| 414 | if (entering(tcp)) { |
| 415 | printxval(which, tcp->u_arg[0], "ITIMER_???"); |
| 416 | tprintf(", "); |
| 417 | printitv(tcp, tcp->u_arg[1]); |
| 418 | tprintf(", "); |
| 419 | } else { |
| 420 | if (syserror(tcp)) |
| 421 | tprintf("%#lx", tcp->u_arg[2]); |
| 422 | else |
| 423 | printitv(tcp, tcp->u_arg[2]); |
| 424 | } |
| 425 | return 0; |
| 426 | } |
| 427 | |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 428 | #ifdef ALPHA |
| 429 | int |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 430 | sys_osf_setitimer(struct tcb *tcp) |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 431 | { |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 432 | if (entering(tcp)) { |
| 433 | printxval(which, tcp->u_arg[0], "ITIMER_???"); |
| 434 | tprintf(", "); |
| 435 | printitv_bitness(tcp, tcp->u_arg[1], BITNESS_32); |
| 436 | tprintf(", "); |
| 437 | } else { |
| 438 | if (syserror(tcp)) |
| 439 | tprintf("%#lx", tcp->u_arg[2]); |
| 440 | else |
| 441 | printitv_bitness(tcp, tcp->u_arg[2], BITNESS_32); |
| 442 | } |
| 443 | return 0; |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 444 | } |
| 445 | #endif |
| 446 | |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 447 | #ifdef LINUX |
| 448 | |
Dmitry V. Levin | 1a684d6 | 2006-12-13 17:42:32 +0000 | [diff] [blame] | 449 | static const struct xlat adjtimex_modes[] = { |
| 450 | { 0, "0" }, |
| 451 | #ifdef ADJ_OFFSET |
| 452 | { ADJ_OFFSET, "ADJ_OFFSET" }, |
| 453 | #endif |
| 454 | #ifdef ADJ_FREQUENCY |
| 455 | { ADJ_FREQUENCY, "ADJ_FREQUENCY" }, |
| 456 | #endif |
| 457 | #ifdef ADJ_MAXERROR |
| 458 | { ADJ_MAXERROR, "ADJ_MAXERROR" }, |
| 459 | #endif |
| 460 | #ifdef ADJ_ESTERROR |
| 461 | { ADJ_ESTERROR, "ADJ_ESTERROR" }, |
| 462 | #endif |
| 463 | #ifdef ADJ_STATUS |
| 464 | { ADJ_STATUS, "ADJ_STATUS" }, |
| 465 | #endif |
| 466 | #ifdef ADJ_TIMECONST |
| 467 | { ADJ_TIMECONST, "ADJ_TIMECONST" }, |
| 468 | #endif |
| 469 | #ifdef ADJ_TICK |
| 470 | { ADJ_TICK, "ADJ_TICK" }, |
| 471 | #endif |
| 472 | #ifdef ADJ_OFFSET_SINGLESHOT |
| 473 | { ADJ_OFFSET_SINGLESHOT, "ADJ_OFFSET_SINGLESHOT" }, |
| 474 | #endif |
| 475 | { 0, NULL } |
| 476 | }; |
| 477 | |
| 478 | static const struct xlat adjtimex_status[] = { |
| 479 | #ifdef STA_PLL |
| 480 | { STA_PLL, "STA_PLL" }, |
| 481 | #endif |
| 482 | #ifdef STA_PPSFREQ |
| 483 | { STA_PPSFREQ, "STA_PPSFREQ" }, |
| 484 | #endif |
| 485 | #ifdef STA_PPSTIME |
| 486 | { STA_PPSTIME, "STA_PPSTIME" }, |
| 487 | #endif |
| 488 | #ifdef STA_FLL |
| 489 | { STA_FLL, "STA_FLL" }, |
| 490 | #endif |
| 491 | #ifdef STA_INS |
| 492 | { STA_INS, "STA_INS" }, |
| 493 | #endif |
| 494 | #ifdef STA_DEL |
| 495 | { STA_DEL, "STA_DEL" }, |
| 496 | #endif |
| 497 | #ifdef STA_UNSYNC |
| 498 | { STA_UNSYNC, "STA_UNSYNC" }, |
| 499 | #endif |
| 500 | #ifdef STA_FREQHOLD |
| 501 | { STA_FREQHOLD, "STA_FREQHOLD" }, |
| 502 | #endif |
| 503 | #ifdef STA_PPSSIGNAL |
| 504 | { STA_PPSSIGNAL, "STA_PPSSIGNAL" }, |
| 505 | #endif |
| 506 | #ifdef STA_PPSJITTER |
| 507 | { STA_PPSJITTER, "STA_PPSJITTER" }, |
| 508 | #endif |
| 509 | #ifdef STA_PPSWANDER |
| 510 | { STA_PPSWANDER, "STA_PPSWANDER" }, |
| 511 | #endif |
| 512 | #ifdef STA_PPSERROR |
| 513 | { STA_PPSERROR, "STA_PPSERROR" }, |
| 514 | #endif |
| 515 | #ifdef STA_CLOCKERR |
| 516 | { STA_CLOCKERR, "STA_CLOCKERR" }, |
| 517 | #endif |
| 518 | { 0, NULL } |
| 519 | }; |
| 520 | |
| 521 | static const struct xlat adjtimex_state[] = { |
| 522 | #ifdef TIME_OK |
| 523 | { TIME_OK, "TIME_OK" }, |
| 524 | #endif |
| 525 | #ifdef TIME_INS |
| 526 | { TIME_INS, "TIME_INS" }, |
| 527 | #endif |
| 528 | #ifdef TIME_DEL |
| 529 | { TIME_DEL, "TIME_DEL" }, |
| 530 | #endif |
| 531 | #ifdef TIME_OOP |
| 532 | { TIME_OOP, "TIME_OOP" }, |
| 533 | #endif |
| 534 | #ifdef TIME_WAIT |
| 535 | { TIME_WAIT, "TIME_WAIT" }, |
| 536 | #endif |
| 537 | #ifdef TIME_ERROR |
| 538 | { TIME_ERROR, "TIME_ERROR" }, |
| 539 | #endif |
| 540 | { 0, NULL } |
| 541 | }; |
| 542 | |
Dmitry V. Levin | 165b15d | 2006-12-13 17:43:45 +0000 | [diff] [blame] | 543 | #if SUPPORTED_PERSONALITIES > 1 |
| 544 | static int |
| 545 | tprint_timex32(struct tcb *tcp, long addr) |
| 546 | { |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 547 | struct { |
Dmitry V. Levin | 165b15d | 2006-12-13 17:43:45 +0000 | [diff] [blame] | 548 | unsigned int modes; |
| 549 | int offset; |
| 550 | int freq; |
| 551 | int maxerror; |
| 552 | int esterror; |
| 553 | int status; |
| 554 | int constant; |
| 555 | int precision; |
| 556 | int tolerance; |
| 557 | struct timeval32 time; |
| 558 | int tick; |
| 559 | int ppsfreq; |
| 560 | int jitter; |
| 561 | int shift; |
| 562 | int stabil; |
| 563 | int jitcnt; |
| 564 | int calcnt; |
| 565 | int errcnt; |
| 566 | int stbcnt; |
| 567 | } tx; |
| 568 | |
| 569 | if (umove(tcp, addr, &tx) < 0) |
| 570 | return -1; |
| 571 | |
| 572 | tprintf("{modes="); |
Dmitry V. Levin | 71d7089 | 2007-01-13 11:17:38 +0000 | [diff] [blame] | 573 | printflags(adjtimex_modes, tx.modes, "ADJ_???"); |
Dmitry V. Levin | 165b15d | 2006-12-13 17:43:45 +0000 | [diff] [blame] | 574 | tprintf(", offset=%d, freq=%d, maxerror=%d, ", |
| 575 | tx.offset, tx.freq, tx.maxerror); |
| 576 | tprintf("esterror=%u, status=", tx.esterror); |
| 577 | printflags(adjtimex_status, tx.status, "STA_???"); |
| 578 | tprintf(", constant=%d, precision=%u, ", |
| 579 | tx.constant, tx.precision); |
| 580 | tprintf("tolerance=%d, time=", tx.tolerance); |
| 581 | tprint_timeval32(tcp, &tx.time); |
| 582 | tprintf(", tick=%d, ppsfreq=%d, jitter=%d", |
| 583 | tx.tick, tx.ppsfreq, tx.jitter); |
| 584 | tprintf(", shift=%d, stabil=%d, jitcnt=%d", |
| 585 | tx.shift, tx.stabil, tx.jitcnt); |
| 586 | tprintf(", calcnt=%d, errcnt=%d, stbcnt=%d", |
| 587 | tx.calcnt, tx.errcnt, tx.stbcnt); |
| 588 | tprintf("}"); |
| 589 | return 0; |
| 590 | } |
| 591 | #endif /* SUPPORTED_PERSONALITIES > 1 */ |
| 592 | |
| 593 | static int |
| 594 | tprint_timex(struct tcb *tcp, long addr) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 595 | { |
Dmitry V. Levin | 1a684d6 | 2006-12-13 17:42:32 +0000 | [diff] [blame] | 596 | struct timex tx; |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 597 | |
Dmitry V. Levin | 165b15d | 2006-12-13 17:43:45 +0000 | [diff] [blame] | 598 | #if SUPPORTED_PERSONALITIES > 1 |
| 599 | if (personality_wordsize[current_personality] == 4) |
| 600 | return tprint_timex32(tcp, addr); |
| 601 | #endif |
| 602 | if (umove(tcp, addr, &tx) < 0) |
| 603 | return -1; |
| 604 | |
| 605 | #if LINUX_VERSION_CODE < 66332 |
| 606 | tprintf("{mode=%d, offset=%ld, frequency=%ld, ", |
| 607 | tx.mode, tx.offset, tx.frequency); |
| 608 | tprintf("maxerror=%ld, esterror=%lu, status=%u, ", |
| 609 | tx.maxerror, tx.esterror, tx.status); |
| 610 | tprintf("time_constant=%ld, precision=%lu, ", |
| 611 | tx.time_constant, tx.precision); |
| 612 | tprintf("tolerance=%ld, time=", tx.tolerance); |
| 613 | tprint_timeval(tcp, &tx.time); |
| 614 | #else |
| 615 | tprintf("{modes="); |
Dmitry V. Levin | 71d7089 | 2007-01-13 11:17:38 +0000 | [diff] [blame] | 616 | printflags(adjtimex_modes, tx.modes, "ADJ_???"); |
Dmitry V. Levin | 165b15d | 2006-12-13 17:43:45 +0000 | [diff] [blame] | 617 | tprintf(", offset=%ld, freq=%ld, maxerror=%ld, ", |
| 618 | tx.offset, tx.freq, tx.maxerror); |
| 619 | tprintf("esterror=%lu, status=", tx.esterror); |
| 620 | printflags(adjtimex_status, tx.status, "STA_???"); |
| 621 | tprintf(", constant=%ld, precision=%lu, ", |
| 622 | tx.constant, tx.precision); |
| 623 | tprintf("tolerance=%ld, time=", tx.tolerance); |
| 624 | tprint_timeval(tcp, &tx.time); |
| 625 | tprintf(", tick=%ld, ppsfreq=%ld, jitter=%ld", |
| 626 | tx.tick, tx.ppsfreq, tx.jitter); |
| 627 | tprintf(", shift=%d, stabil=%ld, jitcnt=%ld", |
| 628 | tx.shift, tx.stabil, tx.jitcnt); |
| 629 | tprintf(", calcnt=%ld, errcnt=%ld, stbcnt=%ld", |
| 630 | tx.calcnt, tx.errcnt, tx.stbcnt); |
| 631 | #endif |
| 632 | tprintf("}"); |
| 633 | return 0; |
| 634 | } |
| 635 | |
| 636 | int |
| 637 | sys_adjtimex(struct tcb *tcp) |
| 638 | { |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 639 | if (exiting(tcp)) { |
| 640 | if (tcp->u_arg[0] == 0) |
| 641 | tprintf("NULL"); |
| 642 | else if (syserror(tcp) || !verbose(tcp)) |
| 643 | tprintf("%#lx", tcp->u_arg[0]); |
Dmitry V. Levin | 165b15d | 2006-12-13 17:43:45 +0000 | [diff] [blame] | 644 | else if (tprint_timex(tcp, tcp->u_arg[0]) < 0) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 645 | tprintf("{...}"); |
Dmitry V. Levin | 21a7534 | 2008-09-03 01:22:18 +0000 | [diff] [blame] | 646 | if (syserror(tcp)) |
| 647 | return 0; |
Dmitry V. Levin | 1a684d6 | 2006-12-13 17:42:32 +0000 | [diff] [blame] | 648 | tcp->auxstr = xlookup(adjtimex_state, tcp->u_rval); |
| 649 | if (tcp->auxstr) |
| 650 | return RVAL_STR; |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 651 | } |
| 652 | return 0; |
| 653 | } |
Roland McGrath | 1e35679 | 2003-03-30 23:52:28 +0000 | [diff] [blame] | 654 | |
Roland McGrath | d9f816f | 2004-09-04 03:39:20 +0000 | [diff] [blame] | 655 | static const struct xlat clockflags[] = { |
Roland McGrath | 1e35679 | 2003-03-30 23:52:28 +0000 | [diff] [blame] | 656 | { TIMER_ABSTIME, "TIMER_ABSTIME" }, |
| 657 | { 0, NULL } |
| 658 | }; |
| 659 | |
Roland McGrath | d9f816f | 2004-09-04 03:39:20 +0000 | [diff] [blame] | 660 | static const struct xlat clocknames[] = { |
Roland McGrath | 55a00f8 | 2004-08-31 08:26:39 +0000 | [diff] [blame] | 661 | #ifdef CLOCK_REALTIME |
Roland McGrath | 54a4edd | 2004-08-31 06:52:45 +0000 | [diff] [blame] | 662 | { CLOCK_REALTIME, "CLOCK_REALTIME" }, |
Roland McGrath | 55a00f8 | 2004-08-31 08:26:39 +0000 | [diff] [blame] | 663 | #endif |
| 664 | #ifdef CLOCK_MONOTONIC |
Roland McGrath | 54a4edd | 2004-08-31 06:52:45 +0000 | [diff] [blame] | 665 | { CLOCK_MONOTONIC, "CLOCK_MONOTONIC" }, |
Roland McGrath | 55a00f8 | 2004-08-31 08:26:39 +0000 | [diff] [blame] | 666 | #endif |
Dmitry V. Levin | cbaaf79 | 2010-09-17 09:19:49 +0000 | [diff] [blame] | 667 | #ifdef CLOCK_PROCESS_CPUTIME_ID |
| 668 | { CLOCK_PROCESS_CPUTIME_ID, "CLOCK_PROCESS_CPUTIME_ID" }, |
| 669 | #endif |
| 670 | #ifdef CLOCK_THREAD_CPUTIME_ID |
| 671 | { CLOCK_THREAD_CPUTIME_ID, "CLOCK_THREAD_CPUTIME_ID" }, |
| 672 | #endif |
| 673 | #ifdef CLOCK_MONOTONIC_RAW |
| 674 | { CLOCK_MONOTONIC_RAW, "CLOCK_MONOTONIC_RAW" }, |
| 675 | #endif |
| 676 | #ifdef CLOCK_REALTIME_COARSE |
| 677 | { CLOCK_REALTIME_COARSE, "CLOCK_REALTIME_COARSE" }, |
| 678 | #endif |
| 679 | #ifdef CLOCK_MONOTONIC_COARSE |
| 680 | { CLOCK_MONOTONIC_COARSE, "CLOCK_MONOTONIC_COARSE" }, |
| 681 | #endif |
| 682 | { 0, NULL } |
Roland McGrath | 54a4edd | 2004-08-31 06:52:45 +0000 | [diff] [blame] | 683 | }; |
| 684 | |
Roland McGrath | 1e35679 | 2003-03-30 23:52:28 +0000 | [diff] [blame] | 685 | int |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 686 | sys_clock_settime(struct tcb *tcp) |
Roland McGrath | 1e35679 | 2003-03-30 23:52:28 +0000 | [diff] [blame] | 687 | { |
| 688 | if (entering(tcp)) { |
Roland McGrath | 54a4edd | 2004-08-31 06:52:45 +0000 | [diff] [blame] | 689 | printxval(clocknames, tcp->u_arg[0], "CLOCK_???"); |
| 690 | tprintf(", "); |
Roland McGrath | 1e35679 | 2003-03-30 23:52:28 +0000 | [diff] [blame] | 691 | printtv(tcp, tcp->u_arg[1]); |
| 692 | } |
| 693 | return 0; |
| 694 | } |
| 695 | |
| 696 | int |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 697 | sys_clock_gettime(struct tcb *tcp) |
Roland McGrath | 1e35679 | 2003-03-30 23:52:28 +0000 | [diff] [blame] | 698 | { |
| 699 | if (entering(tcp)) { |
Roland McGrath | 54a4edd | 2004-08-31 06:52:45 +0000 | [diff] [blame] | 700 | printxval(clocknames, tcp->u_arg[0], "CLOCK_???"); |
| 701 | tprintf(", "); |
Roland McGrath | 1e35679 | 2003-03-30 23:52:28 +0000 | [diff] [blame] | 702 | } else { |
| 703 | if (syserror(tcp)) |
| 704 | tprintf("%#lx", tcp->u_arg[1]); |
| 705 | else |
| 706 | printtv(tcp, tcp->u_arg[1]); |
| 707 | } |
| 708 | return 0; |
| 709 | } |
| 710 | |
| 711 | int |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 712 | sys_clock_nanosleep(struct tcb *tcp) |
Roland McGrath | 1e35679 | 2003-03-30 23:52:28 +0000 | [diff] [blame] | 713 | { |
| 714 | if (entering(tcp)) { |
Roland McGrath | 54a4edd | 2004-08-31 06:52:45 +0000 | [diff] [blame] | 715 | printxval(clocknames, tcp->u_arg[0], "CLOCK_???"); |
| 716 | tprintf(", "); |
Roland McGrath | b2dee13 | 2005-06-01 19:02:36 +0000 | [diff] [blame] | 717 | printflags(clockflags, tcp->u_arg[1], "TIMER_???"); |
Roland McGrath | 1e35679 | 2003-03-30 23:52:28 +0000 | [diff] [blame] | 718 | tprintf(", "); |
| 719 | printtv(tcp, tcp->u_arg[2]); |
| 720 | tprintf(", "); |
| 721 | } else { |
| 722 | if (syserror(tcp)) |
| 723 | tprintf("%#lx", tcp->u_arg[3]); |
| 724 | else |
| 725 | printtv(tcp, tcp->u_arg[3]); |
| 726 | } |
| 727 | return 0; |
| 728 | } |
| 729 | |
| 730 | #ifndef SIGEV_THREAD_ID |
| 731 | # define SIGEV_THREAD_ID 4 |
| 732 | #endif |
Roland McGrath | d9f816f | 2004-09-04 03:39:20 +0000 | [diff] [blame] | 733 | static const struct xlat sigev_value[] = { |
Roland McGrath | 1e35679 | 2003-03-30 23:52:28 +0000 | [diff] [blame] | 734 | { SIGEV_SIGNAL+1, "SIGEV_SIGNAL" }, |
| 735 | { SIGEV_NONE+1, "SIGEV_NONE" }, |
| 736 | { SIGEV_THREAD+1, "SIGEV_THREAD" }, |
| 737 | { SIGEV_THREAD_ID+1, "SIGEV_THREAD_ID" }, |
| 738 | { 0, NULL } |
| 739 | }; |
| 740 | |
Dmitry V. Levin | d3cb392 | 2006-12-13 17:45:02 +0000 | [diff] [blame] | 741 | #if SUPPORTED_PERSONALITIES > 1 |
| 742 | static void |
| 743 | printsigevent32(struct tcb *tcp, long arg) |
| 744 | { |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 745 | struct { |
Dmitry V. Levin | d3cb392 | 2006-12-13 17:45:02 +0000 | [diff] [blame] | 746 | int sigev_value; |
| 747 | int sigev_signo; |
| 748 | int sigev_notify; |
| 749 | |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 750 | union { |
Dmitry V. Levin | d3cb392 | 2006-12-13 17:45:02 +0000 | [diff] [blame] | 751 | int tid; |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 752 | struct { |
Dmitry V. Levin | d3cb392 | 2006-12-13 17:45:02 +0000 | [diff] [blame] | 753 | int function, attribute; |
| 754 | } thread; |
| 755 | } un; |
| 756 | } sev; |
| 757 | |
| 758 | if (umove(tcp, arg, &sev) < 0) |
| 759 | tprintf("{...}"); |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 760 | else { |
Dmitry V. Levin | d3cb392 | 2006-12-13 17:45:02 +0000 | [diff] [blame] | 761 | tprintf("{%#x, ", sev.sigev_value); |
| 762 | if (sev.sigev_notify == SIGEV_SIGNAL) |
| 763 | tprintf("%s, ", signame(sev.sigev_signo)); |
| 764 | else |
| 765 | tprintf("%u, ", sev.sigev_signo); |
| 766 | printxval(sigev_value, sev.sigev_notify + 1, "SIGEV_???"); |
| 767 | tprintf(", "); |
| 768 | if (sev.sigev_notify == SIGEV_THREAD_ID) |
| 769 | tprintf("{%d}", sev.un.tid); |
| 770 | else if (sev.sigev_notify == SIGEV_THREAD) |
| 771 | tprintf("{%#x, %#x}", |
| 772 | sev.un.thread.function, |
| 773 | sev.un.thread.attribute); |
| 774 | else |
| 775 | tprintf("{...}"); |
| 776 | tprintf("}"); |
| 777 | } |
| 778 | } |
| 779 | #endif |
| 780 | |
Roland McGrath | 1e35679 | 2003-03-30 23:52:28 +0000 | [diff] [blame] | 781 | void |
Dmitry V. Levin | d3cb392 | 2006-12-13 17:45:02 +0000 | [diff] [blame] | 782 | printsigevent(struct tcb *tcp, long arg) |
Roland McGrath | 1e35679 | 2003-03-30 23:52:28 +0000 | [diff] [blame] | 783 | { |
| 784 | struct sigevent sev; |
Dmitry V. Levin | d3cb392 | 2006-12-13 17:45:02 +0000 | [diff] [blame] | 785 | |
| 786 | #if SUPPORTED_PERSONALITIES > 1 |
| 787 | if (personality_wordsize[current_personality] == 4) |
| 788 | { |
| 789 | printsigevent32(tcp, arg); |
| 790 | return; |
| 791 | } |
| 792 | #endif |
Roland McGrath | 1e35679 | 2003-03-30 23:52:28 +0000 | [diff] [blame] | 793 | if (umove (tcp, arg, &sev) < 0) |
| 794 | tprintf("{...}"); |
| 795 | else { |
Roland McGrath | 675d4a6 | 2004-09-11 08:12:45 +0000 | [diff] [blame] | 796 | tprintf("{%p, ", sev.sigev_value.sival_ptr); |
| 797 | if (sev.sigev_notify == SIGEV_SIGNAL) |
| 798 | tprintf("%s, ", signame(sev.sigev_signo)); |
| 799 | else |
| 800 | tprintf("%u, ", sev.sigev_signo); |
Roland McGrath | 1e35679 | 2003-03-30 23:52:28 +0000 | [diff] [blame] | 801 | printxval(sigev_value, sev.sigev_notify+1, "SIGEV_???"); |
| 802 | tprintf(", "); |
| 803 | if (sev.sigev_notify == SIGEV_THREAD_ID) |
| 804 | /* _pad[0] is the _tid field which might not be |
| 805 | present in the userlevel definition of the |
| 806 | struct. */ |
| 807 | tprintf("{%d}", sev._sigev_un._pad[0]); |
Roland McGrath | d4c85eb | 2004-04-16 21:48:44 +0000 | [diff] [blame] | 808 | else if (sev.sigev_notify == SIGEV_THREAD) |
| 809 | tprintf("{%p, %p}", sev.sigev_notify_function, |
| 810 | sev.sigev_notify_attributes); |
Roland McGrath | 1e35679 | 2003-03-30 23:52:28 +0000 | [diff] [blame] | 811 | else |
| 812 | tprintf("{...}"); |
| 813 | tprintf("}"); |
| 814 | } |
| 815 | } |
| 816 | |
| 817 | int |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 818 | sys_timer_create(struct tcb *tcp) |
Roland McGrath | 1e35679 | 2003-03-30 23:52:28 +0000 | [diff] [blame] | 819 | { |
| 820 | if (entering(tcp)) { |
Roland McGrath | 675d4a6 | 2004-09-11 08:12:45 +0000 | [diff] [blame] | 821 | printxval(clocknames, tcp->u_arg[0], "CLOCK_???"); |
| 822 | tprintf(", "); |
Roland McGrath | 1e35679 | 2003-03-30 23:52:28 +0000 | [diff] [blame] | 823 | printsigevent(tcp, tcp->u_arg[1]); |
| 824 | tprintf(", "); |
| 825 | } else { |
Dmitry V. Levin | ac518d1 | 2006-12-13 17:03:02 +0000 | [diff] [blame] | 826 | void *p; |
| 827 | |
| 828 | if (syserror(tcp) || umove(tcp, tcp->u_arg[2], &p) < 0) |
Roland McGrath | 1e35679 | 2003-03-30 23:52:28 +0000 | [diff] [blame] | 829 | tprintf("%#lx", tcp->u_arg[2]); |
Dmitry V. Levin | ac518d1 | 2006-12-13 17:03:02 +0000 | [diff] [blame] | 830 | else |
Roland McGrath | 1e35679 | 2003-03-30 23:52:28 +0000 | [diff] [blame] | 831 | tprintf("{%p}", p); |
Roland McGrath | 1e35679 | 2003-03-30 23:52:28 +0000 | [diff] [blame] | 832 | } |
| 833 | return 0; |
| 834 | } |
| 835 | |
| 836 | int |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 837 | sys_timer_settime(struct tcb *tcp) |
Roland McGrath | 1e35679 | 2003-03-30 23:52:28 +0000 | [diff] [blame] | 838 | { |
| 839 | if (entering(tcp)) { |
| 840 | tprintf("%#lx, ", tcp->u_arg[0]); |
Roland McGrath | b2dee13 | 2005-06-01 19:02:36 +0000 | [diff] [blame] | 841 | printflags(clockflags, tcp->u_arg[1], "TIMER_???"); |
Roland McGrath | 1e35679 | 2003-03-30 23:52:28 +0000 | [diff] [blame] | 842 | tprintf(", "); |
| 843 | printitv(tcp, tcp->u_arg[2]); |
| 844 | tprintf(", "); |
| 845 | } else { |
| 846 | if (syserror(tcp)) |
| 847 | tprintf("%#lx", tcp->u_arg[3]); |
| 848 | else |
| 849 | printitv(tcp, tcp->u_arg[3]); |
| 850 | } |
| 851 | return 0; |
| 852 | } |
| 853 | |
| 854 | int |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 855 | sys_timer_gettime(struct tcb *tcp) |
Roland McGrath | 1e35679 | 2003-03-30 23:52:28 +0000 | [diff] [blame] | 856 | { |
| 857 | if (entering(tcp)) { |
| 858 | tprintf("%#lx, ", tcp->u_arg[0]); |
| 859 | } else { |
| 860 | if (syserror(tcp)) |
| 861 | tprintf("%#lx", tcp->u_arg[1]); |
| 862 | else |
| 863 | printitv(tcp, tcp->u_arg[1]); |
| 864 | } |
| 865 | return 0; |
| 866 | } |
Roland McGrath | d83c50b | 2004-10-06 22:27:43 +0000 | [diff] [blame] | 867 | |
| 868 | static void |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 869 | print_rtc(struct tcb *tcp, const struct rtc_time *rt) |
Roland McGrath | d83c50b | 2004-10-06 22:27:43 +0000 | [diff] [blame] | 870 | { |
| 871 | tprintf("{tm_sec=%d, tm_min=%d, tm_hour=%d, " |
| 872 | "tm_mday=%d, tm_mon=%d, tm_year=%d, ", |
| 873 | rt->tm_sec, rt->tm_min, rt->tm_hour, |
| 874 | rt->tm_mday, rt->tm_mon, rt->tm_year); |
| 875 | if (!abbrev(tcp)) |
| 876 | tprintf("tm_wday=%d, tm_yday=%d, tm_isdst=%d}", |
| 877 | rt->tm_wday, rt->tm_yday, rt->tm_isdst); |
| 878 | else |
| 879 | tprintf("...}"); |
| 880 | } |
| 881 | |
| 882 | int |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 883 | rtc_ioctl(struct tcb *tcp, long code, long arg) |
Roland McGrath | d83c50b | 2004-10-06 22:27:43 +0000 | [diff] [blame] | 884 | { |
| 885 | switch (code) { |
| 886 | case RTC_ALM_SET: |
| 887 | case RTC_SET_TIME: |
| 888 | if (entering(tcp)) { |
| 889 | struct rtc_time rt; |
| 890 | if (umove(tcp, arg, &rt) < 0) |
| 891 | tprintf(", %#lx", arg); |
| 892 | else { |
| 893 | tprintf(", "); |
| 894 | print_rtc(tcp, &rt); |
| 895 | } |
| 896 | } |
| 897 | break; |
| 898 | case RTC_ALM_READ: |
| 899 | case RTC_RD_TIME: |
| 900 | if (exiting(tcp)) { |
| 901 | struct rtc_time rt; |
| 902 | if (syserror(tcp) || umove(tcp, arg, &rt) < 0) |
| 903 | tprintf(", %#lx", arg); |
| 904 | else { |
| 905 | tprintf(", "); |
| 906 | print_rtc(tcp, &rt); |
| 907 | } |
| 908 | } |
| 909 | break; |
| 910 | case RTC_IRQP_SET: |
| 911 | case RTC_EPOCH_SET: |
| 912 | if (entering(tcp)) |
| 913 | tprintf(", %lu", arg); |
| 914 | break; |
| 915 | case RTC_IRQP_READ: |
| 916 | case RTC_EPOCH_READ: |
| 917 | if (exiting(tcp)) |
| 918 | tprintf(", %lu", arg); |
| 919 | break; |
| 920 | case RTC_WKALM_SET: |
| 921 | if (entering(tcp)) { |
| 922 | struct rtc_wkalrm wk; |
| 923 | if (umove(tcp, arg, &wk) < 0) |
| 924 | tprintf(", %#lx", arg); |
| 925 | else { |
| 926 | tprintf(", {enabled=%d, pending=%d, ", |
| 927 | wk.enabled, wk.pending); |
| 928 | print_rtc(tcp, &wk.time); |
| 929 | tprintf("}"); |
| 930 | } |
| 931 | } |
| 932 | break; |
| 933 | case RTC_WKALM_RD: |
| 934 | if (exiting(tcp)) { |
| 935 | struct rtc_wkalrm wk; |
| 936 | if (syserror(tcp) || 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); |
| 942 | tprintf("}"); |
| 943 | } |
| 944 | } |
| 945 | break; |
| 946 | default: |
| 947 | if (entering(tcp)) |
| 948 | tprintf(", %#lx", arg); |
| 949 | break; |
| 950 | } |
| 951 | return 1; |
| 952 | } |
Roland McGrath | e466234 | 2007-08-02 01:25:34 +0000 | [diff] [blame] | 953 | |
| 954 | #ifndef TFD_TIMER_ABSTIME |
| 955 | #define TFD_TIMER_ABSTIME (1 << 0) |
| 956 | #endif |
| 957 | |
| 958 | static const struct xlat timerfdflags[] = { |
| 959 | { TFD_TIMER_ABSTIME, "TFD_TIMER_ABSTIME" }, |
| 960 | { 0, NULL } |
| 961 | }; |
| 962 | |
| 963 | int |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 964 | sys_timerfd(struct tcb *tcp) |
Roland McGrath | e466234 | 2007-08-02 01:25:34 +0000 | [diff] [blame] | 965 | { |
| 966 | if (entering(tcp)) { |
| 967 | /* It does not matter that the kernel uses itimerspec. */ |
| 968 | tprintf("%ld, ", tcp->u_arg[0]); |
| 969 | printxval(clocknames, tcp->u_arg[1], "CLOCK_???"); |
| 970 | tprintf(", "); |
| 971 | printflags(timerfdflags, tcp->u_arg[2], "TFD_???"); |
| 972 | tprintf(", "); |
| 973 | printitv(tcp, tcp->u_arg[3]); |
| 974 | } |
| 975 | return 0; |
| 976 | } |
Roland McGrath | de328e6 | 2008-05-20 04:56:13 +0000 | [diff] [blame] | 977 | |
| 978 | int |
| 979 | sys_timerfd_create(struct tcb *tcp) |
| 980 | { |
| 981 | if (entering(tcp)) { |
| 982 | printxval(clocknames, tcp->u_arg[0], "CLOCK_???"); |
| 983 | tprintf(", "); |
| 984 | printflags(timerfdflags, tcp->u_arg[1], "TFD_???"); |
| 985 | } |
| 986 | return 0; |
| 987 | } |
| 988 | |
| 989 | int |
| 990 | sys_timerfd_settime(struct tcb *tcp) |
| 991 | { |
| 992 | if (entering(tcp)) { |
Dmitry V. Levin | 3138213 | 2011-03-04 05:08:02 +0300 | [diff] [blame] | 993 | printfd(tcp, tcp->u_arg[0]); |
| 994 | tprintf(", "); |
Roland McGrath | de328e6 | 2008-05-20 04:56:13 +0000 | [diff] [blame] | 995 | printflags(timerfdflags, tcp->u_arg[1], "TFD_???"); |
| 996 | tprintf(", "); |
| 997 | printitv(tcp, tcp->u_arg[2]); |
| 998 | tprintf(", "); |
| 999 | printitv(tcp, tcp->u_arg[3]); |
| 1000 | } |
| 1001 | return 0; |
| 1002 | } |
| 1003 | |
| 1004 | int |
| 1005 | sys_timerfd_gettime(struct tcb *tcp) |
| 1006 | { |
| 1007 | if (entering(tcp)) { |
Dmitry V. Levin | 3138213 | 2011-03-04 05:08:02 +0300 | [diff] [blame] | 1008 | printfd(tcp, tcp->u_arg[0]); |
Roland McGrath | de328e6 | 2008-05-20 04:56:13 +0000 | [diff] [blame] | 1009 | tprintf(", "); |
| 1010 | printitv(tcp, tcp->u_arg[1]); |
| 1011 | } |
| 1012 | return 0; |
| 1013 | } |
| 1014 | |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1015 | #endif /* LINUX */ |