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 | |
| 291 | if ((rc = umove(tcp, addr, &itv)) >= 0) |
| 292 | tprintf("{it_interval="); |
| 293 | tprint_timeval32(tcp, &itv.it_interval); |
| 294 | tprintf(", it_value="); |
| 295 | tprint_timeval32(tcp, &itv.it_value); |
| 296 | tprintf("}"); |
| 297 | } else |
| 298 | { |
| 299 | struct itimerval itv; |
| 300 | |
| 301 | if ((rc = umove(tcp, addr, &itv)) >= 0) |
| 302 | tprintf("{it_interval="); |
| 303 | tprint_timeval(tcp, &itv.it_interval); |
| 304 | tprintf(", it_value="); |
| 305 | tprint_timeval(tcp, &itv.it_value); |
| 306 | tprintf("}"); |
| 307 | } |
| 308 | |
| 309 | if (rc < 0) |
| 310 | tprintf("{...}"); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 311 | } |
| 312 | } |
| 313 | |
Dmitry V. Levin | 1cad25d | 2006-12-13 17:14:36 +0000 | [diff] [blame] | 314 | #define printitv(tcp, addr) \ |
| 315 | printitv_bitness((tcp), (addr), BITNESS_CURRENT) |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 316 | |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 317 | int |
| 318 | sys_getitimer(tcp) |
| 319 | struct tcb *tcp; |
| 320 | { |
| 321 | if (entering(tcp)) { |
| 322 | printxval(which, tcp->u_arg[0], "ITIMER_???"); |
| 323 | tprintf(", "); |
| 324 | } else { |
| 325 | if (syserror(tcp)) |
| 326 | tprintf("%#lx", tcp->u_arg[1]); |
| 327 | else |
| 328 | printitv(tcp, tcp->u_arg[1]); |
| 329 | } |
| 330 | return 0; |
| 331 | } |
| 332 | |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 333 | |
| 334 | #ifdef ALPHA |
| 335 | int |
| 336 | sys_osf_getitimer(tcp) |
| 337 | struct tcb *tcp; |
| 338 | { |
| 339 | if (entering(tcp)) { |
| 340 | printxval(which, tcp->u_arg[0], "ITIMER_???"); |
| 341 | tprintf(", "); |
| 342 | } else { |
| 343 | if (syserror(tcp)) |
| 344 | tprintf("%#lx", tcp->u_arg[1]); |
| 345 | else |
Dmitry V. Levin | 1cad25d | 2006-12-13 17:14:36 +0000 | [diff] [blame] | 346 | printitv_bitness(tcp, tcp->u_arg[1], BITNESS_32); |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 347 | } |
| 348 | return 0; |
| 349 | } |
| 350 | #endif |
| 351 | |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 352 | int |
| 353 | sys_setitimer(tcp) |
| 354 | struct tcb *tcp; |
| 355 | { |
| 356 | if (entering(tcp)) { |
| 357 | printxval(which, tcp->u_arg[0], "ITIMER_???"); |
| 358 | tprintf(", "); |
| 359 | printitv(tcp, tcp->u_arg[1]); |
| 360 | tprintf(", "); |
| 361 | } else { |
| 362 | if (syserror(tcp)) |
| 363 | tprintf("%#lx", tcp->u_arg[2]); |
| 364 | else |
| 365 | printitv(tcp, tcp->u_arg[2]); |
| 366 | } |
| 367 | return 0; |
| 368 | } |
| 369 | |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 370 | #ifdef ALPHA |
| 371 | int |
| 372 | sys_osf_setitimer(tcp) |
| 373 | struct tcb *tcp; |
| 374 | { |
| 375 | if (entering(tcp)) { |
| 376 | printxval(which, tcp->u_arg[0], "ITIMER_???"); |
| 377 | tprintf(", "); |
Dmitry V. Levin | 1cad25d | 2006-12-13 17:14:36 +0000 | [diff] [blame] | 378 | printitv_bitness(tcp, tcp->u_arg[1], BITNESS_32); |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 379 | tprintf(", "); |
| 380 | } else { |
| 381 | if (syserror(tcp)) |
| 382 | tprintf("%#lx", tcp->u_arg[2]); |
| 383 | else |
Dmitry V. Levin | 1cad25d | 2006-12-13 17:14:36 +0000 | [diff] [blame] | 384 | printitv_bitness(tcp, tcp->u_arg[2], BITNESS_32); |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 385 | } |
| 386 | return 0; |
| 387 | } |
| 388 | #endif |
| 389 | |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 390 | #ifdef LINUX |
| 391 | |
Dmitry V. Levin | 1a684d6 | 2006-12-13 17:42:32 +0000 | [diff] [blame] | 392 | static const struct xlat adjtimex_modes[] = { |
| 393 | { 0, "0" }, |
| 394 | #ifdef ADJ_OFFSET |
| 395 | { ADJ_OFFSET, "ADJ_OFFSET" }, |
| 396 | #endif |
| 397 | #ifdef ADJ_FREQUENCY |
| 398 | { ADJ_FREQUENCY, "ADJ_FREQUENCY" }, |
| 399 | #endif |
| 400 | #ifdef ADJ_MAXERROR |
| 401 | { ADJ_MAXERROR, "ADJ_MAXERROR" }, |
| 402 | #endif |
| 403 | #ifdef ADJ_ESTERROR |
| 404 | { ADJ_ESTERROR, "ADJ_ESTERROR" }, |
| 405 | #endif |
| 406 | #ifdef ADJ_STATUS |
| 407 | { ADJ_STATUS, "ADJ_STATUS" }, |
| 408 | #endif |
| 409 | #ifdef ADJ_TIMECONST |
| 410 | { ADJ_TIMECONST, "ADJ_TIMECONST" }, |
| 411 | #endif |
| 412 | #ifdef ADJ_TICK |
| 413 | { ADJ_TICK, "ADJ_TICK" }, |
| 414 | #endif |
| 415 | #ifdef ADJ_OFFSET_SINGLESHOT |
| 416 | { ADJ_OFFSET_SINGLESHOT, "ADJ_OFFSET_SINGLESHOT" }, |
| 417 | #endif |
| 418 | { 0, NULL } |
| 419 | }; |
| 420 | |
| 421 | static const struct xlat adjtimex_status[] = { |
| 422 | #ifdef STA_PLL |
| 423 | { STA_PLL, "STA_PLL" }, |
| 424 | #endif |
| 425 | #ifdef STA_PPSFREQ |
| 426 | { STA_PPSFREQ, "STA_PPSFREQ" }, |
| 427 | #endif |
| 428 | #ifdef STA_PPSTIME |
| 429 | { STA_PPSTIME, "STA_PPSTIME" }, |
| 430 | #endif |
| 431 | #ifdef STA_FLL |
| 432 | { STA_FLL, "STA_FLL" }, |
| 433 | #endif |
| 434 | #ifdef STA_INS |
| 435 | { STA_INS, "STA_INS" }, |
| 436 | #endif |
| 437 | #ifdef STA_DEL |
| 438 | { STA_DEL, "STA_DEL" }, |
| 439 | #endif |
| 440 | #ifdef STA_UNSYNC |
| 441 | { STA_UNSYNC, "STA_UNSYNC" }, |
| 442 | #endif |
| 443 | #ifdef STA_FREQHOLD |
| 444 | { STA_FREQHOLD, "STA_FREQHOLD" }, |
| 445 | #endif |
| 446 | #ifdef STA_PPSSIGNAL |
| 447 | { STA_PPSSIGNAL, "STA_PPSSIGNAL" }, |
| 448 | #endif |
| 449 | #ifdef STA_PPSJITTER |
| 450 | { STA_PPSJITTER, "STA_PPSJITTER" }, |
| 451 | #endif |
| 452 | #ifdef STA_PPSWANDER |
| 453 | { STA_PPSWANDER, "STA_PPSWANDER" }, |
| 454 | #endif |
| 455 | #ifdef STA_PPSERROR |
| 456 | { STA_PPSERROR, "STA_PPSERROR" }, |
| 457 | #endif |
| 458 | #ifdef STA_CLOCKERR |
| 459 | { STA_CLOCKERR, "STA_CLOCKERR" }, |
| 460 | #endif |
| 461 | { 0, NULL } |
| 462 | }; |
| 463 | |
| 464 | static const struct xlat adjtimex_state[] = { |
| 465 | #ifdef TIME_OK |
| 466 | { TIME_OK, "TIME_OK" }, |
| 467 | #endif |
| 468 | #ifdef TIME_INS |
| 469 | { TIME_INS, "TIME_INS" }, |
| 470 | #endif |
| 471 | #ifdef TIME_DEL |
| 472 | { TIME_DEL, "TIME_DEL" }, |
| 473 | #endif |
| 474 | #ifdef TIME_OOP |
| 475 | { TIME_OOP, "TIME_OOP" }, |
| 476 | #endif |
| 477 | #ifdef TIME_WAIT |
| 478 | { TIME_WAIT, "TIME_WAIT" }, |
| 479 | #endif |
| 480 | #ifdef TIME_ERROR |
| 481 | { TIME_ERROR, "TIME_ERROR" }, |
| 482 | #endif |
| 483 | { 0, NULL } |
| 484 | }; |
| 485 | |
Dmitry V. Levin | 165b15d | 2006-12-13 17:43:45 +0000 | [diff] [blame] | 486 | #if SUPPORTED_PERSONALITIES > 1 |
| 487 | static int |
| 488 | tprint_timex32(struct tcb *tcp, long addr) |
| 489 | { |
| 490 | struct |
| 491 | { |
| 492 | unsigned int modes; |
| 493 | int offset; |
| 494 | int freq; |
| 495 | int maxerror; |
| 496 | int esterror; |
| 497 | int status; |
| 498 | int constant; |
| 499 | int precision; |
| 500 | int tolerance; |
| 501 | struct timeval32 time; |
| 502 | int tick; |
| 503 | int ppsfreq; |
| 504 | int jitter; |
| 505 | int shift; |
| 506 | int stabil; |
| 507 | int jitcnt; |
| 508 | int calcnt; |
| 509 | int errcnt; |
| 510 | int stbcnt; |
| 511 | } tx; |
| 512 | |
| 513 | if (umove(tcp, addr, &tx) < 0) |
| 514 | return -1; |
| 515 | |
| 516 | tprintf("{modes="); |
Dmitry V. Levin | 71d7089 | 2007-01-13 11:17:38 +0000 | [diff] [blame] | 517 | printflags(adjtimex_modes, tx.modes, "ADJ_???"); |
Dmitry V. Levin | 165b15d | 2006-12-13 17:43:45 +0000 | [diff] [blame] | 518 | tprintf(", offset=%d, freq=%d, maxerror=%d, ", |
| 519 | tx.offset, tx.freq, tx.maxerror); |
| 520 | tprintf("esterror=%u, status=", tx.esterror); |
| 521 | printflags(adjtimex_status, tx.status, "STA_???"); |
| 522 | tprintf(", constant=%d, precision=%u, ", |
| 523 | tx.constant, tx.precision); |
| 524 | tprintf("tolerance=%d, time=", tx.tolerance); |
| 525 | tprint_timeval32(tcp, &tx.time); |
| 526 | tprintf(", tick=%d, ppsfreq=%d, jitter=%d", |
| 527 | tx.tick, tx.ppsfreq, tx.jitter); |
| 528 | tprintf(", shift=%d, stabil=%d, jitcnt=%d", |
| 529 | tx.shift, tx.stabil, tx.jitcnt); |
| 530 | tprintf(", calcnt=%d, errcnt=%d, stbcnt=%d", |
| 531 | tx.calcnt, tx.errcnt, tx.stbcnt); |
| 532 | tprintf("}"); |
| 533 | return 0; |
| 534 | } |
| 535 | #endif /* SUPPORTED_PERSONALITIES > 1 */ |
| 536 | |
| 537 | static int |
| 538 | tprint_timex(struct tcb *tcp, long addr) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 539 | { |
Dmitry V. Levin | 1a684d6 | 2006-12-13 17:42:32 +0000 | [diff] [blame] | 540 | struct timex tx; |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 541 | |
Dmitry V. Levin | 165b15d | 2006-12-13 17:43:45 +0000 | [diff] [blame] | 542 | #if SUPPORTED_PERSONALITIES > 1 |
| 543 | if (personality_wordsize[current_personality] == 4) |
| 544 | return tprint_timex32(tcp, addr); |
| 545 | #endif |
| 546 | if (umove(tcp, addr, &tx) < 0) |
| 547 | return -1; |
| 548 | |
| 549 | #if LINUX_VERSION_CODE < 66332 |
| 550 | tprintf("{mode=%d, offset=%ld, frequency=%ld, ", |
| 551 | tx.mode, tx.offset, tx.frequency); |
| 552 | tprintf("maxerror=%ld, esterror=%lu, status=%u, ", |
| 553 | tx.maxerror, tx.esterror, tx.status); |
| 554 | tprintf("time_constant=%ld, precision=%lu, ", |
| 555 | tx.time_constant, tx.precision); |
| 556 | tprintf("tolerance=%ld, time=", tx.tolerance); |
| 557 | tprint_timeval(tcp, &tx.time); |
| 558 | #else |
| 559 | tprintf("{modes="); |
Dmitry V. Levin | 71d7089 | 2007-01-13 11:17:38 +0000 | [diff] [blame] | 560 | printflags(adjtimex_modes, tx.modes, "ADJ_???"); |
Dmitry V. Levin | 165b15d | 2006-12-13 17:43:45 +0000 | [diff] [blame] | 561 | tprintf(", offset=%ld, freq=%ld, maxerror=%ld, ", |
| 562 | tx.offset, tx.freq, tx.maxerror); |
| 563 | tprintf("esterror=%lu, status=", tx.esterror); |
| 564 | printflags(adjtimex_status, tx.status, "STA_???"); |
| 565 | tprintf(", constant=%ld, precision=%lu, ", |
| 566 | tx.constant, tx.precision); |
| 567 | tprintf("tolerance=%ld, time=", tx.tolerance); |
| 568 | tprint_timeval(tcp, &tx.time); |
| 569 | tprintf(", tick=%ld, ppsfreq=%ld, jitter=%ld", |
| 570 | tx.tick, tx.ppsfreq, tx.jitter); |
| 571 | tprintf(", shift=%d, stabil=%ld, jitcnt=%ld", |
| 572 | tx.shift, tx.stabil, tx.jitcnt); |
| 573 | tprintf(", calcnt=%ld, errcnt=%ld, stbcnt=%ld", |
| 574 | tx.calcnt, tx.errcnt, tx.stbcnt); |
| 575 | #endif |
| 576 | tprintf("}"); |
| 577 | return 0; |
| 578 | } |
| 579 | |
| 580 | int |
| 581 | sys_adjtimex(struct tcb *tcp) |
| 582 | { |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 583 | if (exiting(tcp)) { |
| 584 | if (tcp->u_arg[0] == 0) |
| 585 | tprintf("NULL"); |
| 586 | else if (syserror(tcp) || !verbose(tcp)) |
| 587 | tprintf("%#lx", tcp->u_arg[0]); |
Dmitry V. Levin | 165b15d | 2006-12-13 17:43:45 +0000 | [diff] [blame] | 588 | else if (tprint_timex(tcp, tcp->u_arg[0]) < 0) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 589 | tprintf("{...}"); |
Dmitry V. Levin | 1a684d6 | 2006-12-13 17:42:32 +0000 | [diff] [blame] | 590 | tcp->auxstr = xlookup(adjtimex_state, tcp->u_rval); |
| 591 | if (tcp->auxstr) |
| 592 | return RVAL_STR; |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 593 | } |
| 594 | return 0; |
| 595 | } |
Roland McGrath | 1e35679 | 2003-03-30 23:52:28 +0000 | [diff] [blame] | 596 | |
Roland McGrath | d9f816f | 2004-09-04 03:39:20 +0000 | [diff] [blame] | 597 | static const struct xlat clockflags[] = { |
Roland McGrath | 1e35679 | 2003-03-30 23:52:28 +0000 | [diff] [blame] | 598 | { TIMER_ABSTIME, "TIMER_ABSTIME" }, |
| 599 | { 0, NULL } |
| 600 | }; |
| 601 | |
Roland McGrath | d9f816f | 2004-09-04 03:39:20 +0000 | [diff] [blame] | 602 | static const struct xlat clocknames[] = { |
Roland McGrath | 55a00f8 | 2004-08-31 08:26:39 +0000 | [diff] [blame] | 603 | #ifdef CLOCK_REALTIME |
Roland McGrath | 54a4edd | 2004-08-31 06:52:45 +0000 | [diff] [blame] | 604 | { CLOCK_REALTIME, "CLOCK_REALTIME" }, |
Roland McGrath | 55a00f8 | 2004-08-31 08:26:39 +0000 | [diff] [blame] | 605 | #endif |
| 606 | #ifdef CLOCK_MONOTONIC |
Roland McGrath | 54a4edd | 2004-08-31 06:52:45 +0000 | [diff] [blame] | 607 | { CLOCK_MONOTONIC, "CLOCK_MONOTONIC" }, |
Roland McGrath | 55a00f8 | 2004-08-31 08:26:39 +0000 | [diff] [blame] | 608 | #endif |
Roland McGrath | 54a4edd | 2004-08-31 06:52:45 +0000 | [diff] [blame] | 609 | { 0, NULL } |
| 610 | }; |
| 611 | |
Roland McGrath | 1e35679 | 2003-03-30 23:52:28 +0000 | [diff] [blame] | 612 | int |
| 613 | sys_clock_settime(tcp) |
| 614 | struct tcb *tcp; |
| 615 | { |
| 616 | if (entering(tcp)) { |
Roland McGrath | 54a4edd | 2004-08-31 06:52:45 +0000 | [diff] [blame] | 617 | printxval(clocknames, tcp->u_arg[0], "CLOCK_???"); |
| 618 | tprintf(", "); |
Roland McGrath | 1e35679 | 2003-03-30 23:52:28 +0000 | [diff] [blame] | 619 | printtv(tcp, tcp->u_arg[1]); |
| 620 | } |
| 621 | return 0; |
| 622 | } |
| 623 | |
| 624 | int |
| 625 | sys_clock_gettime(tcp) |
| 626 | struct tcb *tcp; |
| 627 | { |
| 628 | if (entering(tcp)) { |
Roland McGrath | 54a4edd | 2004-08-31 06:52:45 +0000 | [diff] [blame] | 629 | printxval(clocknames, tcp->u_arg[0], "CLOCK_???"); |
| 630 | tprintf(", "); |
Roland McGrath | 1e35679 | 2003-03-30 23:52:28 +0000 | [diff] [blame] | 631 | } else { |
| 632 | if (syserror(tcp)) |
| 633 | tprintf("%#lx", tcp->u_arg[1]); |
| 634 | else |
| 635 | printtv(tcp, tcp->u_arg[1]); |
| 636 | } |
| 637 | return 0; |
| 638 | } |
| 639 | |
| 640 | int |
| 641 | sys_clock_nanosleep(tcp) |
| 642 | struct tcb *tcp; |
| 643 | { |
| 644 | if (entering(tcp)) { |
Roland McGrath | 54a4edd | 2004-08-31 06:52:45 +0000 | [diff] [blame] | 645 | printxval(clocknames, tcp->u_arg[0], "CLOCK_???"); |
| 646 | tprintf(", "); |
Roland McGrath | b2dee13 | 2005-06-01 19:02:36 +0000 | [diff] [blame] | 647 | printflags(clockflags, tcp->u_arg[1], "TIMER_???"); |
Roland McGrath | 1e35679 | 2003-03-30 23:52:28 +0000 | [diff] [blame] | 648 | tprintf(", "); |
| 649 | printtv(tcp, tcp->u_arg[2]); |
| 650 | tprintf(", "); |
| 651 | } else { |
| 652 | if (syserror(tcp)) |
| 653 | tprintf("%#lx", tcp->u_arg[3]); |
| 654 | else |
| 655 | printtv(tcp, tcp->u_arg[3]); |
| 656 | } |
| 657 | return 0; |
| 658 | } |
| 659 | |
| 660 | #ifndef SIGEV_THREAD_ID |
| 661 | # define SIGEV_THREAD_ID 4 |
| 662 | #endif |
Roland McGrath | d9f816f | 2004-09-04 03:39:20 +0000 | [diff] [blame] | 663 | static const struct xlat sigev_value[] = { |
Roland McGrath | 1e35679 | 2003-03-30 23:52:28 +0000 | [diff] [blame] | 664 | { SIGEV_SIGNAL+1, "SIGEV_SIGNAL" }, |
| 665 | { SIGEV_NONE+1, "SIGEV_NONE" }, |
| 666 | { SIGEV_THREAD+1, "SIGEV_THREAD" }, |
| 667 | { SIGEV_THREAD_ID+1, "SIGEV_THREAD_ID" }, |
| 668 | { 0, NULL } |
| 669 | }; |
| 670 | |
Dmitry V. Levin | d3cb392 | 2006-12-13 17:45:02 +0000 | [diff] [blame] | 671 | #if SUPPORTED_PERSONALITIES > 1 |
| 672 | static void |
| 673 | printsigevent32(struct tcb *tcp, long arg) |
| 674 | { |
| 675 | struct |
| 676 | { |
| 677 | int sigev_value; |
| 678 | int sigev_signo; |
| 679 | int sigev_notify; |
| 680 | |
| 681 | union |
| 682 | { |
| 683 | int tid; |
| 684 | struct |
| 685 | { |
| 686 | int function, attribute; |
| 687 | } thread; |
| 688 | } un; |
| 689 | } sev; |
| 690 | |
| 691 | if (umove(tcp, arg, &sev) < 0) |
| 692 | tprintf("{...}"); |
| 693 | else |
| 694 | { |
| 695 | tprintf("{%#x, ", sev.sigev_value); |
| 696 | if (sev.sigev_notify == SIGEV_SIGNAL) |
| 697 | tprintf("%s, ", signame(sev.sigev_signo)); |
| 698 | else |
| 699 | tprintf("%u, ", sev.sigev_signo); |
| 700 | printxval(sigev_value, sev.sigev_notify + 1, "SIGEV_???"); |
| 701 | tprintf(", "); |
| 702 | if (sev.sigev_notify == SIGEV_THREAD_ID) |
| 703 | tprintf("{%d}", sev.un.tid); |
| 704 | else if (sev.sigev_notify == SIGEV_THREAD) |
| 705 | tprintf("{%#x, %#x}", |
| 706 | sev.un.thread.function, |
| 707 | sev.un.thread.attribute); |
| 708 | else |
| 709 | tprintf("{...}"); |
| 710 | tprintf("}"); |
| 711 | } |
| 712 | } |
| 713 | #endif |
| 714 | |
Roland McGrath | 1e35679 | 2003-03-30 23:52:28 +0000 | [diff] [blame] | 715 | void |
Dmitry V. Levin | d3cb392 | 2006-12-13 17:45:02 +0000 | [diff] [blame] | 716 | printsigevent(struct tcb *tcp, long arg) |
Roland McGrath | 1e35679 | 2003-03-30 23:52:28 +0000 | [diff] [blame] | 717 | { |
| 718 | struct sigevent sev; |
Dmitry V. Levin | d3cb392 | 2006-12-13 17:45:02 +0000 | [diff] [blame] | 719 | |
| 720 | #if SUPPORTED_PERSONALITIES > 1 |
| 721 | if (personality_wordsize[current_personality] == 4) |
| 722 | { |
| 723 | printsigevent32(tcp, arg); |
| 724 | return; |
| 725 | } |
| 726 | #endif |
Roland McGrath | 1e35679 | 2003-03-30 23:52:28 +0000 | [diff] [blame] | 727 | if (umove (tcp, arg, &sev) < 0) |
| 728 | tprintf("{...}"); |
| 729 | else { |
Roland McGrath | 675d4a6 | 2004-09-11 08:12:45 +0000 | [diff] [blame] | 730 | tprintf("{%p, ", sev.sigev_value.sival_ptr); |
| 731 | if (sev.sigev_notify == SIGEV_SIGNAL) |
| 732 | tprintf("%s, ", signame(sev.sigev_signo)); |
| 733 | else |
| 734 | tprintf("%u, ", sev.sigev_signo); |
Roland McGrath | 1e35679 | 2003-03-30 23:52:28 +0000 | [diff] [blame] | 735 | printxval(sigev_value, sev.sigev_notify+1, "SIGEV_???"); |
| 736 | tprintf(", "); |
| 737 | if (sev.sigev_notify == SIGEV_THREAD_ID) |
| 738 | /* _pad[0] is the _tid field which might not be |
| 739 | present in the userlevel definition of the |
| 740 | struct. */ |
| 741 | tprintf("{%d}", sev._sigev_un._pad[0]); |
Roland McGrath | d4c85eb | 2004-04-16 21:48:44 +0000 | [diff] [blame] | 742 | else if (sev.sigev_notify == SIGEV_THREAD) |
| 743 | tprintf("{%p, %p}", sev.sigev_notify_function, |
| 744 | sev.sigev_notify_attributes); |
Roland McGrath | 1e35679 | 2003-03-30 23:52:28 +0000 | [diff] [blame] | 745 | else |
| 746 | tprintf("{...}"); |
| 747 | tprintf("}"); |
| 748 | } |
| 749 | } |
| 750 | |
| 751 | int |
| 752 | sys_timer_create(tcp) |
| 753 | struct tcb *tcp; |
| 754 | { |
| 755 | if (entering(tcp)) { |
Roland McGrath | 675d4a6 | 2004-09-11 08:12:45 +0000 | [diff] [blame] | 756 | printxval(clocknames, tcp->u_arg[0], "CLOCK_???"); |
| 757 | tprintf(", "); |
Roland McGrath | 1e35679 | 2003-03-30 23:52:28 +0000 | [diff] [blame] | 758 | printsigevent(tcp, tcp->u_arg[1]); |
| 759 | tprintf(", "); |
| 760 | } else { |
Dmitry V. Levin | ac518d1 | 2006-12-13 17:03:02 +0000 | [diff] [blame] | 761 | void *p; |
| 762 | |
| 763 | if (syserror(tcp) || umove(tcp, tcp->u_arg[2], &p) < 0) |
Roland McGrath | 1e35679 | 2003-03-30 23:52:28 +0000 | [diff] [blame] | 764 | tprintf("%#lx", tcp->u_arg[2]); |
Dmitry V. Levin | ac518d1 | 2006-12-13 17:03:02 +0000 | [diff] [blame] | 765 | else |
Roland McGrath | 1e35679 | 2003-03-30 23:52:28 +0000 | [diff] [blame] | 766 | tprintf("{%p}", p); |
Roland McGrath | 1e35679 | 2003-03-30 23:52:28 +0000 | [diff] [blame] | 767 | } |
| 768 | return 0; |
| 769 | } |
| 770 | |
| 771 | int |
| 772 | sys_timer_settime(tcp) |
| 773 | struct tcb *tcp; |
| 774 | { |
| 775 | if (entering(tcp)) { |
| 776 | tprintf("%#lx, ", tcp->u_arg[0]); |
Roland McGrath | b2dee13 | 2005-06-01 19:02:36 +0000 | [diff] [blame] | 777 | printflags(clockflags, tcp->u_arg[1], "TIMER_???"); |
Roland McGrath | 1e35679 | 2003-03-30 23:52:28 +0000 | [diff] [blame] | 778 | tprintf(", "); |
| 779 | printitv(tcp, tcp->u_arg[2]); |
| 780 | tprintf(", "); |
| 781 | } else { |
| 782 | if (syserror(tcp)) |
| 783 | tprintf("%#lx", tcp->u_arg[3]); |
| 784 | else |
| 785 | printitv(tcp, tcp->u_arg[3]); |
| 786 | } |
| 787 | return 0; |
| 788 | } |
| 789 | |
| 790 | int |
| 791 | sys_timer_gettime(tcp) |
| 792 | struct tcb *tcp; |
| 793 | { |
| 794 | if (entering(tcp)) { |
| 795 | tprintf("%#lx, ", tcp->u_arg[0]); |
| 796 | } else { |
| 797 | if (syserror(tcp)) |
| 798 | tprintf("%#lx", tcp->u_arg[1]); |
| 799 | else |
| 800 | printitv(tcp, tcp->u_arg[1]); |
| 801 | } |
| 802 | return 0; |
| 803 | } |
Roland McGrath | d83c50b | 2004-10-06 22:27:43 +0000 | [diff] [blame] | 804 | |
| 805 | static void |
| 806 | print_rtc(tcp, rt) |
| 807 | struct tcb *tcp; |
| 808 | const struct rtc_time *rt; |
| 809 | { |
| 810 | tprintf("{tm_sec=%d, tm_min=%d, tm_hour=%d, " |
| 811 | "tm_mday=%d, tm_mon=%d, tm_year=%d, ", |
| 812 | rt->tm_sec, rt->tm_min, rt->tm_hour, |
| 813 | rt->tm_mday, rt->tm_mon, rt->tm_year); |
| 814 | if (!abbrev(tcp)) |
| 815 | tprintf("tm_wday=%d, tm_yday=%d, tm_isdst=%d}", |
| 816 | rt->tm_wday, rt->tm_yday, rt->tm_isdst); |
| 817 | else |
| 818 | tprintf("...}"); |
| 819 | } |
| 820 | |
| 821 | int |
| 822 | rtc_ioctl(tcp, code, arg) |
| 823 | struct tcb *tcp; |
| 824 | long code; |
| 825 | long arg; |
| 826 | { |
| 827 | switch (code) { |
| 828 | case RTC_ALM_SET: |
| 829 | case RTC_SET_TIME: |
| 830 | if (entering(tcp)) { |
| 831 | struct rtc_time rt; |
| 832 | if (umove(tcp, arg, &rt) < 0) |
| 833 | tprintf(", %#lx", arg); |
| 834 | else { |
| 835 | tprintf(", "); |
| 836 | print_rtc(tcp, &rt); |
| 837 | } |
| 838 | } |
| 839 | break; |
| 840 | case RTC_ALM_READ: |
| 841 | case RTC_RD_TIME: |
| 842 | if (exiting(tcp)) { |
| 843 | struct rtc_time rt; |
| 844 | if (syserror(tcp) || umove(tcp, arg, &rt) < 0) |
| 845 | tprintf(", %#lx", arg); |
| 846 | else { |
| 847 | tprintf(", "); |
| 848 | print_rtc(tcp, &rt); |
| 849 | } |
| 850 | } |
| 851 | break; |
| 852 | case RTC_IRQP_SET: |
| 853 | case RTC_EPOCH_SET: |
| 854 | if (entering(tcp)) |
| 855 | tprintf(", %lu", arg); |
| 856 | break; |
| 857 | case RTC_IRQP_READ: |
| 858 | case RTC_EPOCH_READ: |
| 859 | if (exiting(tcp)) |
| 860 | tprintf(", %lu", arg); |
| 861 | break; |
| 862 | case RTC_WKALM_SET: |
| 863 | if (entering(tcp)) { |
| 864 | struct rtc_wkalrm wk; |
| 865 | if (umove(tcp, arg, &wk) < 0) |
| 866 | tprintf(", %#lx", arg); |
| 867 | else { |
| 868 | tprintf(", {enabled=%d, pending=%d, ", |
| 869 | wk.enabled, wk.pending); |
| 870 | print_rtc(tcp, &wk.time); |
| 871 | tprintf("}"); |
| 872 | } |
| 873 | } |
| 874 | break; |
| 875 | case RTC_WKALM_RD: |
| 876 | if (exiting(tcp)) { |
| 877 | struct rtc_wkalrm wk; |
| 878 | if (syserror(tcp) || umove(tcp, arg, &wk) < 0) |
| 879 | tprintf(", %#lx", arg); |
| 880 | else { |
| 881 | tprintf(", {enabled=%d, pending=%d, ", |
| 882 | wk.enabled, wk.pending); |
| 883 | print_rtc(tcp, &wk.time); |
| 884 | tprintf("}"); |
| 885 | } |
| 886 | } |
| 887 | break; |
| 888 | default: |
| 889 | if (entering(tcp)) |
| 890 | tprintf(", %#lx", arg); |
| 891 | break; |
| 892 | } |
| 893 | return 1; |
| 894 | } |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 895 | #endif /* LINUX */ |