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