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