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