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