Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 1991, 1992 Paul Kranenburg <pk@cs.few.eur.nl> |
| 3 | * Copyright (c) 1993 Branko Lankester <branko@hacktic.nl> |
| 4 | * Copyright (c) 1993, 1994, 1995, 1996 Rick Sladkey <jrs@world.std.com> |
| 5 | * All rights reserved. |
| 6 | * |
| 7 | * Redistribution and use in source and binary forms, with or without |
| 8 | * modification, are permitted provided that the following conditions |
| 9 | * are met: |
| 10 | * 1. Redistributions of source code must retain the above copyright |
| 11 | * notice, this list of conditions and the following disclaimer. |
| 12 | * 2. Redistributions in binary form must reproduce the above copyright |
| 13 | * notice, this list of conditions and the following disclaimer in the |
| 14 | * documentation and/or other materials provided with the distribution. |
| 15 | * 3. The name of the author may not be used to endorse or promote products |
| 16 | * derived from this software without specific prior written permission. |
| 17 | * |
| 18 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR |
| 19 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
| 20 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
| 21 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, |
| 22 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
| 23 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 24 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 25 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 26 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
| 27 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 28 | */ |
| 29 | |
| 30 | #include "defs.h" |
Mike Frysinger | f1639d8 | 2014-12-30 19:08:50 -0500 | [diff] [blame] | 31 | #include <fcntl.h> |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 32 | #include <linux/version.h> |
Wichert Akkerman | d856b99 | 2000-10-13 12:47:12 +0000 | [diff] [blame] | 33 | #include <sys/timex.h> |
Roland McGrath | d83c50b | 2004-10-06 22:27:43 +0000 | [diff] [blame] | 34 | #include <linux/ioctl.h> |
| 35 | #include <linux/rtc.h> |
Roland McGrath | 6afc565 | 2007-07-24 01:57:11 +0000 | [diff] [blame] | 36 | |
| 37 | #ifndef UTIME_NOW |
| 38 | #define UTIME_NOW ((1l << 30) - 1l) |
| 39 | #endif |
| 40 | #ifndef UTIME_OMIT |
| 41 | #define UTIME_OMIT ((1l << 30) - 2l) |
| 42 | #endif |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 43 | |
Dmitry V. Levin | e61086f | 2015-02-27 21:46:42 +0000 | [diff] [blame] | 44 | #if SUPPORTED_PERSONALITIES > 1 |
| 45 | # if defined X86_64 || defined X32 |
| 46 | # define current_time_t_is_compat (current_personality == 1) |
| 47 | # else |
| 48 | # define current_time_t_is_compat (current_wordsize == 4) |
| 49 | # endif |
| 50 | #else |
| 51 | # define current_time_t_is_compat 0 |
| 52 | #endif |
| 53 | |
Dmitry V. Levin | a7945a3 | 2006-12-13 17:10:11 +0000 | [diff] [blame] | 54 | struct timeval32 |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 55 | { |
Dmitry V. Levin | a7945a3 | 2006-12-13 17:10:11 +0000 | [diff] [blame] | 56 | u_int32_t tv_sec, tv_usec; |
| 57 | }; |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 58 | |
Dmitry V. Levin | 1cad25d | 2006-12-13 17:14:36 +0000 | [diff] [blame] | 59 | static void |
| 60 | tprint_timeval32(struct tcb *tcp, const struct timeval32 *tv) |
| 61 | { |
| 62 | tprintf("{%u, %u}", tv->tv_sec, tv->tv_usec); |
| 63 | } |
| 64 | |
| 65 | static void |
| 66 | tprint_timeval(struct tcb *tcp, const struct timeval *tv) |
| 67 | { |
Dmitry V. Levin | e61086f | 2015-02-27 21:46:42 +0000 | [diff] [blame] | 68 | tprintf("{%ju, %ju}", (uintmax_t) tv->tv_sec, (uintmax_t) tv->tv_usec); |
Dmitry V. Levin | 1cad25d | 2006-12-13 17:14:36 +0000 | [diff] [blame] | 69 | } |
| 70 | |
Dmitry V. Levin | a7945a3 | 2006-12-13 17:10:11 +0000 | [diff] [blame] | 71 | void |
Roland McGrath | 6afc565 | 2007-07-24 01:57:11 +0000 | [diff] [blame] | 72 | 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] | 73 | { |
Denys Vlasenko | a1d541e | 2012-01-20 11:04:04 +0100 | [diff] [blame] | 74 | char buf[TIMEVAL_TEXT_BUFSIZE]; |
| 75 | sprinttv(buf, tcp, addr, bitness, special); |
| 76 | tprints(buf); |
Dmitry V. Levin | a7945a3 | 2006-12-13 17:10:11 +0000 | [diff] [blame] | 77 | } |
Wichert Akkerman | 221f54f | 1999-11-18 17:26:45 +0000 | [diff] [blame] | 78 | |
Dmitry V. Levin | ee21a5b | 2014-12-26 23:55:38 +0000 | [diff] [blame] | 79 | static char * |
Dmitry V. Levin | e61086f | 2015-02-27 21:46:42 +0000 | [diff] [blame] | 80 | do_sprinttv(char *buf, const uintmax_t sec, const uintmax_t usec, |
Dmitry V. Levin | ee21a5b | 2014-12-26 23:55:38 +0000 | [diff] [blame] | 81 | const int special) |
| 82 | { |
| 83 | if (special) { |
| 84 | switch (usec) { |
| 85 | case UTIME_NOW: |
| 86 | return stpcpy(buf, "UTIME_NOW"); |
| 87 | case UTIME_OMIT: |
| 88 | return stpcpy(buf, "UTIME_OMIT"); |
| 89 | } |
| 90 | } |
Dmitry V. Levin | e61086f | 2015-02-27 21:46:42 +0000 | [diff] [blame] | 91 | return buf + sprintf(buf, "{%ju, %ju}", sec, usec); |
Dmitry V. Levin | ee21a5b | 2014-12-26 23:55:38 +0000 | [diff] [blame] | 92 | } |
| 93 | |
Denys Vlasenko | 2fb4db3 | 2011-08-31 12:26:03 +0200 | [diff] [blame] | 94 | char * |
Denys Vlasenko | a1d541e | 2012-01-20 11:04:04 +0100 | [diff] [blame] | 95 | 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] | 96 | { |
Dmitry V. Levin | a7945a3 | 2006-12-13 17:10:11 +0000 | [diff] [blame] | 97 | if (addr == 0) |
Denys Vlasenko | 2fb4db3 | 2011-08-31 12:26:03 +0200 | [diff] [blame] | 98 | return stpcpy(buf, "NULL"); |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 99 | |
Denys Vlasenko | b9c7ae6 | 2011-09-01 11:40:40 +0200 | [diff] [blame] | 100 | if (!verbose(tcp)) |
| 101 | return buf + sprintf(buf, "%#lx", addr); |
Denys Vlasenko | 2fb4db3 | 2011-08-31 12:26:03 +0200 | [diff] [blame] | 102 | |
Dmitry V. Levin | e61086f | 2015-02-27 21:46:42 +0000 | [diff] [blame] | 103 | if (bitness == BITNESS_32 || current_time_t_is_compat) |
Denys Vlasenko | 2fb4db3 | 2011-08-31 12:26:03 +0200 | [diff] [blame] | 104 | { |
| 105 | struct timeval32 tv; |
| 106 | |
Dmitry V. Levin | ee21a5b | 2014-12-26 23:55:38 +0000 | [diff] [blame] | 107 | if (umove(tcp, addr, &tv) >= 0) |
| 108 | return do_sprinttv(buf, tv.tv_sec, tv.tv_usec, special); |
Denys Vlasenko | 2fb4db3 | 2011-08-31 12:26:03 +0200 | [diff] [blame] | 109 | } else { |
| 110 | struct timeval tv; |
| 111 | |
Dmitry V. Levin | ee21a5b | 2014-12-26 23:55:38 +0000 | [diff] [blame] | 112 | if (umove(tcp, addr, &tv) >= 0) |
| 113 | return do_sprinttv(buf, tv.tv_sec, tv.tv_usec, special); |
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 |
Dmitry V. Levin | e61086f | 2015-02-27 21:46:42 +0000 | [diff] [blame] | 138 | if (current_time_t_is_compat) { |
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) |
Dmitry V. Levin | e61086f | 2015-02-27 21:46:42 +0000 | [diff] [blame] | 152 | sprintf(buf, "{%ju, %ju}", |
| 153 | (uintmax_t) ts.tv_sec, |
| 154 | (uintmax_t) 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 | |
Dmitry V. Levin | a0bd374 | 2015-04-07 01:36:50 +0000 | [diff] [blame] | 161 | SYS_FUNC(time) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 162 | { |
| 163 | if (exiting(tcp)) { |
Dmitry V. Levin | 1c603a9 | 2015-02-17 22:03:17 +0000 | [diff] [blame] | 164 | printnum_long(tcp, tcp->u_arg[0], "%ld"); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 165 | } |
| 166 | return 0; |
| 167 | } |
| 168 | |
Dmitry V. Levin | a0bd374 | 2015-04-07 01:36:50 +0000 | [diff] [blame] | 169 | SYS_FUNC(gettimeofday) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 170 | { |
| 171 | if (exiting(tcp)) { |
| 172 | if (syserror(tcp)) { |
Dmitry V. Levin | e61086f | 2015-02-27 21:46:42 +0000 | [diff] [blame] | 173 | tprintf("%#lx, %#lx", tcp->u_arg[0], tcp->u_arg[1]); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 174 | return 0; |
| 175 | } |
| 176 | printtv(tcp, tcp->u_arg[0]); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 177 | tprints(", "); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 178 | printtv(tcp, tcp->u_arg[1]); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 179 | } |
| 180 | return 0; |
| 181 | } |
| 182 | |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 183 | #ifdef ALPHA |
Dmitry V. Levin | a0bd374 | 2015-04-07 01:36:50 +0000 | [diff] [blame] | 184 | SYS_FUNC(osf_gettimeofday) |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 185 | { |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 186 | if (exiting(tcp)) { |
| 187 | if (syserror(tcp)) { |
| 188 | tprintf("%#lx, %#lx", tcp->u_arg[0], tcp->u_arg[1]); |
| 189 | return 0; |
| 190 | } |
| 191 | printtv_bitness(tcp, tcp->u_arg[0], BITNESS_32, 0); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 192 | tprints(", "); |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 193 | printtv_bitness(tcp, tcp->u_arg[1], BITNESS_32, 0); |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 194 | } |
| 195 | return 0; |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 196 | } |
| 197 | #endif |
| 198 | |
Dmitry V. Levin | a0bd374 | 2015-04-07 01:36:50 +0000 | [diff] [blame] | 199 | SYS_FUNC(settimeofday) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 200 | { |
| 201 | if (entering(tcp)) { |
| 202 | printtv(tcp, tcp->u_arg[0]); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 203 | tprints(", "); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 204 | printtv(tcp, tcp->u_arg[1]); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 205 | } |
| 206 | return 0; |
| 207 | } |
| 208 | |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 209 | #ifdef ALPHA |
Dmitry V. Levin | a0bd374 | 2015-04-07 01:36:50 +0000 | [diff] [blame] | 210 | SYS_FUNC(osf_settimeofday) |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 211 | { |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 212 | if (entering(tcp)) { |
| 213 | printtv_bitness(tcp, tcp->u_arg[0], BITNESS_32, 0); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 214 | tprints(", "); |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 215 | printtv_bitness(tcp, tcp->u_arg[1], BITNESS_32, 0); |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 216 | } |
| 217 | return 0; |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 218 | } |
| 219 | #endif |
| 220 | |
Dmitry V. Levin | a0bd374 | 2015-04-07 01:36:50 +0000 | [diff] [blame] | 221 | SYS_FUNC(adjtime) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 222 | { |
| 223 | if (entering(tcp)) { |
| 224 | printtv(tcp, tcp->u_arg[0]); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 225 | tprints(", "); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 226 | } else { |
| 227 | if (syserror(tcp)) |
| 228 | tprintf("%#lx", tcp->u_arg[1]); |
| 229 | else |
| 230 | printtv(tcp, tcp->u_arg[1]); |
| 231 | } |
| 232 | return 0; |
| 233 | } |
| 234 | |
Dmitry V. Levin | a0bd374 | 2015-04-07 01:36:50 +0000 | [diff] [blame] | 235 | SYS_FUNC(nanosleep) |
Dmitry V. Levin | 2e55ff4 | 2008-09-03 01:02:46 +0000 | [diff] [blame] | 236 | { |
| 237 | if (entering(tcp)) { |
| 238 | print_timespec(tcp, tcp->u_arg[0]); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 239 | tprints(", "); |
Dmitry V. Levin | 2e55ff4 | 2008-09-03 01:02:46 +0000 | [diff] [blame] | 240 | } else { |
Denys Vlasenko | 64acaa1 | 2012-01-28 02:29:36 +0100 | [diff] [blame] | 241 | /* Second (returned) timespec is only significant |
Denys Vlasenko | 4793221 | 2013-06-30 23:53:49 +0200 | [diff] [blame] | 242 | * if syscall was interrupted. On success, we print |
| 243 | * only its address, since kernel doesn't modify it, |
| 244 | * and printing the value may show uninitialized data. |
Denys Vlasenko | 64acaa1 | 2012-01-28 02:29:36 +0100 | [diff] [blame] | 245 | */ |
Denys Vlasenko | 4793221 | 2013-06-30 23:53:49 +0200 | [diff] [blame] | 246 | switch (tcp->u_error) { |
| 247 | default: |
| 248 | /* Not interrupted (slept entire interval) */ |
| 249 | if (tcp->u_arg[1]) { |
| 250 | tprintf("%#lx", tcp->u_arg[1]); |
| 251 | break; |
| 252 | } |
| 253 | /* Fall through: print_timespec(NULL) prints "NULL" */ |
| 254 | case ERESTARTSYS: |
| 255 | case ERESTARTNOINTR: |
| 256 | case ERESTARTNOHAND: |
| 257 | case ERESTART_RESTARTBLOCK: |
| 258 | /* Interrupted */ |
Dmitry V. Levin | 2e55ff4 | 2008-09-03 01:02:46 +0000 | [diff] [blame] | 259 | print_timespec(tcp, tcp->u_arg[1]); |
Denys Vlasenko | 4793221 | 2013-06-30 23:53:49 +0200 | [diff] [blame] | 260 | } |
Dmitry V. Levin | 2e55ff4 | 2008-09-03 01:02:46 +0000 | [diff] [blame] | 261 | } |
| 262 | return 0; |
| 263 | } |
| 264 | |
Dmitry V. Levin | 0ed617b | 2014-04-25 23:30:54 +0000 | [diff] [blame] | 265 | #include "xlat/itimer_which.h" |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 266 | |
| 267 | static void |
Dmitry V. Levin | 1cad25d | 2006-12-13 17:14:36 +0000 | [diff] [blame] | 268 | printitv_bitness(struct tcb *tcp, long addr, enum bitness_t bitness) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 269 | { |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 270 | if (addr == 0) |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 271 | tprints("NULL"); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 272 | else if (!verbose(tcp)) |
| 273 | tprintf("%#lx", addr); |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 274 | else { |
| 275 | int rc; |
Dmitry V. Levin | 1cad25d | 2006-12-13 17:14:36 +0000 | [diff] [blame] | 276 | |
Dmitry V. Levin | e61086f | 2015-02-27 21:46:42 +0000 | [diff] [blame] | 277 | if (bitness == BITNESS_32 || current_time_t_is_compat) { |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 278 | struct { |
Dmitry V. Levin | 1cad25d | 2006-12-13 17:14:36 +0000 | [diff] [blame] | 279 | struct timeval32 it_interval, it_value; |
| 280 | } itv; |
| 281 | |
Denys Vlasenko | 5d64581 | 2011-08-20 12:48:18 +0200 | [diff] [blame] | 282 | rc = umove(tcp, addr, &itv); |
| 283 | if (rc >= 0) { |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 284 | tprints("{it_interval="); |
Dmitry V. Levin | 1cad25d | 2006-12-13 17:14:36 +0000 | [diff] [blame] | 285 | tprint_timeval32(tcp, &itv.it_interval); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 286 | tprints(", it_value="); |
Dmitry V. Levin | 1cad25d | 2006-12-13 17:14:36 +0000 | [diff] [blame] | 287 | tprint_timeval32(tcp, &itv.it_value); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 288 | tprints("}"); |
Roland McGrath | e466234 | 2007-08-02 01:25:34 +0000 | [diff] [blame] | 289 | } |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 290 | } else { |
Dmitry V. Levin | 1cad25d | 2006-12-13 17:14:36 +0000 | [diff] [blame] | 291 | struct itimerval itv; |
| 292 | |
Denys Vlasenko | 5d64581 | 2011-08-20 12:48:18 +0200 | [diff] [blame] | 293 | rc = umove(tcp, addr, &itv); |
| 294 | if (rc >= 0) { |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 295 | tprints("{it_interval="); |
Dmitry V. Levin | 1cad25d | 2006-12-13 17:14:36 +0000 | [diff] [blame] | 296 | tprint_timeval(tcp, &itv.it_interval); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 297 | tprints(", it_value="); |
Dmitry V. Levin | 1cad25d | 2006-12-13 17:14:36 +0000 | [diff] [blame] | 298 | tprint_timeval(tcp, &itv.it_value); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 299 | tprints("}"); |
Roland McGrath | e466234 | 2007-08-02 01:25:34 +0000 | [diff] [blame] | 300 | } |
Dmitry V. Levin | 1cad25d | 2006-12-13 17:14:36 +0000 | [diff] [blame] | 301 | } |
Dmitry V. Levin | 1cad25d | 2006-12-13 17:14:36 +0000 | [diff] [blame] | 302 | if (rc < 0) |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 303 | tprints("{...}"); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 304 | } |
| 305 | } |
| 306 | |
Dmitry V. Levin | 1cad25d | 2006-12-13 17:14:36 +0000 | [diff] [blame] | 307 | #define printitv(tcp, addr) \ |
| 308 | printitv_bitness((tcp), (addr), BITNESS_CURRENT) |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 309 | |
Dmitry V. Levin | a0bd374 | 2015-04-07 01:36:50 +0000 | [diff] [blame] | 310 | SYS_FUNC(getitimer) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 311 | { |
| 312 | if (entering(tcp)) { |
Dmitry V. Levin | 297b594 | 2014-04-25 23:39:20 +0000 | [diff] [blame] | 313 | printxval(itimer_which, tcp->u_arg[0], "ITIMER_???"); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 314 | tprints(", "); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 315 | } else { |
| 316 | if (syserror(tcp)) |
| 317 | tprintf("%#lx", tcp->u_arg[1]); |
| 318 | else |
| 319 | printitv(tcp, tcp->u_arg[1]); |
| 320 | } |
| 321 | return 0; |
| 322 | } |
| 323 | |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 324 | #ifdef ALPHA |
Dmitry V. Levin | a0bd374 | 2015-04-07 01:36:50 +0000 | [diff] [blame] | 325 | SYS_FUNC(osf_getitimer) |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 326 | { |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 327 | if (entering(tcp)) { |
Dmitry V. Levin | 297b594 | 2014-04-25 23:39:20 +0000 | [diff] [blame] | 328 | printxval(itimer_which, tcp->u_arg[0], "ITIMER_???"); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 329 | tprints(", "); |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 330 | } else { |
| 331 | if (syserror(tcp)) |
| 332 | tprintf("%#lx", tcp->u_arg[1]); |
| 333 | else |
| 334 | printitv_bitness(tcp, tcp->u_arg[1], BITNESS_32); |
| 335 | } |
| 336 | return 0; |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 337 | } |
| 338 | #endif |
| 339 | |
Dmitry V. Levin | a0bd374 | 2015-04-07 01:36:50 +0000 | [diff] [blame] | 340 | SYS_FUNC(setitimer) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 341 | { |
| 342 | if (entering(tcp)) { |
Dmitry V. Levin | 297b594 | 2014-04-25 23:39:20 +0000 | [diff] [blame] | 343 | printxval(itimer_which, tcp->u_arg[0], "ITIMER_???"); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 344 | tprints(", "); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 345 | printitv(tcp, tcp->u_arg[1]); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 346 | tprints(", "); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 347 | } else { |
| 348 | if (syserror(tcp)) |
| 349 | tprintf("%#lx", tcp->u_arg[2]); |
| 350 | else |
| 351 | printitv(tcp, tcp->u_arg[2]); |
| 352 | } |
| 353 | return 0; |
| 354 | } |
| 355 | |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 356 | #ifdef ALPHA |
Dmitry V. Levin | a0bd374 | 2015-04-07 01:36:50 +0000 | [diff] [blame] | 357 | SYS_FUNC(osf_setitimer) |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 358 | { |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 359 | if (entering(tcp)) { |
Dmitry V. Levin | 297b594 | 2014-04-25 23:39:20 +0000 | [diff] [blame] | 360 | printxval(itimer_which, tcp->u_arg[0], "ITIMER_???"); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 361 | tprints(", "); |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 362 | printitv_bitness(tcp, tcp->u_arg[1], BITNESS_32); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 363 | tprints(", "); |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 364 | } else { |
| 365 | if (syserror(tcp)) |
| 366 | tprintf("%#lx", tcp->u_arg[2]); |
| 367 | else |
| 368 | printitv_bitness(tcp, tcp->u_arg[2], BITNESS_32); |
| 369 | } |
| 370 | return 0; |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 371 | } |
| 372 | #endif |
| 373 | |
Dmitry V. Levin | 0ed617b | 2014-04-25 23:30:54 +0000 | [diff] [blame] | 374 | #include "xlat/adjtimex_modes.h" |
Dmitry V. Levin | 0ed617b | 2014-04-25 23:30:54 +0000 | [diff] [blame] | 375 | #include "xlat/adjtimex_status.h" |
Dmitry V. Levin | 0ed617b | 2014-04-25 23:30:54 +0000 | [diff] [blame] | 376 | #include "xlat/adjtimex_state.h" |
Dmitry V. Levin | 1a684d6 | 2006-12-13 17:42:32 +0000 | [diff] [blame] | 377 | |
Dmitry V. Levin | 165b15d | 2006-12-13 17:43:45 +0000 | [diff] [blame] | 378 | #if SUPPORTED_PERSONALITIES > 1 |
| 379 | static int |
| 380 | tprint_timex32(struct tcb *tcp, long addr) |
| 381 | { |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 382 | struct { |
Dmitry V. Levin | 165b15d | 2006-12-13 17:43:45 +0000 | [diff] [blame] | 383 | unsigned int modes; |
| 384 | int offset; |
| 385 | int freq; |
| 386 | int maxerror; |
| 387 | int esterror; |
| 388 | int status; |
| 389 | int constant; |
| 390 | int precision; |
| 391 | int tolerance; |
| 392 | struct timeval32 time; |
| 393 | int tick; |
| 394 | int ppsfreq; |
| 395 | int jitter; |
| 396 | int shift; |
| 397 | int stabil; |
| 398 | int jitcnt; |
| 399 | int calcnt; |
| 400 | int errcnt; |
| 401 | int stbcnt; |
| 402 | } tx; |
| 403 | |
| 404 | if (umove(tcp, addr, &tx) < 0) |
| 405 | return -1; |
| 406 | |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 407 | tprints("{modes="); |
Dmitry V. Levin | 71d7089 | 2007-01-13 11:17:38 +0000 | [diff] [blame] | 408 | printflags(adjtimex_modes, tx.modes, "ADJ_???"); |
Dmitry V. Levin | 165b15d | 2006-12-13 17:43:45 +0000 | [diff] [blame] | 409 | tprintf(", offset=%d, freq=%d, maxerror=%d, ", |
| 410 | tx.offset, tx.freq, tx.maxerror); |
| 411 | tprintf("esterror=%u, status=", tx.esterror); |
| 412 | printflags(adjtimex_status, tx.status, "STA_???"); |
| 413 | tprintf(", constant=%d, precision=%u, ", |
| 414 | tx.constant, tx.precision); |
| 415 | tprintf("tolerance=%d, time=", tx.tolerance); |
| 416 | tprint_timeval32(tcp, &tx.time); |
| 417 | tprintf(", tick=%d, ppsfreq=%d, jitter=%d", |
| 418 | tx.tick, tx.ppsfreq, tx.jitter); |
| 419 | tprintf(", shift=%d, stabil=%d, jitcnt=%d", |
| 420 | tx.shift, tx.stabil, tx.jitcnt); |
| 421 | tprintf(", calcnt=%d, errcnt=%d, stbcnt=%d", |
| 422 | tx.calcnt, tx.errcnt, tx.stbcnt); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 423 | tprints("}"); |
Dmitry V. Levin | 165b15d | 2006-12-13 17:43:45 +0000 | [diff] [blame] | 424 | return 0; |
| 425 | } |
| 426 | #endif /* SUPPORTED_PERSONALITIES > 1 */ |
| 427 | |
| 428 | static int |
| 429 | tprint_timex(struct tcb *tcp, long addr) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 430 | { |
Dmitry V. Levin | 1a684d6 | 2006-12-13 17:42:32 +0000 | [diff] [blame] | 431 | struct timex tx; |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 432 | |
Dmitry V. Levin | 165b15d | 2006-12-13 17:43:45 +0000 | [diff] [blame] | 433 | #if SUPPORTED_PERSONALITIES > 1 |
Dmitry V. Levin | e61086f | 2015-02-27 21:46:42 +0000 | [diff] [blame] | 434 | if (current_time_t_is_compat) |
Dmitry V. Levin | 165b15d | 2006-12-13 17:43:45 +0000 | [diff] [blame] | 435 | return tprint_timex32(tcp, addr); |
| 436 | #endif |
| 437 | if (umove(tcp, addr, &tx) < 0) |
| 438 | return -1; |
| 439 | |
| 440 | #if LINUX_VERSION_CODE < 66332 |
| 441 | tprintf("{mode=%d, offset=%ld, frequency=%ld, ", |
| 442 | tx.mode, tx.offset, tx.frequency); |
| 443 | tprintf("maxerror=%ld, esterror=%lu, status=%u, ", |
| 444 | tx.maxerror, tx.esterror, tx.status); |
| 445 | tprintf("time_constant=%ld, precision=%lu, ", |
| 446 | tx.time_constant, tx.precision); |
| 447 | tprintf("tolerance=%ld, time=", tx.tolerance); |
| 448 | tprint_timeval(tcp, &tx.time); |
| 449 | #else |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 450 | tprints("{modes="); |
Dmitry V. Levin | 71d7089 | 2007-01-13 11:17:38 +0000 | [diff] [blame] | 451 | printflags(adjtimex_modes, tx.modes, "ADJ_???"); |
Dmitry V. Levin | e61086f | 2015-02-27 21:46:42 +0000 | [diff] [blame] | 452 | tprintf(", offset=%jd, freq=%jd, maxerror=%ju, esterror=%ju, status=", |
| 453 | (intmax_t) tx.offset, (intmax_t) tx.freq, |
| 454 | (uintmax_t) tx.maxerror, (uintmax_t) tx.esterror); |
Dmitry V. Levin | 165b15d | 2006-12-13 17:43:45 +0000 | [diff] [blame] | 455 | printflags(adjtimex_status, tx.status, "STA_???"); |
Dmitry V. Levin | e61086f | 2015-02-27 21:46:42 +0000 | [diff] [blame] | 456 | tprintf(", constant=%jd, precision=%ju, tolerance=%jd, time=", |
| 457 | (intmax_t) tx.constant, (uintmax_t) tx.precision, |
| 458 | (intmax_t) tx.tolerance); |
Dmitry V. Levin | 165b15d | 2006-12-13 17:43:45 +0000 | [diff] [blame] | 459 | tprint_timeval(tcp, &tx.time); |
Dmitry V. Levin | e61086f | 2015-02-27 21:46:42 +0000 | [diff] [blame] | 460 | tprintf(", tick=%jd, ppsfreq=%jd, jitter=%jd", |
| 461 | (intmax_t) tx.tick, (intmax_t) tx.ppsfreq, (intmax_t) tx.jitter); |
| 462 | tprintf(", shift=%d, stabil=%jd, jitcnt=%jd", |
| 463 | tx.shift, (intmax_t) tx.stabil, (intmax_t) tx.jitcnt); |
| 464 | tprintf(", calcnt=%jd, errcnt=%jd, stbcnt=%jd", |
| 465 | (intmax_t) tx.calcnt, (intmax_t) tx.errcnt, (intmax_t) tx.stbcnt); |
Dmitry V. Levin | 165b15d | 2006-12-13 17:43:45 +0000 | [diff] [blame] | 466 | #endif |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 467 | tprints("}"); |
Dmitry V. Levin | 165b15d | 2006-12-13 17:43:45 +0000 | [diff] [blame] | 468 | return 0; |
| 469 | } |
| 470 | |
Dmitry V. Levin | 7321547 | 2012-03-11 21:25:51 +0000 | [diff] [blame] | 471 | static int |
| 472 | do_adjtimex(struct tcb *tcp, long addr) |
| 473 | { |
| 474 | if (addr == 0) |
| 475 | tprints("NULL"); |
| 476 | else if (syserror(tcp) || !verbose(tcp)) |
| 477 | tprintf("%#lx", addr); |
| 478 | else if (tprint_timex(tcp, addr) < 0) |
| 479 | tprints("{...}"); |
| 480 | if (syserror(tcp)) |
| 481 | return 0; |
| 482 | tcp->auxstr = xlookup(adjtimex_state, tcp->u_rval); |
| 483 | if (tcp->auxstr) |
| 484 | return RVAL_STR; |
| 485 | return 0; |
| 486 | } |
| 487 | |
Dmitry V. Levin | a0bd374 | 2015-04-07 01:36:50 +0000 | [diff] [blame] | 488 | SYS_FUNC(adjtimex) |
Dmitry V. Levin | 165b15d | 2006-12-13 17:43:45 +0000 | [diff] [blame] | 489 | { |
Dmitry V. Levin | 7321547 | 2012-03-11 21:25:51 +0000 | [diff] [blame] | 490 | if (exiting(tcp)) |
| 491 | return do_adjtimex(tcp, tcp->u_arg[0]); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 492 | return 0; |
| 493 | } |
Roland McGrath | 1e35679 | 2003-03-30 23:52:28 +0000 | [diff] [blame] | 494 | |
Dmitry V. Levin | 0ed617b | 2014-04-25 23:30:54 +0000 | [diff] [blame] | 495 | #include "xlat/clockflags.h" |
Dmitry V. Levin | 0ed617b | 2014-04-25 23:30:54 +0000 | [diff] [blame] | 496 | #include "xlat/clocknames.h" |
Roland McGrath | 54a4edd | 2004-08-31 06:52:45 +0000 | [diff] [blame] | 497 | |
Stefan Sørensen | a5fea90 | 2014-02-03 10:01:27 +0100 | [diff] [blame] | 498 | static void |
| 499 | printclockname(int clockid) |
| 500 | { |
| 501 | #ifdef CLOCKID_TO_FD |
Dmitry V. Levin | d35bdca | 2014-04-26 18:10:19 +0000 | [diff] [blame] | 502 | # include "xlat/cpuclocknames.h" |
| 503 | |
Stefan Sørensen | a5fea90 | 2014-02-03 10:01:27 +0100 | [diff] [blame] | 504 | if (clockid < 0) { |
| 505 | if ((clockid & CLOCKFD_MASK) == CLOCKFD) |
| 506 | tprintf("FD_TO_CLOCKID(%d)", CLOCKID_TO_FD(clockid)); |
| 507 | else { |
| 508 | if(CPUCLOCK_PERTHREAD(clockid)) |
| 509 | tprintf("MAKE_THREAD_CPUCLOCK(%d,", CPUCLOCK_PID(clockid)); |
| 510 | else |
| 511 | tprintf("MAKE_PROCESS_CPUCLOCK(%d,", CPUCLOCK_PID(clockid)); |
| 512 | printxval(cpuclocknames, clockid & CLOCKFD_MASK, "CPUCLOCK_???"); |
| 513 | tprints(")"); |
| 514 | } |
| 515 | } |
| 516 | else |
| 517 | #endif |
| 518 | printxval(clocknames, clockid, "CLOCK_???"); |
| 519 | } |
| 520 | |
Dmitry V. Levin | a0bd374 | 2015-04-07 01:36:50 +0000 | [diff] [blame] | 521 | SYS_FUNC(clock_settime) |
Roland McGrath | 1e35679 | 2003-03-30 23:52:28 +0000 | [diff] [blame] | 522 | { |
| 523 | if (entering(tcp)) { |
Stefan Sørensen | a5fea90 | 2014-02-03 10:01:27 +0100 | [diff] [blame] | 524 | printclockname(tcp->u_arg[0]); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 525 | tprints(", "); |
Roland McGrath | 1e35679 | 2003-03-30 23:52:28 +0000 | [diff] [blame] | 526 | printtv(tcp, tcp->u_arg[1]); |
| 527 | } |
| 528 | return 0; |
| 529 | } |
| 530 | |
Dmitry V. Levin | a0bd374 | 2015-04-07 01:36:50 +0000 | [diff] [blame] | 531 | SYS_FUNC(clock_gettime) |
Roland McGrath | 1e35679 | 2003-03-30 23:52:28 +0000 | [diff] [blame] | 532 | { |
| 533 | if (entering(tcp)) { |
Stefan Sørensen | a5fea90 | 2014-02-03 10:01:27 +0100 | [diff] [blame] | 534 | printclockname(tcp->u_arg[0]); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 535 | tprints(", "); |
Roland McGrath | 1e35679 | 2003-03-30 23:52:28 +0000 | [diff] [blame] | 536 | } else { |
| 537 | if (syserror(tcp)) |
| 538 | tprintf("%#lx", tcp->u_arg[1]); |
| 539 | else |
| 540 | printtv(tcp, tcp->u_arg[1]); |
| 541 | } |
| 542 | return 0; |
| 543 | } |
| 544 | |
Dmitry V. Levin | a0bd374 | 2015-04-07 01:36:50 +0000 | [diff] [blame] | 545 | SYS_FUNC(clock_nanosleep) |
Roland McGrath | 1e35679 | 2003-03-30 23:52:28 +0000 | [diff] [blame] | 546 | { |
| 547 | if (entering(tcp)) { |
Stefan Sørensen | a5fea90 | 2014-02-03 10:01:27 +0100 | [diff] [blame] | 548 | printclockname(tcp->u_arg[0]); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 549 | tprints(", "); |
Roland McGrath | b2dee13 | 2005-06-01 19:02:36 +0000 | [diff] [blame] | 550 | printflags(clockflags, tcp->u_arg[1], "TIMER_???"); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 551 | tprints(", "); |
Roland McGrath | 1e35679 | 2003-03-30 23:52:28 +0000 | [diff] [blame] | 552 | printtv(tcp, tcp->u_arg[2]); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 553 | tprints(", "); |
Roland McGrath | 1e35679 | 2003-03-30 23:52:28 +0000 | [diff] [blame] | 554 | } else { |
| 555 | if (syserror(tcp)) |
| 556 | tprintf("%#lx", tcp->u_arg[3]); |
| 557 | else |
| 558 | printtv(tcp, tcp->u_arg[3]); |
| 559 | } |
| 560 | return 0; |
| 561 | } |
| 562 | |
Dmitry V. Levin | a0bd374 | 2015-04-07 01:36:50 +0000 | [diff] [blame] | 563 | SYS_FUNC(clock_adjtime) |
Dmitry V. Levin | 7321547 | 2012-03-11 21:25:51 +0000 | [diff] [blame] | 564 | { |
| 565 | if (exiting(tcp)) |
| 566 | return do_adjtimex(tcp, tcp->u_arg[1]); |
Stefan Sørensen | a5fea90 | 2014-02-03 10:01:27 +0100 | [diff] [blame] | 567 | printclockname(tcp->u_arg[0]); |
Dmitry V. Levin | 7321547 | 2012-03-11 21:25:51 +0000 | [diff] [blame] | 568 | tprints(", "); |
| 569 | return 0; |
| 570 | } |
| 571 | |
Roland McGrath | 1e35679 | 2003-03-30 23:52:28 +0000 | [diff] [blame] | 572 | #ifndef SIGEV_THREAD_ID |
| 573 | # define SIGEV_THREAD_ID 4 |
| 574 | #endif |
Dmitry V. Levin | 0ed617b | 2014-04-25 23:30:54 +0000 | [diff] [blame] | 575 | #include "xlat/sigev_value.h" |
Roland McGrath | 1e35679 | 2003-03-30 23:52:28 +0000 | [diff] [blame] | 576 | |
Dmitry V. Levin | d3cb392 | 2006-12-13 17:45:02 +0000 | [diff] [blame] | 577 | #if SUPPORTED_PERSONALITIES > 1 |
| 578 | static void |
| 579 | printsigevent32(struct tcb *tcp, long arg) |
| 580 | { |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 581 | struct { |
Dmitry V. Levin | d3cb392 | 2006-12-13 17:45:02 +0000 | [diff] [blame] | 582 | int sigev_value; |
| 583 | int sigev_signo; |
| 584 | int sigev_notify; |
| 585 | |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 586 | union { |
Dmitry V. Levin | d3cb392 | 2006-12-13 17:45:02 +0000 | [diff] [blame] | 587 | int tid; |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 588 | struct { |
Dmitry V. Levin | d3cb392 | 2006-12-13 17:45:02 +0000 | [diff] [blame] | 589 | int function, attribute; |
| 590 | } thread; |
| 591 | } un; |
| 592 | } sev; |
| 593 | |
| 594 | if (umove(tcp, arg, &sev) < 0) |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 595 | tprints("{...}"); |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 596 | else { |
Dmitry V. Levin | d3cb392 | 2006-12-13 17:45:02 +0000 | [diff] [blame] | 597 | tprintf("{%#x, ", sev.sigev_value); |
| 598 | if (sev.sigev_notify == SIGEV_SIGNAL) |
| 599 | tprintf("%s, ", signame(sev.sigev_signo)); |
| 600 | else |
| 601 | tprintf("%u, ", sev.sigev_signo); |
Dmitry V. Levin | bae549e | 2014-02-05 01:46:10 +0000 | [diff] [blame] | 602 | printxval(sigev_value, sev.sigev_notify, "SIGEV_???"); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 603 | tprints(", "); |
Dmitry V. Levin | d3cb392 | 2006-12-13 17:45:02 +0000 | [diff] [blame] | 604 | if (sev.sigev_notify == SIGEV_THREAD_ID) |
| 605 | tprintf("{%d}", sev.un.tid); |
| 606 | else if (sev.sigev_notify == SIGEV_THREAD) |
| 607 | tprintf("{%#x, %#x}", |
| 608 | sev.un.thread.function, |
| 609 | sev.un.thread.attribute); |
| 610 | else |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 611 | tprints("{...}"); |
| 612 | tprints("}"); |
Dmitry V. Levin | d3cb392 | 2006-12-13 17:45:02 +0000 | [diff] [blame] | 613 | } |
| 614 | } |
| 615 | #endif |
| 616 | |
Roland McGrath | 1e35679 | 2003-03-30 23:52:28 +0000 | [diff] [blame] | 617 | void |
Dmitry V. Levin | d3cb392 | 2006-12-13 17:45:02 +0000 | [diff] [blame] | 618 | printsigevent(struct tcb *tcp, long arg) |
Roland McGrath | 1e35679 | 2003-03-30 23:52:28 +0000 | [diff] [blame] | 619 | { |
| 620 | struct sigevent sev; |
Dmitry V. Levin | d3cb392 | 2006-12-13 17:45:02 +0000 | [diff] [blame] | 621 | |
| 622 | #if SUPPORTED_PERSONALITIES > 1 |
Denys Vlasenko | 9fd4f96 | 2012-03-19 09:36:42 +0100 | [diff] [blame] | 623 | if (current_wordsize == 4) { |
Dmitry V. Levin | d3cb392 | 2006-12-13 17:45:02 +0000 | [diff] [blame] | 624 | printsigevent32(tcp, arg); |
| 625 | return; |
| 626 | } |
| 627 | #endif |
Denys Vlasenko | b63256e | 2011-06-07 12:13:24 +0200 | [diff] [blame] | 628 | if (umove(tcp, arg, &sev) < 0) |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 629 | tprints("{...}"); |
Roland McGrath | 1e35679 | 2003-03-30 23:52:28 +0000 | [diff] [blame] | 630 | else { |
Roland McGrath | 675d4a6 | 2004-09-11 08:12:45 +0000 | [diff] [blame] | 631 | tprintf("{%p, ", sev.sigev_value.sival_ptr); |
| 632 | if (sev.sigev_notify == SIGEV_SIGNAL) |
| 633 | tprintf("%s, ", signame(sev.sigev_signo)); |
| 634 | else |
| 635 | tprintf("%u, ", sev.sigev_signo); |
Dmitry V. Levin | bae549e | 2014-02-05 01:46:10 +0000 | [diff] [blame] | 636 | printxval(sigev_value, sev.sigev_notify, "SIGEV_???"); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 637 | tprints(", "); |
Roland McGrath | 1e35679 | 2003-03-30 23:52:28 +0000 | [diff] [blame] | 638 | if (sev.sigev_notify == SIGEV_THREAD_ID) |
Dmitry V. Levin | ae5aa47 | 2013-11-11 23:54:30 +0000 | [diff] [blame] | 639 | #if defined(HAVE_STRUCT_SIGEVENT__SIGEV_UN__PAD) |
Roland McGrath | 1e35679 | 2003-03-30 23:52:28 +0000 | [diff] [blame] | 640 | /* _pad[0] is the _tid field which might not be |
| 641 | present in the userlevel definition of the |
| 642 | struct. */ |
| 643 | tprintf("{%d}", sev._sigev_un._pad[0]); |
Dmitry V. Levin | ae5aa47 | 2013-11-11 23:54:30 +0000 | [diff] [blame] | 644 | #elif defined(HAVE_STRUCT_SIGEVENT___PAD) |
| 645 | tprintf("{%d}", sev.__pad[0]); |
| 646 | #else |
| 647 | # warning unfamiliar struct sigevent => incomplete SIGEV_THREAD_ID decoding |
| 648 | tprints("{...}"); |
| 649 | #endif |
Roland McGrath | d4c85eb | 2004-04-16 21:48:44 +0000 | [diff] [blame] | 650 | else if (sev.sigev_notify == SIGEV_THREAD) |
| 651 | tprintf("{%p, %p}", sev.sigev_notify_function, |
| 652 | sev.sigev_notify_attributes); |
Roland McGrath | 1e35679 | 2003-03-30 23:52:28 +0000 | [diff] [blame] | 653 | else |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 654 | tprints("{...}"); |
| 655 | tprints("}"); |
Roland McGrath | 1e35679 | 2003-03-30 23:52:28 +0000 | [diff] [blame] | 656 | } |
| 657 | } |
| 658 | |
Dmitry V. Levin | a0bd374 | 2015-04-07 01:36:50 +0000 | [diff] [blame] | 659 | SYS_FUNC(timer_create) |
Roland McGrath | 1e35679 | 2003-03-30 23:52:28 +0000 | [diff] [blame] | 660 | { |
| 661 | if (entering(tcp)) { |
Stefan Sørensen | a5fea90 | 2014-02-03 10:01:27 +0100 | [diff] [blame] | 662 | printclockname(tcp->u_arg[0]); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 663 | tprints(", "); |
Roland McGrath | 1e35679 | 2003-03-30 23:52:28 +0000 | [diff] [blame] | 664 | printsigevent(tcp, tcp->u_arg[1]); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 665 | tprints(", "); |
Roland McGrath | 1e35679 | 2003-03-30 23:52:28 +0000 | [diff] [blame] | 666 | } else { |
Andi Kleen | 732f396 | 2011-06-13 21:37:40 +0000 | [diff] [blame] | 667 | int timer_id; |
Dmitry V. Levin | ac518d1 | 2006-12-13 17:03:02 +0000 | [diff] [blame] | 668 | |
Andi Kleen | 732f396 | 2011-06-13 21:37:40 +0000 | [diff] [blame] | 669 | if (syserror(tcp) || umove(tcp, tcp->u_arg[2], &timer_id) < 0) |
Roland McGrath | 1e35679 | 2003-03-30 23:52:28 +0000 | [diff] [blame] | 670 | tprintf("%#lx", tcp->u_arg[2]); |
Dmitry V. Levin | ac518d1 | 2006-12-13 17:03:02 +0000 | [diff] [blame] | 671 | else |
Andi Kleen | 732f396 | 2011-06-13 21:37:40 +0000 | [diff] [blame] | 672 | tprintf("{%d}", timer_id); |
Roland McGrath | 1e35679 | 2003-03-30 23:52:28 +0000 | [diff] [blame] | 673 | } |
| 674 | return 0; |
| 675 | } |
| 676 | |
Dmitry V. Levin | a0bd374 | 2015-04-07 01:36:50 +0000 | [diff] [blame] | 677 | SYS_FUNC(timer_settime) |
Roland McGrath | 1e35679 | 2003-03-30 23:52:28 +0000 | [diff] [blame] | 678 | { |
| 679 | if (entering(tcp)) { |
| 680 | tprintf("%#lx, ", tcp->u_arg[0]); |
Roland McGrath | b2dee13 | 2005-06-01 19:02:36 +0000 | [diff] [blame] | 681 | printflags(clockflags, tcp->u_arg[1], "TIMER_???"); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 682 | tprints(", "); |
Roland McGrath | 1e35679 | 2003-03-30 23:52:28 +0000 | [diff] [blame] | 683 | printitv(tcp, tcp->u_arg[2]); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 684 | tprints(", "); |
Roland McGrath | 1e35679 | 2003-03-30 23:52:28 +0000 | [diff] [blame] | 685 | } else { |
| 686 | if (syserror(tcp)) |
| 687 | tprintf("%#lx", tcp->u_arg[3]); |
| 688 | else |
| 689 | printitv(tcp, tcp->u_arg[3]); |
| 690 | } |
| 691 | return 0; |
| 692 | } |
| 693 | |
Dmitry V. Levin | a0bd374 | 2015-04-07 01:36:50 +0000 | [diff] [blame] | 694 | SYS_FUNC(timer_gettime) |
Roland McGrath | 1e35679 | 2003-03-30 23:52:28 +0000 | [diff] [blame] | 695 | { |
| 696 | if (entering(tcp)) { |
| 697 | tprintf("%#lx, ", tcp->u_arg[0]); |
| 698 | } else { |
| 699 | if (syserror(tcp)) |
| 700 | tprintf("%#lx", tcp->u_arg[1]); |
| 701 | else |
| 702 | printitv(tcp, tcp->u_arg[1]); |
| 703 | } |
| 704 | return 0; |
| 705 | } |
Roland McGrath | d83c50b | 2004-10-06 22:27:43 +0000 | [diff] [blame] | 706 | |
| 707 | static void |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 708 | print_rtc(struct tcb *tcp, const struct rtc_time *rt) |
Roland McGrath | d83c50b | 2004-10-06 22:27:43 +0000 | [diff] [blame] | 709 | { |
| 710 | tprintf("{tm_sec=%d, tm_min=%d, tm_hour=%d, " |
| 711 | "tm_mday=%d, tm_mon=%d, tm_year=%d, ", |
| 712 | rt->tm_sec, rt->tm_min, rt->tm_hour, |
| 713 | rt->tm_mday, rt->tm_mon, rt->tm_year); |
| 714 | if (!abbrev(tcp)) |
| 715 | tprintf("tm_wday=%d, tm_yday=%d, tm_isdst=%d}", |
| 716 | rt->tm_wday, rt->tm_yday, rt->tm_isdst); |
| 717 | else |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 718 | tprints("...}"); |
Roland McGrath | d83c50b | 2004-10-06 22:27:43 +0000 | [diff] [blame] | 719 | } |
| 720 | |
| 721 | int |
Dmitry V. Levin | c7afb48 | 2015-01-19 18:44:21 +0000 | [diff] [blame] | 722 | rtc_ioctl(struct tcb *tcp, const unsigned int code, long arg) |
Roland McGrath | d83c50b | 2004-10-06 22:27:43 +0000 | [diff] [blame] | 723 | { |
| 724 | switch (code) { |
| 725 | case RTC_ALM_SET: |
| 726 | case RTC_SET_TIME: |
| 727 | if (entering(tcp)) { |
| 728 | struct rtc_time rt; |
| 729 | if (umove(tcp, arg, &rt) < 0) |
| 730 | tprintf(", %#lx", arg); |
| 731 | else { |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 732 | tprints(", "); |
Roland McGrath | d83c50b | 2004-10-06 22:27:43 +0000 | [diff] [blame] | 733 | print_rtc(tcp, &rt); |
| 734 | } |
| 735 | } |
| 736 | break; |
| 737 | case RTC_ALM_READ: |
| 738 | case RTC_RD_TIME: |
| 739 | if (exiting(tcp)) { |
| 740 | struct rtc_time rt; |
| 741 | if (syserror(tcp) || umove(tcp, arg, &rt) < 0) |
| 742 | tprintf(", %#lx", arg); |
| 743 | else { |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 744 | tprints(", "); |
Roland McGrath | d83c50b | 2004-10-06 22:27:43 +0000 | [diff] [blame] | 745 | print_rtc(tcp, &rt); |
| 746 | } |
| 747 | } |
| 748 | break; |
| 749 | case RTC_IRQP_SET: |
| 750 | case RTC_EPOCH_SET: |
| 751 | if (entering(tcp)) |
| 752 | tprintf(", %lu", arg); |
| 753 | break; |
| 754 | case RTC_IRQP_READ: |
| 755 | case RTC_EPOCH_READ: |
| 756 | if (exiting(tcp)) |
| 757 | tprintf(", %lu", arg); |
| 758 | break; |
| 759 | case RTC_WKALM_SET: |
| 760 | if (entering(tcp)) { |
| 761 | struct rtc_wkalrm wk; |
| 762 | if (umove(tcp, arg, &wk) < 0) |
| 763 | tprintf(", %#lx", arg); |
| 764 | else { |
| 765 | tprintf(", {enabled=%d, pending=%d, ", |
| 766 | wk.enabled, wk.pending); |
| 767 | print_rtc(tcp, &wk.time); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 768 | tprints("}"); |
Roland McGrath | d83c50b | 2004-10-06 22:27:43 +0000 | [diff] [blame] | 769 | } |
| 770 | } |
| 771 | break; |
| 772 | case RTC_WKALM_RD: |
| 773 | if (exiting(tcp)) { |
| 774 | struct rtc_wkalrm wk; |
| 775 | if (syserror(tcp) || umove(tcp, arg, &wk) < 0) |
| 776 | tprintf(", %#lx", arg); |
| 777 | else { |
| 778 | tprintf(", {enabled=%d, pending=%d, ", |
| 779 | wk.enabled, wk.pending); |
| 780 | print_rtc(tcp, &wk.time); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 781 | tprints("}"); |
Roland McGrath | d83c50b | 2004-10-06 22:27:43 +0000 | [diff] [blame] | 782 | } |
| 783 | } |
| 784 | break; |
| 785 | default: |
| 786 | if (entering(tcp)) |
| 787 | tprintf(", %#lx", arg); |
| 788 | break; |
| 789 | } |
| 790 | return 1; |
| 791 | } |
Roland McGrath | e466234 | 2007-08-02 01:25:34 +0000 | [diff] [blame] | 792 | |
Dmitry V. Levin | 0ed617b | 2014-04-25 23:30:54 +0000 | [diff] [blame] | 793 | #include "xlat/timerfdflags.h" |
Roland McGrath | e466234 | 2007-08-02 01:25:34 +0000 | [diff] [blame] | 794 | |
Dmitry V. Levin | a0bd374 | 2015-04-07 01:36:50 +0000 | [diff] [blame] | 795 | SYS_FUNC(timerfd) |
Roland McGrath | e466234 | 2007-08-02 01:25:34 +0000 | [diff] [blame] | 796 | { |
| 797 | if (entering(tcp)) { |
| 798 | /* It does not matter that the kernel uses itimerspec. */ |
| 799 | tprintf("%ld, ", tcp->u_arg[0]); |
Stefan Sørensen | a5fea90 | 2014-02-03 10:01:27 +0100 | [diff] [blame] | 800 | printclockname(tcp->u_arg[0]); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 801 | tprints(", "); |
Roland McGrath | e466234 | 2007-08-02 01:25:34 +0000 | [diff] [blame] | 802 | printflags(timerfdflags, tcp->u_arg[2], "TFD_???"); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 803 | tprints(", "); |
Roland McGrath | e466234 | 2007-08-02 01:25:34 +0000 | [diff] [blame] | 804 | printitv(tcp, tcp->u_arg[3]); |
| 805 | } |
| 806 | return 0; |
| 807 | } |
Roland McGrath | de328e6 | 2008-05-20 04:56:13 +0000 | [diff] [blame] | 808 | |
Dmitry V. Levin | a0bd374 | 2015-04-07 01:36:50 +0000 | [diff] [blame] | 809 | SYS_FUNC(timerfd_create) |
Roland McGrath | de328e6 | 2008-05-20 04:56:13 +0000 | [diff] [blame] | 810 | { |
| 811 | if (entering(tcp)) { |
Stefan Sørensen | a5fea90 | 2014-02-03 10:01:27 +0100 | [diff] [blame] | 812 | printclockname(tcp->u_arg[0]); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 813 | tprints(", "); |
Roland McGrath | de328e6 | 2008-05-20 04:56:13 +0000 | [diff] [blame] | 814 | printflags(timerfdflags, tcp->u_arg[1], "TFD_???"); |
| 815 | } |
| 816 | return 0; |
| 817 | } |
| 818 | |
Dmitry V. Levin | a0bd374 | 2015-04-07 01:36:50 +0000 | [diff] [blame] | 819 | SYS_FUNC(timerfd_settime) |
Roland McGrath | de328e6 | 2008-05-20 04:56:13 +0000 | [diff] [blame] | 820 | { |
| 821 | if (entering(tcp)) { |
Dmitry V. Levin | 3138213 | 2011-03-04 05:08:02 +0300 | [diff] [blame] | 822 | printfd(tcp, tcp->u_arg[0]); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 823 | tprints(", "); |
Roland McGrath | de328e6 | 2008-05-20 04:56:13 +0000 | [diff] [blame] | 824 | printflags(timerfdflags, tcp->u_arg[1], "TFD_???"); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 825 | tprints(", "); |
Roland McGrath | de328e6 | 2008-05-20 04:56:13 +0000 | [diff] [blame] | 826 | printitv(tcp, tcp->u_arg[2]); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 827 | tprints(", "); |
Roland McGrath | de328e6 | 2008-05-20 04:56:13 +0000 | [diff] [blame] | 828 | printitv(tcp, tcp->u_arg[3]); |
| 829 | } |
| 830 | return 0; |
| 831 | } |
| 832 | |
Dmitry V. Levin | a0bd374 | 2015-04-07 01:36:50 +0000 | [diff] [blame] | 833 | SYS_FUNC(timerfd_gettime) |
Roland McGrath | de328e6 | 2008-05-20 04:56:13 +0000 | [diff] [blame] | 834 | { |
| 835 | if (entering(tcp)) { |
Dmitry V. Levin | 3138213 | 2011-03-04 05:08:02 +0300 | [diff] [blame] | 836 | printfd(tcp, tcp->u_arg[0]); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 837 | tprints(", "); |
Roland McGrath | de328e6 | 2008-05-20 04:56:13 +0000 | [diff] [blame] | 838 | printitv(tcp, tcp->u_arg[1]); |
| 839 | } |
| 840 | return 0; |
| 841 | } |