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