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