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