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. |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 28 | */ |
| 29 | |
| 30 | #include "defs.h" |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 31 | #include <linux/version.h> |
Wichert Akkerman | d856b99 | 2000-10-13 12:47:12 +0000 | [diff] [blame] | 32 | #include <sys/timex.h> |
Roland McGrath | d83c50b | 2004-10-06 22:27:43 +0000 | [diff] [blame] | 33 | #include <linux/ioctl.h> |
| 34 | #include <linux/rtc.h> |
Roland McGrath | 6afc565 | 2007-07-24 01:57:11 +0000 | [diff] [blame] | 35 | |
| 36 | #ifndef UTIME_NOW |
| 37 | #define UTIME_NOW ((1l << 30) - 1l) |
| 38 | #endif |
| 39 | #ifndef UTIME_OMIT |
| 40 | #define UTIME_OMIT ((1l << 30) - 2l) |
| 41 | #endif |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 42 | |
Dmitry V. Levin | a7945a3 | 2006-12-13 17:10:11 +0000 | [diff] [blame] | 43 | struct timeval32 |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 44 | { |
Dmitry V. Levin | a7945a3 | 2006-12-13 17:10:11 +0000 | [diff] [blame] | 45 | u_int32_t tv_sec, tv_usec; |
| 46 | }; |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 47 | |
Dmitry V. Levin | 1cad25d | 2006-12-13 17:14:36 +0000 | [diff] [blame] | 48 | static void |
| 49 | tprint_timeval32(struct tcb *tcp, const struct timeval32 *tv) |
| 50 | { |
| 51 | tprintf("{%u, %u}", tv->tv_sec, tv->tv_usec); |
| 52 | } |
| 53 | |
| 54 | static void |
| 55 | tprint_timeval(struct tcb *tcp, const struct timeval *tv) |
| 56 | { |
| 57 | tprintf("{%lu, %lu}", |
| 58 | (unsigned long) tv->tv_sec, (unsigned long) tv->tv_usec); |
| 59 | } |
| 60 | |
Dmitry V. Levin | a7945a3 | 2006-12-13 17:10:11 +0000 | [diff] [blame] | 61 | void |
Roland McGrath | 6afc565 | 2007-07-24 01:57:11 +0000 | [diff] [blame] | 62 | 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] | 63 | { |
Denys Vlasenko | a1d541e | 2012-01-20 11:04:04 +0100 | [diff] [blame] | 64 | char buf[TIMEVAL_TEXT_BUFSIZE]; |
| 65 | sprinttv(buf, tcp, addr, bitness, special); |
| 66 | tprints(buf); |
Dmitry V. Levin | a7945a3 | 2006-12-13 17:10:11 +0000 | [diff] [blame] | 67 | } |
Wichert Akkerman | 221f54f | 1999-11-18 17:26:45 +0000 | [diff] [blame] | 68 | |
Dmitry V. Levin | ee21a5b | 2014-12-26 23:55:38 +0000 | [diff] [blame^] | 69 | static char * |
| 70 | do_sprinttv(char *buf, const unsigned long sec, const unsigned long usec, |
| 71 | const int special) |
| 72 | { |
| 73 | if (special) { |
| 74 | switch (usec) { |
| 75 | case UTIME_NOW: |
| 76 | return stpcpy(buf, "UTIME_NOW"); |
| 77 | case UTIME_OMIT: |
| 78 | return stpcpy(buf, "UTIME_OMIT"); |
| 79 | } |
| 80 | } |
| 81 | return buf + sprintf(buf, "{%lu, %lu}", sec, usec); |
| 82 | } |
| 83 | |
Denys Vlasenko | 2fb4db3 | 2011-08-31 12:26:03 +0200 | [diff] [blame] | 84 | char * |
Denys Vlasenko | a1d541e | 2012-01-20 11:04:04 +0100 | [diff] [blame] | 85 | sprinttv(char *buf, struct tcb *tcp, long addr, enum bitness_t bitness, int special) |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 86 | { |
Dmitry V. Levin | a7945a3 | 2006-12-13 17:10:11 +0000 | [diff] [blame] | 87 | if (addr == 0) |
Denys Vlasenko | 2fb4db3 | 2011-08-31 12:26:03 +0200 | [diff] [blame] | 88 | return stpcpy(buf, "NULL"); |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 89 | |
Denys Vlasenko | b9c7ae6 | 2011-09-01 11:40:40 +0200 | [diff] [blame] | 90 | if (!verbose(tcp)) |
| 91 | return buf + sprintf(buf, "%#lx", addr); |
Denys Vlasenko | 2fb4db3 | 2011-08-31 12:26:03 +0200 | [diff] [blame] | 92 | |
| 93 | if (bitness == BITNESS_32 |
Denys Vlasenko | 8470374 | 2012-02-25 02:38:52 +0100 | [diff] [blame] | 94 | #if SUPPORTED_PERSONALITIES > 1 |
Denys Vlasenko | 9fd4f96 | 2012-03-19 09:36:42 +0100 | [diff] [blame] | 95 | || current_wordsize == 4 |
Denys Vlasenko | 2fb4db3 | 2011-08-31 12:26:03 +0200 | [diff] [blame] | 96 | #endif |
| 97 | ) |
| 98 | { |
| 99 | struct timeval32 tv; |
| 100 | |
Dmitry V. Levin | ee21a5b | 2014-12-26 23:55:38 +0000 | [diff] [blame^] | 101 | if (umove(tcp, addr, &tv) >= 0) |
| 102 | return do_sprinttv(buf, tv.tv_sec, tv.tv_usec, special); |
Denys Vlasenko | 2fb4db3 | 2011-08-31 12:26:03 +0200 | [diff] [blame] | 103 | } else { |
| 104 | struct timeval tv; |
| 105 | |
Dmitry V. Levin | ee21a5b | 2014-12-26 23:55:38 +0000 | [diff] [blame^] | 106 | if (umove(tcp, addr, &tv) >= 0) |
| 107 | return do_sprinttv(buf, tv.tv_sec, tv.tv_usec, special); |
Denys Vlasenko | 2fb4db3 | 2011-08-31 12:26:03 +0200 | [diff] [blame] | 108 | } |
Denys Vlasenko | 2fb4db3 | 2011-08-31 12:26:03 +0200 | [diff] [blame] | 109 | |
Denys Vlasenko | b9c7ae6 | 2011-09-01 11:40:40 +0200 | [diff] [blame] | 110 | return stpcpy(buf, "{...}"); |
Dmitry V. Levin | a7945a3 | 2006-12-13 17:10:11 +0000 | [diff] [blame] | 111 | } |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 112 | |
Denys Vlasenko | a1d541e | 2012-01-20 11:04:04 +0100 | [diff] [blame] | 113 | void |
| 114 | print_timespec(struct tcb *tcp, long addr) |
Roland McGrath | 6bc09da | 2007-11-01 21:50:54 +0000 | [diff] [blame] | 115 | { |
Denys Vlasenko | a1d541e | 2012-01-20 11:04:04 +0100 | [diff] [blame] | 116 | char buf[TIMESPEC_TEXT_BUFSIZE]; |
| 117 | sprint_timespec(buf, tcp, addr); |
| 118 | tprints(buf); |
Roland McGrath | 6bc09da | 2007-11-01 21:50:54 +0000 | [diff] [blame] | 119 | } |
| 120 | |
Denys Vlasenko | a1d541e | 2012-01-20 11:04:04 +0100 | [diff] [blame] | 121 | void |
| 122 | sprint_timespec(char *buf, struct tcb *tcp, long addr) |
Roland McGrath | 6bc09da | 2007-11-01 21:50:54 +0000 | [diff] [blame] | 123 | { |
| 124 | if (addr == 0) |
| 125 | strcpy(buf, "NULL"); |
| 126 | else if (!verbose(tcp)) |
| 127 | sprintf(buf, "%#lx", addr); |
| 128 | else { |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 129 | int rc; |
Roland McGrath | 6bc09da | 2007-11-01 21:50:54 +0000 | [diff] [blame] | 130 | |
Denys Vlasenko | 8470374 | 2012-02-25 02:38:52 +0100 | [diff] [blame] | 131 | #if SUPPORTED_PERSONALITIES > 1 |
Denys Vlasenko | 9fd4f96 | 2012-03-19 09:36:42 +0100 | [diff] [blame] | 132 | if (current_wordsize == 4) { |
Roland McGrath | 6bc09da | 2007-11-01 21:50:54 +0000 | [diff] [blame] | 133 | struct timeval32 tv; |
| 134 | |
Denys Vlasenko | 5d64581 | 2011-08-20 12:48:18 +0200 | [diff] [blame] | 135 | rc = umove(tcp, addr, &tv); |
| 136 | if (rc >= 0) |
Roland McGrath | 6bc09da | 2007-11-01 21:50:54 +0000 | [diff] [blame] | 137 | sprintf(buf, "{%u, %u}", |
| 138 | tv.tv_sec, tv.tv_usec); |
| 139 | } else |
Roland McGrath | 6bc09da | 2007-11-01 21:50:54 +0000 | [diff] [blame] | 140 | #endif |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 141 | { |
Roland McGrath | 6bc09da | 2007-11-01 21:50:54 +0000 | [diff] [blame] | 142 | struct timespec ts; |
| 143 | |
Denys Vlasenko | 5d64581 | 2011-08-20 12:48:18 +0200 | [diff] [blame] | 144 | rc = umove(tcp, addr, &ts); |
| 145 | if (rc >= 0) |
Roland McGrath | 6bc09da | 2007-11-01 21:50:54 +0000 | [diff] [blame] | 146 | sprintf(buf, "{%lu, %lu}", |
| 147 | (unsigned long) ts.tv_sec, |
| 148 | (unsigned long) ts.tv_nsec); |
Roland McGrath | 6bc09da | 2007-11-01 21:50:54 +0000 | [diff] [blame] | 149 | } |
Roland McGrath | 6bc09da | 2007-11-01 21:50:54 +0000 | [diff] [blame] | 150 | if (rc < 0) |
| 151 | strcpy(buf, "{...}"); |
| 152 | } |
| 153 | } |
| 154 | |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 155 | int |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 156 | sys_time(struct tcb *tcp) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 157 | { |
| 158 | if (exiting(tcp)) { |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 159 | printnum(tcp, tcp->u_arg[0], "%ld"); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 160 | } |
| 161 | return 0; |
| 162 | } |
| 163 | |
| 164 | int |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 165 | sys_gettimeofday(struct tcb *tcp) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 166 | { |
| 167 | if (exiting(tcp)) { |
| 168 | if (syserror(tcp)) { |
| 169 | tprintf("%#lx, %#lx", |
| 170 | tcp->u_arg[0], tcp->u_arg[1]); |
| 171 | return 0; |
| 172 | } |
| 173 | printtv(tcp, tcp->u_arg[0]); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 174 | tprints(", "); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 175 | printtv(tcp, tcp->u_arg[1]); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 176 | } |
| 177 | return 0; |
| 178 | } |
| 179 | |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 180 | #ifdef ALPHA |
| 181 | int |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 182 | sys_osf_gettimeofday(struct tcb *tcp) |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 183 | { |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 184 | if (exiting(tcp)) { |
| 185 | if (syserror(tcp)) { |
| 186 | tprintf("%#lx, %#lx", tcp->u_arg[0], tcp->u_arg[1]); |
| 187 | return 0; |
| 188 | } |
| 189 | printtv_bitness(tcp, tcp->u_arg[0], BITNESS_32, 0); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 190 | tprints(", "); |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 191 | printtv_bitness(tcp, tcp->u_arg[1], BITNESS_32, 0); |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 192 | } |
| 193 | return 0; |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 194 | } |
| 195 | #endif |
| 196 | |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 197 | int |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 198 | sys_settimeofday(struct tcb *tcp) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 199 | { |
| 200 | if (entering(tcp)) { |
| 201 | printtv(tcp, tcp->u_arg[0]); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 202 | tprints(", "); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 203 | printtv(tcp, tcp->u_arg[1]); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 204 | } |
| 205 | return 0; |
| 206 | } |
| 207 | |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 208 | #ifdef ALPHA |
| 209 | int |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 210 | sys_osf_settimeofday(struct tcb *tcp) |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 211 | { |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 212 | if (entering(tcp)) { |
| 213 | printtv_bitness(tcp, tcp->u_arg[0], BITNESS_32, 0); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 214 | tprints(", "); |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 215 | printtv_bitness(tcp, tcp->u_arg[1], BITNESS_32, 0); |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 216 | } |
| 217 | return 0; |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 218 | } |
| 219 | #endif |
| 220 | |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 221 | int |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 222 | sys_adjtime(struct tcb *tcp) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 223 | { |
| 224 | if (entering(tcp)) { |
| 225 | printtv(tcp, tcp->u_arg[0]); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 226 | tprints(", "); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 227 | } else { |
| 228 | if (syserror(tcp)) |
| 229 | tprintf("%#lx", tcp->u_arg[1]); |
| 230 | else |
| 231 | printtv(tcp, tcp->u_arg[1]); |
| 232 | } |
| 233 | return 0; |
| 234 | } |
| 235 | |
Dmitry V. Levin | 2e55ff4 | 2008-09-03 01:02:46 +0000 | [diff] [blame] | 236 | int |
| 237 | sys_nanosleep(struct tcb *tcp) |
| 238 | { |
| 239 | if (entering(tcp)) { |
| 240 | print_timespec(tcp, tcp->u_arg[0]); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 241 | tprints(", "); |
Dmitry V. Levin | 2e55ff4 | 2008-09-03 01:02:46 +0000 | [diff] [blame] | 242 | } else { |
Denys Vlasenko | 64acaa1 | 2012-01-28 02:29:36 +0100 | [diff] [blame] | 243 | /* Second (returned) timespec is only significant |
Denys Vlasenko | 4793221 | 2013-06-30 23:53:49 +0200 | [diff] [blame] | 244 | * if syscall was interrupted. On success, we print |
| 245 | * only its address, since kernel doesn't modify it, |
| 246 | * and printing the value may show uninitialized data. |
Denys Vlasenko | 64acaa1 | 2012-01-28 02:29:36 +0100 | [diff] [blame] | 247 | */ |
Denys Vlasenko | 4793221 | 2013-06-30 23:53:49 +0200 | [diff] [blame] | 248 | switch (tcp->u_error) { |
| 249 | default: |
| 250 | /* Not interrupted (slept entire interval) */ |
| 251 | if (tcp->u_arg[1]) { |
| 252 | tprintf("%#lx", tcp->u_arg[1]); |
| 253 | break; |
| 254 | } |
| 255 | /* Fall through: print_timespec(NULL) prints "NULL" */ |
| 256 | case ERESTARTSYS: |
| 257 | case ERESTARTNOINTR: |
| 258 | case ERESTARTNOHAND: |
| 259 | case ERESTART_RESTARTBLOCK: |
| 260 | /* Interrupted */ |
Dmitry V. Levin | 2e55ff4 | 2008-09-03 01:02:46 +0000 | [diff] [blame] | 261 | print_timespec(tcp, tcp->u_arg[1]); |
Denys Vlasenko | 4793221 | 2013-06-30 23:53:49 +0200 | [diff] [blame] | 262 | } |
Dmitry V. Levin | 2e55ff4 | 2008-09-03 01:02:46 +0000 | [diff] [blame] | 263 | } |
| 264 | return 0; |
| 265 | } |
| 266 | |
Dmitry V. Levin | 0ed617b | 2014-04-25 23:30:54 +0000 | [diff] [blame] | 267 | #include "xlat/itimer_which.h" |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 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) |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 273 | tprints("NULL"); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 274 | else if (!verbose(tcp)) |
| 275 | tprintf("%#lx", addr); |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 276 | else { |
| 277 | int rc; |
Dmitry V. Levin | 1cad25d | 2006-12-13 17:14:36 +0000 | [diff] [blame] | 278 | |
| 279 | if (bitness == BITNESS_32 |
Denys Vlasenko | 8470374 | 2012-02-25 02:38:52 +0100 | [diff] [blame] | 280 | #if SUPPORTED_PERSONALITIES > 1 |
Denys Vlasenko | 9fd4f96 | 2012-03-19 09:36:42 +0100 | [diff] [blame] | 281 | || current_wordsize == 4 |
Dmitry V. Levin | 1cad25d | 2006-12-13 17:14:36 +0000 | [diff] [blame] | 282 | #endif |
| 283 | ) |
| 284 | { |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 285 | struct { |
Dmitry V. Levin | 1cad25d | 2006-12-13 17:14:36 +0000 | [diff] [blame] | 286 | struct timeval32 it_interval, it_value; |
| 287 | } itv; |
| 288 | |
Denys Vlasenko | 5d64581 | 2011-08-20 12:48:18 +0200 | [diff] [blame] | 289 | rc = umove(tcp, addr, &itv); |
| 290 | if (rc >= 0) { |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 291 | tprints("{it_interval="); |
Dmitry V. Levin | 1cad25d | 2006-12-13 17:14:36 +0000 | [diff] [blame] | 292 | tprint_timeval32(tcp, &itv.it_interval); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 293 | tprints(", it_value="); |
Dmitry V. Levin | 1cad25d | 2006-12-13 17:14:36 +0000 | [diff] [blame] | 294 | tprint_timeval32(tcp, &itv.it_value); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 295 | tprints("}"); |
Roland McGrath | e466234 | 2007-08-02 01:25:34 +0000 | [diff] [blame] | 296 | } |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 297 | } else { |
Dmitry V. Levin | 1cad25d | 2006-12-13 17:14:36 +0000 | [diff] [blame] | 298 | struct itimerval itv; |
| 299 | |
Denys Vlasenko | 5d64581 | 2011-08-20 12:48:18 +0200 | [diff] [blame] | 300 | rc = umove(tcp, addr, &itv); |
| 301 | if (rc >= 0) { |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 302 | tprints("{it_interval="); |
Dmitry V. Levin | 1cad25d | 2006-12-13 17:14:36 +0000 | [diff] [blame] | 303 | tprint_timeval(tcp, &itv.it_interval); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 304 | tprints(", it_value="); |
Dmitry V. Levin | 1cad25d | 2006-12-13 17:14:36 +0000 | [diff] [blame] | 305 | tprint_timeval(tcp, &itv.it_value); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 306 | tprints("}"); |
Roland McGrath | e466234 | 2007-08-02 01:25:34 +0000 | [diff] [blame] | 307 | } |
Dmitry V. Levin | 1cad25d | 2006-12-13 17:14:36 +0000 | [diff] [blame] | 308 | } |
Dmitry V. Levin | 1cad25d | 2006-12-13 17:14:36 +0000 | [diff] [blame] | 309 | if (rc < 0) |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 310 | tprints("{...}"); |
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 |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 318 | sys_getitimer(struct tcb *tcp) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 319 | { |
| 320 | if (entering(tcp)) { |
Dmitry V. Levin | 297b594 | 2014-04-25 23:39:20 +0000 | [diff] [blame] | 321 | printxval(itimer_which, tcp->u_arg[0], "ITIMER_???"); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 322 | tprints(", "); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 323 | } else { |
| 324 | if (syserror(tcp)) |
| 325 | tprintf("%#lx", tcp->u_arg[1]); |
| 326 | else |
| 327 | printitv(tcp, tcp->u_arg[1]); |
| 328 | } |
| 329 | return 0; |
| 330 | } |
| 331 | |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 332 | #ifdef ALPHA |
| 333 | int |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 334 | sys_osf_getitimer(struct tcb *tcp) |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 335 | { |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 336 | if (entering(tcp)) { |
Dmitry V. Levin | 297b594 | 2014-04-25 23:39:20 +0000 | [diff] [blame] | 337 | printxval(itimer_which, tcp->u_arg[0], "ITIMER_???"); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 338 | tprints(", "); |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 339 | } else { |
| 340 | if (syserror(tcp)) |
| 341 | tprintf("%#lx", tcp->u_arg[1]); |
| 342 | else |
| 343 | printitv_bitness(tcp, tcp->u_arg[1], BITNESS_32); |
| 344 | } |
| 345 | return 0; |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 346 | } |
| 347 | #endif |
| 348 | |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 349 | int |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 350 | sys_setitimer(struct tcb *tcp) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 351 | { |
| 352 | if (entering(tcp)) { |
Dmitry V. Levin | 297b594 | 2014-04-25 23:39:20 +0000 | [diff] [blame] | 353 | printxval(itimer_which, tcp->u_arg[0], "ITIMER_???"); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 354 | tprints(", "); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 355 | printitv(tcp, tcp->u_arg[1]); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 356 | tprints(", "); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 357 | } else { |
| 358 | if (syserror(tcp)) |
| 359 | tprintf("%#lx", tcp->u_arg[2]); |
| 360 | else |
| 361 | printitv(tcp, tcp->u_arg[2]); |
| 362 | } |
| 363 | return 0; |
| 364 | } |
| 365 | |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 366 | #ifdef ALPHA |
| 367 | int |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 368 | sys_osf_setitimer(struct tcb *tcp) |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 369 | { |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 370 | if (entering(tcp)) { |
Dmitry V. Levin | 297b594 | 2014-04-25 23:39:20 +0000 | [diff] [blame] | 371 | printxval(itimer_which, tcp->u_arg[0], "ITIMER_???"); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 372 | tprints(", "); |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 373 | printitv_bitness(tcp, tcp->u_arg[1], BITNESS_32); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 374 | tprints(", "); |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 375 | } else { |
| 376 | if (syserror(tcp)) |
| 377 | tprintf("%#lx", tcp->u_arg[2]); |
| 378 | else |
| 379 | printitv_bitness(tcp, tcp->u_arg[2], BITNESS_32); |
| 380 | } |
| 381 | return 0; |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 382 | } |
| 383 | #endif |
| 384 | |
Dmitry V. Levin | 0ed617b | 2014-04-25 23:30:54 +0000 | [diff] [blame] | 385 | #include "xlat/adjtimex_modes.h" |
Dmitry V. Levin | 0ed617b | 2014-04-25 23:30:54 +0000 | [diff] [blame] | 386 | #include "xlat/adjtimex_status.h" |
Dmitry V. Levin | 0ed617b | 2014-04-25 23:30:54 +0000 | [diff] [blame] | 387 | #include "xlat/adjtimex_state.h" |
Dmitry V. Levin | 1a684d6 | 2006-12-13 17:42:32 +0000 | [diff] [blame] | 388 | |
Dmitry V. Levin | 165b15d | 2006-12-13 17:43:45 +0000 | [diff] [blame] | 389 | #if SUPPORTED_PERSONALITIES > 1 |
| 390 | static int |
| 391 | tprint_timex32(struct tcb *tcp, long addr) |
| 392 | { |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 393 | struct { |
Dmitry V. Levin | 165b15d | 2006-12-13 17:43:45 +0000 | [diff] [blame] | 394 | unsigned int modes; |
| 395 | int offset; |
| 396 | int freq; |
| 397 | int maxerror; |
| 398 | int esterror; |
| 399 | int status; |
| 400 | int constant; |
| 401 | int precision; |
| 402 | int tolerance; |
| 403 | struct timeval32 time; |
| 404 | int tick; |
| 405 | int ppsfreq; |
| 406 | int jitter; |
| 407 | int shift; |
| 408 | int stabil; |
| 409 | int jitcnt; |
| 410 | int calcnt; |
| 411 | int errcnt; |
| 412 | int stbcnt; |
| 413 | } tx; |
| 414 | |
| 415 | if (umove(tcp, addr, &tx) < 0) |
| 416 | return -1; |
| 417 | |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 418 | tprints("{modes="); |
Dmitry V. Levin | 71d7089 | 2007-01-13 11:17:38 +0000 | [diff] [blame] | 419 | printflags(adjtimex_modes, tx.modes, "ADJ_???"); |
Dmitry V. Levin | 165b15d | 2006-12-13 17:43:45 +0000 | [diff] [blame] | 420 | tprintf(", offset=%d, freq=%d, maxerror=%d, ", |
| 421 | tx.offset, tx.freq, tx.maxerror); |
| 422 | tprintf("esterror=%u, status=", tx.esterror); |
| 423 | printflags(adjtimex_status, tx.status, "STA_???"); |
| 424 | tprintf(", constant=%d, precision=%u, ", |
| 425 | tx.constant, tx.precision); |
| 426 | tprintf("tolerance=%d, time=", tx.tolerance); |
| 427 | tprint_timeval32(tcp, &tx.time); |
| 428 | tprintf(", tick=%d, ppsfreq=%d, jitter=%d", |
| 429 | tx.tick, tx.ppsfreq, tx.jitter); |
| 430 | tprintf(", shift=%d, stabil=%d, jitcnt=%d", |
| 431 | tx.shift, tx.stabil, tx.jitcnt); |
| 432 | tprintf(", calcnt=%d, errcnt=%d, stbcnt=%d", |
| 433 | tx.calcnt, tx.errcnt, tx.stbcnt); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 434 | tprints("}"); |
Dmitry V. Levin | 165b15d | 2006-12-13 17:43:45 +0000 | [diff] [blame] | 435 | return 0; |
| 436 | } |
| 437 | #endif /* SUPPORTED_PERSONALITIES > 1 */ |
| 438 | |
| 439 | static int |
| 440 | tprint_timex(struct tcb *tcp, long addr) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 441 | { |
Dmitry V. Levin | 1a684d6 | 2006-12-13 17:42:32 +0000 | [diff] [blame] | 442 | struct timex tx; |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 443 | |
Dmitry V. Levin | 165b15d | 2006-12-13 17:43:45 +0000 | [diff] [blame] | 444 | #if SUPPORTED_PERSONALITIES > 1 |
Denys Vlasenko | 9fd4f96 | 2012-03-19 09:36:42 +0100 | [diff] [blame] | 445 | if (current_wordsize == 4) |
Dmitry V. Levin | 165b15d | 2006-12-13 17:43:45 +0000 | [diff] [blame] | 446 | return tprint_timex32(tcp, addr); |
| 447 | #endif |
| 448 | if (umove(tcp, addr, &tx) < 0) |
| 449 | return -1; |
| 450 | |
| 451 | #if LINUX_VERSION_CODE < 66332 |
| 452 | tprintf("{mode=%d, offset=%ld, frequency=%ld, ", |
| 453 | tx.mode, tx.offset, tx.frequency); |
| 454 | tprintf("maxerror=%ld, esterror=%lu, status=%u, ", |
| 455 | tx.maxerror, tx.esterror, tx.status); |
| 456 | tprintf("time_constant=%ld, precision=%lu, ", |
| 457 | tx.time_constant, tx.precision); |
| 458 | tprintf("tolerance=%ld, time=", tx.tolerance); |
| 459 | tprint_timeval(tcp, &tx.time); |
| 460 | #else |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 461 | tprints("{modes="); |
Dmitry V. Levin | 71d7089 | 2007-01-13 11:17:38 +0000 | [diff] [blame] | 462 | printflags(adjtimex_modes, tx.modes, "ADJ_???"); |
Dmitry V. Levin | 165b15d | 2006-12-13 17:43:45 +0000 | [diff] [blame] | 463 | tprintf(", offset=%ld, freq=%ld, maxerror=%ld, ", |
H.J. Lu | 0b315b6 | 2012-02-03 10:16:03 -0800 | [diff] [blame] | 464 | (long) tx.offset, (long) tx.freq, (long) tx.maxerror); |
| 465 | tprintf("esterror=%lu, status=", (long) tx.esterror); |
Dmitry V. Levin | 165b15d | 2006-12-13 17:43:45 +0000 | [diff] [blame] | 466 | printflags(adjtimex_status, tx.status, "STA_???"); |
| 467 | tprintf(", constant=%ld, precision=%lu, ", |
H.J. Lu | 0b315b6 | 2012-02-03 10:16:03 -0800 | [diff] [blame] | 468 | (long) tx.constant, (long) tx.precision); |
| 469 | tprintf("tolerance=%ld, time=", (long) tx.tolerance); |
Dmitry V. Levin | 165b15d | 2006-12-13 17:43:45 +0000 | [diff] [blame] | 470 | tprint_timeval(tcp, &tx.time); |
| 471 | tprintf(", tick=%ld, ppsfreq=%ld, jitter=%ld", |
H.J. Lu | 0b315b6 | 2012-02-03 10:16:03 -0800 | [diff] [blame] | 472 | (long) tx.tick, (long) tx.ppsfreq, (long) tx.jitter); |
Dmitry V. Levin | 165b15d | 2006-12-13 17:43:45 +0000 | [diff] [blame] | 473 | tprintf(", shift=%d, stabil=%ld, jitcnt=%ld", |
H.J. Lu | 0b315b6 | 2012-02-03 10:16:03 -0800 | [diff] [blame] | 474 | tx.shift, (long) tx.stabil, (long) tx.jitcnt); |
Dmitry V. Levin | 165b15d | 2006-12-13 17:43:45 +0000 | [diff] [blame] | 475 | tprintf(", calcnt=%ld, errcnt=%ld, stbcnt=%ld", |
H.J. Lu | 0b315b6 | 2012-02-03 10:16:03 -0800 | [diff] [blame] | 476 | (long) tx.calcnt, (long) tx.errcnt, (long) tx.stbcnt); |
Dmitry V. Levin | 165b15d | 2006-12-13 17:43:45 +0000 | [diff] [blame] | 477 | #endif |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 478 | tprints("}"); |
Dmitry V. Levin | 165b15d | 2006-12-13 17:43:45 +0000 | [diff] [blame] | 479 | return 0; |
| 480 | } |
| 481 | |
Dmitry V. Levin | 7321547 | 2012-03-11 21:25:51 +0000 | [diff] [blame] | 482 | static int |
| 483 | do_adjtimex(struct tcb *tcp, long addr) |
| 484 | { |
| 485 | if (addr == 0) |
| 486 | tprints("NULL"); |
| 487 | else if (syserror(tcp) || !verbose(tcp)) |
| 488 | tprintf("%#lx", addr); |
| 489 | else if (tprint_timex(tcp, addr) < 0) |
| 490 | tprints("{...}"); |
| 491 | if (syserror(tcp)) |
| 492 | return 0; |
| 493 | tcp->auxstr = xlookup(adjtimex_state, tcp->u_rval); |
| 494 | if (tcp->auxstr) |
| 495 | return RVAL_STR; |
| 496 | return 0; |
| 497 | } |
| 498 | |
Dmitry V. Levin | 165b15d | 2006-12-13 17:43:45 +0000 | [diff] [blame] | 499 | int |
| 500 | sys_adjtimex(struct tcb *tcp) |
| 501 | { |
Dmitry V. Levin | 7321547 | 2012-03-11 21:25:51 +0000 | [diff] [blame] | 502 | if (exiting(tcp)) |
| 503 | return do_adjtimex(tcp, tcp->u_arg[0]); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 504 | return 0; |
| 505 | } |
Roland McGrath | 1e35679 | 2003-03-30 23:52:28 +0000 | [diff] [blame] | 506 | |
Dmitry V. Levin | 0ed617b | 2014-04-25 23:30:54 +0000 | [diff] [blame] | 507 | #include "xlat/clockflags.h" |
Dmitry V. Levin | 0ed617b | 2014-04-25 23:30:54 +0000 | [diff] [blame] | 508 | #include "xlat/clocknames.h" |
Roland McGrath | 54a4edd | 2004-08-31 06:52:45 +0000 | [diff] [blame] | 509 | |
Stefan Sørensen | a5fea90 | 2014-02-03 10:01:27 +0100 | [diff] [blame] | 510 | static void |
| 511 | printclockname(int clockid) |
| 512 | { |
| 513 | #ifdef CLOCKID_TO_FD |
Dmitry V. Levin | d35bdca | 2014-04-26 18:10:19 +0000 | [diff] [blame] | 514 | # include "xlat/cpuclocknames.h" |
| 515 | |
Stefan Sørensen | a5fea90 | 2014-02-03 10:01:27 +0100 | [diff] [blame] | 516 | if (clockid < 0) { |
| 517 | if ((clockid & CLOCKFD_MASK) == CLOCKFD) |
| 518 | tprintf("FD_TO_CLOCKID(%d)", CLOCKID_TO_FD(clockid)); |
| 519 | else { |
| 520 | if(CPUCLOCK_PERTHREAD(clockid)) |
| 521 | tprintf("MAKE_THREAD_CPUCLOCK(%d,", CPUCLOCK_PID(clockid)); |
| 522 | else |
| 523 | tprintf("MAKE_PROCESS_CPUCLOCK(%d,", CPUCLOCK_PID(clockid)); |
| 524 | printxval(cpuclocknames, clockid & CLOCKFD_MASK, "CPUCLOCK_???"); |
| 525 | tprints(")"); |
| 526 | } |
| 527 | } |
| 528 | else |
| 529 | #endif |
| 530 | printxval(clocknames, clockid, "CLOCK_???"); |
| 531 | } |
| 532 | |
Roland McGrath | 1e35679 | 2003-03-30 23:52:28 +0000 | [diff] [blame] | 533 | int |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 534 | sys_clock_settime(struct tcb *tcp) |
Roland McGrath | 1e35679 | 2003-03-30 23:52:28 +0000 | [diff] [blame] | 535 | { |
| 536 | if (entering(tcp)) { |
Stefan Sørensen | a5fea90 | 2014-02-03 10:01:27 +0100 | [diff] [blame] | 537 | printclockname(tcp->u_arg[0]); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 538 | tprints(", "); |
Roland McGrath | 1e35679 | 2003-03-30 23:52:28 +0000 | [diff] [blame] | 539 | printtv(tcp, tcp->u_arg[1]); |
| 540 | } |
| 541 | return 0; |
| 542 | } |
| 543 | |
| 544 | int |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 545 | sys_clock_gettime(struct tcb *tcp) |
Roland McGrath | 1e35679 | 2003-03-30 23:52:28 +0000 | [diff] [blame] | 546 | { |
| 547 | if (entering(tcp)) { |
Stefan Sørensen | a5fea90 | 2014-02-03 10:01:27 +0100 | [diff] [blame] | 548 | printclockname(tcp->u_arg[0]); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 549 | tprints(", "); |
Roland McGrath | 1e35679 | 2003-03-30 23:52:28 +0000 | [diff] [blame] | 550 | } else { |
| 551 | if (syserror(tcp)) |
| 552 | tprintf("%#lx", tcp->u_arg[1]); |
| 553 | else |
| 554 | printtv(tcp, tcp->u_arg[1]); |
| 555 | } |
| 556 | return 0; |
| 557 | } |
| 558 | |
| 559 | int |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 560 | sys_clock_nanosleep(struct tcb *tcp) |
Roland McGrath | 1e35679 | 2003-03-30 23:52:28 +0000 | [diff] [blame] | 561 | { |
| 562 | if (entering(tcp)) { |
Stefan Sørensen | a5fea90 | 2014-02-03 10:01:27 +0100 | [diff] [blame] | 563 | printclockname(tcp->u_arg[0]); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 564 | tprints(", "); |
Roland McGrath | b2dee13 | 2005-06-01 19:02:36 +0000 | [diff] [blame] | 565 | printflags(clockflags, tcp->u_arg[1], "TIMER_???"); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 566 | tprints(", "); |
Roland McGrath | 1e35679 | 2003-03-30 23:52:28 +0000 | [diff] [blame] | 567 | printtv(tcp, tcp->u_arg[2]); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 568 | tprints(", "); |
Roland McGrath | 1e35679 | 2003-03-30 23:52:28 +0000 | [diff] [blame] | 569 | } else { |
| 570 | if (syserror(tcp)) |
| 571 | tprintf("%#lx", tcp->u_arg[3]); |
| 572 | else |
| 573 | printtv(tcp, tcp->u_arg[3]); |
| 574 | } |
| 575 | return 0; |
| 576 | } |
| 577 | |
Dmitry V. Levin | 7321547 | 2012-03-11 21:25:51 +0000 | [diff] [blame] | 578 | int |
| 579 | sys_clock_adjtime(struct tcb *tcp) |
| 580 | { |
| 581 | if (exiting(tcp)) |
| 582 | return do_adjtimex(tcp, tcp->u_arg[1]); |
Stefan Sørensen | a5fea90 | 2014-02-03 10:01:27 +0100 | [diff] [blame] | 583 | printclockname(tcp->u_arg[0]); |
Dmitry V. Levin | 7321547 | 2012-03-11 21:25:51 +0000 | [diff] [blame] | 584 | tprints(", "); |
| 585 | return 0; |
| 586 | } |
| 587 | |
Roland McGrath | 1e35679 | 2003-03-30 23:52:28 +0000 | [diff] [blame] | 588 | #ifndef SIGEV_THREAD_ID |
| 589 | # define SIGEV_THREAD_ID 4 |
| 590 | #endif |
Dmitry V. Levin | 0ed617b | 2014-04-25 23:30:54 +0000 | [diff] [blame] | 591 | #include "xlat/sigev_value.h" |
Roland McGrath | 1e35679 | 2003-03-30 23:52:28 +0000 | [diff] [blame] | 592 | |
Dmitry V. Levin | d3cb392 | 2006-12-13 17:45:02 +0000 | [diff] [blame] | 593 | #if SUPPORTED_PERSONALITIES > 1 |
| 594 | static void |
| 595 | printsigevent32(struct tcb *tcp, long arg) |
| 596 | { |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 597 | struct { |
Dmitry V. Levin | d3cb392 | 2006-12-13 17:45:02 +0000 | [diff] [blame] | 598 | int sigev_value; |
| 599 | int sigev_signo; |
| 600 | int sigev_notify; |
| 601 | |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 602 | union { |
Dmitry V. Levin | d3cb392 | 2006-12-13 17:45:02 +0000 | [diff] [blame] | 603 | int tid; |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 604 | struct { |
Dmitry V. Levin | d3cb392 | 2006-12-13 17:45:02 +0000 | [diff] [blame] | 605 | int function, attribute; |
| 606 | } thread; |
| 607 | } un; |
| 608 | } sev; |
| 609 | |
| 610 | if (umove(tcp, arg, &sev) < 0) |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 611 | tprints("{...}"); |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 612 | else { |
Dmitry V. Levin | d3cb392 | 2006-12-13 17:45:02 +0000 | [diff] [blame] | 613 | tprintf("{%#x, ", sev.sigev_value); |
| 614 | if (sev.sigev_notify == SIGEV_SIGNAL) |
| 615 | tprintf("%s, ", signame(sev.sigev_signo)); |
| 616 | else |
| 617 | tprintf("%u, ", sev.sigev_signo); |
Dmitry V. Levin | bae549e | 2014-02-05 01:46:10 +0000 | [diff] [blame] | 618 | printxval(sigev_value, sev.sigev_notify, "SIGEV_???"); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 619 | tprints(", "); |
Dmitry V. Levin | d3cb392 | 2006-12-13 17:45:02 +0000 | [diff] [blame] | 620 | if (sev.sigev_notify == SIGEV_THREAD_ID) |
| 621 | tprintf("{%d}", sev.un.tid); |
| 622 | else if (sev.sigev_notify == SIGEV_THREAD) |
| 623 | tprintf("{%#x, %#x}", |
| 624 | sev.un.thread.function, |
| 625 | sev.un.thread.attribute); |
| 626 | else |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 627 | tprints("{...}"); |
| 628 | tprints("}"); |
Dmitry V. Levin | d3cb392 | 2006-12-13 17:45:02 +0000 | [diff] [blame] | 629 | } |
| 630 | } |
| 631 | #endif |
| 632 | |
Roland McGrath | 1e35679 | 2003-03-30 23:52:28 +0000 | [diff] [blame] | 633 | void |
Dmitry V. Levin | d3cb392 | 2006-12-13 17:45:02 +0000 | [diff] [blame] | 634 | printsigevent(struct tcb *tcp, long arg) |
Roland McGrath | 1e35679 | 2003-03-30 23:52:28 +0000 | [diff] [blame] | 635 | { |
| 636 | struct sigevent sev; |
Dmitry V. Levin | d3cb392 | 2006-12-13 17:45:02 +0000 | [diff] [blame] | 637 | |
| 638 | #if SUPPORTED_PERSONALITIES > 1 |
Denys Vlasenko | 9fd4f96 | 2012-03-19 09:36:42 +0100 | [diff] [blame] | 639 | if (current_wordsize == 4) { |
Dmitry V. Levin | d3cb392 | 2006-12-13 17:45:02 +0000 | [diff] [blame] | 640 | printsigevent32(tcp, arg); |
| 641 | return; |
| 642 | } |
| 643 | #endif |
Denys Vlasenko | b63256e | 2011-06-07 12:13:24 +0200 | [diff] [blame] | 644 | if (umove(tcp, arg, &sev) < 0) |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 645 | tprints("{...}"); |
Roland McGrath | 1e35679 | 2003-03-30 23:52:28 +0000 | [diff] [blame] | 646 | else { |
Roland McGrath | 675d4a6 | 2004-09-11 08:12:45 +0000 | [diff] [blame] | 647 | tprintf("{%p, ", sev.sigev_value.sival_ptr); |
| 648 | if (sev.sigev_notify == SIGEV_SIGNAL) |
| 649 | tprintf("%s, ", signame(sev.sigev_signo)); |
| 650 | else |
| 651 | tprintf("%u, ", sev.sigev_signo); |
Dmitry V. Levin | bae549e | 2014-02-05 01:46:10 +0000 | [diff] [blame] | 652 | printxval(sigev_value, sev.sigev_notify, "SIGEV_???"); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 653 | tprints(", "); |
Roland McGrath | 1e35679 | 2003-03-30 23:52:28 +0000 | [diff] [blame] | 654 | if (sev.sigev_notify == SIGEV_THREAD_ID) |
Dmitry V. Levin | ae5aa47 | 2013-11-11 23:54:30 +0000 | [diff] [blame] | 655 | #if defined(HAVE_STRUCT_SIGEVENT__SIGEV_UN__PAD) |
Roland McGrath | 1e35679 | 2003-03-30 23:52:28 +0000 | [diff] [blame] | 656 | /* _pad[0] is the _tid field which might not be |
| 657 | present in the userlevel definition of the |
| 658 | struct. */ |
| 659 | tprintf("{%d}", sev._sigev_un._pad[0]); |
Dmitry V. Levin | ae5aa47 | 2013-11-11 23:54:30 +0000 | [diff] [blame] | 660 | #elif defined(HAVE_STRUCT_SIGEVENT___PAD) |
| 661 | tprintf("{%d}", sev.__pad[0]); |
| 662 | #else |
| 663 | # warning unfamiliar struct sigevent => incomplete SIGEV_THREAD_ID decoding |
| 664 | tprints("{...}"); |
| 665 | #endif |
Roland McGrath | d4c85eb | 2004-04-16 21:48:44 +0000 | [diff] [blame] | 666 | else if (sev.sigev_notify == SIGEV_THREAD) |
| 667 | tprintf("{%p, %p}", sev.sigev_notify_function, |
| 668 | sev.sigev_notify_attributes); |
Roland McGrath | 1e35679 | 2003-03-30 23:52:28 +0000 | [diff] [blame] | 669 | else |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 670 | tprints("{...}"); |
| 671 | tprints("}"); |
Roland McGrath | 1e35679 | 2003-03-30 23:52:28 +0000 | [diff] [blame] | 672 | } |
| 673 | } |
| 674 | |
| 675 | int |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 676 | sys_timer_create(struct tcb *tcp) |
Roland McGrath | 1e35679 | 2003-03-30 23:52:28 +0000 | [diff] [blame] | 677 | { |
| 678 | if (entering(tcp)) { |
Stefan Sørensen | a5fea90 | 2014-02-03 10:01:27 +0100 | [diff] [blame] | 679 | printclockname(tcp->u_arg[0]); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 680 | tprints(", "); |
Roland McGrath | 1e35679 | 2003-03-30 23:52:28 +0000 | [diff] [blame] | 681 | printsigevent(tcp, tcp->u_arg[1]); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 682 | tprints(", "); |
Roland McGrath | 1e35679 | 2003-03-30 23:52:28 +0000 | [diff] [blame] | 683 | } else { |
Andi Kleen | 732f396 | 2011-06-13 21:37:40 +0000 | [diff] [blame] | 684 | int timer_id; |
Dmitry V. Levin | ac518d1 | 2006-12-13 17:03:02 +0000 | [diff] [blame] | 685 | |
Andi Kleen | 732f396 | 2011-06-13 21:37:40 +0000 | [diff] [blame] | 686 | if (syserror(tcp) || umove(tcp, tcp->u_arg[2], &timer_id) < 0) |
Roland McGrath | 1e35679 | 2003-03-30 23:52:28 +0000 | [diff] [blame] | 687 | tprintf("%#lx", tcp->u_arg[2]); |
Dmitry V. Levin | ac518d1 | 2006-12-13 17:03:02 +0000 | [diff] [blame] | 688 | else |
Andi Kleen | 732f396 | 2011-06-13 21:37:40 +0000 | [diff] [blame] | 689 | tprintf("{%d}", timer_id); |
Roland McGrath | 1e35679 | 2003-03-30 23:52:28 +0000 | [diff] [blame] | 690 | } |
| 691 | return 0; |
| 692 | } |
| 693 | |
| 694 | int |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 695 | sys_timer_settime(struct tcb *tcp) |
Roland McGrath | 1e35679 | 2003-03-30 23:52:28 +0000 | [diff] [blame] | 696 | { |
| 697 | if (entering(tcp)) { |
| 698 | tprintf("%#lx, ", tcp->u_arg[0]); |
Roland McGrath | b2dee13 | 2005-06-01 19:02:36 +0000 | [diff] [blame] | 699 | printflags(clockflags, tcp->u_arg[1], "TIMER_???"); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 700 | tprints(", "); |
Roland McGrath | 1e35679 | 2003-03-30 23:52:28 +0000 | [diff] [blame] | 701 | printitv(tcp, tcp->u_arg[2]); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 702 | tprints(", "); |
Roland McGrath | 1e35679 | 2003-03-30 23:52:28 +0000 | [diff] [blame] | 703 | } else { |
| 704 | if (syserror(tcp)) |
| 705 | tprintf("%#lx", tcp->u_arg[3]); |
| 706 | else |
| 707 | printitv(tcp, tcp->u_arg[3]); |
| 708 | } |
| 709 | return 0; |
| 710 | } |
| 711 | |
| 712 | int |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 713 | sys_timer_gettime(struct tcb *tcp) |
Roland McGrath | 1e35679 | 2003-03-30 23:52:28 +0000 | [diff] [blame] | 714 | { |
| 715 | if (entering(tcp)) { |
| 716 | tprintf("%#lx, ", tcp->u_arg[0]); |
| 717 | } else { |
| 718 | if (syserror(tcp)) |
| 719 | tprintf("%#lx", tcp->u_arg[1]); |
| 720 | else |
| 721 | printitv(tcp, tcp->u_arg[1]); |
| 722 | } |
| 723 | return 0; |
| 724 | } |
Roland McGrath | d83c50b | 2004-10-06 22:27:43 +0000 | [diff] [blame] | 725 | |
| 726 | static void |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 727 | print_rtc(struct tcb *tcp, const struct rtc_time *rt) |
Roland McGrath | d83c50b | 2004-10-06 22:27:43 +0000 | [diff] [blame] | 728 | { |
| 729 | tprintf("{tm_sec=%d, tm_min=%d, tm_hour=%d, " |
| 730 | "tm_mday=%d, tm_mon=%d, tm_year=%d, ", |
| 731 | rt->tm_sec, rt->tm_min, rt->tm_hour, |
| 732 | rt->tm_mday, rt->tm_mon, rt->tm_year); |
| 733 | if (!abbrev(tcp)) |
| 734 | tprintf("tm_wday=%d, tm_yday=%d, tm_isdst=%d}", |
| 735 | rt->tm_wday, rt->tm_yday, rt->tm_isdst); |
| 736 | else |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 737 | tprints("...}"); |
Roland McGrath | d83c50b | 2004-10-06 22:27:43 +0000 | [diff] [blame] | 738 | } |
| 739 | |
| 740 | int |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 741 | rtc_ioctl(struct tcb *tcp, long code, long arg) |
Roland McGrath | d83c50b | 2004-10-06 22:27:43 +0000 | [diff] [blame] | 742 | { |
| 743 | switch (code) { |
| 744 | case RTC_ALM_SET: |
| 745 | case RTC_SET_TIME: |
| 746 | if (entering(tcp)) { |
| 747 | struct rtc_time rt; |
| 748 | if (umove(tcp, arg, &rt) < 0) |
| 749 | tprintf(", %#lx", arg); |
| 750 | else { |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 751 | tprints(", "); |
Roland McGrath | d83c50b | 2004-10-06 22:27:43 +0000 | [diff] [blame] | 752 | print_rtc(tcp, &rt); |
| 753 | } |
| 754 | } |
| 755 | break; |
| 756 | case RTC_ALM_READ: |
| 757 | case RTC_RD_TIME: |
| 758 | if (exiting(tcp)) { |
| 759 | struct rtc_time rt; |
| 760 | if (syserror(tcp) || umove(tcp, arg, &rt) < 0) |
| 761 | tprintf(", %#lx", arg); |
| 762 | else { |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 763 | tprints(", "); |
Roland McGrath | d83c50b | 2004-10-06 22:27:43 +0000 | [diff] [blame] | 764 | print_rtc(tcp, &rt); |
| 765 | } |
| 766 | } |
| 767 | break; |
| 768 | case RTC_IRQP_SET: |
| 769 | case RTC_EPOCH_SET: |
| 770 | if (entering(tcp)) |
| 771 | tprintf(", %lu", arg); |
| 772 | break; |
| 773 | case RTC_IRQP_READ: |
| 774 | case RTC_EPOCH_READ: |
| 775 | if (exiting(tcp)) |
| 776 | tprintf(", %lu", arg); |
| 777 | break; |
| 778 | case RTC_WKALM_SET: |
| 779 | if (entering(tcp)) { |
| 780 | struct rtc_wkalrm wk; |
| 781 | if (umove(tcp, arg, &wk) < 0) |
| 782 | tprintf(", %#lx", arg); |
| 783 | else { |
| 784 | tprintf(", {enabled=%d, pending=%d, ", |
| 785 | wk.enabled, wk.pending); |
| 786 | print_rtc(tcp, &wk.time); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 787 | tprints("}"); |
Roland McGrath | d83c50b | 2004-10-06 22:27:43 +0000 | [diff] [blame] | 788 | } |
| 789 | } |
| 790 | break; |
| 791 | case RTC_WKALM_RD: |
| 792 | if (exiting(tcp)) { |
| 793 | struct rtc_wkalrm wk; |
| 794 | if (syserror(tcp) || umove(tcp, arg, &wk) < 0) |
| 795 | tprintf(", %#lx", arg); |
| 796 | else { |
| 797 | tprintf(", {enabled=%d, pending=%d, ", |
| 798 | wk.enabled, wk.pending); |
| 799 | print_rtc(tcp, &wk.time); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 800 | tprints("}"); |
Roland McGrath | d83c50b | 2004-10-06 22:27:43 +0000 | [diff] [blame] | 801 | } |
| 802 | } |
| 803 | break; |
| 804 | default: |
| 805 | if (entering(tcp)) |
| 806 | tprintf(", %#lx", arg); |
| 807 | break; |
| 808 | } |
| 809 | return 1; |
| 810 | } |
Roland McGrath | e466234 | 2007-08-02 01:25:34 +0000 | [diff] [blame] | 811 | |
| 812 | #ifndef TFD_TIMER_ABSTIME |
| 813 | #define TFD_TIMER_ABSTIME (1 << 0) |
| 814 | #endif |
| 815 | |
Dmitry V. Levin | 0ed617b | 2014-04-25 23:30:54 +0000 | [diff] [blame] | 816 | #include "xlat/timerfdflags.h" |
Roland McGrath | e466234 | 2007-08-02 01:25:34 +0000 | [diff] [blame] | 817 | |
| 818 | int |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 819 | sys_timerfd(struct tcb *tcp) |
Roland McGrath | e466234 | 2007-08-02 01:25:34 +0000 | [diff] [blame] | 820 | { |
| 821 | if (entering(tcp)) { |
| 822 | /* It does not matter that the kernel uses itimerspec. */ |
| 823 | tprintf("%ld, ", tcp->u_arg[0]); |
Stefan Sørensen | a5fea90 | 2014-02-03 10:01:27 +0100 | [diff] [blame] | 824 | printclockname(tcp->u_arg[0]); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 825 | tprints(", "); |
Roland McGrath | e466234 | 2007-08-02 01:25:34 +0000 | [diff] [blame] | 826 | printflags(timerfdflags, tcp->u_arg[2], "TFD_???"); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 827 | tprints(", "); |
Roland McGrath | e466234 | 2007-08-02 01:25:34 +0000 | [diff] [blame] | 828 | printitv(tcp, tcp->u_arg[3]); |
| 829 | } |
| 830 | return 0; |
| 831 | } |
Roland McGrath | de328e6 | 2008-05-20 04:56:13 +0000 | [diff] [blame] | 832 | |
| 833 | int |
| 834 | sys_timerfd_create(struct tcb *tcp) |
| 835 | { |
| 836 | if (entering(tcp)) { |
Stefan Sørensen | a5fea90 | 2014-02-03 10:01:27 +0100 | [diff] [blame] | 837 | printclockname(tcp->u_arg[0]); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 838 | tprints(", "); |
Roland McGrath | de328e6 | 2008-05-20 04:56:13 +0000 | [diff] [blame] | 839 | printflags(timerfdflags, tcp->u_arg[1], "TFD_???"); |
| 840 | } |
| 841 | return 0; |
| 842 | } |
| 843 | |
| 844 | int |
| 845 | sys_timerfd_settime(struct tcb *tcp) |
| 846 | { |
| 847 | if (entering(tcp)) { |
Dmitry V. Levin | 3138213 | 2011-03-04 05:08:02 +0300 | [diff] [blame] | 848 | printfd(tcp, tcp->u_arg[0]); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 849 | tprints(", "); |
Roland McGrath | de328e6 | 2008-05-20 04:56:13 +0000 | [diff] [blame] | 850 | printflags(timerfdflags, tcp->u_arg[1], "TFD_???"); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 851 | tprints(", "); |
Roland McGrath | de328e6 | 2008-05-20 04:56:13 +0000 | [diff] [blame] | 852 | printitv(tcp, tcp->u_arg[2]); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 853 | tprints(", "); |
Roland McGrath | de328e6 | 2008-05-20 04:56:13 +0000 | [diff] [blame] | 854 | printitv(tcp, tcp->u_arg[3]); |
| 855 | } |
| 856 | return 0; |
| 857 | } |
| 858 | |
| 859 | int |
| 860 | sys_timerfd_gettime(struct tcb *tcp) |
| 861 | { |
| 862 | if (entering(tcp)) { |
Dmitry V. Levin | 3138213 | 2011-03-04 05:08:02 +0300 | [diff] [blame] | 863 | printfd(tcp, tcp->u_arg[0]); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 864 | tprints(", "); |
Roland McGrath | de328e6 | 2008-05-20 04:56:13 +0000 | [diff] [blame] | 865 | printitv(tcp, tcp->u_arg[1]); |
| 866 | } |
| 867 | return 0; |
| 868 | } |