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> |
Wichert Akkerman | 4dc8a2a | 1999-12-23 14:20:14 +0000 | [diff] [blame] | 5 | * Copyright (c) 1996-1999 Wichert Akkerman <wichert@cistron.nl> |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 6 | * All rights reserved. |
| 7 | * |
| 8 | * Redistribution and use in source and binary forms, with or without |
| 9 | * modification, are permitted provided that the following conditions |
| 10 | * are met: |
| 11 | * 1. Redistributions of source code must retain the above copyright |
| 12 | * notice, this list of conditions and the following disclaimer. |
| 13 | * 2. Redistributions in binary form must reproduce the above copyright |
| 14 | * notice, this list of conditions and the following disclaimer in the |
| 15 | * documentation and/or other materials provided with the distribution. |
| 16 | * 3. The name of the author may not be used to endorse or promote products |
| 17 | * derived from this software without specific prior written permission. |
| 18 | * |
| 19 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR |
| 20 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
| 21 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
| 22 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, |
| 23 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
| 24 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 25 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 26 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 27 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
| 28 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 29 | */ |
| 30 | |
| 31 | #include "defs.h" |
Dmitry V. Levin | 8829365 | 2012-03-09 21:02:19 +0000 | [diff] [blame] | 32 | #include <sys/swap.h> |
Roland McGrath | c531e57 | 2008-08-01 01:13:10 +0000 | [diff] [blame] | 33 | |
Denys Vlasenko | 9472a27 | 2013-02-12 11:43:46 +0100 | [diff] [blame] | 34 | #if defined(SPARC) || defined(SPARC64) |
Wichert Akkerman | dacfb6e | 1999-06-03 14:21:07 +0000 | [diff] [blame] | 35 | struct stat { |
| 36 | unsigned short st_dev; |
| 37 | unsigned int st_ino; |
| 38 | unsigned short st_mode; |
| 39 | short st_nlink; |
| 40 | unsigned short st_uid; |
| 41 | unsigned short st_gid; |
| 42 | unsigned short st_rdev; |
| 43 | unsigned int st_size; |
| 44 | int st_atime; |
| 45 | unsigned int __unused1; |
| 46 | int st_mtime; |
| 47 | unsigned int __unused2; |
| 48 | int st_ctime; |
| 49 | unsigned int __unused3; |
| 50 | int st_blksize; |
| 51 | int st_blocks; |
| 52 | unsigned int __unused4[2]; |
| 53 | }; |
Denys Vlasenko | 8470374 | 2012-02-25 02:38:52 +0100 | [diff] [blame] | 54 | # if defined(SPARC64) |
Roland McGrath | 6d1a65c | 2004-07-12 07:44:08 +0000 | [diff] [blame] | 55 | struct stat_sparc64 { |
| 56 | unsigned int st_dev; |
| 57 | unsigned long st_ino; |
| 58 | unsigned int st_mode; |
| 59 | unsigned int st_nlink; |
| 60 | unsigned int st_uid; |
| 61 | unsigned int st_gid; |
| 62 | unsigned int st_rdev; |
| 63 | long st_size; |
| 64 | long st_atime; |
| 65 | long st_mtime; |
| 66 | long st_ctime; |
| 67 | long st_blksize; |
| 68 | long st_blocks; |
| 69 | unsigned long __unused4[2]; |
| 70 | }; |
Denys Vlasenko | 8470374 | 2012-02-25 02:38:52 +0100 | [diff] [blame] | 71 | # endif /* SPARC64 */ |
| 72 | # define stat kernel_stat |
| 73 | # include <asm/stat.h> |
| 74 | # undef stat |
H.J. Lu | 35be581 | 2012-04-16 13:00:01 +0200 | [diff] [blame] | 75 | #elif defined(X32) |
| 76 | struct stat { |
| 77 | unsigned long long st_dev; |
| 78 | unsigned long long st_ino; |
| 79 | unsigned long long st_nlink; |
| 80 | |
| 81 | unsigned int st_mode; |
| 82 | unsigned int st_uid; |
| 83 | unsigned int st_gid; |
| 84 | unsigned int __pad0; |
| 85 | unsigned long long st_rdev; |
| 86 | long long st_size; |
| 87 | long long st_blksize; |
| 88 | long long st_blocks; |
| 89 | |
| 90 | unsigned long long st_atime; |
| 91 | unsigned long long st_atime_nsec; |
| 92 | unsigned long long st_mtime; |
| 93 | unsigned long long st_mtime_nsec; |
| 94 | unsigned long long st_ctime; |
| 95 | unsigned long long st_ctime_nsec; |
| 96 | long long __unused[3]; |
| 97 | }; |
H.J. Lu | 085e428 | 2012-04-17 11:05:04 -0700 | [diff] [blame] | 98 | |
| 99 | struct stat64 { |
| 100 | unsigned long long st_dev; |
| 101 | unsigned char __pad0[4]; |
| 102 | unsigned long __st_ino; |
| 103 | unsigned int st_mode; |
| 104 | unsigned int st_nlink; |
| 105 | unsigned long st_uid; |
| 106 | unsigned long st_gid; |
| 107 | unsigned long long st_rdev; |
| 108 | unsigned char __pad3[4]; |
| 109 | long long st_size; |
| 110 | unsigned long st_blksize; |
| 111 | unsigned long long st_blocks; |
| 112 | unsigned long st_atime; |
| 113 | unsigned long st_atime_nsec; |
| 114 | unsigned long st_mtime; |
| 115 | unsigned int st_mtime_nsec; |
| 116 | unsigned long st_ctime; |
| 117 | unsigned long st_ctime_nsec; |
| 118 | unsigned long long st_ino; |
Dmitry V. Levin | 0eeda2c | 2013-05-01 16:37:08 +0000 | [diff] [blame] | 119 | } __attribute__((packed)); |
| 120 | # define HAVE_STAT64 1 |
Dmitry V. Levin | bd2e28a | 2013-05-01 15:14:25 +0000 | [diff] [blame] | 121 | |
| 122 | struct __old_kernel_stat { |
| 123 | unsigned short st_dev; |
| 124 | unsigned short st_ino; |
| 125 | unsigned short st_mode; |
| 126 | unsigned short st_nlink; |
| 127 | unsigned short st_uid; |
| 128 | unsigned short st_gid; |
| 129 | unsigned short st_rdev; |
| 130 | unsigned int st_size; |
| 131 | unsigned int st_atime; |
| 132 | unsigned int st_mtime; |
| 133 | unsigned int st_ctime; |
| 134 | }; |
Denys Vlasenko | 8470374 | 2012-02-25 02:38:52 +0100 | [diff] [blame] | 135 | #else |
| 136 | # undef dev_t |
| 137 | # undef ino_t |
| 138 | # undef mode_t |
| 139 | # undef nlink_t |
| 140 | # undef uid_t |
| 141 | # undef gid_t |
| 142 | # undef off_t |
| 143 | # undef loff_t |
Denys Vlasenko | 8470374 | 2012-02-25 02:38:52 +0100 | [diff] [blame] | 144 | # define dev_t __kernel_dev_t |
| 145 | # define ino_t __kernel_ino_t |
| 146 | # define mode_t __kernel_mode_t |
| 147 | # define nlink_t __kernel_nlink_t |
| 148 | # define uid_t __kernel_uid_t |
| 149 | # define gid_t __kernel_gid_t |
| 150 | # define off_t __kernel_off_t |
| 151 | # define loff_t __kernel_loff_t |
Wichert Akkerman | a601370 | 1999-07-08 14:00:58 +0000 | [diff] [blame] | 152 | |
Denys Vlasenko | 8470374 | 2012-02-25 02:38:52 +0100 | [diff] [blame] | 153 | # include <asm/stat.h> |
Wichert Akkerman | a601370 | 1999-07-08 14:00:58 +0000 | [diff] [blame] | 154 | |
Denys Vlasenko | 8470374 | 2012-02-25 02:38:52 +0100 | [diff] [blame] | 155 | # undef dev_t |
| 156 | # undef ino_t |
| 157 | # undef mode_t |
| 158 | # undef nlink_t |
| 159 | # undef uid_t |
| 160 | # undef gid_t |
| 161 | # undef off_t |
| 162 | # undef loff_t |
Denys Vlasenko | 8470374 | 2012-02-25 02:38:52 +0100 | [diff] [blame] | 163 | # define dev_t dev_t |
| 164 | # define ino_t ino_t |
| 165 | # define mode_t mode_t |
| 166 | # define nlink_t nlink_t |
| 167 | # define uid_t uid_t |
| 168 | # define gid_t gid_t |
| 169 | # define off_t off_t |
| 170 | # define loff_t loff_t |
| 171 | #endif |
| 172 | |
Denys Vlasenko | 8470374 | 2012-02-25 02:38:52 +0100 | [diff] [blame] | 173 | #define stat libc_stat |
| 174 | #define stat64 libc_stat64 |
| 175 | #include <sys/stat.h> |
| 176 | #undef stat |
| 177 | #undef stat64 |
Denys Vlasenko | a6d91de | 2012-03-16 12:02:22 +0100 | [diff] [blame] | 178 | /* These might be macros. */ |
Denys Vlasenko | 8470374 | 2012-02-25 02:38:52 +0100 | [diff] [blame] | 179 | #undef st_atime |
| 180 | #undef st_mtime |
| 181 | #undef st_ctime |
Wichert Akkerman | d4d8e92 | 1999-04-18 23:30:29 +0000 | [diff] [blame] | 182 | |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 183 | #include <fcntl.h> |
Roland McGrath | 186c5ac | 2002-12-15 23:58:23 +0000 | [diff] [blame] | 184 | #ifdef HAVE_LINUX_XATTR_H |
Denys Vlasenko | 8470374 | 2012-02-25 02:38:52 +0100 | [diff] [blame] | 185 | # include <linux/xattr.h> |
Denys Vlasenko | ed720fd | 2012-02-25 02:24:03 +0100 | [diff] [blame] | 186 | #else |
Denys Vlasenko | 8470374 | 2012-02-25 02:38:52 +0100 | [diff] [blame] | 187 | # define XATTR_CREATE 1 |
| 188 | # define XATTR_REPLACE 2 |
Roland McGrath | 186c5ac | 2002-12-15 23:58:23 +0000 | [diff] [blame] | 189 | #endif |
| 190 | |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 191 | #ifdef MAJOR_IN_SYSMACROS |
Denys Vlasenko | 8470374 | 2012-02-25 02:38:52 +0100 | [diff] [blame] | 192 | # include <sys/sysmacros.h> |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 193 | #endif |
| 194 | |
| 195 | #ifdef MAJOR_IN_MKDEV |
Denys Vlasenko | 8470374 | 2012-02-25 02:38:52 +0100 | [diff] [blame] | 196 | # include <sys/mkdev.h> |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 197 | #endif |
| 198 | |
Dmitry V. Levin | 63ebcfc | 2014-04-26 15:35:02 +0000 | [diff] [blame] | 199 | #ifdef O_LARGEFILE |
| 200 | # if O_LARGEFILE == 0 /* biarch platforms in 64-bit mode */ |
| 201 | # undef O_LARGEFILE |
| 202 | # ifdef SPARC64 |
| 203 | # define O_LARGEFILE 0x40000 |
| 204 | # elif defined X86_64 || defined S390X |
| 205 | # define O_LARGEFILE 0100000 |
| 206 | # endif |
| 207 | # endif |
| 208 | #endif |
| 209 | |
Dmitry V. Levin | 0ed617b | 2014-04-25 23:30:54 +0000 | [diff] [blame] | 210 | #include "xlat/open_access_modes.h" |
Dmitry V. Levin | 0ed617b | 2014-04-25 23:30:54 +0000 | [diff] [blame] | 211 | #include "xlat/open_mode_flags.h" |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 212 | |
Dmitry V. Levin | 95ebf5a | 2006-10-13 20:25:12 +0000 | [diff] [blame] | 213 | #ifndef AT_FDCWD |
| 214 | # define AT_FDCWD -100 |
| 215 | #endif |
| 216 | |
Denys Vlasenko | e740fd3 | 2009-04-16 12:06:16 +0000 | [diff] [blame] | 217 | /* The fd is an "int", so when decoding x86 on x86_64, we need to force sign |
| 218 | * extension to get the right value. We do this by declaring fd as int here. |
| 219 | */ |
Dmitry V. Levin | 99db95d | 2014-02-05 04:13:18 +0000 | [diff] [blame] | 220 | void |
Dmitry V. Levin | 3138213 | 2011-03-04 05:08:02 +0300 | [diff] [blame] | 221 | print_dirfd(struct tcb *tcp, int fd) |
Dmitry V. Levin | 95ebf5a | 2006-10-13 20:25:12 +0000 | [diff] [blame] | 222 | { |
| 223 | if (fd == AT_FDCWD) |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 224 | tprints("AT_FDCWD, "); |
Denys Vlasenko | 7b609d5 | 2011-06-22 14:32:43 +0200 | [diff] [blame] | 225 | else { |
Dmitry V. Levin | 3138213 | 2011-03-04 05:08:02 +0300 | [diff] [blame] | 226 | printfd(tcp, fd); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 227 | tprints(", "); |
Dmitry V. Levin | 3138213 | 2011-03-04 05:08:02 +0300 | [diff] [blame] | 228 | } |
Dmitry V. Levin | 95ebf5a | 2006-10-13 20:25:12 +0000 | [diff] [blame] | 229 | } |
Dmitry V. Levin | 95ebf5a | 2006-10-13 20:25:12 +0000 | [diff] [blame] | 230 | |
Dmitry V. Levin | 9b5b67e | 2007-01-11 23:19:55 +0000 | [diff] [blame] | 231 | /* |
| 232 | * low bits of the open(2) flags define access mode, |
| 233 | * other bits are real flags. |
| 234 | */ |
Denys Vlasenko | eedaac7 | 2009-03-10 20:41:58 +0000 | [diff] [blame] | 235 | const char * |
Elliott Hughes | 22e34b9 | 2014-09-23 19:09:50 -0700 | [diff] [blame] | 236 | sprint_open_modes(int flags) |
Dmitry V. Levin | 9b5b67e | 2007-01-11 23:19:55 +0000 | [diff] [blame] | 237 | { |
Denys Vlasenko | 4f3df07 | 2012-01-29 22:38:35 +0100 | [diff] [blame] | 238 | static char outstr[(1 + ARRAY_SIZE(open_mode_flags)) * sizeof("O_LARGEFILE")]; |
Denys Vlasenko | eedaac7 | 2009-03-10 20:41:58 +0000 | [diff] [blame] | 239 | char *p; |
Denys Vlasenko | 4f3df07 | 2012-01-29 22:38:35 +0100 | [diff] [blame] | 240 | char sep; |
Denys Vlasenko | eedaac7 | 2009-03-10 20:41:58 +0000 | [diff] [blame] | 241 | const char *str; |
| 242 | const struct xlat *x; |
Dmitry V. Levin | 9b5b67e | 2007-01-11 23:19:55 +0000 | [diff] [blame] | 243 | |
Denys Vlasenko | 4f3df07 | 2012-01-29 22:38:35 +0100 | [diff] [blame] | 244 | sep = ' '; |
| 245 | p = stpcpy(outstr, "flags"); |
Denys Vlasenko | eedaac7 | 2009-03-10 20:41:58 +0000 | [diff] [blame] | 246 | str = xlookup(open_access_modes, flags & 3); |
| 247 | if (str) { |
Denys Vlasenko | 4f3df07 | 2012-01-29 22:38:35 +0100 | [diff] [blame] | 248 | *p++ = sep; |
Denys Vlasenko | 5284557 | 2011-08-31 12:07:38 +0200 | [diff] [blame] | 249 | p = stpcpy(p, str); |
Dmitry V. Levin | 9b5b67e | 2007-01-11 23:19:55 +0000 | [diff] [blame] | 250 | flags &= ~3; |
| 251 | if (!flags) |
Denys Vlasenko | eedaac7 | 2009-03-10 20:41:58 +0000 | [diff] [blame] | 252 | return outstr; |
| 253 | sep = '|'; |
Dmitry V. Levin | 9b5b67e | 2007-01-11 23:19:55 +0000 | [diff] [blame] | 254 | } |
Denys Vlasenko | eedaac7 | 2009-03-10 20:41:58 +0000 | [diff] [blame] | 255 | |
| 256 | for (x = open_mode_flags; x->str; x++) { |
| 257 | if ((flags & x->val) == x->val) { |
Denys Vlasenko | 4f3df07 | 2012-01-29 22:38:35 +0100 | [diff] [blame] | 258 | *p++ = sep; |
Denys Vlasenko | 5284557 | 2011-08-31 12:07:38 +0200 | [diff] [blame] | 259 | p = stpcpy(p, x->str); |
Denys Vlasenko | eedaac7 | 2009-03-10 20:41:58 +0000 | [diff] [blame] | 260 | flags &= ~x->val; |
| 261 | if (!flags) |
| 262 | return outstr; |
| 263 | sep = '|'; |
| 264 | } |
| 265 | } |
| 266 | /* flags is still nonzero */ |
Denys Vlasenko | 4f3df07 | 2012-01-29 22:38:35 +0100 | [diff] [blame] | 267 | *p++ = sep; |
Denys Vlasenko | eedaac7 | 2009-03-10 20:41:58 +0000 | [diff] [blame] | 268 | sprintf(p, "%#x", flags); |
| 269 | return outstr; |
| 270 | } |
| 271 | |
| 272 | void |
Elliott Hughes | 22e34b9 | 2014-09-23 19:09:50 -0700 | [diff] [blame] | 273 | tprint_open_modes(int flags) |
Denys Vlasenko | eedaac7 | 2009-03-10 20:41:58 +0000 | [diff] [blame] | 274 | { |
Denys Vlasenko | 5940e65 | 2011-09-01 09:55:05 +0200 | [diff] [blame] | 275 | tprints(sprint_open_modes(flags) + sizeof("flags")); |
Dmitry V. Levin | 9b5b67e | 2007-01-11 23:19:55 +0000 | [diff] [blame] | 276 | } |
| 277 | |
Dmitry V. Levin | 95ebf5a | 2006-10-13 20:25:12 +0000 | [diff] [blame] | 278 | static int |
| 279 | decode_open(struct tcb *tcp, int offset) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 280 | { |
| 281 | if (entering(tcp)) { |
Dmitry V. Levin | 95ebf5a | 2006-10-13 20:25:12 +0000 | [diff] [blame] | 282 | printpath(tcp, tcp->u_arg[offset]); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 283 | tprints(", "); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 284 | /* flags */ |
Denys Vlasenko | eedaac7 | 2009-03-10 20:41:58 +0000 | [diff] [blame] | 285 | tprint_open_modes(tcp->u_arg[offset + 1]); |
Dmitry V. Levin | 95ebf5a | 2006-10-13 20:25:12 +0000 | [diff] [blame] | 286 | if (tcp->u_arg[offset + 1] & O_CREAT) { |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 287 | /* mode */ |
Dmitry V. Levin | 95ebf5a | 2006-10-13 20:25:12 +0000 | [diff] [blame] | 288 | tprintf(", %#lo", tcp->u_arg[offset + 2]); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 289 | } |
| 290 | } |
Zubin Mithra | 64aa1b1 | 2014-06-04 08:30:41 +0530 | [diff] [blame] | 291 | return RVAL_FD; |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 292 | } |
| 293 | |
Dmitry V. Levin | 95ebf5a | 2006-10-13 20:25:12 +0000 | [diff] [blame] | 294 | int |
| 295 | sys_open(struct tcb *tcp) |
| 296 | { |
| 297 | return decode_open(tcp, 0); |
| 298 | } |
| 299 | |
Dmitry V. Levin | 95ebf5a | 2006-10-13 20:25:12 +0000 | [diff] [blame] | 300 | int |
| 301 | sys_openat(struct tcb *tcp) |
| 302 | { |
| 303 | if (entering(tcp)) |
Dmitry V. Levin | 3138213 | 2011-03-04 05:08:02 +0300 | [diff] [blame] | 304 | print_dirfd(tcp, tcp->u_arg[0]); |
Dmitry V. Levin | 95ebf5a | 2006-10-13 20:25:12 +0000 | [diff] [blame] | 305 | return decode_open(tcp, 1); |
| 306 | } |
Dmitry V. Levin | 95ebf5a | 2006-10-13 20:25:12 +0000 | [diff] [blame] | 307 | |
Denys Vlasenko | 9472a27 | 2013-02-12 11:43:46 +0100 | [diff] [blame] | 308 | #if defined(SPARC) || defined(SPARC64) |
Dmitry V. Levin | 0ed617b | 2014-04-25 23:30:54 +0000 | [diff] [blame] | 309 | #include "xlat/openmodessol.h" |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 310 | |
| 311 | int |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 312 | solaris_open(struct tcb *tcp) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 313 | { |
| 314 | if (entering(tcp)) { |
| 315 | printpath(tcp, tcp->u_arg[0]); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 316 | tprints(", "); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 317 | /* flags */ |
Roland McGrath | b2dee13 | 2005-06-01 19:02:36 +0000 | [diff] [blame] | 318 | printflags(openmodessol, tcp->u_arg[1] + 1, "O_???"); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 319 | if (tcp->u_arg[1] & 0x100) { |
| 320 | /* mode */ |
| 321 | tprintf(", %#lo", tcp->u_arg[2]); |
| 322 | } |
| 323 | } |
| 324 | return 0; |
| 325 | } |
| 326 | |
| 327 | #endif |
| 328 | |
| 329 | int |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 330 | sys_creat(struct tcb *tcp) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 331 | { |
| 332 | if (entering(tcp)) { |
| 333 | printpath(tcp, tcp->u_arg[0]); |
| 334 | tprintf(", %#lo", tcp->u_arg[1]); |
| 335 | } |
Zubin Mithra | 64aa1b1 | 2014-06-04 08:30:41 +0530 | [diff] [blame] | 336 | return RVAL_FD; |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 337 | } |
| 338 | |
Dmitry V. Levin | 0ed617b | 2014-04-25 23:30:54 +0000 | [diff] [blame] | 339 | #include "xlat/access_flags.h" |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 340 | |
Dmitry V. Levin | 95ebf5a | 2006-10-13 20:25:12 +0000 | [diff] [blame] | 341 | static int |
| 342 | decode_access(struct tcb *tcp, int offset) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 343 | { |
| 344 | if (entering(tcp)) { |
Dmitry V. Levin | 95ebf5a | 2006-10-13 20:25:12 +0000 | [diff] [blame] | 345 | printpath(tcp, tcp->u_arg[offset]); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 346 | tprints(", "); |
Dmitry V. Levin | 95ebf5a | 2006-10-13 20:25:12 +0000 | [diff] [blame] | 347 | printflags(access_flags, tcp->u_arg[offset + 1], "?_OK"); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 348 | } |
| 349 | return 0; |
| 350 | } |
| 351 | |
| 352 | int |
Dmitry V. Levin | 95ebf5a | 2006-10-13 20:25:12 +0000 | [diff] [blame] | 353 | sys_access(struct tcb *tcp) |
| 354 | { |
| 355 | return decode_access(tcp, 0); |
| 356 | } |
| 357 | |
Dmitry V. Levin | 95ebf5a | 2006-10-13 20:25:12 +0000 | [diff] [blame] | 358 | int |
| 359 | sys_faccessat(struct tcb *tcp) |
| 360 | { |
| 361 | if (entering(tcp)) |
Dmitry V. Levin | 3138213 | 2011-03-04 05:08:02 +0300 | [diff] [blame] | 362 | print_dirfd(tcp, tcp->u_arg[0]); |
Dmitry V. Levin | 95ebf5a | 2006-10-13 20:25:12 +0000 | [diff] [blame] | 363 | return decode_access(tcp, 1); |
| 364 | } |
Dmitry V. Levin | 95ebf5a | 2006-10-13 20:25:12 +0000 | [diff] [blame] | 365 | |
| 366 | int |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 367 | sys_umask(struct tcb *tcp) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 368 | { |
| 369 | if (entering(tcp)) { |
| 370 | tprintf("%#lo", tcp->u_arg[0]); |
| 371 | } |
| 372 | return RVAL_OCTAL; |
| 373 | } |
| 374 | |
Dmitry V. Levin | 0ed617b | 2014-04-25 23:30:54 +0000 | [diff] [blame] | 375 | #include "xlat/whence_codes.h" |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 376 | |
Denys Vlasenko | 386b871 | 2013-02-17 01:38:14 +0100 | [diff] [blame] | 377 | /* Linux kernel has exactly one version of lseek: |
| 378 | * fs/read_write.c::SYSCALL_DEFINE3(lseek, unsigned, fd, off_t, offset, unsigned, origin) |
| 379 | * In kernel, off_t is always the same as (kernel's) long |
| 380 | * (see include/uapi/asm-generic/posix_types.h), |
| 381 | * which means that on x32 we need to use tcp->ext_arg[N] to get offset argument. |
Denys Vlasenko | 09a87ae | 2013-02-17 13:17:49 +0100 | [diff] [blame] | 382 | * Use test/x32_lseek.c to test lseek decoding. |
Denys Vlasenko | 386b871 | 2013-02-17 01:38:14 +0100 | [diff] [blame] | 383 | */ |
H.J. Lu | c933f27 | 2012-04-16 17:41:13 +0200 | [diff] [blame] | 384 | #if defined(LINUX_MIPSN32) || defined(X32) |
Roland McGrath | 542c2c6 | 2008-05-20 01:11:56 +0000 | [diff] [blame] | 385 | int |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 386 | sys_lseek(struct tcb *tcp) |
Roland McGrath | 542c2c6 | 2008-05-20 01:11:56 +0000 | [diff] [blame] | 387 | { |
| 388 | long long offset; |
Denys Vlasenko | 386b871 | 2013-02-17 01:38:14 +0100 | [diff] [blame] | 389 | int whence; |
Roland McGrath | 542c2c6 | 2008-05-20 01:11:56 +0000 | [diff] [blame] | 390 | |
| 391 | if (entering(tcp)) { |
Dmitry V. Levin | 3138213 | 2011-03-04 05:08:02 +0300 | [diff] [blame] | 392 | printfd(tcp, tcp->u_arg[0]); |
Roland McGrath | 542c2c6 | 2008-05-20 01:11:56 +0000 | [diff] [blame] | 393 | offset = tcp->ext_arg[1]; |
Denys Vlasenko | 386b871 | 2013-02-17 01:38:14 +0100 | [diff] [blame] | 394 | whence = tcp->u_arg[2]; |
| 395 | if (whence == SEEK_SET) |
| 396 | tprintf(", %llu, ", offset); |
Roland McGrath | 542c2c6 | 2008-05-20 01:11:56 +0000 | [diff] [blame] | 397 | else |
Denys Vlasenko | 386b871 | 2013-02-17 01:38:14 +0100 | [diff] [blame] | 398 | tprintf(", %lld, ", offset); |
Denys Vlasenko | 782d90f | 2013-02-17 12:47:44 +0100 | [diff] [blame] | 399 | printxval(whence_codes, whence, "SEEK_???"); |
Roland McGrath | 542c2c6 | 2008-05-20 01:11:56 +0000 | [diff] [blame] | 400 | } |
H.J. Lu | dd0130b | 2012-04-16 12:16:45 +0200 | [diff] [blame] | 401 | return RVAL_LUDECIMAL; |
Roland McGrath | 542c2c6 | 2008-05-20 01:11:56 +0000 | [diff] [blame] | 402 | } |
H.J. Lu | dd0130b | 2012-04-16 12:16:45 +0200 | [diff] [blame] | 403 | #else |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 404 | int |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 405 | sys_lseek(struct tcb *tcp) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 406 | { |
Denys Vlasenko | 0612176 | 2013-02-17 20:08:50 +0100 | [diff] [blame] | 407 | long offset; |
Denys Vlasenko | 386b871 | 2013-02-17 01:38:14 +0100 | [diff] [blame] | 408 | int whence; |
Wichert Akkerman | bf79f2e | 2000-09-01 21:03:06 +0000 | [diff] [blame] | 409 | |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 410 | if (entering(tcp)) { |
Dmitry V. Levin | 3138213 | 2011-03-04 05:08:02 +0300 | [diff] [blame] | 411 | printfd(tcp, tcp->u_arg[0]); |
Wichert Akkerman | bf79f2e | 2000-09-01 21:03:06 +0000 | [diff] [blame] | 412 | offset = tcp->u_arg[1]; |
Denys Vlasenko | 386b871 | 2013-02-17 01:38:14 +0100 | [diff] [blame] | 413 | whence = tcp->u_arg[2]; |
| 414 | if (whence == SEEK_SET) |
| 415 | tprintf(", %lu, ", offset); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 416 | else |
Denys Vlasenko | 386b871 | 2013-02-17 01:38:14 +0100 | [diff] [blame] | 417 | tprintf(", %ld, ", offset); |
Denys Vlasenko | 782d90f | 2013-02-17 12:47:44 +0100 | [diff] [blame] | 418 | printxval(whence_codes, whence, "SEEK_???"); |
Roland McGrath | 186c5ac | 2002-12-15 23:58:23 +0000 | [diff] [blame] | 419 | } |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 420 | return RVAL_UDECIMAL; |
| 421 | } |
John Hughes | 5a826b8 | 2001-03-07 13:21:24 +0000 | [diff] [blame] | 422 | #endif |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 423 | |
Denys Vlasenko | 386b871 | 2013-02-17 01:38:14 +0100 | [diff] [blame] | 424 | /* llseek syscall takes explicitly two ulong arguments hi, lo, |
| 425 | * rather than one 64-bit argument for which LONG_LONG works |
| 426 | * appropriate for the native byte order. |
| 427 | * |
| 428 | * See kernel's fs/read_write.c::SYSCALL_DEFINE5(llseek, ...) |
| 429 | * |
| 430 | * hi,lo are "unsigned longs" and combined exactly this way in kernel: |
| 431 | * ((loff_t) hi << 32) | lo |
Denys Vlasenko | 09a87ae | 2013-02-17 13:17:49 +0100 | [diff] [blame] | 432 | * Note that for architectures with kernel's long wider than userspace long |
Denys Vlasenko | 386b871 | 2013-02-17 01:38:14 +0100 | [diff] [blame] | 433 | * (such as x32), combining code will use *kernel's*, i.e. *wide* longs |
Denys Vlasenko | 0612176 | 2013-02-17 20:08:50 +0100 | [diff] [blame] | 434 | * for hi and lo. We would need to use tcp->ext_arg[N] on x32... |
| 435 | * ...however, x32 (and x86_64) does not _have_ llseek syscall as such. |
Denys Vlasenko | 386b871 | 2013-02-17 01:38:14 +0100 | [diff] [blame] | 436 | */ |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 437 | int |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 438 | sys_llseek(struct tcb *tcp) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 439 | { |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 440 | if (entering(tcp)) { |
Dmitry V. Levin | 3138213 | 2011-03-04 05:08:02 +0300 | [diff] [blame] | 441 | printfd(tcp, tcp->u_arg[0]); |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 442 | if (tcp->u_arg[4] == SEEK_SET) |
Dmitry V. Levin | 3138213 | 2011-03-04 05:08:02 +0300 | [diff] [blame] | 443 | tprintf(", %llu, ", |
Denys Vlasenko | 386b871 | 2013-02-17 01:38:14 +0100 | [diff] [blame] | 444 | ((long long) tcp->u_arg[1]) << 32 | |
Dmitry V. Levin | 3138213 | 2011-03-04 05:08:02 +0300 | [diff] [blame] | 445 | (unsigned long long) (unsigned) tcp->u_arg[2]); |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 446 | else |
Dmitry V. Levin | 3138213 | 2011-03-04 05:08:02 +0300 | [diff] [blame] | 447 | tprintf(", %lld, ", |
Denys Vlasenko | 386b871 | 2013-02-17 01:38:14 +0100 | [diff] [blame] | 448 | ((long long) tcp->u_arg[1]) << 32 | |
Dmitry V. Levin | 3138213 | 2011-03-04 05:08:02 +0300 | [diff] [blame] | 449 | (unsigned long long) (unsigned) tcp->u_arg[2]); |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 450 | } |
| 451 | else { |
Denys Vlasenko | 386b871 | 2013-02-17 01:38:14 +0100 | [diff] [blame] | 452 | long long off; |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 453 | if (syserror(tcp) || umove(tcp, tcp->u_arg[3], &off) < 0) |
| 454 | tprintf("%#lx, ", tcp->u_arg[3]); |
| 455 | else |
| 456 | tprintf("[%llu], ", off); |
Denys Vlasenko | 782d90f | 2013-02-17 12:47:44 +0100 | [diff] [blame] | 457 | printxval(whence_codes, tcp->u_arg[4], "SEEK_???"); |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 458 | } |
| 459 | return 0; |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 460 | } |
Roland McGrath | 186c5ac | 2002-12-15 23:58:23 +0000 | [diff] [blame] | 461 | |
| 462 | int |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 463 | sys_readahead(struct tcb *tcp) |
Roland McGrath | 186c5ac | 2002-12-15 23:58:23 +0000 | [diff] [blame] | 464 | { |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 465 | if (entering(tcp)) { |
Andreas Schwab | b5600fc | 2009-11-04 17:08:34 +0100 | [diff] [blame] | 466 | int argn; |
Dmitry V. Levin | 3138213 | 2011-03-04 05:08:02 +0300 | [diff] [blame] | 467 | printfd(tcp, tcp->u_arg[0]); |
Dmitry V. Levin | 3c49b02 | 2014-08-07 00:07:28 +0000 | [diff] [blame] | 468 | argn = printllval(tcp, ", %lld", 1); |
Andreas Schwab | b5600fc | 2009-11-04 17:08:34 +0100 | [diff] [blame] | 469 | tprintf(", %ld", tcp->u_arg[argn]); |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 470 | } |
| 471 | return 0; |
Roland McGrath | 186c5ac | 2002-12-15 23:58:23 +0000 | [diff] [blame] | 472 | } |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 473 | |
| 474 | int |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 475 | sys_truncate(struct tcb *tcp) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 476 | { |
| 477 | if (entering(tcp)) { |
| 478 | printpath(tcp, tcp->u_arg[0]); |
| 479 | tprintf(", %lu", tcp->u_arg[1]); |
| 480 | } |
| 481 | return 0; |
| 482 | } |
| 483 | |
John Hughes | 96f5147 | 2001-03-06 16:50:41 +0000 | [diff] [blame] | 484 | int |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 485 | sys_truncate64(struct tcb *tcp) |
John Hughes | 96f5147 | 2001-03-06 16:50:41 +0000 | [diff] [blame] | 486 | { |
| 487 | if (entering(tcp)) { |
| 488 | printpath(tcp, tcp->u_arg[0]); |
Dmitry V. Levin | 3c49b02 | 2014-08-07 00:07:28 +0000 | [diff] [blame] | 489 | printllval(tcp, ", %llu", 1); |
John Hughes | 96f5147 | 2001-03-06 16:50:41 +0000 | [diff] [blame] | 490 | } |
| 491 | return 0; |
| 492 | } |
John Hughes | 96f5147 | 2001-03-06 16:50:41 +0000 | [diff] [blame] | 493 | |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 494 | int |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 495 | sys_ftruncate(struct tcb *tcp) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 496 | { |
| 497 | if (entering(tcp)) { |
Dmitry V. Levin | 3138213 | 2011-03-04 05:08:02 +0300 | [diff] [blame] | 498 | printfd(tcp, tcp->u_arg[0]); |
| 499 | tprintf(", %lu", tcp->u_arg[1]); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 500 | } |
| 501 | return 0; |
| 502 | } |
| 503 | |
John Hughes | 96f5147 | 2001-03-06 16:50:41 +0000 | [diff] [blame] | 504 | int |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 505 | sys_ftruncate64(struct tcb *tcp) |
John Hughes | 96f5147 | 2001-03-06 16:50:41 +0000 | [diff] [blame] | 506 | { |
| 507 | if (entering(tcp)) { |
Dmitry V. Levin | 3138213 | 2011-03-04 05:08:02 +0300 | [diff] [blame] | 508 | printfd(tcp, tcp->u_arg[0]); |
Dmitry V. Levin | 3c49b02 | 2014-08-07 00:07:28 +0000 | [diff] [blame] | 509 | printllval(tcp, ", %llu", 1); |
John Hughes | 96f5147 | 2001-03-06 16:50:41 +0000 | [diff] [blame] | 510 | } |
| 511 | return 0; |
| 512 | } |
John Hughes | 96f5147 | 2001-03-06 16:50:41 +0000 | [diff] [blame] | 513 | |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 514 | /* several stats */ |
| 515 | |
Dmitry V. Levin | 0ed617b | 2014-04-25 23:30:54 +0000 | [diff] [blame] | 516 | #include "xlat/modetypes.h" |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 517 | |
Roland McGrath | f9c49b2 | 2004-10-06 22:11:54 +0000 | [diff] [blame] | 518 | static const char * |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 519 | sprintmode(int mode) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 520 | { |
Denys Vlasenko | 1945ccc | 2012-02-27 14:37:48 +0100 | [diff] [blame] | 521 | static char buf[sizeof("S_IFSOCK|S_ISUID|S_ISGID|S_ISVTX|%o") |
| 522 | + sizeof(int)*3 |
| 523 | + /*paranoia:*/ 8]; |
Roland McGrath | f9c49b2 | 2004-10-06 22:11:54 +0000 | [diff] [blame] | 524 | const char *s; |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 525 | |
| 526 | if ((mode & S_IFMT) == 0) |
| 527 | s = ""; |
| 528 | else if ((s = xlookup(modetypes, mode & S_IFMT)) == NULL) { |
| 529 | sprintf(buf, "%#o", mode); |
| 530 | return buf; |
| 531 | } |
Denys Vlasenko | 1945ccc | 2012-02-27 14:37:48 +0100 | [diff] [blame] | 532 | s = buf + sprintf(buf, "%s%s%s%s", s, |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 533 | (mode & S_ISUID) ? "|S_ISUID" : "", |
| 534 | (mode & S_ISGID) ? "|S_ISGID" : "", |
| 535 | (mode & S_ISVTX) ? "|S_ISVTX" : ""); |
| 536 | mode &= ~(S_IFMT|S_ISUID|S_ISGID|S_ISVTX); |
| 537 | if (mode) |
Denys Vlasenko | 1945ccc | 2012-02-27 14:37:48 +0100 | [diff] [blame] | 538 | sprintf((char*)s, "|%#o", mode); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 539 | s = (*buf == '|') ? buf + 1 : buf; |
| 540 | return *s ? s : "0"; |
| 541 | } |
| 542 | |
| 543 | static char * |
Dmitry V. Levin | dc7715b | 2008-04-19 23:45:09 +0000 | [diff] [blame] | 544 | sprinttime(time_t t) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 545 | { |
| 546 | struct tm *tmp; |
Denys Vlasenko | 1945ccc | 2012-02-27 14:37:48 +0100 | [diff] [blame] | 547 | static char buf[sizeof("yyyy/mm/dd-hh:mm:ss")]; |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 548 | |
| 549 | if (t == 0) { |
Dmitry V. Levin | dc7715b | 2008-04-19 23:45:09 +0000 | [diff] [blame] | 550 | strcpy(buf, "0"); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 551 | return buf; |
| 552 | } |
Denys Vlasenko | 5d64581 | 2011-08-20 12:48:18 +0200 | [diff] [blame] | 553 | tmp = localtime(&t); |
| 554 | if (tmp) |
Dmitry V. Levin | dc7715b | 2008-04-19 23:45:09 +0000 | [diff] [blame] | 555 | snprintf(buf, sizeof buf, "%02d/%02d/%02d-%02d:%02d:%02d", |
| 556 | tmp->tm_year + 1900, tmp->tm_mon + 1, tmp->tm_mday, |
| 557 | tmp->tm_hour, tmp->tm_min, tmp->tm_sec); |
| 558 | else |
| 559 | snprintf(buf, sizeof buf, "%lu", (unsigned long) t); |
| 560 | |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 561 | return buf; |
| 562 | } |
| 563 | |
Denys Vlasenko | 9472a27 | 2013-02-12 11:43:46 +0100 | [diff] [blame] | 564 | #if defined(SPARC) || defined(SPARC64) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 565 | typedef struct { |
Denys Vlasenko | adedb51 | 2008-12-30 18:47:55 +0000 | [diff] [blame] | 566 | int tv_sec; |
| 567 | int tv_nsec; |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 568 | } timestruct_t; |
| 569 | |
| 570 | struct solstat { |
Denys Vlasenko | adedb51 | 2008-12-30 18:47:55 +0000 | [diff] [blame] | 571 | unsigned st_dev; |
| 572 | int st_pad1[3]; /* network id */ |
| 573 | unsigned st_ino; |
| 574 | unsigned st_mode; |
| 575 | unsigned st_nlink; |
| 576 | unsigned st_uid; |
| 577 | unsigned st_gid; |
| 578 | unsigned st_rdev; |
| 579 | int st_pad2[2]; |
| 580 | int st_size; |
| 581 | int st_pad3; /* st_size, off_t expansion */ |
| 582 | timestruct_t st_atime; |
| 583 | timestruct_t st_mtime; |
| 584 | timestruct_t st_ctime; |
| 585 | int st_blksize; |
| 586 | int st_blocks; |
| 587 | char st_fstype[16]; |
| 588 | int st_pad4[8]; /* expansion area */ |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 589 | }; |
| 590 | |
| 591 | static void |
Dmitry V. Levin | b838b1e | 2008-04-19 23:47:47 +0000 | [diff] [blame] | 592 | printstatsol(struct tcb *tcp, long addr) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 593 | { |
| 594 | struct solstat statbuf; |
| 595 | |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 596 | if (umove(tcp, addr, &statbuf) < 0) { |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 597 | tprints("{...}"); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 598 | return; |
| 599 | } |
| 600 | if (!abbrev(tcp)) { |
| 601 | tprintf("{st_dev=makedev(%lu, %lu), st_ino=%lu, st_mode=%s, ", |
| 602 | (unsigned long) ((statbuf.st_dev >> 18) & 0x3fff), |
| 603 | (unsigned long) (statbuf.st_dev & 0x3ffff), |
| 604 | (unsigned long) statbuf.st_ino, |
| 605 | sprintmode(statbuf.st_mode)); |
| 606 | tprintf("st_nlink=%lu, st_uid=%lu, st_gid=%lu, ", |
| 607 | (unsigned long) statbuf.st_nlink, |
| 608 | (unsigned long) statbuf.st_uid, |
| 609 | (unsigned long) statbuf.st_gid); |
| 610 | tprintf("st_blksize=%lu, ", (unsigned long) statbuf.st_blksize); |
| 611 | tprintf("st_blocks=%lu, ", (unsigned long) statbuf.st_blocks); |
| 612 | } |
| 613 | else |
| 614 | tprintf("{st_mode=%s, ", sprintmode(statbuf.st_mode)); |
| 615 | switch (statbuf.st_mode & S_IFMT) { |
| 616 | case S_IFCHR: case S_IFBLK: |
| 617 | tprintf("st_rdev=makedev(%lu, %lu), ", |
| 618 | (unsigned long) ((statbuf.st_rdev >> 18) & 0x3fff), |
| 619 | (unsigned long) (statbuf.st_rdev & 0x3ffff)); |
| 620 | break; |
| 621 | default: |
| 622 | tprintf("st_size=%u, ", statbuf.st_size); |
| 623 | break; |
| 624 | } |
| 625 | if (!abbrev(tcp)) { |
Dmitry V. Levin | b838b1e | 2008-04-19 23:47:47 +0000 | [diff] [blame] | 626 | tprintf("st_atime=%s, ", sprinttime(statbuf.st_atime.tv_sec)); |
| 627 | tprintf("st_mtime=%s, ", sprinttime(statbuf.st_mtime.tv_sec)); |
| 628 | tprintf("st_ctime=%s}", sprinttime(statbuf.st_ctime.tv_sec)); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 629 | } |
| 630 | else |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 631 | tprints("...}"); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 632 | } |
Roland McGrath | 6d1a65c | 2004-07-12 07:44:08 +0000 | [diff] [blame] | 633 | |
Denys Vlasenko | 9472a27 | 2013-02-12 11:43:46 +0100 | [diff] [blame] | 634 | # if defined(SPARC64) |
Roland McGrath | 6d1a65c | 2004-07-12 07:44:08 +0000 | [diff] [blame] | 635 | static void |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 636 | printstat_sparc64(struct tcb *tcp, long addr) |
Roland McGrath | 6d1a65c | 2004-07-12 07:44:08 +0000 | [diff] [blame] | 637 | { |
| 638 | struct stat_sparc64 statbuf; |
| 639 | |
Roland McGrath | 6d1a65c | 2004-07-12 07:44:08 +0000 | [diff] [blame] | 640 | if (umove(tcp, addr, &statbuf) < 0) { |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 641 | tprints("{...}"); |
Roland McGrath | 6d1a65c | 2004-07-12 07:44:08 +0000 | [diff] [blame] | 642 | return; |
| 643 | } |
| 644 | |
| 645 | if (!abbrev(tcp)) { |
| 646 | tprintf("{st_dev=makedev(%lu, %lu), st_ino=%lu, st_mode=%s, ", |
| 647 | (unsigned long) major(statbuf.st_dev), |
| 648 | (unsigned long) minor(statbuf.st_dev), |
| 649 | (unsigned long) statbuf.st_ino, |
| 650 | sprintmode(statbuf.st_mode)); |
| 651 | tprintf("st_nlink=%lu, st_uid=%lu, st_gid=%lu, ", |
| 652 | (unsigned long) statbuf.st_nlink, |
| 653 | (unsigned long) statbuf.st_uid, |
| 654 | (unsigned long) statbuf.st_gid); |
| 655 | tprintf("st_blksize=%lu, ", |
| 656 | (unsigned long) statbuf.st_blksize); |
| 657 | tprintf("st_blocks=%lu, ", |
| 658 | (unsigned long) statbuf.st_blocks); |
| 659 | } |
| 660 | else |
| 661 | tprintf("{st_mode=%s, ", sprintmode(statbuf.st_mode)); |
| 662 | switch (statbuf.st_mode & S_IFMT) { |
| 663 | case S_IFCHR: case S_IFBLK: |
| 664 | tprintf("st_rdev=makedev(%lu, %lu), ", |
| 665 | (unsigned long) major(statbuf.st_rdev), |
| 666 | (unsigned long) minor(statbuf.st_rdev)); |
| 667 | break; |
| 668 | default: |
| 669 | tprintf("st_size=%lu, ", statbuf.st_size); |
| 670 | break; |
| 671 | } |
| 672 | if (!abbrev(tcp)) { |
| 673 | tprintf("st_atime=%s, ", sprinttime(statbuf.st_atime)); |
| 674 | tprintf("st_mtime=%s, ", sprinttime(statbuf.st_mtime)); |
Denys Vlasenko | 1945ccc | 2012-02-27 14:37:48 +0100 | [diff] [blame] | 675 | tprintf("st_ctime=%s}", sprinttime(statbuf.st_ctime)); |
Roland McGrath | 6d1a65c | 2004-07-12 07:44:08 +0000 | [diff] [blame] | 676 | } |
| 677 | else |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 678 | tprints("...}"); |
Roland McGrath | 6d1a65c | 2004-07-12 07:44:08 +0000 | [diff] [blame] | 679 | } |
Denys Vlasenko | 9472a27 | 2013-02-12 11:43:46 +0100 | [diff] [blame] | 680 | # endif /* SPARC64 */ |
| 681 | #endif /* SPARC[64] */ |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 682 | |
Denys Vlasenko | 8470374 | 2012-02-25 02:38:52 +0100 | [diff] [blame] | 683 | #if defined POWERPC64 |
Andreas Schwab | d69fa49 | 2010-07-12 21:39:57 +0200 | [diff] [blame] | 684 | struct stat_powerpc32 { |
| 685 | unsigned int st_dev; |
| 686 | unsigned int st_ino; |
| 687 | unsigned int st_mode; |
| 688 | unsigned short st_nlink; |
| 689 | unsigned int st_uid; |
| 690 | unsigned int st_gid; |
| 691 | unsigned int st_rdev; |
| 692 | unsigned int st_size; |
| 693 | unsigned int st_blksize; |
| 694 | unsigned int st_blocks; |
| 695 | unsigned int st_atime; |
| 696 | unsigned int st_atime_nsec; |
| 697 | unsigned int st_mtime; |
| 698 | unsigned int st_mtime_nsec; |
| 699 | unsigned int st_ctime; |
| 700 | unsigned int st_ctime_nsec; |
| 701 | unsigned int __unused4; |
| 702 | unsigned int __unused5; |
| 703 | }; |
| 704 | |
| 705 | static void |
| 706 | printstat_powerpc32(struct tcb *tcp, long addr) |
| 707 | { |
| 708 | struct stat_powerpc32 statbuf; |
| 709 | |
| 710 | if (umove(tcp, addr, &statbuf) < 0) { |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 711 | tprints("{...}"); |
Andreas Schwab | d69fa49 | 2010-07-12 21:39:57 +0200 | [diff] [blame] | 712 | return; |
| 713 | } |
| 714 | |
| 715 | if (!abbrev(tcp)) { |
| 716 | tprintf("{st_dev=makedev(%u, %u), st_ino=%u, st_mode=%s, ", |
| 717 | major(statbuf.st_dev), minor(statbuf.st_dev), |
| 718 | statbuf.st_ino, |
| 719 | sprintmode(statbuf.st_mode)); |
| 720 | tprintf("st_nlink=%u, st_uid=%u, st_gid=%u, ", |
| 721 | statbuf.st_nlink, statbuf.st_uid, statbuf.st_gid); |
| 722 | tprintf("st_blksize=%u, ", statbuf.st_blksize); |
| 723 | tprintf("st_blocks=%u, ", statbuf.st_blocks); |
| 724 | } |
| 725 | else |
| 726 | tprintf("{st_mode=%s, ", sprintmode(statbuf.st_mode)); |
| 727 | switch (statbuf.st_mode & S_IFMT) { |
| 728 | case S_IFCHR: case S_IFBLK: |
| 729 | tprintf("st_rdev=makedev(%lu, %lu), ", |
| 730 | (unsigned long) major(statbuf.st_rdev), |
| 731 | (unsigned long) minor(statbuf.st_rdev)); |
| 732 | break; |
| 733 | default: |
| 734 | tprintf("st_size=%u, ", statbuf.st_size); |
| 735 | break; |
| 736 | } |
| 737 | if (!abbrev(tcp)) { |
| 738 | tprintf("st_atime=%s, ", sprinttime(statbuf.st_atime)); |
| 739 | tprintf("st_mtime=%s, ", sprinttime(statbuf.st_mtime)); |
Denys Vlasenko | 1945ccc | 2012-02-27 14:37:48 +0100 | [diff] [blame] | 740 | tprintf("st_ctime=%s}", sprinttime(statbuf.st_ctime)); |
Andreas Schwab | d69fa49 | 2010-07-12 21:39:57 +0200 | [diff] [blame] | 741 | } |
| 742 | else |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 743 | tprints("...}"); |
Andreas Schwab | d69fa49 | 2010-07-12 21:39:57 +0200 | [diff] [blame] | 744 | } |
Denys Vlasenko | 8470374 | 2012-02-25 02:38:52 +0100 | [diff] [blame] | 745 | #endif /* POWERPC64 */ |
Andreas Schwab | d69fa49 | 2010-07-12 21:39:57 +0200 | [diff] [blame] | 746 | |
Dmitry V. Levin | 0ed617b | 2014-04-25 23:30:54 +0000 | [diff] [blame] | 747 | #include "xlat/fileflags.h" |
Wichert Akkerman | bf79f2e | 2000-09-01 21:03:06 +0000 | [diff] [blame] | 748 | |
Wichert Akkerman | 328c5e7 | 1999-04-16 00:21:26 +0000 | [diff] [blame] | 749 | static void |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 750 | realprintstat(struct tcb *tcp, struct stat *statbuf) |
Wichert Akkerman | 328c5e7 | 1999-04-16 00:21:26 +0000 | [diff] [blame] | 751 | { |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 752 | if (!abbrev(tcp)) { |
| 753 | tprintf("{st_dev=makedev(%lu, %lu), st_ino=%lu, st_mode=%s, ", |
| 754 | (unsigned long) major(statbuf->st_dev), |
| 755 | (unsigned long) minor(statbuf->st_dev), |
| 756 | (unsigned long) statbuf->st_ino, |
| 757 | sprintmode(statbuf->st_mode)); |
| 758 | tprintf("st_nlink=%lu, st_uid=%lu, st_gid=%lu, ", |
| 759 | (unsigned long) statbuf->st_nlink, |
| 760 | (unsigned long) statbuf->st_uid, |
| 761 | (unsigned long) statbuf->st_gid); |
Roland McGrath | 6d2b349 | 2002-12-30 00:51:30 +0000 | [diff] [blame] | 762 | #ifdef HAVE_STRUCT_STAT_ST_BLKSIZE |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 763 | tprintf("st_blksize=%lu, ", (unsigned long) statbuf->st_blksize); |
| 764 | #endif |
Roland McGrath | 6d2b349 | 2002-12-30 00:51:30 +0000 | [diff] [blame] | 765 | #ifdef HAVE_STRUCT_STAT_ST_BLOCKS |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 766 | tprintf("st_blocks=%lu, ", (unsigned long) statbuf->st_blocks); |
| 767 | #endif |
| 768 | } |
| 769 | else |
| 770 | tprintf("{st_mode=%s, ", sprintmode(statbuf->st_mode)); |
| 771 | switch (statbuf->st_mode & S_IFMT) { |
| 772 | case S_IFCHR: case S_IFBLK: |
Roland McGrath | 6d2b349 | 2002-12-30 00:51:30 +0000 | [diff] [blame] | 773 | #ifdef HAVE_STRUCT_STAT_ST_RDEV |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 774 | tprintf("st_rdev=makedev(%lu, %lu), ", |
| 775 | (unsigned long) major(statbuf->st_rdev), |
| 776 | (unsigned long) minor(statbuf->st_rdev)); |
Roland McGrath | 6d2b349 | 2002-12-30 00:51:30 +0000 | [diff] [blame] | 777 | #else /* !HAVE_STRUCT_STAT_ST_RDEV */ |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 778 | tprintf("st_size=makedev(%lu, %lu), ", |
| 779 | (unsigned long) major(statbuf->st_size), |
| 780 | (unsigned long) minor(statbuf->st_size)); |
Roland McGrath | 6d2b349 | 2002-12-30 00:51:30 +0000 | [diff] [blame] | 781 | #endif /* !HAVE_STRUCT_STAT_ST_RDEV */ |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 782 | break; |
| 783 | default: |
Dmitry V. Levin | e9a06b7 | 2011-02-23 16:16:50 +0000 | [diff] [blame] | 784 | tprintf("st_size=%lu, ", (unsigned long) statbuf->st_size); |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 785 | break; |
| 786 | } |
| 787 | if (!abbrev(tcp)) { |
| 788 | tprintf("st_atime=%s, ", sprinttime(statbuf->st_atime)); |
| 789 | tprintf("st_mtime=%s, ", sprinttime(statbuf->st_mtime)); |
| 790 | tprintf("st_ctime=%s", sprinttime(statbuf->st_ctime)); |
Roland McGrath | 6d2b349 | 2002-12-30 00:51:30 +0000 | [diff] [blame] | 791 | #if HAVE_STRUCT_STAT_ST_FLAGS |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 792 | tprints(", st_flags="); |
Roland McGrath | b2dee13 | 2005-06-01 19:02:36 +0000 | [diff] [blame] | 793 | printflags(fileflags, statbuf->st_flags, "UF_???"); |
John Hughes | c0fc3fd | 2001-03-08 16:10:40 +0000 | [diff] [blame] | 794 | #endif |
Roland McGrath | 6d2b349 | 2002-12-30 00:51:30 +0000 | [diff] [blame] | 795 | #if HAVE_STRUCT_STAT_ST_ACLCNT |
John Hughes | c0fc3fd | 2001-03-08 16:10:40 +0000 | [diff] [blame] | 796 | tprintf(", st_aclcnt=%d", statbuf->st_aclcnt); |
| 797 | #endif |
Roland McGrath | 6d2b349 | 2002-12-30 00:51:30 +0000 | [diff] [blame] | 798 | #if HAVE_STRUCT_STAT_ST_LEVEL |
John Hughes | c0fc3fd | 2001-03-08 16:10:40 +0000 | [diff] [blame] | 799 | tprintf(", st_level=%ld", statbuf->st_level); |
| 800 | #endif |
Roland McGrath | 6d2b349 | 2002-12-30 00:51:30 +0000 | [diff] [blame] | 801 | #if HAVE_STRUCT_STAT_ST_FSTYPE |
John Hughes | c0fc3fd | 2001-03-08 16:10:40 +0000 | [diff] [blame] | 802 | tprintf(", st_fstype=%.*s", |
| 803 | (int) sizeof statbuf->st_fstype, statbuf->st_fstype); |
| 804 | #endif |
Roland McGrath | 6d2b349 | 2002-12-30 00:51:30 +0000 | [diff] [blame] | 805 | #if HAVE_STRUCT_STAT_ST_GEN |
John Hughes | c0fc3fd | 2001-03-08 16:10:40 +0000 | [diff] [blame] | 806 | tprintf(", st_gen=%u", statbuf->st_gen); |
| 807 | #endif |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 808 | tprints("}"); |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 809 | } |
| 810 | else |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 811 | tprints("...}"); |
Wichert Akkerman | 328c5e7 | 1999-04-16 00:21:26 +0000 | [diff] [blame] | 812 | } |
| 813 | |
Dmitry V. Levin | 0eeda2c | 2013-05-01 16:37:08 +0000 | [diff] [blame] | 814 | #ifndef X32 |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 815 | static void |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 816 | printstat(struct tcb *tcp, long addr) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 817 | { |
Wichert Akkerman | 328c5e7 | 1999-04-16 00:21:26 +0000 | [diff] [blame] | 818 | struct stat statbuf; |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 819 | |
Denys Vlasenko | 4e718b5 | 2009-04-20 18:30:13 +0000 | [diff] [blame] | 820 | if (!addr) { |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 821 | tprints("NULL"); |
Denys Vlasenko | 4e718b5 | 2009-04-20 18:30:13 +0000 | [diff] [blame] | 822 | return; |
| 823 | } |
| 824 | if (syserror(tcp) || !verbose(tcp)) { |
| 825 | tprintf("%#lx", addr); |
| 826 | return; |
| 827 | } |
| 828 | |
Denys Vlasenko | 9472a27 | 2013-02-12 11:43:46 +0100 | [diff] [blame] | 829 | #if defined(SPARC) || defined(SPARC64) |
Denys Vlasenko | 5ae2b7c | 2009-02-27 20:32:52 +0000 | [diff] [blame] | 830 | if (current_personality == 1) { |
| 831 | printstatsol(tcp, addr); |
| 832 | return; |
| 833 | } |
Roland McGrath | 6d1a65c | 2004-07-12 07:44:08 +0000 | [diff] [blame] | 834 | #ifdef SPARC64 |
| 835 | else if (current_personality == 2) { |
| 836 | printstat_sparc64(tcp, addr); |
| 837 | return; |
| 838 | } |
| 839 | #endif |
Denys Vlasenko | 9472a27 | 2013-02-12 11:43:46 +0100 | [diff] [blame] | 840 | #endif /* SPARC[64] */ |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 841 | |
Denys Vlasenko | 8470374 | 2012-02-25 02:38:52 +0100 | [diff] [blame] | 842 | #if defined POWERPC64 |
Andreas Schwab | d69fa49 | 2010-07-12 21:39:57 +0200 | [diff] [blame] | 843 | if (current_personality == 1) { |
| 844 | printstat_powerpc32(tcp, addr); |
| 845 | return; |
| 846 | } |
| 847 | #endif |
| 848 | |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 849 | if (umove(tcp, addr, &statbuf) < 0) { |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 850 | tprints("{...}"); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 851 | return; |
| 852 | } |
Wichert Akkerman | 328c5e7 | 1999-04-16 00:21:26 +0000 | [diff] [blame] | 853 | |
| 854 | realprintstat(tcp, &statbuf); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 855 | } |
Dmitry V. Levin | 0eeda2c | 2013-05-01 16:37:08 +0000 | [diff] [blame] | 856 | #else /* X32 */ |
| 857 | # define printstat printstat64 |
| 858 | #endif |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 859 | |
Elliott Hughes | 391c0d8 | 2014-04-03 17:50:14 -0700 | [diff] [blame] | 860 | #if !defined HAVE_STAT64 && (defined AARCH64 || defined X86_64) |
Roland McGrath | e6d0f71 | 2007-08-07 01:22:49 +0000 | [diff] [blame] | 861 | /* |
| 862 | * Linux x86_64 has unified `struct stat' but its i386 biarch needs |
| 863 | * `struct stat64'. Its <asm-i386/stat.h> definition expects 32-bit `long'. |
| 864 | * <linux/include/asm-x86_64/ia32.h> is not in the public includes set. |
| 865 | * __GNUC__ is needed for the required __attribute__ below. |
Elliott Hughes | 391c0d8 | 2014-04-03 17:50:14 -0700 | [diff] [blame] | 866 | * |
| 867 | * Similarly, aarch64 has a unified `struct stat' but its arm personality |
| 868 | * needs `struct stat64' (which also expects a 32-bit `long' but which |
| 869 | * shouldn't be packed). |
Roland McGrath | e6d0f71 | 2007-08-07 01:22:49 +0000 | [diff] [blame] | 870 | */ |
| 871 | struct stat64 { |
| 872 | unsigned long long st_dev; |
| 873 | unsigned char __pad0[4]; |
| 874 | unsigned int __st_ino; |
| 875 | unsigned int st_mode; |
| 876 | unsigned int st_nlink; |
| 877 | unsigned int st_uid; |
| 878 | unsigned int st_gid; |
| 879 | unsigned long long st_rdev; |
| 880 | unsigned char __pad3[4]; |
| 881 | long long st_size; |
| 882 | unsigned int st_blksize; |
| 883 | unsigned long long st_blocks; |
| 884 | unsigned int st_atime; |
| 885 | unsigned int st_atime_nsec; |
| 886 | unsigned int st_mtime; |
| 887 | unsigned int st_mtime_nsec; |
| 888 | unsigned int st_ctime; |
| 889 | unsigned int st_ctime_nsec; |
| 890 | unsigned long long st_ino; |
Elliott Hughes | 391c0d8 | 2014-04-03 17:50:14 -0700 | [diff] [blame] | 891 | } |
| 892 | # if defined X86_64 |
| 893 | __attribute__((packed)) |
| 894 | # define STAT64_SIZE 96 |
| 895 | #else |
| 896 | # define STAT64_SIZE 104 |
| 897 | # endif |
| 898 | ; |
Roland McGrath | e6d0f71 | 2007-08-07 01:22:49 +0000 | [diff] [blame] | 899 | # define HAVE_STAT64 1 |
Roland McGrath | e6d0f71 | 2007-08-07 01:22:49 +0000 | [diff] [blame] | 900 | #endif |
| 901 | |
Wichert Akkerman | c792698 | 2000-04-10 22:22:31 +0000 | [diff] [blame] | 902 | #ifdef HAVE_STAT64 |
Wichert Akkerman | 328c5e7 | 1999-04-16 00:21:26 +0000 | [diff] [blame] | 903 | static void |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 904 | printstat64(struct tcb *tcp, long addr) |
Ulrich Drepper | 7f02c4d | 1999-12-24 08:01:34 +0000 | [diff] [blame] | 905 | { |
Dmitry V. Levin | 0eeda2c | 2013-05-01 16:37:08 +0000 | [diff] [blame] | 906 | #ifdef X32 |
| 907 | struct stat statbuf; |
| 908 | #else |
Ulrich Drepper | 7f02c4d | 1999-12-24 08:01:34 +0000 | [diff] [blame] | 909 | struct stat64 statbuf; |
Dmitry V. Levin | 0eeda2c | 2013-05-01 16:37:08 +0000 | [diff] [blame] | 910 | #endif |
Ulrich Drepper | 7f02c4d | 1999-12-24 08:01:34 +0000 | [diff] [blame] | 911 | |
Denys Vlasenko | 4e718b5 | 2009-04-20 18:30:13 +0000 | [diff] [blame] | 912 | #ifdef STAT64_SIZE |
Roland McGrath | e6d0f71 | 2007-08-07 01:22:49 +0000 | [diff] [blame] | 913 | (void) sizeof(char[sizeof statbuf == STAT64_SIZE ? 1 : -1]); |
| 914 | #endif |
| 915 | |
Ulrich Drepper | 7f02c4d | 1999-12-24 08:01:34 +0000 | [diff] [blame] | 916 | if (!addr) { |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 917 | tprints("NULL"); |
Ulrich Drepper | 7f02c4d | 1999-12-24 08:01:34 +0000 | [diff] [blame] | 918 | return; |
| 919 | } |
| 920 | if (syserror(tcp) || !verbose(tcp)) { |
Wichert Akkerman | 8b1b40c | 2000-02-03 21:58:30 +0000 | [diff] [blame] | 921 | tprintf("%#lx", addr); |
Ulrich Drepper | 7f02c4d | 1999-12-24 08:01:34 +0000 | [diff] [blame] | 922 | return; |
| 923 | } |
Denys Vlasenko | 4e718b5 | 2009-04-20 18:30:13 +0000 | [diff] [blame] | 924 | |
Denys Vlasenko | 9472a27 | 2013-02-12 11:43:46 +0100 | [diff] [blame] | 925 | #if defined(SPARC) || defined(SPARC64) |
Denys Vlasenko | 4e718b5 | 2009-04-20 18:30:13 +0000 | [diff] [blame] | 926 | if (current_personality == 1) { |
| 927 | printstatsol(tcp, addr); |
| 928 | return; |
| 929 | } |
| 930 | # ifdef SPARC64 |
| 931 | else if (current_personality == 2) { |
| 932 | printstat_sparc64(tcp, addr); |
| 933 | return; |
| 934 | } |
| 935 | # endif |
Denys Vlasenko | 9472a27 | 2013-02-12 11:43:46 +0100 | [diff] [blame] | 936 | #endif /* SPARC[64] */ |
Denys Vlasenko | 4e718b5 | 2009-04-20 18:30:13 +0000 | [diff] [blame] | 937 | |
Elliott Hughes | 391c0d8 | 2014-04-03 17:50:14 -0700 | [diff] [blame] | 938 | #if defined AARCH64 |
| 939 | if (current_personality != 0) { |
| 940 | printstat(tcp, addr); |
| 941 | return; |
| 942 | } |
| 943 | #endif |
Denys Vlasenko | 8470374 | 2012-02-25 02:38:52 +0100 | [diff] [blame] | 944 | #if defined X86_64 |
H.J. Lu | 35be581 | 2012-04-16 13:00:01 +0200 | [diff] [blame] | 945 | if (current_personality != 1) { |
Andreas Schwab | 61b7435 | 2009-10-16 11:37:13 +0200 | [diff] [blame] | 946 | printstat(tcp, addr); |
| 947 | return; |
| 948 | } |
| 949 | #endif |
Dmitry V. Levin | ff896f7 | 2009-10-21 13:43:57 +0000 | [diff] [blame] | 950 | |
Ulrich Drepper | 7f02c4d | 1999-12-24 08:01:34 +0000 | [diff] [blame] | 951 | if (umove(tcp, addr, &statbuf) < 0) { |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 952 | tprints("{...}"); |
Ulrich Drepper | 7f02c4d | 1999-12-24 08:01:34 +0000 | [diff] [blame] | 953 | return; |
| 954 | } |
| 955 | |
| 956 | if (!abbrev(tcp)) { |
Wichert Akkerman | d077c45 | 2000-08-10 18:16:15 +0000 | [diff] [blame] | 957 | tprintf("{st_dev=makedev(%lu, %lu), st_ino=%llu, st_mode=%s, ", |
Ulrich Drepper | 7f02c4d | 1999-12-24 08:01:34 +0000 | [diff] [blame] | 958 | (unsigned long) major(statbuf.st_dev), |
| 959 | (unsigned long) minor(statbuf.st_dev), |
Wichert Akkerman | d077c45 | 2000-08-10 18:16:15 +0000 | [diff] [blame] | 960 | (unsigned long long) statbuf.st_ino, |
Ulrich Drepper | 7f02c4d | 1999-12-24 08:01:34 +0000 | [diff] [blame] | 961 | sprintmode(statbuf.st_mode)); |
| 962 | tprintf("st_nlink=%lu, st_uid=%lu, st_gid=%lu, ", |
| 963 | (unsigned long) statbuf.st_nlink, |
| 964 | (unsigned long) statbuf.st_uid, |
| 965 | (unsigned long) statbuf.st_gid); |
Roland McGrath | 6d2b349 | 2002-12-30 00:51:30 +0000 | [diff] [blame] | 966 | #ifdef HAVE_STRUCT_STAT_ST_BLKSIZE |
Ulrich Drepper | 7f02c4d | 1999-12-24 08:01:34 +0000 | [diff] [blame] | 967 | tprintf("st_blksize=%lu, ", |
| 968 | (unsigned long) statbuf.st_blksize); |
Roland McGrath | 6d2b349 | 2002-12-30 00:51:30 +0000 | [diff] [blame] | 969 | #endif /* HAVE_STRUCT_STAT_ST_BLKSIZE */ |
| 970 | #ifdef HAVE_STRUCT_STAT_ST_BLOCKS |
Ulrich Drepper | 7f02c4d | 1999-12-24 08:01:34 +0000 | [diff] [blame] | 971 | tprintf("st_blocks=%lu, ", (unsigned long) statbuf.st_blocks); |
Roland McGrath | 6d2b349 | 2002-12-30 00:51:30 +0000 | [diff] [blame] | 972 | #endif /* HAVE_STRUCT_STAT_ST_BLOCKS */ |
Ulrich Drepper | 7f02c4d | 1999-12-24 08:01:34 +0000 | [diff] [blame] | 973 | } |
| 974 | else |
| 975 | tprintf("{st_mode=%s, ", sprintmode(statbuf.st_mode)); |
| 976 | switch (statbuf.st_mode & S_IFMT) { |
| 977 | case S_IFCHR: case S_IFBLK: |
Roland McGrath | 6d2b349 | 2002-12-30 00:51:30 +0000 | [diff] [blame] | 978 | #ifdef HAVE_STRUCT_STAT_ST_RDEV |
Ulrich Drepper | 7f02c4d | 1999-12-24 08:01:34 +0000 | [diff] [blame] | 979 | tprintf("st_rdev=makedev(%lu, %lu), ", |
| 980 | (unsigned long) major(statbuf.st_rdev), |
| 981 | (unsigned long) minor(statbuf.st_rdev)); |
Roland McGrath | 6d2b349 | 2002-12-30 00:51:30 +0000 | [diff] [blame] | 982 | #else /* !HAVE_STRUCT_STAT_ST_RDEV */ |
Ulrich Drepper | 7f02c4d | 1999-12-24 08:01:34 +0000 | [diff] [blame] | 983 | tprintf("st_size=makedev(%lu, %lu), ", |
| 984 | (unsigned long) major(statbuf.st_size), |
| 985 | (unsigned long) minor(statbuf.st_size)); |
Roland McGrath | 6d2b349 | 2002-12-30 00:51:30 +0000 | [diff] [blame] | 986 | #endif /* !HAVE_STRUCT_STAT_ST_RDEV */ |
Ulrich Drepper | 7f02c4d | 1999-12-24 08:01:34 +0000 | [diff] [blame] | 987 | break; |
| 988 | default: |
Roland McGrath | c7bd4d3 | 2007-08-07 01:05:19 +0000 | [diff] [blame] | 989 | tprintf("st_size=%llu, ", (unsigned long long) statbuf.st_size); |
Ulrich Drepper | 7f02c4d | 1999-12-24 08:01:34 +0000 | [diff] [blame] | 990 | break; |
| 991 | } |
| 992 | if (!abbrev(tcp)) { |
| 993 | tprintf("st_atime=%s, ", sprinttime(statbuf.st_atime)); |
| 994 | tprintf("st_mtime=%s, ", sprinttime(statbuf.st_mtime)); |
John Hughes | c0fc3fd | 2001-03-08 16:10:40 +0000 | [diff] [blame] | 995 | tprintf("st_ctime=%s", sprinttime(statbuf.st_ctime)); |
Roland McGrath | 6d2b349 | 2002-12-30 00:51:30 +0000 | [diff] [blame] | 996 | #if HAVE_STRUCT_STAT_ST_FLAGS |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 997 | tprints(", st_flags="); |
Roland McGrath | b2dee13 | 2005-06-01 19:02:36 +0000 | [diff] [blame] | 998 | printflags(fileflags, statbuf.st_flags, "UF_???"); |
John Hughes | c0fc3fd | 2001-03-08 16:10:40 +0000 | [diff] [blame] | 999 | #endif |
Roland McGrath | 6d2b349 | 2002-12-30 00:51:30 +0000 | [diff] [blame] | 1000 | #if HAVE_STRUCT_STAT_ST_ACLCNT |
John Hughes | c0fc3fd | 2001-03-08 16:10:40 +0000 | [diff] [blame] | 1001 | tprintf(", st_aclcnt=%d", statbuf.st_aclcnt); |
| 1002 | #endif |
Roland McGrath | 6d2b349 | 2002-12-30 00:51:30 +0000 | [diff] [blame] | 1003 | #if HAVE_STRUCT_STAT_ST_LEVEL |
John Hughes | c0fc3fd | 2001-03-08 16:10:40 +0000 | [diff] [blame] | 1004 | tprintf(", st_level=%ld", statbuf.st_level); |
| 1005 | #endif |
Roland McGrath | 6d2b349 | 2002-12-30 00:51:30 +0000 | [diff] [blame] | 1006 | #if HAVE_STRUCT_STAT_ST_FSTYPE |
John Hughes | c0fc3fd | 2001-03-08 16:10:40 +0000 | [diff] [blame] | 1007 | tprintf(", st_fstype=%.*s", |
| 1008 | (int) sizeof statbuf.st_fstype, statbuf.st_fstype); |
| 1009 | #endif |
Roland McGrath | 6d2b349 | 2002-12-30 00:51:30 +0000 | [diff] [blame] | 1010 | #if HAVE_STRUCT_STAT_ST_GEN |
John Hughes | c0fc3fd | 2001-03-08 16:10:40 +0000 | [diff] [blame] | 1011 | tprintf(", st_gen=%u", statbuf.st_gen); |
| 1012 | #endif |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 1013 | tprints("}"); |
Ulrich Drepper | 7f02c4d | 1999-12-24 08:01:34 +0000 | [diff] [blame] | 1014 | } |
| 1015 | else |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 1016 | tprints("...}"); |
Ulrich Drepper | 7f02c4d | 1999-12-24 08:01:34 +0000 | [diff] [blame] | 1017 | } |
Wichert Akkerman | c792698 | 2000-04-10 22:22:31 +0000 | [diff] [blame] | 1018 | #endif /* HAVE_STAT64 */ |
Ulrich Drepper | 7f02c4d | 1999-12-24 08:01:34 +0000 | [diff] [blame] | 1019 | |
Denys Vlasenko | 8435d67 | 2013-02-18 15:47:57 +0100 | [diff] [blame] | 1020 | #if defined(HAVE_STRUCT___OLD_KERNEL_STAT) |
Ulrich Drepper | 7f02c4d | 1999-12-24 08:01:34 +0000 | [diff] [blame] | 1021 | static void |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 1022 | convertoldstat(const struct __old_kernel_stat *oldbuf, struct stat *newbuf) |
Wichert Akkerman | 328c5e7 | 1999-04-16 00:21:26 +0000 | [diff] [blame] | 1023 | { |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 1024 | newbuf->st_dev = oldbuf->st_dev; |
| 1025 | newbuf->st_ino = oldbuf->st_ino; |
| 1026 | newbuf->st_mode = oldbuf->st_mode; |
| 1027 | newbuf->st_nlink = oldbuf->st_nlink; |
| 1028 | newbuf->st_uid = oldbuf->st_uid; |
| 1029 | newbuf->st_gid = oldbuf->st_gid; |
| 1030 | newbuf->st_rdev = oldbuf->st_rdev; |
| 1031 | newbuf->st_size = oldbuf->st_size; |
| 1032 | newbuf->st_atime = oldbuf->st_atime; |
| 1033 | newbuf->st_mtime = oldbuf->st_mtime; |
| 1034 | newbuf->st_ctime = oldbuf->st_ctime; |
| 1035 | newbuf->st_blksize = 0; /* not supported in old_stat */ |
| 1036 | newbuf->st_blocks = 0; /* not supported in old_stat */ |
Wichert Akkerman | 328c5e7 | 1999-04-16 00:21:26 +0000 | [diff] [blame] | 1037 | } |
Wichert Akkerman | 328c5e7 | 1999-04-16 00:21:26 +0000 | [diff] [blame] | 1038 | |
Wichert Akkerman | 328c5e7 | 1999-04-16 00:21:26 +0000 | [diff] [blame] | 1039 | static void |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 1040 | printoldstat(struct tcb *tcp, long addr) |
Wichert Akkerman | 328c5e7 | 1999-04-16 00:21:26 +0000 | [diff] [blame] | 1041 | { |
Wichert Akkerman | 25d0c4f | 1999-04-18 19:35:42 +0000 | [diff] [blame] | 1042 | struct __old_kernel_stat statbuf; |
| 1043 | struct stat newstatbuf; |
Wichert Akkerman | 328c5e7 | 1999-04-16 00:21:26 +0000 | [diff] [blame] | 1044 | |
Wichert Akkerman | 328c5e7 | 1999-04-16 00:21:26 +0000 | [diff] [blame] | 1045 | if (!addr) { |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 1046 | tprints("NULL"); |
Wichert Akkerman | 328c5e7 | 1999-04-16 00:21:26 +0000 | [diff] [blame] | 1047 | return; |
| 1048 | } |
| 1049 | if (syserror(tcp) || !verbose(tcp)) { |
Wichert Akkerman | 8b1b40c | 2000-02-03 21:58:30 +0000 | [diff] [blame] | 1050 | tprintf("%#lx", addr); |
Wichert Akkerman | 328c5e7 | 1999-04-16 00:21:26 +0000 | [diff] [blame] | 1051 | return; |
| 1052 | } |
Denys Vlasenko | 4e718b5 | 2009-04-20 18:30:13 +0000 | [diff] [blame] | 1053 | |
Denys Vlasenko | 9472a27 | 2013-02-12 11:43:46 +0100 | [diff] [blame] | 1054 | # if defined(SPARC) || defined(SPARC64) |
Denys Vlasenko | 4e718b5 | 2009-04-20 18:30:13 +0000 | [diff] [blame] | 1055 | if (current_personality == 1) { |
| 1056 | printstatsol(tcp, addr); |
| 1057 | return; |
| 1058 | } |
Denys Vlasenko | 8470374 | 2012-02-25 02:38:52 +0100 | [diff] [blame] | 1059 | # endif |
Denys Vlasenko | 4e718b5 | 2009-04-20 18:30:13 +0000 | [diff] [blame] | 1060 | |
Wichert Akkerman | 328c5e7 | 1999-04-16 00:21:26 +0000 | [diff] [blame] | 1061 | if (umove(tcp, addr, &statbuf) < 0) { |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 1062 | tprints("{...}"); |
Wichert Akkerman | 328c5e7 | 1999-04-16 00:21:26 +0000 | [diff] [blame] | 1063 | return; |
| 1064 | } |
| 1065 | |
| 1066 | convertoldstat(&statbuf, &newstatbuf); |
| 1067 | realprintstat(tcp, &newstatbuf); |
| 1068 | } |
Denys Vlasenko | 8470374 | 2012-02-25 02:38:52 +0100 | [diff] [blame] | 1069 | #endif |
Wichert Akkerman | 328c5e7 | 1999-04-16 00:21:26 +0000 | [diff] [blame] | 1070 | |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1071 | int |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 1072 | sys_stat(struct tcb *tcp) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1073 | { |
| 1074 | if (entering(tcp)) { |
| 1075 | printpath(tcp, tcp->u_arg[0]); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 1076 | tprints(", "); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1077 | } else { |
| 1078 | printstat(tcp, tcp->u_arg[1]); |
| 1079 | } |
| 1080 | return 0; |
| 1081 | } |
| 1082 | |
Dmitry V. Levin | 0eeda2c | 2013-05-01 16:37:08 +0000 | [diff] [blame] | 1083 | #ifdef X32 |
| 1084 | static void |
| 1085 | printstat64_x32(struct tcb *tcp, long addr) |
| 1086 | { |
| 1087 | struct stat64 statbuf; |
| 1088 | |
| 1089 | if (!addr) { |
| 1090 | tprints("NULL"); |
| 1091 | return; |
| 1092 | } |
| 1093 | if (syserror(tcp) || !verbose(tcp)) { |
| 1094 | tprintf("%#lx", addr); |
| 1095 | return; |
| 1096 | } |
| 1097 | |
| 1098 | if (umove(tcp, addr, &statbuf) < 0) { |
| 1099 | tprints("{...}"); |
| 1100 | return; |
| 1101 | } |
| 1102 | |
| 1103 | if (!abbrev(tcp)) { |
| 1104 | tprintf("{st_dev=makedev(%lu, %lu), st_ino=%llu, st_mode=%s, ", |
| 1105 | (unsigned long) major(statbuf.st_dev), |
| 1106 | (unsigned long) minor(statbuf.st_dev), |
| 1107 | (unsigned long long) statbuf.st_ino, |
| 1108 | sprintmode(statbuf.st_mode)); |
| 1109 | tprintf("st_nlink=%lu, st_uid=%lu, st_gid=%lu, ", |
| 1110 | (unsigned long) statbuf.st_nlink, |
| 1111 | (unsigned long) statbuf.st_uid, |
| 1112 | (unsigned long) statbuf.st_gid); |
| 1113 | tprintf("st_blksize=%lu, ", |
| 1114 | (unsigned long) statbuf.st_blksize); |
| 1115 | tprintf("st_blocks=%lu, ", (unsigned long) statbuf.st_blocks); |
| 1116 | } |
| 1117 | else |
| 1118 | tprintf("{st_mode=%s, ", sprintmode(statbuf.st_mode)); |
| 1119 | switch (statbuf.st_mode & S_IFMT) { |
| 1120 | case S_IFCHR: case S_IFBLK: |
| 1121 | tprintf("st_rdev=makedev(%lu, %lu), ", |
| 1122 | (unsigned long) major(statbuf.st_rdev), |
| 1123 | (unsigned long) minor(statbuf.st_rdev)); |
| 1124 | break; |
| 1125 | default: |
| 1126 | tprintf("st_size=%llu, ", (unsigned long long) statbuf.st_size); |
| 1127 | break; |
| 1128 | } |
| 1129 | if (!abbrev(tcp)) { |
| 1130 | tprintf("st_atime=%s, ", sprinttime(statbuf.st_atime)); |
| 1131 | tprintf("st_mtime=%s, ", sprinttime(statbuf.st_mtime)); |
| 1132 | tprintf("st_ctime=%s", sprinttime(statbuf.st_ctime)); |
| 1133 | tprints("}"); |
| 1134 | } |
| 1135 | else |
| 1136 | tprints("...}"); |
| 1137 | } |
| 1138 | #endif /* X32 */ |
| 1139 | |
Wichert Akkerman | 328c5e7 | 1999-04-16 00:21:26 +0000 | [diff] [blame] | 1140 | int |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 1141 | sys_stat64(struct tcb *tcp) |
Ulrich Drepper | 7f02c4d | 1999-12-24 08:01:34 +0000 | [diff] [blame] | 1142 | { |
| 1143 | #ifdef HAVE_STAT64 |
| 1144 | if (entering(tcp)) { |
| 1145 | printpath(tcp, tcp->u_arg[0]); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 1146 | tprints(", "); |
Ulrich Drepper | 7f02c4d | 1999-12-24 08:01:34 +0000 | [diff] [blame] | 1147 | } else { |
Dmitry V. Levin | 0eeda2c | 2013-05-01 16:37:08 +0000 | [diff] [blame] | 1148 | # ifdef X32 |
| 1149 | printstat64_x32(tcp, tcp->u_arg[1]); |
| 1150 | # else |
Ulrich Drepper | 7f02c4d | 1999-12-24 08:01:34 +0000 | [diff] [blame] | 1151 | printstat64(tcp, tcp->u_arg[1]); |
Dmitry V. Levin | 0eeda2c | 2013-05-01 16:37:08 +0000 | [diff] [blame] | 1152 | # endif |
Ulrich Drepper | 7f02c4d | 1999-12-24 08:01:34 +0000 | [diff] [blame] | 1153 | } |
| 1154 | return 0; |
| 1155 | #else |
| 1156 | return printargs(tcp); |
| 1157 | #endif |
| 1158 | } |
| 1159 | |
Dmitry V. Levin | 95ebf5a | 2006-10-13 20:25:12 +0000 | [diff] [blame] | 1160 | #ifndef AT_SYMLINK_NOFOLLOW |
Dmitry V. Levin | 7989ad4 | 2012-03-13 23:26:01 +0000 | [diff] [blame] | 1161 | # define AT_SYMLINK_NOFOLLOW 0x100 |
Dmitry V. Levin | 95ebf5a | 2006-10-13 20:25:12 +0000 | [diff] [blame] | 1162 | #endif |
Dmitry V. Levin | 7989ad4 | 2012-03-13 23:26:01 +0000 | [diff] [blame] | 1163 | #ifndef AT_REMOVEDIR |
| 1164 | # define AT_REMOVEDIR 0x200 |
| 1165 | #endif |
| 1166 | #ifndef AT_SYMLINK_FOLLOW |
| 1167 | # define AT_SYMLINK_FOLLOW 0x400 |
| 1168 | #endif |
| 1169 | #ifndef AT_NO_AUTOMOUNT |
| 1170 | # define AT_NO_AUTOMOUNT 0x800 |
| 1171 | #endif |
| 1172 | #ifndef AT_EMPTY_PATH |
| 1173 | # define AT_EMPTY_PATH 0x1000 |
| 1174 | #endif |
| 1175 | |
Dmitry V. Levin | 0ed617b | 2014-04-25 23:30:54 +0000 | [diff] [blame] | 1176 | #include "xlat/at_flags.h" |
Dmitry V. Levin | 95ebf5a | 2006-10-13 20:25:12 +0000 | [diff] [blame] | 1177 | |
| 1178 | int |
| 1179 | sys_newfstatat(struct tcb *tcp) |
| 1180 | { |
| 1181 | if (entering(tcp)) { |
Dmitry V. Levin | 3138213 | 2011-03-04 05:08:02 +0300 | [diff] [blame] | 1182 | print_dirfd(tcp, tcp->u_arg[0]); |
Dmitry V. Levin | 95ebf5a | 2006-10-13 20:25:12 +0000 | [diff] [blame] | 1183 | printpath(tcp, tcp->u_arg[1]); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 1184 | tprints(", "); |
Dmitry V. Levin | 95ebf5a | 2006-10-13 20:25:12 +0000 | [diff] [blame] | 1185 | } else { |
Andreas Schwab | d69fa49 | 2010-07-12 21:39:57 +0200 | [diff] [blame] | 1186 | #ifdef POWERPC64 |
| 1187 | if (current_personality == 0) |
| 1188 | printstat(tcp, tcp->u_arg[2]); |
| 1189 | else |
| 1190 | printstat64(tcp, tcp->u_arg[2]); |
| 1191 | #elif defined HAVE_STAT64 |
Dmitry V. Levin | 95ebf5a | 2006-10-13 20:25:12 +0000 | [diff] [blame] | 1192 | printstat64(tcp, tcp->u_arg[2]); |
| 1193 | #else |
| 1194 | printstat(tcp, tcp->u_arg[2]); |
| 1195 | #endif |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 1196 | tprints(", "); |
Dmitry V. Levin | 7989ad4 | 2012-03-13 23:26:01 +0000 | [diff] [blame] | 1197 | printflags(at_flags, tcp->u_arg[3], "AT_???"); |
Dmitry V. Levin | 95ebf5a | 2006-10-13 20:25:12 +0000 | [diff] [blame] | 1198 | } |
| 1199 | return 0; |
| 1200 | } |
Dmitry V. Levin | 95ebf5a | 2006-10-13 20:25:12 +0000 | [diff] [blame] | 1201 | |
Denys Vlasenko | 8435d67 | 2013-02-18 15:47:57 +0100 | [diff] [blame] | 1202 | #if defined(HAVE_STRUCT___OLD_KERNEL_STAT) |
Ulrich Drepper | 7f02c4d | 1999-12-24 08:01:34 +0000 | [diff] [blame] | 1203 | int |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 1204 | sys_oldstat(struct tcb *tcp) |
Wichert Akkerman | 328c5e7 | 1999-04-16 00:21:26 +0000 | [diff] [blame] | 1205 | { |
| 1206 | if (entering(tcp)) { |
| 1207 | printpath(tcp, tcp->u_arg[0]); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 1208 | tprints(", "); |
Wichert Akkerman | 328c5e7 | 1999-04-16 00:21:26 +0000 | [diff] [blame] | 1209 | } else { |
| 1210 | printoldstat(tcp, tcp->u_arg[1]); |
| 1211 | } |
| 1212 | return 0; |
| 1213 | } |
Denys Vlasenko | 8470374 | 2012-02-25 02:38:52 +0100 | [diff] [blame] | 1214 | #endif |
Wichert Akkerman | 328c5e7 | 1999-04-16 00:21:26 +0000 | [diff] [blame] | 1215 | |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1216 | int |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 1217 | sys_fstat(struct tcb *tcp) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1218 | { |
Dmitry V. Levin | 3138213 | 2011-03-04 05:08:02 +0300 | [diff] [blame] | 1219 | if (entering(tcp)) { |
| 1220 | printfd(tcp, tcp->u_arg[0]); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 1221 | tprints(", "); |
Dmitry V. Levin | 3138213 | 2011-03-04 05:08:02 +0300 | [diff] [blame] | 1222 | } else { |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1223 | printstat(tcp, tcp->u_arg[1]); |
| 1224 | } |
| 1225 | return 0; |
| 1226 | } |
| 1227 | |
Wichert Akkerman | 328c5e7 | 1999-04-16 00:21:26 +0000 | [diff] [blame] | 1228 | int |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 1229 | sys_fstat64(struct tcb *tcp) |
Ulrich Drepper | 7f02c4d | 1999-12-24 08:01:34 +0000 | [diff] [blame] | 1230 | { |
| 1231 | #ifdef HAVE_STAT64 |
Dmitry V. Levin | 3138213 | 2011-03-04 05:08:02 +0300 | [diff] [blame] | 1232 | if (entering(tcp)) { |
| 1233 | printfd(tcp, tcp->u_arg[0]); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 1234 | tprints(", "); |
Dmitry V. Levin | 3138213 | 2011-03-04 05:08:02 +0300 | [diff] [blame] | 1235 | } else { |
Dmitry V. Levin | 0eeda2c | 2013-05-01 16:37:08 +0000 | [diff] [blame] | 1236 | # ifdef X32 |
| 1237 | printstat64_x32(tcp, tcp->u_arg[1]); |
| 1238 | # else |
Ulrich Drepper | 7f02c4d | 1999-12-24 08:01:34 +0000 | [diff] [blame] | 1239 | printstat64(tcp, tcp->u_arg[1]); |
Dmitry V. Levin | 0eeda2c | 2013-05-01 16:37:08 +0000 | [diff] [blame] | 1240 | # endif |
Ulrich Drepper | 7f02c4d | 1999-12-24 08:01:34 +0000 | [diff] [blame] | 1241 | } |
| 1242 | return 0; |
| 1243 | #else |
| 1244 | return printargs(tcp); |
| 1245 | #endif |
| 1246 | } |
| 1247 | |
Denys Vlasenko | 8435d67 | 2013-02-18 15:47:57 +0100 | [diff] [blame] | 1248 | #if defined(HAVE_STRUCT___OLD_KERNEL_STAT) |
Ulrich Drepper | 7f02c4d | 1999-12-24 08:01:34 +0000 | [diff] [blame] | 1249 | int |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 1250 | sys_oldfstat(struct tcb *tcp) |
Wichert Akkerman | 328c5e7 | 1999-04-16 00:21:26 +0000 | [diff] [blame] | 1251 | { |
Dmitry V. Levin | 3138213 | 2011-03-04 05:08:02 +0300 | [diff] [blame] | 1252 | if (entering(tcp)) { |
| 1253 | printfd(tcp, tcp->u_arg[0]); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 1254 | tprints(", "); |
Dmitry V. Levin | 3138213 | 2011-03-04 05:08:02 +0300 | [diff] [blame] | 1255 | } else { |
Wichert Akkerman | 328c5e7 | 1999-04-16 00:21:26 +0000 | [diff] [blame] | 1256 | printoldstat(tcp, tcp->u_arg[1]); |
| 1257 | } |
| 1258 | return 0; |
| 1259 | } |
Denys Vlasenko | 8470374 | 2012-02-25 02:38:52 +0100 | [diff] [blame] | 1260 | #endif |
Wichert Akkerman | 328c5e7 | 1999-04-16 00:21:26 +0000 | [diff] [blame] | 1261 | |
Denys Vlasenko | 9472a27 | 2013-02-12 11:43:46 +0100 | [diff] [blame] | 1262 | #if defined(SPARC) || defined(SPARC64) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1263 | |
| 1264 | int |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 1265 | sys_xstat(struct tcb *tcp) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1266 | { |
| 1267 | if (entering(tcp)) { |
| 1268 | tprintf("%ld, ", tcp->u_arg[0]); |
| 1269 | printpath(tcp, tcp->u_arg[1]); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 1270 | tprints(", "); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1271 | } else { |
Denys Vlasenko | 8470374 | 2012-02-25 02:38:52 +0100 | [diff] [blame] | 1272 | # ifdef _STAT64_VER |
John Hughes | 8fe2c98 | 2001-03-06 09:45:18 +0000 | [diff] [blame] | 1273 | if (tcp->u_arg[0] == _STAT64_VER) |
Denys Vlasenko | b237b1b | 2012-02-27 13:56:59 +0100 | [diff] [blame] | 1274 | printstat64(tcp, tcp->u_arg[2]); |
John Hughes | 8fe2c98 | 2001-03-06 09:45:18 +0000 | [diff] [blame] | 1275 | else |
Denys Vlasenko | 8470374 | 2012-02-25 02:38:52 +0100 | [diff] [blame] | 1276 | # endif |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1277 | printstat(tcp, tcp->u_arg[2]); |
| 1278 | } |
| 1279 | return 0; |
| 1280 | } |
| 1281 | |
| 1282 | int |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 1283 | sys_fxstat(struct tcb *tcp) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1284 | { |
| 1285 | if (entering(tcp)) |
| 1286 | tprintf("%ld, %ld, ", tcp->u_arg[0], tcp->u_arg[1]); |
| 1287 | else { |
Denys Vlasenko | 8470374 | 2012-02-25 02:38:52 +0100 | [diff] [blame] | 1288 | # ifdef _STAT64_VER |
John Hughes | 8fe2c98 | 2001-03-06 09:45:18 +0000 | [diff] [blame] | 1289 | if (tcp->u_arg[0] == _STAT64_VER) |
Denys Vlasenko | b237b1b | 2012-02-27 13:56:59 +0100 | [diff] [blame] | 1290 | printstat64(tcp, tcp->u_arg[2]); |
John Hughes | 8fe2c98 | 2001-03-06 09:45:18 +0000 | [diff] [blame] | 1291 | else |
Denys Vlasenko | 8470374 | 2012-02-25 02:38:52 +0100 | [diff] [blame] | 1292 | # endif |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1293 | printstat(tcp, tcp->u_arg[2]); |
| 1294 | } |
| 1295 | return 0; |
| 1296 | } |
| 1297 | |
| 1298 | int |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 1299 | sys_lxstat(struct tcb *tcp) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1300 | { |
| 1301 | if (entering(tcp)) { |
| 1302 | tprintf("%ld, ", tcp->u_arg[0]); |
| 1303 | printpath(tcp, tcp->u_arg[1]); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 1304 | tprints(", "); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1305 | } else { |
Denys Vlasenko | 8470374 | 2012-02-25 02:38:52 +0100 | [diff] [blame] | 1306 | # ifdef _STAT64_VER |
John Hughes | 8fe2c98 | 2001-03-06 09:45:18 +0000 | [diff] [blame] | 1307 | if (tcp->u_arg[0] == _STAT64_VER) |
Denys Vlasenko | b237b1b | 2012-02-27 13:56:59 +0100 | [diff] [blame] | 1308 | printstat64(tcp, tcp->u_arg[2]); |
John Hughes | 8fe2c98 | 2001-03-06 09:45:18 +0000 | [diff] [blame] | 1309 | else |
Denys Vlasenko | 8470374 | 2012-02-25 02:38:52 +0100 | [diff] [blame] | 1310 | # endif |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1311 | printstat(tcp, tcp->u_arg[2]); |
| 1312 | } |
| 1313 | return 0; |
| 1314 | } |
| 1315 | |
| 1316 | int |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 1317 | sys_xmknod(struct tcb *tcp) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1318 | { |
| 1319 | int mode = tcp->u_arg[2]; |
| 1320 | |
| 1321 | if (entering(tcp)) { |
| 1322 | tprintf("%ld, ", tcp->u_arg[0]); |
| 1323 | printpath(tcp, tcp->u_arg[1]); |
| 1324 | tprintf(", %s", sprintmode(mode)); |
| 1325 | switch (mode & S_IFMT) { |
| 1326 | case S_IFCHR: case S_IFBLK: |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1327 | tprintf(", makedev(%lu, %lu)", |
| 1328 | (unsigned long) ((tcp->u_arg[3] >> 18) & 0x3fff), |
| 1329 | (unsigned long) (tcp->u_arg[3] & 0x3ffff)); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1330 | break; |
| 1331 | default: |
| 1332 | break; |
| 1333 | } |
| 1334 | } |
| 1335 | return 0; |
| 1336 | } |
| 1337 | |
Denys Vlasenko | 9472a27 | 2013-02-12 11:43:46 +0100 | [diff] [blame] | 1338 | #endif /* SPARC[64] */ |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1339 | |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1340 | /* directory */ |
| 1341 | int |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 1342 | sys_chdir(struct tcb *tcp) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1343 | { |
| 1344 | if (entering(tcp)) { |
| 1345 | printpath(tcp, tcp->u_arg[0]); |
| 1346 | } |
| 1347 | return 0; |
| 1348 | } |
| 1349 | |
Dmitry V. Levin | 95ebf5a | 2006-10-13 20:25:12 +0000 | [diff] [blame] | 1350 | int |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 1351 | sys_link(struct tcb *tcp) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1352 | { |
| 1353 | if (entering(tcp)) { |
| 1354 | printpath(tcp, tcp->u_arg[0]); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 1355 | tprints(", "); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1356 | printpath(tcp, tcp->u_arg[1]); |
| 1357 | } |
| 1358 | return 0; |
| 1359 | } |
| 1360 | |
Dmitry V. Levin | 95ebf5a | 2006-10-13 20:25:12 +0000 | [diff] [blame] | 1361 | int |
| 1362 | sys_linkat(struct tcb *tcp) |
| 1363 | { |
| 1364 | if (entering(tcp)) { |
Dmitry V. Levin | 3138213 | 2011-03-04 05:08:02 +0300 | [diff] [blame] | 1365 | print_dirfd(tcp, tcp->u_arg[0]); |
Dmitry V. Levin | 95ebf5a | 2006-10-13 20:25:12 +0000 | [diff] [blame] | 1366 | printpath(tcp, tcp->u_arg[1]); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 1367 | tprints(", "); |
Dmitry V. Levin | 3138213 | 2011-03-04 05:08:02 +0300 | [diff] [blame] | 1368 | print_dirfd(tcp, tcp->u_arg[2]); |
Dmitry V. Levin | 95ebf5a | 2006-10-13 20:25:12 +0000 | [diff] [blame] | 1369 | printpath(tcp, tcp->u_arg[3]); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 1370 | tprints(", "); |
Dmitry V. Levin | 7989ad4 | 2012-03-13 23:26:01 +0000 | [diff] [blame] | 1371 | printflags(at_flags, tcp->u_arg[4], "AT_???"); |
Dmitry V. Levin | 95ebf5a | 2006-10-13 20:25:12 +0000 | [diff] [blame] | 1372 | } |
| 1373 | return 0; |
| 1374 | } |
Dmitry V. Levin | 95ebf5a | 2006-10-13 20:25:12 +0000 | [diff] [blame] | 1375 | |
Dmitry V. Levin | 95ebf5a | 2006-10-13 20:25:12 +0000 | [diff] [blame] | 1376 | int |
| 1377 | sys_unlinkat(struct tcb *tcp) |
| 1378 | { |
| 1379 | if (entering(tcp)) { |
Dmitry V. Levin | 3138213 | 2011-03-04 05:08:02 +0300 | [diff] [blame] | 1380 | print_dirfd(tcp, tcp->u_arg[0]); |
Dmitry V. Levin | 95ebf5a | 2006-10-13 20:25:12 +0000 | [diff] [blame] | 1381 | printpath(tcp, tcp->u_arg[1]); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 1382 | tprints(", "); |
Dmitry V. Levin | 7989ad4 | 2012-03-13 23:26:01 +0000 | [diff] [blame] | 1383 | printflags(at_flags, tcp->u_arg[2], "AT_???"); |
Dmitry V. Levin | 95ebf5a | 2006-10-13 20:25:12 +0000 | [diff] [blame] | 1384 | } |
| 1385 | return 0; |
| 1386 | } |
Dmitry V. Levin | 95ebf5a | 2006-10-13 20:25:12 +0000 | [diff] [blame] | 1387 | |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1388 | int |
Dmitry V. Levin | 95ebf5a | 2006-10-13 20:25:12 +0000 | [diff] [blame] | 1389 | sys_symlinkat(struct tcb *tcp) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1390 | { |
| 1391 | if (entering(tcp)) { |
| 1392 | printpath(tcp, tcp->u_arg[0]); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 1393 | tprints(", "); |
Dmitry V. Levin | 3138213 | 2011-03-04 05:08:02 +0300 | [diff] [blame] | 1394 | print_dirfd(tcp, tcp->u_arg[1]); |
Dmitry V. Levin | 95ebf5a | 2006-10-13 20:25:12 +0000 | [diff] [blame] | 1395 | printpath(tcp, tcp->u_arg[2]); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1396 | } |
| 1397 | return 0; |
| 1398 | } |
Dmitry V. Levin | 95ebf5a | 2006-10-13 20:25:12 +0000 | [diff] [blame] | 1399 | |
| 1400 | static int |
| 1401 | decode_readlink(struct tcb *tcp, int offset) |
| 1402 | { |
| 1403 | if (entering(tcp)) { |
| 1404 | printpath(tcp, tcp->u_arg[offset]); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 1405 | tprints(", "); |
Dmitry V. Levin | 95ebf5a | 2006-10-13 20:25:12 +0000 | [diff] [blame] | 1406 | } else { |
| 1407 | if (syserror(tcp)) |
| 1408 | tprintf("%#lx", tcp->u_arg[offset + 1]); |
| 1409 | else |
Denys Vlasenko | 3449ae8 | 2012-01-27 17:24:26 +0100 | [diff] [blame] | 1410 | /* Used to use printpathn(), but readlink |
| 1411 | * neither includes NUL in the returned count, |
| 1412 | * nor actually writes it into memory. |
| 1413 | * printpathn() would decide on printing |
| 1414 | * "..." continuation based on garbage |
| 1415 | * past return buffer's end. |
| 1416 | */ |
| 1417 | printstr(tcp, tcp->u_arg[offset + 1], tcp->u_rval); |
Dmitry V. Levin | 95ebf5a | 2006-10-13 20:25:12 +0000 | [diff] [blame] | 1418 | tprintf(", %lu", tcp->u_arg[offset + 2]); |
| 1419 | } |
| 1420 | return 0; |
| 1421 | } |
| 1422 | |
| 1423 | int |
| 1424 | sys_readlink(struct tcb *tcp) |
| 1425 | { |
| 1426 | return decode_readlink(tcp, 0); |
| 1427 | } |
| 1428 | |
Dmitry V. Levin | 95ebf5a | 2006-10-13 20:25:12 +0000 | [diff] [blame] | 1429 | int |
| 1430 | sys_readlinkat(struct tcb *tcp) |
| 1431 | { |
| 1432 | if (entering(tcp)) |
Dmitry V. Levin | 3138213 | 2011-03-04 05:08:02 +0300 | [diff] [blame] | 1433 | print_dirfd(tcp, tcp->u_arg[0]); |
Dmitry V. Levin | 95ebf5a | 2006-10-13 20:25:12 +0000 | [diff] [blame] | 1434 | return decode_readlink(tcp, 1); |
| 1435 | } |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1436 | |
Mike Frysinger | 5b677ab | 2014-08-14 04:05:41 -0400 | [diff] [blame] | 1437 | static void |
| 1438 | decode_renameat(struct tcb *tcp) |
| 1439 | { |
| 1440 | print_dirfd(tcp, tcp->u_arg[0]); |
| 1441 | printpath(tcp, tcp->u_arg[1]); |
| 1442 | tprints(", "); |
| 1443 | print_dirfd(tcp, tcp->u_arg[2]); |
| 1444 | printpath(tcp, tcp->u_arg[3]); |
| 1445 | } |
| 1446 | |
Dmitry V. Levin | 95ebf5a | 2006-10-13 20:25:12 +0000 | [diff] [blame] | 1447 | int |
| 1448 | sys_renameat(struct tcb *tcp) |
| 1449 | { |
| 1450 | if (entering(tcp)) { |
Mike Frysinger | 5b677ab | 2014-08-14 04:05:41 -0400 | [diff] [blame] | 1451 | decode_renameat(tcp); |
| 1452 | } |
| 1453 | return 0; |
| 1454 | } |
| 1455 | |
| 1456 | #include "xlat/rename_flags.h" |
| 1457 | |
| 1458 | int |
| 1459 | sys_renameat2(struct tcb *tcp) |
| 1460 | { |
| 1461 | if (entering(tcp)) { |
| 1462 | decode_renameat(tcp); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 1463 | tprints(", "); |
Mike Frysinger | 5b677ab | 2014-08-14 04:05:41 -0400 | [diff] [blame] | 1464 | printflags(rename_flags, tcp->u_arg[4], "RENAME_??"); |
Dmitry V. Levin | 95ebf5a | 2006-10-13 20:25:12 +0000 | [diff] [blame] | 1465 | } |
| 1466 | return 0; |
| 1467 | } |
Dmitry V. Levin | 95ebf5a | 2006-10-13 20:25:12 +0000 | [diff] [blame] | 1468 | |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1469 | int |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 1470 | sys_chown(struct tcb *tcp) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1471 | { |
| 1472 | if (entering(tcp)) { |
| 1473 | printpath(tcp, tcp->u_arg[0]); |
Roland McGrath | 6bc1220 | 2003-11-13 22:32:27 +0000 | [diff] [blame] | 1474 | printuid(", ", tcp->u_arg[1]); |
| 1475 | printuid(", ", tcp->u_arg[2]); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1476 | } |
| 1477 | return 0; |
| 1478 | } |
| 1479 | |
Dmitry V. Levin | 95ebf5a | 2006-10-13 20:25:12 +0000 | [diff] [blame] | 1480 | int |
| 1481 | sys_fchownat(struct tcb *tcp) |
| 1482 | { |
| 1483 | if (entering(tcp)) { |
Dmitry V. Levin | 3138213 | 2011-03-04 05:08:02 +0300 | [diff] [blame] | 1484 | print_dirfd(tcp, tcp->u_arg[0]); |
Dmitry V. Levin | 95ebf5a | 2006-10-13 20:25:12 +0000 | [diff] [blame] | 1485 | printpath(tcp, tcp->u_arg[1]); |
| 1486 | printuid(", ", tcp->u_arg[2]); |
| 1487 | printuid(", ", tcp->u_arg[3]); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 1488 | tprints(", "); |
Dmitry V. Levin | 7989ad4 | 2012-03-13 23:26:01 +0000 | [diff] [blame] | 1489 | printflags(at_flags, tcp->u_arg[4], "AT_???"); |
Dmitry V. Levin | 95ebf5a | 2006-10-13 20:25:12 +0000 | [diff] [blame] | 1490 | } |
| 1491 | return 0; |
| 1492 | } |
Dmitry V. Levin | 95ebf5a | 2006-10-13 20:25:12 +0000 | [diff] [blame] | 1493 | |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1494 | int |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 1495 | sys_fchown(struct tcb *tcp) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1496 | { |
| 1497 | if (entering(tcp)) { |
Dmitry V. Levin | 3138213 | 2011-03-04 05:08:02 +0300 | [diff] [blame] | 1498 | printfd(tcp, tcp->u_arg[0]); |
Roland McGrath | 6bc1220 | 2003-11-13 22:32:27 +0000 | [diff] [blame] | 1499 | printuid(", ", tcp->u_arg[1]); |
| 1500 | printuid(", ", tcp->u_arg[2]); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1501 | } |
| 1502 | return 0; |
| 1503 | } |
| 1504 | |
Dmitry V. Levin | 95ebf5a | 2006-10-13 20:25:12 +0000 | [diff] [blame] | 1505 | static int |
| 1506 | decode_chmod(struct tcb *tcp, int offset) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1507 | { |
| 1508 | if (entering(tcp)) { |
Dmitry V. Levin | 95ebf5a | 2006-10-13 20:25:12 +0000 | [diff] [blame] | 1509 | printpath(tcp, tcp->u_arg[offset]); |
| 1510 | tprintf(", %#lo", tcp->u_arg[offset + 1]); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1511 | } |
| 1512 | return 0; |
| 1513 | } |
| 1514 | |
| 1515 | int |
Dmitry V. Levin | 95ebf5a | 2006-10-13 20:25:12 +0000 | [diff] [blame] | 1516 | sys_chmod(struct tcb *tcp) |
| 1517 | { |
| 1518 | return decode_chmod(tcp, 0); |
| 1519 | } |
| 1520 | |
Dmitry V. Levin | 95ebf5a | 2006-10-13 20:25:12 +0000 | [diff] [blame] | 1521 | int |
| 1522 | sys_fchmodat(struct tcb *tcp) |
| 1523 | { |
| 1524 | if (entering(tcp)) |
Dmitry V. Levin | 3138213 | 2011-03-04 05:08:02 +0300 | [diff] [blame] | 1525 | print_dirfd(tcp, tcp->u_arg[0]); |
Dmitry V. Levin | 95ebf5a | 2006-10-13 20:25:12 +0000 | [diff] [blame] | 1526 | return decode_chmod(tcp, 1); |
| 1527 | } |
Dmitry V. Levin | 95ebf5a | 2006-10-13 20:25:12 +0000 | [diff] [blame] | 1528 | |
| 1529 | int |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 1530 | sys_fchmod(struct tcb *tcp) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1531 | { |
| 1532 | if (entering(tcp)) { |
Dmitry V. Levin | 3138213 | 2011-03-04 05:08:02 +0300 | [diff] [blame] | 1533 | printfd(tcp, tcp->u_arg[0]); |
| 1534 | tprintf(", %#lo", tcp->u_arg[1]); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1535 | } |
| 1536 | return 0; |
| 1537 | } |
| 1538 | |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 1539 | #ifdef ALPHA |
| 1540 | int |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 1541 | sys_osf_utimes(struct tcb *tcp) |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 1542 | { |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 1543 | if (entering(tcp)) { |
| 1544 | printpath(tcp, tcp->u_arg[0]); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 1545 | tprints(", "); |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 1546 | printtv_bitness(tcp, tcp->u_arg[1], BITNESS_32, 0); |
| 1547 | } |
| 1548 | return 0; |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 1549 | } |
| 1550 | #endif |
| 1551 | |
Dmitry V. Levin | 95ebf5a | 2006-10-13 20:25:12 +0000 | [diff] [blame] | 1552 | static int |
Roland McGrath | 6afc565 | 2007-07-24 01:57:11 +0000 | [diff] [blame] | 1553 | decode_utimes(struct tcb *tcp, int offset, int special) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1554 | { |
| 1555 | if (entering(tcp)) { |
Dmitry V. Levin | 95ebf5a | 2006-10-13 20:25:12 +0000 | [diff] [blame] | 1556 | printpath(tcp, tcp->u_arg[offset]); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 1557 | tprints(", "); |
Roland McGrath | 6afc565 | 2007-07-24 01:57:11 +0000 | [diff] [blame] | 1558 | if (tcp->u_arg[offset + 1] == 0) |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 1559 | tprints("NULL"); |
Roland McGrath | 6afc565 | 2007-07-24 01:57:11 +0000 | [diff] [blame] | 1560 | else { |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 1561 | tprints("{"); |
Roland McGrath | 6afc565 | 2007-07-24 01:57:11 +0000 | [diff] [blame] | 1562 | printtv_bitness(tcp, tcp->u_arg[offset + 1], |
| 1563 | BITNESS_CURRENT, special); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 1564 | tprints(", "); |
Roland McGrath | e6d0f71 | 2007-08-07 01:22:49 +0000 | [diff] [blame] | 1565 | printtv_bitness(tcp, tcp->u_arg[offset + 1] |
Denys Vlasenko | b63256e | 2011-06-07 12:13:24 +0200 | [diff] [blame] | 1566 | + sizeof(struct timeval), |
Roland McGrath | 6afc565 | 2007-07-24 01:57:11 +0000 | [diff] [blame] | 1567 | BITNESS_CURRENT, special); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 1568 | tprints("}"); |
Roland McGrath | 6afc565 | 2007-07-24 01:57:11 +0000 | [diff] [blame] | 1569 | } |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1570 | } |
| 1571 | return 0; |
| 1572 | } |
| 1573 | |
| 1574 | int |
Dmitry V. Levin | 95ebf5a | 2006-10-13 20:25:12 +0000 | [diff] [blame] | 1575 | sys_utimes(struct tcb *tcp) |
| 1576 | { |
Roland McGrath | 6afc565 | 2007-07-24 01:57:11 +0000 | [diff] [blame] | 1577 | return decode_utimes(tcp, 0, 0); |
Dmitry V. Levin | 95ebf5a | 2006-10-13 20:25:12 +0000 | [diff] [blame] | 1578 | } |
| 1579 | |
Dmitry V. Levin | 95ebf5a | 2006-10-13 20:25:12 +0000 | [diff] [blame] | 1580 | int |
| 1581 | sys_futimesat(struct tcb *tcp) |
| 1582 | { |
| 1583 | if (entering(tcp)) |
Dmitry V. Levin | 3138213 | 2011-03-04 05:08:02 +0300 | [diff] [blame] | 1584 | print_dirfd(tcp, tcp->u_arg[0]); |
Roland McGrath | 6afc565 | 2007-07-24 01:57:11 +0000 | [diff] [blame] | 1585 | return decode_utimes(tcp, 1, 0); |
| 1586 | } |
| 1587 | |
| 1588 | int |
| 1589 | sys_utimensat(struct tcb *tcp) |
| 1590 | { |
| 1591 | if (entering(tcp)) { |
Dmitry V. Levin | 3138213 | 2011-03-04 05:08:02 +0300 | [diff] [blame] | 1592 | print_dirfd(tcp, tcp->u_arg[0]); |
Roland McGrath | 6afc565 | 2007-07-24 01:57:11 +0000 | [diff] [blame] | 1593 | decode_utimes(tcp, 1, 1); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 1594 | tprints(", "); |
Dmitry V. Levin | 7989ad4 | 2012-03-13 23:26:01 +0000 | [diff] [blame] | 1595 | printflags(at_flags, tcp->u_arg[3], "AT_???"); |
Roland McGrath | 6afc565 | 2007-07-24 01:57:11 +0000 | [diff] [blame] | 1596 | } |
| 1597 | return 0; |
Dmitry V. Levin | 95ebf5a | 2006-10-13 20:25:12 +0000 | [diff] [blame] | 1598 | } |
Dmitry V. Levin | 95ebf5a | 2006-10-13 20:25:12 +0000 | [diff] [blame] | 1599 | |
| 1600 | int |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 1601 | sys_utime(struct tcb *tcp) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1602 | { |
Roland McGrath | 7e9817c | 2007-07-05 20:31:58 +0000 | [diff] [blame] | 1603 | union { |
| 1604 | long utl[2]; |
| 1605 | int uti[2]; |
Denys Vlasenko | 751acb3 | 2013-02-08 15:34:46 +0100 | [diff] [blame] | 1606 | long paranoia_for_huge_wordsize[4]; |
Roland McGrath | 7e9817c | 2007-07-05 20:31:58 +0000 | [diff] [blame] | 1607 | } u; |
Denys Vlasenko | 751acb3 | 2013-02-08 15:34:46 +0100 | [diff] [blame] | 1608 | unsigned wordsize; |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1609 | |
| 1610 | if (entering(tcp)) { |
| 1611 | printpath(tcp, tcp->u_arg[0]); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 1612 | tprints(", "); |
Denys Vlasenko | 751acb3 | 2013-02-08 15:34:46 +0100 | [diff] [blame] | 1613 | |
| 1614 | wordsize = current_wordsize; |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1615 | if (!tcp->u_arg[1]) |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 1616 | tprints("NULL"); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1617 | else if (!verbose(tcp)) |
| 1618 | tprintf("%#lx", tcp->u_arg[1]); |
Denys Vlasenko | 1945ccc | 2012-02-27 14:37:48 +0100 | [diff] [blame] | 1619 | else if (umoven(tcp, tcp->u_arg[1], 2 * wordsize, (char *) &u) < 0) |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 1620 | tprints("[?, ?]"); |
Denys Vlasenko | 1945ccc | 2012-02-27 14:37:48 +0100 | [diff] [blame] | 1621 | else if (wordsize == sizeof u.utl[0]) { |
Roland McGrath | 7e9817c | 2007-07-05 20:31:58 +0000 | [diff] [blame] | 1622 | tprintf("[%s,", sprinttime(u.utl[0])); |
| 1623 | tprintf(" %s]", sprinttime(u.utl[1])); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1624 | } |
Denys Vlasenko | 1945ccc | 2012-02-27 14:37:48 +0100 | [diff] [blame] | 1625 | else if (wordsize == sizeof u.uti[0]) { |
Roland McGrath | 7e9817c | 2007-07-05 20:31:58 +0000 | [diff] [blame] | 1626 | tprintf("[%s,", sprinttime(u.uti[0])); |
| 1627 | tprintf(" %s]", sprinttime(u.uti[1])); |
| 1628 | } |
| 1629 | else |
Denys Vlasenko | 751acb3 | 2013-02-08 15:34:46 +0100 | [diff] [blame] | 1630 | tprintf("<decode error: unsupported wordsize %d>", |
| 1631 | wordsize); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1632 | } |
| 1633 | return 0; |
| 1634 | } |
| 1635 | |
Dmitry V. Levin | 95ebf5a | 2006-10-13 20:25:12 +0000 | [diff] [blame] | 1636 | static int |
| 1637 | decode_mknod(struct tcb *tcp, int offset) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1638 | { |
Dmitry V. Levin | 95ebf5a | 2006-10-13 20:25:12 +0000 | [diff] [blame] | 1639 | int mode = tcp->u_arg[offset + 1]; |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1640 | |
| 1641 | if (entering(tcp)) { |
Dmitry V. Levin | 95ebf5a | 2006-10-13 20:25:12 +0000 | [diff] [blame] | 1642 | printpath(tcp, tcp->u_arg[offset]); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1643 | tprintf(", %s", sprintmode(mode)); |
| 1644 | switch (mode & S_IFMT) { |
Denys Vlasenko | b237b1b | 2012-02-27 13:56:59 +0100 | [diff] [blame] | 1645 | case S_IFCHR: |
| 1646 | case S_IFBLK: |
Denys Vlasenko | 9472a27 | 2013-02-12 11:43:46 +0100 | [diff] [blame] | 1647 | #if defined(SPARC) || defined(SPARC64) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1648 | if (current_personality == 1) |
Denys Vlasenko | b237b1b | 2012-02-27 13:56:59 +0100 | [diff] [blame] | 1649 | tprintf(", makedev(%lu, %lu)", |
Dmitry V. Levin | 95ebf5a | 2006-10-13 20:25:12 +0000 | [diff] [blame] | 1650 | (unsigned long) ((tcp->u_arg[offset + 2] >> 18) & 0x3fff), |
| 1651 | (unsigned long) (tcp->u_arg[offset + 2] & 0x3ffff)); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1652 | else |
Roland McGrath | 186c5ac | 2002-12-15 23:58:23 +0000 | [diff] [blame] | 1653 | #endif |
Denys Vlasenko | b237b1b | 2012-02-27 13:56:59 +0100 | [diff] [blame] | 1654 | tprintf(", makedev(%lu, %lu)", |
Dmitry V. Levin | 95ebf5a | 2006-10-13 20:25:12 +0000 | [diff] [blame] | 1655 | (unsigned long) major(tcp->u_arg[offset + 2]), |
| 1656 | (unsigned long) minor(tcp->u_arg[offset + 2])); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1657 | break; |
| 1658 | default: |
| 1659 | break; |
| 1660 | } |
| 1661 | } |
| 1662 | return 0; |
| 1663 | } |
| 1664 | |
| 1665 | int |
Dmitry V. Levin | 95ebf5a | 2006-10-13 20:25:12 +0000 | [diff] [blame] | 1666 | sys_mknod(struct tcb *tcp) |
| 1667 | { |
| 1668 | return decode_mknod(tcp, 0); |
| 1669 | } |
| 1670 | |
Dmitry V. Levin | 95ebf5a | 2006-10-13 20:25:12 +0000 | [diff] [blame] | 1671 | int |
| 1672 | sys_mknodat(struct tcb *tcp) |
| 1673 | { |
| 1674 | if (entering(tcp)) |
Dmitry V. Levin | 3138213 | 2011-03-04 05:08:02 +0300 | [diff] [blame] | 1675 | print_dirfd(tcp, tcp->u_arg[0]); |
Dmitry V. Levin | 95ebf5a | 2006-10-13 20:25:12 +0000 | [diff] [blame] | 1676 | return decode_mknod(tcp, 1); |
| 1677 | } |
Dmitry V. Levin | 95ebf5a | 2006-10-13 20:25:12 +0000 | [diff] [blame] | 1678 | |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1679 | int |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 1680 | sys_getcwd(struct tcb *tcp) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1681 | { |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 1682 | if (exiting(tcp)) { |
| 1683 | if (syserror(tcp)) |
| 1684 | tprintf("%#lx", tcp->u_arg[0]); |
| 1685 | else |
| 1686 | printpathn(tcp, tcp->u_arg[0], tcp->u_rval - 1); |
| 1687 | tprintf(", %lu", tcp->u_arg[1]); |
| 1688 | } |
| 1689 | return 0; |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1690 | } |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1691 | |
Dmitry V. Levin | 0ed617b | 2014-04-25 23:30:54 +0000 | [diff] [blame] | 1692 | #include "xlat/xattrflags.h" |
Roland McGrath | 186c5ac | 2002-12-15 23:58:23 +0000 | [diff] [blame] | 1693 | |
Roland McGrath | 3292e22 | 2004-08-31 06:30:48 +0000 | [diff] [blame] | 1694 | static void |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 1695 | print_xattr_val(struct tcb *tcp, int failed, |
| 1696 | unsigned long arg, |
| 1697 | unsigned long insize, |
| 1698 | unsigned long size) |
Roland McGrath | 3292e22 | 2004-08-31 06:30:48 +0000 | [diff] [blame] | 1699 | { |
Dmitry V. Levin | 1f21513 | 2012-12-07 21:38:52 +0000 | [diff] [blame] | 1700 | if (insize == 0) |
| 1701 | failed = 1; |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 1702 | if (!failed) { |
| 1703 | unsigned long capacity = 4 * size + 1; |
| 1704 | unsigned char *buf = (capacity < size) ? NULL : malloc(capacity); |
| 1705 | if (buf == NULL || /* probably a bogus size argument */ |
| 1706 | umoven(tcp, arg, size, (char *) &buf[3 * size]) < 0) { |
| 1707 | failed = 1; |
Roland McGrath | 883567c | 2005-02-02 03:38:32 +0000 | [diff] [blame] | 1708 | } |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 1709 | else { |
| 1710 | unsigned char *out = buf; |
| 1711 | unsigned char *in = &buf[3 * size]; |
| 1712 | size_t i; |
| 1713 | for (i = 0; i < size; ++i) { |
Denys Vlasenko | 5198ed4 | 2013-03-06 23:44:23 +0100 | [diff] [blame] | 1714 | if (in[i] >= ' ' && in[i] <= 0x7e) |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 1715 | *out++ = in[i]; |
| 1716 | else { |
| 1717 | #define tohex(n) "0123456789abcdef"[n] |
| 1718 | *out++ = '\\'; |
| 1719 | *out++ = 'x'; |
| 1720 | *out++ = tohex(in[i] / 16); |
| 1721 | *out++ = tohex(in[i] % 16); |
| 1722 | } |
| 1723 | } |
| 1724 | /* Don't print terminating NUL if there is one. */ |
| 1725 | if (i > 0 && in[i - 1] == '\0') |
| 1726 | out -= 4; |
| 1727 | *out = '\0'; |
| 1728 | tprintf(", \"%s\", %ld", buf, insize); |
| 1729 | } |
| 1730 | free(buf); |
Roland McGrath | 883567c | 2005-02-02 03:38:32 +0000 | [diff] [blame] | 1731 | } |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 1732 | if (failed) |
| 1733 | tprintf(", 0x%lx, %ld", arg, insize); |
Roland McGrath | 3292e22 | 2004-08-31 06:30:48 +0000 | [diff] [blame] | 1734 | } |
| 1735 | |
Roland McGrath | 186c5ac | 2002-12-15 23:58:23 +0000 | [diff] [blame] | 1736 | int |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 1737 | sys_setxattr(struct tcb *tcp) |
Roland McGrath | 186c5ac | 2002-12-15 23:58:23 +0000 | [diff] [blame] | 1738 | { |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 1739 | if (entering(tcp)) { |
| 1740 | printpath(tcp, tcp->u_arg[0]); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 1741 | tprints(", "); |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 1742 | printstr(tcp, tcp->u_arg[1], -1); |
| 1743 | print_xattr_val(tcp, 0, tcp->u_arg[2], tcp->u_arg[3], tcp->u_arg[3]); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 1744 | tprints(", "); |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 1745 | printflags(xattrflags, tcp->u_arg[4], "XATTR_???"); |
| 1746 | } |
| 1747 | return 0; |
Roland McGrath | 186c5ac | 2002-12-15 23:58:23 +0000 | [diff] [blame] | 1748 | } |
| 1749 | |
| 1750 | int |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 1751 | sys_fsetxattr(struct tcb *tcp) |
Roland McGrath | 186c5ac | 2002-12-15 23:58:23 +0000 | [diff] [blame] | 1752 | { |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 1753 | if (entering(tcp)) { |
Dmitry V. Levin | 3138213 | 2011-03-04 05:08:02 +0300 | [diff] [blame] | 1754 | printfd(tcp, tcp->u_arg[0]); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 1755 | tprints(", "); |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 1756 | printstr(tcp, tcp->u_arg[1], -1); |
| 1757 | print_xattr_val(tcp, 0, tcp->u_arg[2], tcp->u_arg[3], tcp->u_arg[3]); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 1758 | tprints(", "); |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 1759 | printflags(xattrflags, tcp->u_arg[4], "XATTR_???"); |
| 1760 | } |
| 1761 | return 0; |
Roland McGrath | 186c5ac | 2002-12-15 23:58:23 +0000 | [diff] [blame] | 1762 | } |
| 1763 | |
| 1764 | int |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 1765 | sys_getxattr(struct tcb *tcp) |
Roland McGrath | 186c5ac | 2002-12-15 23:58:23 +0000 | [diff] [blame] | 1766 | { |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 1767 | if (entering(tcp)) { |
| 1768 | printpath(tcp, tcp->u_arg[0]); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 1769 | tprints(", "); |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 1770 | printstr(tcp, tcp->u_arg[1], -1); |
| 1771 | } else { |
| 1772 | print_xattr_val(tcp, syserror(tcp), tcp->u_arg[2], tcp->u_arg[3], |
| 1773 | tcp->u_rval); |
| 1774 | } |
| 1775 | return 0; |
Roland McGrath | 186c5ac | 2002-12-15 23:58:23 +0000 | [diff] [blame] | 1776 | } |
| 1777 | |
| 1778 | int |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 1779 | sys_fgetxattr(struct tcb *tcp) |
Roland McGrath | 186c5ac | 2002-12-15 23:58:23 +0000 | [diff] [blame] | 1780 | { |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 1781 | if (entering(tcp)) { |
Dmitry V. Levin | 3138213 | 2011-03-04 05:08:02 +0300 | [diff] [blame] | 1782 | printfd(tcp, tcp->u_arg[0]); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 1783 | tprints(", "); |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 1784 | printstr(tcp, tcp->u_arg[1], -1); |
| 1785 | } else { |
| 1786 | print_xattr_val(tcp, syserror(tcp), tcp->u_arg[2], tcp->u_arg[3], |
| 1787 | tcp->u_rval); |
| 1788 | } |
| 1789 | return 0; |
Roland McGrath | 186c5ac | 2002-12-15 23:58:23 +0000 | [diff] [blame] | 1790 | } |
| 1791 | |
Dmitry V. Levin | 33d2476 | 2012-03-14 16:34:32 +0000 | [diff] [blame] | 1792 | static void |
| 1793 | print_xattr_list(struct tcb *tcp, unsigned long addr, unsigned long size) |
| 1794 | { |
| 1795 | if (syserror(tcp)) { |
| 1796 | tprintf("%#lx", addr); |
| 1797 | } else { |
| 1798 | if (!addr) { |
| 1799 | tprints("NULL"); |
| 1800 | } else { |
| 1801 | unsigned long len = |
Dmitry V. Levin | 3ed5d02 | 2014-09-10 13:46:04 +0000 | [diff] [blame] | 1802 | (size < (unsigned long) tcp->u_rval) ? |
| 1803 | size : (unsigned long) tcp->u_rval; |
Dmitry V. Levin | 33d2476 | 2012-03-14 16:34:32 +0000 | [diff] [blame] | 1804 | printstr(tcp, addr, len); |
| 1805 | } |
| 1806 | } |
| 1807 | tprintf(", %lu", size); |
| 1808 | } |
| 1809 | |
Roland McGrath | 186c5ac | 2002-12-15 23:58:23 +0000 | [diff] [blame] | 1810 | int |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 1811 | sys_listxattr(struct tcb *tcp) |
Roland McGrath | 186c5ac | 2002-12-15 23:58:23 +0000 | [diff] [blame] | 1812 | { |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 1813 | if (entering(tcp)) { |
| 1814 | printpath(tcp, tcp->u_arg[0]); |
Dmitry V. Levin | 33d2476 | 2012-03-14 16:34:32 +0000 | [diff] [blame] | 1815 | tprints(", "); |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 1816 | } else { |
Dmitry V. Levin | 33d2476 | 2012-03-14 16:34:32 +0000 | [diff] [blame] | 1817 | print_xattr_list(tcp, tcp->u_arg[1], tcp->u_arg[2]); |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 1818 | } |
| 1819 | return 0; |
Roland McGrath | 186c5ac | 2002-12-15 23:58:23 +0000 | [diff] [blame] | 1820 | } |
| 1821 | |
| 1822 | int |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 1823 | sys_flistxattr(struct tcb *tcp) |
Roland McGrath | 186c5ac | 2002-12-15 23:58:23 +0000 | [diff] [blame] | 1824 | { |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 1825 | if (entering(tcp)) { |
Dmitry V. Levin | 3138213 | 2011-03-04 05:08:02 +0300 | [diff] [blame] | 1826 | printfd(tcp, tcp->u_arg[0]); |
Dmitry V. Levin | 33d2476 | 2012-03-14 16:34:32 +0000 | [diff] [blame] | 1827 | tprints(", "); |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 1828 | } else { |
Dmitry V. Levin | 33d2476 | 2012-03-14 16:34:32 +0000 | [diff] [blame] | 1829 | print_xattr_list(tcp, tcp->u_arg[1], tcp->u_arg[2]); |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 1830 | } |
| 1831 | return 0; |
Roland McGrath | 186c5ac | 2002-12-15 23:58:23 +0000 | [diff] [blame] | 1832 | } |
| 1833 | |
| 1834 | int |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 1835 | sys_removexattr(struct tcb *tcp) |
Roland McGrath | 186c5ac | 2002-12-15 23:58:23 +0000 | [diff] [blame] | 1836 | { |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 1837 | if (entering(tcp)) { |
| 1838 | printpath(tcp, tcp->u_arg[0]); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 1839 | tprints(", "); |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 1840 | printstr(tcp, tcp->u_arg[1], -1); |
| 1841 | } |
| 1842 | return 0; |
Roland McGrath | 186c5ac | 2002-12-15 23:58:23 +0000 | [diff] [blame] | 1843 | } |
| 1844 | |
| 1845 | int |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 1846 | sys_fremovexattr(struct tcb *tcp) |
Roland McGrath | 186c5ac | 2002-12-15 23:58:23 +0000 | [diff] [blame] | 1847 | { |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 1848 | if (entering(tcp)) { |
Dmitry V. Levin | 3138213 | 2011-03-04 05:08:02 +0300 | [diff] [blame] | 1849 | printfd(tcp, tcp->u_arg[0]); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 1850 | tprints(", "); |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 1851 | printstr(tcp, tcp->u_arg[1], -1); |
| 1852 | } |
| 1853 | return 0; |
Roland McGrath | 186c5ac | 2002-12-15 23:58:23 +0000 | [diff] [blame] | 1854 | } |
Roland McGrath | df13e8f | 2004-10-07 18:51:19 +0000 | [diff] [blame] | 1855 | |
Dmitry V. Levin | 0ed617b | 2014-04-25 23:30:54 +0000 | [diff] [blame] | 1856 | #include "xlat/advise.h" |
Roland McGrath | df13e8f | 2004-10-07 18:51:19 +0000 | [diff] [blame] | 1857 | |
Roland McGrath | df13e8f | 2004-10-07 18:51:19 +0000 | [diff] [blame] | 1858 | int |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 1859 | sys_fadvise64(struct tcb *tcp) |
Roland McGrath | df13e8f | 2004-10-07 18:51:19 +0000 | [diff] [blame] | 1860 | { |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 1861 | if (entering(tcp)) { |
Andreas Schwab | b5600fc | 2009-11-04 17:08:34 +0100 | [diff] [blame] | 1862 | int argn; |
Dmitry V. Levin | 3138213 | 2011-03-04 05:08:02 +0300 | [diff] [blame] | 1863 | printfd(tcp, tcp->u_arg[0]); |
Dmitry V. Levin | 3c49b02 | 2014-08-07 00:07:28 +0000 | [diff] [blame] | 1864 | argn = printllval(tcp, ", %lld", 1); |
Andreas Schwab | b5600fc | 2009-11-04 17:08:34 +0100 | [diff] [blame] | 1865 | tprintf(", %ld, ", tcp->u_arg[argn++]); |
| 1866 | printxval(advise, tcp->u_arg[argn], "POSIX_FADV_???"); |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 1867 | } |
| 1868 | return 0; |
Roland McGrath | df13e8f | 2004-10-07 18:51:19 +0000 | [diff] [blame] | 1869 | } |
Roland McGrath | df13e8f | 2004-10-07 18:51:19 +0000 | [diff] [blame] | 1870 | |
Roland McGrath | df13e8f | 2004-10-07 18:51:19 +0000 | [diff] [blame] | 1871 | int |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 1872 | sys_fadvise64_64(struct tcb *tcp) |
Roland McGrath | df13e8f | 2004-10-07 18:51:19 +0000 | [diff] [blame] | 1873 | { |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 1874 | if (entering(tcp)) { |
Andreas Schwab | b5600fc | 2009-11-04 17:08:34 +0100 | [diff] [blame] | 1875 | int argn; |
Dmitry V. Levin | 3138213 | 2011-03-04 05:08:02 +0300 | [diff] [blame] | 1876 | printfd(tcp, tcp->u_arg[0]); |
Dmitry V. Levin | 3c49b02 | 2014-08-07 00:07:28 +0000 | [diff] [blame] | 1877 | argn = printllval(tcp, ", %lld, ", 1); |
| 1878 | argn = printllval(tcp, "%lld, ", argn); |
Dmitry V. Levin | 8e096c4 | 2013-05-06 18:23:01 +0000 | [diff] [blame] | 1879 | #if defined __ARM_EABI__ || defined AARCH64 || defined POWERPC || defined XTENSA |
Kirill A. Shutemov | 896db21 | 2009-09-19 03:21:33 +0300 | [diff] [blame] | 1880 | printxval(advise, tcp->u_arg[1], "POSIX_FADV_???"); |
Roland McGrath | df13e8f | 2004-10-07 18:51:19 +0000 | [diff] [blame] | 1881 | #else |
Andreas Schwab | b5600fc | 2009-11-04 17:08:34 +0100 | [diff] [blame] | 1882 | printxval(advise, tcp->u_arg[argn], "POSIX_FADV_???"); |
Roland McGrath | df13e8f | 2004-10-07 18:51:19 +0000 | [diff] [blame] | 1883 | #endif |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 1884 | } |
| 1885 | return 0; |
Roland McGrath | df13e8f | 2004-10-07 18:51:19 +0000 | [diff] [blame] | 1886 | } |
Dmitry V. Levin | 95ebf5a | 2006-10-13 20:25:12 +0000 | [diff] [blame] | 1887 | |
Dmitry V. Levin | 0ed617b | 2014-04-25 23:30:54 +0000 | [diff] [blame] | 1888 | #include "xlat/sync_file_range_flags.h" |
William Manley | 16b9dcf | 2013-08-09 18:04:11 +0100 | [diff] [blame] | 1889 | |
| 1890 | int |
| 1891 | sys_sync_file_range(struct tcb *tcp) |
| 1892 | { |
| 1893 | if (entering(tcp)) { |
| 1894 | int argn; |
| 1895 | printfd(tcp, tcp->u_arg[0]); |
Dmitry V. Levin | 3c49b02 | 2014-08-07 00:07:28 +0000 | [diff] [blame] | 1896 | argn = printllval(tcp, ", %lld, ", 1); |
| 1897 | argn = printllval(tcp, "%lld, ", argn); |
William Manley | 16b9dcf | 2013-08-09 18:04:11 +0100 | [diff] [blame] | 1898 | printflags(sync_file_range_flags, tcp->u_arg[argn], |
| 1899 | "SYNC_FILE_RANGE_???"); |
| 1900 | } |
| 1901 | return 0; |
| 1902 | } |
| 1903 | |
| 1904 | int |
| 1905 | sys_sync_file_range2(struct tcb *tcp) |
| 1906 | { |
| 1907 | if (entering(tcp)) { |
| 1908 | int argn; |
| 1909 | printfd(tcp, tcp->u_arg[0]); |
| 1910 | printflags(sync_file_range_flags, 1, |
| 1911 | "SYNC_FILE_RANGE_???"); |
Dmitry V. Levin | 3c49b02 | 2014-08-07 00:07:28 +0000 | [diff] [blame] | 1912 | argn = printllval(tcp, ", %lld, ", 2); |
| 1913 | argn = printllval(tcp, "%lld, ", argn); |
William Manley | 16b9dcf | 2013-08-09 18:04:11 +0100 | [diff] [blame] | 1914 | } |
| 1915 | return 0; |
| 1916 | } |
| 1917 | |
Mark Wielaard | bab8940 | 2010-03-21 14:41:26 +0100 | [diff] [blame] | 1918 | int |
Roland McGrath | 96a9661 | 2008-05-20 04:56:18 +0000 | [diff] [blame] | 1919 | sys_fallocate(struct tcb *tcp) |
| 1920 | { |
| 1921 | if (entering(tcp)) { |
Andreas Schwab | b5600fc | 2009-11-04 17:08:34 +0100 | [diff] [blame] | 1922 | int argn; |
Dmitry V. Levin | 3138213 | 2011-03-04 05:08:02 +0300 | [diff] [blame] | 1923 | printfd(tcp, tcp->u_arg[0]); /* fd */ |
Denys Vlasenko | d33e72a | 2012-05-18 02:03:24 +0200 | [diff] [blame] | 1924 | tprintf(", %#lo, ", tcp->u_arg[1]); /* mode */ |
Dmitry V. Levin | 3c49b02 | 2014-08-07 00:07:28 +0000 | [diff] [blame] | 1925 | argn = printllval(tcp, "%llu, ", 2); /* offset */ |
| 1926 | printllval(tcp, "%llu", argn); /* len */ |
Roland McGrath | 96a9661 | 2008-05-20 04:56:18 +0000 | [diff] [blame] | 1927 | } |
| 1928 | return 0; |
| 1929 | } |
Dmitry V. Levin | 8829365 | 2012-03-09 21:02:19 +0000 | [diff] [blame] | 1930 | |
Dmitry V. Levin | ad0c01e | 2012-03-15 00:52:22 +0000 | [diff] [blame] | 1931 | #ifndef SWAP_FLAG_PREFER |
| 1932 | # define SWAP_FLAG_PREFER 0x8000 |
| 1933 | #endif |
| 1934 | #ifndef SWAP_FLAG_DISCARD |
| 1935 | # define SWAP_FLAG_DISCARD 0x10000 |
| 1936 | #endif |
Dmitry V. Levin | 0ed617b | 2014-04-25 23:30:54 +0000 | [diff] [blame] | 1937 | #include "xlat/swap_flags.h" |
Dmitry V. Levin | 8829365 | 2012-03-09 21:02:19 +0000 | [diff] [blame] | 1938 | |
| 1939 | int |
| 1940 | sys_swapon(struct tcb *tcp) |
| 1941 | { |
| 1942 | if (entering(tcp)) { |
| 1943 | int flags = tcp->u_arg[1]; |
| 1944 | printpath(tcp, tcp->u_arg[0]); |
| 1945 | tprints(", "); |
| 1946 | printflags(swap_flags, flags & ~SWAP_FLAG_PRIO_MASK, |
| 1947 | "SWAP_FLAG_???"); |
| 1948 | if (flags & SWAP_FLAG_PREFER) |
| 1949 | tprintf("|%d", flags & SWAP_FLAG_PRIO_MASK); |
| 1950 | } |
| 1951 | return 0; |
| 1952 | } |