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