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" |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 32 | #include <dirent.h> |
Dmitry V. Levin | 8829365 | 2012-03-09 21:02:19 +0000 | [diff] [blame] | 33 | #include <sys/swap.h> |
Roland McGrath | c531e57 | 2008-08-01 01:13:10 +0000 | [diff] [blame] | 34 | |
Denys Vlasenko | 9472a27 | 2013-02-12 11:43:46 +0100 | [diff] [blame] | 35 | #if defined(SPARC) || defined(SPARC64) |
Wichert Akkerman | dacfb6e | 1999-06-03 14:21:07 +0000 | [diff] [blame] | 36 | struct stat { |
| 37 | unsigned short st_dev; |
| 38 | unsigned int st_ino; |
| 39 | unsigned short st_mode; |
| 40 | short st_nlink; |
| 41 | unsigned short st_uid; |
| 42 | unsigned short st_gid; |
| 43 | unsigned short st_rdev; |
| 44 | unsigned int st_size; |
| 45 | int st_atime; |
| 46 | unsigned int __unused1; |
| 47 | int st_mtime; |
| 48 | unsigned int __unused2; |
| 49 | int st_ctime; |
| 50 | unsigned int __unused3; |
| 51 | int st_blksize; |
| 52 | int st_blocks; |
| 53 | unsigned int __unused4[2]; |
| 54 | }; |
Denys Vlasenko | 8470374 | 2012-02-25 02:38:52 +0100 | [diff] [blame] | 55 | # if defined(SPARC64) |
Roland McGrath | 6d1a65c | 2004-07-12 07:44:08 +0000 | [diff] [blame] | 56 | struct stat_sparc64 { |
| 57 | unsigned int st_dev; |
| 58 | unsigned long st_ino; |
| 59 | unsigned int st_mode; |
| 60 | unsigned int st_nlink; |
| 61 | unsigned int st_uid; |
| 62 | unsigned int st_gid; |
| 63 | unsigned int st_rdev; |
| 64 | long st_size; |
| 65 | long st_atime; |
| 66 | long st_mtime; |
| 67 | long st_ctime; |
| 68 | long st_blksize; |
| 69 | long st_blocks; |
| 70 | unsigned long __unused4[2]; |
| 71 | }; |
Denys Vlasenko | 8470374 | 2012-02-25 02:38:52 +0100 | [diff] [blame] | 72 | # endif /* SPARC64 */ |
| 73 | # define stat kernel_stat |
| 74 | # include <asm/stat.h> |
| 75 | # undef stat |
H.J. Lu | 35be581 | 2012-04-16 13:00:01 +0200 | [diff] [blame] | 76 | #elif defined(X32) |
| 77 | struct stat { |
| 78 | unsigned long long st_dev; |
| 79 | unsigned long long st_ino; |
| 80 | unsigned long long st_nlink; |
| 81 | |
| 82 | unsigned int st_mode; |
| 83 | unsigned int st_uid; |
| 84 | unsigned int st_gid; |
| 85 | unsigned int __pad0; |
| 86 | unsigned long long st_rdev; |
| 87 | long long st_size; |
| 88 | long long st_blksize; |
| 89 | long long st_blocks; |
| 90 | |
| 91 | unsigned long long st_atime; |
| 92 | unsigned long long st_atime_nsec; |
| 93 | unsigned long long st_mtime; |
| 94 | unsigned long long st_mtime_nsec; |
| 95 | unsigned long long st_ctime; |
| 96 | unsigned long long st_ctime_nsec; |
| 97 | long long __unused[3]; |
| 98 | }; |
H.J. Lu | 085e428 | 2012-04-17 11:05:04 -0700 | [diff] [blame] | 99 | |
| 100 | struct stat64 { |
| 101 | unsigned long long st_dev; |
| 102 | unsigned char __pad0[4]; |
| 103 | unsigned long __st_ino; |
| 104 | unsigned int st_mode; |
| 105 | unsigned int st_nlink; |
| 106 | unsigned long st_uid; |
| 107 | unsigned long st_gid; |
| 108 | unsigned long long st_rdev; |
| 109 | unsigned char __pad3[4]; |
| 110 | long long st_size; |
| 111 | unsigned long st_blksize; |
| 112 | unsigned long long st_blocks; |
| 113 | unsigned long st_atime; |
| 114 | unsigned long st_atime_nsec; |
| 115 | unsigned long st_mtime; |
| 116 | unsigned int st_mtime_nsec; |
| 117 | unsigned long st_ctime; |
| 118 | unsigned long st_ctime_nsec; |
| 119 | unsigned long long st_ino; |
Dmitry V. Levin | 0eeda2c | 2013-05-01 16:37:08 +0000 | [diff] [blame] | 120 | } __attribute__((packed)); |
| 121 | # define HAVE_STAT64 1 |
Dmitry V. Levin | bd2e28a | 2013-05-01 15:14:25 +0000 | [diff] [blame] | 122 | |
| 123 | struct __old_kernel_stat { |
| 124 | unsigned short st_dev; |
| 125 | unsigned short st_ino; |
| 126 | unsigned short st_mode; |
| 127 | unsigned short st_nlink; |
| 128 | unsigned short st_uid; |
| 129 | unsigned short st_gid; |
| 130 | unsigned short st_rdev; |
| 131 | unsigned int st_size; |
| 132 | unsigned int st_atime; |
| 133 | unsigned int st_mtime; |
| 134 | unsigned int st_ctime; |
| 135 | }; |
Denys Vlasenko | 8470374 | 2012-02-25 02:38:52 +0100 | [diff] [blame] | 136 | #else |
| 137 | # undef dev_t |
| 138 | # undef ino_t |
| 139 | # undef mode_t |
| 140 | # undef nlink_t |
| 141 | # undef uid_t |
| 142 | # undef gid_t |
| 143 | # undef off_t |
| 144 | # undef loff_t |
Denys Vlasenko | 8470374 | 2012-02-25 02:38:52 +0100 | [diff] [blame] | 145 | # define dev_t __kernel_dev_t |
| 146 | # define ino_t __kernel_ino_t |
| 147 | # define mode_t __kernel_mode_t |
| 148 | # define nlink_t __kernel_nlink_t |
| 149 | # define uid_t __kernel_uid_t |
| 150 | # define gid_t __kernel_gid_t |
| 151 | # define off_t __kernel_off_t |
| 152 | # define loff_t __kernel_loff_t |
Wichert Akkerman | a601370 | 1999-07-08 14:00:58 +0000 | [diff] [blame] | 153 | |
Denys Vlasenko | 8470374 | 2012-02-25 02:38:52 +0100 | [diff] [blame] | 154 | # include <asm/stat.h> |
Wichert Akkerman | a601370 | 1999-07-08 14:00:58 +0000 | [diff] [blame] | 155 | |
Denys Vlasenko | 8470374 | 2012-02-25 02:38:52 +0100 | [diff] [blame] | 156 | # undef dev_t |
| 157 | # undef ino_t |
| 158 | # undef mode_t |
| 159 | # undef nlink_t |
| 160 | # undef uid_t |
| 161 | # undef gid_t |
| 162 | # undef off_t |
| 163 | # undef loff_t |
Denys Vlasenko | 8470374 | 2012-02-25 02:38:52 +0100 | [diff] [blame] | 164 | # define dev_t dev_t |
| 165 | # define ino_t ino_t |
| 166 | # define mode_t mode_t |
| 167 | # define nlink_t nlink_t |
| 168 | # define uid_t uid_t |
| 169 | # define gid_t gid_t |
| 170 | # define off_t off_t |
| 171 | # define loff_t loff_t |
| 172 | #endif |
| 173 | |
Denys Vlasenko | 8470374 | 2012-02-25 02:38:52 +0100 | [diff] [blame] | 174 | #define stat libc_stat |
| 175 | #define stat64 libc_stat64 |
| 176 | #include <sys/stat.h> |
| 177 | #undef stat |
| 178 | #undef stat64 |
Denys Vlasenko | a6d91de | 2012-03-16 12:02:22 +0100 | [diff] [blame] | 179 | /* These might be macros. */ |
Denys Vlasenko | 8470374 | 2012-02-25 02:38:52 +0100 | [diff] [blame] | 180 | #undef st_atime |
| 181 | #undef st_mtime |
| 182 | #undef st_ctime |
Wichert Akkerman | d4d8e92 | 1999-04-18 23:30:29 +0000 | [diff] [blame] | 183 | |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 184 | #include <fcntl.h> |
Wichert Akkerman | bf79f2e | 2000-09-01 21:03:06 +0000 | [diff] [blame] | 185 | #ifdef HAVE_SYS_VFS_H |
Denys Vlasenko | 8470374 | 2012-02-25 02:38:52 +0100 | [diff] [blame] | 186 | # include <sys/vfs.h> |
Wichert Akkerman | bf79f2e | 2000-09-01 21:03:06 +0000 | [diff] [blame] | 187 | #endif |
Roland McGrath | 186c5ac | 2002-12-15 23:58:23 +0000 | [diff] [blame] | 188 | #ifdef HAVE_LINUX_XATTR_H |
Denys Vlasenko | 8470374 | 2012-02-25 02:38:52 +0100 | [diff] [blame] | 189 | # include <linux/xattr.h> |
Denys Vlasenko | ed720fd | 2012-02-25 02:24:03 +0100 | [diff] [blame] | 190 | #else |
Denys Vlasenko | 8470374 | 2012-02-25 02:38:52 +0100 | [diff] [blame] | 191 | # define XATTR_CREATE 1 |
| 192 | # define XATTR_REPLACE 2 |
Roland McGrath | 186c5ac | 2002-12-15 23:58:23 +0000 | [diff] [blame] | 193 | #endif |
| 194 | |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 195 | #ifdef MAJOR_IN_SYSMACROS |
Denys Vlasenko | 8470374 | 2012-02-25 02:38:52 +0100 | [diff] [blame] | 196 | # include <sys/sysmacros.h> |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 197 | #endif |
| 198 | |
| 199 | #ifdef MAJOR_IN_MKDEV |
Denys Vlasenko | 8470374 | 2012-02-25 02:38:52 +0100 | [diff] [blame] | 200 | # include <sys/mkdev.h> |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 201 | #endif |
| 202 | |
| 203 | #ifdef HAVE_SYS_ASYNCH_H |
Denys Vlasenko | 8470374 | 2012-02-25 02:38:52 +0100 | [diff] [blame] | 204 | # include <sys/asynch.h> |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 205 | #endif |
| 206 | |
Denys Vlasenko | a6d91de | 2012-03-16 12:02:22 +0100 | [diff] [blame] | 207 | struct kernel_dirent { |
| 208 | unsigned long d_ino; |
| 209 | unsigned long d_off; |
| 210 | unsigned short d_reclen; |
| 211 | char d_name[1]; |
| 212 | }; |
| 213 | |
Dmitry V. Levin | 0ed617b | 2014-04-25 23:30:54 +0000 | [diff] [blame^] | 214 | #include "xlat/open_access_modes.h" |
Dmitry V. Levin | 9b5b67e | 2007-01-11 23:19:55 +0000 | [diff] [blame] | 215 | |
Dmitry V. Levin | 0ed617b | 2014-04-25 23:30:54 +0000 | [diff] [blame^] | 216 | #include "xlat/open_mode_flags.h" |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 217 | |
Dmitry V. Levin | 95ebf5a | 2006-10-13 20:25:12 +0000 | [diff] [blame] | 218 | #ifndef AT_FDCWD |
| 219 | # define AT_FDCWD -100 |
| 220 | #endif |
| 221 | |
Denys Vlasenko | e740fd3 | 2009-04-16 12:06:16 +0000 | [diff] [blame] | 222 | /* The fd is an "int", so when decoding x86 on x86_64, we need to force sign |
| 223 | * extension to get the right value. We do this by declaring fd as int here. |
| 224 | */ |
Dmitry V. Levin | 99db95d | 2014-02-05 04:13:18 +0000 | [diff] [blame] | 225 | void |
Dmitry V. Levin | 3138213 | 2011-03-04 05:08:02 +0300 | [diff] [blame] | 226 | print_dirfd(struct tcb *tcp, int fd) |
Dmitry V. Levin | 95ebf5a | 2006-10-13 20:25:12 +0000 | [diff] [blame] | 227 | { |
| 228 | if (fd == AT_FDCWD) |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 229 | tprints("AT_FDCWD, "); |
Denys Vlasenko | 7b609d5 | 2011-06-22 14:32:43 +0200 | [diff] [blame] | 230 | else { |
Dmitry V. Levin | 3138213 | 2011-03-04 05:08:02 +0300 | [diff] [blame] | 231 | printfd(tcp, fd); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 232 | tprints(", "); |
Dmitry V. Levin | 3138213 | 2011-03-04 05:08:02 +0300 | [diff] [blame] | 233 | } |
Dmitry V. Levin | 95ebf5a | 2006-10-13 20:25:12 +0000 | [diff] [blame] | 234 | } |
Dmitry V. Levin | 95ebf5a | 2006-10-13 20:25:12 +0000 | [diff] [blame] | 235 | |
Dmitry V. Levin | 9b5b67e | 2007-01-11 23:19:55 +0000 | [diff] [blame] | 236 | /* |
| 237 | * low bits of the open(2) flags define access mode, |
| 238 | * other bits are real flags. |
| 239 | */ |
Denys Vlasenko | eedaac7 | 2009-03-10 20:41:58 +0000 | [diff] [blame] | 240 | const char * |
| 241 | sprint_open_modes(mode_t flags) |
Dmitry V. Levin | 9b5b67e | 2007-01-11 23:19:55 +0000 | [diff] [blame] | 242 | { |
Denys Vlasenko | 4f3df07 | 2012-01-29 22:38:35 +0100 | [diff] [blame] | 243 | static char outstr[(1 + ARRAY_SIZE(open_mode_flags)) * sizeof("O_LARGEFILE")]; |
Denys Vlasenko | eedaac7 | 2009-03-10 20:41:58 +0000 | [diff] [blame] | 244 | char *p; |
Denys Vlasenko | 4f3df07 | 2012-01-29 22:38:35 +0100 | [diff] [blame] | 245 | char sep; |
Denys Vlasenko | eedaac7 | 2009-03-10 20:41:58 +0000 | [diff] [blame] | 246 | const char *str; |
| 247 | const struct xlat *x; |
Dmitry V. Levin | 9b5b67e | 2007-01-11 23:19:55 +0000 | [diff] [blame] | 248 | |
Denys Vlasenko | 4f3df07 | 2012-01-29 22:38:35 +0100 | [diff] [blame] | 249 | sep = ' '; |
| 250 | p = stpcpy(outstr, "flags"); |
Denys Vlasenko | eedaac7 | 2009-03-10 20:41:58 +0000 | [diff] [blame] | 251 | str = xlookup(open_access_modes, flags & 3); |
| 252 | if (str) { |
Denys Vlasenko | 4f3df07 | 2012-01-29 22:38:35 +0100 | [diff] [blame] | 253 | *p++ = sep; |
Denys Vlasenko | 5284557 | 2011-08-31 12:07:38 +0200 | [diff] [blame] | 254 | p = stpcpy(p, str); |
Dmitry V. Levin | 9b5b67e | 2007-01-11 23:19:55 +0000 | [diff] [blame] | 255 | flags &= ~3; |
| 256 | if (!flags) |
Denys Vlasenko | eedaac7 | 2009-03-10 20:41:58 +0000 | [diff] [blame] | 257 | return outstr; |
| 258 | sep = '|'; |
Dmitry V. Levin | 9b5b67e | 2007-01-11 23:19:55 +0000 | [diff] [blame] | 259 | } |
Denys Vlasenko | eedaac7 | 2009-03-10 20:41:58 +0000 | [diff] [blame] | 260 | |
| 261 | for (x = open_mode_flags; x->str; x++) { |
| 262 | if ((flags & x->val) == x->val) { |
Denys Vlasenko | 4f3df07 | 2012-01-29 22:38:35 +0100 | [diff] [blame] | 263 | *p++ = sep; |
Denys Vlasenko | 5284557 | 2011-08-31 12:07:38 +0200 | [diff] [blame] | 264 | p = stpcpy(p, x->str); |
Denys Vlasenko | eedaac7 | 2009-03-10 20:41:58 +0000 | [diff] [blame] | 265 | flags &= ~x->val; |
| 266 | if (!flags) |
| 267 | return outstr; |
| 268 | sep = '|'; |
| 269 | } |
| 270 | } |
| 271 | /* flags is still nonzero */ |
Denys Vlasenko | 4f3df07 | 2012-01-29 22:38:35 +0100 | [diff] [blame] | 272 | *p++ = sep; |
Denys Vlasenko | eedaac7 | 2009-03-10 20:41:58 +0000 | [diff] [blame] | 273 | sprintf(p, "%#x", flags); |
| 274 | return outstr; |
| 275 | } |
| 276 | |
| 277 | void |
| 278 | tprint_open_modes(mode_t flags) |
| 279 | { |
Denys Vlasenko | 5940e65 | 2011-09-01 09:55:05 +0200 | [diff] [blame] | 280 | tprints(sprint_open_modes(flags) + sizeof("flags")); |
Dmitry V. Levin | 9b5b67e | 2007-01-11 23:19:55 +0000 | [diff] [blame] | 281 | } |
| 282 | |
Dmitry V. Levin | 95ebf5a | 2006-10-13 20:25:12 +0000 | [diff] [blame] | 283 | static int |
| 284 | decode_open(struct tcb *tcp, int offset) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 285 | { |
| 286 | if (entering(tcp)) { |
Dmitry V. Levin | 95ebf5a | 2006-10-13 20:25:12 +0000 | [diff] [blame] | 287 | printpath(tcp, tcp->u_arg[offset]); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 288 | tprints(", "); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 289 | /* flags */ |
Denys Vlasenko | eedaac7 | 2009-03-10 20:41:58 +0000 | [diff] [blame] | 290 | tprint_open_modes(tcp->u_arg[offset + 1]); |
Dmitry V. Levin | 95ebf5a | 2006-10-13 20:25:12 +0000 | [diff] [blame] | 291 | if (tcp->u_arg[offset + 1] & O_CREAT) { |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 292 | /* mode */ |
Dmitry V. Levin | 95ebf5a | 2006-10-13 20:25:12 +0000 | [diff] [blame] | 293 | tprintf(", %#lo", tcp->u_arg[offset + 2]); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 294 | } |
| 295 | } |
| 296 | return 0; |
| 297 | } |
| 298 | |
Dmitry V. Levin | 95ebf5a | 2006-10-13 20:25:12 +0000 | [diff] [blame] | 299 | int |
| 300 | sys_open(struct tcb *tcp) |
| 301 | { |
| 302 | return decode_open(tcp, 0); |
| 303 | } |
| 304 | |
Dmitry V. Levin | 95ebf5a | 2006-10-13 20:25:12 +0000 | [diff] [blame] | 305 | int |
| 306 | sys_openat(struct tcb *tcp) |
| 307 | { |
| 308 | if (entering(tcp)) |
Dmitry V. Levin | 3138213 | 2011-03-04 05:08:02 +0300 | [diff] [blame] | 309 | print_dirfd(tcp, tcp->u_arg[0]); |
Dmitry V. Levin | 95ebf5a | 2006-10-13 20:25:12 +0000 | [diff] [blame] | 310 | return decode_open(tcp, 1); |
| 311 | } |
Dmitry V. Levin | 95ebf5a | 2006-10-13 20:25:12 +0000 | [diff] [blame] | 312 | |
Denys Vlasenko | 9472a27 | 2013-02-12 11:43:46 +0100 | [diff] [blame] | 313 | #if defined(SPARC) || defined(SPARC64) |
Dmitry V. Levin | 0ed617b | 2014-04-25 23:30:54 +0000 | [diff] [blame^] | 314 | #include "xlat/openmodessol.h" |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 315 | |
| 316 | int |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 317 | solaris_open(struct tcb *tcp) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 318 | { |
| 319 | if (entering(tcp)) { |
| 320 | printpath(tcp, tcp->u_arg[0]); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 321 | tprints(", "); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 322 | /* flags */ |
Roland McGrath | b2dee13 | 2005-06-01 19:02:36 +0000 | [diff] [blame] | 323 | printflags(openmodessol, tcp->u_arg[1] + 1, "O_???"); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 324 | if (tcp->u_arg[1] & 0x100) { |
| 325 | /* mode */ |
| 326 | tprintf(", %#lo", tcp->u_arg[2]); |
| 327 | } |
| 328 | } |
| 329 | return 0; |
| 330 | } |
| 331 | |
| 332 | #endif |
| 333 | |
| 334 | int |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 335 | sys_creat(struct tcb *tcp) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 336 | { |
| 337 | if (entering(tcp)) { |
| 338 | printpath(tcp, tcp->u_arg[0]); |
| 339 | tprintf(", %#lo", tcp->u_arg[1]); |
| 340 | } |
| 341 | return 0; |
| 342 | } |
| 343 | |
Dmitry V. Levin | 0ed617b | 2014-04-25 23:30:54 +0000 | [diff] [blame^] | 344 | #include "xlat/access_flags.h" |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 345 | |
Dmitry V. Levin | 95ebf5a | 2006-10-13 20:25:12 +0000 | [diff] [blame] | 346 | static int |
| 347 | decode_access(struct tcb *tcp, int offset) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 348 | { |
| 349 | if (entering(tcp)) { |
Dmitry V. Levin | 95ebf5a | 2006-10-13 20:25:12 +0000 | [diff] [blame] | 350 | printpath(tcp, tcp->u_arg[offset]); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 351 | tprints(", "); |
Dmitry V. Levin | 95ebf5a | 2006-10-13 20:25:12 +0000 | [diff] [blame] | 352 | printflags(access_flags, tcp->u_arg[offset + 1], "?_OK"); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 353 | } |
| 354 | return 0; |
| 355 | } |
| 356 | |
| 357 | int |
Dmitry V. Levin | 95ebf5a | 2006-10-13 20:25:12 +0000 | [diff] [blame] | 358 | sys_access(struct tcb *tcp) |
| 359 | { |
| 360 | return decode_access(tcp, 0); |
| 361 | } |
| 362 | |
Dmitry V. Levin | 95ebf5a | 2006-10-13 20:25:12 +0000 | [diff] [blame] | 363 | int |
| 364 | sys_faccessat(struct tcb *tcp) |
| 365 | { |
| 366 | if (entering(tcp)) |
Dmitry V. Levin | 3138213 | 2011-03-04 05:08:02 +0300 | [diff] [blame] | 367 | print_dirfd(tcp, tcp->u_arg[0]); |
Dmitry V. Levin | 95ebf5a | 2006-10-13 20:25:12 +0000 | [diff] [blame] | 368 | return decode_access(tcp, 1); |
| 369 | } |
Dmitry V. Levin | 95ebf5a | 2006-10-13 20:25:12 +0000 | [diff] [blame] | 370 | |
| 371 | int |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 372 | sys_umask(struct tcb *tcp) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 373 | { |
| 374 | if (entering(tcp)) { |
| 375 | tprintf("%#lo", tcp->u_arg[0]); |
| 376 | } |
| 377 | return RVAL_OCTAL; |
| 378 | } |
| 379 | |
Dmitry V. Levin | 0ed617b | 2014-04-25 23:30:54 +0000 | [diff] [blame^] | 380 | #include "xlat/whence_codes.h" |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 381 | |
Denys Vlasenko | 386b871 | 2013-02-17 01:38:14 +0100 | [diff] [blame] | 382 | /* Linux kernel has exactly one version of lseek: |
| 383 | * fs/read_write.c::SYSCALL_DEFINE3(lseek, unsigned, fd, off_t, offset, unsigned, origin) |
| 384 | * In kernel, off_t is always the same as (kernel's) long |
| 385 | * (see include/uapi/asm-generic/posix_types.h), |
| 386 | * 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] | 387 | * Use test/x32_lseek.c to test lseek decoding. |
Denys Vlasenko | 386b871 | 2013-02-17 01:38:14 +0100 | [diff] [blame] | 388 | */ |
H.J. Lu | c933f27 | 2012-04-16 17:41:13 +0200 | [diff] [blame] | 389 | #if defined(LINUX_MIPSN32) || defined(X32) |
Roland McGrath | 542c2c6 | 2008-05-20 01:11:56 +0000 | [diff] [blame] | 390 | int |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 391 | sys_lseek(struct tcb *tcp) |
Roland McGrath | 542c2c6 | 2008-05-20 01:11:56 +0000 | [diff] [blame] | 392 | { |
| 393 | long long offset; |
Denys Vlasenko | 386b871 | 2013-02-17 01:38:14 +0100 | [diff] [blame] | 394 | int whence; |
Roland McGrath | 542c2c6 | 2008-05-20 01:11:56 +0000 | [diff] [blame] | 395 | |
| 396 | if (entering(tcp)) { |
Dmitry V. Levin | 3138213 | 2011-03-04 05:08:02 +0300 | [diff] [blame] | 397 | printfd(tcp, tcp->u_arg[0]); |
Roland McGrath | 542c2c6 | 2008-05-20 01:11:56 +0000 | [diff] [blame] | 398 | offset = tcp->ext_arg[1]; |
Denys Vlasenko | 386b871 | 2013-02-17 01:38:14 +0100 | [diff] [blame] | 399 | whence = tcp->u_arg[2]; |
| 400 | if (whence == SEEK_SET) |
| 401 | tprintf(", %llu, ", offset); |
Roland McGrath | 542c2c6 | 2008-05-20 01:11:56 +0000 | [diff] [blame] | 402 | else |
Denys Vlasenko | 386b871 | 2013-02-17 01:38:14 +0100 | [diff] [blame] | 403 | tprintf(", %lld, ", offset); |
Denys Vlasenko | 782d90f | 2013-02-17 12:47:44 +0100 | [diff] [blame] | 404 | printxval(whence_codes, whence, "SEEK_???"); |
Roland McGrath | 542c2c6 | 2008-05-20 01:11:56 +0000 | [diff] [blame] | 405 | } |
H.J. Lu | dd0130b | 2012-04-16 12:16:45 +0200 | [diff] [blame] | 406 | return RVAL_LUDECIMAL; |
Roland McGrath | 542c2c6 | 2008-05-20 01:11:56 +0000 | [diff] [blame] | 407 | } |
H.J. Lu | dd0130b | 2012-04-16 12:16:45 +0200 | [diff] [blame] | 408 | #else |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 409 | int |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 410 | sys_lseek(struct tcb *tcp) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 411 | { |
Denys Vlasenko | 0612176 | 2013-02-17 20:08:50 +0100 | [diff] [blame] | 412 | long offset; |
Denys Vlasenko | 386b871 | 2013-02-17 01:38:14 +0100 | [diff] [blame] | 413 | int whence; |
Wichert Akkerman | bf79f2e | 2000-09-01 21:03:06 +0000 | [diff] [blame] | 414 | |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 415 | if (entering(tcp)) { |
Dmitry V. Levin | 3138213 | 2011-03-04 05:08:02 +0300 | [diff] [blame] | 416 | printfd(tcp, tcp->u_arg[0]); |
Wichert Akkerman | bf79f2e | 2000-09-01 21:03:06 +0000 | [diff] [blame] | 417 | offset = tcp->u_arg[1]; |
Denys Vlasenko | 386b871 | 2013-02-17 01:38:14 +0100 | [diff] [blame] | 418 | whence = tcp->u_arg[2]; |
| 419 | if (whence == SEEK_SET) |
| 420 | tprintf(", %lu, ", offset); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 421 | else |
Denys Vlasenko | 386b871 | 2013-02-17 01:38:14 +0100 | [diff] [blame] | 422 | tprintf(", %ld, ", offset); |
Denys Vlasenko | 782d90f | 2013-02-17 12:47:44 +0100 | [diff] [blame] | 423 | printxval(whence_codes, whence, "SEEK_???"); |
Roland McGrath | 186c5ac | 2002-12-15 23:58:23 +0000 | [diff] [blame] | 424 | } |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 425 | return RVAL_UDECIMAL; |
| 426 | } |
John Hughes | 5a826b8 | 2001-03-07 13:21:24 +0000 | [diff] [blame] | 427 | #endif |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 428 | |
Denys Vlasenko | 386b871 | 2013-02-17 01:38:14 +0100 | [diff] [blame] | 429 | /* llseek syscall takes explicitly two ulong arguments hi, lo, |
| 430 | * rather than one 64-bit argument for which LONG_LONG works |
| 431 | * appropriate for the native byte order. |
| 432 | * |
| 433 | * See kernel's fs/read_write.c::SYSCALL_DEFINE5(llseek, ...) |
| 434 | * |
| 435 | * hi,lo are "unsigned longs" and combined exactly this way in kernel: |
| 436 | * ((loff_t) hi << 32) | lo |
Denys Vlasenko | 09a87ae | 2013-02-17 13:17:49 +0100 | [diff] [blame] | 437 | * Note that for architectures with kernel's long wider than userspace long |
Denys Vlasenko | 386b871 | 2013-02-17 01:38:14 +0100 | [diff] [blame] | 438 | * (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] | 439 | * for hi and lo. We would need to use tcp->ext_arg[N] on x32... |
| 440 | * ...however, x32 (and x86_64) does not _have_ llseek syscall as such. |
Denys Vlasenko | 386b871 | 2013-02-17 01:38:14 +0100 | [diff] [blame] | 441 | */ |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 442 | int |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 443 | sys_llseek(struct tcb *tcp) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 444 | { |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 445 | if (entering(tcp)) { |
Dmitry V. Levin | 3138213 | 2011-03-04 05:08:02 +0300 | [diff] [blame] | 446 | printfd(tcp, tcp->u_arg[0]); |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 447 | if (tcp->u_arg[4] == SEEK_SET) |
Dmitry V. Levin | 3138213 | 2011-03-04 05:08:02 +0300 | [diff] [blame] | 448 | tprintf(", %llu, ", |
Denys Vlasenko | 386b871 | 2013-02-17 01:38:14 +0100 | [diff] [blame] | 449 | ((long long) tcp->u_arg[1]) << 32 | |
Dmitry V. Levin | 3138213 | 2011-03-04 05:08:02 +0300 | [diff] [blame] | 450 | (unsigned long long) (unsigned) tcp->u_arg[2]); |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 451 | else |
Dmitry V. Levin | 3138213 | 2011-03-04 05:08:02 +0300 | [diff] [blame] | 452 | tprintf(", %lld, ", |
Denys Vlasenko | 386b871 | 2013-02-17 01:38:14 +0100 | [diff] [blame] | 453 | ((long long) tcp->u_arg[1]) << 32 | |
Dmitry V. Levin | 3138213 | 2011-03-04 05:08:02 +0300 | [diff] [blame] | 454 | (unsigned long long) (unsigned) tcp->u_arg[2]); |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 455 | } |
| 456 | else { |
Denys Vlasenko | 386b871 | 2013-02-17 01:38:14 +0100 | [diff] [blame] | 457 | long long off; |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 458 | if (syserror(tcp) || umove(tcp, tcp->u_arg[3], &off) < 0) |
| 459 | tprintf("%#lx, ", tcp->u_arg[3]); |
| 460 | else |
| 461 | tprintf("[%llu], ", off); |
Denys Vlasenko | 782d90f | 2013-02-17 12:47:44 +0100 | [diff] [blame] | 462 | printxval(whence_codes, tcp->u_arg[4], "SEEK_???"); |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 463 | } |
| 464 | return 0; |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 465 | } |
Roland McGrath | 186c5ac | 2002-12-15 23:58:23 +0000 | [diff] [blame] | 466 | |
| 467 | int |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 468 | sys_readahead(struct tcb *tcp) |
Roland McGrath | 186c5ac | 2002-12-15 23:58:23 +0000 | [diff] [blame] | 469 | { |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 470 | if (entering(tcp)) { |
Andreas Schwab | b5600fc | 2009-11-04 17:08:34 +0100 | [diff] [blame] | 471 | int argn; |
Dmitry V. Levin | 3138213 | 2011-03-04 05:08:02 +0300 | [diff] [blame] | 472 | printfd(tcp, tcp->u_arg[0]); |
Dmitry V. Levin | 7845a42 | 2014-04-17 13:32:47 +0000 | [diff] [blame] | 473 | argn = printllval_aligned(tcp, ", %lld", 1); |
Andreas Schwab | b5600fc | 2009-11-04 17:08:34 +0100 | [diff] [blame] | 474 | tprintf(", %ld", tcp->u_arg[argn]); |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 475 | } |
| 476 | return 0; |
Roland McGrath | 186c5ac | 2002-12-15 23:58:23 +0000 | [diff] [blame] | 477 | } |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 478 | |
| 479 | int |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 480 | sys_truncate(struct tcb *tcp) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 481 | { |
| 482 | if (entering(tcp)) { |
| 483 | printpath(tcp, tcp->u_arg[0]); |
| 484 | tprintf(", %lu", tcp->u_arg[1]); |
| 485 | } |
| 486 | return 0; |
| 487 | } |
| 488 | |
John Hughes | 96f5147 | 2001-03-06 16:50:41 +0000 | [diff] [blame] | 489 | int |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 490 | sys_truncate64(struct tcb *tcp) |
John Hughes | 96f5147 | 2001-03-06 16:50:41 +0000 | [diff] [blame] | 491 | { |
| 492 | if (entering(tcp)) { |
| 493 | printpath(tcp, tcp->u_arg[0]); |
Dmitry V. Levin | 7845a42 | 2014-04-17 13:32:47 +0000 | [diff] [blame] | 494 | printllval_aligned(tcp, ", %llu", 1); |
John Hughes | 96f5147 | 2001-03-06 16:50:41 +0000 | [diff] [blame] | 495 | } |
| 496 | return 0; |
| 497 | } |
John Hughes | 96f5147 | 2001-03-06 16:50:41 +0000 | [diff] [blame] | 498 | |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 499 | int |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 500 | sys_ftruncate(struct tcb *tcp) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 501 | { |
| 502 | if (entering(tcp)) { |
Dmitry V. Levin | 3138213 | 2011-03-04 05:08:02 +0300 | [diff] [blame] | 503 | printfd(tcp, tcp->u_arg[0]); |
| 504 | tprintf(", %lu", tcp->u_arg[1]); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 505 | } |
| 506 | return 0; |
| 507 | } |
| 508 | |
John Hughes | 96f5147 | 2001-03-06 16:50:41 +0000 | [diff] [blame] | 509 | int |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 510 | sys_ftruncate64(struct tcb *tcp) |
John Hughes | 96f5147 | 2001-03-06 16:50:41 +0000 | [diff] [blame] | 511 | { |
| 512 | if (entering(tcp)) { |
Dmitry V. Levin | 3138213 | 2011-03-04 05:08:02 +0300 | [diff] [blame] | 513 | printfd(tcp, tcp->u_arg[0]); |
Dmitry V. Levin | 7845a42 | 2014-04-17 13:32:47 +0000 | [diff] [blame] | 514 | printllval_aligned(tcp, ", %llu", 1); |
John Hughes | 96f5147 | 2001-03-06 16:50:41 +0000 | [diff] [blame] | 515 | } |
| 516 | return 0; |
| 517 | } |
John Hughes | 96f5147 | 2001-03-06 16:50:41 +0000 | [diff] [blame] | 518 | |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 519 | /* several stats */ |
| 520 | |
Dmitry V. Levin | 0ed617b | 2014-04-25 23:30:54 +0000 | [diff] [blame^] | 521 | #include "xlat/modetypes.h" |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 522 | |
Roland McGrath | f9c49b2 | 2004-10-06 22:11:54 +0000 | [diff] [blame] | 523 | static const char * |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 524 | sprintmode(int mode) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 525 | { |
Denys Vlasenko | 1945ccc | 2012-02-27 14:37:48 +0100 | [diff] [blame] | 526 | static char buf[sizeof("S_IFSOCK|S_ISUID|S_ISGID|S_ISVTX|%o") |
| 527 | + sizeof(int)*3 |
| 528 | + /*paranoia:*/ 8]; |
Roland McGrath | f9c49b2 | 2004-10-06 22:11:54 +0000 | [diff] [blame] | 529 | const char *s; |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 530 | |
| 531 | if ((mode & S_IFMT) == 0) |
| 532 | s = ""; |
| 533 | else if ((s = xlookup(modetypes, mode & S_IFMT)) == NULL) { |
| 534 | sprintf(buf, "%#o", mode); |
| 535 | return buf; |
| 536 | } |
Denys Vlasenko | 1945ccc | 2012-02-27 14:37:48 +0100 | [diff] [blame] | 537 | s = buf + sprintf(buf, "%s%s%s%s", s, |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 538 | (mode & S_ISUID) ? "|S_ISUID" : "", |
| 539 | (mode & S_ISGID) ? "|S_ISGID" : "", |
| 540 | (mode & S_ISVTX) ? "|S_ISVTX" : ""); |
| 541 | mode &= ~(S_IFMT|S_ISUID|S_ISGID|S_ISVTX); |
| 542 | if (mode) |
Denys Vlasenko | 1945ccc | 2012-02-27 14:37:48 +0100 | [diff] [blame] | 543 | sprintf((char*)s, "|%#o", mode); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 544 | s = (*buf == '|') ? buf + 1 : buf; |
| 545 | return *s ? s : "0"; |
| 546 | } |
| 547 | |
| 548 | static char * |
Dmitry V. Levin | dc7715b | 2008-04-19 23:45:09 +0000 | [diff] [blame] | 549 | sprinttime(time_t t) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 550 | { |
| 551 | struct tm *tmp; |
Denys Vlasenko | 1945ccc | 2012-02-27 14:37:48 +0100 | [diff] [blame] | 552 | static char buf[sizeof("yyyy/mm/dd-hh:mm:ss")]; |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 553 | |
| 554 | if (t == 0) { |
Dmitry V. Levin | dc7715b | 2008-04-19 23:45:09 +0000 | [diff] [blame] | 555 | strcpy(buf, "0"); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 556 | return buf; |
| 557 | } |
Denys Vlasenko | 5d64581 | 2011-08-20 12:48:18 +0200 | [diff] [blame] | 558 | tmp = localtime(&t); |
| 559 | if (tmp) |
Dmitry V. Levin | dc7715b | 2008-04-19 23:45:09 +0000 | [diff] [blame] | 560 | snprintf(buf, sizeof buf, "%02d/%02d/%02d-%02d:%02d:%02d", |
| 561 | tmp->tm_year + 1900, tmp->tm_mon + 1, tmp->tm_mday, |
| 562 | tmp->tm_hour, tmp->tm_min, tmp->tm_sec); |
| 563 | else |
| 564 | snprintf(buf, sizeof buf, "%lu", (unsigned long) t); |
| 565 | |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 566 | return buf; |
| 567 | } |
| 568 | |
Denys Vlasenko | 9472a27 | 2013-02-12 11:43:46 +0100 | [diff] [blame] | 569 | #if defined(SPARC) || defined(SPARC64) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 570 | typedef struct { |
Denys Vlasenko | adedb51 | 2008-12-30 18:47:55 +0000 | [diff] [blame] | 571 | int tv_sec; |
| 572 | int tv_nsec; |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 573 | } timestruct_t; |
| 574 | |
| 575 | struct solstat { |
Denys Vlasenko | adedb51 | 2008-12-30 18:47:55 +0000 | [diff] [blame] | 576 | unsigned st_dev; |
| 577 | int st_pad1[3]; /* network id */ |
| 578 | unsigned st_ino; |
| 579 | unsigned st_mode; |
| 580 | unsigned st_nlink; |
| 581 | unsigned st_uid; |
| 582 | unsigned st_gid; |
| 583 | unsigned st_rdev; |
| 584 | int st_pad2[2]; |
| 585 | int st_size; |
| 586 | int st_pad3; /* st_size, off_t expansion */ |
| 587 | timestruct_t st_atime; |
| 588 | timestruct_t st_mtime; |
| 589 | timestruct_t st_ctime; |
| 590 | int st_blksize; |
| 591 | int st_blocks; |
| 592 | char st_fstype[16]; |
| 593 | int st_pad4[8]; /* expansion area */ |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 594 | }; |
| 595 | |
| 596 | static void |
Dmitry V. Levin | b838b1e | 2008-04-19 23:47:47 +0000 | [diff] [blame] | 597 | printstatsol(struct tcb *tcp, long addr) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 598 | { |
| 599 | struct solstat statbuf; |
| 600 | |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 601 | if (umove(tcp, addr, &statbuf) < 0) { |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 602 | tprints("{...}"); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 603 | return; |
| 604 | } |
| 605 | if (!abbrev(tcp)) { |
| 606 | tprintf("{st_dev=makedev(%lu, %lu), st_ino=%lu, st_mode=%s, ", |
| 607 | (unsigned long) ((statbuf.st_dev >> 18) & 0x3fff), |
| 608 | (unsigned long) (statbuf.st_dev & 0x3ffff), |
| 609 | (unsigned long) statbuf.st_ino, |
| 610 | sprintmode(statbuf.st_mode)); |
| 611 | tprintf("st_nlink=%lu, st_uid=%lu, st_gid=%lu, ", |
| 612 | (unsigned long) statbuf.st_nlink, |
| 613 | (unsigned long) statbuf.st_uid, |
| 614 | (unsigned long) statbuf.st_gid); |
| 615 | tprintf("st_blksize=%lu, ", (unsigned long) statbuf.st_blksize); |
| 616 | tprintf("st_blocks=%lu, ", (unsigned long) statbuf.st_blocks); |
| 617 | } |
| 618 | else |
| 619 | tprintf("{st_mode=%s, ", sprintmode(statbuf.st_mode)); |
| 620 | switch (statbuf.st_mode & S_IFMT) { |
| 621 | case S_IFCHR: case S_IFBLK: |
| 622 | tprintf("st_rdev=makedev(%lu, %lu), ", |
| 623 | (unsigned long) ((statbuf.st_rdev >> 18) & 0x3fff), |
| 624 | (unsigned long) (statbuf.st_rdev & 0x3ffff)); |
| 625 | break; |
| 626 | default: |
| 627 | tprintf("st_size=%u, ", statbuf.st_size); |
| 628 | break; |
| 629 | } |
| 630 | if (!abbrev(tcp)) { |
Dmitry V. Levin | b838b1e | 2008-04-19 23:47:47 +0000 | [diff] [blame] | 631 | tprintf("st_atime=%s, ", sprinttime(statbuf.st_atime.tv_sec)); |
| 632 | tprintf("st_mtime=%s, ", sprinttime(statbuf.st_mtime.tv_sec)); |
| 633 | tprintf("st_ctime=%s}", sprinttime(statbuf.st_ctime.tv_sec)); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 634 | } |
| 635 | else |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 636 | tprints("...}"); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 637 | } |
Roland McGrath | 6d1a65c | 2004-07-12 07:44:08 +0000 | [diff] [blame] | 638 | |
Denys Vlasenko | 9472a27 | 2013-02-12 11:43:46 +0100 | [diff] [blame] | 639 | # if defined(SPARC64) |
Roland McGrath | 6d1a65c | 2004-07-12 07:44:08 +0000 | [diff] [blame] | 640 | static void |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 641 | printstat_sparc64(struct tcb *tcp, long addr) |
Roland McGrath | 6d1a65c | 2004-07-12 07:44:08 +0000 | [diff] [blame] | 642 | { |
| 643 | struct stat_sparc64 statbuf; |
| 644 | |
Roland McGrath | 6d1a65c | 2004-07-12 07:44:08 +0000 | [diff] [blame] | 645 | if (umove(tcp, addr, &statbuf) < 0) { |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 646 | tprints("{...}"); |
Roland McGrath | 6d1a65c | 2004-07-12 07:44:08 +0000 | [diff] [blame] | 647 | return; |
| 648 | } |
| 649 | |
| 650 | if (!abbrev(tcp)) { |
| 651 | tprintf("{st_dev=makedev(%lu, %lu), st_ino=%lu, st_mode=%s, ", |
| 652 | (unsigned long) major(statbuf.st_dev), |
| 653 | (unsigned long) minor(statbuf.st_dev), |
| 654 | (unsigned long) statbuf.st_ino, |
| 655 | sprintmode(statbuf.st_mode)); |
| 656 | tprintf("st_nlink=%lu, st_uid=%lu, st_gid=%lu, ", |
| 657 | (unsigned long) statbuf.st_nlink, |
| 658 | (unsigned long) statbuf.st_uid, |
| 659 | (unsigned long) statbuf.st_gid); |
| 660 | tprintf("st_blksize=%lu, ", |
| 661 | (unsigned long) statbuf.st_blksize); |
| 662 | tprintf("st_blocks=%lu, ", |
| 663 | (unsigned long) statbuf.st_blocks); |
| 664 | } |
| 665 | else |
| 666 | tprintf("{st_mode=%s, ", sprintmode(statbuf.st_mode)); |
| 667 | switch (statbuf.st_mode & S_IFMT) { |
| 668 | case S_IFCHR: case S_IFBLK: |
| 669 | tprintf("st_rdev=makedev(%lu, %lu), ", |
| 670 | (unsigned long) major(statbuf.st_rdev), |
| 671 | (unsigned long) minor(statbuf.st_rdev)); |
| 672 | break; |
| 673 | default: |
| 674 | tprintf("st_size=%lu, ", statbuf.st_size); |
| 675 | break; |
| 676 | } |
| 677 | if (!abbrev(tcp)) { |
| 678 | tprintf("st_atime=%s, ", sprinttime(statbuf.st_atime)); |
| 679 | tprintf("st_mtime=%s, ", sprinttime(statbuf.st_mtime)); |
Denys Vlasenko | 1945ccc | 2012-02-27 14:37:48 +0100 | [diff] [blame] | 680 | tprintf("st_ctime=%s}", sprinttime(statbuf.st_ctime)); |
Roland McGrath | 6d1a65c | 2004-07-12 07:44:08 +0000 | [diff] [blame] | 681 | } |
| 682 | else |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 683 | tprints("...}"); |
Roland McGrath | 6d1a65c | 2004-07-12 07:44:08 +0000 | [diff] [blame] | 684 | } |
Denys Vlasenko | 9472a27 | 2013-02-12 11:43:46 +0100 | [diff] [blame] | 685 | # endif /* SPARC64 */ |
| 686 | #endif /* SPARC[64] */ |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 687 | |
Denys Vlasenko | 8470374 | 2012-02-25 02:38:52 +0100 | [diff] [blame] | 688 | #if defined POWERPC64 |
Andreas Schwab | d69fa49 | 2010-07-12 21:39:57 +0200 | [diff] [blame] | 689 | struct stat_powerpc32 { |
| 690 | unsigned int st_dev; |
| 691 | unsigned int st_ino; |
| 692 | unsigned int st_mode; |
| 693 | unsigned short st_nlink; |
| 694 | unsigned int st_uid; |
| 695 | unsigned int st_gid; |
| 696 | unsigned int st_rdev; |
| 697 | unsigned int st_size; |
| 698 | unsigned int st_blksize; |
| 699 | unsigned int st_blocks; |
| 700 | unsigned int st_atime; |
| 701 | unsigned int st_atime_nsec; |
| 702 | unsigned int st_mtime; |
| 703 | unsigned int st_mtime_nsec; |
| 704 | unsigned int st_ctime; |
| 705 | unsigned int st_ctime_nsec; |
| 706 | unsigned int __unused4; |
| 707 | unsigned int __unused5; |
| 708 | }; |
| 709 | |
| 710 | static void |
| 711 | printstat_powerpc32(struct tcb *tcp, long addr) |
| 712 | { |
| 713 | struct stat_powerpc32 statbuf; |
| 714 | |
| 715 | if (umove(tcp, addr, &statbuf) < 0) { |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 716 | tprints("{...}"); |
Andreas Schwab | d69fa49 | 2010-07-12 21:39:57 +0200 | [diff] [blame] | 717 | return; |
| 718 | } |
| 719 | |
| 720 | if (!abbrev(tcp)) { |
| 721 | tprintf("{st_dev=makedev(%u, %u), st_ino=%u, st_mode=%s, ", |
| 722 | major(statbuf.st_dev), minor(statbuf.st_dev), |
| 723 | statbuf.st_ino, |
| 724 | sprintmode(statbuf.st_mode)); |
| 725 | tprintf("st_nlink=%u, st_uid=%u, st_gid=%u, ", |
| 726 | statbuf.st_nlink, statbuf.st_uid, statbuf.st_gid); |
| 727 | tprintf("st_blksize=%u, ", statbuf.st_blksize); |
| 728 | tprintf("st_blocks=%u, ", statbuf.st_blocks); |
| 729 | } |
| 730 | else |
| 731 | tprintf("{st_mode=%s, ", sprintmode(statbuf.st_mode)); |
| 732 | switch (statbuf.st_mode & S_IFMT) { |
| 733 | case S_IFCHR: case S_IFBLK: |
| 734 | tprintf("st_rdev=makedev(%lu, %lu), ", |
| 735 | (unsigned long) major(statbuf.st_rdev), |
| 736 | (unsigned long) minor(statbuf.st_rdev)); |
| 737 | break; |
| 738 | default: |
| 739 | tprintf("st_size=%u, ", statbuf.st_size); |
| 740 | break; |
| 741 | } |
| 742 | if (!abbrev(tcp)) { |
| 743 | tprintf("st_atime=%s, ", sprinttime(statbuf.st_atime)); |
| 744 | tprintf("st_mtime=%s, ", sprinttime(statbuf.st_mtime)); |
Denys Vlasenko | 1945ccc | 2012-02-27 14:37:48 +0100 | [diff] [blame] | 745 | tprintf("st_ctime=%s}", sprinttime(statbuf.st_ctime)); |
Andreas Schwab | d69fa49 | 2010-07-12 21:39:57 +0200 | [diff] [blame] | 746 | } |
| 747 | else |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 748 | tprints("...}"); |
Andreas Schwab | d69fa49 | 2010-07-12 21:39:57 +0200 | [diff] [blame] | 749 | } |
Denys Vlasenko | 8470374 | 2012-02-25 02:38:52 +0100 | [diff] [blame] | 750 | #endif /* POWERPC64 */ |
Andreas Schwab | d69fa49 | 2010-07-12 21:39:57 +0200 | [diff] [blame] | 751 | |
Dmitry V. Levin | 0ed617b | 2014-04-25 23:30:54 +0000 | [diff] [blame^] | 752 | #include "xlat/fileflags.h" |
Wichert Akkerman | bf79f2e | 2000-09-01 21:03:06 +0000 | [diff] [blame] | 753 | |
Wichert Akkerman | 328c5e7 | 1999-04-16 00:21:26 +0000 | [diff] [blame] | 754 | static void |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 755 | realprintstat(struct tcb *tcp, struct stat *statbuf) |
Wichert Akkerman | 328c5e7 | 1999-04-16 00:21:26 +0000 | [diff] [blame] | 756 | { |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 757 | if (!abbrev(tcp)) { |
| 758 | tprintf("{st_dev=makedev(%lu, %lu), st_ino=%lu, st_mode=%s, ", |
| 759 | (unsigned long) major(statbuf->st_dev), |
| 760 | (unsigned long) minor(statbuf->st_dev), |
| 761 | (unsigned long) statbuf->st_ino, |
| 762 | sprintmode(statbuf->st_mode)); |
| 763 | tprintf("st_nlink=%lu, st_uid=%lu, st_gid=%lu, ", |
| 764 | (unsigned long) statbuf->st_nlink, |
| 765 | (unsigned long) statbuf->st_uid, |
| 766 | (unsigned long) statbuf->st_gid); |
Roland McGrath | 6d2b349 | 2002-12-30 00:51:30 +0000 | [diff] [blame] | 767 | #ifdef HAVE_STRUCT_STAT_ST_BLKSIZE |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 768 | tprintf("st_blksize=%lu, ", (unsigned long) statbuf->st_blksize); |
| 769 | #endif |
Roland McGrath | 6d2b349 | 2002-12-30 00:51:30 +0000 | [diff] [blame] | 770 | #ifdef HAVE_STRUCT_STAT_ST_BLOCKS |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 771 | tprintf("st_blocks=%lu, ", (unsigned long) statbuf->st_blocks); |
| 772 | #endif |
| 773 | } |
| 774 | else |
| 775 | tprintf("{st_mode=%s, ", sprintmode(statbuf->st_mode)); |
| 776 | switch (statbuf->st_mode & S_IFMT) { |
| 777 | case S_IFCHR: case S_IFBLK: |
Roland McGrath | 6d2b349 | 2002-12-30 00:51:30 +0000 | [diff] [blame] | 778 | #ifdef HAVE_STRUCT_STAT_ST_RDEV |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 779 | tprintf("st_rdev=makedev(%lu, %lu), ", |
| 780 | (unsigned long) major(statbuf->st_rdev), |
| 781 | (unsigned long) minor(statbuf->st_rdev)); |
Roland McGrath | 6d2b349 | 2002-12-30 00:51:30 +0000 | [diff] [blame] | 782 | #else /* !HAVE_STRUCT_STAT_ST_RDEV */ |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 783 | tprintf("st_size=makedev(%lu, %lu), ", |
| 784 | (unsigned long) major(statbuf->st_size), |
| 785 | (unsigned long) minor(statbuf->st_size)); |
Roland McGrath | 6d2b349 | 2002-12-30 00:51:30 +0000 | [diff] [blame] | 786 | #endif /* !HAVE_STRUCT_STAT_ST_RDEV */ |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 787 | break; |
| 788 | default: |
Dmitry V. Levin | e9a06b7 | 2011-02-23 16:16:50 +0000 | [diff] [blame] | 789 | tprintf("st_size=%lu, ", (unsigned long) statbuf->st_size); |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 790 | break; |
| 791 | } |
| 792 | if (!abbrev(tcp)) { |
| 793 | tprintf("st_atime=%s, ", sprinttime(statbuf->st_atime)); |
| 794 | tprintf("st_mtime=%s, ", sprinttime(statbuf->st_mtime)); |
| 795 | tprintf("st_ctime=%s", sprinttime(statbuf->st_ctime)); |
Roland McGrath | 6d2b349 | 2002-12-30 00:51:30 +0000 | [diff] [blame] | 796 | #if HAVE_STRUCT_STAT_ST_FLAGS |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 797 | tprints(", st_flags="); |
Roland McGrath | b2dee13 | 2005-06-01 19:02:36 +0000 | [diff] [blame] | 798 | printflags(fileflags, statbuf->st_flags, "UF_???"); |
John Hughes | c0fc3fd | 2001-03-08 16:10:40 +0000 | [diff] [blame] | 799 | #endif |
Roland McGrath | 6d2b349 | 2002-12-30 00:51:30 +0000 | [diff] [blame] | 800 | #if HAVE_STRUCT_STAT_ST_ACLCNT |
John Hughes | c0fc3fd | 2001-03-08 16:10:40 +0000 | [diff] [blame] | 801 | tprintf(", st_aclcnt=%d", statbuf->st_aclcnt); |
| 802 | #endif |
Roland McGrath | 6d2b349 | 2002-12-30 00:51:30 +0000 | [diff] [blame] | 803 | #if HAVE_STRUCT_STAT_ST_LEVEL |
John Hughes | c0fc3fd | 2001-03-08 16:10:40 +0000 | [diff] [blame] | 804 | tprintf(", st_level=%ld", statbuf->st_level); |
| 805 | #endif |
Roland McGrath | 6d2b349 | 2002-12-30 00:51:30 +0000 | [diff] [blame] | 806 | #if HAVE_STRUCT_STAT_ST_FSTYPE |
John Hughes | c0fc3fd | 2001-03-08 16:10:40 +0000 | [diff] [blame] | 807 | tprintf(", st_fstype=%.*s", |
| 808 | (int) sizeof statbuf->st_fstype, statbuf->st_fstype); |
| 809 | #endif |
Roland McGrath | 6d2b349 | 2002-12-30 00:51:30 +0000 | [diff] [blame] | 810 | #if HAVE_STRUCT_STAT_ST_GEN |
John Hughes | c0fc3fd | 2001-03-08 16:10:40 +0000 | [diff] [blame] | 811 | tprintf(", st_gen=%u", statbuf->st_gen); |
| 812 | #endif |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 813 | tprints("}"); |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 814 | } |
| 815 | else |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 816 | tprints("...}"); |
Wichert Akkerman | 328c5e7 | 1999-04-16 00:21:26 +0000 | [diff] [blame] | 817 | } |
| 818 | |
Dmitry V. Levin | 0eeda2c | 2013-05-01 16:37:08 +0000 | [diff] [blame] | 819 | #ifndef X32 |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 820 | static void |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 821 | printstat(struct tcb *tcp, long addr) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 822 | { |
Wichert Akkerman | 328c5e7 | 1999-04-16 00:21:26 +0000 | [diff] [blame] | 823 | struct stat statbuf; |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 824 | |
Denys Vlasenko | 4e718b5 | 2009-04-20 18:30:13 +0000 | [diff] [blame] | 825 | if (!addr) { |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 826 | tprints("NULL"); |
Denys Vlasenko | 4e718b5 | 2009-04-20 18:30:13 +0000 | [diff] [blame] | 827 | return; |
| 828 | } |
| 829 | if (syserror(tcp) || !verbose(tcp)) { |
| 830 | tprintf("%#lx", addr); |
| 831 | return; |
| 832 | } |
| 833 | |
Denys Vlasenko | 9472a27 | 2013-02-12 11:43:46 +0100 | [diff] [blame] | 834 | #if defined(SPARC) || defined(SPARC64) |
Denys Vlasenko | 5ae2b7c | 2009-02-27 20:32:52 +0000 | [diff] [blame] | 835 | if (current_personality == 1) { |
| 836 | printstatsol(tcp, addr); |
| 837 | return; |
| 838 | } |
Roland McGrath | 6d1a65c | 2004-07-12 07:44:08 +0000 | [diff] [blame] | 839 | #ifdef SPARC64 |
| 840 | else if (current_personality == 2) { |
| 841 | printstat_sparc64(tcp, addr); |
| 842 | return; |
| 843 | } |
| 844 | #endif |
Denys Vlasenko | 9472a27 | 2013-02-12 11:43:46 +0100 | [diff] [blame] | 845 | #endif /* SPARC[64] */ |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 846 | |
Denys Vlasenko | 8470374 | 2012-02-25 02:38:52 +0100 | [diff] [blame] | 847 | #if defined POWERPC64 |
Andreas Schwab | d69fa49 | 2010-07-12 21:39:57 +0200 | [diff] [blame] | 848 | if (current_personality == 1) { |
| 849 | printstat_powerpc32(tcp, addr); |
| 850 | return; |
| 851 | } |
| 852 | #endif |
| 853 | |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 854 | if (umove(tcp, addr, &statbuf) < 0) { |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 855 | tprints("{...}"); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 856 | return; |
| 857 | } |
Wichert Akkerman | 328c5e7 | 1999-04-16 00:21:26 +0000 | [diff] [blame] | 858 | |
| 859 | realprintstat(tcp, &statbuf); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 860 | } |
Dmitry V. Levin | 0eeda2c | 2013-05-01 16:37:08 +0000 | [diff] [blame] | 861 | #else /* X32 */ |
| 862 | # define printstat printstat64 |
| 863 | #endif |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 864 | |
Elliott Hughes | 391c0d8 | 2014-04-03 17:50:14 -0700 | [diff] [blame] | 865 | #if !defined HAVE_STAT64 && (defined AARCH64 || defined X86_64) |
Roland McGrath | e6d0f71 | 2007-08-07 01:22:49 +0000 | [diff] [blame] | 866 | /* |
| 867 | * Linux x86_64 has unified `struct stat' but its i386 biarch needs |
| 868 | * `struct stat64'. Its <asm-i386/stat.h> definition expects 32-bit `long'. |
| 869 | * <linux/include/asm-x86_64/ia32.h> is not in the public includes set. |
| 870 | * __GNUC__ is needed for the required __attribute__ below. |
Elliott Hughes | 391c0d8 | 2014-04-03 17:50:14 -0700 | [diff] [blame] | 871 | * |
| 872 | * Similarly, aarch64 has a unified `struct stat' but its arm personality |
| 873 | * needs `struct stat64' (which also expects a 32-bit `long' but which |
| 874 | * shouldn't be packed). |
Roland McGrath | e6d0f71 | 2007-08-07 01:22:49 +0000 | [diff] [blame] | 875 | */ |
| 876 | struct stat64 { |
| 877 | unsigned long long st_dev; |
| 878 | unsigned char __pad0[4]; |
| 879 | unsigned int __st_ino; |
| 880 | unsigned int st_mode; |
| 881 | unsigned int st_nlink; |
| 882 | unsigned int st_uid; |
| 883 | unsigned int st_gid; |
| 884 | unsigned long long st_rdev; |
| 885 | unsigned char __pad3[4]; |
| 886 | long long st_size; |
| 887 | unsigned int st_blksize; |
| 888 | unsigned long long st_blocks; |
| 889 | unsigned int st_atime; |
| 890 | unsigned int st_atime_nsec; |
| 891 | unsigned int st_mtime; |
| 892 | unsigned int st_mtime_nsec; |
| 893 | unsigned int st_ctime; |
| 894 | unsigned int st_ctime_nsec; |
| 895 | unsigned long long st_ino; |
Elliott Hughes | 391c0d8 | 2014-04-03 17:50:14 -0700 | [diff] [blame] | 896 | } |
| 897 | # if defined X86_64 |
| 898 | __attribute__((packed)) |
| 899 | # define STAT64_SIZE 96 |
| 900 | #else |
| 901 | # define STAT64_SIZE 104 |
| 902 | # endif |
| 903 | ; |
Roland McGrath | e6d0f71 | 2007-08-07 01:22:49 +0000 | [diff] [blame] | 904 | # define HAVE_STAT64 1 |
Roland McGrath | e6d0f71 | 2007-08-07 01:22:49 +0000 | [diff] [blame] | 905 | #endif |
| 906 | |
Wichert Akkerman | c792698 | 2000-04-10 22:22:31 +0000 | [diff] [blame] | 907 | #ifdef HAVE_STAT64 |
Wichert Akkerman | 328c5e7 | 1999-04-16 00:21:26 +0000 | [diff] [blame] | 908 | static void |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 909 | printstat64(struct tcb *tcp, long addr) |
Ulrich Drepper | 7f02c4d | 1999-12-24 08:01:34 +0000 | [diff] [blame] | 910 | { |
Dmitry V. Levin | 0eeda2c | 2013-05-01 16:37:08 +0000 | [diff] [blame] | 911 | #ifdef X32 |
| 912 | struct stat statbuf; |
| 913 | #else |
Ulrich Drepper | 7f02c4d | 1999-12-24 08:01:34 +0000 | [diff] [blame] | 914 | struct stat64 statbuf; |
Dmitry V. Levin | 0eeda2c | 2013-05-01 16:37:08 +0000 | [diff] [blame] | 915 | #endif |
Ulrich Drepper | 7f02c4d | 1999-12-24 08:01:34 +0000 | [diff] [blame] | 916 | |
Denys Vlasenko | 4e718b5 | 2009-04-20 18:30:13 +0000 | [diff] [blame] | 917 | #ifdef STAT64_SIZE |
Roland McGrath | e6d0f71 | 2007-08-07 01:22:49 +0000 | [diff] [blame] | 918 | (void) sizeof(char[sizeof statbuf == STAT64_SIZE ? 1 : -1]); |
| 919 | #endif |
| 920 | |
Ulrich Drepper | 7f02c4d | 1999-12-24 08:01:34 +0000 | [diff] [blame] | 921 | if (!addr) { |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 922 | tprints("NULL"); |
Ulrich Drepper | 7f02c4d | 1999-12-24 08:01:34 +0000 | [diff] [blame] | 923 | return; |
| 924 | } |
| 925 | if (syserror(tcp) || !verbose(tcp)) { |
Wichert Akkerman | 8b1b40c | 2000-02-03 21:58:30 +0000 | [diff] [blame] | 926 | tprintf("%#lx", addr); |
Ulrich Drepper | 7f02c4d | 1999-12-24 08:01:34 +0000 | [diff] [blame] | 927 | return; |
| 928 | } |
Denys Vlasenko | 4e718b5 | 2009-04-20 18:30:13 +0000 | [diff] [blame] | 929 | |
Denys Vlasenko | 9472a27 | 2013-02-12 11:43:46 +0100 | [diff] [blame] | 930 | #if defined(SPARC) || defined(SPARC64) |
Denys Vlasenko | 4e718b5 | 2009-04-20 18:30:13 +0000 | [diff] [blame] | 931 | if (current_personality == 1) { |
| 932 | printstatsol(tcp, addr); |
| 933 | return; |
| 934 | } |
| 935 | # ifdef SPARC64 |
| 936 | else if (current_personality == 2) { |
| 937 | printstat_sparc64(tcp, addr); |
| 938 | return; |
| 939 | } |
| 940 | # endif |
Denys Vlasenko | 9472a27 | 2013-02-12 11:43:46 +0100 | [diff] [blame] | 941 | #endif /* SPARC[64] */ |
Denys Vlasenko | 4e718b5 | 2009-04-20 18:30:13 +0000 | [diff] [blame] | 942 | |
Elliott Hughes | 391c0d8 | 2014-04-03 17:50:14 -0700 | [diff] [blame] | 943 | #if defined AARCH64 |
| 944 | if (current_personality != 0) { |
| 945 | printstat(tcp, addr); |
| 946 | return; |
| 947 | } |
| 948 | #endif |
Denys Vlasenko | 8470374 | 2012-02-25 02:38:52 +0100 | [diff] [blame] | 949 | #if defined X86_64 |
H.J. Lu | 35be581 | 2012-04-16 13:00:01 +0200 | [diff] [blame] | 950 | if (current_personality != 1) { |
Andreas Schwab | 61b7435 | 2009-10-16 11:37:13 +0200 | [diff] [blame] | 951 | printstat(tcp, addr); |
| 952 | return; |
| 953 | } |
| 954 | #endif |
Dmitry V. Levin | ff896f7 | 2009-10-21 13:43:57 +0000 | [diff] [blame] | 955 | |
Ulrich Drepper | 7f02c4d | 1999-12-24 08:01:34 +0000 | [diff] [blame] | 956 | if (umove(tcp, addr, &statbuf) < 0) { |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 957 | tprints("{...}"); |
Ulrich Drepper | 7f02c4d | 1999-12-24 08:01:34 +0000 | [diff] [blame] | 958 | return; |
| 959 | } |
| 960 | |
| 961 | if (!abbrev(tcp)) { |
Wichert Akkerman | d077c45 | 2000-08-10 18:16:15 +0000 | [diff] [blame] | 962 | tprintf("{st_dev=makedev(%lu, %lu), st_ino=%llu, st_mode=%s, ", |
Ulrich Drepper | 7f02c4d | 1999-12-24 08:01:34 +0000 | [diff] [blame] | 963 | (unsigned long) major(statbuf.st_dev), |
| 964 | (unsigned long) minor(statbuf.st_dev), |
Wichert Akkerman | d077c45 | 2000-08-10 18:16:15 +0000 | [diff] [blame] | 965 | (unsigned long long) statbuf.st_ino, |
Ulrich Drepper | 7f02c4d | 1999-12-24 08:01:34 +0000 | [diff] [blame] | 966 | sprintmode(statbuf.st_mode)); |
| 967 | tprintf("st_nlink=%lu, st_uid=%lu, st_gid=%lu, ", |
| 968 | (unsigned long) statbuf.st_nlink, |
| 969 | (unsigned long) statbuf.st_uid, |
| 970 | (unsigned long) statbuf.st_gid); |
Roland McGrath | 6d2b349 | 2002-12-30 00:51:30 +0000 | [diff] [blame] | 971 | #ifdef HAVE_STRUCT_STAT_ST_BLKSIZE |
Ulrich Drepper | 7f02c4d | 1999-12-24 08:01:34 +0000 | [diff] [blame] | 972 | tprintf("st_blksize=%lu, ", |
| 973 | (unsigned long) statbuf.st_blksize); |
Roland McGrath | 6d2b349 | 2002-12-30 00:51:30 +0000 | [diff] [blame] | 974 | #endif /* HAVE_STRUCT_STAT_ST_BLKSIZE */ |
| 975 | #ifdef HAVE_STRUCT_STAT_ST_BLOCKS |
Ulrich Drepper | 7f02c4d | 1999-12-24 08:01:34 +0000 | [diff] [blame] | 976 | tprintf("st_blocks=%lu, ", (unsigned long) statbuf.st_blocks); |
Roland McGrath | 6d2b349 | 2002-12-30 00:51:30 +0000 | [diff] [blame] | 977 | #endif /* HAVE_STRUCT_STAT_ST_BLOCKS */ |
Ulrich Drepper | 7f02c4d | 1999-12-24 08:01:34 +0000 | [diff] [blame] | 978 | } |
| 979 | else |
| 980 | tprintf("{st_mode=%s, ", sprintmode(statbuf.st_mode)); |
| 981 | switch (statbuf.st_mode & S_IFMT) { |
| 982 | case S_IFCHR: case S_IFBLK: |
Roland McGrath | 6d2b349 | 2002-12-30 00:51:30 +0000 | [diff] [blame] | 983 | #ifdef HAVE_STRUCT_STAT_ST_RDEV |
Ulrich Drepper | 7f02c4d | 1999-12-24 08:01:34 +0000 | [diff] [blame] | 984 | tprintf("st_rdev=makedev(%lu, %lu), ", |
| 985 | (unsigned long) major(statbuf.st_rdev), |
| 986 | (unsigned long) minor(statbuf.st_rdev)); |
Roland McGrath | 6d2b349 | 2002-12-30 00:51:30 +0000 | [diff] [blame] | 987 | #else /* !HAVE_STRUCT_STAT_ST_RDEV */ |
Ulrich Drepper | 7f02c4d | 1999-12-24 08:01:34 +0000 | [diff] [blame] | 988 | tprintf("st_size=makedev(%lu, %lu), ", |
| 989 | (unsigned long) major(statbuf.st_size), |
| 990 | (unsigned long) minor(statbuf.st_size)); |
Roland McGrath | 6d2b349 | 2002-12-30 00:51:30 +0000 | [diff] [blame] | 991 | #endif /* !HAVE_STRUCT_STAT_ST_RDEV */ |
Ulrich Drepper | 7f02c4d | 1999-12-24 08:01:34 +0000 | [diff] [blame] | 992 | break; |
| 993 | default: |
Roland McGrath | c7bd4d3 | 2007-08-07 01:05:19 +0000 | [diff] [blame] | 994 | tprintf("st_size=%llu, ", (unsigned long long) statbuf.st_size); |
Ulrich Drepper | 7f02c4d | 1999-12-24 08:01:34 +0000 | [diff] [blame] | 995 | break; |
| 996 | } |
| 997 | if (!abbrev(tcp)) { |
| 998 | tprintf("st_atime=%s, ", sprinttime(statbuf.st_atime)); |
| 999 | tprintf("st_mtime=%s, ", sprinttime(statbuf.st_mtime)); |
John Hughes | c0fc3fd | 2001-03-08 16:10:40 +0000 | [diff] [blame] | 1000 | tprintf("st_ctime=%s", sprinttime(statbuf.st_ctime)); |
Roland McGrath | 6d2b349 | 2002-12-30 00:51:30 +0000 | [diff] [blame] | 1001 | #if HAVE_STRUCT_STAT_ST_FLAGS |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 1002 | tprints(", st_flags="); |
Roland McGrath | b2dee13 | 2005-06-01 19:02:36 +0000 | [diff] [blame] | 1003 | printflags(fileflags, statbuf.st_flags, "UF_???"); |
John Hughes | c0fc3fd | 2001-03-08 16:10:40 +0000 | [diff] [blame] | 1004 | #endif |
Roland McGrath | 6d2b349 | 2002-12-30 00:51:30 +0000 | [diff] [blame] | 1005 | #if HAVE_STRUCT_STAT_ST_ACLCNT |
John Hughes | c0fc3fd | 2001-03-08 16:10:40 +0000 | [diff] [blame] | 1006 | tprintf(", st_aclcnt=%d", statbuf.st_aclcnt); |
| 1007 | #endif |
Roland McGrath | 6d2b349 | 2002-12-30 00:51:30 +0000 | [diff] [blame] | 1008 | #if HAVE_STRUCT_STAT_ST_LEVEL |
John Hughes | c0fc3fd | 2001-03-08 16:10:40 +0000 | [diff] [blame] | 1009 | tprintf(", st_level=%ld", statbuf.st_level); |
| 1010 | #endif |
Roland McGrath | 6d2b349 | 2002-12-30 00:51:30 +0000 | [diff] [blame] | 1011 | #if HAVE_STRUCT_STAT_ST_FSTYPE |
John Hughes | c0fc3fd | 2001-03-08 16:10:40 +0000 | [diff] [blame] | 1012 | tprintf(", st_fstype=%.*s", |
| 1013 | (int) sizeof statbuf.st_fstype, statbuf.st_fstype); |
| 1014 | #endif |
Roland McGrath | 6d2b349 | 2002-12-30 00:51:30 +0000 | [diff] [blame] | 1015 | #if HAVE_STRUCT_STAT_ST_GEN |
John Hughes | c0fc3fd | 2001-03-08 16:10:40 +0000 | [diff] [blame] | 1016 | tprintf(", st_gen=%u", statbuf.st_gen); |
| 1017 | #endif |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 1018 | tprints("}"); |
Ulrich Drepper | 7f02c4d | 1999-12-24 08:01:34 +0000 | [diff] [blame] | 1019 | } |
| 1020 | else |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 1021 | tprints("...}"); |
Ulrich Drepper | 7f02c4d | 1999-12-24 08:01:34 +0000 | [diff] [blame] | 1022 | } |
Wichert Akkerman | c792698 | 2000-04-10 22:22:31 +0000 | [diff] [blame] | 1023 | #endif /* HAVE_STAT64 */ |
Ulrich Drepper | 7f02c4d | 1999-12-24 08:01:34 +0000 | [diff] [blame] | 1024 | |
Denys Vlasenko | 8435d67 | 2013-02-18 15:47:57 +0100 | [diff] [blame] | 1025 | #if defined(HAVE_STRUCT___OLD_KERNEL_STAT) |
Ulrich Drepper | 7f02c4d | 1999-12-24 08:01:34 +0000 | [diff] [blame] | 1026 | static void |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 1027 | convertoldstat(const struct __old_kernel_stat *oldbuf, struct stat *newbuf) |
Wichert Akkerman | 328c5e7 | 1999-04-16 00:21:26 +0000 | [diff] [blame] | 1028 | { |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 1029 | newbuf->st_dev = oldbuf->st_dev; |
| 1030 | newbuf->st_ino = oldbuf->st_ino; |
| 1031 | newbuf->st_mode = oldbuf->st_mode; |
| 1032 | newbuf->st_nlink = oldbuf->st_nlink; |
| 1033 | newbuf->st_uid = oldbuf->st_uid; |
| 1034 | newbuf->st_gid = oldbuf->st_gid; |
| 1035 | newbuf->st_rdev = oldbuf->st_rdev; |
| 1036 | newbuf->st_size = oldbuf->st_size; |
| 1037 | newbuf->st_atime = oldbuf->st_atime; |
| 1038 | newbuf->st_mtime = oldbuf->st_mtime; |
| 1039 | newbuf->st_ctime = oldbuf->st_ctime; |
| 1040 | newbuf->st_blksize = 0; /* not supported in old_stat */ |
| 1041 | newbuf->st_blocks = 0; /* not supported in old_stat */ |
Wichert Akkerman | 328c5e7 | 1999-04-16 00:21:26 +0000 | [diff] [blame] | 1042 | } |
Wichert Akkerman | 328c5e7 | 1999-04-16 00:21:26 +0000 | [diff] [blame] | 1043 | |
Wichert Akkerman | 328c5e7 | 1999-04-16 00:21:26 +0000 | [diff] [blame] | 1044 | static void |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 1045 | printoldstat(struct tcb *tcp, long addr) |
Wichert Akkerman | 328c5e7 | 1999-04-16 00:21:26 +0000 | [diff] [blame] | 1046 | { |
Wichert Akkerman | 25d0c4f | 1999-04-18 19:35:42 +0000 | [diff] [blame] | 1047 | struct __old_kernel_stat statbuf; |
| 1048 | struct stat newstatbuf; |
Wichert Akkerman | 328c5e7 | 1999-04-16 00:21:26 +0000 | [diff] [blame] | 1049 | |
Wichert Akkerman | 328c5e7 | 1999-04-16 00:21:26 +0000 | [diff] [blame] | 1050 | if (!addr) { |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 1051 | tprints("NULL"); |
Wichert Akkerman | 328c5e7 | 1999-04-16 00:21:26 +0000 | [diff] [blame] | 1052 | return; |
| 1053 | } |
| 1054 | if (syserror(tcp) || !verbose(tcp)) { |
Wichert Akkerman | 8b1b40c | 2000-02-03 21:58:30 +0000 | [diff] [blame] | 1055 | tprintf("%#lx", addr); |
Wichert Akkerman | 328c5e7 | 1999-04-16 00:21:26 +0000 | [diff] [blame] | 1056 | return; |
| 1057 | } |
Denys Vlasenko | 4e718b5 | 2009-04-20 18:30:13 +0000 | [diff] [blame] | 1058 | |
Denys Vlasenko | 9472a27 | 2013-02-12 11:43:46 +0100 | [diff] [blame] | 1059 | # if defined(SPARC) || defined(SPARC64) |
Denys Vlasenko | 4e718b5 | 2009-04-20 18:30:13 +0000 | [diff] [blame] | 1060 | if (current_personality == 1) { |
| 1061 | printstatsol(tcp, addr); |
| 1062 | return; |
| 1063 | } |
Denys Vlasenko | 8470374 | 2012-02-25 02:38:52 +0100 | [diff] [blame] | 1064 | # endif |
Denys Vlasenko | 4e718b5 | 2009-04-20 18:30:13 +0000 | [diff] [blame] | 1065 | |
Wichert Akkerman | 328c5e7 | 1999-04-16 00:21:26 +0000 | [diff] [blame] | 1066 | if (umove(tcp, addr, &statbuf) < 0) { |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 1067 | tprints("{...}"); |
Wichert Akkerman | 328c5e7 | 1999-04-16 00:21:26 +0000 | [diff] [blame] | 1068 | return; |
| 1069 | } |
| 1070 | |
| 1071 | convertoldstat(&statbuf, &newstatbuf); |
| 1072 | realprintstat(tcp, &newstatbuf); |
| 1073 | } |
Denys Vlasenko | 8470374 | 2012-02-25 02:38:52 +0100 | [diff] [blame] | 1074 | #endif |
Wichert Akkerman | 328c5e7 | 1999-04-16 00:21:26 +0000 | [diff] [blame] | 1075 | |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1076 | int |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 1077 | sys_stat(struct tcb *tcp) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1078 | { |
| 1079 | if (entering(tcp)) { |
| 1080 | printpath(tcp, tcp->u_arg[0]); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 1081 | tprints(", "); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1082 | } else { |
| 1083 | printstat(tcp, tcp->u_arg[1]); |
| 1084 | } |
| 1085 | return 0; |
| 1086 | } |
| 1087 | |
Dmitry V. Levin | 0eeda2c | 2013-05-01 16:37:08 +0000 | [diff] [blame] | 1088 | #ifdef X32 |
| 1089 | static void |
| 1090 | printstat64_x32(struct tcb *tcp, long addr) |
| 1091 | { |
| 1092 | struct stat64 statbuf; |
| 1093 | |
| 1094 | if (!addr) { |
| 1095 | tprints("NULL"); |
| 1096 | return; |
| 1097 | } |
| 1098 | if (syserror(tcp) || !verbose(tcp)) { |
| 1099 | tprintf("%#lx", addr); |
| 1100 | return; |
| 1101 | } |
| 1102 | |
| 1103 | if (umove(tcp, addr, &statbuf) < 0) { |
| 1104 | tprints("{...}"); |
| 1105 | return; |
| 1106 | } |
| 1107 | |
| 1108 | if (!abbrev(tcp)) { |
| 1109 | tprintf("{st_dev=makedev(%lu, %lu), st_ino=%llu, st_mode=%s, ", |
| 1110 | (unsigned long) major(statbuf.st_dev), |
| 1111 | (unsigned long) minor(statbuf.st_dev), |
| 1112 | (unsigned long long) statbuf.st_ino, |
| 1113 | sprintmode(statbuf.st_mode)); |
| 1114 | tprintf("st_nlink=%lu, st_uid=%lu, st_gid=%lu, ", |
| 1115 | (unsigned long) statbuf.st_nlink, |
| 1116 | (unsigned long) statbuf.st_uid, |
| 1117 | (unsigned long) statbuf.st_gid); |
| 1118 | tprintf("st_blksize=%lu, ", |
| 1119 | (unsigned long) statbuf.st_blksize); |
| 1120 | tprintf("st_blocks=%lu, ", (unsigned long) statbuf.st_blocks); |
| 1121 | } |
| 1122 | else |
| 1123 | tprintf("{st_mode=%s, ", sprintmode(statbuf.st_mode)); |
| 1124 | switch (statbuf.st_mode & S_IFMT) { |
| 1125 | case S_IFCHR: case S_IFBLK: |
| 1126 | tprintf("st_rdev=makedev(%lu, %lu), ", |
| 1127 | (unsigned long) major(statbuf.st_rdev), |
| 1128 | (unsigned long) minor(statbuf.st_rdev)); |
| 1129 | break; |
| 1130 | default: |
| 1131 | tprintf("st_size=%llu, ", (unsigned long long) statbuf.st_size); |
| 1132 | break; |
| 1133 | } |
| 1134 | if (!abbrev(tcp)) { |
| 1135 | tprintf("st_atime=%s, ", sprinttime(statbuf.st_atime)); |
| 1136 | tprintf("st_mtime=%s, ", sprinttime(statbuf.st_mtime)); |
| 1137 | tprintf("st_ctime=%s", sprinttime(statbuf.st_ctime)); |
| 1138 | tprints("}"); |
| 1139 | } |
| 1140 | else |
| 1141 | tprints("...}"); |
| 1142 | } |
| 1143 | #endif /* X32 */ |
| 1144 | |
Wichert Akkerman | 328c5e7 | 1999-04-16 00:21:26 +0000 | [diff] [blame] | 1145 | int |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 1146 | sys_stat64(struct tcb *tcp) |
Ulrich Drepper | 7f02c4d | 1999-12-24 08:01:34 +0000 | [diff] [blame] | 1147 | { |
| 1148 | #ifdef HAVE_STAT64 |
| 1149 | if (entering(tcp)) { |
| 1150 | printpath(tcp, tcp->u_arg[0]); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 1151 | tprints(", "); |
Ulrich Drepper | 7f02c4d | 1999-12-24 08:01:34 +0000 | [diff] [blame] | 1152 | } else { |
Dmitry V. Levin | 0eeda2c | 2013-05-01 16:37:08 +0000 | [diff] [blame] | 1153 | # ifdef X32 |
| 1154 | printstat64_x32(tcp, tcp->u_arg[1]); |
| 1155 | # else |
Ulrich Drepper | 7f02c4d | 1999-12-24 08:01:34 +0000 | [diff] [blame] | 1156 | printstat64(tcp, tcp->u_arg[1]); |
Dmitry V. Levin | 0eeda2c | 2013-05-01 16:37:08 +0000 | [diff] [blame] | 1157 | # endif |
Ulrich Drepper | 7f02c4d | 1999-12-24 08:01:34 +0000 | [diff] [blame] | 1158 | } |
| 1159 | return 0; |
| 1160 | #else |
| 1161 | return printargs(tcp); |
| 1162 | #endif |
| 1163 | } |
| 1164 | |
Dmitry V. Levin | 95ebf5a | 2006-10-13 20:25:12 +0000 | [diff] [blame] | 1165 | #ifndef AT_SYMLINK_NOFOLLOW |
Dmitry V. Levin | 7989ad4 | 2012-03-13 23:26:01 +0000 | [diff] [blame] | 1166 | # define AT_SYMLINK_NOFOLLOW 0x100 |
Dmitry V. Levin | 95ebf5a | 2006-10-13 20:25:12 +0000 | [diff] [blame] | 1167 | #endif |
Dmitry V. Levin | 7989ad4 | 2012-03-13 23:26:01 +0000 | [diff] [blame] | 1168 | #ifndef AT_REMOVEDIR |
| 1169 | # define AT_REMOVEDIR 0x200 |
| 1170 | #endif |
| 1171 | #ifndef AT_SYMLINK_FOLLOW |
| 1172 | # define AT_SYMLINK_FOLLOW 0x400 |
| 1173 | #endif |
| 1174 | #ifndef AT_NO_AUTOMOUNT |
| 1175 | # define AT_NO_AUTOMOUNT 0x800 |
| 1176 | #endif |
| 1177 | #ifndef AT_EMPTY_PATH |
| 1178 | # define AT_EMPTY_PATH 0x1000 |
| 1179 | #endif |
| 1180 | |
Dmitry V. Levin | 0ed617b | 2014-04-25 23:30:54 +0000 | [diff] [blame^] | 1181 | #include "xlat/at_flags.h" |
Dmitry V. Levin | 95ebf5a | 2006-10-13 20:25:12 +0000 | [diff] [blame] | 1182 | |
| 1183 | int |
| 1184 | sys_newfstatat(struct tcb *tcp) |
| 1185 | { |
| 1186 | if (entering(tcp)) { |
Dmitry V. Levin | 3138213 | 2011-03-04 05:08:02 +0300 | [diff] [blame] | 1187 | print_dirfd(tcp, tcp->u_arg[0]); |
Dmitry V. Levin | 95ebf5a | 2006-10-13 20:25:12 +0000 | [diff] [blame] | 1188 | printpath(tcp, tcp->u_arg[1]); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 1189 | tprints(", "); |
Dmitry V. Levin | 95ebf5a | 2006-10-13 20:25:12 +0000 | [diff] [blame] | 1190 | } else { |
Andreas Schwab | d69fa49 | 2010-07-12 21:39:57 +0200 | [diff] [blame] | 1191 | #ifdef POWERPC64 |
| 1192 | if (current_personality == 0) |
| 1193 | printstat(tcp, tcp->u_arg[2]); |
| 1194 | else |
| 1195 | printstat64(tcp, tcp->u_arg[2]); |
| 1196 | #elif defined HAVE_STAT64 |
Dmitry V. Levin | 95ebf5a | 2006-10-13 20:25:12 +0000 | [diff] [blame] | 1197 | printstat64(tcp, tcp->u_arg[2]); |
| 1198 | #else |
| 1199 | printstat(tcp, tcp->u_arg[2]); |
| 1200 | #endif |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 1201 | tprints(", "); |
Dmitry V. Levin | 7989ad4 | 2012-03-13 23:26:01 +0000 | [diff] [blame] | 1202 | printflags(at_flags, tcp->u_arg[3], "AT_???"); |
Dmitry V. Levin | 95ebf5a | 2006-10-13 20:25:12 +0000 | [diff] [blame] | 1203 | } |
| 1204 | return 0; |
| 1205 | } |
Dmitry V. Levin | 95ebf5a | 2006-10-13 20:25:12 +0000 | [diff] [blame] | 1206 | |
Denys Vlasenko | 8435d67 | 2013-02-18 15:47:57 +0100 | [diff] [blame] | 1207 | #if defined(HAVE_STRUCT___OLD_KERNEL_STAT) |
Ulrich Drepper | 7f02c4d | 1999-12-24 08:01:34 +0000 | [diff] [blame] | 1208 | int |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 1209 | sys_oldstat(struct tcb *tcp) |
Wichert Akkerman | 328c5e7 | 1999-04-16 00:21:26 +0000 | [diff] [blame] | 1210 | { |
| 1211 | if (entering(tcp)) { |
| 1212 | printpath(tcp, tcp->u_arg[0]); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 1213 | tprints(", "); |
Wichert Akkerman | 328c5e7 | 1999-04-16 00:21:26 +0000 | [diff] [blame] | 1214 | } else { |
| 1215 | printoldstat(tcp, tcp->u_arg[1]); |
| 1216 | } |
| 1217 | return 0; |
| 1218 | } |
Denys Vlasenko | 8470374 | 2012-02-25 02:38:52 +0100 | [diff] [blame] | 1219 | #endif |
Wichert Akkerman | 328c5e7 | 1999-04-16 00:21:26 +0000 | [diff] [blame] | 1220 | |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1221 | int |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 1222 | sys_fstat(struct tcb *tcp) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1223 | { |
Dmitry V. Levin | 3138213 | 2011-03-04 05:08:02 +0300 | [diff] [blame] | 1224 | if (entering(tcp)) { |
| 1225 | printfd(tcp, tcp->u_arg[0]); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 1226 | tprints(", "); |
Dmitry V. Levin | 3138213 | 2011-03-04 05:08:02 +0300 | [diff] [blame] | 1227 | } else { |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1228 | printstat(tcp, tcp->u_arg[1]); |
| 1229 | } |
| 1230 | return 0; |
| 1231 | } |
| 1232 | |
Wichert Akkerman | 328c5e7 | 1999-04-16 00:21:26 +0000 | [diff] [blame] | 1233 | int |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 1234 | sys_fstat64(struct tcb *tcp) |
Ulrich Drepper | 7f02c4d | 1999-12-24 08:01:34 +0000 | [diff] [blame] | 1235 | { |
| 1236 | #ifdef HAVE_STAT64 |
Dmitry V. Levin | 3138213 | 2011-03-04 05:08:02 +0300 | [diff] [blame] | 1237 | if (entering(tcp)) { |
| 1238 | printfd(tcp, tcp->u_arg[0]); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 1239 | tprints(", "); |
Dmitry V. Levin | 3138213 | 2011-03-04 05:08:02 +0300 | [diff] [blame] | 1240 | } else { |
Dmitry V. Levin | 0eeda2c | 2013-05-01 16:37:08 +0000 | [diff] [blame] | 1241 | # ifdef X32 |
| 1242 | printstat64_x32(tcp, tcp->u_arg[1]); |
| 1243 | # else |
Ulrich Drepper | 7f02c4d | 1999-12-24 08:01:34 +0000 | [diff] [blame] | 1244 | printstat64(tcp, tcp->u_arg[1]); |
Dmitry V. Levin | 0eeda2c | 2013-05-01 16:37:08 +0000 | [diff] [blame] | 1245 | # endif |
Ulrich Drepper | 7f02c4d | 1999-12-24 08:01:34 +0000 | [diff] [blame] | 1246 | } |
| 1247 | return 0; |
| 1248 | #else |
| 1249 | return printargs(tcp); |
| 1250 | #endif |
| 1251 | } |
| 1252 | |
Denys Vlasenko | 8435d67 | 2013-02-18 15:47:57 +0100 | [diff] [blame] | 1253 | #if defined(HAVE_STRUCT___OLD_KERNEL_STAT) |
Ulrich Drepper | 7f02c4d | 1999-12-24 08:01:34 +0000 | [diff] [blame] | 1254 | int |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 1255 | sys_oldfstat(struct tcb *tcp) |
Wichert Akkerman | 328c5e7 | 1999-04-16 00:21:26 +0000 | [diff] [blame] | 1256 | { |
Dmitry V. Levin | 3138213 | 2011-03-04 05:08:02 +0300 | [diff] [blame] | 1257 | if (entering(tcp)) { |
| 1258 | printfd(tcp, tcp->u_arg[0]); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 1259 | tprints(", "); |
Dmitry V. Levin | 3138213 | 2011-03-04 05:08:02 +0300 | [diff] [blame] | 1260 | } else { |
Wichert Akkerman | 328c5e7 | 1999-04-16 00:21:26 +0000 | [diff] [blame] | 1261 | printoldstat(tcp, tcp->u_arg[1]); |
| 1262 | } |
| 1263 | return 0; |
| 1264 | } |
Denys Vlasenko | 8470374 | 2012-02-25 02:38:52 +0100 | [diff] [blame] | 1265 | #endif |
Wichert Akkerman | 328c5e7 | 1999-04-16 00:21:26 +0000 | [diff] [blame] | 1266 | |
Denys Vlasenko | 9472a27 | 2013-02-12 11:43:46 +0100 | [diff] [blame] | 1267 | #if defined(SPARC) || defined(SPARC64) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1268 | |
| 1269 | int |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 1270 | sys_xstat(struct tcb *tcp) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1271 | { |
| 1272 | if (entering(tcp)) { |
| 1273 | tprintf("%ld, ", tcp->u_arg[0]); |
| 1274 | printpath(tcp, tcp->u_arg[1]); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 1275 | tprints(", "); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1276 | } else { |
Denys Vlasenko | 8470374 | 2012-02-25 02:38:52 +0100 | [diff] [blame] | 1277 | # ifdef _STAT64_VER |
John Hughes | 8fe2c98 | 2001-03-06 09:45:18 +0000 | [diff] [blame] | 1278 | if (tcp->u_arg[0] == _STAT64_VER) |
Denys Vlasenko | b237b1b | 2012-02-27 13:56:59 +0100 | [diff] [blame] | 1279 | printstat64(tcp, tcp->u_arg[2]); |
John Hughes | 8fe2c98 | 2001-03-06 09:45:18 +0000 | [diff] [blame] | 1280 | else |
Denys Vlasenko | 8470374 | 2012-02-25 02:38:52 +0100 | [diff] [blame] | 1281 | # endif |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1282 | printstat(tcp, tcp->u_arg[2]); |
| 1283 | } |
| 1284 | return 0; |
| 1285 | } |
| 1286 | |
| 1287 | int |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 1288 | sys_fxstat(struct tcb *tcp) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1289 | { |
| 1290 | if (entering(tcp)) |
| 1291 | tprintf("%ld, %ld, ", tcp->u_arg[0], tcp->u_arg[1]); |
| 1292 | else { |
Denys Vlasenko | 8470374 | 2012-02-25 02:38:52 +0100 | [diff] [blame] | 1293 | # ifdef _STAT64_VER |
John Hughes | 8fe2c98 | 2001-03-06 09:45:18 +0000 | [diff] [blame] | 1294 | if (tcp->u_arg[0] == _STAT64_VER) |
Denys Vlasenko | b237b1b | 2012-02-27 13:56:59 +0100 | [diff] [blame] | 1295 | printstat64(tcp, tcp->u_arg[2]); |
John Hughes | 8fe2c98 | 2001-03-06 09:45:18 +0000 | [diff] [blame] | 1296 | else |
Denys Vlasenko | 8470374 | 2012-02-25 02:38:52 +0100 | [diff] [blame] | 1297 | # endif |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1298 | printstat(tcp, tcp->u_arg[2]); |
| 1299 | } |
| 1300 | return 0; |
| 1301 | } |
| 1302 | |
| 1303 | int |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 1304 | sys_lxstat(struct tcb *tcp) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1305 | { |
| 1306 | if (entering(tcp)) { |
| 1307 | tprintf("%ld, ", tcp->u_arg[0]); |
| 1308 | printpath(tcp, tcp->u_arg[1]); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 1309 | tprints(", "); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1310 | } else { |
Denys Vlasenko | 8470374 | 2012-02-25 02:38:52 +0100 | [diff] [blame] | 1311 | # ifdef _STAT64_VER |
John Hughes | 8fe2c98 | 2001-03-06 09:45:18 +0000 | [diff] [blame] | 1312 | if (tcp->u_arg[0] == _STAT64_VER) |
Denys Vlasenko | b237b1b | 2012-02-27 13:56:59 +0100 | [diff] [blame] | 1313 | printstat64(tcp, tcp->u_arg[2]); |
John Hughes | 8fe2c98 | 2001-03-06 09:45:18 +0000 | [diff] [blame] | 1314 | else |
Denys Vlasenko | 8470374 | 2012-02-25 02:38:52 +0100 | [diff] [blame] | 1315 | # endif |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1316 | printstat(tcp, tcp->u_arg[2]); |
| 1317 | } |
| 1318 | return 0; |
| 1319 | } |
| 1320 | |
| 1321 | int |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 1322 | sys_xmknod(struct tcb *tcp) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1323 | { |
| 1324 | int mode = tcp->u_arg[2]; |
| 1325 | |
| 1326 | if (entering(tcp)) { |
| 1327 | tprintf("%ld, ", tcp->u_arg[0]); |
| 1328 | printpath(tcp, tcp->u_arg[1]); |
| 1329 | tprintf(", %s", sprintmode(mode)); |
| 1330 | switch (mode & S_IFMT) { |
| 1331 | case S_IFCHR: case S_IFBLK: |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1332 | tprintf(", makedev(%lu, %lu)", |
| 1333 | (unsigned long) ((tcp->u_arg[3] >> 18) & 0x3fff), |
| 1334 | (unsigned long) (tcp->u_arg[3] & 0x3ffff)); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1335 | break; |
| 1336 | default: |
| 1337 | break; |
| 1338 | } |
| 1339 | } |
| 1340 | return 0; |
| 1341 | } |
| 1342 | |
Denys Vlasenko | 8470374 | 2012-02-25 02:38:52 +0100 | [diff] [blame] | 1343 | # ifdef HAVE_SYS_ACL_H |
Wichert Akkerman | 8829a55 | 1999-06-11 13:18:40 +0000 | [diff] [blame] | 1344 | |
Denys Vlasenko | 8470374 | 2012-02-25 02:38:52 +0100 | [diff] [blame] | 1345 | # include <sys/acl.h> |
Wichert Akkerman | 8829a55 | 1999-06-11 13:18:40 +0000 | [diff] [blame] | 1346 | |
Dmitry V. Levin | 0ed617b | 2014-04-25 23:30:54 +0000 | [diff] [blame^] | 1347 | #include "xlat/aclcmds.h" |
Wichert Akkerman | 8829a55 | 1999-06-11 13:18:40 +0000 | [diff] [blame] | 1348 | |
| 1349 | int |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 1350 | sys_acl(struct tcb *tcp) |
Wichert Akkerman | 8829a55 | 1999-06-11 13:18:40 +0000 | [diff] [blame] | 1351 | { |
| 1352 | if (entering(tcp)) { |
| 1353 | printpath(tcp, tcp->u_arg[0]); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 1354 | tprints(", "); |
Wichert Akkerman | 8829a55 | 1999-06-11 13:18:40 +0000 | [diff] [blame] | 1355 | printxval(aclcmds, tcp->u_arg[1], "???ACL???"); |
| 1356 | tprintf(", %ld", tcp->u_arg[2]); |
| 1357 | /* |
| 1358 | * FIXME - dump out the list of aclent_t's pointed to |
| 1359 | * by "tcp->u_arg[3]" if it's not NULL. |
| 1360 | */ |
| 1361 | if (tcp->u_arg[3]) |
| 1362 | tprintf(", %#lx", tcp->u_arg[3]); |
| 1363 | else |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 1364 | tprints(", NULL"); |
Wichert Akkerman | 8829a55 | 1999-06-11 13:18:40 +0000 | [diff] [blame] | 1365 | } |
| 1366 | return 0; |
| 1367 | } |
| 1368 | |
Wichert Akkerman | 8829a55 | 1999-06-11 13:18:40 +0000 | [diff] [blame] | 1369 | int |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 1370 | sys_facl(struct tcb *tcp) |
Wichert Akkerman | 8829a55 | 1999-06-11 13:18:40 +0000 | [diff] [blame] | 1371 | { |
| 1372 | if (entering(tcp)) { |
| 1373 | tprintf("%ld, ", tcp->u_arg[0]); |
| 1374 | printxval(aclcmds, tcp->u_arg[1], "???ACL???"); |
| 1375 | tprintf(", %ld", tcp->u_arg[2]); |
| 1376 | /* |
| 1377 | * FIXME - dump out the list of aclent_t's pointed to |
| 1378 | * by "tcp->u_arg[3]" if it's not NULL. |
| 1379 | */ |
| 1380 | if (tcp->u_arg[3]) |
| 1381 | tprintf(", %#lx", tcp->u_arg[3]); |
| 1382 | else |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 1383 | tprints(", NULL"); |
Wichert Akkerman | 8829a55 | 1999-06-11 13:18:40 +0000 | [diff] [blame] | 1384 | } |
| 1385 | return 0; |
| 1386 | } |
| 1387 | |
Dmitry V. Levin | 0ed617b | 2014-04-25 23:30:54 +0000 | [diff] [blame^] | 1388 | #include "xlat/aclipc.h" |
Wichert Akkerman | e4aafd4 | 1999-11-26 09:54:08 +0000 | [diff] [blame] | 1389 | |
Wichert Akkerman | e4aafd4 | 1999-11-26 09:54:08 +0000 | [diff] [blame] | 1390 | int |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 1391 | sys_aclipc(struct tcb *tcp) |
Wichert Akkerman | e4aafd4 | 1999-11-26 09:54:08 +0000 | [diff] [blame] | 1392 | { |
| 1393 | if (entering(tcp)) { |
| 1394 | printxval(aclipc, tcp->u_arg[0], "???IPC???"); |
| 1395 | tprintf(", %#lx, ", tcp->u_arg[1]); |
| 1396 | printxval(aclcmds, tcp->u_arg[2], "???ACL???"); |
| 1397 | tprintf(", %ld", tcp->u_arg[3]); |
| 1398 | /* |
| 1399 | * FIXME - dump out the list of aclent_t's pointed to |
| 1400 | * by "tcp->u_arg[4]" if it's not NULL. |
| 1401 | */ |
| 1402 | if (tcp->u_arg[4]) |
| 1403 | tprintf(", %#lx", tcp->u_arg[4]); |
| 1404 | else |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 1405 | tprints(", NULL"); |
Wichert Akkerman | e4aafd4 | 1999-11-26 09:54:08 +0000 | [diff] [blame] | 1406 | } |
| 1407 | return 0; |
| 1408 | } |
| 1409 | |
Denys Vlasenko | 8470374 | 2012-02-25 02:38:52 +0100 | [diff] [blame] | 1410 | # endif /* HAVE_SYS_ACL_H */ |
Wichert Akkerman | 8829a55 | 1999-06-11 13:18:40 +0000 | [diff] [blame] | 1411 | |
Denys Vlasenko | 9472a27 | 2013-02-12 11:43:46 +0100 | [diff] [blame] | 1412 | #endif /* SPARC[64] */ |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1413 | |
Dmitry V. Levin | 0ed617b | 2014-04-25 23:30:54 +0000 | [diff] [blame^] | 1414 | #include "xlat/fsmagic.h" |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1415 | |
Roland McGrath | f9c49b2 | 2004-10-06 22:11:54 +0000 | [diff] [blame] | 1416 | static const char * |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 1417 | sprintfstype(int magic) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1418 | { |
| 1419 | static char buf[32]; |
Roland McGrath | f9c49b2 | 2004-10-06 22:11:54 +0000 | [diff] [blame] | 1420 | const char *s; |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1421 | |
| 1422 | s = xlookup(fsmagic, magic); |
| 1423 | if (s) { |
| 1424 | sprintf(buf, "\"%s\"", s); |
| 1425 | return buf; |
| 1426 | } |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1427 | sprintf(buf, "%#x", magic); |
| 1428 | return buf; |
| 1429 | } |
| 1430 | |
| 1431 | static void |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 1432 | printstatfs(struct tcb *tcp, long addr) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1433 | { |
| 1434 | struct statfs statbuf; |
| 1435 | |
| 1436 | if (syserror(tcp) || !verbose(tcp)) { |
| 1437 | tprintf("%#lx", addr); |
| 1438 | return; |
| 1439 | } |
| 1440 | if (umove(tcp, addr, &statbuf) < 0) { |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 1441 | tprints("{...}"); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1442 | return; |
| 1443 | } |
| 1444 | #ifdef ALPHA |
| 1445 | |
| 1446 | tprintf("{f_type=%s, f_fbsize=%u, f_blocks=%u, f_bfree=%u, ", |
| 1447 | sprintfstype(statbuf.f_type), |
| 1448 | statbuf.f_bsize, statbuf.f_blocks, statbuf.f_bfree); |
Roland McGrath | ab147c5 | 2003-07-17 09:03:02 +0000 | [diff] [blame] | 1449 | tprintf("f_bavail=%u, f_files=%u, f_ffree=%u, f_fsid={%d, %d}, f_namelen=%u", |
Denys Vlasenko | b63256e | 2011-06-07 12:13:24 +0200 | [diff] [blame] | 1450 | statbuf.f_bavail, statbuf.f_files, statbuf.f_ffree, |
Roland McGrath | ab147c5 | 2003-07-17 09:03:02 +0000 | [diff] [blame] | 1451 | statbuf.f_fsid.__val[0], statbuf.f_fsid.__val[1], |
| 1452 | statbuf.f_namelen); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1453 | #else /* !ALPHA */ |
| 1454 | tprintf("{f_type=%s, f_bsize=%lu, f_blocks=%lu, f_bfree=%lu, ", |
| 1455 | sprintfstype(statbuf.f_type), |
Nate Sammons | 5c74d20 | 1999-04-06 01:37:51 +0000 | [diff] [blame] | 1456 | (unsigned long)statbuf.f_bsize, |
| 1457 | (unsigned long)statbuf.f_blocks, |
| 1458 | (unsigned long)statbuf.f_bfree); |
Roland McGrath | ab147c5 | 2003-07-17 09:03:02 +0000 | [diff] [blame] | 1459 | tprintf("f_bavail=%lu, f_files=%lu, f_ffree=%lu, f_fsid={%d, %d}", |
| 1460 | (unsigned long)statbuf.f_bavail, |
Nate Sammons | 5c74d20 | 1999-04-06 01:37:51 +0000 | [diff] [blame] | 1461 | (unsigned long)statbuf.f_files, |
Roland McGrath | ab147c5 | 2003-07-17 09:03:02 +0000 | [diff] [blame] | 1462 | (unsigned long)statbuf.f_ffree, |
| 1463 | statbuf.f_fsid.__val[0], statbuf.f_fsid.__val[1]); |
Wichert Akkerman | 2e2553a | 1999-05-09 00:29:58 +0000 | [diff] [blame] | 1464 | tprintf(", f_namelen=%lu", (unsigned long)statbuf.f_namelen); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1465 | #endif /* !ALPHA */ |
Roland McGrath | ab147c5 | 2003-07-17 09:03:02 +0000 | [diff] [blame] | 1466 | #ifdef _STATFS_F_FRSIZE |
| 1467 | tprintf(", f_frsize=%lu", (unsigned long)statbuf.f_frsize); |
| 1468 | #endif |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 1469 | tprints("}"); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1470 | } |
| 1471 | |
| 1472 | int |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 1473 | sys_statfs(struct tcb *tcp) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1474 | { |
| 1475 | if (entering(tcp)) { |
| 1476 | printpath(tcp, tcp->u_arg[0]); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 1477 | tprints(", "); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1478 | } else { |
| 1479 | printstatfs(tcp, tcp->u_arg[1]); |
| 1480 | } |
| 1481 | return 0; |
| 1482 | } |
| 1483 | |
| 1484 | int |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 1485 | sys_fstatfs(struct tcb *tcp) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1486 | { |
| 1487 | if (entering(tcp)) { |
Dmitry V. Levin | 3138213 | 2011-03-04 05:08:02 +0300 | [diff] [blame] | 1488 | printfd(tcp, tcp->u_arg[0]); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 1489 | tprints(", "); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1490 | } else { |
| 1491 | printstatfs(tcp, tcp->u_arg[1]); |
| 1492 | } |
| 1493 | return 0; |
| 1494 | } |
| 1495 | |
Denys Vlasenko | 8470374 | 2012-02-25 02:38:52 +0100 | [diff] [blame] | 1496 | #if defined HAVE_STATFS64 |
Roland McGrath | ab147c5 | 2003-07-17 09:03:02 +0000 | [diff] [blame] | 1497 | static void |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 1498 | printstatfs64(struct tcb *tcp, long addr) |
Roland McGrath | ab147c5 | 2003-07-17 09:03:02 +0000 | [diff] [blame] | 1499 | { |
| 1500 | struct statfs64 statbuf; |
| 1501 | |
| 1502 | if (syserror(tcp) || !verbose(tcp)) { |
| 1503 | tprintf("%#lx", addr); |
| 1504 | return; |
| 1505 | } |
| 1506 | if (umove(tcp, addr, &statbuf) < 0) { |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 1507 | tprints("{...}"); |
Roland McGrath | ab147c5 | 2003-07-17 09:03:02 +0000 | [diff] [blame] | 1508 | return; |
| 1509 | } |
Roland McGrath | 0873843 | 2005-06-03 02:40:39 +0000 | [diff] [blame] | 1510 | tprintf("{f_type=%s, f_bsize=%llu, f_blocks=%llu, f_bfree=%llu, ", |
Roland McGrath | ab147c5 | 2003-07-17 09:03:02 +0000 | [diff] [blame] | 1511 | sprintfstype(statbuf.f_type), |
Roland McGrath | 0873843 | 2005-06-03 02:40:39 +0000 | [diff] [blame] | 1512 | (unsigned long long)statbuf.f_bsize, |
| 1513 | (unsigned long long)statbuf.f_blocks, |
| 1514 | (unsigned long long)statbuf.f_bfree); |
| 1515 | tprintf("f_bavail=%llu, f_files=%llu, f_ffree=%llu, f_fsid={%d, %d}", |
| 1516 | (unsigned long long)statbuf.f_bavail, |
| 1517 | (unsigned long long)statbuf.f_files, |
| 1518 | (unsigned long long)statbuf.f_ffree, |
Roland McGrath | ab147c5 | 2003-07-17 09:03:02 +0000 | [diff] [blame] | 1519 | statbuf.f_fsid.__val[0], statbuf.f_fsid.__val[1]); |
| 1520 | tprintf(", f_namelen=%lu", (unsigned long)statbuf.f_namelen); |
Roland McGrath | ab147c5 | 2003-07-17 09:03:02 +0000 | [diff] [blame] | 1521 | #ifdef _STATFS_F_FRSIZE |
Roland McGrath | 0873843 | 2005-06-03 02:40:39 +0000 | [diff] [blame] | 1522 | tprintf(", f_frsize=%llu", (unsigned long long)statbuf.f_frsize); |
Roland McGrath | ab147c5 | 2003-07-17 09:03:02 +0000 | [diff] [blame] | 1523 | #endif |
Andreas Schwab | 000d66f | 2012-01-17 18:13:33 +0100 | [diff] [blame] | 1524 | #ifdef _STATFS_F_FLAGS |
| 1525 | tprintf(", f_flags=%llu", (unsigned long long)statbuf.f_flags); |
| 1526 | #endif |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 1527 | tprints("}"); |
Roland McGrath | ab147c5 | 2003-07-17 09:03:02 +0000 | [diff] [blame] | 1528 | } |
| 1529 | |
Andreas Schwab | 7d55801 | 2012-01-17 18:14:22 +0100 | [diff] [blame] | 1530 | struct compat_statfs64 { |
| 1531 | uint32_t f_type; |
| 1532 | uint32_t f_bsize; |
| 1533 | uint64_t f_blocks; |
| 1534 | uint64_t f_bfree; |
| 1535 | uint64_t f_bavail; |
| 1536 | uint64_t f_files; |
| 1537 | uint64_t f_ffree; |
| 1538 | fsid_t f_fsid; |
| 1539 | uint32_t f_namelen; |
| 1540 | uint32_t f_frsize; |
| 1541 | uint32_t f_flags; |
| 1542 | uint32_t f_spare[4]; |
| 1543 | } |
| 1544 | #if defined(X86_64) || defined(IA64) |
| 1545 | __attribute__ ((packed, aligned(4))) |
| 1546 | #endif |
| 1547 | ; |
| 1548 | |
| 1549 | static void |
| 1550 | printcompat_statfs64(struct tcb *tcp, long addr) |
| 1551 | { |
| 1552 | struct compat_statfs64 statbuf; |
| 1553 | |
| 1554 | if (syserror(tcp) || !verbose(tcp)) { |
| 1555 | tprintf("%#lx", addr); |
| 1556 | return; |
| 1557 | } |
| 1558 | if (umove(tcp, addr, &statbuf) < 0) { |
| 1559 | tprints("{...}"); |
| 1560 | return; |
| 1561 | } |
| 1562 | tprintf("{f_type=%s, f_bsize=%lu, f_blocks=%llu, f_bfree=%llu, ", |
| 1563 | sprintfstype(statbuf.f_type), |
| 1564 | (unsigned long)statbuf.f_bsize, |
| 1565 | (unsigned long long)statbuf.f_blocks, |
| 1566 | (unsigned long long)statbuf.f_bfree); |
| 1567 | tprintf("f_bavail=%llu, f_files=%llu, f_ffree=%llu, f_fsid={%d, %d}", |
| 1568 | (unsigned long long)statbuf.f_bavail, |
| 1569 | (unsigned long long)statbuf.f_files, |
| 1570 | (unsigned long long)statbuf.f_ffree, |
| 1571 | statbuf.f_fsid.__val[0], statbuf.f_fsid.__val[1]); |
| 1572 | tprintf(", f_namelen=%lu", (unsigned long)statbuf.f_namelen); |
| 1573 | tprintf(", f_frsize=%lu", (unsigned long)statbuf.f_frsize); |
Denys Vlasenko | 1945ccc | 2012-02-27 14:37:48 +0100 | [diff] [blame] | 1574 | tprintf(", f_flags=%lu}", (unsigned long)statbuf.f_frsize); |
Andreas Schwab | 7d55801 | 2012-01-17 18:14:22 +0100 | [diff] [blame] | 1575 | } |
| 1576 | |
Roland McGrath | ab147c5 | 2003-07-17 09:03:02 +0000 | [diff] [blame] | 1577 | int |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 1578 | sys_statfs64(struct tcb *tcp) |
Roland McGrath | ab147c5 | 2003-07-17 09:03:02 +0000 | [diff] [blame] | 1579 | { |
| 1580 | if (entering(tcp)) { |
| 1581 | printpath(tcp, tcp->u_arg[0]); |
| 1582 | tprintf(", %lu, ", tcp->u_arg[1]); |
| 1583 | } else { |
Denys Vlasenko | b63256e | 2011-06-07 12:13:24 +0200 | [diff] [blame] | 1584 | if (tcp->u_arg[1] == sizeof(struct statfs64)) |
Roland McGrath | ab147c5 | 2003-07-17 09:03:02 +0000 | [diff] [blame] | 1585 | printstatfs64(tcp, tcp->u_arg[2]); |
Andreas Schwab | 7d55801 | 2012-01-17 18:14:22 +0100 | [diff] [blame] | 1586 | else if (tcp->u_arg[1] == sizeof(struct compat_statfs64)) |
| 1587 | printcompat_statfs64(tcp, tcp->u_arg[2]); |
Roland McGrath | ab147c5 | 2003-07-17 09:03:02 +0000 | [diff] [blame] | 1588 | else |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 1589 | tprints("{???}"); |
Roland McGrath | ab147c5 | 2003-07-17 09:03:02 +0000 | [diff] [blame] | 1590 | } |
| 1591 | return 0; |
| 1592 | } |
| 1593 | |
| 1594 | int |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 1595 | sys_fstatfs64(struct tcb *tcp) |
Roland McGrath | ab147c5 | 2003-07-17 09:03:02 +0000 | [diff] [blame] | 1596 | { |
| 1597 | if (entering(tcp)) { |
Dmitry V. Levin | 3138213 | 2011-03-04 05:08:02 +0300 | [diff] [blame] | 1598 | printfd(tcp, tcp->u_arg[0]); |
| 1599 | tprintf(", %lu, ", tcp->u_arg[1]); |
Roland McGrath | ab147c5 | 2003-07-17 09:03:02 +0000 | [diff] [blame] | 1600 | } else { |
Denys Vlasenko | b63256e | 2011-06-07 12:13:24 +0200 | [diff] [blame] | 1601 | if (tcp->u_arg[1] == sizeof(struct statfs64)) |
Roland McGrath | ab147c5 | 2003-07-17 09:03:02 +0000 | [diff] [blame] | 1602 | printstatfs64(tcp, tcp->u_arg[2]); |
Andreas Schwab | 7d55801 | 2012-01-17 18:14:22 +0100 | [diff] [blame] | 1603 | else if (tcp->u_arg[1] == sizeof(struct compat_statfs64)) |
| 1604 | printcompat_statfs64(tcp, tcp->u_arg[2]); |
Roland McGrath | ab147c5 | 2003-07-17 09:03:02 +0000 | [diff] [blame] | 1605 | else |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 1606 | tprints("{???}"); |
Roland McGrath | ab147c5 | 2003-07-17 09:03:02 +0000 | [diff] [blame] | 1607 | } |
| 1608 | return 0; |
| 1609 | } |
| 1610 | #endif |
| 1611 | |
Denys Vlasenko | c36c352 | 2012-02-25 02:47:15 +0100 | [diff] [blame] | 1612 | #if defined(ALPHA) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1613 | int |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 1614 | osf_statfs(struct tcb *tcp) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1615 | { |
| 1616 | if (entering(tcp)) { |
| 1617 | printpath(tcp, tcp->u_arg[0]); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 1618 | tprints(", "); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1619 | } else { |
| 1620 | printstatfs(tcp, tcp->u_arg[1]); |
| 1621 | tprintf(", %lu", tcp->u_arg[2]); |
| 1622 | } |
| 1623 | return 0; |
| 1624 | } |
| 1625 | |
| 1626 | int |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 1627 | osf_fstatfs(struct tcb *tcp) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1628 | { |
| 1629 | if (entering(tcp)) { |
| 1630 | tprintf("%lu, ", tcp->u_arg[0]); |
| 1631 | } else { |
| 1632 | printstatfs(tcp, tcp->u_arg[1]); |
| 1633 | tprintf(", %lu", tcp->u_arg[2]); |
| 1634 | } |
| 1635 | return 0; |
| 1636 | } |
Denys Vlasenko | 8470374 | 2012-02-25 02:38:52 +0100 | [diff] [blame] | 1637 | #endif |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1638 | |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1639 | /* directory */ |
| 1640 | int |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 1641 | sys_chdir(struct tcb *tcp) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1642 | { |
| 1643 | if (entering(tcp)) { |
| 1644 | printpath(tcp, tcp->u_arg[0]); |
| 1645 | } |
| 1646 | return 0; |
| 1647 | } |
| 1648 | |
Dmitry V. Levin | 95ebf5a | 2006-10-13 20:25:12 +0000 | [diff] [blame] | 1649 | static int |
| 1650 | decode_mkdir(struct tcb *tcp, int offset) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1651 | { |
| 1652 | if (entering(tcp)) { |
Dmitry V. Levin | 95ebf5a | 2006-10-13 20:25:12 +0000 | [diff] [blame] | 1653 | printpath(tcp, tcp->u_arg[offset]); |
| 1654 | tprintf(", %#lo", tcp->u_arg[offset + 1]); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1655 | } |
| 1656 | return 0; |
| 1657 | } |
| 1658 | |
| 1659 | int |
Dmitry V. Levin | 95ebf5a | 2006-10-13 20:25:12 +0000 | [diff] [blame] | 1660 | sys_mkdir(struct tcb *tcp) |
| 1661 | { |
| 1662 | return decode_mkdir(tcp, 0); |
| 1663 | } |
| 1664 | |
Dmitry V. Levin | 95ebf5a | 2006-10-13 20:25:12 +0000 | [diff] [blame] | 1665 | int |
| 1666 | sys_mkdirat(struct tcb *tcp) |
| 1667 | { |
| 1668 | if (entering(tcp)) |
Dmitry V. Levin | 3138213 | 2011-03-04 05:08:02 +0300 | [diff] [blame] | 1669 | print_dirfd(tcp, tcp->u_arg[0]); |
Dmitry V. Levin | 95ebf5a | 2006-10-13 20:25:12 +0000 | [diff] [blame] | 1670 | return decode_mkdir(tcp, 1); |
| 1671 | } |
Dmitry V. Levin | 95ebf5a | 2006-10-13 20:25:12 +0000 | [diff] [blame] | 1672 | |
| 1673 | int |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 1674 | sys_link(struct tcb *tcp) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1675 | { |
| 1676 | if (entering(tcp)) { |
| 1677 | printpath(tcp, tcp->u_arg[0]); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 1678 | tprints(", "); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1679 | printpath(tcp, tcp->u_arg[1]); |
| 1680 | } |
| 1681 | return 0; |
| 1682 | } |
| 1683 | |
Dmitry V. Levin | 95ebf5a | 2006-10-13 20:25:12 +0000 | [diff] [blame] | 1684 | int |
| 1685 | sys_linkat(struct tcb *tcp) |
| 1686 | { |
| 1687 | if (entering(tcp)) { |
Dmitry V. Levin | 3138213 | 2011-03-04 05:08:02 +0300 | [diff] [blame] | 1688 | print_dirfd(tcp, tcp->u_arg[0]); |
Dmitry V. Levin | 95ebf5a | 2006-10-13 20:25:12 +0000 | [diff] [blame] | 1689 | printpath(tcp, tcp->u_arg[1]); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 1690 | tprints(", "); |
Dmitry V. Levin | 3138213 | 2011-03-04 05:08:02 +0300 | [diff] [blame] | 1691 | print_dirfd(tcp, tcp->u_arg[2]); |
Dmitry V. Levin | 95ebf5a | 2006-10-13 20:25:12 +0000 | [diff] [blame] | 1692 | printpath(tcp, tcp->u_arg[3]); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 1693 | tprints(", "); |
Dmitry V. Levin | 7989ad4 | 2012-03-13 23:26:01 +0000 | [diff] [blame] | 1694 | printflags(at_flags, tcp->u_arg[4], "AT_???"); |
Dmitry V. Levin | 95ebf5a | 2006-10-13 20:25:12 +0000 | [diff] [blame] | 1695 | } |
| 1696 | return 0; |
| 1697 | } |
Dmitry V. Levin | 95ebf5a | 2006-10-13 20:25:12 +0000 | [diff] [blame] | 1698 | |
Dmitry V. Levin | 95ebf5a | 2006-10-13 20:25:12 +0000 | [diff] [blame] | 1699 | int |
| 1700 | sys_unlinkat(struct tcb *tcp) |
| 1701 | { |
| 1702 | if (entering(tcp)) { |
Dmitry V. Levin | 3138213 | 2011-03-04 05:08:02 +0300 | [diff] [blame] | 1703 | print_dirfd(tcp, tcp->u_arg[0]); |
Dmitry V. Levin | 95ebf5a | 2006-10-13 20:25:12 +0000 | [diff] [blame] | 1704 | printpath(tcp, tcp->u_arg[1]); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 1705 | tprints(", "); |
Dmitry V. Levin | 7989ad4 | 2012-03-13 23:26:01 +0000 | [diff] [blame] | 1706 | printflags(at_flags, tcp->u_arg[2], "AT_???"); |
Dmitry V. Levin | 95ebf5a | 2006-10-13 20:25:12 +0000 | [diff] [blame] | 1707 | } |
| 1708 | return 0; |
| 1709 | } |
Dmitry V. Levin | 95ebf5a | 2006-10-13 20:25:12 +0000 | [diff] [blame] | 1710 | |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1711 | int |
Dmitry V. Levin | 95ebf5a | 2006-10-13 20:25:12 +0000 | [diff] [blame] | 1712 | sys_symlinkat(struct tcb *tcp) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1713 | { |
| 1714 | if (entering(tcp)) { |
| 1715 | printpath(tcp, tcp->u_arg[0]); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 1716 | tprints(", "); |
Dmitry V. Levin | 3138213 | 2011-03-04 05:08:02 +0300 | [diff] [blame] | 1717 | print_dirfd(tcp, tcp->u_arg[1]); |
Dmitry V. Levin | 95ebf5a | 2006-10-13 20:25:12 +0000 | [diff] [blame] | 1718 | printpath(tcp, tcp->u_arg[2]); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1719 | } |
| 1720 | return 0; |
| 1721 | } |
Dmitry V. Levin | 95ebf5a | 2006-10-13 20:25:12 +0000 | [diff] [blame] | 1722 | |
| 1723 | static int |
| 1724 | decode_readlink(struct tcb *tcp, int offset) |
| 1725 | { |
| 1726 | if (entering(tcp)) { |
| 1727 | printpath(tcp, tcp->u_arg[offset]); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 1728 | tprints(", "); |
Dmitry V. Levin | 95ebf5a | 2006-10-13 20:25:12 +0000 | [diff] [blame] | 1729 | } else { |
| 1730 | if (syserror(tcp)) |
| 1731 | tprintf("%#lx", tcp->u_arg[offset + 1]); |
| 1732 | else |
Denys Vlasenko | 3449ae8 | 2012-01-27 17:24:26 +0100 | [diff] [blame] | 1733 | /* Used to use printpathn(), but readlink |
| 1734 | * neither includes NUL in the returned count, |
| 1735 | * nor actually writes it into memory. |
| 1736 | * printpathn() would decide on printing |
| 1737 | * "..." continuation based on garbage |
| 1738 | * past return buffer's end. |
| 1739 | */ |
| 1740 | printstr(tcp, tcp->u_arg[offset + 1], tcp->u_rval); |
Dmitry V. Levin | 95ebf5a | 2006-10-13 20:25:12 +0000 | [diff] [blame] | 1741 | tprintf(", %lu", tcp->u_arg[offset + 2]); |
| 1742 | } |
| 1743 | return 0; |
| 1744 | } |
| 1745 | |
| 1746 | int |
| 1747 | sys_readlink(struct tcb *tcp) |
| 1748 | { |
| 1749 | return decode_readlink(tcp, 0); |
| 1750 | } |
| 1751 | |
Dmitry V. Levin | 95ebf5a | 2006-10-13 20:25:12 +0000 | [diff] [blame] | 1752 | int |
| 1753 | sys_readlinkat(struct tcb *tcp) |
| 1754 | { |
| 1755 | if (entering(tcp)) |
Dmitry V. Levin | 3138213 | 2011-03-04 05:08:02 +0300 | [diff] [blame] | 1756 | print_dirfd(tcp, tcp->u_arg[0]); |
Dmitry V. Levin | 95ebf5a | 2006-10-13 20:25:12 +0000 | [diff] [blame] | 1757 | return decode_readlink(tcp, 1); |
| 1758 | } |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1759 | |
Dmitry V. Levin | 95ebf5a | 2006-10-13 20:25:12 +0000 | [diff] [blame] | 1760 | int |
| 1761 | sys_renameat(struct tcb *tcp) |
| 1762 | { |
| 1763 | if (entering(tcp)) { |
Dmitry V. Levin | 3138213 | 2011-03-04 05:08:02 +0300 | [diff] [blame] | 1764 | print_dirfd(tcp, tcp->u_arg[0]); |
Dmitry V. Levin | 95ebf5a | 2006-10-13 20:25:12 +0000 | [diff] [blame] | 1765 | printpath(tcp, tcp->u_arg[1]); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 1766 | tprints(", "); |
Dmitry V. Levin | 3138213 | 2011-03-04 05:08:02 +0300 | [diff] [blame] | 1767 | print_dirfd(tcp, tcp->u_arg[2]); |
Dmitry V. Levin | 95ebf5a | 2006-10-13 20:25:12 +0000 | [diff] [blame] | 1768 | printpath(tcp, tcp->u_arg[3]); |
| 1769 | } |
| 1770 | return 0; |
| 1771 | } |
Dmitry V. Levin | 95ebf5a | 2006-10-13 20:25:12 +0000 | [diff] [blame] | 1772 | |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1773 | int |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 1774 | sys_chown(struct tcb *tcp) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1775 | { |
| 1776 | if (entering(tcp)) { |
| 1777 | printpath(tcp, tcp->u_arg[0]); |
Roland McGrath | 6bc1220 | 2003-11-13 22:32:27 +0000 | [diff] [blame] | 1778 | printuid(", ", tcp->u_arg[1]); |
| 1779 | printuid(", ", tcp->u_arg[2]); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1780 | } |
| 1781 | return 0; |
| 1782 | } |
| 1783 | |
Dmitry V. Levin | 95ebf5a | 2006-10-13 20:25:12 +0000 | [diff] [blame] | 1784 | int |
| 1785 | sys_fchownat(struct tcb *tcp) |
| 1786 | { |
| 1787 | if (entering(tcp)) { |
Dmitry V. Levin | 3138213 | 2011-03-04 05:08:02 +0300 | [diff] [blame] | 1788 | print_dirfd(tcp, tcp->u_arg[0]); |
Dmitry V. Levin | 95ebf5a | 2006-10-13 20:25:12 +0000 | [diff] [blame] | 1789 | printpath(tcp, tcp->u_arg[1]); |
| 1790 | printuid(", ", tcp->u_arg[2]); |
| 1791 | printuid(", ", tcp->u_arg[3]); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 1792 | tprints(", "); |
Dmitry V. Levin | 7989ad4 | 2012-03-13 23:26:01 +0000 | [diff] [blame] | 1793 | printflags(at_flags, tcp->u_arg[4], "AT_???"); |
Dmitry V. Levin | 95ebf5a | 2006-10-13 20:25:12 +0000 | [diff] [blame] | 1794 | } |
| 1795 | return 0; |
| 1796 | } |
Dmitry V. Levin | 95ebf5a | 2006-10-13 20:25:12 +0000 | [diff] [blame] | 1797 | |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1798 | int |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 1799 | sys_fchown(struct tcb *tcp) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1800 | { |
| 1801 | if (entering(tcp)) { |
Dmitry V. Levin | 3138213 | 2011-03-04 05:08:02 +0300 | [diff] [blame] | 1802 | printfd(tcp, tcp->u_arg[0]); |
Roland McGrath | 6bc1220 | 2003-11-13 22:32:27 +0000 | [diff] [blame] | 1803 | printuid(", ", tcp->u_arg[1]); |
| 1804 | printuid(", ", tcp->u_arg[2]); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1805 | } |
| 1806 | return 0; |
| 1807 | } |
| 1808 | |
Dmitry V. Levin | 95ebf5a | 2006-10-13 20:25:12 +0000 | [diff] [blame] | 1809 | static int |
| 1810 | decode_chmod(struct tcb *tcp, int offset) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1811 | { |
| 1812 | if (entering(tcp)) { |
Dmitry V. Levin | 95ebf5a | 2006-10-13 20:25:12 +0000 | [diff] [blame] | 1813 | printpath(tcp, tcp->u_arg[offset]); |
| 1814 | tprintf(", %#lo", tcp->u_arg[offset + 1]); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1815 | } |
| 1816 | return 0; |
| 1817 | } |
| 1818 | |
| 1819 | int |
Dmitry V. Levin | 95ebf5a | 2006-10-13 20:25:12 +0000 | [diff] [blame] | 1820 | sys_chmod(struct tcb *tcp) |
| 1821 | { |
| 1822 | return decode_chmod(tcp, 0); |
| 1823 | } |
| 1824 | |
Dmitry V. Levin | 95ebf5a | 2006-10-13 20:25:12 +0000 | [diff] [blame] | 1825 | int |
| 1826 | sys_fchmodat(struct tcb *tcp) |
| 1827 | { |
| 1828 | if (entering(tcp)) |
Dmitry V. Levin | 3138213 | 2011-03-04 05:08:02 +0300 | [diff] [blame] | 1829 | print_dirfd(tcp, tcp->u_arg[0]); |
Dmitry V. Levin | 95ebf5a | 2006-10-13 20:25:12 +0000 | [diff] [blame] | 1830 | return decode_chmod(tcp, 1); |
| 1831 | } |
Dmitry V. Levin | 95ebf5a | 2006-10-13 20:25:12 +0000 | [diff] [blame] | 1832 | |
| 1833 | int |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 1834 | sys_fchmod(struct tcb *tcp) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1835 | { |
| 1836 | if (entering(tcp)) { |
Dmitry V. Levin | 3138213 | 2011-03-04 05:08:02 +0300 | [diff] [blame] | 1837 | printfd(tcp, tcp->u_arg[0]); |
| 1838 | tprintf(", %#lo", tcp->u_arg[1]); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1839 | } |
| 1840 | return 0; |
| 1841 | } |
| 1842 | |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 1843 | #ifdef ALPHA |
| 1844 | int |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 1845 | sys_osf_utimes(struct tcb *tcp) |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 1846 | { |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 1847 | if (entering(tcp)) { |
| 1848 | printpath(tcp, tcp->u_arg[0]); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 1849 | tprints(", "); |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 1850 | printtv_bitness(tcp, tcp->u_arg[1], BITNESS_32, 0); |
| 1851 | } |
| 1852 | return 0; |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 1853 | } |
| 1854 | #endif |
| 1855 | |
Dmitry V. Levin | 95ebf5a | 2006-10-13 20:25:12 +0000 | [diff] [blame] | 1856 | static int |
Roland McGrath | 6afc565 | 2007-07-24 01:57:11 +0000 | [diff] [blame] | 1857 | decode_utimes(struct tcb *tcp, int offset, int special) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1858 | { |
| 1859 | if (entering(tcp)) { |
Dmitry V. Levin | 95ebf5a | 2006-10-13 20:25:12 +0000 | [diff] [blame] | 1860 | printpath(tcp, tcp->u_arg[offset]); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 1861 | tprints(", "); |
Roland McGrath | 6afc565 | 2007-07-24 01:57:11 +0000 | [diff] [blame] | 1862 | if (tcp->u_arg[offset + 1] == 0) |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 1863 | tprints("NULL"); |
Roland McGrath | 6afc565 | 2007-07-24 01:57:11 +0000 | [diff] [blame] | 1864 | else { |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 1865 | tprints("{"); |
Roland McGrath | 6afc565 | 2007-07-24 01:57:11 +0000 | [diff] [blame] | 1866 | printtv_bitness(tcp, tcp->u_arg[offset + 1], |
| 1867 | BITNESS_CURRENT, special); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 1868 | tprints(", "); |
Roland McGrath | e6d0f71 | 2007-08-07 01:22:49 +0000 | [diff] [blame] | 1869 | printtv_bitness(tcp, tcp->u_arg[offset + 1] |
Denys Vlasenko | b63256e | 2011-06-07 12:13:24 +0200 | [diff] [blame] | 1870 | + sizeof(struct timeval), |
Roland McGrath | 6afc565 | 2007-07-24 01:57:11 +0000 | [diff] [blame] | 1871 | BITNESS_CURRENT, special); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 1872 | tprints("}"); |
Roland McGrath | 6afc565 | 2007-07-24 01:57:11 +0000 | [diff] [blame] | 1873 | } |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1874 | } |
| 1875 | return 0; |
| 1876 | } |
| 1877 | |
| 1878 | int |
Dmitry V. Levin | 95ebf5a | 2006-10-13 20:25:12 +0000 | [diff] [blame] | 1879 | sys_utimes(struct tcb *tcp) |
| 1880 | { |
Roland McGrath | 6afc565 | 2007-07-24 01:57:11 +0000 | [diff] [blame] | 1881 | return decode_utimes(tcp, 0, 0); |
Dmitry V. Levin | 95ebf5a | 2006-10-13 20:25:12 +0000 | [diff] [blame] | 1882 | } |
| 1883 | |
Dmitry V. Levin | 95ebf5a | 2006-10-13 20:25:12 +0000 | [diff] [blame] | 1884 | int |
| 1885 | sys_futimesat(struct tcb *tcp) |
| 1886 | { |
| 1887 | if (entering(tcp)) |
Dmitry V. Levin | 3138213 | 2011-03-04 05:08:02 +0300 | [diff] [blame] | 1888 | print_dirfd(tcp, tcp->u_arg[0]); |
Roland McGrath | 6afc565 | 2007-07-24 01:57:11 +0000 | [diff] [blame] | 1889 | return decode_utimes(tcp, 1, 0); |
| 1890 | } |
| 1891 | |
| 1892 | int |
| 1893 | sys_utimensat(struct tcb *tcp) |
| 1894 | { |
| 1895 | if (entering(tcp)) { |
Dmitry V. Levin | 3138213 | 2011-03-04 05:08:02 +0300 | [diff] [blame] | 1896 | print_dirfd(tcp, tcp->u_arg[0]); |
Roland McGrath | 6afc565 | 2007-07-24 01:57:11 +0000 | [diff] [blame] | 1897 | decode_utimes(tcp, 1, 1); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 1898 | tprints(", "); |
Dmitry V. Levin | 7989ad4 | 2012-03-13 23:26:01 +0000 | [diff] [blame] | 1899 | printflags(at_flags, tcp->u_arg[3], "AT_???"); |
Roland McGrath | 6afc565 | 2007-07-24 01:57:11 +0000 | [diff] [blame] | 1900 | } |
| 1901 | return 0; |
Dmitry V. Levin | 95ebf5a | 2006-10-13 20:25:12 +0000 | [diff] [blame] | 1902 | } |
Dmitry V. Levin | 95ebf5a | 2006-10-13 20:25:12 +0000 | [diff] [blame] | 1903 | |
| 1904 | int |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 1905 | sys_utime(struct tcb *tcp) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1906 | { |
Roland McGrath | 7e9817c | 2007-07-05 20:31:58 +0000 | [diff] [blame] | 1907 | union { |
| 1908 | long utl[2]; |
| 1909 | int uti[2]; |
Denys Vlasenko | 751acb3 | 2013-02-08 15:34:46 +0100 | [diff] [blame] | 1910 | long paranoia_for_huge_wordsize[4]; |
Roland McGrath | 7e9817c | 2007-07-05 20:31:58 +0000 | [diff] [blame] | 1911 | } u; |
Denys Vlasenko | 751acb3 | 2013-02-08 15:34:46 +0100 | [diff] [blame] | 1912 | unsigned wordsize; |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1913 | |
| 1914 | if (entering(tcp)) { |
| 1915 | printpath(tcp, tcp->u_arg[0]); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 1916 | tprints(", "); |
Denys Vlasenko | 751acb3 | 2013-02-08 15:34:46 +0100 | [diff] [blame] | 1917 | |
| 1918 | wordsize = current_wordsize; |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1919 | if (!tcp->u_arg[1]) |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 1920 | tprints("NULL"); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1921 | else if (!verbose(tcp)) |
| 1922 | tprintf("%#lx", tcp->u_arg[1]); |
Denys Vlasenko | 1945ccc | 2012-02-27 14:37:48 +0100 | [diff] [blame] | 1923 | 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] | 1924 | tprints("[?, ?]"); |
Denys Vlasenko | 1945ccc | 2012-02-27 14:37:48 +0100 | [diff] [blame] | 1925 | else if (wordsize == sizeof u.utl[0]) { |
Roland McGrath | 7e9817c | 2007-07-05 20:31:58 +0000 | [diff] [blame] | 1926 | tprintf("[%s,", sprinttime(u.utl[0])); |
| 1927 | tprintf(" %s]", sprinttime(u.utl[1])); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1928 | } |
Denys Vlasenko | 1945ccc | 2012-02-27 14:37:48 +0100 | [diff] [blame] | 1929 | else if (wordsize == sizeof u.uti[0]) { |
Roland McGrath | 7e9817c | 2007-07-05 20:31:58 +0000 | [diff] [blame] | 1930 | tprintf("[%s,", sprinttime(u.uti[0])); |
| 1931 | tprintf(" %s]", sprinttime(u.uti[1])); |
| 1932 | } |
| 1933 | else |
Denys Vlasenko | 751acb3 | 2013-02-08 15:34:46 +0100 | [diff] [blame] | 1934 | tprintf("<decode error: unsupported wordsize %d>", |
| 1935 | wordsize); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1936 | } |
| 1937 | return 0; |
| 1938 | } |
| 1939 | |
Dmitry V. Levin | 95ebf5a | 2006-10-13 20:25:12 +0000 | [diff] [blame] | 1940 | static int |
| 1941 | decode_mknod(struct tcb *tcp, int offset) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1942 | { |
Dmitry V. Levin | 95ebf5a | 2006-10-13 20:25:12 +0000 | [diff] [blame] | 1943 | int mode = tcp->u_arg[offset + 1]; |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1944 | |
| 1945 | if (entering(tcp)) { |
Dmitry V. Levin | 95ebf5a | 2006-10-13 20:25:12 +0000 | [diff] [blame] | 1946 | printpath(tcp, tcp->u_arg[offset]); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1947 | tprintf(", %s", sprintmode(mode)); |
| 1948 | switch (mode & S_IFMT) { |
Denys Vlasenko | b237b1b | 2012-02-27 13:56:59 +0100 | [diff] [blame] | 1949 | case S_IFCHR: |
| 1950 | case S_IFBLK: |
Denys Vlasenko | 9472a27 | 2013-02-12 11:43:46 +0100 | [diff] [blame] | 1951 | #if defined(SPARC) || defined(SPARC64) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1952 | if (current_personality == 1) |
Denys Vlasenko | b237b1b | 2012-02-27 13:56:59 +0100 | [diff] [blame] | 1953 | tprintf(", makedev(%lu, %lu)", |
Dmitry V. Levin | 95ebf5a | 2006-10-13 20:25:12 +0000 | [diff] [blame] | 1954 | (unsigned long) ((tcp->u_arg[offset + 2] >> 18) & 0x3fff), |
| 1955 | (unsigned long) (tcp->u_arg[offset + 2] & 0x3ffff)); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1956 | else |
Roland McGrath | 186c5ac | 2002-12-15 23:58:23 +0000 | [diff] [blame] | 1957 | #endif |
Denys Vlasenko | b237b1b | 2012-02-27 13:56:59 +0100 | [diff] [blame] | 1958 | tprintf(", makedev(%lu, %lu)", |
Dmitry V. Levin | 95ebf5a | 2006-10-13 20:25:12 +0000 | [diff] [blame] | 1959 | (unsigned long) major(tcp->u_arg[offset + 2]), |
| 1960 | (unsigned long) minor(tcp->u_arg[offset + 2])); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1961 | break; |
| 1962 | default: |
| 1963 | break; |
| 1964 | } |
| 1965 | } |
| 1966 | return 0; |
| 1967 | } |
| 1968 | |
| 1969 | int |
Dmitry V. Levin | 95ebf5a | 2006-10-13 20:25:12 +0000 | [diff] [blame] | 1970 | sys_mknod(struct tcb *tcp) |
| 1971 | { |
| 1972 | return decode_mknod(tcp, 0); |
| 1973 | } |
| 1974 | |
Dmitry V. Levin | 95ebf5a | 2006-10-13 20:25:12 +0000 | [diff] [blame] | 1975 | int |
| 1976 | sys_mknodat(struct tcb *tcp) |
| 1977 | { |
| 1978 | if (entering(tcp)) |
Dmitry V. Levin | 3138213 | 2011-03-04 05:08:02 +0300 | [diff] [blame] | 1979 | print_dirfd(tcp, tcp->u_arg[0]); |
Dmitry V. Levin | 95ebf5a | 2006-10-13 20:25:12 +0000 | [diff] [blame] | 1980 | return decode_mknod(tcp, 1); |
| 1981 | } |
Dmitry V. Levin | 95ebf5a | 2006-10-13 20:25:12 +0000 | [diff] [blame] | 1982 | |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1983 | static void |
Dmitry V. Levin | 68f80e6 | 2013-03-20 12:45:05 +0000 | [diff] [blame] | 1984 | print_old_dirent(struct tcb *tcp, long addr) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1985 | { |
Dmitry V. Levin | 68f80e6 | 2013-03-20 12:45:05 +0000 | [diff] [blame] | 1986 | #ifdef SH64 |
| 1987 | typedef struct kernel_dirent old_dirent_t; |
| 1988 | #else |
| 1989 | typedef struct { |
| 1990 | uint32_t d_ino; |
| 1991 | uint32_t d_off; |
| 1992 | unsigned short d_reclen; |
| 1993 | char d_name[1]; |
| 1994 | } old_dirent_t; |
| 1995 | #endif |
| 1996 | old_dirent_t d; |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1997 | |
Dmitry V. Levin | 68f80e6 | 2013-03-20 12:45:05 +0000 | [diff] [blame] | 1998 | if (!verbose(tcp) || umove(tcp, addr, &d) < 0) { |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1999 | tprintf("%#lx", addr); |
| 2000 | return; |
| 2001 | } |
Dmitry V. Levin | 68f80e6 | 2013-03-20 12:45:05 +0000 | [diff] [blame] | 2002 | |
| 2003 | tprintf("{d_ino=%lu, d_off=%lu, d_reclen=%u, d_name=\"", |
| 2004 | (unsigned long) d.d_ino, (unsigned long) d.d_off, d.d_reclen); |
| 2005 | if (d.d_reclen > 256) |
| 2006 | d.d_reclen = 256; |
| 2007 | printpathn(tcp, addr + offsetof(old_dirent_t, d_name), d.d_reclen); |
| 2008 | tprints("\"}"); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 2009 | } |
| 2010 | |
| 2011 | int |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 2012 | sys_readdir(struct tcb *tcp) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 2013 | { |
| 2014 | if (entering(tcp)) { |
Dmitry V. Levin | 3138213 | 2011-03-04 05:08:02 +0300 | [diff] [blame] | 2015 | printfd(tcp, tcp->u_arg[0]); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 2016 | tprints(", "); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 2017 | } else { |
| 2018 | if (syserror(tcp) || tcp->u_rval == 0 || !verbose(tcp)) |
| 2019 | tprintf("%#lx", tcp->u_arg[1]); |
| 2020 | else |
Dmitry V. Levin | 68f80e6 | 2013-03-20 12:45:05 +0000 | [diff] [blame] | 2021 | print_old_dirent(tcp, tcp->u_arg[1]); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 2022 | /* Not much point in printing this out, it is always 1. */ |
| 2023 | if (tcp->u_arg[2] != 1) |
| 2024 | tprintf(", %lu", tcp->u_arg[2]); |
| 2025 | } |
| 2026 | return 0; |
| 2027 | } |
| 2028 | |
Dmitry V. Levin | 0ed617b | 2014-04-25 23:30:54 +0000 | [diff] [blame^] | 2029 | #include "xlat/direnttypes.h" |
Wichert Akkerman | bf79f2e | 2000-09-01 21:03:06 +0000 | [diff] [blame] | 2030 | |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 2031 | int |
Dmitry V. Levin | 153fbd6 | 2008-04-19 23:49:58 +0000 | [diff] [blame] | 2032 | sys_getdents(struct tcb *tcp) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 2033 | { |
| 2034 | int i, len, dents = 0; |
| 2035 | char *buf; |
| 2036 | |
| 2037 | if (entering(tcp)) { |
Dmitry V. Levin | 3138213 | 2011-03-04 05:08:02 +0300 | [diff] [blame] | 2038 | printfd(tcp, tcp->u_arg[0]); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 2039 | tprints(", "); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 2040 | return 0; |
| 2041 | } |
| 2042 | if (syserror(tcp) || !verbose(tcp)) { |
| 2043 | tprintf("%#lx, %lu", tcp->u_arg[1], tcp->u_arg[2]); |
| 2044 | return 0; |
| 2045 | } |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 2046 | len = tcp->u_rval; |
Denys Vlasenko | 79a79ea | 2011-09-01 16:35:44 +0200 | [diff] [blame] | 2047 | /* Beware of insanely large or negative values in tcp->u_rval */ |
| 2048 | if (tcp->u_rval > 1024*1024) |
| 2049 | len = 1024*1024; |
| 2050 | if (tcp->u_rval < 0) |
| 2051 | len = 0; |
Mike Frysinger | 229738c | 2009-10-07 20:41:56 -0400 | [diff] [blame] | 2052 | buf = len ? malloc(len) : NULL; |
Denys Vlasenko | 1d46ba5 | 2011-08-31 14:00:02 +0200 | [diff] [blame] | 2053 | if (len && !buf) |
| 2054 | die_out_of_memory(); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 2055 | if (umoven(tcp, tcp->u_arg[1], len, buf) < 0) { |
Roland McGrath | 46100d0 | 2005-06-01 18:55:42 +0000 | [diff] [blame] | 2056 | tprintf("%#lx, %lu", tcp->u_arg[1], tcp->u_arg[2]); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 2057 | free(buf); |
| 2058 | return 0; |
| 2059 | } |
| 2060 | if (!abbrev(tcp)) |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 2061 | tprints("{"); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 2062 | for (i = 0; i < len;) { |
Wichert Akkerman | 9524bb9 | 1999-05-25 23:11:18 +0000 | [diff] [blame] | 2063 | struct kernel_dirent *d = (struct kernel_dirent *) &buf[i]; |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 2064 | if (!abbrev(tcp)) { |
| 2065 | tprintf("%s{d_ino=%lu, d_off=%lu, ", |
| 2066 | i ? " " : "", d->d_ino, d->d_off); |
Dmitry V. Levin | ad232c6 | 2012-08-16 19:29:55 +0000 | [diff] [blame] | 2067 | tprintf("d_reclen=%u, d_name=\"%s\", d_type=", |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 2068 | d->d_reclen, d->d_name); |
Dmitry V. Levin | ad232c6 | 2012-08-16 19:29:55 +0000 | [diff] [blame] | 2069 | printxval(direnttypes, buf[i + d->d_reclen - 1], "DT_???"); |
| 2070 | tprints("}"); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 2071 | } |
Pavel Machek | 9a9f10b | 2000-02-01 16:22:52 +0000 | [diff] [blame] | 2072 | if (!d->d_reclen) { |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 2073 | tprints("/* d_reclen == 0, problem here */"); |
Pavel Machek | 9a9f10b | 2000-02-01 16:22:52 +0000 | [diff] [blame] | 2074 | break; |
| 2075 | } |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 2076 | i += d->d_reclen; |
| 2077 | dents++; |
| 2078 | } |
| 2079 | if (!abbrev(tcp)) |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 2080 | tprints("}"); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 2081 | else |
| 2082 | tprintf("/* %u entries */", dents); |
| 2083 | tprintf(", %lu", tcp->u_arg[2]); |
| 2084 | free(buf); |
| 2085 | return 0; |
| 2086 | } |
| 2087 | |
John Hughes | bdf48f5 | 2001-03-06 15:08:09 +0000 | [diff] [blame] | 2088 | int |
Dmitry V. Levin | 153fbd6 | 2008-04-19 23:49:58 +0000 | [diff] [blame] | 2089 | sys_getdents64(struct tcb *tcp) |
John Hughes | bdf48f5 | 2001-03-06 15:08:09 +0000 | [diff] [blame] | 2090 | { |
| 2091 | int i, len, dents = 0; |
| 2092 | char *buf; |
| 2093 | |
| 2094 | if (entering(tcp)) { |
Dmitry V. Levin | 3138213 | 2011-03-04 05:08:02 +0300 | [diff] [blame] | 2095 | printfd(tcp, tcp->u_arg[0]); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 2096 | tprints(", "); |
John Hughes | bdf48f5 | 2001-03-06 15:08:09 +0000 | [diff] [blame] | 2097 | return 0; |
| 2098 | } |
| 2099 | if (syserror(tcp) || !verbose(tcp)) { |
| 2100 | tprintf("%#lx, %lu", tcp->u_arg[1], tcp->u_arg[2]); |
| 2101 | return 0; |
| 2102 | } |
Denys Vlasenko | 79a79ea | 2011-09-01 16:35:44 +0200 | [diff] [blame] | 2103 | |
John Hughes | bdf48f5 | 2001-03-06 15:08:09 +0000 | [diff] [blame] | 2104 | len = tcp->u_rval; |
Denys Vlasenko | 79a79ea | 2011-09-01 16:35:44 +0200 | [diff] [blame] | 2105 | /* Beware of insanely large or negative tcp->u_rval */ |
| 2106 | if (tcp->u_rval > 1024*1024) |
| 2107 | len = 1024*1024; |
| 2108 | if (tcp->u_rval < 0) |
| 2109 | len = 0; |
Mike Frysinger | 229738c | 2009-10-07 20:41:56 -0400 | [diff] [blame] | 2110 | buf = len ? malloc(len) : NULL; |
Denys Vlasenko | 1d46ba5 | 2011-08-31 14:00:02 +0200 | [diff] [blame] | 2111 | if (len && !buf) |
| 2112 | die_out_of_memory(); |
Denys Vlasenko | 79a79ea | 2011-09-01 16:35:44 +0200 | [diff] [blame] | 2113 | |
John Hughes | bdf48f5 | 2001-03-06 15:08:09 +0000 | [diff] [blame] | 2114 | if (umoven(tcp, tcp->u_arg[1], len, buf) < 0) { |
Roland McGrath | 46100d0 | 2005-06-01 18:55:42 +0000 | [diff] [blame] | 2115 | tprintf("%#lx, %lu", tcp->u_arg[1], tcp->u_arg[2]); |
John Hughes | bdf48f5 | 2001-03-06 15:08:09 +0000 | [diff] [blame] | 2116 | free(buf); |
| 2117 | return 0; |
| 2118 | } |
| 2119 | if (!abbrev(tcp)) |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 2120 | tprints("{"); |
John Hughes | bdf48f5 | 2001-03-06 15:08:09 +0000 | [diff] [blame] | 2121 | for (i = 0; i < len;) { |
| 2122 | struct dirent64 *d = (struct dirent64 *) &buf[i]; |
John Hughes | bdf48f5 | 2001-03-06 15:08:09 +0000 | [diff] [blame] | 2123 | if (!abbrev(tcp)) { |
Dmitry V. Levin | 1f336e5 | 2006-10-14 20:20:46 +0000 | [diff] [blame] | 2124 | tprintf("%s{d_ino=%" PRIu64 ", d_off=%" PRId64 ", ", |
Roland McGrath | 186c5ac | 2002-12-15 23:58:23 +0000 | [diff] [blame] | 2125 | i ? " " : "", |
Roland McGrath | 9205324 | 2004-01-13 10:16:47 +0000 | [diff] [blame] | 2126 | d->d_ino, |
| 2127 | d->d_off); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 2128 | tprints("d_type="); |
Roland McGrath | 4054284 | 2004-01-13 09:47:49 +0000 | [diff] [blame] | 2129 | printxval(direnttypes, d->d_type, "DT_???"); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 2130 | tprints(", "); |
John Hughes | bdf48f5 | 2001-03-06 15:08:09 +0000 | [diff] [blame] | 2131 | tprintf("d_reclen=%u, d_name=\"%s\"}", |
| 2132 | d->d_reclen, d->d_name); |
| 2133 | } |
Dmitry V. Levin | 153fbd6 | 2008-04-19 23:49:58 +0000 | [diff] [blame] | 2134 | if (!d->d_reclen) { |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 2135 | tprints("/* d_reclen == 0, problem here */"); |
Dmitry V. Levin | 153fbd6 | 2008-04-19 23:49:58 +0000 | [diff] [blame] | 2136 | break; |
| 2137 | } |
John Hughes | bdf48f5 | 2001-03-06 15:08:09 +0000 | [diff] [blame] | 2138 | i += d->d_reclen; |
| 2139 | dents++; |
| 2140 | } |
| 2141 | if (!abbrev(tcp)) |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 2142 | tprints("}"); |
John Hughes | bdf48f5 | 2001-03-06 15:08:09 +0000 | [diff] [blame] | 2143 | else |
| 2144 | tprintf("/* %u entries */", dents); |
| 2145 | tprintf(", %lu", tcp->u_arg[2]); |
| 2146 | free(buf); |
| 2147 | return 0; |
| 2148 | } |
Roland McGrath | 186c5ac | 2002-12-15 23:58:23 +0000 | [diff] [blame] | 2149 | |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 2150 | int |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 2151 | sys_getcwd(struct tcb *tcp) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 2152 | { |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 2153 | if (exiting(tcp)) { |
| 2154 | if (syserror(tcp)) |
| 2155 | tprintf("%#lx", tcp->u_arg[0]); |
| 2156 | else |
| 2157 | printpathn(tcp, tcp->u_arg[0], tcp->u_rval - 1); |
| 2158 | tprintf(", %lu", tcp->u_arg[1]); |
| 2159 | } |
| 2160 | return 0; |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 2161 | } |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 2162 | |
| 2163 | #ifdef HAVE_SYS_ASYNCH_H |
| 2164 | |
| 2165 | int |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 2166 | sys_aioread(struct tcb *tcp) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 2167 | { |
| 2168 | struct aio_result_t res; |
| 2169 | |
| 2170 | if (entering(tcp)) { |
| 2171 | tprintf("%lu, ", tcp->u_arg[0]); |
| 2172 | } else { |
| 2173 | if (syserror(tcp)) |
| 2174 | tprintf("%#lx", tcp->u_arg[1]); |
| 2175 | else |
| 2176 | printstr(tcp, tcp->u_arg[1], tcp->u_arg[2]); |
| 2177 | tprintf(", %lu, %lu, ", tcp->u_arg[2], tcp->u_arg[3]); |
| 2178 | printxval(whence, tcp->u_arg[4], "L_???"); |
| 2179 | if (syserror(tcp) || tcp->u_arg[5] == 0 |
| 2180 | || umove(tcp, tcp->u_arg[5], &res) < 0) |
| 2181 | tprintf(", %#lx", tcp->u_arg[5]); |
| 2182 | else |
| 2183 | tprintf(", {aio_return %d aio_errno %d}", |
| 2184 | res.aio_return, res.aio_errno); |
| 2185 | } |
| 2186 | return 0; |
| 2187 | } |
| 2188 | |
| 2189 | int |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 2190 | sys_aiowrite(struct tcb *tcp) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 2191 | { |
| 2192 | struct aio_result_t res; |
| 2193 | |
| 2194 | if (entering(tcp)) { |
| 2195 | tprintf("%lu, ", tcp->u_arg[0]); |
| 2196 | printstr(tcp, tcp->u_arg[1], tcp->u_arg[2]); |
| 2197 | tprintf(", %lu, %lu, ", tcp->u_arg[2], tcp->u_arg[3]); |
| 2198 | printxval(whence, tcp->u_arg[4], "L_???"); |
| 2199 | } |
| 2200 | else { |
| 2201 | if (tcp->u_arg[5] == 0) |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 2202 | tprints(", NULL"); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 2203 | else if (syserror(tcp) |
| 2204 | || umove(tcp, tcp->u_arg[5], &res) < 0) |
| 2205 | tprintf(", %#lx", tcp->u_arg[5]); |
| 2206 | else |
| 2207 | tprintf(", {aio_return %d aio_errno %d}", |
| 2208 | res.aio_return, res.aio_errno); |
| 2209 | } |
| 2210 | return 0; |
| 2211 | } |
| 2212 | |
| 2213 | int |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 2214 | sys_aiowait(struct tcb *tcp) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 2215 | { |
| 2216 | if (entering(tcp)) |
| 2217 | printtv(tcp, tcp->u_arg[0]); |
| 2218 | return 0; |
| 2219 | } |
| 2220 | |
| 2221 | int |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 2222 | sys_aiocancel(struct tcb *tcp) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 2223 | { |
| 2224 | struct aio_result_t res; |
| 2225 | |
| 2226 | if (exiting(tcp)) { |
| 2227 | if (tcp->u_arg[0] == 0) |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 2228 | tprints("NULL"); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 2229 | else if (syserror(tcp) |
| 2230 | || umove(tcp, tcp->u_arg[0], &res) < 0) |
| 2231 | tprintf("%#lx", tcp->u_arg[0]); |
| 2232 | else |
| 2233 | tprintf("{aio_return %d aio_errno %d}", |
| 2234 | res.aio_return, res.aio_errno); |
| 2235 | } |
| 2236 | return 0; |
| 2237 | } |
| 2238 | |
| 2239 | #endif /* HAVE_SYS_ASYNCH_H */ |
Roland McGrath | 186c5ac | 2002-12-15 23:58:23 +0000 | [diff] [blame] | 2240 | |
Dmitry V. Levin | 0ed617b | 2014-04-25 23:30:54 +0000 | [diff] [blame^] | 2241 | #include "xlat/xattrflags.h" |
Roland McGrath | 186c5ac | 2002-12-15 23:58:23 +0000 | [diff] [blame] | 2242 | |
Roland McGrath | 3292e22 | 2004-08-31 06:30:48 +0000 | [diff] [blame] | 2243 | static void |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 2244 | print_xattr_val(struct tcb *tcp, int failed, |
| 2245 | unsigned long arg, |
| 2246 | unsigned long insize, |
| 2247 | unsigned long size) |
Roland McGrath | 3292e22 | 2004-08-31 06:30:48 +0000 | [diff] [blame] | 2248 | { |
Dmitry V. Levin | 1f21513 | 2012-12-07 21:38:52 +0000 | [diff] [blame] | 2249 | if (insize == 0) |
| 2250 | failed = 1; |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 2251 | if (!failed) { |
| 2252 | unsigned long capacity = 4 * size + 1; |
| 2253 | unsigned char *buf = (capacity < size) ? NULL : malloc(capacity); |
| 2254 | if (buf == NULL || /* probably a bogus size argument */ |
| 2255 | umoven(tcp, arg, size, (char *) &buf[3 * size]) < 0) { |
| 2256 | failed = 1; |
Roland McGrath | 883567c | 2005-02-02 03:38:32 +0000 | [diff] [blame] | 2257 | } |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 2258 | else { |
| 2259 | unsigned char *out = buf; |
| 2260 | unsigned char *in = &buf[3 * size]; |
| 2261 | size_t i; |
| 2262 | for (i = 0; i < size; ++i) { |
Denys Vlasenko | 5198ed4 | 2013-03-06 23:44:23 +0100 | [diff] [blame] | 2263 | if (in[i] >= ' ' && in[i] <= 0x7e) |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 2264 | *out++ = in[i]; |
| 2265 | else { |
| 2266 | #define tohex(n) "0123456789abcdef"[n] |
| 2267 | *out++ = '\\'; |
| 2268 | *out++ = 'x'; |
| 2269 | *out++ = tohex(in[i] / 16); |
| 2270 | *out++ = tohex(in[i] % 16); |
| 2271 | } |
| 2272 | } |
| 2273 | /* Don't print terminating NUL if there is one. */ |
| 2274 | if (i > 0 && in[i - 1] == '\0') |
| 2275 | out -= 4; |
| 2276 | *out = '\0'; |
| 2277 | tprintf(", \"%s\", %ld", buf, insize); |
| 2278 | } |
| 2279 | free(buf); |
Roland McGrath | 883567c | 2005-02-02 03:38:32 +0000 | [diff] [blame] | 2280 | } |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 2281 | if (failed) |
| 2282 | tprintf(", 0x%lx, %ld", arg, insize); |
Roland McGrath | 3292e22 | 2004-08-31 06:30:48 +0000 | [diff] [blame] | 2283 | } |
| 2284 | |
Roland McGrath | 186c5ac | 2002-12-15 23:58:23 +0000 | [diff] [blame] | 2285 | int |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 2286 | sys_setxattr(struct tcb *tcp) |
Roland McGrath | 186c5ac | 2002-12-15 23:58:23 +0000 | [diff] [blame] | 2287 | { |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 2288 | if (entering(tcp)) { |
| 2289 | printpath(tcp, tcp->u_arg[0]); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 2290 | tprints(", "); |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 2291 | printstr(tcp, tcp->u_arg[1], -1); |
| 2292 | 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] | 2293 | tprints(", "); |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 2294 | printflags(xattrflags, tcp->u_arg[4], "XATTR_???"); |
| 2295 | } |
| 2296 | return 0; |
Roland McGrath | 186c5ac | 2002-12-15 23:58:23 +0000 | [diff] [blame] | 2297 | } |
| 2298 | |
| 2299 | int |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 2300 | sys_fsetxattr(struct tcb *tcp) |
Roland McGrath | 186c5ac | 2002-12-15 23:58:23 +0000 | [diff] [blame] | 2301 | { |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 2302 | if (entering(tcp)) { |
Dmitry V. Levin | 3138213 | 2011-03-04 05:08:02 +0300 | [diff] [blame] | 2303 | printfd(tcp, tcp->u_arg[0]); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 2304 | tprints(", "); |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 2305 | printstr(tcp, tcp->u_arg[1], -1); |
| 2306 | 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] | 2307 | tprints(", "); |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 2308 | printflags(xattrflags, tcp->u_arg[4], "XATTR_???"); |
| 2309 | } |
| 2310 | return 0; |
Roland McGrath | 186c5ac | 2002-12-15 23:58:23 +0000 | [diff] [blame] | 2311 | } |
| 2312 | |
| 2313 | int |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 2314 | sys_getxattr(struct tcb *tcp) |
Roland McGrath | 186c5ac | 2002-12-15 23:58:23 +0000 | [diff] [blame] | 2315 | { |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 2316 | if (entering(tcp)) { |
| 2317 | printpath(tcp, tcp->u_arg[0]); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 2318 | tprints(", "); |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 2319 | printstr(tcp, tcp->u_arg[1], -1); |
| 2320 | } else { |
| 2321 | print_xattr_val(tcp, syserror(tcp), tcp->u_arg[2], tcp->u_arg[3], |
| 2322 | tcp->u_rval); |
| 2323 | } |
| 2324 | return 0; |
Roland McGrath | 186c5ac | 2002-12-15 23:58:23 +0000 | [diff] [blame] | 2325 | } |
| 2326 | |
| 2327 | int |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 2328 | sys_fgetxattr(struct tcb *tcp) |
Roland McGrath | 186c5ac | 2002-12-15 23:58:23 +0000 | [diff] [blame] | 2329 | { |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 2330 | if (entering(tcp)) { |
Dmitry V. Levin | 3138213 | 2011-03-04 05:08:02 +0300 | [diff] [blame] | 2331 | printfd(tcp, tcp->u_arg[0]); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 2332 | tprints(", "); |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 2333 | printstr(tcp, tcp->u_arg[1], -1); |
| 2334 | } else { |
| 2335 | print_xattr_val(tcp, syserror(tcp), tcp->u_arg[2], tcp->u_arg[3], |
| 2336 | tcp->u_rval); |
| 2337 | } |
| 2338 | return 0; |
Roland McGrath | 186c5ac | 2002-12-15 23:58:23 +0000 | [diff] [blame] | 2339 | } |
| 2340 | |
Dmitry V. Levin | 33d2476 | 2012-03-14 16:34:32 +0000 | [diff] [blame] | 2341 | static void |
| 2342 | print_xattr_list(struct tcb *tcp, unsigned long addr, unsigned long size) |
| 2343 | { |
| 2344 | if (syserror(tcp)) { |
| 2345 | tprintf("%#lx", addr); |
| 2346 | } else { |
| 2347 | if (!addr) { |
| 2348 | tprints("NULL"); |
| 2349 | } else { |
| 2350 | unsigned long len = |
| 2351 | (size < tcp->u_rval) ? size : tcp->u_rval; |
| 2352 | printstr(tcp, addr, len); |
| 2353 | } |
| 2354 | } |
| 2355 | tprintf(", %lu", size); |
| 2356 | } |
| 2357 | |
Roland McGrath | 186c5ac | 2002-12-15 23:58:23 +0000 | [diff] [blame] | 2358 | int |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 2359 | sys_listxattr(struct tcb *tcp) |
Roland McGrath | 186c5ac | 2002-12-15 23:58:23 +0000 | [diff] [blame] | 2360 | { |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 2361 | if (entering(tcp)) { |
| 2362 | printpath(tcp, tcp->u_arg[0]); |
Dmitry V. Levin | 33d2476 | 2012-03-14 16:34:32 +0000 | [diff] [blame] | 2363 | tprints(", "); |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 2364 | } else { |
Dmitry V. Levin | 33d2476 | 2012-03-14 16:34:32 +0000 | [diff] [blame] | 2365 | print_xattr_list(tcp, tcp->u_arg[1], tcp->u_arg[2]); |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 2366 | } |
| 2367 | return 0; |
Roland McGrath | 186c5ac | 2002-12-15 23:58:23 +0000 | [diff] [blame] | 2368 | } |
| 2369 | |
| 2370 | int |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 2371 | sys_flistxattr(struct tcb *tcp) |
Roland McGrath | 186c5ac | 2002-12-15 23:58:23 +0000 | [diff] [blame] | 2372 | { |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 2373 | if (entering(tcp)) { |
Dmitry V. Levin | 3138213 | 2011-03-04 05:08:02 +0300 | [diff] [blame] | 2374 | printfd(tcp, tcp->u_arg[0]); |
Dmitry V. Levin | 33d2476 | 2012-03-14 16:34:32 +0000 | [diff] [blame] | 2375 | tprints(", "); |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 2376 | } else { |
Dmitry V. Levin | 33d2476 | 2012-03-14 16:34:32 +0000 | [diff] [blame] | 2377 | print_xattr_list(tcp, tcp->u_arg[1], tcp->u_arg[2]); |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 2378 | } |
| 2379 | return 0; |
Roland McGrath | 186c5ac | 2002-12-15 23:58:23 +0000 | [diff] [blame] | 2380 | } |
| 2381 | |
| 2382 | int |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 2383 | sys_removexattr(struct tcb *tcp) |
Roland McGrath | 186c5ac | 2002-12-15 23:58:23 +0000 | [diff] [blame] | 2384 | { |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 2385 | if (entering(tcp)) { |
| 2386 | printpath(tcp, tcp->u_arg[0]); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 2387 | tprints(", "); |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 2388 | printstr(tcp, tcp->u_arg[1], -1); |
| 2389 | } |
| 2390 | return 0; |
Roland McGrath | 186c5ac | 2002-12-15 23:58:23 +0000 | [diff] [blame] | 2391 | } |
| 2392 | |
| 2393 | int |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 2394 | sys_fremovexattr(struct tcb *tcp) |
Roland McGrath | 186c5ac | 2002-12-15 23:58:23 +0000 | [diff] [blame] | 2395 | { |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 2396 | if (entering(tcp)) { |
Dmitry V. Levin | 3138213 | 2011-03-04 05:08:02 +0300 | [diff] [blame] | 2397 | printfd(tcp, tcp->u_arg[0]); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 2398 | tprints(", "); |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 2399 | printstr(tcp, tcp->u_arg[1], -1); |
| 2400 | } |
| 2401 | return 0; |
Roland McGrath | 186c5ac | 2002-12-15 23:58:23 +0000 | [diff] [blame] | 2402 | } |
Roland McGrath | df13e8f | 2004-10-07 18:51:19 +0000 | [diff] [blame] | 2403 | |
Dmitry V. Levin | 0ed617b | 2014-04-25 23:30:54 +0000 | [diff] [blame^] | 2404 | #include "xlat/advise.h" |
Roland McGrath | df13e8f | 2004-10-07 18:51:19 +0000 | [diff] [blame] | 2405 | |
Roland McGrath | df13e8f | 2004-10-07 18:51:19 +0000 | [diff] [blame] | 2406 | int |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 2407 | sys_fadvise64(struct tcb *tcp) |
Roland McGrath | df13e8f | 2004-10-07 18:51:19 +0000 | [diff] [blame] | 2408 | { |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 2409 | if (entering(tcp)) { |
Andreas Schwab | b5600fc | 2009-11-04 17:08:34 +0100 | [diff] [blame] | 2410 | int argn; |
Dmitry V. Levin | 3138213 | 2011-03-04 05:08:02 +0300 | [diff] [blame] | 2411 | printfd(tcp, tcp->u_arg[0]); |
Dmitry V. Levin | 7845a42 | 2014-04-17 13:32:47 +0000 | [diff] [blame] | 2412 | argn = printllval_aligned(tcp, ", %lld", 1); |
Andreas Schwab | b5600fc | 2009-11-04 17:08:34 +0100 | [diff] [blame] | 2413 | tprintf(", %ld, ", tcp->u_arg[argn++]); |
| 2414 | printxval(advise, tcp->u_arg[argn], "POSIX_FADV_???"); |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 2415 | } |
| 2416 | return 0; |
Roland McGrath | df13e8f | 2004-10-07 18:51:19 +0000 | [diff] [blame] | 2417 | } |
Roland McGrath | df13e8f | 2004-10-07 18:51:19 +0000 | [diff] [blame] | 2418 | |
Roland McGrath | df13e8f | 2004-10-07 18:51:19 +0000 | [diff] [blame] | 2419 | int |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 2420 | sys_fadvise64_64(struct tcb *tcp) |
Roland McGrath | df13e8f | 2004-10-07 18:51:19 +0000 | [diff] [blame] | 2421 | { |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 2422 | if (entering(tcp)) { |
Andreas Schwab | b5600fc | 2009-11-04 17:08:34 +0100 | [diff] [blame] | 2423 | int argn; |
Dmitry V. Levin | 3138213 | 2011-03-04 05:08:02 +0300 | [diff] [blame] | 2424 | printfd(tcp, tcp->u_arg[0]); |
Dmitry V. Levin | 7845a42 | 2014-04-17 13:32:47 +0000 | [diff] [blame] | 2425 | argn = printllval_aligned(tcp, ", %lld, ", 1); |
| 2426 | argn = printllval_aligned(tcp, "%lld, ", argn); |
Dmitry V. Levin | 8e096c4 | 2013-05-06 18:23:01 +0000 | [diff] [blame] | 2427 | #if defined __ARM_EABI__ || defined AARCH64 || defined POWERPC || defined XTENSA |
Kirill A. Shutemov | 896db21 | 2009-09-19 03:21:33 +0300 | [diff] [blame] | 2428 | printxval(advise, tcp->u_arg[1], "POSIX_FADV_???"); |
Roland McGrath | df13e8f | 2004-10-07 18:51:19 +0000 | [diff] [blame] | 2429 | #else |
Andreas Schwab | b5600fc | 2009-11-04 17:08:34 +0100 | [diff] [blame] | 2430 | printxval(advise, tcp->u_arg[argn], "POSIX_FADV_???"); |
Roland McGrath | df13e8f | 2004-10-07 18:51:19 +0000 | [diff] [blame] | 2431 | #endif |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 2432 | } |
| 2433 | return 0; |
Roland McGrath | df13e8f | 2004-10-07 18:51:19 +0000 | [diff] [blame] | 2434 | } |
Dmitry V. Levin | 95ebf5a | 2006-10-13 20:25:12 +0000 | [diff] [blame] | 2435 | |
Dmitry V. Levin | 0ed617b | 2014-04-25 23:30:54 +0000 | [diff] [blame^] | 2436 | #include "xlat/sync_file_range_flags.h" |
William Manley | 16b9dcf | 2013-08-09 18:04:11 +0100 | [diff] [blame] | 2437 | |
| 2438 | int |
| 2439 | sys_sync_file_range(struct tcb *tcp) |
| 2440 | { |
| 2441 | if (entering(tcp)) { |
| 2442 | int argn; |
| 2443 | printfd(tcp, tcp->u_arg[0]); |
Dmitry V. Levin | 7845a42 | 2014-04-17 13:32:47 +0000 | [diff] [blame] | 2444 | argn = printllval_aligned(tcp, ", %lld, ", 1); |
| 2445 | argn = printllval_aligned(tcp, "%lld, ", argn); |
William Manley | 16b9dcf | 2013-08-09 18:04:11 +0100 | [diff] [blame] | 2446 | printflags(sync_file_range_flags, tcp->u_arg[argn], |
| 2447 | "SYNC_FILE_RANGE_???"); |
| 2448 | } |
| 2449 | return 0; |
| 2450 | } |
| 2451 | |
| 2452 | int |
| 2453 | sys_sync_file_range2(struct tcb *tcp) |
| 2454 | { |
| 2455 | if (entering(tcp)) { |
| 2456 | int argn; |
| 2457 | printfd(tcp, tcp->u_arg[0]); |
| 2458 | printflags(sync_file_range_flags, 1, |
| 2459 | "SYNC_FILE_RANGE_???"); |
Dmitry V. Levin | 7845a42 | 2014-04-17 13:32:47 +0000 | [diff] [blame] | 2460 | argn = printllval_aligned(tcp, ", %lld, ", 2); |
| 2461 | argn = printllval_aligned(tcp, "%lld, ", argn); |
William Manley | 16b9dcf | 2013-08-09 18:04:11 +0100 | [diff] [blame] | 2462 | } |
| 2463 | return 0; |
| 2464 | } |
| 2465 | |
Mark Wielaard | bab8940 | 2010-03-21 14:41:26 +0100 | [diff] [blame] | 2466 | int |
Roland McGrath | 96a9661 | 2008-05-20 04:56:18 +0000 | [diff] [blame] | 2467 | sys_fallocate(struct tcb *tcp) |
| 2468 | { |
| 2469 | if (entering(tcp)) { |
Andreas Schwab | b5600fc | 2009-11-04 17:08:34 +0100 | [diff] [blame] | 2470 | int argn; |
Dmitry V. Levin | 3138213 | 2011-03-04 05:08:02 +0300 | [diff] [blame] | 2471 | printfd(tcp, tcp->u_arg[0]); /* fd */ |
Denys Vlasenko | d33e72a | 2012-05-18 02:03:24 +0200 | [diff] [blame] | 2472 | tprintf(", %#lo, ", tcp->u_arg[1]); /* mode */ |
Dmitry V. Levin | 7845a42 | 2014-04-17 13:32:47 +0000 | [diff] [blame] | 2473 | argn = printllval_aligned(tcp, "%llu, ", 2); /* offset */ |
| 2474 | printllval_aligned(tcp, "%llu", argn); /* len */ |
Roland McGrath | 96a9661 | 2008-05-20 04:56:18 +0000 | [diff] [blame] | 2475 | } |
| 2476 | return 0; |
| 2477 | } |
Dmitry V. Levin | 8829365 | 2012-03-09 21:02:19 +0000 | [diff] [blame] | 2478 | |
Dmitry V. Levin | ad0c01e | 2012-03-15 00:52:22 +0000 | [diff] [blame] | 2479 | #ifndef SWAP_FLAG_PREFER |
| 2480 | # define SWAP_FLAG_PREFER 0x8000 |
| 2481 | #endif |
| 2482 | #ifndef SWAP_FLAG_DISCARD |
| 2483 | # define SWAP_FLAG_DISCARD 0x10000 |
| 2484 | #endif |
Dmitry V. Levin | 0ed617b | 2014-04-25 23:30:54 +0000 | [diff] [blame^] | 2485 | #include "xlat/swap_flags.h" |
Dmitry V. Levin | 8829365 | 2012-03-09 21:02:19 +0000 | [diff] [blame] | 2486 | |
| 2487 | int |
| 2488 | sys_swapon(struct tcb *tcp) |
| 2489 | { |
| 2490 | if (entering(tcp)) { |
| 2491 | int flags = tcp->u_arg[1]; |
| 2492 | printpath(tcp, tcp->u_arg[0]); |
| 2493 | tprints(", "); |
| 2494 | printflags(swap_flags, flags & ~SWAP_FLAG_PRIO_MASK, |
| 2495 | "SWAP_FLAG_???"); |
| 2496 | if (flags & SWAP_FLAG_PREFER) |
| 2497 | tprintf("|%d", flags & SWAP_FLAG_PRIO_MASK); |
| 2498 | } |
| 2499 | return 0; |
| 2500 | } |