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