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