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