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