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 | |
John Hughes | bdf48f5 | 2001-03-06 15:08:09 +0000 | [diff] [blame^] | 414 | #if _LFS_LARGEFILE |
| 415 | int |
| 416 | sys_lseek64 (tcp) |
| 417 | struct tcb *tcp; |
| 418 | { |
| 419 | if (entering(tcp)) { |
| 420 | long long offset = get64(tcp->u_arg [1], tcp->u_arg[2]); |
| 421 | if (tcp->u_arg[3] == SEEK_SET) |
| 422 | tprintf("%ld, %llu, ", tcp->u_arg[0], offset); |
| 423 | else |
| 424 | tprintf("%ld, %lld, ", tcp->u_arg[0], offset); |
| 425 | printxval(whence, tcp->u_arg[3], "SEEK_???"); |
| 426 | } |
| 427 | return RVAL_LUDECIMAL; |
| 428 | } |
| 429 | #endif |
| 430 | |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 431 | int |
| 432 | sys_truncate(tcp) |
| 433 | struct tcb *tcp; |
| 434 | { |
| 435 | if (entering(tcp)) { |
| 436 | printpath(tcp, tcp->u_arg[0]); |
Wichert Akkerman | bf79f2e | 2000-09-01 21:03:06 +0000 | [diff] [blame] | 437 | #ifndef FREEBSD |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 438 | tprintf(", %lu", tcp->u_arg[1]); |
Wichert Akkerman | bf79f2e | 2000-09-01 21:03:06 +0000 | [diff] [blame] | 439 | #else |
| 440 | tprintf(", %llu", ((off_t) tcp->u_arg[1] << 32) + tcp->u_arg[2]); |
| 441 | #endif |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 442 | } |
| 443 | return 0; |
| 444 | } |
| 445 | |
| 446 | int |
| 447 | sys_ftruncate(tcp) |
| 448 | struct tcb *tcp; |
| 449 | { |
| 450 | if (entering(tcp)) { |
Wichert Akkerman | bf79f2e | 2000-09-01 21:03:06 +0000 | [diff] [blame] | 451 | #ifndef FREEBSD |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 452 | tprintf("%ld, %lu", tcp->u_arg[0], tcp->u_arg[1]); |
Wichert Akkerman | bf79f2e | 2000-09-01 21:03:06 +0000 | [diff] [blame] | 453 | #else |
| 454 | tprintf("%ld, %llu", tcp->u_arg[0], |
| 455 | ((off_t) tcp->u_arg[1] << 32) + tcp->u_arg[2]); |
| 456 | #endif |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 457 | } |
| 458 | return 0; |
| 459 | } |
| 460 | |
| 461 | /* several stats */ |
| 462 | |
| 463 | static struct xlat modetypes[] = { |
| 464 | { S_IFREG, "S_IFREG" }, |
| 465 | { S_IFSOCK, "S_IFSOCK" }, |
| 466 | { S_IFIFO, "S_IFIFO" }, |
| 467 | { S_IFLNK, "S_IFLNK" }, |
| 468 | { S_IFDIR, "S_IFDIR" }, |
| 469 | { S_IFBLK, "S_IFBLK" }, |
| 470 | { S_IFCHR, "S_IFCHR" }, |
| 471 | { 0, NULL }, |
| 472 | }; |
| 473 | |
| 474 | static char * |
| 475 | sprintmode(mode) |
| 476 | int mode; |
| 477 | { |
| 478 | static char buf[64]; |
| 479 | char *s; |
| 480 | |
| 481 | if ((mode & S_IFMT) == 0) |
| 482 | s = ""; |
| 483 | else if ((s = xlookup(modetypes, mode & S_IFMT)) == NULL) { |
| 484 | sprintf(buf, "%#o", mode); |
| 485 | return buf; |
| 486 | } |
| 487 | sprintf(buf, "%s%s%s%s", s, |
| 488 | (mode & S_ISUID) ? "|S_ISUID" : "", |
| 489 | (mode & S_ISGID) ? "|S_ISGID" : "", |
| 490 | (mode & S_ISVTX) ? "|S_ISVTX" : ""); |
| 491 | mode &= ~(S_IFMT|S_ISUID|S_ISGID|S_ISVTX); |
| 492 | if (mode) |
| 493 | sprintf(buf + strlen(buf), "|%#o", mode); |
| 494 | s = (*buf == '|') ? buf + 1 : buf; |
| 495 | return *s ? s : "0"; |
| 496 | } |
| 497 | |
| 498 | static char * |
| 499 | sprinttime(t) |
| 500 | time_t t; |
| 501 | { |
| 502 | struct tm *tmp; |
| 503 | static char buf[32]; |
| 504 | |
| 505 | if (t == 0) { |
| 506 | sprintf(buf, "0"); |
| 507 | return buf; |
| 508 | } |
| 509 | tmp = localtime(&t); |
| 510 | sprintf(buf, "%02d/%02d/%02d-%02d:%02d:%02d", |
Wichert Akkerman | 3ed6dc2 | 2000-01-11 14:41:09 +0000 | [diff] [blame] | 511 | tmp->tm_year + 1900, tmp->tm_mon + 1, tmp->tm_mday, |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 512 | tmp->tm_hour, tmp->tm_min, tmp->tm_sec); |
| 513 | return buf; |
| 514 | } |
| 515 | |
| 516 | #ifdef LINUXSPARC |
| 517 | typedef struct { |
| 518 | int tv_sec; |
| 519 | int tv_nsec; |
| 520 | } timestruct_t; |
| 521 | |
| 522 | struct solstat { |
| 523 | unsigned st_dev; |
| 524 | int st_pad1[3]; /* network id */ |
| 525 | unsigned st_ino; |
| 526 | unsigned st_mode; |
| 527 | unsigned st_nlink; |
| 528 | unsigned st_uid; |
| 529 | unsigned st_gid; |
| 530 | unsigned st_rdev; |
| 531 | int st_pad2[2]; |
| 532 | int st_size; |
| 533 | int st_pad3; /* st_size, off_t expansion */ |
| 534 | timestruct_t st_atime; |
| 535 | timestruct_t st_mtime; |
| 536 | timestruct_t st_ctime; |
| 537 | int st_blksize; |
| 538 | int st_blocks; |
| 539 | char st_fstype[16]; |
| 540 | int st_pad4[8]; /* expansion area */ |
| 541 | }; |
| 542 | |
| 543 | static void |
| 544 | printstatsol(tcp, addr) |
| 545 | struct tcb *tcp; |
Wichert Akkerman | 8b1b40c | 2000-02-03 21:58:30 +0000 | [diff] [blame] | 546 | long addr; |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 547 | { |
| 548 | struct solstat statbuf; |
| 549 | |
| 550 | if (!addr) { |
| 551 | tprintf("NULL"); |
| 552 | return; |
| 553 | } |
| 554 | if (syserror(tcp) || !verbose(tcp)) { |
Wichert Akkerman | 8b1b40c | 2000-02-03 21:58:30 +0000 | [diff] [blame] | 555 | tprintf("%#lx", addr); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 556 | return; |
| 557 | } |
| 558 | if (umove(tcp, addr, &statbuf) < 0) { |
| 559 | tprintf("{...}"); |
| 560 | return; |
| 561 | } |
| 562 | if (!abbrev(tcp)) { |
| 563 | tprintf("{st_dev=makedev(%lu, %lu), st_ino=%lu, st_mode=%s, ", |
| 564 | (unsigned long) ((statbuf.st_dev >> 18) & 0x3fff), |
| 565 | (unsigned long) (statbuf.st_dev & 0x3ffff), |
| 566 | (unsigned long) statbuf.st_ino, |
| 567 | sprintmode(statbuf.st_mode)); |
| 568 | tprintf("st_nlink=%lu, st_uid=%lu, st_gid=%lu, ", |
| 569 | (unsigned long) statbuf.st_nlink, |
| 570 | (unsigned long) statbuf.st_uid, |
| 571 | (unsigned long) statbuf.st_gid); |
| 572 | tprintf("st_blksize=%lu, ", (unsigned long) statbuf.st_blksize); |
| 573 | tprintf("st_blocks=%lu, ", (unsigned long) statbuf.st_blocks); |
| 574 | } |
| 575 | else |
| 576 | tprintf("{st_mode=%s, ", sprintmode(statbuf.st_mode)); |
| 577 | switch (statbuf.st_mode & S_IFMT) { |
| 578 | case S_IFCHR: case S_IFBLK: |
| 579 | tprintf("st_rdev=makedev(%lu, %lu), ", |
| 580 | (unsigned long) ((statbuf.st_rdev >> 18) & 0x3fff), |
| 581 | (unsigned long) (statbuf.st_rdev & 0x3ffff)); |
| 582 | break; |
| 583 | default: |
| 584 | tprintf("st_size=%u, ", statbuf.st_size); |
| 585 | break; |
| 586 | } |
| 587 | if (!abbrev(tcp)) { |
| 588 | tprintf("st_atime=%s, ", sprinttime(statbuf.st_atime)); |
| 589 | tprintf("st_mtime=%s, ", sprinttime(statbuf.st_mtime)); |
| 590 | tprintf("st_ctime=%s}", sprinttime(statbuf.st_ctime)); |
| 591 | } |
| 592 | else |
| 593 | tprintf("...}"); |
| 594 | } |
Wichert Akkerman | b859bea | 1999-04-18 22:50:50 +0000 | [diff] [blame] | 595 | #endif /* LINUXSPARC */ |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 596 | |
Wichert Akkerman | bf79f2e | 2000-09-01 21:03:06 +0000 | [diff] [blame] | 597 | #ifdef FREEBSD |
| 598 | static struct xlat fileflags[] = { |
| 599 | { UF_NODUMP, "UF_NODUMP" }, |
| 600 | { UF_IMMUTABLE, "UF_IMMUTABLE" }, |
| 601 | { UF_APPEND, "UF_APPEND" }, |
| 602 | { UF_OPAQUE, "UF_OPAQUE" }, |
| 603 | { UF_NOUNLINK, "UF_NOUNLINK" }, |
| 604 | { SF_ARCHIVED, "SF_ARCHIVED" }, |
| 605 | { SF_IMMUTABLE, "SF_IMMUTABLE" }, |
| 606 | { SF_APPEND, "SF_APPEND" }, |
| 607 | { SF_NOUNLINK, "SF_NOUNLINK" }, |
| 608 | { 0, NULL }, |
| 609 | }; |
| 610 | |
| 611 | int |
| 612 | sys_chflags(tcp) |
| 613 | struct tcb *tcp; |
| 614 | { |
| 615 | if (entering(tcp)) { |
| 616 | printpath(tcp, tcp->u_arg[0]); |
| 617 | tprintf(", "); |
| 618 | if (tcp->u_arg[1]) |
| 619 | printflags(fileflags, tcp->u_arg[1]); |
| 620 | else |
| 621 | tprintf("0"); |
| 622 | } |
| 623 | return 0; |
| 624 | } |
| 625 | |
| 626 | int |
| 627 | sys_fchflags(tcp) |
| 628 | struct tcb *tcp; |
| 629 | { |
| 630 | if (entering(tcp)) { |
| 631 | tprintf("%ld, ", tcp->u_arg[0]); |
| 632 | if (tcp->u_arg[1]) |
| 633 | printflags(fileflags, tcp->u_arg[1]); |
| 634 | else |
| 635 | tprintf("0"); |
| 636 | } |
| 637 | return 0; |
| 638 | } |
| 639 | #endif |
| 640 | |
Wichert Akkerman | 328c5e7 | 1999-04-16 00:21:26 +0000 | [diff] [blame] | 641 | static void |
| 642 | realprintstat(tcp, statbuf) |
| 643 | struct tcb *tcp; |
Wichert Akkerman | 328c5e7 | 1999-04-16 00:21:26 +0000 | [diff] [blame] | 644 | struct stat *statbuf; |
Wichert Akkerman | 328c5e7 | 1999-04-16 00:21:26 +0000 | [diff] [blame] | 645 | { |
| 646 | if (!abbrev(tcp)) { |
| 647 | tprintf("{st_dev=makedev(%lu, %lu), st_ino=%lu, st_mode=%s, ", |
| 648 | (unsigned long) major(statbuf->st_dev), |
| 649 | (unsigned long) minor(statbuf->st_dev), |
| 650 | (unsigned long) statbuf->st_ino, |
| 651 | sprintmode(statbuf->st_mode)); |
| 652 | tprintf("st_nlink=%lu, st_uid=%lu, st_gid=%lu, ", |
| 653 | (unsigned long) statbuf->st_nlink, |
| 654 | (unsigned long) statbuf->st_uid, |
| 655 | (unsigned long) statbuf->st_gid); |
| 656 | #ifdef HAVE_ST_BLKSIZE |
| 657 | tprintf("st_blksize=%lu, ", (unsigned long) statbuf->st_blksize); |
| 658 | #endif /* HAVE_ST_BLKSIZE */ |
| 659 | #ifdef HAVE_ST_BLOCKS |
| 660 | tprintf("st_blocks=%lu, ", (unsigned long) statbuf->st_blocks); |
| 661 | #endif /* HAVE_ST_BLOCKS */ |
| 662 | } |
| 663 | else |
| 664 | tprintf("{st_mode=%s, ", sprintmode(statbuf->st_mode)); |
| 665 | switch (statbuf->st_mode & S_IFMT) { |
| 666 | case S_IFCHR: case S_IFBLK: |
| 667 | #ifdef HAVE_ST_RDEV |
| 668 | tprintf("st_rdev=makedev(%lu, %lu), ", |
| 669 | (unsigned long) major(statbuf->st_rdev), |
| 670 | (unsigned long) minor(statbuf->st_rdev)); |
| 671 | #else /* !HAVE_ST_RDEV */ |
| 672 | tprintf("st_size=makedev(%lu, %lu), ", |
| 673 | (unsigned long) major(statbuf->st_size), |
| 674 | (unsigned long) minor(statbuf->st_size)); |
| 675 | #endif /* !HAVE_ST_RDEV */ |
| 676 | break; |
| 677 | default: |
| 678 | tprintf("st_size=%lu, ", statbuf->st_size); |
| 679 | break; |
| 680 | } |
| 681 | if (!abbrev(tcp)) { |
| 682 | tprintf("st_atime=%s, ", sprinttime(statbuf->st_atime)); |
| 683 | tprintf("st_mtime=%s, ", sprinttime(statbuf->st_mtime)); |
Wichert Akkerman | bf79f2e | 2000-09-01 21:03:06 +0000 | [diff] [blame] | 684 | #ifndef FREEBSD |
Wichert Akkerman | 328c5e7 | 1999-04-16 00:21:26 +0000 | [diff] [blame] | 685 | tprintf("st_ctime=%s}", sprinttime(statbuf->st_ctime)); |
Wichert Akkerman | bf79f2e | 2000-09-01 21:03:06 +0000 | [diff] [blame] | 686 | #else /* FREEBSD */ |
| 687 | tprintf("st_ctime=%s, ", sprinttime(statbuf->st_ctime)); |
| 688 | tprintf("st_flags="); |
| 689 | if (statbuf->st_flags) { |
| 690 | printflags(fileflags, statbuf->st_flags); |
| 691 | } else |
| 692 | tprintf("0"); |
| 693 | tprintf(", st_gen=%u}", statbuf->st_gen); |
| 694 | #endif /* FREEBSD */ |
Wichert Akkerman | 328c5e7 | 1999-04-16 00:21:26 +0000 | [diff] [blame] | 695 | } |
| 696 | else |
| 697 | tprintf("...}"); |
| 698 | } |
| 699 | |
Nate Sammons | 771a6ff | 1999-04-05 22:39:31 +0000 | [diff] [blame] | 700 | |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 701 | static void |
| 702 | printstat(tcp, addr) |
| 703 | struct tcb *tcp; |
Wichert Akkerman | 8b1b40c | 2000-02-03 21:58:30 +0000 | [diff] [blame] | 704 | long addr; |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 705 | { |
Wichert Akkerman | 328c5e7 | 1999-04-16 00:21:26 +0000 | [diff] [blame] | 706 | struct stat statbuf; |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 707 | |
| 708 | #ifdef LINUXSPARC |
| 709 | if (current_personality == 1) { |
| 710 | printstatsol(tcp, addr); |
| 711 | return; |
| 712 | } |
| 713 | #endif /* LINUXSPARC */ |
| 714 | |
| 715 | if (!addr) { |
| 716 | tprintf("NULL"); |
| 717 | return; |
| 718 | } |
| 719 | if (syserror(tcp) || !verbose(tcp)) { |
Wichert Akkerman | 8b1b40c | 2000-02-03 21:58:30 +0000 | [diff] [blame] | 720 | tprintf("%#lx", addr); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 721 | return; |
| 722 | } |
| 723 | if (umove(tcp, addr, &statbuf) < 0) { |
| 724 | tprintf("{...}"); |
| 725 | return; |
| 726 | } |
Wichert Akkerman | 328c5e7 | 1999-04-16 00:21:26 +0000 | [diff] [blame] | 727 | |
| 728 | realprintstat(tcp, &statbuf); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 729 | } |
| 730 | |
Wichert Akkerman | c792698 | 2000-04-10 22:22:31 +0000 | [diff] [blame] | 731 | #ifdef HAVE_STAT64 |
Wichert Akkerman | 328c5e7 | 1999-04-16 00:21:26 +0000 | [diff] [blame] | 732 | static void |
Ulrich Drepper | 7f02c4d | 1999-12-24 08:01:34 +0000 | [diff] [blame] | 733 | printstat64(tcp, addr) |
| 734 | struct tcb *tcp; |
Wichert Akkerman | 8b1b40c | 2000-02-03 21:58:30 +0000 | [diff] [blame] | 735 | long addr; |
Ulrich Drepper | 7f02c4d | 1999-12-24 08:01:34 +0000 | [diff] [blame] | 736 | { |
| 737 | struct stat64 statbuf; |
| 738 | |
| 739 | #ifdef LINUXSPARC |
| 740 | if (current_personality == 1) { |
| 741 | printstatsol(tcp, addr); |
| 742 | return; |
| 743 | } |
| 744 | #endif /* LINUXSPARC */ |
| 745 | |
| 746 | if (!addr) { |
| 747 | tprintf("NULL"); |
| 748 | return; |
| 749 | } |
| 750 | if (syserror(tcp) || !verbose(tcp)) { |
Wichert Akkerman | 8b1b40c | 2000-02-03 21:58:30 +0000 | [diff] [blame] | 751 | tprintf("%#lx", addr); |
Ulrich Drepper | 7f02c4d | 1999-12-24 08:01:34 +0000 | [diff] [blame] | 752 | return; |
| 753 | } |
| 754 | if (umove(tcp, addr, &statbuf) < 0) { |
| 755 | tprintf("{...}"); |
| 756 | return; |
| 757 | } |
| 758 | |
| 759 | if (!abbrev(tcp)) { |
Wichert Akkerman | d077c45 | 2000-08-10 18:16:15 +0000 | [diff] [blame] | 760 | #ifdef HAVE_LONG_LONG |
| 761 | tprintf("{st_dev=makedev(%lu, %lu), st_ino=%llu, st_mode=%s, ", |
| 762 | #else |
Ulrich Drepper | 7f02c4d | 1999-12-24 08:01:34 +0000 | [diff] [blame] | 763 | tprintf("{st_dev=makedev(%lu, %lu), st_ino=%lu, st_mode=%s, ", |
Wichert Akkerman | d077c45 | 2000-08-10 18:16:15 +0000 | [diff] [blame] | 764 | #endif |
Ulrich Drepper | 7f02c4d | 1999-12-24 08:01:34 +0000 | [diff] [blame] | 765 | (unsigned long) major(statbuf.st_dev), |
| 766 | (unsigned long) minor(statbuf.st_dev), |
Wichert Akkerman | d077c45 | 2000-08-10 18:16:15 +0000 | [diff] [blame] | 767 | #ifdef HAVE_LONG_LONG |
| 768 | (unsigned long long) statbuf.st_ino, |
| 769 | #else |
Ulrich Drepper | 7f02c4d | 1999-12-24 08:01:34 +0000 | [diff] [blame] | 770 | (unsigned long) statbuf.st_ino, |
Wichert Akkerman | d077c45 | 2000-08-10 18:16:15 +0000 | [diff] [blame] | 771 | #endif |
Ulrich Drepper | 7f02c4d | 1999-12-24 08:01:34 +0000 | [diff] [blame] | 772 | sprintmode(statbuf.st_mode)); |
| 773 | tprintf("st_nlink=%lu, st_uid=%lu, st_gid=%lu, ", |
| 774 | (unsigned long) statbuf.st_nlink, |
| 775 | (unsigned long) statbuf.st_uid, |
| 776 | (unsigned long) statbuf.st_gid); |
| 777 | #ifdef HAVE_ST_BLKSIZE |
| 778 | tprintf("st_blksize=%lu, ", |
| 779 | (unsigned long) statbuf.st_blksize); |
| 780 | #endif /* HAVE_ST_BLKSIZE */ |
| 781 | #ifdef HAVE_ST_BLOCKS |
| 782 | tprintf("st_blocks=%lu, ", (unsigned long) statbuf.st_blocks); |
| 783 | #endif /* HAVE_ST_BLOCKS */ |
| 784 | } |
| 785 | else |
| 786 | tprintf("{st_mode=%s, ", sprintmode(statbuf.st_mode)); |
| 787 | switch (statbuf.st_mode & S_IFMT) { |
| 788 | case S_IFCHR: case S_IFBLK: |
| 789 | #ifdef HAVE_ST_RDEV |
| 790 | tprintf("st_rdev=makedev(%lu, %lu), ", |
| 791 | (unsigned long) major(statbuf.st_rdev), |
| 792 | (unsigned long) minor(statbuf.st_rdev)); |
| 793 | #else /* !HAVE_ST_RDEV */ |
| 794 | tprintf("st_size=makedev(%lu, %lu), ", |
| 795 | (unsigned long) major(statbuf.st_size), |
| 796 | (unsigned long) minor(statbuf.st_size)); |
| 797 | #endif /* !HAVE_ST_RDEV */ |
| 798 | break; |
| 799 | default: |
| 800 | tprintf("st_size=%llu, ", statbuf.st_size); |
| 801 | break; |
| 802 | } |
| 803 | if (!abbrev(tcp)) { |
| 804 | tprintf("st_atime=%s, ", sprinttime(statbuf.st_atime)); |
| 805 | tprintf("st_mtime=%s, ", sprinttime(statbuf.st_mtime)); |
| 806 | tprintf("st_ctime=%s}", sprinttime(statbuf.st_ctime)); |
| 807 | } |
| 808 | else |
| 809 | tprintf("...}"); |
| 810 | } |
Wichert Akkerman | c792698 | 2000-04-10 22:22:31 +0000 | [diff] [blame] | 811 | #endif /* HAVE_STAT64 */ |
Ulrich Drepper | 7f02c4d | 1999-12-24 08:01:34 +0000 | [diff] [blame] | 812 | |
Wichert Akkerman | 8b1b40c | 2000-02-03 21:58:30 +0000 | [diff] [blame] | 813 | #if defined(linux) && !defined(IA64) |
Ulrich Drepper | 7f02c4d | 1999-12-24 08:01:34 +0000 | [diff] [blame] | 814 | static void |
Wichert Akkerman | 328c5e7 | 1999-04-16 00:21:26 +0000 | [diff] [blame] | 815 | convertoldstat(oldbuf, newbuf) |
Wichert Akkerman | 25d0c4f | 1999-04-18 19:35:42 +0000 | [diff] [blame] | 816 | const struct __old_kernel_stat *oldbuf; |
| 817 | struct stat *newbuf; |
Wichert Akkerman | 328c5e7 | 1999-04-16 00:21:26 +0000 | [diff] [blame] | 818 | { |
| 819 | newbuf->st_dev=oldbuf->st_dev; |
| 820 | newbuf->st_ino=oldbuf->st_ino; |
| 821 | newbuf->st_mode=oldbuf->st_mode; |
| 822 | newbuf->st_nlink=oldbuf->st_nlink; |
| 823 | newbuf->st_uid=oldbuf->st_uid; |
| 824 | newbuf->st_gid=oldbuf->st_gid; |
| 825 | newbuf->st_rdev=oldbuf->st_rdev; |
| 826 | newbuf->st_size=oldbuf->st_size; |
| 827 | newbuf->st_atime=oldbuf->st_atime; |
| 828 | newbuf->st_mtime=oldbuf->st_mtime; |
| 829 | newbuf->st_ctime=oldbuf->st_ctime; |
| 830 | newbuf->st_blksize=0; /* not supported in old_stat */ |
| 831 | newbuf->st_blocks=0; /* not supported in old_stat */ |
| 832 | } |
Wichert Akkerman | 328c5e7 | 1999-04-16 00:21:26 +0000 | [diff] [blame] | 833 | |
| 834 | |
Wichert Akkerman | 328c5e7 | 1999-04-16 00:21:26 +0000 | [diff] [blame] | 835 | static void |
| 836 | printoldstat(tcp, addr) |
| 837 | struct tcb *tcp; |
Wichert Akkerman | 8b1b40c | 2000-02-03 21:58:30 +0000 | [diff] [blame] | 838 | long addr; |
Wichert Akkerman | 328c5e7 | 1999-04-16 00:21:26 +0000 | [diff] [blame] | 839 | { |
Wichert Akkerman | 25d0c4f | 1999-04-18 19:35:42 +0000 | [diff] [blame] | 840 | struct __old_kernel_stat statbuf; |
| 841 | struct stat newstatbuf; |
Wichert Akkerman | 328c5e7 | 1999-04-16 00:21:26 +0000 | [diff] [blame] | 842 | |
| 843 | #ifdef LINUXSPARC |
| 844 | if (current_personality == 1) { |
| 845 | printstatsol(tcp, addr); |
| 846 | return; |
| 847 | } |
| 848 | #endif /* LINUXSPARC */ |
| 849 | |
| 850 | if (!addr) { |
| 851 | tprintf("NULL"); |
| 852 | return; |
| 853 | } |
| 854 | if (syserror(tcp) || !verbose(tcp)) { |
Wichert Akkerman | 8b1b40c | 2000-02-03 21:58:30 +0000 | [diff] [blame] | 855 | tprintf("%#lx", addr); |
Wichert Akkerman | 328c5e7 | 1999-04-16 00:21:26 +0000 | [diff] [blame] | 856 | return; |
| 857 | } |
| 858 | if (umove(tcp, addr, &statbuf) < 0) { |
| 859 | tprintf("{...}"); |
| 860 | return; |
| 861 | } |
| 862 | |
| 863 | convertoldstat(&statbuf, &newstatbuf); |
| 864 | realprintstat(tcp, &newstatbuf); |
| 865 | } |
Wichert Akkerman | 8b1b40c | 2000-02-03 21:58:30 +0000 | [diff] [blame] | 866 | #endif /* linux && !IA64 */ |
Wichert Akkerman | 328c5e7 | 1999-04-16 00:21:26 +0000 | [diff] [blame] | 867 | |
| 868 | |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 869 | int |
| 870 | sys_stat(tcp) |
| 871 | struct tcb *tcp; |
| 872 | { |
| 873 | if (entering(tcp)) { |
| 874 | printpath(tcp, tcp->u_arg[0]); |
| 875 | tprintf(", "); |
| 876 | } else { |
| 877 | printstat(tcp, tcp->u_arg[1]); |
| 878 | } |
| 879 | return 0; |
| 880 | } |
| 881 | |
Wichert Akkerman | 328c5e7 | 1999-04-16 00:21:26 +0000 | [diff] [blame] | 882 | #ifdef linux |
| 883 | int |
Ulrich Drepper | 7f02c4d | 1999-12-24 08:01:34 +0000 | [diff] [blame] | 884 | sys_stat64(tcp) |
| 885 | struct tcb *tcp; |
| 886 | { |
| 887 | #ifdef HAVE_STAT64 |
| 888 | if (entering(tcp)) { |
| 889 | printpath(tcp, tcp->u_arg[0]); |
| 890 | tprintf(", "); |
| 891 | } else { |
| 892 | printstat64(tcp, tcp->u_arg[1]); |
| 893 | } |
| 894 | return 0; |
| 895 | #else |
| 896 | return printargs(tcp); |
| 897 | #endif |
| 898 | } |
| 899 | |
Wichert Akkerman | 8b1b40c | 2000-02-03 21:58:30 +0000 | [diff] [blame] | 900 | # if !defined(IA64) |
Ulrich Drepper | 7f02c4d | 1999-12-24 08:01:34 +0000 | [diff] [blame] | 901 | int |
Wichert Akkerman | 328c5e7 | 1999-04-16 00:21:26 +0000 | [diff] [blame] | 902 | sys_oldstat(tcp) |
| 903 | struct tcb *tcp; |
| 904 | { |
| 905 | if (entering(tcp)) { |
| 906 | printpath(tcp, tcp->u_arg[0]); |
| 907 | tprintf(", "); |
| 908 | } else { |
| 909 | printoldstat(tcp, tcp->u_arg[1]); |
| 910 | } |
| 911 | return 0; |
| 912 | } |
Wichert Akkerman | 8b1b40c | 2000-02-03 21:58:30 +0000 | [diff] [blame] | 913 | # endif /* !IA64 */ |
| 914 | #endif /* linux */ |
Wichert Akkerman | 328c5e7 | 1999-04-16 00:21:26 +0000 | [diff] [blame] | 915 | |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 916 | int |
| 917 | sys_fstat(tcp) |
| 918 | struct tcb *tcp; |
| 919 | { |
| 920 | if (entering(tcp)) |
| 921 | tprintf("%ld, ", tcp->u_arg[0]); |
| 922 | else { |
| 923 | printstat(tcp, tcp->u_arg[1]); |
| 924 | } |
| 925 | return 0; |
| 926 | } |
| 927 | |
Wichert Akkerman | 328c5e7 | 1999-04-16 00:21:26 +0000 | [diff] [blame] | 928 | #ifdef linux |
| 929 | int |
Ulrich Drepper | 7f02c4d | 1999-12-24 08:01:34 +0000 | [diff] [blame] | 930 | sys_fstat64(tcp) |
| 931 | struct tcb *tcp; |
| 932 | { |
| 933 | #ifdef HAVE_STAT64 |
| 934 | if (entering(tcp)) |
| 935 | tprintf("%ld, ", tcp->u_arg[0]); |
| 936 | else { |
| 937 | printstat64(tcp, tcp->u_arg[1]); |
| 938 | } |
| 939 | return 0; |
| 940 | #else |
| 941 | return printargs(tcp); |
| 942 | #endif |
| 943 | } |
| 944 | |
Wichert Akkerman | 8b1b40c | 2000-02-03 21:58:30 +0000 | [diff] [blame] | 945 | # if !defined(IA64) |
Ulrich Drepper | 7f02c4d | 1999-12-24 08:01:34 +0000 | [diff] [blame] | 946 | int |
Wichert Akkerman | 328c5e7 | 1999-04-16 00:21:26 +0000 | [diff] [blame] | 947 | sys_oldfstat(tcp) |
| 948 | struct tcb *tcp; |
| 949 | { |
| 950 | if (entering(tcp)) |
| 951 | tprintf("%ld, ", tcp->u_arg[0]); |
| 952 | else { |
| 953 | printoldstat(tcp, tcp->u_arg[1]); |
| 954 | } |
| 955 | return 0; |
| 956 | } |
Wichert Akkerman | 8b1b40c | 2000-02-03 21:58:30 +0000 | [diff] [blame] | 957 | # endif /* !IA64 */ |
Wichert Akkerman | 328c5e7 | 1999-04-16 00:21:26 +0000 | [diff] [blame] | 958 | #endif |
| 959 | |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 960 | int |
| 961 | sys_lstat(tcp) |
| 962 | struct tcb *tcp; |
| 963 | { |
| 964 | if (entering(tcp)) { |
| 965 | printpath(tcp, tcp->u_arg[0]); |
| 966 | tprintf(", "); |
| 967 | } else { |
| 968 | printstat(tcp, tcp->u_arg[1]); |
| 969 | } |
| 970 | return 0; |
| 971 | } |
| 972 | |
Wichert Akkerman | 328c5e7 | 1999-04-16 00:21:26 +0000 | [diff] [blame] | 973 | #ifdef linux |
| 974 | int |
Ulrich Drepper | 7f02c4d | 1999-12-24 08:01:34 +0000 | [diff] [blame] | 975 | sys_lstat64(tcp) |
| 976 | struct tcb *tcp; |
| 977 | { |
| 978 | #ifdef HAVE_STAT64 |
| 979 | if (entering(tcp)) { |
| 980 | printpath(tcp, tcp->u_arg[0]); |
| 981 | tprintf(", "); |
| 982 | } else { |
| 983 | printstat64(tcp, tcp->u_arg[1]); |
| 984 | } |
| 985 | return 0; |
| 986 | #else |
| 987 | return printargs(tcp); |
| 988 | #endif |
| 989 | } |
| 990 | |
Wichert Akkerman | 8b1b40c | 2000-02-03 21:58:30 +0000 | [diff] [blame] | 991 | # if !defined(IA64) |
Ulrich Drepper | 7f02c4d | 1999-12-24 08:01:34 +0000 | [diff] [blame] | 992 | int |
Wichert Akkerman | 328c5e7 | 1999-04-16 00:21:26 +0000 | [diff] [blame] | 993 | sys_oldlstat(tcp) |
| 994 | struct tcb *tcp; |
| 995 | { |
| 996 | if (entering(tcp)) { |
| 997 | printpath(tcp, tcp->u_arg[0]); |
| 998 | tprintf(", "); |
| 999 | } else { |
| 1000 | printoldstat(tcp, tcp->u_arg[1]); |
| 1001 | } |
| 1002 | return 0; |
| 1003 | } |
Wichert Akkerman | 8b1b40c | 2000-02-03 21:58:30 +0000 | [diff] [blame] | 1004 | # endif /* !IA64 */ |
Wichert Akkerman | 328c5e7 | 1999-04-16 00:21:26 +0000 | [diff] [blame] | 1005 | #endif |
| 1006 | |
| 1007 | |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1008 | #if defined(SVR4) || defined(LINUXSPARC) |
| 1009 | |
| 1010 | int |
| 1011 | sys_xstat(tcp) |
| 1012 | struct tcb *tcp; |
| 1013 | { |
| 1014 | if (entering(tcp)) { |
| 1015 | tprintf("%ld, ", tcp->u_arg[0]); |
| 1016 | printpath(tcp, tcp->u_arg[1]); |
| 1017 | tprintf(", "); |
| 1018 | } else { |
John Hughes | 8fe2c98 | 2001-03-06 09:45:18 +0000 | [diff] [blame] | 1019 | #ifdef _STAT64_VER |
| 1020 | if (tcp->u_arg[0] == _STAT64_VER) |
| 1021 | printstat64 (tcp, tcp->u_arg[2]); |
| 1022 | else |
| 1023 | #endif |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1024 | printstat(tcp, tcp->u_arg[2]); |
| 1025 | } |
| 1026 | return 0; |
| 1027 | } |
| 1028 | |
| 1029 | int |
| 1030 | sys_fxstat(tcp) |
| 1031 | struct tcb *tcp; |
| 1032 | { |
| 1033 | if (entering(tcp)) |
| 1034 | tprintf("%ld, %ld, ", tcp->u_arg[0], tcp->u_arg[1]); |
| 1035 | else { |
John Hughes | 8fe2c98 | 2001-03-06 09:45:18 +0000 | [diff] [blame] | 1036 | #ifdef _STAT64_VER |
| 1037 | if (tcp->u_arg[0] == _STAT64_VER) |
| 1038 | printstat64 (tcp, tcp->u_arg[2]); |
| 1039 | else |
| 1040 | #endif |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1041 | printstat(tcp, tcp->u_arg[2]); |
| 1042 | } |
| 1043 | return 0; |
| 1044 | } |
| 1045 | |
| 1046 | int |
| 1047 | sys_lxstat(tcp) |
| 1048 | struct tcb *tcp; |
| 1049 | { |
| 1050 | if (entering(tcp)) { |
| 1051 | tprintf("%ld, ", tcp->u_arg[0]); |
| 1052 | printpath(tcp, tcp->u_arg[1]); |
| 1053 | tprintf(", "); |
| 1054 | } else { |
John Hughes | 8fe2c98 | 2001-03-06 09:45:18 +0000 | [diff] [blame] | 1055 | #ifdef _STAT64_VER |
| 1056 | if (tcp->u_arg[0] == _STAT64_VER) |
| 1057 | printstat64 (tcp, tcp->u_arg[2]); |
| 1058 | else |
| 1059 | #endif |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1060 | printstat(tcp, tcp->u_arg[2]); |
| 1061 | } |
| 1062 | return 0; |
| 1063 | } |
| 1064 | |
| 1065 | int |
| 1066 | sys_xmknod(tcp) |
| 1067 | struct tcb *tcp; |
| 1068 | { |
| 1069 | int mode = tcp->u_arg[2]; |
| 1070 | |
| 1071 | if (entering(tcp)) { |
| 1072 | tprintf("%ld, ", tcp->u_arg[0]); |
| 1073 | printpath(tcp, tcp->u_arg[1]); |
| 1074 | tprintf(", %s", sprintmode(mode)); |
| 1075 | switch (mode & S_IFMT) { |
| 1076 | case S_IFCHR: case S_IFBLK: |
| 1077 | #ifdef LINUXSPARC |
| 1078 | tprintf(", makedev(%lu, %lu)", |
| 1079 | (unsigned long) ((tcp->u_arg[3] >> 18) & 0x3fff), |
| 1080 | (unsigned long) (tcp->u_arg[3] & 0x3ffff)); |
| 1081 | #else |
| 1082 | tprintf(", makedev(%lu, %lu)", |
| 1083 | (unsigned long) major(tcp->u_arg[3]), |
| 1084 | (unsigned long) minor(tcp->u_arg[3])); |
| 1085 | #endif |
| 1086 | break; |
| 1087 | default: |
| 1088 | break; |
| 1089 | } |
| 1090 | } |
| 1091 | return 0; |
| 1092 | } |
| 1093 | |
Wichert Akkerman | 8829a55 | 1999-06-11 13:18:40 +0000 | [diff] [blame] | 1094 | #ifdef HAVE_SYS_ACL_H |
| 1095 | |
| 1096 | #include <sys/acl.h> |
| 1097 | |
| 1098 | struct xlat aclcmds[] = { |
Wichert Akkerman | e4aafd4 | 1999-11-26 09:54:08 +0000 | [diff] [blame] | 1099 | #ifdef SETACL |
Wichert Akkerman | 8829a55 | 1999-06-11 13:18:40 +0000 | [diff] [blame] | 1100 | { SETACL, "SETACL" }, |
Wichert Akkerman | e4aafd4 | 1999-11-26 09:54:08 +0000 | [diff] [blame] | 1101 | #endif |
| 1102 | #ifdef GETACL |
Wichert Akkerman | 8829a55 | 1999-06-11 13:18:40 +0000 | [diff] [blame] | 1103 | { GETACL, "GETACL" }, |
Wichert Akkerman | e4aafd4 | 1999-11-26 09:54:08 +0000 | [diff] [blame] | 1104 | #endif |
| 1105 | #ifdef GETACLCNT |
Wichert Akkerman | 8829a55 | 1999-06-11 13:18:40 +0000 | [diff] [blame] | 1106 | { GETACLCNT, "GETACLCNT" }, |
Wichert Akkerman | e4aafd4 | 1999-11-26 09:54:08 +0000 | [diff] [blame] | 1107 | #endif |
| 1108 | #ifdef ACL_GET |
| 1109 | { ACL_GET, "ACL_GET" }, |
| 1110 | #endif |
| 1111 | #ifdef ACL_SET |
| 1112 | { ACL_SET, "ACL_SET" }, |
| 1113 | #endif |
| 1114 | #ifdef ACL_CNT |
| 1115 | { ACL_CNT, "ACL_CNT" }, |
| 1116 | #endif |
Wichert Akkerman | 8829a55 | 1999-06-11 13:18:40 +0000 | [diff] [blame] | 1117 | { 0, NULL }, |
| 1118 | }; |
| 1119 | |
| 1120 | int |
| 1121 | sys_acl(tcp) |
| 1122 | struct tcb *tcp; |
| 1123 | { |
| 1124 | if (entering(tcp)) { |
| 1125 | printpath(tcp, tcp->u_arg[0]); |
| 1126 | tprintf(", "); |
| 1127 | printxval(aclcmds, tcp->u_arg[1], "???ACL???"); |
| 1128 | tprintf(", %ld", tcp->u_arg[2]); |
| 1129 | /* |
| 1130 | * FIXME - dump out the list of aclent_t's pointed to |
| 1131 | * by "tcp->u_arg[3]" if it's not NULL. |
| 1132 | */ |
| 1133 | if (tcp->u_arg[3]) |
| 1134 | tprintf(", %#lx", tcp->u_arg[3]); |
| 1135 | else |
| 1136 | tprintf(", NULL"); |
| 1137 | } |
| 1138 | return 0; |
| 1139 | } |
| 1140 | |
| 1141 | |
| 1142 | int |
| 1143 | sys_facl(tcp) |
| 1144 | struct tcb *tcp; |
| 1145 | { |
| 1146 | if (entering(tcp)) { |
| 1147 | tprintf("%ld, ", tcp->u_arg[0]); |
| 1148 | printxval(aclcmds, tcp->u_arg[1], "???ACL???"); |
| 1149 | tprintf(", %ld", tcp->u_arg[2]); |
| 1150 | /* |
| 1151 | * FIXME - dump out the list of aclent_t's pointed to |
| 1152 | * by "tcp->u_arg[3]" if it's not NULL. |
| 1153 | */ |
| 1154 | if (tcp->u_arg[3]) |
| 1155 | tprintf(", %#lx", tcp->u_arg[3]); |
| 1156 | else |
| 1157 | tprintf(", NULL"); |
| 1158 | } |
| 1159 | return 0; |
| 1160 | } |
| 1161 | |
Wichert Akkerman | e4aafd4 | 1999-11-26 09:54:08 +0000 | [diff] [blame] | 1162 | |
| 1163 | struct xlat aclipc[] = { |
| 1164 | #ifdef IPC_SHM |
| 1165 | { IPC_SHM, "IPC_SHM" }, |
| 1166 | #endif |
| 1167 | #ifdef IPC_SEM |
| 1168 | { IPC_SEM, "IPC_SEM" }, |
| 1169 | #endif |
| 1170 | #ifdef IPC_MSG |
| 1171 | { IPC_MSG, "IPC_MSG" }, |
| 1172 | #endif |
| 1173 | { 0, NULL }, |
| 1174 | }; |
| 1175 | |
| 1176 | |
| 1177 | int |
| 1178 | sys_aclipc(tcp) |
| 1179 | struct tcb *tcp; |
| 1180 | { |
| 1181 | if (entering(tcp)) { |
| 1182 | printxval(aclipc, tcp->u_arg[0], "???IPC???"); |
| 1183 | tprintf(", %#lx, ", tcp->u_arg[1]); |
| 1184 | printxval(aclcmds, tcp->u_arg[2], "???ACL???"); |
| 1185 | tprintf(", %ld", tcp->u_arg[3]); |
| 1186 | /* |
| 1187 | * FIXME - dump out the list of aclent_t's pointed to |
| 1188 | * by "tcp->u_arg[4]" if it's not NULL. |
| 1189 | */ |
| 1190 | if (tcp->u_arg[4]) |
| 1191 | tprintf(", %#lx", tcp->u_arg[4]); |
| 1192 | else |
| 1193 | tprintf(", NULL"); |
| 1194 | } |
| 1195 | return 0; |
| 1196 | } |
| 1197 | |
| 1198 | |
| 1199 | |
Wichert Akkerman | 8829a55 | 1999-06-11 13:18:40 +0000 | [diff] [blame] | 1200 | #endif /* HAVE_SYS_ACL_H */ |
| 1201 | |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1202 | #endif /* SVR4 || LINUXSPARC */ |
| 1203 | |
Wichert Akkerman | 328c5e7 | 1999-04-16 00:21:26 +0000 | [diff] [blame] | 1204 | #ifdef linux |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1205 | |
| 1206 | static struct xlat fsmagic[] = { |
Wichert Akkerman | 43a7482 | 2000-06-27 17:33:32 +0000 | [diff] [blame] | 1207 | { 0x73757245, "CODA_SUPER_MAGIC" }, |
| 1208 | { 0x012ff7b7, "COH_SUPER_MAGIC" }, |
| 1209 | { 0x1373, "DEVFS_SUPER_MAGIC" }, |
| 1210 | { 0x1cd1, "DEVPTS_SUPER_MAGIC" }, |
| 1211 | { 0x414A53, "EFS_SUPER_MAGIC" }, |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1212 | { 0xef51, "EXT2_OLD_SUPER_MAGIC" }, |
| 1213 | { 0xef53, "EXT2_SUPER_MAGIC" }, |
| 1214 | { 0x137d, "EXT_SUPER_MAGIC" }, |
Wichert Akkerman | 43a7482 | 2000-06-27 17:33:32 +0000 | [diff] [blame] | 1215 | { 0xf995e849, "HPFS_SUPER_MAGIC" }, |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1216 | { 0x9660, "ISOFS_SUPER_MAGIC" }, |
| 1217 | { 0x137f, "MINIX_SUPER_MAGIC" }, |
| 1218 | { 0x138f, "MINIX_SUPER_MAGIC2" }, |
Wichert Akkerman | 2e2553a | 1999-05-09 00:29:58 +0000 | [diff] [blame] | 1219 | { 0x2468, "MINIX2_SUPER_MAGIC" }, |
| 1220 | { 0x2478, "MINIX2_SUPER_MAGIC2" }, |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1221 | { 0x4d44, "MSDOS_SUPER_MAGIC" }, |
Wichert Akkerman | 43a7482 | 2000-06-27 17:33:32 +0000 | [diff] [blame] | 1222 | { 0x564c, "NCP_SUPER_MAGIC" }, |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1223 | { 0x6969, "NFS_SUPER_MAGIC" }, |
| 1224 | { 0x9fa0, "PROC_SUPER_MAGIC" }, |
Wichert Akkerman | 43a7482 | 2000-06-27 17:33:32 +0000 | [diff] [blame] | 1225 | { 0x002f, "QNX4_SUPER_MAGIC" }, |
| 1226 | { 0x52654973, "REISERFS_SUPER_MAGIC" }, |
| 1227 | { 0x02011994, "SHMFS_SUPER_MAGIC" }, |
| 1228 | { 0x517b, "SMB_SUPER_MAGIC" }, |
| 1229 | { 0x012ff7b6, "SYSV2_SUPER_MAGIC" }, |
| 1230 | { 0x012ff7b5, "SYSV4_SUPER_MAGIC" }, |
| 1231 | { 0x00011954, "UFS_MAGIC" }, |
| 1232 | { 0x54190100, "UFS_CIGAM" }, |
| 1233 | { 0x012ff7b4, "XENIX_SUPER_MAGIC" }, |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1234 | { 0x012fd16d, "XIAFS_SUPER_MAGIC" }, |
| 1235 | { 0, NULL }, |
| 1236 | }; |
| 1237 | |
Wichert Akkerman | 328c5e7 | 1999-04-16 00:21:26 +0000 | [diff] [blame] | 1238 | #endif /* linux */ |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1239 | |
| 1240 | #ifndef SVR4 |
| 1241 | |
| 1242 | static char * |
| 1243 | sprintfstype(magic) |
| 1244 | int magic; |
| 1245 | { |
| 1246 | static char buf[32]; |
Wichert Akkerman | 328c5e7 | 1999-04-16 00:21:26 +0000 | [diff] [blame] | 1247 | #ifdef linux |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1248 | char *s; |
| 1249 | |
| 1250 | s = xlookup(fsmagic, magic); |
| 1251 | if (s) { |
| 1252 | sprintf(buf, "\"%s\"", s); |
| 1253 | return buf; |
| 1254 | } |
Wichert Akkerman | 328c5e7 | 1999-04-16 00:21:26 +0000 | [diff] [blame] | 1255 | #endif /* linux */ |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1256 | sprintf(buf, "%#x", magic); |
| 1257 | return buf; |
| 1258 | } |
| 1259 | |
| 1260 | static void |
| 1261 | printstatfs(tcp, addr) |
| 1262 | struct tcb *tcp; |
| 1263 | long addr; |
| 1264 | { |
| 1265 | struct statfs statbuf; |
| 1266 | |
| 1267 | if (syserror(tcp) || !verbose(tcp)) { |
| 1268 | tprintf("%#lx", addr); |
| 1269 | return; |
| 1270 | } |
| 1271 | if (umove(tcp, addr, &statbuf) < 0) { |
| 1272 | tprintf("{...}"); |
| 1273 | return; |
| 1274 | } |
| 1275 | #ifdef ALPHA |
| 1276 | |
| 1277 | tprintf("{f_type=%s, f_fbsize=%u, f_blocks=%u, f_bfree=%u, ", |
| 1278 | sprintfstype(statbuf.f_type), |
| 1279 | statbuf.f_bsize, statbuf.f_blocks, statbuf.f_bfree); |
Wichert Akkerman | 2e2553a | 1999-05-09 00:29:58 +0000 | [diff] [blame] | 1280 | 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] | 1281 | statbuf.f_bavail,statbuf.f_files, statbuf.f_ffree, statbuf.f_namelen); |
| 1282 | #else /* !ALPHA */ |
| 1283 | tprintf("{f_type=%s, f_bsize=%lu, f_blocks=%lu, f_bfree=%lu, ", |
| 1284 | sprintfstype(statbuf.f_type), |
Nate Sammons | 5c74d20 | 1999-04-06 01:37:51 +0000 | [diff] [blame] | 1285 | (unsigned long)statbuf.f_bsize, |
| 1286 | (unsigned long)statbuf.f_blocks, |
| 1287 | (unsigned long)statbuf.f_bfree); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1288 | tprintf("f_files=%lu, f_ffree=%lu", |
Nate Sammons | 5c74d20 | 1999-04-06 01:37:51 +0000 | [diff] [blame] | 1289 | (unsigned long)statbuf.f_files, |
| 1290 | (unsigned long)statbuf.f_ffree); |
Wichert Akkerman | 328c5e7 | 1999-04-16 00:21:26 +0000 | [diff] [blame] | 1291 | #ifdef linux |
Wichert Akkerman | 2e2553a | 1999-05-09 00:29:58 +0000 | [diff] [blame] | 1292 | tprintf(", f_namelen=%lu", (unsigned long)statbuf.f_namelen); |
Wichert Akkerman | 328c5e7 | 1999-04-16 00:21:26 +0000 | [diff] [blame] | 1293 | #endif /* linux */ |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1294 | #endif /* !ALPHA */ |
| 1295 | tprintf("}"); |
| 1296 | } |
| 1297 | |
| 1298 | int |
| 1299 | sys_statfs(tcp) |
| 1300 | struct tcb *tcp; |
| 1301 | { |
| 1302 | if (entering(tcp)) { |
| 1303 | printpath(tcp, tcp->u_arg[0]); |
| 1304 | tprintf(", "); |
| 1305 | } else { |
| 1306 | printstatfs(tcp, tcp->u_arg[1]); |
| 1307 | } |
| 1308 | return 0; |
| 1309 | } |
| 1310 | |
| 1311 | int |
| 1312 | sys_fstatfs(tcp) |
| 1313 | struct tcb *tcp; |
| 1314 | { |
| 1315 | if (entering(tcp)) { |
| 1316 | tprintf("%lu, ", tcp->u_arg[0]); |
| 1317 | } else { |
| 1318 | printstatfs(tcp, tcp->u_arg[1]); |
| 1319 | } |
| 1320 | return 0; |
| 1321 | } |
| 1322 | |
Wichert Akkerman | a0f36c6 | 1999-04-16 14:01:34 +0000 | [diff] [blame] | 1323 | #if defined(linux) && defined(__alpha) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1324 | |
| 1325 | int |
| 1326 | osf_statfs(tcp) |
| 1327 | struct tcb *tcp; |
| 1328 | { |
| 1329 | if (entering(tcp)) { |
| 1330 | printpath(tcp, tcp->u_arg[0]); |
| 1331 | tprintf(", "); |
| 1332 | } else { |
| 1333 | printstatfs(tcp, tcp->u_arg[1]); |
| 1334 | tprintf(", %lu", tcp->u_arg[2]); |
| 1335 | } |
| 1336 | return 0; |
| 1337 | } |
| 1338 | |
| 1339 | int |
| 1340 | osf_fstatfs(tcp) |
| 1341 | struct tcb *tcp; |
| 1342 | { |
| 1343 | if (entering(tcp)) { |
| 1344 | tprintf("%lu, ", tcp->u_arg[0]); |
| 1345 | } else { |
| 1346 | printstatfs(tcp, tcp->u_arg[1]); |
| 1347 | tprintf(", %lu", tcp->u_arg[2]); |
| 1348 | } |
| 1349 | return 0; |
| 1350 | } |
Wichert Akkerman | a0f36c6 | 1999-04-16 14:01:34 +0000 | [diff] [blame] | 1351 | #endif /* linux && __alpha */ |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1352 | |
| 1353 | #endif /* !SVR4 */ |
| 1354 | |
| 1355 | #ifdef SUNOS4 |
| 1356 | |
| 1357 | int |
| 1358 | sys_ustat(tcp) |
| 1359 | struct tcb *tcp; |
| 1360 | { |
| 1361 | struct ustat statbuf; |
| 1362 | |
| 1363 | if (entering(tcp)) { |
| 1364 | tprintf("makedev(%lu, %lu), ", |
| 1365 | (long) major(tcp->u_arg[0]), |
| 1366 | (long) minor(tcp->u_arg[0])); |
| 1367 | } |
| 1368 | else { |
| 1369 | if (syserror(tcp) || !verbose(tcp)) |
| 1370 | tprintf("%#lx", tcp->u_arg[1]); |
| 1371 | else if (umove(tcp, tcp->u_arg[1], &statbuf) < 0) |
| 1372 | tprintf("{...}"); |
| 1373 | else { |
| 1374 | tprintf("{f_tfree=%lu, f_tinode=%lu, ", |
| 1375 | statbuf.f_tfree, statbuf.f_tinode); |
| 1376 | tprintf("f_fname=\"%.*s\", ", |
| 1377 | (int) sizeof(statbuf.f_fname), |
| 1378 | statbuf.f_fname); |
| 1379 | tprintf("f_fpack=\"%.*s\"}", |
| 1380 | (int) sizeof(statbuf.f_fpack), |
| 1381 | statbuf.f_fpack); |
| 1382 | } |
| 1383 | } |
| 1384 | return 0; |
| 1385 | } |
| 1386 | |
| 1387 | #endif /* SUNOS4 */ |
| 1388 | |
Wichert Akkerman | c792698 | 2000-04-10 22:22:31 +0000 | [diff] [blame] | 1389 | int |
| 1390 | sys_pivotroot(tcp) |
| 1391 | struct tcb *tcp; |
| 1392 | { |
| 1393 | if (entering(tcp)) { |
| 1394 | printpath(tcp, tcp->u_arg[0]); |
| 1395 | tprintf(", "); |
| 1396 | printpath(tcp, tcp->u_arg[1]); |
| 1397 | } |
| 1398 | return 0; |
| 1399 | } |
| 1400 | |
| 1401 | |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1402 | /* directory */ |
| 1403 | int |
| 1404 | sys_chdir(tcp) |
| 1405 | struct tcb *tcp; |
| 1406 | { |
| 1407 | if (entering(tcp)) { |
| 1408 | printpath(tcp, tcp->u_arg[0]); |
| 1409 | } |
| 1410 | return 0; |
| 1411 | } |
| 1412 | |
| 1413 | int |
| 1414 | sys_mkdir(tcp) |
| 1415 | struct tcb *tcp; |
| 1416 | { |
| 1417 | if (entering(tcp)) { |
| 1418 | printpath(tcp, tcp->u_arg[0]); |
| 1419 | tprintf(", %#lo", tcp->u_arg[1]); |
| 1420 | } |
| 1421 | return 0; |
| 1422 | } |
| 1423 | |
| 1424 | int |
| 1425 | sys_rmdir(tcp) |
| 1426 | struct tcb *tcp; |
| 1427 | { |
| 1428 | if (entering(tcp)) { |
| 1429 | printpath(tcp, tcp->u_arg[0]); |
| 1430 | } |
| 1431 | return 0; |
| 1432 | } |
| 1433 | |
| 1434 | int |
| 1435 | sys_fchdir(tcp) |
| 1436 | struct tcb *tcp; |
| 1437 | { |
| 1438 | if (entering(tcp)) { |
| 1439 | tprintf("%ld", tcp->u_arg[0]); |
| 1440 | } |
| 1441 | return 0; |
| 1442 | } |
| 1443 | |
| 1444 | int |
| 1445 | sys_chroot(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_fchroot(tcp) |
| 1456 | struct tcb *tcp; |
| 1457 | { |
| 1458 | if (entering(tcp)) { |
| 1459 | tprintf("%ld", tcp->u_arg[0]); |
| 1460 | } |
| 1461 | return 0; |
| 1462 | } |
| 1463 | |
| 1464 | int |
| 1465 | sys_link(tcp) |
| 1466 | struct tcb *tcp; |
| 1467 | { |
| 1468 | if (entering(tcp)) { |
| 1469 | printpath(tcp, tcp->u_arg[0]); |
| 1470 | tprintf(", "); |
| 1471 | printpath(tcp, tcp->u_arg[1]); |
| 1472 | } |
| 1473 | return 0; |
| 1474 | } |
| 1475 | |
| 1476 | int |
| 1477 | sys_unlink(tcp) |
| 1478 | struct tcb *tcp; |
| 1479 | { |
| 1480 | if (entering(tcp)) { |
| 1481 | printpath(tcp, tcp->u_arg[0]); |
| 1482 | } |
| 1483 | return 0; |
| 1484 | } |
| 1485 | |
| 1486 | int |
| 1487 | sys_symlink(tcp) |
| 1488 | struct tcb *tcp; |
| 1489 | { |
| 1490 | if (entering(tcp)) { |
| 1491 | printpath(tcp, tcp->u_arg[0]); |
| 1492 | tprintf(", "); |
| 1493 | printpath(tcp, tcp->u_arg[1]); |
| 1494 | } |
| 1495 | return 0; |
| 1496 | } |
| 1497 | |
| 1498 | int |
| 1499 | sys_readlink(tcp) |
| 1500 | struct tcb *tcp; |
| 1501 | { |
| 1502 | if (entering(tcp)) { |
| 1503 | printpath(tcp, tcp->u_arg[0]); |
| 1504 | tprintf(", "); |
| 1505 | } else { |
| 1506 | if (syserror(tcp)) |
| 1507 | tprintf("%#lx", tcp->u_arg[1]); |
| 1508 | else |
| 1509 | printpathn(tcp, tcp->u_arg[1], tcp->u_rval); |
| 1510 | tprintf(", %lu", tcp->u_arg[2]); |
| 1511 | } |
| 1512 | return 0; |
| 1513 | } |
| 1514 | |
| 1515 | int |
| 1516 | sys_rename(tcp) |
| 1517 | struct tcb *tcp; |
| 1518 | { |
| 1519 | if (entering(tcp)) { |
| 1520 | printpath(tcp, tcp->u_arg[0]); |
| 1521 | tprintf(", "); |
| 1522 | printpath(tcp, tcp->u_arg[1]); |
| 1523 | } |
| 1524 | return 0; |
| 1525 | } |
| 1526 | |
| 1527 | int |
| 1528 | sys_chown(tcp) |
| 1529 | struct tcb *tcp; |
| 1530 | { |
| 1531 | if (entering(tcp)) { |
| 1532 | printpath(tcp, tcp->u_arg[0]); |
| 1533 | tprintf(", %lu, %lu", tcp->u_arg[1], tcp->u_arg[2]); |
| 1534 | } |
| 1535 | return 0; |
| 1536 | } |
| 1537 | |
| 1538 | int |
| 1539 | sys_fchown(tcp) |
| 1540 | struct tcb *tcp; |
| 1541 | { |
| 1542 | if (entering(tcp)) { |
| 1543 | tprintf("%ld, %lu, %lu", |
| 1544 | tcp->u_arg[0], tcp->u_arg[1], tcp->u_arg[2]); |
| 1545 | } |
| 1546 | return 0; |
| 1547 | } |
| 1548 | |
| 1549 | int |
| 1550 | sys_chmod(tcp) |
| 1551 | struct tcb *tcp; |
| 1552 | { |
| 1553 | if (entering(tcp)) { |
| 1554 | printpath(tcp, tcp->u_arg[0]); |
| 1555 | tprintf(", %#lo", tcp->u_arg[1]); |
| 1556 | } |
| 1557 | return 0; |
| 1558 | } |
| 1559 | |
| 1560 | int |
| 1561 | sys_fchmod(tcp) |
| 1562 | struct tcb *tcp; |
| 1563 | { |
| 1564 | if (entering(tcp)) { |
| 1565 | tprintf("%ld, %#lo", tcp->u_arg[0], tcp->u_arg[1]); |
| 1566 | } |
| 1567 | return 0; |
| 1568 | } |
| 1569 | |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 1570 | #ifdef ALPHA |
| 1571 | int |
| 1572 | sys_osf_utimes(tcp) |
| 1573 | struct tcb *tcp; |
| 1574 | { |
| 1575 | if (entering(tcp)) { |
| 1576 | printpath(tcp, tcp->u_arg[0]); |
| 1577 | tprintf(", "); |
| 1578 | printtv32(tcp, tcp->u_arg[1]); |
| 1579 | } |
| 1580 | return 0; |
| 1581 | } |
| 1582 | #endif |
| 1583 | |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1584 | int |
| 1585 | sys_utimes(tcp) |
| 1586 | struct tcb *tcp; |
| 1587 | { |
| 1588 | if (entering(tcp)) { |
| 1589 | printpath(tcp, tcp->u_arg[0]); |
| 1590 | tprintf(", "); |
| 1591 | printtv(tcp, tcp->u_arg[1]); |
| 1592 | } |
| 1593 | return 0; |
| 1594 | } |
| 1595 | |
| 1596 | int |
| 1597 | sys_utime(tcp) |
| 1598 | struct tcb *tcp; |
| 1599 | { |
| 1600 | long ut[2]; |
| 1601 | |
| 1602 | if (entering(tcp)) { |
| 1603 | printpath(tcp, tcp->u_arg[0]); |
| 1604 | tprintf(", "); |
| 1605 | if (!tcp->u_arg[1]) |
| 1606 | tprintf("NULL"); |
| 1607 | else if (!verbose(tcp)) |
| 1608 | tprintf("%#lx", tcp->u_arg[1]); |
| 1609 | else if (umoven(tcp, tcp->u_arg[1], sizeof ut, |
| 1610 | (char *) ut) < 0) |
| 1611 | tprintf("[?, ?]"); |
| 1612 | else { |
| 1613 | tprintf("[%s,", sprinttime(ut[0])); |
| 1614 | tprintf(" %s]", sprinttime(ut[1])); |
| 1615 | } |
| 1616 | } |
| 1617 | return 0; |
| 1618 | } |
| 1619 | |
| 1620 | int |
| 1621 | sys_mknod(tcp) |
| 1622 | struct tcb *tcp; |
| 1623 | { |
| 1624 | int mode = tcp->u_arg[1]; |
| 1625 | |
| 1626 | if (entering(tcp)) { |
| 1627 | printpath(tcp, tcp->u_arg[0]); |
| 1628 | tprintf(", %s", sprintmode(mode)); |
| 1629 | switch (mode & S_IFMT) { |
| 1630 | case S_IFCHR: case S_IFBLK: |
| 1631 | #ifdef LINUXSPARC |
| 1632 | if (current_personality == 1) |
| 1633 | tprintf(", makedev(%lu, %lu)", |
| 1634 | (unsigned long) ((tcp->u_arg[2] >> 18) & 0x3fff), |
| 1635 | (unsigned long) (tcp->u_arg[2] & 0x3ffff)); |
| 1636 | else |
| 1637 | #endif |
| 1638 | tprintf(", makedev(%lu, %lu)", |
| 1639 | (unsigned long) major(tcp->u_arg[2]), |
| 1640 | (unsigned long) minor(tcp->u_arg[2])); |
| 1641 | break; |
| 1642 | default: |
| 1643 | break; |
| 1644 | } |
| 1645 | } |
| 1646 | return 0; |
| 1647 | } |
| 1648 | |
| 1649 | int |
| 1650 | sys_mkfifo(tcp) |
| 1651 | struct tcb *tcp; |
| 1652 | { |
| 1653 | if (entering(tcp)) { |
| 1654 | printpath(tcp, tcp->u_arg[0]); |
| 1655 | tprintf(", %#lo", tcp->u_arg[1]); |
| 1656 | } |
| 1657 | return 0; |
| 1658 | } |
| 1659 | |
| 1660 | int |
| 1661 | sys_fsync(tcp) |
| 1662 | struct tcb *tcp; |
| 1663 | { |
| 1664 | if (entering(tcp)) { |
| 1665 | tprintf("%ld", tcp->u_arg[0]); |
| 1666 | } |
| 1667 | return 0; |
| 1668 | } |
| 1669 | |
Wichert Akkerman | 328c5e7 | 1999-04-16 00:21:26 +0000 | [diff] [blame] | 1670 | #ifdef linux |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1671 | |
| 1672 | static void |
| 1673 | printdir(tcp, addr) |
| 1674 | struct tcb *tcp; |
| 1675 | long addr; |
| 1676 | { |
| 1677 | struct dirent d; |
| 1678 | |
| 1679 | if (!verbose(tcp)) { |
| 1680 | tprintf("%#lx", addr); |
| 1681 | return; |
| 1682 | } |
| 1683 | if (umove(tcp, addr, &d) < 0) { |
| 1684 | tprintf("{...}"); |
| 1685 | return; |
| 1686 | } |
| 1687 | tprintf("{d_ino=%ld, ", (unsigned long) d.d_ino); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1688 | tprintf("d_name="); |
| 1689 | printpathn(tcp, (long) ((struct dirent *) addr)->d_name, d.d_reclen); |
| 1690 | tprintf("}"); |
| 1691 | } |
| 1692 | |
| 1693 | int |
| 1694 | sys_readdir(tcp) |
| 1695 | struct tcb *tcp; |
| 1696 | { |
| 1697 | if (entering(tcp)) { |
| 1698 | tprintf("%lu, ", tcp->u_arg[0]); |
| 1699 | } else { |
| 1700 | if (syserror(tcp) || tcp->u_rval == 0 || !verbose(tcp)) |
| 1701 | tprintf("%#lx", tcp->u_arg[1]); |
| 1702 | else |
| 1703 | printdir(tcp, tcp->u_arg[1]); |
| 1704 | /* Not much point in printing this out, it is always 1. */ |
| 1705 | if (tcp->u_arg[2] != 1) |
| 1706 | tprintf(", %lu", tcp->u_arg[2]); |
| 1707 | } |
| 1708 | return 0; |
| 1709 | } |
| 1710 | |
Wichert Akkerman | 328c5e7 | 1999-04-16 00:21:26 +0000 | [diff] [blame] | 1711 | #endif /* linux */ |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1712 | |
Wichert Akkerman | bf79f2e | 2000-09-01 21:03:06 +0000 | [diff] [blame] | 1713 | #ifdef FREEBSD |
| 1714 | struct xlat direnttypes[] = { |
| 1715 | { DT_FIFO, "DT_FIFO" }, |
| 1716 | { DT_CHR, "DT_CHR" }, |
| 1717 | { DT_DIR, "DT_DIR" }, |
| 1718 | { DT_BLK, "DT_BLK" }, |
| 1719 | { DT_REG, "DT_REG" }, |
| 1720 | { DT_LNK, "DT_LNK" }, |
| 1721 | { DT_SOCK, "DT_SOCK" }, |
| 1722 | { DT_WHT, "DT_WHT" }, |
| 1723 | { 0, NULL }, |
| 1724 | }; |
| 1725 | |
| 1726 | #endif |
| 1727 | |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1728 | int |
| 1729 | sys_getdents(tcp) |
| 1730 | struct tcb *tcp; |
| 1731 | { |
| 1732 | int i, len, dents = 0; |
| 1733 | char *buf; |
| 1734 | |
| 1735 | if (entering(tcp)) { |
| 1736 | tprintf("%lu, ", tcp->u_arg[0]); |
| 1737 | return 0; |
| 1738 | } |
| 1739 | if (syserror(tcp) || !verbose(tcp)) { |
| 1740 | tprintf("%#lx, %lu", tcp->u_arg[1], tcp->u_arg[2]); |
| 1741 | return 0; |
| 1742 | } |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1743 | len = tcp->u_rval; |
| 1744 | if ((buf = malloc(len)) == NULL) { |
| 1745 | tprintf("out of memory\n"); |
| 1746 | return 0; |
| 1747 | } |
| 1748 | if (umoven(tcp, tcp->u_arg[1], len, buf) < 0) { |
| 1749 | tprintf("{...}, %lu", tcp->u_arg[2]); |
| 1750 | free(buf); |
| 1751 | return 0; |
| 1752 | } |
| 1753 | if (!abbrev(tcp)) |
| 1754 | tprintf("{"); |
| 1755 | for (i = 0; i < len;) { |
Wichert Akkerman | 9524bb9 | 1999-05-25 23:11:18 +0000 | [diff] [blame] | 1756 | struct kernel_dirent *d = (struct kernel_dirent *) &buf[i]; |
Wichert Akkerman | 328c5e7 | 1999-04-16 00:21:26 +0000 | [diff] [blame] | 1757 | #ifdef linux |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1758 | if (!abbrev(tcp)) { |
| 1759 | tprintf("%s{d_ino=%lu, d_off=%lu, ", |
| 1760 | i ? " " : "", d->d_ino, d->d_off); |
| 1761 | tprintf("d_reclen=%u, d_name=\"%s\"}", |
| 1762 | d->d_reclen, d->d_name); |
| 1763 | } |
Wichert Akkerman | 328c5e7 | 1999-04-16 00:21:26 +0000 | [diff] [blame] | 1764 | #endif /* linux */ |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1765 | #ifdef SVR4 |
| 1766 | if (!abbrev(tcp)) { |
| 1767 | tprintf("%s{d_ino=%lu, d_off=%lu, ", |
| 1768 | i ? " " : "", d->d_ino, d->d_off); |
| 1769 | tprintf("d_reclen=%u, d_name=\"%s\"}", |
| 1770 | d->d_reclen, d->d_name); |
| 1771 | } |
| 1772 | #endif /* SVR4 */ |
| 1773 | #ifdef SUNOS4 |
| 1774 | if (!abbrev(tcp)) { |
| 1775 | tprintf("%s{d_off=%lu, d_fileno=%lu, d_reclen=%u, ", |
| 1776 | i ? " " : "", d->d_off, d->d_fileno, |
| 1777 | d->d_reclen); |
| 1778 | tprintf("d_namlen=%u, d_name=\"%.*s\"}", |
| 1779 | d->d_namlen, d->d_namlen, d->d_name); |
| 1780 | } |
| 1781 | #endif /* SUNOS4 */ |
Wichert Akkerman | bf79f2e | 2000-09-01 21:03:06 +0000 | [diff] [blame] | 1782 | #ifdef FREEBSD |
| 1783 | if (!abbrev(tcp)) { |
| 1784 | tprintf("%s{d_fileno=%u, d_reclen=%u, d_type=", |
| 1785 | i ? " " : "", d->d_fileno, d->d_reclen); |
| 1786 | printxval(direnttypes, d->d_type, "DT_???"); |
| 1787 | tprintf(", d_namlen=%u, d_name=\"%.*s\"}", |
| 1788 | d->d_namlen, d->d_namlen, d->d_name); |
| 1789 | } |
| 1790 | #endif /* FREEBSD */ |
Pavel Machek | 9a9f10b | 2000-02-01 16:22:52 +0000 | [diff] [blame] | 1791 | if (!d->d_reclen) { |
| 1792 | tprintf("/* d_reclen == 0, problem here */"); |
| 1793 | break; |
| 1794 | } |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1795 | i += d->d_reclen; |
| 1796 | dents++; |
| 1797 | } |
| 1798 | if (!abbrev(tcp)) |
| 1799 | tprintf("}"); |
| 1800 | else |
| 1801 | tprintf("/* %u entries */", dents); |
| 1802 | tprintf(", %lu", tcp->u_arg[2]); |
| 1803 | free(buf); |
| 1804 | return 0; |
| 1805 | } |
| 1806 | |
John Hughes | bdf48f5 | 2001-03-06 15:08:09 +0000 | [diff] [blame^] | 1807 | |
| 1808 | #if _LFS64_LARGEFILE |
| 1809 | int |
| 1810 | sys_getdents64(tcp) |
| 1811 | struct tcb *tcp; |
| 1812 | { |
| 1813 | int i, len, dents = 0; |
| 1814 | char *buf; |
| 1815 | |
| 1816 | if (entering(tcp)) { |
| 1817 | tprintf("%lu, ", tcp->u_arg[0]); |
| 1818 | return 0; |
| 1819 | } |
| 1820 | if (syserror(tcp) || !verbose(tcp)) { |
| 1821 | tprintf("%#lx, %lu", tcp->u_arg[1], tcp->u_arg[2]); |
| 1822 | return 0; |
| 1823 | } |
| 1824 | len = tcp->u_rval; |
| 1825 | if ((buf = malloc(len)) == NULL) { |
| 1826 | tprintf("out of memory\n"); |
| 1827 | return 0; |
| 1828 | } |
| 1829 | if (umoven(tcp, tcp->u_arg[1], len, buf) < 0) { |
| 1830 | tprintf("{...}, %lu", tcp->u_arg[2]); |
| 1831 | free(buf); |
| 1832 | return 0; |
| 1833 | } |
| 1834 | if (!abbrev(tcp)) |
| 1835 | tprintf("{"); |
| 1836 | for (i = 0; i < len;) { |
| 1837 | struct dirent64 *d = (struct dirent64 *) &buf[i]; |
| 1838 | #ifdef linux |
| 1839 | if (!abbrev(tcp)) { |
| 1840 | tprintf("%s{d_ino=%lu, d_off=%lu, ", |
| 1841 | i ? " " : "", d->d_ino, d->d_off); |
| 1842 | tprintf("d_reclen=%u, d_name=\"%s\"}", |
| 1843 | d->d_reclen, d->d_name); |
| 1844 | } |
| 1845 | #endif /* linux */ |
| 1846 | #ifdef SVR4 |
| 1847 | if (!abbrev(tcp)) { |
| 1848 | tprintf("%s{d_ino=%llu, d_off=%llu, ", |
| 1849 | i ? " " : "", d->d_ino, d->d_off); |
| 1850 | tprintf("d_reclen=%u, d_name=\"%s\"}", |
| 1851 | d->d_reclen, d->d_name); |
| 1852 | } |
| 1853 | #endif /* SVR4 */ |
| 1854 | #ifdef SUNOS4 |
| 1855 | if (!abbrev(tcp)) { |
| 1856 | tprintf("%s{d_off=%lu, d_fileno=%lu, d_reclen=%u, ", |
| 1857 | i ? " " : "", d->d_off, d->d_fileno, |
| 1858 | d->d_reclen); |
| 1859 | tprintf("d_namlen=%u, d_name=\"%.*s\"}", |
| 1860 | d->d_namlen, d->d_namlen, d->d_name); |
| 1861 | } |
| 1862 | #endif /* SUNOS4 */ |
| 1863 | i += d->d_reclen; |
| 1864 | dents++; |
| 1865 | } |
| 1866 | if (!abbrev(tcp)) |
| 1867 | tprintf("}"); |
| 1868 | else |
| 1869 | tprintf("/* %u entries */", dents); |
| 1870 | tprintf(", %lu", tcp->u_arg[2]); |
| 1871 | free(buf); |
| 1872 | return 0; |
| 1873 | } |
| 1874 | #endif |
| 1875 | |
Wichert Akkerman | bf79f2e | 2000-09-01 21:03:06 +0000 | [diff] [blame] | 1876 | #ifdef FREEBSD |
| 1877 | int |
| 1878 | sys_getdirentries(tcp) |
| 1879 | struct tcb * tcp; |
| 1880 | { |
| 1881 | int i, len, dents = 0; |
| 1882 | long basep; |
| 1883 | char *buf; |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1884 | |
Wichert Akkerman | bf79f2e | 2000-09-01 21:03:06 +0000 | [diff] [blame] | 1885 | if (entering(tcp)) { |
| 1886 | tprintf("%lu, ", tcp->u_arg[0]); |
| 1887 | return 0; |
| 1888 | } |
| 1889 | if (syserror(tcp) || !verbose(tcp)) { |
| 1890 | tprintf("%#lx, %lu, %#lx", tcp->u_arg[1], tcp->u_arg[2], tcp->u_arg[3]); |
| 1891 | return 0; |
| 1892 | } |
| 1893 | len = tcp->u_rval; |
| 1894 | if ((buf = malloc(len)) == NULL) { |
| 1895 | tprintf("out of memory\n"); |
| 1896 | return 0; |
| 1897 | } |
| 1898 | if (umoven(tcp, tcp->u_arg[1], len, buf) < 0) { |
| 1899 | tprintf("{...}, %lu, %#lx", tcp->u_arg[2], tcp->u_arg[3]); |
| 1900 | free(buf); |
| 1901 | return 0; |
| 1902 | } |
| 1903 | if (!abbrev(tcp)) |
| 1904 | tprintf("{"); |
| 1905 | for (i = 0; i < len;) { |
| 1906 | struct kernel_dirent *d = (struct kernel_dirent *) &buf[i]; |
| 1907 | if (!abbrev(tcp)) { |
| 1908 | tprintf("%s{d_fileno=%u, d_reclen=%u, d_type=", |
| 1909 | i ? " " : "", d->d_fileno, d->d_reclen); |
| 1910 | printxval(direnttypes, d->d_type, "DT_???"); |
| 1911 | tprintf(", d_namlen=%u, d_name=\"%.*s\"}", |
| 1912 | d->d_namlen, d->d_namlen, d->d_name); |
| 1913 | } |
| 1914 | i += d->d_reclen; |
| 1915 | dents++; |
| 1916 | } |
| 1917 | if (!abbrev(tcp)) |
| 1918 | tprintf("}"); |
| 1919 | else |
| 1920 | tprintf("/* %u entries */", dents); |
| 1921 | free(buf); |
| 1922 | tprintf(", %lu", tcp->u_arg[2]); |
| 1923 | if (umove(tcp, tcp->u_arg[3], &basep) < 0) |
| 1924 | tprintf(", %#lx", tcp->u_arg[3]); |
| 1925 | else |
| 1926 | tprintf(", [%lu]", basep); |
| 1927 | return 0; |
| 1928 | } |
| 1929 | #endif |
| 1930 | |
| 1931 | #ifdef linux |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1932 | int |
| 1933 | sys_getcwd(tcp) |
| 1934 | struct tcb *tcp; |
| 1935 | { |
| 1936 | if (exiting(tcp)) { |
| 1937 | if (syserror(tcp)) |
| 1938 | tprintf("%#lx", tcp->u_arg[0]); |
| 1939 | else |
Wichert Akkerman | 2e2553a | 1999-05-09 00:29:58 +0000 | [diff] [blame] | 1940 | printpathn(tcp, tcp->u_arg[0], tcp->u_rval - 1); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1941 | tprintf(", %lu", tcp->u_arg[1]); |
| 1942 | } |
| 1943 | return 0; |
| 1944 | } |
Wichert Akkerman | 328c5e7 | 1999-04-16 00:21:26 +0000 | [diff] [blame] | 1945 | #endif /* linux */ |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1946 | |
Wichert Akkerman | bf79f2e | 2000-09-01 21:03:06 +0000 | [diff] [blame] | 1947 | #ifdef FREEBSD |
| 1948 | int |
| 1949 | sys___getcwd(tcp) |
| 1950 | struct tcb *tcp; |
| 1951 | { |
| 1952 | if (exiting(tcp)) { |
| 1953 | if (syserror(tcp)) |
| 1954 | tprintf("%#lx", tcp->u_arg[0]); |
| 1955 | else |
| 1956 | printpathn(tcp, tcp->u_arg[0], tcp->u_arg[1]); |
| 1957 | tprintf(", %lu", tcp->u_arg[1]); |
| 1958 | } |
| 1959 | return 0; |
| 1960 | } |
| 1961 | #endif |
| 1962 | |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1963 | #ifdef HAVE_SYS_ASYNCH_H |
| 1964 | |
| 1965 | int |
| 1966 | sys_aioread(tcp) |
| 1967 | struct tcb *tcp; |
| 1968 | { |
| 1969 | struct aio_result_t res; |
| 1970 | |
| 1971 | if (entering(tcp)) { |
| 1972 | tprintf("%lu, ", tcp->u_arg[0]); |
| 1973 | } else { |
| 1974 | if (syserror(tcp)) |
| 1975 | tprintf("%#lx", tcp->u_arg[1]); |
| 1976 | else |
| 1977 | printstr(tcp, tcp->u_arg[1], tcp->u_arg[2]); |
| 1978 | tprintf(", %lu, %lu, ", tcp->u_arg[2], tcp->u_arg[3]); |
| 1979 | printxval(whence, tcp->u_arg[4], "L_???"); |
| 1980 | if (syserror(tcp) || tcp->u_arg[5] == 0 |
| 1981 | || umove(tcp, tcp->u_arg[5], &res) < 0) |
| 1982 | tprintf(", %#lx", tcp->u_arg[5]); |
| 1983 | else |
| 1984 | tprintf(", {aio_return %d aio_errno %d}", |
| 1985 | res.aio_return, res.aio_errno); |
| 1986 | } |
| 1987 | return 0; |
| 1988 | } |
| 1989 | |
| 1990 | int |
| 1991 | sys_aiowrite(tcp) |
| 1992 | struct tcb *tcp; |
| 1993 | { |
| 1994 | struct aio_result_t res; |
| 1995 | |
| 1996 | if (entering(tcp)) { |
| 1997 | tprintf("%lu, ", tcp->u_arg[0]); |
| 1998 | printstr(tcp, tcp->u_arg[1], tcp->u_arg[2]); |
| 1999 | tprintf(", %lu, %lu, ", tcp->u_arg[2], tcp->u_arg[3]); |
| 2000 | printxval(whence, tcp->u_arg[4], "L_???"); |
| 2001 | } |
| 2002 | else { |
| 2003 | if (tcp->u_arg[5] == 0) |
| 2004 | tprintf(", NULL"); |
| 2005 | else if (syserror(tcp) |
| 2006 | || umove(tcp, tcp->u_arg[5], &res) < 0) |
| 2007 | tprintf(", %#lx", tcp->u_arg[5]); |
| 2008 | else |
| 2009 | tprintf(", {aio_return %d aio_errno %d}", |
| 2010 | res.aio_return, res.aio_errno); |
| 2011 | } |
| 2012 | return 0; |
| 2013 | } |
| 2014 | |
| 2015 | int |
| 2016 | sys_aiowait(tcp) |
| 2017 | struct tcb *tcp; |
| 2018 | { |
| 2019 | if (entering(tcp)) |
| 2020 | printtv(tcp, tcp->u_arg[0]); |
| 2021 | return 0; |
| 2022 | } |
| 2023 | |
| 2024 | int |
| 2025 | sys_aiocancel(tcp) |
| 2026 | struct tcb *tcp; |
| 2027 | { |
| 2028 | struct aio_result_t res; |
| 2029 | |
| 2030 | if (exiting(tcp)) { |
| 2031 | if (tcp->u_arg[0] == 0) |
| 2032 | tprintf("NULL"); |
| 2033 | else if (syserror(tcp) |
| 2034 | || umove(tcp, tcp->u_arg[0], &res) < 0) |
| 2035 | tprintf("%#lx", tcp->u_arg[0]); |
| 2036 | else |
| 2037 | tprintf("{aio_return %d aio_errno %d}", |
| 2038 | res.aio_return, res.aio_errno); |
| 2039 | } |
| 2040 | return 0; |
| 2041 | } |
| 2042 | |
| 2043 | #endif /* HAVE_SYS_ASYNCH_H */ |