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