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