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