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