Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1 | /* |
Michal Ludvig | 53b320f | 2002-09-23 13:30:09 +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> |
Michal Ludvig | 53b320f | 2002-09-23 13:30:09 +0000 | [diff] [blame] | 37 | #ifdef LINUX |
Wichert Akkerman | 9524bb9 | 1999-05-25 23:11:18 +0000 | [diff] [blame] | 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 |
Michal Ludvig | 10a88d0 | 2002-10-07 14:31:00 +0000 | [diff] [blame] | 43 | #undef dirent64 |
Wichert Akkerman | 9524bb9 | 1999-05-25 23:11:18 +0000 | [diff] [blame] | 44 | #else |
| 45 | #define kernel_dirent dirent |
| 46 | #endif |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 47 | |
Michal Ludvig | 53b320f | 2002-09-23 13:30:09 +0000 | [diff] [blame] | 48 | #ifdef LINUX |
Wichert Akkerman | dacfb6e | 1999-06-03 14:21:07 +0000 | [diff] [blame] | 49 | # ifdef LINUXSPARC |
| 50 | struct stat { |
| 51 | unsigned short st_dev; |
| 52 | unsigned int st_ino; |
| 53 | unsigned short st_mode; |
| 54 | short st_nlink; |
| 55 | unsigned short st_uid; |
| 56 | unsigned short st_gid; |
| 57 | unsigned short st_rdev; |
| 58 | unsigned int st_size; |
| 59 | int st_atime; |
| 60 | unsigned int __unused1; |
| 61 | int st_mtime; |
| 62 | unsigned int __unused2; |
| 63 | int st_ctime; |
| 64 | unsigned int __unused3; |
| 65 | int st_blksize; |
| 66 | int st_blocks; |
| 67 | unsigned int __unused4[2]; |
| 68 | }; |
Roland McGrath | 6d1a65c | 2004-07-12 07:44:08 +0000 | [diff] [blame] | 69 | #if defined(SPARC64) |
| 70 | struct stat_sparc64 { |
| 71 | unsigned int st_dev; |
| 72 | unsigned long st_ino; |
| 73 | unsigned int st_mode; |
| 74 | unsigned int st_nlink; |
| 75 | unsigned int st_uid; |
| 76 | unsigned int st_gid; |
| 77 | unsigned int st_rdev; |
| 78 | long st_size; |
| 79 | long st_atime; |
| 80 | long st_mtime; |
| 81 | long st_ctime; |
| 82 | long st_blksize; |
| 83 | long st_blocks; |
| 84 | unsigned long __unused4[2]; |
| 85 | }; |
| 86 | #endif /* SPARC64 */ |
Wichert Akkerman | dacfb6e | 1999-06-03 14:21:07 +0000 | [diff] [blame] | 87 | # define stat kernel_stat |
| 88 | # include <asm/stat.h> |
| 89 | # undef stat |
| 90 | # else |
Wichert Akkerman | 5b4d128 | 1999-07-09 00:32:54 +0000 | [diff] [blame] | 91 | # undef dev_t |
| 92 | # undef ino_t |
| 93 | # undef mode_t |
| 94 | # undef nlink_t |
| 95 | # undef uid_t |
| 96 | # undef gid_t |
| 97 | # undef off_t |
| 98 | # undef loff_t |
| 99 | |
Wichert Akkerman | a601370 | 1999-07-08 14:00:58 +0000 | [diff] [blame] | 100 | # define dev_t __kernel_dev_t |
| 101 | # define ino_t __kernel_ino_t |
| 102 | # define mode_t __kernel_mode_t |
| 103 | # define nlink_t __kernel_nlink_t |
| 104 | # define uid_t __kernel_uid_t |
| 105 | # define gid_t __kernel_gid_t |
| 106 | # define off_t __kernel_off_t |
| 107 | # define loff_t __kernel_loff_t |
| 108 | |
Wichert Akkerman | dacfb6e | 1999-06-03 14:21:07 +0000 | [diff] [blame] | 109 | # include <asm/stat.h> |
Wichert Akkerman | a601370 | 1999-07-08 14:00:58 +0000 | [diff] [blame] | 110 | |
| 111 | # undef dev_t |
| 112 | # undef ino_t |
| 113 | # undef mode_t |
| 114 | # undef nlink_t |
| 115 | # undef uid_t |
| 116 | # undef gid_t |
| 117 | # undef off_t |
| 118 | # undef loff_t |
Wichert Akkerman | 5b4d128 | 1999-07-09 00:32:54 +0000 | [diff] [blame] | 119 | |
| 120 | # define dev_t dev_t |
| 121 | # define ino_t ino_t |
| 122 | # define mode_t mode_t |
| 123 | # define nlink_t nlink_t |
| 124 | # define uid_t uid_t |
| 125 | # define gid_t gid_t |
| 126 | # define off_t off_t |
| 127 | # define loff_t loff_t |
Wichert Akkerman | dacfb6e | 1999-06-03 14:21:07 +0000 | [diff] [blame] | 128 | # endif |
Wichert Akkerman | c1652e2 | 2001-03-27 12:17:16 +0000 | [diff] [blame] | 129 | # ifdef HPPA /* asm-parisc/stat.h defines stat64 */ |
| 130 | # undef stat64 |
| 131 | # endif |
Wichert Akkerman | d4d8e92 | 1999-04-18 23:30:29 +0000 | [diff] [blame] | 132 | # define stat libc_stat |
Ulrich Drepper | 0fa01d7 | 1999-12-24 07:18:28 +0000 | [diff] [blame] | 133 | # define stat64 libc_stat64 |
Wichert Akkerman | d4d8e92 | 1999-04-18 23:30:29 +0000 | [diff] [blame] | 134 | # include <sys/stat.h> |
| 135 | # undef stat |
Ulrich Drepper | 0fa01d7 | 1999-12-24 07:18:28 +0000 | [diff] [blame] | 136 | # undef stat64 |
Roland McGrath | ca16a40 | 2003-01-09 06:53:22 +0000 | [diff] [blame] | 137 | /* These might be macros. */ |
| 138 | # undef st_atime |
| 139 | # undef st_mtime |
| 140 | # undef st_ctime |
Wichert Akkerman | c1652e2 | 2001-03-27 12:17:16 +0000 | [diff] [blame] | 141 | # ifdef HPPA |
| 142 | # define stat64 hpux_stat64 |
| 143 | # endif |
Wichert Akkerman | d4d8e92 | 1999-04-18 23:30:29 +0000 | [diff] [blame] | 144 | #else |
| 145 | # include <sys/stat.h> |
Wichert Akkerman | 328c5e7 | 1999-04-16 00:21:26 +0000 | [diff] [blame] | 146 | #endif |
Wichert Akkerman | d4d8e92 | 1999-04-18 23:30:29 +0000 | [diff] [blame] | 147 | |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 148 | #include <fcntl.h> |
| 149 | |
| 150 | #ifdef SVR4 |
| 151 | # include <sys/cred.h> |
| 152 | #endif /* SVR4 */ |
| 153 | |
Wichert Akkerman | bf79f2e | 2000-09-01 21:03:06 +0000 | [diff] [blame] | 154 | #ifdef HAVE_SYS_VFS_H |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 155 | #include <sys/vfs.h> |
Wichert Akkerman | bf79f2e | 2000-09-01 21:03:06 +0000 | [diff] [blame] | 156 | #endif |
| 157 | |
Roland McGrath | 186c5ac | 2002-12-15 23:58:23 +0000 | [diff] [blame] | 158 | #ifdef HAVE_LINUX_XATTR_H |
| 159 | #include <linux/xattr.h> |
| 160 | #elif defined linux |
| 161 | #define XATTR_CREATE 1 |
| 162 | #define XATTR_REPLACE 2 |
| 163 | #endif |
| 164 | |
Wichert Akkerman | bf79f2e | 2000-09-01 21:03:06 +0000 | [diff] [blame] | 165 | #ifdef FREEBSD |
| 166 | #include <sys/param.h> |
| 167 | #include <sys/mount.h> |
| 168 | #include <sys/stat.h> |
John Hughes | 70623be | 2001-03-08 13:59:00 +0000 | [diff] [blame] | 169 | #endif |
| 170 | |
Dmitry V. Levin | 1f336e5 | 2006-10-14 20:20:46 +0000 | [diff] [blame^] | 171 | #if _LFS64_LARGEFILE && (defined(LINUX) || defined(SVR4)) |
| 172 | # ifdef HAVE_INTTYPES_H |
| 173 | # include <inttypes.h> |
| 174 | # else |
| 175 | # define PRId64 "lld" |
| 176 | # define PRIu64 "llu" |
| 177 | # endif |
| 178 | #endif |
| 179 | |
John Hughes | 70623be | 2001-03-08 13:59:00 +0000 | [diff] [blame] | 180 | #if HAVE_LONG_LONG_OFF_T |
| 181 | /* |
| 182 | * Ugly hacks for systems that have typedef long long off_t |
| 183 | */ |
John Hughes | b8c9f77 | 2001-03-07 16:53:07 +0000 | [diff] [blame] | 184 | |
| 185 | #define stat64 stat |
| 186 | #define HAVE_STAT64 1 /* Ugly hack */ |
John Hughes | 70623be | 2001-03-08 13:59:00 +0000 | [diff] [blame] | 187 | |
| 188 | #define sys_stat64 sys_stat |
| 189 | #define sys_fstat64 sys_fstat |
| 190 | #define sys_lstat64 sys_lstat |
| 191 | #define sys_lseek64 sys_lseek |
| 192 | #define sys_truncate64 sys_truncate |
| 193 | #define sys_ftruncate64 sys_ftruncate |
Wichert Akkerman | bf79f2e | 2000-09-01 21:03:06 +0000 | [diff] [blame] | 194 | #endif |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 195 | |
| 196 | #ifdef MAJOR_IN_SYSMACROS |
| 197 | #include <sys/sysmacros.h> |
| 198 | #endif |
| 199 | |
| 200 | #ifdef MAJOR_IN_MKDEV |
| 201 | #include <sys/mkdev.h> |
| 202 | #endif |
| 203 | |
| 204 | #ifdef HAVE_SYS_ASYNCH_H |
| 205 | #include <sys/asynch.h> |
| 206 | #endif |
| 207 | |
| 208 | #ifdef SUNOS4 |
| 209 | #include <ustat.h> |
| 210 | #endif |
| 211 | |
| 212 | /* |
| 213 | * This is a really dirty trick but it should always work. Traditional |
| 214 | * Unix says r/w/rw are 0/1/2, so we make them true flags 1/2/3 by |
| 215 | * adding 1. Just remember to add 1 to any arg decoded with openmodes. |
| 216 | */ |
Roland McGrath | d9f816f | 2004-09-04 03:39:20 +0000 | [diff] [blame] | 217 | const struct xlat openmodes[] = { |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 218 | { O_RDWR+1, "O_RDWR" }, |
| 219 | { O_RDONLY+1, "O_RDONLY" }, |
| 220 | { O_WRONLY+1, "O_WRONLY" }, |
| 221 | { O_NONBLOCK, "O_NONBLOCK" }, |
| 222 | { O_APPEND, "O_APPEND" }, |
| 223 | { O_CREAT, "O_CREAT" }, |
| 224 | { O_TRUNC, "O_TRUNC" }, |
| 225 | { O_EXCL, "O_EXCL" }, |
| 226 | { O_NOCTTY, "O_NOCTTY" }, |
| 227 | #ifdef O_SYNC |
| 228 | { O_SYNC, "O_SYNC" }, |
| 229 | #endif |
| 230 | #ifdef O_ASYNC |
| 231 | { O_ASYNC, "O_ASYNC" }, |
| 232 | #endif |
| 233 | #ifdef O_DSYNC |
| 234 | { O_DSYNC, "O_DSYNC" }, |
| 235 | #endif |
| 236 | #ifdef O_RSYNC |
| 237 | { O_RSYNC, "O_RSYNC" }, |
| 238 | #endif |
| 239 | #ifdef O_NDELAY |
| 240 | { O_NDELAY, "O_NDELAY" }, |
| 241 | #endif |
| 242 | #ifdef O_PRIV |
| 243 | { O_PRIV, "O_PRIV" }, |
| 244 | #endif |
| 245 | #ifdef O_DIRECT |
Wichert Akkerman | 5ae21ea | 2000-05-01 01:53:59 +0000 | [diff] [blame] | 246 | { O_DIRECT, "O_DIRECT" }, |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 247 | #endif |
| 248 | #ifdef O_LARGEFILE |
Roland McGrath | fee836e | 2005-02-02 22:11:32 +0000 | [diff] [blame] | 249 | # if O_LARGEFILE == 0 /* biarch platforms in 64-bit mode */ |
| 250 | # undef O_LARGEFILE |
| 251 | # ifdef SPARC64 |
| 252 | # define O_LARGEFILE 0x40000 |
| 253 | # elif defined X86_64 || defined S390X |
| 254 | # define O_LARGEFILE 0100000 |
| 255 | # endif |
| 256 | # endif |
Roland McGrath | 663a8a0 | 2005-02-04 09:49:56 +0000 | [diff] [blame] | 257 | # ifdef O_LARGEFILE |
Wichert Akkerman | 5ae21ea | 2000-05-01 01:53:59 +0000 | [diff] [blame] | 258 | { O_LARGEFILE, "O_LARGEFILE" }, |
Roland McGrath | 663a8a0 | 2005-02-04 09:49:56 +0000 | [diff] [blame] | 259 | # endif |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 260 | #endif |
| 261 | #ifdef O_DIRECTORY |
Wichert Akkerman | 5ae21ea | 2000-05-01 01:53:59 +0000 | [diff] [blame] | 262 | { O_DIRECTORY, "O_DIRECTORY" }, |
| 263 | #endif |
| 264 | #ifdef O_NOFOLLOW |
| 265 | { O_NOFOLLOW, "O_NOFOLLOW" }, |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 266 | #endif |
Roland McGrath | 1025c3e | 2005-05-09 07:40:35 +0000 | [diff] [blame] | 267 | #ifdef O_NOATIME |
| 268 | { O_NOATIME, "O_NOATIME" }, |
| 269 | #endif |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 270 | |
| 271 | #ifdef FNDELAY |
| 272 | { FNDELAY, "FNDELAY" }, |
| 273 | #endif |
| 274 | #ifdef FAPPEND |
| 275 | { FAPPEND, "FAPPEND" }, |
| 276 | #endif |
| 277 | #ifdef FMARK |
| 278 | { FMARK, "FMARK" }, |
| 279 | #endif |
| 280 | #ifdef FDEFER |
| 281 | { FDEFER, "FDEFER" }, |
| 282 | #endif |
| 283 | #ifdef FASYNC |
| 284 | { FASYNC, "FASYNC" }, |
| 285 | #endif |
| 286 | #ifdef FSHLOCK |
| 287 | { FSHLOCK, "FSHLOCK" }, |
| 288 | #endif |
| 289 | #ifdef FEXLOCK |
| 290 | { FEXLOCK, "FEXLOCK" }, |
| 291 | #endif |
| 292 | #ifdef FCREAT |
| 293 | { FCREAT, "FCREAT" }, |
| 294 | #endif |
| 295 | #ifdef FTRUNC |
| 296 | { FTRUNC, "FTRUNC" }, |
| 297 | #endif |
| 298 | #ifdef FEXCL |
| 299 | { FEXCL, "FEXCL" }, |
| 300 | #endif |
| 301 | #ifdef FNBIO |
| 302 | { FNBIO, "FNBIO" }, |
| 303 | #endif |
| 304 | #ifdef FSYNC |
| 305 | { FSYNC, "FSYNC" }, |
| 306 | #endif |
| 307 | #ifdef FNOCTTY |
| 308 | { FNOCTTY, "FNOCTTY" }, |
Roland McGrath | 186c5ac | 2002-12-15 23:58:23 +0000 | [diff] [blame] | 309 | #endif |
Wichert Akkerman | bf79f2e | 2000-09-01 21:03:06 +0000 | [diff] [blame] | 310 | #ifdef O_SHLOCK |
| 311 | { O_SHLOCK, "O_SHLOCK" }, |
| 312 | #endif |
| 313 | #ifdef O_EXLOCK |
| 314 | { O_EXLOCK, "O_EXLOCK" }, |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 315 | #endif |
| 316 | { 0, NULL }, |
| 317 | }; |
| 318 | |
Dmitry V. Levin | 95ebf5a | 2006-10-13 20:25:12 +0000 | [diff] [blame] | 319 | #ifdef LINUX |
| 320 | |
| 321 | #ifndef AT_FDCWD |
| 322 | # define AT_FDCWD -100 |
| 323 | #endif |
| 324 | |
| 325 | static void |
| 326 | print_dirfd(long fd) |
| 327 | { |
| 328 | if (fd == AT_FDCWD) |
| 329 | tprintf("AT_FDCWD, "); |
| 330 | else |
| 331 | tprintf("%ld, ", fd); |
| 332 | } |
| 333 | #endif |
| 334 | |
| 335 | static int |
| 336 | decode_open(struct tcb *tcp, int offset) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 337 | { |
| 338 | if (entering(tcp)) { |
Dmitry V. Levin | 95ebf5a | 2006-10-13 20:25:12 +0000 | [diff] [blame] | 339 | printpath(tcp, tcp->u_arg[offset]); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 340 | tprintf(", "); |
| 341 | /* flags */ |
Dmitry V. Levin | 95ebf5a | 2006-10-13 20:25:12 +0000 | [diff] [blame] | 342 | printflags(openmodes, tcp->u_arg[offset + 1] + 1, "O_???"); |
| 343 | if (tcp->u_arg[offset + 1] & O_CREAT) { |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 344 | /* mode */ |
Dmitry V. Levin | 95ebf5a | 2006-10-13 20:25:12 +0000 | [diff] [blame] | 345 | tprintf(", %#lo", tcp->u_arg[offset + 2]); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 346 | } |
| 347 | } |
| 348 | return 0; |
| 349 | } |
| 350 | |
Dmitry V. Levin | 95ebf5a | 2006-10-13 20:25:12 +0000 | [diff] [blame] | 351 | int |
| 352 | sys_open(struct tcb *tcp) |
| 353 | { |
| 354 | return decode_open(tcp, 0); |
| 355 | } |
| 356 | |
| 357 | #ifdef LINUX |
| 358 | int |
| 359 | sys_openat(struct tcb *tcp) |
| 360 | { |
| 361 | if (entering(tcp)) |
| 362 | print_dirfd(tcp->u_arg[0]); |
| 363 | return decode_open(tcp, 1); |
| 364 | } |
| 365 | #endif |
| 366 | |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 367 | #ifdef LINUXSPARC |
Roland McGrath | a4d4853 | 2005-06-08 20:45:28 +0000 | [diff] [blame] | 368 | static const struct xlat openmodessol[] = { |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 369 | { 0, "O_RDWR" }, |
| 370 | { 1, "O_RDONLY" }, |
| 371 | { 2, "O_WRONLY" }, |
| 372 | { 0x80, "O_NONBLOCK" }, |
| 373 | { 8, "O_APPEND" }, |
| 374 | { 0x100, "O_CREAT" }, |
| 375 | { 0x200, "O_TRUNC" }, |
| 376 | { 0x400, "O_EXCL" }, |
| 377 | { 0x800, "O_NOCTTY" }, |
| 378 | { 0x10, "O_SYNC" }, |
| 379 | { 0x40, "O_DSYNC" }, |
| 380 | { 0x8000, "O_RSYNC" }, |
| 381 | { 4, "O_NDELAY" }, |
| 382 | { 0x1000, "O_PRIV" }, |
| 383 | { 0, NULL }, |
| 384 | }; |
| 385 | |
| 386 | int |
| 387 | solaris_open(tcp) |
| 388 | struct tcb *tcp; |
| 389 | { |
| 390 | if (entering(tcp)) { |
| 391 | printpath(tcp, tcp->u_arg[0]); |
| 392 | tprintf(", "); |
| 393 | /* flags */ |
Roland McGrath | b2dee13 | 2005-06-01 19:02:36 +0000 | [diff] [blame] | 394 | printflags(openmodessol, tcp->u_arg[1] + 1, "O_???"); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 395 | if (tcp->u_arg[1] & 0x100) { |
| 396 | /* mode */ |
| 397 | tprintf(", %#lo", tcp->u_arg[2]); |
| 398 | } |
| 399 | } |
| 400 | return 0; |
| 401 | } |
| 402 | |
| 403 | #endif |
| 404 | |
| 405 | int |
| 406 | sys_creat(tcp) |
| 407 | struct tcb *tcp; |
| 408 | { |
| 409 | if (entering(tcp)) { |
| 410 | printpath(tcp, tcp->u_arg[0]); |
| 411 | tprintf(", %#lo", tcp->u_arg[1]); |
| 412 | } |
| 413 | return 0; |
| 414 | } |
| 415 | |
Roland McGrath | d9f816f | 2004-09-04 03:39:20 +0000 | [diff] [blame] | 416 | static const struct xlat access_flags[] = { |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 417 | { F_OK, "F_OK", }, |
| 418 | { R_OK, "R_OK" }, |
| 419 | { W_OK, "W_OK" }, |
| 420 | { X_OK, "X_OK" }, |
| 421 | #ifdef EFF_ONLY_OK |
| 422 | { EFF_ONLY_OK, "EFF_ONLY_OK" }, |
| 423 | #endif |
| 424 | #ifdef EX_OK |
| 425 | { EX_OK, "EX_OK" }, |
| 426 | #endif |
| 427 | { 0, NULL }, |
| 428 | }; |
| 429 | |
Dmitry V. Levin | 95ebf5a | 2006-10-13 20:25:12 +0000 | [diff] [blame] | 430 | static int |
| 431 | decode_access(struct tcb *tcp, int offset) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 432 | { |
| 433 | if (entering(tcp)) { |
Dmitry V. Levin | 95ebf5a | 2006-10-13 20:25:12 +0000 | [diff] [blame] | 434 | printpath(tcp, tcp->u_arg[offset]); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 435 | tprintf(", "); |
Dmitry V. Levin | 95ebf5a | 2006-10-13 20:25:12 +0000 | [diff] [blame] | 436 | printflags(access_flags, tcp->u_arg[offset + 1], "?_OK"); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 437 | } |
| 438 | return 0; |
| 439 | } |
| 440 | |
| 441 | int |
Dmitry V. Levin | 95ebf5a | 2006-10-13 20:25:12 +0000 | [diff] [blame] | 442 | sys_access(struct tcb *tcp) |
| 443 | { |
| 444 | return decode_access(tcp, 0); |
| 445 | } |
| 446 | |
| 447 | #ifdef LINUX |
| 448 | int |
| 449 | sys_faccessat(struct tcb *tcp) |
| 450 | { |
| 451 | if (entering(tcp)) |
| 452 | print_dirfd(tcp->u_arg[0]); |
| 453 | return decode_access(tcp, 1); |
| 454 | } |
| 455 | #endif |
| 456 | |
| 457 | int |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 458 | sys_umask(tcp) |
| 459 | struct tcb *tcp; |
| 460 | { |
| 461 | if (entering(tcp)) { |
| 462 | tprintf("%#lo", tcp->u_arg[0]); |
| 463 | } |
| 464 | return RVAL_OCTAL; |
| 465 | } |
| 466 | |
Roland McGrath | d9f816f | 2004-09-04 03:39:20 +0000 | [diff] [blame] | 467 | static const struct xlat whence[] = { |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 468 | { SEEK_SET, "SEEK_SET" }, |
| 469 | { SEEK_CUR, "SEEK_CUR" }, |
| 470 | { SEEK_END, "SEEK_END" }, |
| 471 | { 0, NULL }, |
| 472 | }; |
| 473 | |
John Hughes | 70623be | 2001-03-08 13:59:00 +0000 | [diff] [blame] | 474 | #ifndef HAVE_LONG_LONG_OFF_T |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 475 | int |
| 476 | sys_lseek(tcp) |
| 477 | struct tcb *tcp; |
| 478 | { |
Wichert Akkerman | bf79f2e | 2000-09-01 21:03:06 +0000 | [diff] [blame] | 479 | off_t offset; |
| 480 | int _whence; |
| 481 | |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 482 | if (entering(tcp)) { |
| 483 | tprintf("%ld, ", tcp->u_arg[0]); |
Wichert Akkerman | bf79f2e | 2000-09-01 21:03:06 +0000 | [diff] [blame] | 484 | offset = tcp->u_arg[1]; |
| 485 | _whence = tcp->u_arg[2]; |
| 486 | if (_whence == SEEK_SET) |
| 487 | tprintf("%lu, ", offset); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 488 | else |
Roland McGrath | 186c5ac | 2002-12-15 23:58:23 +0000 | [diff] [blame] | 489 | tprintf("%ld, ", offset); |
Wichert Akkerman | bf79f2e | 2000-09-01 21:03:06 +0000 | [diff] [blame] | 490 | printxval(whence, _whence, "SEEK_???"); |
Roland McGrath | 186c5ac | 2002-12-15 23:58:23 +0000 | [diff] [blame] | 491 | } |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 492 | return RVAL_UDECIMAL; |
| 493 | } |
John Hughes | 5a826b8 | 2001-03-07 13:21:24 +0000 | [diff] [blame] | 494 | #endif |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 495 | |
Michal Ludvig | 53b320f | 2002-09-23 13:30:09 +0000 | [diff] [blame] | 496 | #ifdef LINUX |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 497 | int |
| 498 | sys_llseek (tcp) |
| 499 | struct tcb *tcp; |
| 500 | { |
| 501 | if (entering(tcp)) { |
Roland McGrath | 8c304bc | 2004-10-19 22:59:55 +0000 | [diff] [blame] | 502 | /* |
| 503 | * This one call takes explicitly two 32-bit arguments hi, lo, |
| 504 | * rather than one 64-bit argument for which LONG_LONG works |
| 505 | * appropriate for the native byte order. |
| 506 | */ |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 507 | if (tcp->u_arg[4] == SEEK_SET) |
| 508 | tprintf("%ld, %llu, ", tcp->u_arg[0], |
Roland McGrath | 8c304bc | 2004-10-19 22:59:55 +0000 | [diff] [blame] | 509 | (((long long int) tcp->u_arg[1]) << 32 |
| 510 | | (unsigned long long) (unsigned) tcp->u_arg[2])); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 511 | else |
| 512 | tprintf("%ld, %lld, ", tcp->u_arg[0], |
Roland McGrath | 8c304bc | 2004-10-19 22:59:55 +0000 | [diff] [blame] | 513 | (((long long int) tcp->u_arg[1]) << 32 |
| 514 | | (unsigned long long) (unsigned) tcp->u_arg[2])); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 515 | } |
| 516 | else { |
Wichert Akkerman | 2e2553a | 1999-05-09 00:29:58 +0000 | [diff] [blame] | 517 | long long int off; |
| 518 | if (syserror(tcp) || umove(tcp, tcp->u_arg[3], &off) < 0) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 519 | tprintf("%#lx, ", tcp->u_arg[3]); |
Wichert Akkerman | 2e2553a | 1999-05-09 00:29:58 +0000 | [diff] [blame] | 520 | else |
| 521 | tprintf("[%llu], ", off); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 522 | printxval(whence, tcp->u_arg[4], "SEEK_???"); |
| 523 | } |
| 524 | return 0; |
| 525 | } |
Roland McGrath | 186c5ac | 2002-12-15 23:58:23 +0000 | [diff] [blame] | 526 | |
| 527 | int |
| 528 | sys_readahead (tcp) |
| 529 | struct tcb *tcp; |
| 530 | { |
| 531 | if (entering(tcp)) { |
| 532 | tprintf("%ld, %lld, %ld", tcp->u_arg[0], |
| 533 | # if defined IA64 || defined X86_64 || defined ALPHA |
| 534 | (long long int) tcp->u_arg[1], tcp->u_arg[2] |
| 535 | # else |
Roland McGrath | 2fe2a3e | 2004-10-07 19:09:16 +0000 | [diff] [blame] | 536 | LONG_LONG(tcp->u_arg[1], tcp->u_arg[2]), tcp->u_arg[3] |
Roland McGrath | 186c5ac | 2002-12-15 23:58:23 +0000 | [diff] [blame] | 537 | # endif |
| 538 | ); |
| 539 | } |
| 540 | return 0; |
| 541 | } |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 542 | #endif |
| 543 | |
John Hughes | 70623be | 2001-03-08 13:59:00 +0000 | [diff] [blame] | 544 | #if _LFS64_LARGEFILE || HAVE_LONG_LONG_OFF_T |
John Hughes | bdf48f5 | 2001-03-06 15:08:09 +0000 | [diff] [blame] | 545 | int |
| 546 | sys_lseek64 (tcp) |
| 547 | struct tcb *tcp; |
| 548 | { |
| 549 | if (entering(tcp)) { |
John Hughes | 5a826b8 | 2001-03-07 13:21:24 +0000 | [diff] [blame] | 550 | long long offset; |
| 551 | ALIGN64 (tcp, 1); /* FreeBSD aligns off_t args */ |
John Hughes | 0c79e01 | 2001-03-08 14:40:06 +0000 | [diff] [blame] | 552 | offset = LONG_LONG(tcp->u_arg [1], tcp->u_arg[2]); |
John Hughes | bdf48f5 | 2001-03-06 15:08:09 +0000 | [diff] [blame] | 553 | if (tcp->u_arg[3] == SEEK_SET) |
| 554 | tprintf("%ld, %llu, ", tcp->u_arg[0], offset); |
| 555 | else |
| 556 | tprintf("%ld, %lld, ", tcp->u_arg[0], offset); |
| 557 | printxval(whence, tcp->u_arg[3], "SEEK_???"); |
| 558 | } |
| 559 | return RVAL_LUDECIMAL; |
| 560 | } |
| 561 | #endif |
| 562 | |
John Hughes | 70623be | 2001-03-08 13:59:00 +0000 | [diff] [blame] | 563 | #ifndef HAVE_LONG_LONG_OFF_T |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 564 | int |
| 565 | sys_truncate(tcp) |
| 566 | struct tcb *tcp; |
| 567 | { |
| 568 | if (entering(tcp)) { |
| 569 | printpath(tcp, tcp->u_arg[0]); |
| 570 | tprintf(", %lu", tcp->u_arg[1]); |
| 571 | } |
| 572 | return 0; |
| 573 | } |
John Hughes | 5a826b8 | 2001-03-07 13:21:24 +0000 | [diff] [blame] | 574 | #endif |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 575 | |
John Hughes | 70623be | 2001-03-08 13:59:00 +0000 | [diff] [blame] | 576 | #if _LFS64_LARGEFILE || HAVE_LONG_LONG_OFF_T |
John Hughes | 96f5147 | 2001-03-06 16:50:41 +0000 | [diff] [blame] | 577 | int |
| 578 | sys_truncate64(tcp) |
| 579 | struct tcb *tcp; |
| 580 | { |
| 581 | if (entering(tcp)) { |
John Hughes | 5a826b8 | 2001-03-07 13:21:24 +0000 | [diff] [blame] | 582 | ALIGN64 (tcp, 1); |
John Hughes | 96f5147 | 2001-03-06 16:50:41 +0000 | [diff] [blame] | 583 | printpath(tcp, tcp->u_arg[0]); |
John Hughes | 0c79e01 | 2001-03-08 14:40:06 +0000 | [diff] [blame] | 584 | tprintf(", %llu", LONG_LONG(tcp->u_arg[1],tcp->u_arg[2])); |
John Hughes | 96f5147 | 2001-03-06 16:50:41 +0000 | [diff] [blame] | 585 | } |
| 586 | return 0; |
| 587 | } |
| 588 | #endif |
| 589 | |
John Hughes | 70623be | 2001-03-08 13:59:00 +0000 | [diff] [blame] | 590 | #ifndef HAVE_LONG_LONG_OFF_T |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 591 | int |
| 592 | sys_ftruncate(tcp) |
| 593 | struct tcb *tcp; |
| 594 | { |
| 595 | if (entering(tcp)) { |
| 596 | tprintf("%ld, %lu", tcp->u_arg[0], tcp->u_arg[1]); |
| 597 | } |
| 598 | return 0; |
| 599 | } |
John Hughes | 5a826b8 | 2001-03-07 13:21:24 +0000 | [diff] [blame] | 600 | #endif |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 601 | |
John Hughes | 70623be | 2001-03-08 13:59:00 +0000 | [diff] [blame] | 602 | #if _LFS64_LARGEFILE || HAVE_LONG_LONG_OFF_T |
John Hughes | 96f5147 | 2001-03-06 16:50:41 +0000 | [diff] [blame] | 603 | int |
| 604 | sys_ftruncate64(tcp) |
| 605 | struct tcb *tcp; |
| 606 | { |
| 607 | if (entering(tcp)) { |
John Hughes | 5a826b8 | 2001-03-07 13:21:24 +0000 | [diff] [blame] | 608 | ALIGN64 (tcp, 1); |
John Hughes | 96f5147 | 2001-03-06 16:50:41 +0000 | [diff] [blame] | 609 | tprintf("%ld, %llu", tcp->u_arg[0], |
John Hughes | 0c79e01 | 2001-03-08 14:40:06 +0000 | [diff] [blame] | 610 | LONG_LONG(tcp->u_arg[1] ,tcp->u_arg[2])); |
John Hughes | 96f5147 | 2001-03-06 16:50:41 +0000 | [diff] [blame] | 611 | } |
| 612 | return 0; |
| 613 | } |
| 614 | #endif |
| 615 | |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 616 | /* several stats */ |
| 617 | |
Roland McGrath | d9f816f | 2004-09-04 03:39:20 +0000 | [diff] [blame] | 618 | static const struct xlat modetypes[] = { |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 619 | { S_IFREG, "S_IFREG" }, |
| 620 | { S_IFSOCK, "S_IFSOCK" }, |
| 621 | { S_IFIFO, "S_IFIFO" }, |
| 622 | { S_IFLNK, "S_IFLNK" }, |
| 623 | { S_IFDIR, "S_IFDIR" }, |
| 624 | { S_IFBLK, "S_IFBLK" }, |
| 625 | { S_IFCHR, "S_IFCHR" }, |
| 626 | { 0, NULL }, |
| 627 | }; |
| 628 | |
Roland McGrath | f9c49b2 | 2004-10-06 22:11:54 +0000 | [diff] [blame] | 629 | static const char * |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 630 | sprintmode(mode) |
| 631 | int mode; |
| 632 | { |
| 633 | static char buf[64]; |
Roland McGrath | f9c49b2 | 2004-10-06 22:11:54 +0000 | [diff] [blame] | 634 | const char *s; |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 635 | |
| 636 | if ((mode & S_IFMT) == 0) |
| 637 | s = ""; |
| 638 | else if ((s = xlookup(modetypes, mode & S_IFMT)) == NULL) { |
| 639 | sprintf(buf, "%#o", mode); |
| 640 | return buf; |
| 641 | } |
| 642 | sprintf(buf, "%s%s%s%s", s, |
| 643 | (mode & S_ISUID) ? "|S_ISUID" : "", |
| 644 | (mode & S_ISGID) ? "|S_ISGID" : "", |
| 645 | (mode & S_ISVTX) ? "|S_ISVTX" : ""); |
| 646 | mode &= ~(S_IFMT|S_ISUID|S_ISGID|S_ISVTX); |
| 647 | if (mode) |
| 648 | sprintf(buf + strlen(buf), "|%#o", mode); |
| 649 | s = (*buf == '|') ? buf + 1 : buf; |
| 650 | return *s ? s : "0"; |
| 651 | } |
| 652 | |
| 653 | static char * |
| 654 | sprinttime(t) |
| 655 | time_t t; |
| 656 | { |
| 657 | struct tm *tmp; |
| 658 | static char buf[32]; |
| 659 | |
| 660 | if (t == 0) { |
| 661 | sprintf(buf, "0"); |
| 662 | return buf; |
| 663 | } |
| 664 | tmp = localtime(&t); |
| 665 | sprintf(buf, "%02d/%02d/%02d-%02d:%02d:%02d", |
Wichert Akkerman | 3ed6dc2 | 2000-01-11 14:41:09 +0000 | [diff] [blame] | 666 | tmp->tm_year + 1900, tmp->tm_mon + 1, tmp->tm_mday, |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 667 | tmp->tm_hour, tmp->tm_min, tmp->tm_sec); |
| 668 | return buf; |
| 669 | } |
| 670 | |
| 671 | #ifdef LINUXSPARC |
| 672 | typedef struct { |
| 673 | int tv_sec; |
| 674 | int tv_nsec; |
| 675 | } timestruct_t; |
| 676 | |
| 677 | struct solstat { |
| 678 | unsigned st_dev; |
| 679 | int st_pad1[3]; /* network id */ |
| 680 | unsigned st_ino; |
| 681 | unsigned st_mode; |
| 682 | unsigned st_nlink; |
| 683 | unsigned st_uid; |
| 684 | unsigned st_gid; |
| 685 | unsigned st_rdev; |
| 686 | int st_pad2[2]; |
| 687 | int st_size; |
| 688 | int st_pad3; /* st_size, off_t expansion */ |
| 689 | timestruct_t st_atime; |
| 690 | timestruct_t st_mtime; |
| 691 | timestruct_t st_ctime; |
| 692 | int st_blksize; |
| 693 | int st_blocks; |
| 694 | char st_fstype[16]; |
| 695 | int st_pad4[8]; /* expansion area */ |
| 696 | }; |
| 697 | |
| 698 | static void |
| 699 | printstatsol(tcp, addr) |
| 700 | struct tcb *tcp; |
Wichert Akkerman | 8b1b40c | 2000-02-03 21:58:30 +0000 | [diff] [blame] | 701 | long addr; |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 702 | { |
| 703 | struct solstat statbuf; |
| 704 | |
| 705 | if (!addr) { |
| 706 | tprintf("NULL"); |
| 707 | return; |
| 708 | } |
| 709 | if (syserror(tcp) || !verbose(tcp)) { |
Wichert Akkerman | 8b1b40c | 2000-02-03 21:58:30 +0000 | [diff] [blame] | 710 | tprintf("%#lx", addr); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 711 | return; |
| 712 | } |
| 713 | if (umove(tcp, addr, &statbuf) < 0) { |
| 714 | tprintf("{...}"); |
| 715 | return; |
| 716 | } |
| 717 | if (!abbrev(tcp)) { |
| 718 | tprintf("{st_dev=makedev(%lu, %lu), st_ino=%lu, st_mode=%s, ", |
| 719 | (unsigned long) ((statbuf.st_dev >> 18) & 0x3fff), |
| 720 | (unsigned long) (statbuf.st_dev & 0x3ffff), |
| 721 | (unsigned long) statbuf.st_ino, |
| 722 | sprintmode(statbuf.st_mode)); |
| 723 | tprintf("st_nlink=%lu, st_uid=%lu, st_gid=%lu, ", |
| 724 | (unsigned long) statbuf.st_nlink, |
| 725 | (unsigned long) statbuf.st_uid, |
| 726 | (unsigned long) statbuf.st_gid); |
| 727 | tprintf("st_blksize=%lu, ", (unsigned long) statbuf.st_blksize); |
| 728 | tprintf("st_blocks=%lu, ", (unsigned long) statbuf.st_blocks); |
| 729 | } |
| 730 | else |
| 731 | tprintf("{st_mode=%s, ", sprintmode(statbuf.st_mode)); |
| 732 | switch (statbuf.st_mode & S_IFMT) { |
| 733 | case S_IFCHR: case S_IFBLK: |
| 734 | tprintf("st_rdev=makedev(%lu, %lu), ", |
| 735 | (unsigned long) ((statbuf.st_rdev >> 18) & 0x3fff), |
| 736 | (unsigned long) (statbuf.st_rdev & 0x3ffff)); |
| 737 | break; |
| 738 | default: |
| 739 | tprintf("st_size=%u, ", statbuf.st_size); |
| 740 | break; |
| 741 | } |
| 742 | if (!abbrev(tcp)) { |
| 743 | tprintf("st_atime=%s, ", sprinttime(statbuf.st_atime)); |
| 744 | tprintf("st_mtime=%s, ", sprinttime(statbuf.st_mtime)); |
| 745 | tprintf("st_ctime=%s}", sprinttime(statbuf.st_ctime)); |
| 746 | } |
| 747 | else |
| 748 | tprintf("...}"); |
| 749 | } |
Roland McGrath | 6d1a65c | 2004-07-12 07:44:08 +0000 | [diff] [blame] | 750 | |
| 751 | #if defined (SPARC64) |
| 752 | static void |
| 753 | printstat_sparc64(tcp, addr) |
| 754 | struct tcb *tcp; |
| 755 | long addr; |
| 756 | { |
| 757 | struct stat_sparc64 statbuf; |
| 758 | |
| 759 | if (!addr) { |
| 760 | tprintf("NULL"); |
| 761 | return; |
| 762 | } |
| 763 | if (syserror(tcp) || !verbose(tcp)) { |
| 764 | tprintf("%#lx", addr); |
| 765 | return; |
| 766 | } |
| 767 | if (umove(tcp, addr, &statbuf) < 0) { |
| 768 | tprintf("{...}"); |
| 769 | return; |
| 770 | } |
| 771 | |
| 772 | if (!abbrev(tcp)) { |
| 773 | tprintf("{st_dev=makedev(%lu, %lu), st_ino=%lu, st_mode=%s, ", |
| 774 | (unsigned long) major(statbuf.st_dev), |
| 775 | (unsigned long) minor(statbuf.st_dev), |
| 776 | (unsigned long) statbuf.st_ino, |
| 777 | sprintmode(statbuf.st_mode)); |
| 778 | tprintf("st_nlink=%lu, st_uid=%lu, st_gid=%lu, ", |
| 779 | (unsigned long) statbuf.st_nlink, |
| 780 | (unsigned long) statbuf.st_uid, |
| 781 | (unsigned long) statbuf.st_gid); |
| 782 | tprintf("st_blksize=%lu, ", |
| 783 | (unsigned long) statbuf.st_blksize); |
| 784 | tprintf("st_blocks=%lu, ", |
| 785 | (unsigned long) statbuf.st_blocks); |
| 786 | } |
| 787 | else |
| 788 | tprintf("{st_mode=%s, ", sprintmode(statbuf.st_mode)); |
| 789 | switch (statbuf.st_mode & S_IFMT) { |
| 790 | case S_IFCHR: case S_IFBLK: |
| 791 | tprintf("st_rdev=makedev(%lu, %lu), ", |
| 792 | (unsigned long) major(statbuf.st_rdev), |
| 793 | (unsigned long) minor(statbuf.st_rdev)); |
| 794 | break; |
| 795 | default: |
| 796 | tprintf("st_size=%lu, ", statbuf.st_size); |
| 797 | break; |
| 798 | } |
| 799 | if (!abbrev(tcp)) { |
| 800 | tprintf("st_atime=%s, ", sprinttime(statbuf.st_atime)); |
| 801 | tprintf("st_mtime=%s, ", sprinttime(statbuf.st_mtime)); |
| 802 | tprintf("st_ctime=%s", sprinttime(statbuf.st_ctime)); |
| 803 | tprintf("}"); |
| 804 | } |
| 805 | else |
| 806 | tprintf("...}"); |
| 807 | } |
| 808 | #endif /* SPARC64 */ |
Wichert Akkerman | b859bea | 1999-04-18 22:50:50 +0000 | [diff] [blame] | 809 | #endif /* LINUXSPARC */ |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 810 | |
Roland McGrath | a4d4853 | 2005-06-08 20:45:28 +0000 | [diff] [blame] | 811 | static const struct xlat fileflags[] = { |
John Hughes | c0fc3fd | 2001-03-08 16:10:40 +0000 | [diff] [blame] | 812 | #ifdef FREEBSD |
Wichert Akkerman | bf79f2e | 2000-09-01 21:03:06 +0000 | [diff] [blame] | 813 | { UF_NODUMP, "UF_NODUMP" }, |
| 814 | { UF_IMMUTABLE, "UF_IMMUTABLE" }, |
| 815 | { UF_APPEND, "UF_APPEND" }, |
| 816 | { UF_OPAQUE, "UF_OPAQUE" }, |
| 817 | { UF_NOUNLINK, "UF_NOUNLINK" }, |
| 818 | { SF_ARCHIVED, "SF_ARCHIVED" }, |
| 819 | { SF_IMMUTABLE, "SF_IMMUTABLE" }, |
| 820 | { SF_APPEND, "SF_APPEND" }, |
| 821 | { SF_NOUNLINK, "SF_NOUNLINK" }, |
John Hughes | c0fc3fd | 2001-03-08 16:10:40 +0000 | [diff] [blame] | 822 | #elif UNIXWARE >= 2 |
| 823 | #ifdef _S_ISMLD |
| 824 | { _S_ISMLD, "_S_ISMLD" }, |
| 825 | #endif |
| 826 | #ifdef _S_ISMOUNTED |
| 827 | { _S_ISMOUNTED, "_S_ISMOUNTED" }, |
| 828 | #endif |
| 829 | #endif |
Wichert Akkerman | bf79f2e | 2000-09-01 21:03:06 +0000 | [diff] [blame] | 830 | { 0, NULL }, |
| 831 | }; |
| 832 | |
John Hughes | c0fc3fd | 2001-03-08 16:10:40 +0000 | [diff] [blame] | 833 | #ifdef FREEBSD |
Wichert Akkerman | bf79f2e | 2000-09-01 21:03:06 +0000 | [diff] [blame] | 834 | int |
| 835 | sys_chflags(tcp) |
| 836 | struct tcb *tcp; |
| 837 | { |
| 838 | if (entering(tcp)) { |
| 839 | printpath(tcp, tcp->u_arg[0]); |
| 840 | tprintf(", "); |
Roland McGrath | b2dee13 | 2005-06-01 19:02:36 +0000 | [diff] [blame] | 841 | printflags(fileflags, tcp->u_arg[1], "UF_???"); |
Wichert Akkerman | bf79f2e | 2000-09-01 21:03:06 +0000 | [diff] [blame] | 842 | } |
| 843 | return 0; |
| 844 | } |
| 845 | |
| 846 | int |
| 847 | sys_fchflags(tcp) |
| 848 | struct tcb *tcp; |
| 849 | { |
| 850 | if (entering(tcp)) { |
| 851 | tprintf("%ld, ", tcp->u_arg[0]); |
Roland McGrath | b2dee13 | 2005-06-01 19:02:36 +0000 | [diff] [blame] | 852 | printflags(fileflags, tcp->u_arg[1], "UF_???"); |
Wichert Akkerman | bf79f2e | 2000-09-01 21:03:06 +0000 | [diff] [blame] | 853 | } |
| 854 | return 0; |
| 855 | } |
| 856 | #endif |
| 857 | |
John Hughes | 70623be | 2001-03-08 13:59:00 +0000 | [diff] [blame] | 858 | #ifndef HAVE_LONG_LONG_OFF_T |
Wichert Akkerman | 328c5e7 | 1999-04-16 00:21:26 +0000 | [diff] [blame] | 859 | static void |
| 860 | realprintstat(tcp, statbuf) |
| 861 | struct tcb *tcp; |
Wichert Akkerman | 328c5e7 | 1999-04-16 00:21:26 +0000 | [diff] [blame] | 862 | struct stat *statbuf; |
Wichert Akkerman | 328c5e7 | 1999-04-16 00:21:26 +0000 | [diff] [blame] | 863 | { |
| 864 | if (!abbrev(tcp)) { |
| 865 | tprintf("{st_dev=makedev(%lu, %lu), st_ino=%lu, st_mode=%s, ", |
| 866 | (unsigned long) major(statbuf->st_dev), |
| 867 | (unsigned long) minor(statbuf->st_dev), |
| 868 | (unsigned long) statbuf->st_ino, |
| 869 | sprintmode(statbuf->st_mode)); |
| 870 | tprintf("st_nlink=%lu, st_uid=%lu, st_gid=%lu, ", |
| 871 | (unsigned long) statbuf->st_nlink, |
| 872 | (unsigned long) statbuf->st_uid, |
| 873 | (unsigned long) statbuf->st_gid); |
Roland McGrath | 6d2b349 | 2002-12-30 00:51:30 +0000 | [diff] [blame] | 874 | #ifdef HAVE_STRUCT_STAT_ST_BLKSIZE |
Wichert Akkerman | 328c5e7 | 1999-04-16 00:21:26 +0000 | [diff] [blame] | 875 | tprintf("st_blksize=%lu, ", (unsigned long) statbuf->st_blksize); |
Roland McGrath | 6d2b349 | 2002-12-30 00:51:30 +0000 | [diff] [blame] | 876 | #endif /* HAVE_STRUCT_STAT_ST_BLKSIZE */ |
| 877 | #ifdef HAVE_STRUCT_STAT_ST_BLOCKS |
Wichert Akkerman | 328c5e7 | 1999-04-16 00:21:26 +0000 | [diff] [blame] | 878 | tprintf("st_blocks=%lu, ", (unsigned long) statbuf->st_blocks); |
Roland McGrath | 6d2b349 | 2002-12-30 00:51:30 +0000 | [diff] [blame] | 879 | #endif /* HAVE_STRUCT_STAT_ST_BLOCKS */ |
Wichert Akkerman | 328c5e7 | 1999-04-16 00:21:26 +0000 | [diff] [blame] | 880 | } |
| 881 | else |
| 882 | tprintf("{st_mode=%s, ", sprintmode(statbuf->st_mode)); |
| 883 | switch (statbuf->st_mode & S_IFMT) { |
| 884 | case S_IFCHR: case S_IFBLK: |
Roland McGrath | 6d2b349 | 2002-12-30 00:51:30 +0000 | [diff] [blame] | 885 | #ifdef HAVE_STRUCT_STAT_ST_RDEV |
Wichert Akkerman | 328c5e7 | 1999-04-16 00:21:26 +0000 | [diff] [blame] | 886 | tprintf("st_rdev=makedev(%lu, %lu), ", |
| 887 | (unsigned long) major(statbuf->st_rdev), |
| 888 | (unsigned long) minor(statbuf->st_rdev)); |
Roland McGrath | 6d2b349 | 2002-12-30 00:51:30 +0000 | [diff] [blame] | 889 | #else /* !HAVE_STRUCT_STAT_ST_RDEV */ |
Wichert Akkerman | 328c5e7 | 1999-04-16 00:21:26 +0000 | [diff] [blame] | 890 | tprintf("st_size=makedev(%lu, %lu), ", |
| 891 | (unsigned long) major(statbuf->st_size), |
| 892 | (unsigned long) minor(statbuf->st_size)); |
Roland McGrath | 6d2b349 | 2002-12-30 00:51:30 +0000 | [diff] [blame] | 893 | #endif /* !HAVE_STRUCT_STAT_ST_RDEV */ |
Wichert Akkerman | 328c5e7 | 1999-04-16 00:21:26 +0000 | [diff] [blame] | 894 | break; |
| 895 | default: |
| 896 | tprintf("st_size=%lu, ", statbuf->st_size); |
| 897 | break; |
| 898 | } |
| 899 | if (!abbrev(tcp)) { |
| 900 | tprintf("st_atime=%s, ", sprinttime(statbuf->st_atime)); |
| 901 | tprintf("st_mtime=%s, ", sprinttime(statbuf->st_mtime)); |
John Hughes | c0fc3fd | 2001-03-08 16:10:40 +0000 | [diff] [blame] | 902 | tprintf("st_ctime=%s", sprinttime(statbuf->st_ctime)); |
Roland McGrath | 6d2b349 | 2002-12-30 00:51:30 +0000 | [diff] [blame] | 903 | #if HAVE_STRUCT_STAT_ST_FLAGS |
John Hughes | c0fc3fd | 2001-03-08 16:10:40 +0000 | [diff] [blame] | 904 | tprintf(", st_flags="); |
Roland McGrath | b2dee13 | 2005-06-01 19:02:36 +0000 | [diff] [blame] | 905 | printflags(fileflags, statbuf->st_flags, "UF_???"); |
John Hughes | c0fc3fd | 2001-03-08 16:10:40 +0000 | [diff] [blame] | 906 | #endif |
Roland McGrath | 6d2b349 | 2002-12-30 00:51:30 +0000 | [diff] [blame] | 907 | #if HAVE_STRUCT_STAT_ST_ACLCNT |
John Hughes | c0fc3fd | 2001-03-08 16:10:40 +0000 | [diff] [blame] | 908 | tprintf(", st_aclcnt=%d", statbuf->st_aclcnt); |
| 909 | #endif |
Roland McGrath | 6d2b349 | 2002-12-30 00:51:30 +0000 | [diff] [blame] | 910 | #if HAVE_STRUCT_STAT_ST_LEVEL |
John Hughes | c0fc3fd | 2001-03-08 16:10:40 +0000 | [diff] [blame] | 911 | tprintf(", st_level=%ld", statbuf->st_level); |
| 912 | #endif |
Roland McGrath | 6d2b349 | 2002-12-30 00:51:30 +0000 | [diff] [blame] | 913 | #if HAVE_STRUCT_STAT_ST_FSTYPE |
John Hughes | c0fc3fd | 2001-03-08 16:10:40 +0000 | [diff] [blame] | 914 | tprintf(", st_fstype=%.*s", |
| 915 | (int) sizeof statbuf->st_fstype, statbuf->st_fstype); |
| 916 | #endif |
Roland McGrath | 6d2b349 | 2002-12-30 00:51:30 +0000 | [diff] [blame] | 917 | #if HAVE_STRUCT_STAT_ST_GEN |
John Hughes | c0fc3fd | 2001-03-08 16:10:40 +0000 | [diff] [blame] | 918 | tprintf(", st_gen=%u", statbuf->st_gen); |
| 919 | #endif |
| 920 | tprintf("}"); |
Wichert Akkerman | 328c5e7 | 1999-04-16 00:21:26 +0000 | [diff] [blame] | 921 | } |
| 922 | else |
| 923 | tprintf("...}"); |
| 924 | } |
| 925 | |
Nate Sammons | 771a6ff | 1999-04-05 22:39:31 +0000 | [diff] [blame] | 926 | |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 927 | static void |
| 928 | printstat(tcp, addr) |
| 929 | struct tcb *tcp; |
Wichert Akkerman | 8b1b40c | 2000-02-03 21:58:30 +0000 | [diff] [blame] | 930 | long addr; |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 931 | { |
Wichert Akkerman | 328c5e7 | 1999-04-16 00:21:26 +0000 | [diff] [blame] | 932 | struct stat statbuf; |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 933 | |
| 934 | #ifdef LINUXSPARC |
| 935 | if (current_personality == 1) { |
| 936 | printstatsol(tcp, addr); |
| 937 | return; |
| 938 | } |
Roland McGrath | 6d1a65c | 2004-07-12 07:44:08 +0000 | [diff] [blame] | 939 | #ifdef SPARC64 |
| 940 | else if (current_personality == 2) { |
| 941 | printstat_sparc64(tcp, addr); |
| 942 | return; |
| 943 | } |
| 944 | #endif |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 945 | #endif /* LINUXSPARC */ |
| 946 | |
| 947 | if (!addr) { |
| 948 | tprintf("NULL"); |
| 949 | return; |
| 950 | } |
| 951 | if (syserror(tcp) || !verbose(tcp)) { |
Wichert Akkerman | 8b1b40c | 2000-02-03 21:58:30 +0000 | [diff] [blame] | 952 | tprintf("%#lx", addr); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 953 | return; |
| 954 | } |
| 955 | if (umove(tcp, addr, &statbuf) < 0) { |
| 956 | tprintf("{...}"); |
| 957 | return; |
| 958 | } |
Wichert Akkerman | 328c5e7 | 1999-04-16 00:21:26 +0000 | [diff] [blame] | 959 | |
| 960 | realprintstat(tcp, &statbuf); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 961 | } |
John Hughes | 70623be | 2001-03-08 13:59:00 +0000 | [diff] [blame] | 962 | #endif /* !HAVE_LONG_LONG_OFF_T */ |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 963 | |
Wichert Akkerman | c792698 | 2000-04-10 22:22:31 +0000 | [diff] [blame] | 964 | #ifdef HAVE_STAT64 |
Wichert Akkerman | 328c5e7 | 1999-04-16 00:21:26 +0000 | [diff] [blame] | 965 | static void |
Ulrich Drepper | 7f02c4d | 1999-12-24 08:01:34 +0000 | [diff] [blame] | 966 | printstat64(tcp, addr) |
| 967 | struct tcb *tcp; |
Wichert Akkerman | 8b1b40c | 2000-02-03 21:58:30 +0000 | [diff] [blame] | 968 | long addr; |
Ulrich Drepper | 7f02c4d | 1999-12-24 08:01:34 +0000 | [diff] [blame] | 969 | { |
| 970 | struct stat64 statbuf; |
| 971 | |
| 972 | #ifdef LINUXSPARC |
| 973 | if (current_personality == 1) { |
| 974 | printstatsol(tcp, addr); |
| 975 | return; |
| 976 | } |
Roland McGrath | 6d1a65c | 2004-07-12 07:44:08 +0000 | [diff] [blame] | 977 | #ifdef SPARC64 |
| 978 | else if (current_personality == 2) { |
| 979 | printstat_sparc64(tcp, addr); |
| 980 | return; |
| 981 | } |
| 982 | #endif |
Ulrich Drepper | 7f02c4d | 1999-12-24 08:01:34 +0000 | [diff] [blame] | 983 | #endif /* LINUXSPARC */ |
| 984 | |
| 985 | if (!addr) { |
| 986 | tprintf("NULL"); |
| 987 | return; |
| 988 | } |
| 989 | if (syserror(tcp) || !verbose(tcp)) { |
Wichert Akkerman | 8b1b40c | 2000-02-03 21:58:30 +0000 | [diff] [blame] | 990 | tprintf("%#lx", addr); |
Ulrich Drepper | 7f02c4d | 1999-12-24 08:01:34 +0000 | [diff] [blame] | 991 | return; |
| 992 | } |
| 993 | if (umove(tcp, addr, &statbuf) < 0) { |
| 994 | tprintf("{...}"); |
| 995 | return; |
| 996 | } |
| 997 | |
| 998 | if (!abbrev(tcp)) { |
Wichert Akkerman | d077c45 | 2000-08-10 18:16:15 +0000 | [diff] [blame] | 999 | #ifdef HAVE_LONG_LONG |
| 1000 | tprintf("{st_dev=makedev(%lu, %lu), st_ino=%llu, st_mode=%s, ", |
| 1001 | #else |
Ulrich Drepper | 7f02c4d | 1999-12-24 08:01:34 +0000 | [diff] [blame] | 1002 | tprintf("{st_dev=makedev(%lu, %lu), st_ino=%lu, st_mode=%s, ", |
Wichert Akkerman | d077c45 | 2000-08-10 18:16:15 +0000 | [diff] [blame] | 1003 | #endif |
Ulrich Drepper | 7f02c4d | 1999-12-24 08:01:34 +0000 | [diff] [blame] | 1004 | (unsigned long) major(statbuf.st_dev), |
| 1005 | (unsigned long) minor(statbuf.st_dev), |
Wichert Akkerman | d077c45 | 2000-08-10 18:16:15 +0000 | [diff] [blame] | 1006 | #ifdef HAVE_LONG_LONG |
| 1007 | (unsigned long long) statbuf.st_ino, |
| 1008 | #else |
Ulrich Drepper | 7f02c4d | 1999-12-24 08:01:34 +0000 | [diff] [blame] | 1009 | (unsigned long) statbuf.st_ino, |
Wichert Akkerman | d077c45 | 2000-08-10 18:16:15 +0000 | [diff] [blame] | 1010 | #endif |
Ulrich Drepper | 7f02c4d | 1999-12-24 08:01:34 +0000 | [diff] [blame] | 1011 | sprintmode(statbuf.st_mode)); |
| 1012 | tprintf("st_nlink=%lu, st_uid=%lu, st_gid=%lu, ", |
| 1013 | (unsigned long) statbuf.st_nlink, |
| 1014 | (unsigned long) statbuf.st_uid, |
| 1015 | (unsigned long) statbuf.st_gid); |
Roland McGrath | 6d2b349 | 2002-12-30 00:51:30 +0000 | [diff] [blame] | 1016 | #ifdef HAVE_STRUCT_STAT_ST_BLKSIZE |
Ulrich Drepper | 7f02c4d | 1999-12-24 08:01:34 +0000 | [diff] [blame] | 1017 | tprintf("st_blksize=%lu, ", |
| 1018 | (unsigned long) statbuf.st_blksize); |
Roland McGrath | 6d2b349 | 2002-12-30 00:51:30 +0000 | [diff] [blame] | 1019 | #endif /* HAVE_STRUCT_STAT_ST_BLKSIZE */ |
| 1020 | #ifdef HAVE_STRUCT_STAT_ST_BLOCKS |
Ulrich Drepper | 7f02c4d | 1999-12-24 08:01:34 +0000 | [diff] [blame] | 1021 | tprintf("st_blocks=%lu, ", (unsigned long) statbuf.st_blocks); |
Roland McGrath | 6d2b349 | 2002-12-30 00:51:30 +0000 | [diff] [blame] | 1022 | #endif /* HAVE_STRUCT_STAT_ST_BLOCKS */ |
Ulrich Drepper | 7f02c4d | 1999-12-24 08:01:34 +0000 | [diff] [blame] | 1023 | } |
| 1024 | else |
| 1025 | tprintf("{st_mode=%s, ", sprintmode(statbuf.st_mode)); |
| 1026 | switch (statbuf.st_mode & S_IFMT) { |
| 1027 | case S_IFCHR: case S_IFBLK: |
Roland McGrath | 6d2b349 | 2002-12-30 00:51:30 +0000 | [diff] [blame] | 1028 | #ifdef HAVE_STRUCT_STAT_ST_RDEV |
Ulrich Drepper | 7f02c4d | 1999-12-24 08:01:34 +0000 | [diff] [blame] | 1029 | tprintf("st_rdev=makedev(%lu, %lu), ", |
| 1030 | (unsigned long) major(statbuf.st_rdev), |
| 1031 | (unsigned long) minor(statbuf.st_rdev)); |
Roland McGrath | 6d2b349 | 2002-12-30 00:51:30 +0000 | [diff] [blame] | 1032 | #else /* !HAVE_STRUCT_STAT_ST_RDEV */ |
Ulrich Drepper | 7f02c4d | 1999-12-24 08:01:34 +0000 | [diff] [blame] | 1033 | tprintf("st_size=makedev(%lu, %lu), ", |
| 1034 | (unsigned long) major(statbuf.st_size), |
| 1035 | (unsigned long) minor(statbuf.st_size)); |
Roland McGrath | 6d2b349 | 2002-12-30 00:51:30 +0000 | [diff] [blame] | 1036 | #endif /* !HAVE_STRUCT_STAT_ST_RDEV */ |
Ulrich Drepper | 7f02c4d | 1999-12-24 08:01:34 +0000 | [diff] [blame] | 1037 | break; |
| 1038 | default: |
| 1039 | tprintf("st_size=%llu, ", statbuf.st_size); |
| 1040 | break; |
| 1041 | } |
| 1042 | if (!abbrev(tcp)) { |
| 1043 | tprintf("st_atime=%s, ", sprinttime(statbuf.st_atime)); |
| 1044 | tprintf("st_mtime=%s, ", sprinttime(statbuf.st_mtime)); |
John Hughes | c0fc3fd | 2001-03-08 16:10:40 +0000 | [diff] [blame] | 1045 | tprintf("st_ctime=%s", sprinttime(statbuf.st_ctime)); |
Roland McGrath | 6d2b349 | 2002-12-30 00:51:30 +0000 | [diff] [blame] | 1046 | #if HAVE_STRUCT_STAT_ST_FLAGS |
John Hughes | c0fc3fd | 2001-03-08 16:10:40 +0000 | [diff] [blame] | 1047 | tprintf(", st_flags="); |
Roland McGrath | b2dee13 | 2005-06-01 19:02:36 +0000 | [diff] [blame] | 1048 | printflags(fileflags, statbuf.st_flags, "UF_???"); |
John Hughes | c0fc3fd | 2001-03-08 16:10:40 +0000 | [diff] [blame] | 1049 | #endif |
Roland McGrath | 6d2b349 | 2002-12-30 00:51:30 +0000 | [diff] [blame] | 1050 | #if HAVE_STRUCT_STAT_ST_ACLCNT |
John Hughes | c0fc3fd | 2001-03-08 16:10:40 +0000 | [diff] [blame] | 1051 | tprintf(", st_aclcnt=%d", statbuf.st_aclcnt); |
| 1052 | #endif |
Roland McGrath | 6d2b349 | 2002-12-30 00:51:30 +0000 | [diff] [blame] | 1053 | #if HAVE_STRUCT_STAT_ST_LEVEL |
John Hughes | c0fc3fd | 2001-03-08 16:10:40 +0000 | [diff] [blame] | 1054 | tprintf(", st_level=%ld", statbuf.st_level); |
| 1055 | #endif |
Roland McGrath | 6d2b349 | 2002-12-30 00:51:30 +0000 | [diff] [blame] | 1056 | #if HAVE_STRUCT_STAT_ST_FSTYPE |
John Hughes | c0fc3fd | 2001-03-08 16:10:40 +0000 | [diff] [blame] | 1057 | tprintf(", st_fstype=%.*s", |
| 1058 | (int) sizeof statbuf.st_fstype, statbuf.st_fstype); |
| 1059 | #endif |
Roland McGrath | 6d2b349 | 2002-12-30 00:51:30 +0000 | [diff] [blame] | 1060 | #if HAVE_STRUCT_STAT_ST_GEN |
John Hughes | c0fc3fd | 2001-03-08 16:10:40 +0000 | [diff] [blame] | 1061 | tprintf(", st_gen=%u", statbuf.st_gen); |
| 1062 | #endif |
| 1063 | tprintf("}"); |
Ulrich Drepper | 7f02c4d | 1999-12-24 08:01:34 +0000 | [diff] [blame] | 1064 | } |
| 1065 | else |
| 1066 | tprintf("...}"); |
| 1067 | } |
Wichert Akkerman | c792698 | 2000-04-10 22:22:31 +0000 | [diff] [blame] | 1068 | #endif /* HAVE_STAT64 */ |
Ulrich Drepper | 7f02c4d | 1999-12-24 08:01:34 +0000 | [diff] [blame] | 1069 | |
Roland McGrath | 79db8af | 2003-06-27 21:20:09 +0000 | [diff] [blame] | 1070 | #if defined(LINUX) && defined(HAVE_STRUCT___OLD_KERNEL_STAT) |
Ulrich Drepper | 7f02c4d | 1999-12-24 08:01:34 +0000 | [diff] [blame] | 1071 | static void |
Wichert Akkerman | 328c5e7 | 1999-04-16 00:21:26 +0000 | [diff] [blame] | 1072 | convertoldstat(oldbuf, newbuf) |
Wichert Akkerman | 25d0c4f | 1999-04-18 19:35:42 +0000 | [diff] [blame] | 1073 | const struct __old_kernel_stat *oldbuf; |
| 1074 | struct stat *newbuf; |
Wichert Akkerman | 328c5e7 | 1999-04-16 00:21:26 +0000 | [diff] [blame] | 1075 | { |
| 1076 | newbuf->st_dev=oldbuf->st_dev; |
| 1077 | newbuf->st_ino=oldbuf->st_ino; |
| 1078 | newbuf->st_mode=oldbuf->st_mode; |
| 1079 | newbuf->st_nlink=oldbuf->st_nlink; |
| 1080 | newbuf->st_uid=oldbuf->st_uid; |
| 1081 | newbuf->st_gid=oldbuf->st_gid; |
| 1082 | newbuf->st_rdev=oldbuf->st_rdev; |
| 1083 | newbuf->st_size=oldbuf->st_size; |
| 1084 | newbuf->st_atime=oldbuf->st_atime; |
| 1085 | newbuf->st_mtime=oldbuf->st_mtime; |
| 1086 | newbuf->st_ctime=oldbuf->st_ctime; |
| 1087 | newbuf->st_blksize=0; /* not supported in old_stat */ |
| 1088 | newbuf->st_blocks=0; /* not supported in old_stat */ |
| 1089 | } |
Wichert Akkerman | 328c5e7 | 1999-04-16 00:21:26 +0000 | [diff] [blame] | 1090 | |
| 1091 | |
Wichert Akkerman | 328c5e7 | 1999-04-16 00:21:26 +0000 | [diff] [blame] | 1092 | static void |
| 1093 | printoldstat(tcp, addr) |
| 1094 | struct tcb *tcp; |
Wichert Akkerman | 8b1b40c | 2000-02-03 21:58:30 +0000 | [diff] [blame] | 1095 | long addr; |
Wichert Akkerman | 328c5e7 | 1999-04-16 00:21:26 +0000 | [diff] [blame] | 1096 | { |
Wichert Akkerman | 25d0c4f | 1999-04-18 19:35:42 +0000 | [diff] [blame] | 1097 | struct __old_kernel_stat statbuf; |
| 1098 | struct stat newstatbuf; |
Wichert Akkerman | 328c5e7 | 1999-04-16 00:21:26 +0000 | [diff] [blame] | 1099 | |
| 1100 | #ifdef LINUXSPARC |
| 1101 | if (current_personality == 1) { |
| 1102 | printstatsol(tcp, addr); |
| 1103 | return; |
| 1104 | } |
| 1105 | #endif /* LINUXSPARC */ |
| 1106 | |
| 1107 | if (!addr) { |
| 1108 | tprintf("NULL"); |
| 1109 | return; |
| 1110 | } |
| 1111 | if (syserror(tcp) || !verbose(tcp)) { |
Wichert Akkerman | 8b1b40c | 2000-02-03 21:58:30 +0000 | [diff] [blame] | 1112 | tprintf("%#lx", addr); |
Wichert Akkerman | 328c5e7 | 1999-04-16 00:21:26 +0000 | [diff] [blame] | 1113 | return; |
| 1114 | } |
| 1115 | if (umove(tcp, addr, &statbuf) < 0) { |
| 1116 | tprintf("{...}"); |
| 1117 | return; |
| 1118 | } |
| 1119 | |
| 1120 | convertoldstat(&statbuf, &newstatbuf); |
| 1121 | realprintstat(tcp, &newstatbuf); |
| 1122 | } |
Michal Ludvig | 10a88d0 | 2002-10-07 14:31:00 +0000 | [diff] [blame] | 1123 | #endif /* LINUX && !IA64 && !HPPA && !X86_64 && !S390 && !S390X */ |
Wichert Akkerman | 328c5e7 | 1999-04-16 00:21:26 +0000 | [diff] [blame] | 1124 | |
John Hughes | 70623be | 2001-03-08 13:59:00 +0000 | [diff] [blame] | 1125 | #ifndef HAVE_LONG_LONG_OFF_T |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1126 | int |
| 1127 | sys_stat(tcp) |
| 1128 | struct tcb *tcp; |
| 1129 | { |
| 1130 | if (entering(tcp)) { |
| 1131 | printpath(tcp, tcp->u_arg[0]); |
| 1132 | tprintf(", "); |
| 1133 | } else { |
| 1134 | printstat(tcp, tcp->u_arg[1]); |
| 1135 | } |
| 1136 | return 0; |
| 1137 | } |
John Hughes | b8c9f77 | 2001-03-07 16:53:07 +0000 | [diff] [blame] | 1138 | #endif |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1139 | |
Wichert Akkerman | 328c5e7 | 1999-04-16 00:21:26 +0000 | [diff] [blame] | 1140 | int |
Ulrich Drepper | 7f02c4d | 1999-12-24 08:01:34 +0000 | [diff] [blame] | 1141 | sys_stat64(tcp) |
| 1142 | struct tcb *tcp; |
| 1143 | { |
| 1144 | #ifdef HAVE_STAT64 |
| 1145 | if (entering(tcp)) { |
| 1146 | printpath(tcp, tcp->u_arg[0]); |
| 1147 | tprintf(", "); |
| 1148 | } else { |
| 1149 | printstat64(tcp, tcp->u_arg[1]); |
| 1150 | } |
| 1151 | return 0; |
| 1152 | #else |
| 1153 | return printargs(tcp); |
| 1154 | #endif |
| 1155 | } |
| 1156 | |
Dmitry V. Levin | 95ebf5a | 2006-10-13 20:25:12 +0000 | [diff] [blame] | 1157 | #ifdef LINUX |
| 1158 | static const struct xlat fstatatflags[] = { |
| 1159 | #ifndef AT_SYMLINK_NOFOLLOW |
| 1160 | # define AT_SYMLINK_NOFOLLOW 0x100 |
| 1161 | #endif |
| 1162 | { AT_SYMLINK_NOFOLLOW, "AT_SYMLINK_NOFOLLOW" }, |
| 1163 | { 0, NULL }, |
| 1164 | }; |
| 1165 | |
| 1166 | int |
| 1167 | sys_newfstatat(struct tcb *tcp) |
| 1168 | { |
| 1169 | if (entering(tcp)) { |
| 1170 | print_dirfd(tcp->u_arg[0]); |
| 1171 | printpath(tcp, tcp->u_arg[1]); |
| 1172 | tprintf(", "); |
| 1173 | } else { |
| 1174 | #ifdef HAVE_STAT64 |
| 1175 | printstat64(tcp, tcp->u_arg[2]); |
| 1176 | #else |
| 1177 | printstat(tcp, tcp->u_arg[2]); |
| 1178 | #endif |
| 1179 | tprintf(", "); |
| 1180 | printflags(fstatatflags, tcp->u_arg[3], "AT_???"); |
| 1181 | } |
| 1182 | return 0; |
| 1183 | } |
| 1184 | #endif |
| 1185 | |
Roland McGrath | 79db8af | 2003-06-27 21:20:09 +0000 | [diff] [blame] | 1186 | #if defined(LINUX) && defined(HAVE_STRUCT___OLD_KERNEL_STAT) |
Ulrich Drepper | 7f02c4d | 1999-12-24 08:01:34 +0000 | [diff] [blame] | 1187 | int |
Wichert Akkerman | 328c5e7 | 1999-04-16 00:21:26 +0000 | [diff] [blame] | 1188 | sys_oldstat(tcp) |
| 1189 | struct tcb *tcp; |
| 1190 | { |
| 1191 | if (entering(tcp)) { |
| 1192 | printpath(tcp, tcp->u_arg[0]); |
| 1193 | tprintf(", "); |
| 1194 | } else { |
| 1195 | printoldstat(tcp, tcp->u_arg[1]); |
| 1196 | } |
| 1197 | return 0; |
| 1198 | } |
Roland McGrath | 79db8af | 2003-06-27 21:20:09 +0000 | [diff] [blame] | 1199 | #endif /* LINUX && HAVE_STRUCT___OLD_KERNEL_STAT */ |
Wichert Akkerman | 328c5e7 | 1999-04-16 00:21:26 +0000 | [diff] [blame] | 1200 | |
John Hughes | 70623be | 2001-03-08 13:59:00 +0000 | [diff] [blame] | 1201 | #ifndef HAVE_LONG_LONG_OFF_T |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1202 | int |
| 1203 | sys_fstat(tcp) |
| 1204 | struct tcb *tcp; |
| 1205 | { |
| 1206 | if (entering(tcp)) |
| 1207 | tprintf("%ld, ", tcp->u_arg[0]); |
| 1208 | else { |
| 1209 | printstat(tcp, tcp->u_arg[1]); |
| 1210 | } |
| 1211 | return 0; |
| 1212 | } |
John Hughes | b8c9f77 | 2001-03-07 16:53:07 +0000 | [diff] [blame] | 1213 | #endif |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1214 | |
Wichert Akkerman | 328c5e7 | 1999-04-16 00:21:26 +0000 | [diff] [blame] | 1215 | int |
Ulrich Drepper | 7f02c4d | 1999-12-24 08:01:34 +0000 | [diff] [blame] | 1216 | sys_fstat64(tcp) |
| 1217 | struct tcb *tcp; |
| 1218 | { |
| 1219 | #ifdef HAVE_STAT64 |
| 1220 | if (entering(tcp)) |
| 1221 | tprintf("%ld, ", tcp->u_arg[0]); |
| 1222 | else { |
| 1223 | printstat64(tcp, tcp->u_arg[1]); |
| 1224 | } |
| 1225 | return 0; |
| 1226 | #else |
| 1227 | return printargs(tcp); |
| 1228 | #endif |
| 1229 | } |
| 1230 | |
Roland McGrath | 79db8af | 2003-06-27 21:20:09 +0000 | [diff] [blame] | 1231 | #if defined(LINUX) && defined(HAVE_STRUCT___OLD_KERNEL_STAT) |
Ulrich Drepper | 7f02c4d | 1999-12-24 08:01:34 +0000 | [diff] [blame] | 1232 | int |
Wichert Akkerman | 328c5e7 | 1999-04-16 00:21:26 +0000 | [diff] [blame] | 1233 | sys_oldfstat(tcp) |
| 1234 | struct tcb *tcp; |
| 1235 | { |
| 1236 | if (entering(tcp)) |
| 1237 | tprintf("%ld, ", tcp->u_arg[0]); |
| 1238 | else { |
| 1239 | printoldstat(tcp, tcp->u_arg[1]); |
| 1240 | } |
| 1241 | return 0; |
| 1242 | } |
Roland McGrath | 79db8af | 2003-06-27 21:20:09 +0000 | [diff] [blame] | 1243 | #endif /* LINUX && HAVE_STRUCT___OLD_KERNEL_STAT */ |
Wichert Akkerman | 328c5e7 | 1999-04-16 00:21:26 +0000 | [diff] [blame] | 1244 | |
John Hughes | 70623be | 2001-03-08 13:59:00 +0000 | [diff] [blame] | 1245 | #ifndef HAVE_LONG_LONG_OFF_T |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1246 | int |
| 1247 | sys_lstat(tcp) |
| 1248 | struct tcb *tcp; |
| 1249 | { |
| 1250 | if (entering(tcp)) { |
| 1251 | printpath(tcp, tcp->u_arg[0]); |
| 1252 | tprintf(", "); |
| 1253 | } else { |
| 1254 | printstat(tcp, tcp->u_arg[1]); |
| 1255 | } |
| 1256 | return 0; |
| 1257 | } |
John Hughes | b8c9f77 | 2001-03-07 16:53:07 +0000 | [diff] [blame] | 1258 | #endif |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1259 | |
Wichert Akkerman | 328c5e7 | 1999-04-16 00:21:26 +0000 | [diff] [blame] | 1260 | int |
Ulrich Drepper | 7f02c4d | 1999-12-24 08:01:34 +0000 | [diff] [blame] | 1261 | sys_lstat64(tcp) |
| 1262 | struct tcb *tcp; |
| 1263 | { |
| 1264 | #ifdef HAVE_STAT64 |
| 1265 | if (entering(tcp)) { |
| 1266 | printpath(tcp, tcp->u_arg[0]); |
| 1267 | tprintf(", "); |
| 1268 | } else { |
| 1269 | printstat64(tcp, tcp->u_arg[1]); |
| 1270 | } |
| 1271 | return 0; |
| 1272 | #else |
| 1273 | return printargs(tcp); |
| 1274 | #endif |
| 1275 | } |
| 1276 | |
Roland McGrath | 79db8af | 2003-06-27 21:20:09 +0000 | [diff] [blame] | 1277 | #if defined(LINUX) && defined(HAVE_STRUCT___OLD_KERNEL_STAT) |
Ulrich Drepper | 7f02c4d | 1999-12-24 08:01:34 +0000 | [diff] [blame] | 1278 | int |
Wichert Akkerman | 328c5e7 | 1999-04-16 00:21:26 +0000 | [diff] [blame] | 1279 | sys_oldlstat(tcp) |
| 1280 | struct tcb *tcp; |
| 1281 | { |
| 1282 | if (entering(tcp)) { |
| 1283 | printpath(tcp, tcp->u_arg[0]); |
| 1284 | tprintf(", "); |
| 1285 | } else { |
| 1286 | printoldstat(tcp, tcp->u_arg[1]); |
| 1287 | } |
| 1288 | return 0; |
| 1289 | } |
Roland McGrath | 79db8af | 2003-06-27 21:20:09 +0000 | [diff] [blame] | 1290 | #endif /* LINUX && HAVE_STRUCT___OLD_KERNEL_STAT */ |
Wichert Akkerman | 328c5e7 | 1999-04-16 00:21:26 +0000 | [diff] [blame] | 1291 | |
| 1292 | |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1293 | #if defined(SVR4) || defined(LINUXSPARC) |
| 1294 | |
| 1295 | int |
| 1296 | sys_xstat(tcp) |
| 1297 | struct tcb *tcp; |
| 1298 | { |
| 1299 | if (entering(tcp)) { |
| 1300 | tprintf("%ld, ", tcp->u_arg[0]); |
| 1301 | printpath(tcp, tcp->u_arg[1]); |
| 1302 | tprintf(", "); |
| 1303 | } else { |
John Hughes | 8fe2c98 | 2001-03-06 09:45:18 +0000 | [diff] [blame] | 1304 | #ifdef _STAT64_VER |
| 1305 | if (tcp->u_arg[0] == _STAT64_VER) |
| 1306 | printstat64 (tcp, tcp->u_arg[2]); |
| 1307 | else |
| 1308 | #endif |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1309 | printstat(tcp, tcp->u_arg[2]); |
| 1310 | } |
| 1311 | return 0; |
| 1312 | } |
| 1313 | |
| 1314 | int |
| 1315 | sys_fxstat(tcp) |
| 1316 | struct tcb *tcp; |
| 1317 | { |
| 1318 | if (entering(tcp)) |
| 1319 | tprintf("%ld, %ld, ", tcp->u_arg[0], tcp->u_arg[1]); |
| 1320 | else { |
John Hughes | 8fe2c98 | 2001-03-06 09:45:18 +0000 | [diff] [blame] | 1321 | #ifdef _STAT64_VER |
| 1322 | if (tcp->u_arg[0] == _STAT64_VER) |
| 1323 | printstat64 (tcp, tcp->u_arg[2]); |
| 1324 | else |
| 1325 | #endif |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1326 | printstat(tcp, tcp->u_arg[2]); |
| 1327 | } |
| 1328 | return 0; |
| 1329 | } |
| 1330 | |
| 1331 | int |
| 1332 | sys_lxstat(tcp) |
| 1333 | struct tcb *tcp; |
| 1334 | { |
| 1335 | if (entering(tcp)) { |
| 1336 | tprintf("%ld, ", tcp->u_arg[0]); |
| 1337 | printpath(tcp, tcp->u_arg[1]); |
| 1338 | tprintf(", "); |
| 1339 | } else { |
John Hughes | 8fe2c98 | 2001-03-06 09:45:18 +0000 | [diff] [blame] | 1340 | #ifdef _STAT64_VER |
| 1341 | if (tcp->u_arg[0] == _STAT64_VER) |
| 1342 | printstat64 (tcp, tcp->u_arg[2]); |
| 1343 | else |
| 1344 | #endif |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1345 | printstat(tcp, tcp->u_arg[2]); |
| 1346 | } |
| 1347 | return 0; |
| 1348 | } |
| 1349 | |
| 1350 | int |
| 1351 | sys_xmknod(tcp) |
| 1352 | struct tcb *tcp; |
| 1353 | { |
| 1354 | int mode = tcp->u_arg[2]; |
| 1355 | |
| 1356 | if (entering(tcp)) { |
| 1357 | tprintf("%ld, ", tcp->u_arg[0]); |
| 1358 | printpath(tcp, tcp->u_arg[1]); |
| 1359 | tprintf(", %s", sprintmode(mode)); |
| 1360 | switch (mode & S_IFMT) { |
| 1361 | case S_IFCHR: case S_IFBLK: |
| 1362 | #ifdef LINUXSPARC |
| 1363 | tprintf(", makedev(%lu, %lu)", |
| 1364 | (unsigned long) ((tcp->u_arg[3] >> 18) & 0x3fff), |
| 1365 | (unsigned long) (tcp->u_arg[3] & 0x3ffff)); |
Roland McGrath | 186c5ac | 2002-12-15 23:58:23 +0000 | [diff] [blame] | 1366 | #else |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1367 | tprintf(", makedev(%lu, %lu)", |
| 1368 | (unsigned long) major(tcp->u_arg[3]), |
| 1369 | (unsigned long) minor(tcp->u_arg[3])); |
Roland McGrath | 186c5ac | 2002-12-15 23:58:23 +0000 | [diff] [blame] | 1370 | #endif |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1371 | break; |
| 1372 | default: |
| 1373 | break; |
| 1374 | } |
| 1375 | } |
| 1376 | return 0; |
| 1377 | } |
| 1378 | |
Wichert Akkerman | 8829a55 | 1999-06-11 13:18:40 +0000 | [diff] [blame] | 1379 | #ifdef HAVE_SYS_ACL_H |
| 1380 | |
| 1381 | #include <sys/acl.h> |
| 1382 | |
Roland McGrath | a4d4853 | 2005-06-08 20:45:28 +0000 | [diff] [blame] | 1383 | static const struct xlat aclcmds[] = { |
Wichert Akkerman | e4aafd4 | 1999-11-26 09:54:08 +0000 | [diff] [blame] | 1384 | #ifdef SETACL |
Wichert Akkerman | 8829a55 | 1999-06-11 13:18:40 +0000 | [diff] [blame] | 1385 | { SETACL, "SETACL" }, |
Wichert Akkerman | e4aafd4 | 1999-11-26 09:54:08 +0000 | [diff] [blame] | 1386 | #endif |
| 1387 | #ifdef GETACL |
Wichert Akkerman | 8829a55 | 1999-06-11 13:18:40 +0000 | [diff] [blame] | 1388 | { GETACL, "GETACL" }, |
Wichert Akkerman | e4aafd4 | 1999-11-26 09:54:08 +0000 | [diff] [blame] | 1389 | #endif |
| 1390 | #ifdef GETACLCNT |
Wichert Akkerman | 8829a55 | 1999-06-11 13:18:40 +0000 | [diff] [blame] | 1391 | { GETACLCNT, "GETACLCNT" }, |
Wichert Akkerman | e4aafd4 | 1999-11-26 09:54:08 +0000 | [diff] [blame] | 1392 | #endif |
| 1393 | #ifdef ACL_GET |
| 1394 | { ACL_GET, "ACL_GET" }, |
Roland McGrath | 186c5ac | 2002-12-15 23:58:23 +0000 | [diff] [blame] | 1395 | #endif |
Wichert Akkerman | e4aafd4 | 1999-11-26 09:54:08 +0000 | [diff] [blame] | 1396 | #ifdef ACL_SET |
| 1397 | { ACL_SET, "ACL_SET" }, |
Roland McGrath | 186c5ac | 2002-12-15 23:58:23 +0000 | [diff] [blame] | 1398 | #endif |
Wichert Akkerman | e4aafd4 | 1999-11-26 09:54:08 +0000 | [diff] [blame] | 1399 | #ifdef ACL_CNT |
| 1400 | { ACL_CNT, "ACL_CNT" }, |
Roland McGrath | 186c5ac | 2002-12-15 23:58:23 +0000 | [diff] [blame] | 1401 | #endif |
Wichert Akkerman | 8829a55 | 1999-06-11 13:18:40 +0000 | [diff] [blame] | 1402 | { 0, NULL }, |
| 1403 | }; |
| 1404 | |
| 1405 | int |
| 1406 | sys_acl(tcp) |
| 1407 | struct tcb *tcp; |
| 1408 | { |
| 1409 | if (entering(tcp)) { |
| 1410 | printpath(tcp, tcp->u_arg[0]); |
| 1411 | tprintf(", "); |
| 1412 | printxval(aclcmds, tcp->u_arg[1], "???ACL???"); |
| 1413 | tprintf(", %ld", tcp->u_arg[2]); |
| 1414 | /* |
| 1415 | * FIXME - dump out the list of aclent_t's pointed to |
| 1416 | * by "tcp->u_arg[3]" if it's not NULL. |
| 1417 | */ |
| 1418 | if (tcp->u_arg[3]) |
| 1419 | tprintf(", %#lx", tcp->u_arg[3]); |
| 1420 | else |
| 1421 | tprintf(", NULL"); |
| 1422 | } |
| 1423 | return 0; |
| 1424 | } |
| 1425 | |
| 1426 | |
| 1427 | int |
| 1428 | sys_facl(tcp) |
| 1429 | struct tcb *tcp; |
| 1430 | { |
| 1431 | if (entering(tcp)) { |
| 1432 | tprintf("%ld, ", tcp->u_arg[0]); |
| 1433 | printxval(aclcmds, tcp->u_arg[1], "???ACL???"); |
| 1434 | tprintf(", %ld", tcp->u_arg[2]); |
| 1435 | /* |
| 1436 | * FIXME - dump out the list of aclent_t's pointed to |
| 1437 | * by "tcp->u_arg[3]" if it's not NULL. |
| 1438 | */ |
| 1439 | if (tcp->u_arg[3]) |
| 1440 | tprintf(", %#lx", tcp->u_arg[3]); |
| 1441 | else |
| 1442 | tprintf(", NULL"); |
| 1443 | } |
| 1444 | return 0; |
| 1445 | } |
| 1446 | |
Wichert Akkerman | e4aafd4 | 1999-11-26 09:54:08 +0000 | [diff] [blame] | 1447 | |
Roland McGrath | a4d4853 | 2005-06-08 20:45:28 +0000 | [diff] [blame] | 1448 | static const struct xlat aclipc[] = { |
Wichert Akkerman | e4aafd4 | 1999-11-26 09:54:08 +0000 | [diff] [blame] | 1449 | #ifdef IPC_SHM |
| 1450 | { IPC_SHM, "IPC_SHM" }, |
Roland McGrath | 186c5ac | 2002-12-15 23:58:23 +0000 | [diff] [blame] | 1451 | #endif |
Wichert Akkerman | e4aafd4 | 1999-11-26 09:54:08 +0000 | [diff] [blame] | 1452 | #ifdef IPC_SEM |
| 1453 | { IPC_SEM, "IPC_SEM" }, |
Roland McGrath | 186c5ac | 2002-12-15 23:58:23 +0000 | [diff] [blame] | 1454 | #endif |
Wichert Akkerman | e4aafd4 | 1999-11-26 09:54:08 +0000 | [diff] [blame] | 1455 | #ifdef IPC_MSG |
| 1456 | { IPC_MSG, "IPC_MSG" }, |
Roland McGrath | 186c5ac | 2002-12-15 23:58:23 +0000 | [diff] [blame] | 1457 | #endif |
Wichert Akkerman | e4aafd4 | 1999-11-26 09:54:08 +0000 | [diff] [blame] | 1458 | { 0, NULL }, |
| 1459 | }; |
| 1460 | |
| 1461 | |
| 1462 | int |
| 1463 | sys_aclipc(tcp) |
| 1464 | struct tcb *tcp; |
| 1465 | { |
| 1466 | if (entering(tcp)) { |
| 1467 | printxval(aclipc, tcp->u_arg[0], "???IPC???"); |
| 1468 | tprintf(", %#lx, ", tcp->u_arg[1]); |
| 1469 | printxval(aclcmds, tcp->u_arg[2], "???ACL???"); |
| 1470 | tprintf(", %ld", tcp->u_arg[3]); |
| 1471 | /* |
| 1472 | * FIXME - dump out the list of aclent_t's pointed to |
| 1473 | * by "tcp->u_arg[4]" if it's not NULL. |
| 1474 | */ |
| 1475 | if (tcp->u_arg[4]) |
| 1476 | tprintf(", %#lx", tcp->u_arg[4]); |
| 1477 | else |
| 1478 | tprintf(", NULL"); |
| 1479 | } |
| 1480 | return 0; |
| 1481 | } |
| 1482 | |
| 1483 | |
| 1484 | |
Wichert Akkerman | 8829a55 | 1999-06-11 13:18:40 +0000 | [diff] [blame] | 1485 | #endif /* HAVE_SYS_ACL_H */ |
| 1486 | |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1487 | #endif /* SVR4 || LINUXSPARC */ |
| 1488 | |
Michal Ludvig | 53b320f | 2002-09-23 13:30:09 +0000 | [diff] [blame] | 1489 | #ifdef LINUX |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1490 | |
Roland McGrath | d9f816f | 2004-09-04 03:39:20 +0000 | [diff] [blame] | 1491 | static const struct xlat fsmagic[] = { |
Wichert Akkerman | 43a7482 | 2000-06-27 17:33:32 +0000 | [diff] [blame] | 1492 | { 0x73757245, "CODA_SUPER_MAGIC" }, |
| 1493 | { 0x012ff7b7, "COH_SUPER_MAGIC" }, |
| 1494 | { 0x1373, "DEVFS_SUPER_MAGIC" }, |
| 1495 | { 0x1cd1, "DEVPTS_SUPER_MAGIC" }, |
| 1496 | { 0x414A53, "EFS_SUPER_MAGIC" }, |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1497 | { 0xef51, "EXT2_OLD_SUPER_MAGIC" }, |
| 1498 | { 0xef53, "EXT2_SUPER_MAGIC" }, |
| 1499 | { 0x137d, "EXT_SUPER_MAGIC" }, |
Wichert Akkerman | 43a7482 | 2000-06-27 17:33:32 +0000 | [diff] [blame] | 1500 | { 0xf995e849, "HPFS_SUPER_MAGIC" }, |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1501 | { 0x9660, "ISOFS_SUPER_MAGIC" }, |
| 1502 | { 0x137f, "MINIX_SUPER_MAGIC" }, |
| 1503 | { 0x138f, "MINIX_SUPER_MAGIC2" }, |
Wichert Akkerman | 2e2553a | 1999-05-09 00:29:58 +0000 | [diff] [blame] | 1504 | { 0x2468, "MINIX2_SUPER_MAGIC" }, |
| 1505 | { 0x2478, "MINIX2_SUPER_MAGIC2" }, |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1506 | { 0x4d44, "MSDOS_SUPER_MAGIC" }, |
Wichert Akkerman | 43a7482 | 2000-06-27 17:33:32 +0000 | [diff] [blame] | 1507 | { 0x564c, "NCP_SUPER_MAGIC" }, |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1508 | { 0x6969, "NFS_SUPER_MAGIC" }, |
| 1509 | { 0x9fa0, "PROC_SUPER_MAGIC" }, |
Wichert Akkerman | 43a7482 | 2000-06-27 17:33:32 +0000 | [diff] [blame] | 1510 | { 0x002f, "QNX4_SUPER_MAGIC" }, |
| 1511 | { 0x52654973, "REISERFS_SUPER_MAGIC" }, |
| 1512 | { 0x02011994, "SHMFS_SUPER_MAGIC" }, |
| 1513 | { 0x517b, "SMB_SUPER_MAGIC" }, |
| 1514 | { 0x012ff7b6, "SYSV2_SUPER_MAGIC" }, |
| 1515 | { 0x012ff7b5, "SYSV4_SUPER_MAGIC" }, |
| 1516 | { 0x00011954, "UFS_MAGIC" }, |
| 1517 | { 0x54190100, "UFS_CIGAM" }, |
| 1518 | { 0x012ff7b4, "XENIX_SUPER_MAGIC" }, |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1519 | { 0x012fd16d, "XIAFS_SUPER_MAGIC" }, |
Roland McGrath | c767ad8 | 2004-01-13 10:13:45 +0000 | [diff] [blame] | 1520 | { 0x62656572, "SYSFS_MAGIC" }, |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1521 | { 0, NULL }, |
| 1522 | }; |
| 1523 | |
Michal Ludvig | 53b320f | 2002-09-23 13:30:09 +0000 | [diff] [blame] | 1524 | #endif /* LINUX */ |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1525 | |
| 1526 | #ifndef SVR4 |
| 1527 | |
Roland McGrath | f9c49b2 | 2004-10-06 22:11:54 +0000 | [diff] [blame] | 1528 | static const char * |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1529 | sprintfstype(magic) |
| 1530 | int magic; |
| 1531 | { |
| 1532 | static char buf[32]; |
Michal Ludvig | 53b320f | 2002-09-23 13:30:09 +0000 | [diff] [blame] | 1533 | #ifdef LINUX |
Roland McGrath | f9c49b2 | 2004-10-06 22:11:54 +0000 | [diff] [blame] | 1534 | const char *s; |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1535 | |
| 1536 | s = xlookup(fsmagic, magic); |
| 1537 | if (s) { |
| 1538 | sprintf(buf, "\"%s\"", s); |
| 1539 | return buf; |
| 1540 | } |
Michal Ludvig | 53b320f | 2002-09-23 13:30:09 +0000 | [diff] [blame] | 1541 | #endif /* LINUX */ |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1542 | sprintf(buf, "%#x", magic); |
| 1543 | return buf; |
| 1544 | } |
| 1545 | |
| 1546 | static void |
| 1547 | printstatfs(tcp, addr) |
| 1548 | struct tcb *tcp; |
| 1549 | long addr; |
| 1550 | { |
| 1551 | struct statfs statbuf; |
| 1552 | |
| 1553 | if (syserror(tcp) || !verbose(tcp)) { |
| 1554 | tprintf("%#lx", addr); |
| 1555 | return; |
| 1556 | } |
| 1557 | if (umove(tcp, addr, &statbuf) < 0) { |
| 1558 | tprintf("{...}"); |
| 1559 | return; |
| 1560 | } |
| 1561 | #ifdef ALPHA |
| 1562 | |
| 1563 | tprintf("{f_type=%s, f_fbsize=%u, f_blocks=%u, f_bfree=%u, ", |
| 1564 | sprintfstype(statbuf.f_type), |
| 1565 | statbuf.f_bsize, statbuf.f_blocks, statbuf.f_bfree); |
Roland McGrath | ab147c5 | 2003-07-17 09:03:02 +0000 | [diff] [blame] | 1566 | tprintf("f_bavail=%u, f_files=%u, f_ffree=%u, f_fsid={%d, %d}, f_namelen=%u", |
| 1567 | statbuf.f_bavail,statbuf.f_files, statbuf.f_ffree, |
| 1568 | statbuf.f_fsid.__val[0], statbuf.f_fsid.__val[1], |
| 1569 | statbuf.f_namelen); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1570 | #else /* !ALPHA */ |
| 1571 | tprintf("{f_type=%s, f_bsize=%lu, f_blocks=%lu, f_bfree=%lu, ", |
| 1572 | sprintfstype(statbuf.f_type), |
Nate Sammons | 5c74d20 | 1999-04-06 01:37:51 +0000 | [diff] [blame] | 1573 | (unsigned long)statbuf.f_bsize, |
| 1574 | (unsigned long)statbuf.f_blocks, |
| 1575 | (unsigned long)statbuf.f_bfree); |
Roland McGrath | ab147c5 | 2003-07-17 09:03:02 +0000 | [diff] [blame] | 1576 | tprintf("f_bavail=%lu, f_files=%lu, f_ffree=%lu, f_fsid={%d, %d}", |
| 1577 | (unsigned long)statbuf.f_bavail, |
Nate Sammons | 5c74d20 | 1999-04-06 01:37:51 +0000 | [diff] [blame] | 1578 | (unsigned long)statbuf.f_files, |
Roland McGrath | ab147c5 | 2003-07-17 09:03:02 +0000 | [diff] [blame] | 1579 | (unsigned long)statbuf.f_ffree, |
| 1580 | statbuf.f_fsid.__val[0], statbuf.f_fsid.__val[1]); |
Michal Ludvig | 53b320f | 2002-09-23 13:30:09 +0000 | [diff] [blame] | 1581 | #ifdef LINUX |
Wichert Akkerman | 2e2553a | 1999-05-09 00:29:58 +0000 | [diff] [blame] | 1582 | tprintf(", f_namelen=%lu", (unsigned long)statbuf.f_namelen); |
Michal Ludvig | 53b320f | 2002-09-23 13:30:09 +0000 | [diff] [blame] | 1583 | #endif /* LINUX */ |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1584 | #endif /* !ALPHA */ |
Roland McGrath | ab147c5 | 2003-07-17 09:03:02 +0000 | [diff] [blame] | 1585 | #ifdef _STATFS_F_FRSIZE |
| 1586 | tprintf(", f_frsize=%lu", (unsigned long)statbuf.f_frsize); |
| 1587 | #endif |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1588 | tprintf("}"); |
| 1589 | } |
| 1590 | |
| 1591 | int |
| 1592 | sys_statfs(tcp) |
| 1593 | struct tcb *tcp; |
| 1594 | { |
| 1595 | if (entering(tcp)) { |
| 1596 | printpath(tcp, tcp->u_arg[0]); |
| 1597 | tprintf(", "); |
| 1598 | } else { |
| 1599 | printstatfs(tcp, tcp->u_arg[1]); |
| 1600 | } |
| 1601 | return 0; |
| 1602 | } |
| 1603 | |
| 1604 | int |
| 1605 | sys_fstatfs(tcp) |
| 1606 | struct tcb *tcp; |
| 1607 | { |
| 1608 | if (entering(tcp)) { |
| 1609 | tprintf("%lu, ", tcp->u_arg[0]); |
| 1610 | } else { |
| 1611 | printstatfs(tcp, tcp->u_arg[1]); |
| 1612 | } |
| 1613 | return 0; |
| 1614 | } |
| 1615 | |
Roland McGrath | ab147c5 | 2003-07-17 09:03:02 +0000 | [diff] [blame] | 1616 | #ifdef LINUX |
| 1617 | static void |
| 1618 | printstatfs64(tcp, addr) |
| 1619 | struct tcb *tcp; |
| 1620 | long addr; |
| 1621 | { |
| 1622 | struct statfs64 statbuf; |
| 1623 | |
| 1624 | if (syserror(tcp) || !verbose(tcp)) { |
| 1625 | tprintf("%#lx", addr); |
| 1626 | return; |
| 1627 | } |
| 1628 | if (umove(tcp, addr, &statbuf) < 0) { |
| 1629 | tprintf("{...}"); |
| 1630 | return; |
| 1631 | } |
Roland McGrath | 0873843 | 2005-06-03 02:40:39 +0000 | [diff] [blame] | 1632 | tprintf("{f_type=%s, f_bsize=%llu, f_blocks=%llu, f_bfree=%llu, ", |
Roland McGrath | ab147c5 | 2003-07-17 09:03:02 +0000 | [diff] [blame] | 1633 | sprintfstype(statbuf.f_type), |
Roland McGrath | 0873843 | 2005-06-03 02:40:39 +0000 | [diff] [blame] | 1634 | (unsigned long long)statbuf.f_bsize, |
| 1635 | (unsigned long long)statbuf.f_blocks, |
| 1636 | (unsigned long long)statbuf.f_bfree); |
| 1637 | tprintf("f_bavail=%llu, f_files=%llu, f_ffree=%llu, f_fsid={%d, %d}", |
| 1638 | (unsigned long long)statbuf.f_bavail, |
| 1639 | (unsigned long long)statbuf.f_files, |
| 1640 | (unsigned long long)statbuf.f_ffree, |
Roland McGrath | ab147c5 | 2003-07-17 09:03:02 +0000 | [diff] [blame] | 1641 | statbuf.f_fsid.__val[0], statbuf.f_fsid.__val[1]); |
| 1642 | tprintf(", f_namelen=%lu", (unsigned long)statbuf.f_namelen); |
Roland McGrath | ab147c5 | 2003-07-17 09:03:02 +0000 | [diff] [blame] | 1643 | #ifdef _STATFS_F_FRSIZE |
Roland McGrath | 0873843 | 2005-06-03 02:40:39 +0000 | [diff] [blame] | 1644 | tprintf(", f_frsize=%llu", (unsigned long long)statbuf.f_frsize); |
Roland McGrath | ab147c5 | 2003-07-17 09:03:02 +0000 | [diff] [blame] | 1645 | #endif |
| 1646 | tprintf("}"); |
| 1647 | } |
| 1648 | |
| 1649 | int |
| 1650 | sys_statfs64(tcp) |
| 1651 | struct tcb *tcp; |
| 1652 | { |
| 1653 | if (entering(tcp)) { |
| 1654 | printpath(tcp, tcp->u_arg[0]); |
| 1655 | tprintf(", %lu, ", tcp->u_arg[1]); |
| 1656 | } else { |
| 1657 | if (tcp->u_arg[1] == sizeof (struct statfs64)) |
| 1658 | printstatfs64(tcp, tcp->u_arg[2]); |
| 1659 | else |
| 1660 | tprintf("{???}"); |
| 1661 | } |
| 1662 | return 0; |
| 1663 | } |
| 1664 | |
| 1665 | int |
| 1666 | sys_fstatfs64(tcp) |
| 1667 | struct tcb *tcp; |
| 1668 | { |
| 1669 | if (entering(tcp)) { |
| 1670 | tprintf("%lu, %lu, ", tcp->u_arg[0], tcp->u_arg[1]); |
| 1671 | } else { |
| 1672 | if (tcp->u_arg[1] == sizeof (struct statfs64)) |
| 1673 | printstatfs64(tcp, tcp->u_arg[2]); |
| 1674 | else |
| 1675 | tprintf("{???}"); |
| 1676 | } |
| 1677 | return 0; |
| 1678 | } |
| 1679 | #endif |
| 1680 | |
Michal Ludvig | 53b320f | 2002-09-23 13:30:09 +0000 | [diff] [blame] | 1681 | #if defined(LINUX) && defined(__alpha) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1682 | |
| 1683 | int |
| 1684 | osf_statfs(tcp) |
| 1685 | struct tcb *tcp; |
| 1686 | { |
| 1687 | if (entering(tcp)) { |
| 1688 | printpath(tcp, tcp->u_arg[0]); |
| 1689 | tprintf(", "); |
| 1690 | } else { |
| 1691 | printstatfs(tcp, tcp->u_arg[1]); |
| 1692 | tprintf(", %lu", tcp->u_arg[2]); |
| 1693 | } |
| 1694 | return 0; |
| 1695 | } |
| 1696 | |
| 1697 | int |
| 1698 | osf_fstatfs(tcp) |
| 1699 | struct tcb *tcp; |
| 1700 | { |
| 1701 | if (entering(tcp)) { |
| 1702 | tprintf("%lu, ", tcp->u_arg[0]); |
| 1703 | } else { |
| 1704 | printstatfs(tcp, tcp->u_arg[1]); |
| 1705 | tprintf(", %lu", tcp->u_arg[2]); |
| 1706 | } |
| 1707 | return 0; |
| 1708 | } |
Michal Ludvig | 53b320f | 2002-09-23 13:30:09 +0000 | [diff] [blame] | 1709 | #endif /* LINUX && __alpha */ |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1710 | |
| 1711 | #endif /* !SVR4 */ |
| 1712 | |
| 1713 | #ifdef SUNOS4 |
| 1714 | |
| 1715 | int |
| 1716 | sys_ustat(tcp) |
| 1717 | struct tcb *tcp; |
| 1718 | { |
| 1719 | struct ustat statbuf; |
| 1720 | |
| 1721 | if (entering(tcp)) { |
| 1722 | tprintf("makedev(%lu, %lu), ", |
| 1723 | (long) major(tcp->u_arg[0]), |
| 1724 | (long) minor(tcp->u_arg[0])); |
| 1725 | } |
| 1726 | else { |
| 1727 | if (syserror(tcp) || !verbose(tcp)) |
| 1728 | tprintf("%#lx", tcp->u_arg[1]); |
| 1729 | else if (umove(tcp, tcp->u_arg[1], &statbuf) < 0) |
| 1730 | tprintf("{...}"); |
| 1731 | else { |
| 1732 | tprintf("{f_tfree=%lu, f_tinode=%lu, ", |
| 1733 | statbuf.f_tfree, statbuf.f_tinode); |
| 1734 | tprintf("f_fname=\"%.*s\", ", |
| 1735 | (int) sizeof(statbuf.f_fname), |
| 1736 | statbuf.f_fname); |
| 1737 | tprintf("f_fpack=\"%.*s\"}", |
| 1738 | (int) sizeof(statbuf.f_fpack), |
| 1739 | statbuf.f_fpack); |
| 1740 | } |
| 1741 | } |
| 1742 | return 0; |
| 1743 | } |
| 1744 | |
| 1745 | #endif /* SUNOS4 */ |
| 1746 | |
Wichert Akkerman | c792698 | 2000-04-10 22:22:31 +0000 | [diff] [blame] | 1747 | int |
| 1748 | sys_pivotroot(tcp) |
| 1749 | struct tcb *tcp; |
| 1750 | { |
| 1751 | if (entering(tcp)) { |
| 1752 | printpath(tcp, tcp->u_arg[0]); |
| 1753 | tprintf(", "); |
| 1754 | printpath(tcp, tcp->u_arg[1]); |
| 1755 | } |
| 1756 | return 0; |
| 1757 | } |
| 1758 | |
| 1759 | |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1760 | /* directory */ |
| 1761 | int |
| 1762 | sys_chdir(tcp) |
| 1763 | struct tcb *tcp; |
| 1764 | { |
| 1765 | if (entering(tcp)) { |
| 1766 | printpath(tcp, tcp->u_arg[0]); |
| 1767 | } |
| 1768 | return 0; |
| 1769 | } |
| 1770 | |
Dmitry V. Levin | 95ebf5a | 2006-10-13 20:25:12 +0000 | [diff] [blame] | 1771 | static int |
| 1772 | decode_mkdir(struct tcb *tcp, int offset) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1773 | { |
| 1774 | if (entering(tcp)) { |
Dmitry V. Levin | 95ebf5a | 2006-10-13 20:25:12 +0000 | [diff] [blame] | 1775 | printpath(tcp, tcp->u_arg[offset]); |
| 1776 | tprintf(", %#lo", tcp->u_arg[offset + 1]); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1777 | } |
| 1778 | return 0; |
| 1779 | } |
| 1780 | |
| 1781 | int |
Dmitry V. Levin | 95ebf5a | 2006-10-13 20:25:12 +0000 | [diff] [blame] | 1782 | sys_mkdir(struct tcb *tcp) |
| 1783 | { |
| 1784 | return decode_mkdir(tcp, 0); |
| 1785 | } |
| 1786 | |
| 1787 | #ifdef LINUX |
| 1788 | int |
| 1789 | sys_mkdirat(struct tcb *tcp) |
| 1790 | { |
| 1791 | if (entering(tcp)) |
| 1792 | print_dirfd(tcp->u_arg[0]); |
| 1793 | return decode_mkdir(tcp, 1); |
| 1794 | } |
| 1795 | #endif |
| 1796 | |
| 1797 | int |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1798 | sys_rmdir(tcp) |
| 1799 | struct tcb *tcp; |
| 1800 | { |
| 1801 | if (entering(tcp)) { |
| 1802 | printpath(tcp, tcp->u_arg[0]); |
| 1803 | } |
| 1804 | return 0; |
| 1805 | } |
| 1806 | |
| 1807 | int |
| 1808 | sys_fchdir(tcp) |
| 1809 | struct tcb *tcp; |
| 1810 | { |
| 1811 | if (entering(tcp)) { |
| 1812 | tprintf("%ld", tcp->u_arg[0]); |
| 1813 | } |
| 1814 | return 0; |
| 1815 | } |
| 1816 | |
| 1817 | int |
| 1818 | sys_chroot(tcp) |
| 1819 | struct tcb *tcp; |
| 1820 | { |
| 1821 | if (entering(tcp)) { |
| 1822 | printpath(tcp, tcp->u_arg[0]); |
| 1823 | } |
| 1824 | return 0; |
| 1825 | } |
| 1826 | |
| 1827 | int |
| 1828 | sys_fchroot(tcp) |
| 1829 | struct tcb *tcp; |
| 1830 | { |
| 1831 | if (entering(tcp)) { |
| 1832 | tprintf("%ld", tcp->u_arg[0]); |
| 1833 | } |
| 1834 | return 0; |
| 1835 | } |
| 1836 | |
| 1837 | int |
| 1838 | sys_link(tcp) |
| 1839 | struct tcb *tcp; |
| 1840 | { |
| 1841 | if (entering(tcp)) { |
| 1842 | printpath(tcp, tcp->u_arg[0]); |
| 1843 | tprintf(", "); |
| 1844 | printpath(tcp, tcp->u_arg[1]); |
| 1845 | } |
| 1846 | return 0; |
| 1847 | } |
| 1848 | |
Dmitry V. Levin | 95ebf5a | 2006-10-13 20:25:12 +0000 | [diff] [blame] | 1849 | #ifdef LINUX |
| 1850 | int |
| 1851 | sys_linkat(struct tcb *tcp) |
| 1852 | { |
| 1853 | if (entering(tcp)) { |
| 1854 | print_dirfd(tcp->u_arg[0]); |
| 1855 | printpath(tcp, tcp->u_arg[1]); |
| 1856 | tprintf(", "); |
| 1857 | print_dirfd(tcp->u_arg[2]); |
| 1858 | printpath(tcp, tcp->u_arg[3]); |
| 1859 | tprintf(", %ld", tcp->u_arg[4]); |
| 1860 | } |
| 1861 | return 0; |
| 1862 | } |
| 1863 | #endif |
| 1864 | |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1865 | int |
| 1866 | sys_unlink(tcp) |
| 1867 | struct tcb *tcp; |
| 1868 | { |
| 1869 | if (entering(tcp)) { |
| 1870 | printpath(tcp, tcp->u_arg[0]); |
| 1871 | } |
| 1872 | return 0; |
| 1873 | } |
| 1874 | |
Dmitry V. Levin | 95ebf5a | 2006-10-13 20:25:12 +0000 | [diff] [blame] | 1875 | #ifdef LINUX |
| 1876 | static const struct xlat unlinkatflags[] = { |
| 1877 | #ifndef AT_REMOVEDIR |
| 1878 | # define AT_REMOVEDIR 0x200 |
| 1879 | #endif |
| 1880 | { AT_REMOVEDIR, "AT_REMOVEDIR" }, |
| 1881 | { 0, NULL }, |
| 1882 | }; |
| 1883 | |
| 1884 | int |
| 1885 | sys_unlinkat(struct tcb *tcp) |
| 1886 | { |
| 1887 | if (entering(tcp)) { |
| 1888 | print_dirfd(tcp->u_arg[0]); |
| 1889 | printpath(tcp, tcp->u_arg[1]); |
| 1890 | tprintf(", "); |
| 1891 | printflags(unlinkatflags, tcp->u_arg[2], "AT_???"); |
| 1892 | } |
| 1893 | return 0; |
| 1894 | } |
| 1895 | #endif |
| 1896 | |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1897 | int |
| 1898 | sys_symlink(tcp) |
| 1899 | struct tcb *tcp; |
| 1900 | { |
| 1901 | if (entering(tcp)) { |
| 1902 | printpath(tcp, tcp->u_arg[0]); |
| 1903 | tprintf(", "); |
| 1904 | printpath(tcp, tcp->u_arg[1]); |
| 1905 | } |
| 1906 | return 0; |
| 1907 | } |
| 1908 | |
Dmitry V. Levin | 95ebf5a | 2006-10-13 20:25:12 +0000 | [diff] [blame] | 1909 | #ifdef LINUX |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1910 | int |
Dmitry V. Levin | 95ebf5a | 2006-10-13 20:25:12 +0000 | [diff] [blame] | 1911 | sys_symlinkat(struct tcb *tcp) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1912 | { |
| 1913 | if (entering(tcp)) { |
| 1914 | printpath(tcp, tcp->u_arg[0]); |
| 1915 | tprintf(", "); |
Dmitry V. Levin | 95ebf5a | 2006-10-13 20:25:12 +0000 | [diff] [blame] | 1916 | print_dirfd(tcp->u_arg[1]); |
| 1917 | printpath(tcp, tcp->u_arg[2]); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1918 | } |
| 1919 | return 0; |
| 1920 | } |
Dmitry V. Levin | 95ebf5a | 2006-10-13 20:25:12 +0000 | [diff] [blame] | 1921 | #endif |
| 1922 | |
| 1923 | static int |
| 1924 | decode_readlink(struct tcb *tcp, int offset) |
| 1925 | { |
| 1926 | if (entering(tcp)) { |
| 1927 | printpath(tcp, tcp->u_arg[offset]); |
| 1928 | tprintf(", "); |
| 1929 | } else { |
| 1930 | if (syserror(tcp)) |
| 1931 | tprintf("%#lx", tcp->u_arg[offset + 1]); |
| 1932 | else |
| 1933 | printpathn(tcp, tcp->u_arg[offset + 1], tcp->u_rval); |
| 1934 | tprintf(", %lu", tcp->u_arg[offset + 2]); |
| 1935 | } |
| 1936 | return 0; |
| 1937 | } |
| 1938 | |
| 1939 | int |
| 1940 | sys_readlink(struct tcb *tcp) |
| 1941 | { |
| 1942 | return decode_readlink(tcp, 0); |
| 1943 | } |
| 1944 | |
| 1945 | #ifdef LINUX |
| 1946 | int |
| 1947 | sys_readlinkat(struct tcb *tcp) |
| 1948 | { |
| 1949 | if (entering(tcp)) |
| 1950 | print_dirfd(tcp->u_arg[0]); |
| 1951 | return decode_readlink(tcp, 1); |
| 1952 | } |
| 1953 | #endif |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1954 | |
| 1955 | int |
| 1956 | sys_rename(tcp) |
| 1957 | struct tcb *tcp; |
| 1958 | { |
| 1959 | if (entering(tcp)) { |
| 1960 | printpath(tcp, tcp->u_arg[0]); |
| 1961 | tprintf(", "); |
| 1962 | printpath(tcp, tcp->u_arg[1]); |
| 1963 | } |
| 1964 | return 0; |
| 1965 | } |
| 1966 | |
Dmitry V. Levin | 95ebf5a | 2006-10-13 20:25:12 +0000 | [diff] [blame] | 1967 | #ifdef LINUX |
| 1968 | int |
| 1969 | sys_renameat(struct tcb *tcp) |
| 1970 | { |
| 1971 | if (entering(tcp)) { |
| 1972 | print_dirfd(tcp->u_arg[0]); |
| 1973 | printpath(tcp, tcp->u_arg[1]); |
| 1974 | tprintf(", "); |
| 1975 | print_dirfd(tcp->u_arg[2]); |
| 1976 | printpath(tcp, tcp->u_arg[3]); |
| 1977 | } |
| 1978 | return 0; |
| 1979 | } |
| 1980 | #endif |
| 1981 | |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1982 | int |
| 1983 | sys_chown(tcp) |
| 1984 | struct tcb *tcp; |
| 1985 | { |
| 1986 | if (entering(tcp)) { |
| 1987 | printpath(tcp, tcp->u_arg[0]); |
Roland McGrath | 6bc1220 | 2003-11-13 22:32:27 +0000 | [diff] [blame] | 1988 | printuid(", ", tcp->u_arg[1]); |
| 1989 | printuid(", ", tcp->u_arg[2]); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1990 | } |
| 1991 | return 0; |
| 1992 | } |
| 1993 | |
Dmitry V. Levin | 95ebf5a | 2006-10-13 20:25:12 +0000 | [diff] [blame] | 1994 | #ifdef LINUX |
| 1995 | int |
| 1996 | sys_fchownat(struct tcb *tcp) |
| 1997 | { |
| 1998 | if (entering(tcp)) { |
| 1999 | print_dirfd(tcp->u_arg[0]); |
| 2000 | printpath(tcp, tcp->u_arg[1]); |
| 2001 | printuid(", ", tcp->u_arg[2]); |
| 2002 | printuid(", ", tcp->u_arg[3]); |
| 2003 | tprintf(", "); |
| 2004 | printflags(fstatatflags, tcp->u_arg[4], "AT_???"); |
| 2005 | } |
| 2006 | return 0; |
| 2007 | } |
| 2008 | #endif |
| 2009 | |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 2010 | int |
| 2011 | sys_fchown(tcp) |
| 2012 | struct tcb *tcp; |
| 2013 | { |
| 2014 | if (entering(tcp)) { |
Roland McGrath | 6bc1220 | 2003-11-13 22:32:27 +0000 | [diff] [blame] | 2015 | tprintf("%ld", tcp->u_arg[0]); |
| 2016 | printuid(", ", tcp->u_arg[1]); |
| 2017 | printuid(", ", tcp->u_arg[2]); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 2018 | } |
| 2019 | return 0; |
| 2020 | } |
| 2021 | |
Dmitry V. Levin | 95ebf5a | 2006-10-13 20:25:12 +0000 | [diff] [blame] | 2022 | static int |
| 2023 | decode_chmod(struct tcb *tcp, int offset) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 2024 | { |
| 2025 | if (entering(tcp)) { |
Dmitry V. Levin | 95ebf5a | 2006-10-13 20:25:12 +0000 | [diff] [blame] | 2026 | printpath(tcp, tcp->u_arg[offset]); |
| 2027 | tprintf(", %#lo", tcp->u_arg[offset + 1]); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 2028 | } |
| 2029 | return 0; |
| 2030 | } |
| 2031 | |
| 2032 | int |
Dmitry V. Levin | 95ebf5a | 2006-10-13 20:25:12 +0000 | [diff] [blame] | 2033 | sys_chmod(struct tcb *tcp) |
| 2034 | { |
| 2035 | return decode_chmod(tcp, 0); |
| 2036 | } |
| 2037 | |
| 2038 | #ifdef LINUX |
| 2039 | int |
| 2040 | sys_fchmodat(struct tcb *tcp) |
| 2041 | { |
| 2042 | if (entering(tcp)) |
| 2043 | print_dirfd(tcp->u_arg[0]); |
| 2044 | return decode_chmod(tcp, 1); |
| 2045 | } |
| 2046 | #endif |
| 2047 | |
| 2048 | int |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 2049 | sys_fchmod(tcp) |
| 2050 | struct tcb *tcp; |
| 2051 | { |
| 2052 | if (entering(tcp)) { |
| 2053 | tprintf("%ld, %#lo", tcp->u_arg[0], tcp->u_arg[1]); |
| 2054 | } |
| 2055 | return 0; |
| 2056 | } |
| 2057 | |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 2058 | #ifdef ALPHA |
| 2059 | int |
| 2060 | sys_osf_utimes(tcp) |
| 2061 | struct tcb *tcp; |
| 2062 | { |
| 2063 | if (entering(tcp)) { |
| 2064 | printpath(tcp, tcp->u_arg[0]); |
| 2065 | tprintf(", "); |
| 2066 | printtv32(tcp, tcp->u_arg[1]); |
| 2067 | } |
| 2068 | return 0; |
| 2069 | } |
| 2070 | #endif |
| 2071 | |
Dmitry V. Levin | 95ebf5a | 2006-10-13 20:25:12 +0000 | [diff] [blame] | 2072 | static int |
| 2073 | decode_utimes(struct tcb *tcp, int offset) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 2074 | { |
| 2075 | if (entering(tcp)) { |
Dmitry V. Levin | 95ebf5a | 2006-10-13 20:25:12 +0000 | [diff] [blame] | 2076 | printpath(tcp, tcp->u_arg[offset]); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 2077 | tprintf(", "); |
Dmitry V. Levin | 95ebf5a | 2006-10-13 20:25:12 +0000 | [diff] [blame] | 2078 | printtv(tcp, tcp->u_arg[offset + 1]); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 2079 | } |
| 2080 | return 0; |
| 2081 | } |
| 2082 | |
| 2083 | int |
Dmitry V. Levin | 95ebf5a | 2006-10-13 20:25:12 +0000 | [diff] [blame] | 2084 | sys_utimes(struct tcb *tcp) |
| 2085 | { |
| 2086 | return decode_utimes(tcp, 0); |
| 2087 | } |
| 2088 | |
| 2089 | #ifdef LINUX |
| 2090 | int |
| 2091 | sys_futimesat(struct tcb *tcp) |
| 2092 | { |
| 2093 | if (entering(tcp)) |
| 2094 | print_dirfd(tcp->u_arg[0]); |
| 2095 | return decode_utimes(tcp, 1); |
| 2096 | } |
| 2097 | #endif |
| 2098 | |
| 2099 | int |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 2100 | sys_utime(tcp) |
| 2101 | struct tcb *tcp; |
| 2102 | { |
| 2103 | long ut[2]; |
| 2104 | |
| 2105 | if (entering(tcp)) { |
| 2106 | printpath(tcp, tcp->u_arg[0]); |
| 2107 | tprintf(", "); |
| 2108 | if (!tcp->u_arg[1]) |
| 2109 | tprintf("NULL"); |
| 2110 | else if (!verbose(tcp)) |
| 2111 | tprintf("%#lx", tcp->u_arg[1]); |
| 2112 | else if (umoven(tcp, tcp->u_arg[1], sizeof ut, |
| 2113 | (char *) ut) < 0) |
| 2114 | tprintf("[?, ?]"); |
| 2115 | else { |
| 2116 | tprintf("[%s,", sprinttime(ut[0])); |
| 2117 | tprintf(" %s]", sprinttime(ut[1])); |
| 2118 | } |
| 2119 | } |
| 2120 | return 0; |
| 2121 | } |
| 2122 | |
Dmitry V. Levin | 95ebf5a | 2006-10-13 20:25:12 +0000 | [diff] [blame] | 2123 | static int |
| 2124 | decode_mknod(struct tcb *tcp, int offset) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 2125 | { |
Dmitry V. Levin | 95ebf5a | 2006-10-13 20:25:12 +0000 | [diff] [blame] | 2126 | int mode = tcp->u_arg[offset + 1]; |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 2127 | |
| 2128 | if (entering(tcp)) { |
Dmitry V. Levin | 95ebf5a | 2006-10-13 20:25:12 +0000 | [diff] [blame] | 2129 | printpath(tcp, tcp->u_arg[offset]); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 2130 | tprintf(", %s", sprintmode(mode)); |
| 2131 | switch (mode & S_IFMT) { |
| 2132 | case S_IFCHR: case S_IFBLK: |
| 2133 | #ifdef LINUXSPARC |
| 2134 | if (current_personality == 1) |
| 2135 | tprintf(", makedev(%lu, %lu)", |
Dmitry V. Levin | 95ebf5a | 2006-10-13 20:25:12 +0000 | [diff] [blame] | 2136 | (unsigned long) ((tcp->u_arg[offset + 2] >> 18) & 0x3fff), |
| 2137 | (unsigned long) (tcp->u_arg[offset + 2] & 0x3ffff)); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 2138 | else |
Roland McGrath | 186c5ac | 2002-12-15 23:58:23 +0000 | [diff] [blame] | 2139 | #endif |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 2140 | tprintf(", makedev(%lu, %lu)", |
Dmitry V. Levin | 95ebf5a | 2006-10-13 20:25:12 +0000 | [diff] [blame] | 2141 | (unsigned long) major(tcp->u_arg[offset + 2]), |
| 2142 | (unsigned long) minor(tcp->u_arg[offset + 2])); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 2143 | break; |
| 2144 | default: |
| 2145 | break; |
| 2146 | } |
| 2147 | } |
| 2148 | return 0; |
| 2149 | } |
| 2150 | |
| 2151 | int |
Dmitry V. Levin | 95ebf5a | 2006-10-13 20:25:12 +0000 | [diff] [blame] | 2152 | sys_mknod(struct tcb *tcp) |
| 2153 | { |
| 2154 | return decode_mknod(tcp, 0); |
| 2155 | } |
| 2156 | |
| 2157 | #ifdef LINUX |
| 2158 | int |
| 2159 | sys_mknodat(struct tcb *tcp) |
| 2160 | { |
| 2161 | if (entering(tcp)) |
| 2162 | print_dirfd(tcp->u_arg[0]); |
| 2163 | return decode_mknod(tcp, 1); |
| 2164 | } |
| 2165 | #endif |
| 2166 | |
| 2167 | int |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 2168 | sys_mkfifo(tcp) |
| 2169 | struct tcb *tcp; |
| 2170 | { |
| 2171 | if (entering(tcp)) { |
| 2172 | printpath(tcp, tcp->u_arg[0]); |
| 2173 | tprintf(", %#lo", tcp->u_arg[1]); |
| 2174 | } |
| 2175 | return 0; |
| 2176 | } |
| 2177 | |
| 2178 | int |
| 2179 | sys_fsync(tcp) |
| 2180 | struct tcb *tcp; |
| 2181 | { |
| 2182 | if (entering(tcp)) { |
| 2183 | tprintf("%ld", tcp->u_arg[0]); |
| 2184 | } |
| 2185 | return 0; |
| 2186 | } |
| 2187 | |
Michal Ludvig | 53b320f | 2002-09-23 13:30:09 +0000 | [diff] [blame] | 2188 | #ifdef LINUX |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 2189 | |
| 2190 | static void |
| 2191 | printdir(tcp, addr) |
| 2192 | struct tcb *tcp; |
| 2193 | long addr; |
| 2194 | { |
| 2195 | struct dirent d; |
| 2196 | |
| 2197 | if (!verbose(tcp)) { |
| 2198 | tprintf("%#lx", addr); |
| 2199 | return; |
| 2200 | } |
| 2201 | if (umove(tcp, addr, &d) < 0) { |
| 2202 | tprintf("{...}"); |
| 2203 | return; |
| 2204 | } |
| 2205 | tprintf("{d_ino=%ld, ", (unsigned long) d.d_ino); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 2206 | tprintf("d_name="); |
| 2207 | printpathn(tcp, (long) ((struct dirent *) addr)->d_name, d.d_reclen); |
| 2208 | tprintf("}"); |
| 2209 | } |
| 2210 | |
| 2211 | int |
| 2212 | sys_readdir(tcp) |
| 2213 | struct tcb *tcp; |
| 2214 | { |
| 2215 | if (entering(tcp)) { |
| 2216 | tprintf("%lu, ", tcp->u_arg[0]); |
| 2217 | } else { |
| 2218 | if (syserror(tcp) || tcp->u_rval == 0 || !verbose(tcp)) |
| 2219 | tprintf("%#lx", tcp->u_arg[1]); |
| 2220 | else |
| 2221 | printdir(tcp, tcp->u_arg[1]); |
| 2222 | /* Not much point in printing this out, it is always 1. */ |
| 2223 | if (tcp->u_arg[2] != 1) |
| 2224 | tprintf(", %lu", tcp->u_arg[2]); |
| 2225 | } |
| 2226 | return 0; |
| 2227 | } |
| 2228 | |
Michal Ludvig | 53b320f | 2002-09-23 13:30:09 +0000 | [diff] [blame] | 2229 | #endif /* LINUX */ |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 2230 | |
Roland McGrath | 4054284 | 2004-01-13 09:47:49 +0000 | [diff] [blame] | 2231 | #if defined FREEBSD || defined LINUX |
Roland McGrath | a4d4853 | 2005-06-08 20:45:28 +0000 | [diff] [blame] | 2232 | static const struct xlat direnttypes[] = { |
Roland McGrath | 4054284 | 2004-01-13 09:47:49 +0000 | [diff] [blame] | 2233 | { DT_UNKNOWN, "DT_UNKNOWN" }, |
Wichert Akkerman | bf79f2e | 2000-09-01 21:03:06 +0000 | [diff] [blame] | 2234 | { DT_FIFO, "DT_FIFO" }, |
| 2235 | { DT_CHR, "DT_CHR" }, |
| 2236 | { DT_DIR, "DT_DIR" }, |
| 2237 | { DT_BLK, "DT_BLK" }, |
| 2238 | { DT_REG, "DT_REG" }, |
| 2239 | { DT_LNK, "DT_LNK" }, |
| 2240 | { DT_SOCK, "DT_SOCK" }, |
| 2241 | { DT_WHT, "DT_WHT" }, |
| 2242 | { 0, NULL }, |
| 2243 | }; |
| 2244 | |
| 2245 | #endif |
| 2246 | |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 2247 | int |
| 2248 | sys_getdents(tcp) |
| 2249 | struct tcb *tcp; |
| 2250 | { |
| 2251 | int i, len, dents = 0; |
| 2252 | char *buf; |
| 2253 | |
| 2254 | if (entering(tcp)) { |
| 2255 | tprintf("%lu, ", tcp->u_arg[0]); |
| 2256 | return 0; |
| 2257 | } |
| 2258 | if (syserror(tcp) || !verbose(tcp)) { |
| 2259 | tprintf("%#lx, %lu", tcp->u_arg[1], tcp->u_arg[2]); |
| 2260 | return 0; |
| 2261 | } |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 2262 | len = tcp->u_rval; |
| 2263 | if ((buf = malloc(len)) == NULL) { |
Roland McGrath | 46100d0 | 2005-06-01 18:55:42 +0000 | [diff] [blame] | 2264 | tprintf("%#lx, %lu", tcp->u_arg[1], tcp->u_arg[2]); |
| 2265 | fprintf(stderr, "out of memory\n"); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 2266 | return 0; |
| 2267 | } |
| 2268 | if (umoven(tcp, tcp->u_arg[1], len, buf) < 0) { |
Roland McGrath | 46100d0 | 2005-06-01 18:55:42 +0000 | [diff] [blame] | 2269 | tprintf("%#lx, %lu", tcp->u_arg[1], tcp->u_arg[2]); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 2270 | free(buf); |
| 2271 | return 0; |
| 2272 | } |
| 2273 | if (!abbrev(tcp)) |
| 2274 | tprintf("{"); |
| 2275 | for (i = 0; i < len;) { |
Wichert Akkerman | 9524bb9 | 1999-05-25 23:11:18 +0000 | [diff] [blame] | 2276 | struct kernel_dirent *d = (struct kernel_dirent *) &buf[i]; |
Michal Ludvig | 53b320f | 2002-09-23 13:30:09 +0000 | [diff] [blame] | 2277 | #ifdef LINUX |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 2278 | if (!abbrev(tcp)) { |
| 2279 | tprintf("%s{d_ino=%lu, d_off=%lu, ", |
| 2280 | i ? " " : "", d->d_ino, d->d_off); |
| 2281 | tprintf("d_reclen=%u, d_name=\"%s\"}", |
| 2282 | d->d_reclen, d->d_name); |
| 2283 | } |
Michal Ludvig | 53b320f | 2002-09-23 13:30:09 +0000 | [diff] [blame] | 2284 | #endif /* LINUX */ |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 2285 | #ifdef SVR4 |
| 2286 | if (!abbrev(tcp)) { |
| 2287 | tprintf("%s{d_ino=%lu, d_off=%lu, ", |
Roland McGrath | 186c5ac | 2002-12-15 23:58:23 +0000 | [diff] [blame] | 2288 | i ? " " : "", |
| 2289 | (unsigned long) d->d_ino, |
| 2290 | (unsigned long) d->d_off); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 2291 | tprintf("d_reclen=%u, d_name=\"%s\"}", |
| 2292 | d->d_reclen, d->d_name); |
| 2293 | } |
| 2294 | #endif /* SVR4 */ |
| 2295 | #ifdef SUNOS4 |
| 2296 | if (!abbrev(tcp)) { |
| 2297 | tprintf("%s{d_off=%lu, d_fileno=%lu, d_reclen=%u, ", |
| 2298 | i ? " " : "", d->d_off, d->d_fileno, |
| 2299 | d->d_reclen); |
| 2300 | tprintf("d_namlen=%u, d_name=\"%.*s\"}", |
| 2301 | d->d_namlen, d->d_namlen, d->d_name); |
| 2302 | } |
| 2303 | #endif /* SUNOS4 */ |
Wichert Akkerman | bf79f2e | 2000-09-01 21:03:06 +0000 | [diff] [blame] | 2304 | #ifdef FREEBSD |
| 2305 | if (!abbrev(tcp)) { |
| 2306 | tprintf("%s{d_fileno=%u, d_reclen=%u, d_type=", |
| 2307 | i ? " " : "", d->d_fileno, d->d_reclen); |
| 2308 | printxval(direnttypes, d->d_type, "DT_???"); |
| 2309 | tprintf(", d_namlen=%u, d_name=\"%.*s\"}", |
| 2310 | d->d_namlen, d->d_namlen, d->d_name); |
| 2311 | } |
Roland McGrath | 186c5ac | 2002-12-15 23:58:23 +0000 | [diff] [blame] | 2312 | #endif /* FREEBSD */ |
Pavel Machek | 9a9f10b | 2000-02-01 16:22:52 +0000 | [diff] [blame] | 2313 | if (!d->d_reclen) { |
| 2314 | tprintf("/* d_reclen == 0, problem here */"); |
| 2315 | break; |
| 2316 | } |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 2317 | i += d->d_reclen; |
| 2318 | dents++; |
| 2319 | } |
| 2320 | if (!abbrev(tcp)) |
| 2321 | tprintf("}"); |
| 2322 | else |
| 2323 | tprintf("/* %u entries */", dents); |
| 2324 | tprintf(", %lu", tcp->u_arg[2]); |
| 2325 | free(buf); |
| 2326 | return 0; |
| 2327 | } |
| 2328 | |
John Hughes | bdf48f5 | 2001-03-06 15:08:09 +0000 | [diff] [blame] | 2329 | |
| 2330 | #if _LFS64_LARGEFILE |
| 2331 | int |
| 2332 | sys_getdents64(tcp) |
| 2333 | struct tcb *tcp; |
| 2334 | { |
| 2335 | int i, len, dents = 0; |
| 2336 | char *buf; |
| 2337 | |
| 2338 | if (entering(tcp)) { |
| 2339 | tprintf("%lu, ", tcp->u_arg[0]); |
| 2340 | return 0; |
| 2341 | } |
| 2342 | if (syserror(tcp) || !verbose(tcp)) { |
| 2343 | tprintf("%#lx, %lu", tcp->u_arg[1], tcp->u_arg[2]); |
| 2344 | return 0; |
| 2345 | } |
| 2346 | len = tcp->u_rval; |
| 2347 | if ((buf = malloc(len)) == NULL) { |
Roland McGrath | 46100d0 | 2005-06-01 18:55:42 +0000 | [diff] [blame] | 2348 | tprintf("%#lx, %lu", tcp->u_arg[1], tcp->u_arg[2]); |
| 2349 | fprintf(stderr, "out of memory\n"); |
John Hughes | bdf48f5 | 2001-03-06 15:08:09 +0000 | [diff] [blame] | 2350 | return 0; |
| 2351 | } |
| 2352 | if (umoven(tcp, tcp->u_arg[1], len, buf) < 0) { |
Roland McGrath | 46100d0 | 2005-06-01 18:55:42 +0000 | [diff] [blame] | 2353 | tprintf("%#lx, %lu", tcp->u_arg[1], tcp->u_arg[2]); |
John Hughes | bdf48f5 | 2001-03-06 15:08:09 +0000 | [diff] [blame] | 2354 | free(buf); |
| 2355 | return 0; |
| 2356 | } |
| 2357 | if (!abbrev(tcp)) |
| 2358 | tprintf("{"); |
| 2359 | for (i = 0; i < len;) { |
| 2360 | struct dirent64 *d = (struct dirent64 *) &buf[i]; |
Michal Ludvig | 53b320f | 2002-09-23 13:30:09 +0000 | [diff] [blame] | 2361 | #if defined(LINUX) || defined(SVR4) |
John Hughes | bdf48f5 | 2001-03-06 15:08:09 +0000 | [diff] [blame] | 2362 | if (!abbrev(tcp)) { |
Dmitry V. Levin | 1f336e5 | 2006-10-14 20:20:46 +0000 | [diff] [blame^] | 2363 | tprintf("%s{d_ino=%" PRIu64 ", d_off=%" PRId64 ", ", |
Roland McGrath | 186c5ac | 2002-12-15 23:58:23 +0000 | [diff] [blame] | 2364 | i ? " " : "", |
Roland McGrath | 9205324 | 2004-01-13 10:16:47 +0000 | [diff] [blame] | 2365 | d->d_ino, |
| 2366 | d->d_off); |
Roland McGrath | 4054284 | 2004-01-13 09:47:49 +0000 | [diff] [blame] | 2367 | #ifdef LINUX |
| 2368 | tprintf("d_type="); |
| 2369 | printxval(direnttypes, d->d_type, "DT_???"); |
| 2370 | tprintf(", "); |
| 2371 | #endif |
John Hughes | bdf48f5 | 2001-03-06 15:08:09 +0000 | [diff] [blame] | 2372 | tprintf("d_reclen=%u, d_name=\"%s\"}", |
| 2373 | d->d_reclen, d->d_name); |
| 2374 | } |
Michal Ludvig | 53b320f | 2002-09-23 13:30:09 +0000 | [diff] [blame] | 2375 | #endif /* LINUX || SVR4 */ |
John Hughes | bdf48f5 | 2001-03-06 15:08:09 +0000 | [diff] [blame] | 2376 | #ifdef SUNOS4 |
| 2377 | if (!abbrev(tcp)) { |
| 2378 | tprintf("%s{d_off=%lu, d_fileno=%lu, d_reclen=%u, ", |
| 2379 | i ? " " : "", d->d_off, d->d_fileno, |
| 2380 | d->d_reclen); |
| 2381 | tprintf("d_namlen=%u, d_name=\"%.*s\"}", |
| 2382 | d->d_namlen, d->d_namlen, d->d_name); |
| 2383 | } |
| 2384 | #endif /* SUNOS4 */ |
| 2385 | i += d->d_reclen; |
| 2386 | dents++; |
| 2387 | } |
| 2388 | if (!abbrev(tcp)) |
| 2389 | tprintf("}"); |
| 2390 | else |
| 2391 | tprintf("/* %u entries */", dents); |
| 2392 | tprintf(", %lu", tcp->u_arg[2]); |
| 2393 | free(buf); |
| 2394 | return 0; |
| 2395 | } |
| 2396 | #endif |
Roland McGrath | 186c5ac | 2002-12-15 23:58:23 +0000 | [diff] [blame] | 2397 | |
Wichert Akkerman | bf79f2e | 2000-09-01 21:03:06 +0000 | [diff] [blame] | 2398 | #ifdef FREEBSD |
| 2399 | int |
| 2400 | sys_getdirentries(tcp) |
| 2401 | struct tcb * tcp; |
| 2402 | { |
| 2403 | int i, len, dents = 0; |
| 2404 | long basep; |
| 2405 | char *buf; |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 2406 | |
Wichert Akkerman | bf79f2e | 2000-09-01 21:03:06 +0000 | [diff] [blame] | 2407 | if (entering(tcp)) { |
| 2408 | tprintf("%lu, ", tcp->u_arg[0]); |
| 2409 | return 0; |
| 2410 | } |
| 2411 | if (syserror(tcp) || !verbose(tcp)) { |
| 2412 | tprintf("%#lx, %lu, %#lx", tcp->u_arg[1], tcp->u_arg[2], tcp->u_arg[3]); |
| 2413 | return 0; |
| 2414 | } |
| 2415 | len = tcp->u_rval; |
| 2416 | if ((buf = malloc(len)) == NULL) { |
Roland McGrath | 46100d0 | 2005-06-01 18:55:42 +0000 | [diff] [blame] | 2417 | tprintf("%#lx, %lu, %#lx", tcp->u_arg[1], tcp->u_arg[2], tcp->u_arg[3]); |
| 2418 | fprintf(stderr, "out of memory\n"); |
Wichert Akkerman | bf79f2e | 2000-09-01 21:03:06 +0000 | [diff] [blame] | 2419 | return 0; |
| 2420 | } |
| 2421 | if (umoven(tcp, tcp->u_arg[1], len, buf) < 0) { |
Roland McGrath | 46100d0 | 2005-06-01 18:55:42 +0000 | [diff] [blame] | 2422 | tprintf("%#lx, %lu, %#lx", tcp->u_arg[1], tcp->u_arg[2], tcp->u_arg[3]); |
Wichert Akkerman | bf79f2e | 2000-09-01 21:03:06 +0000 | [diff] [blame] | 2423 | free(buf); |
| 2424 | return 0; |
| 2425 | } |
| 2426 | if (!abbrev(tcp)) |
| 2427 | tprintf("{"); |
| 2428 | for (i = 0; i < len;) { |
| 2429 | struct kernel_dirent *d = (struct kernel_dirent *) &buf[i]; |
| 2430 | if (!abbrev(tcp)) { |
| 2431 | tprintf("%s{d_fileno=%u, d_reclen=%u, d_type=", |
| 2432 | i ? " " : "", d->d_fileno, d->d_reclen); |
| 2433 | printxval(direnttypes, d->d_type, "DT_???"); |
| 2434 | tprintf(", d_namlen=%u, d_name=\"%.*s\"}", |
| 2435 | d->d_namlen, d->d_namlen, d->d_name); |
| 2436 | } |
| 2437 | i += d->d_reclen; |
| 2438 | dents++; |
| 2439 | } |
| 2440 | if (!abbrev(tcp)) |
| 2441 | tprintf("}"); |
| 2442 | else |
| 2443 | tprintf("/* %u entries */", dents); |
| 2444 | free(buf); |
| 2445 | tprintf(", %lu", tcp->u_arg[2]); |
| 2446 | if (umove(tcp, tcp->u_arg[3], &basep) < 0) |
| 2447 | tprintf(", %#lx", tcp->u_arg[3]); |
| 2448 | else |
| 2449 | tprintf(", [%lu]", basep); |
| 2450 | return 0; |
| 2451 | } |
| 2452 | #endif |
| 2453 | |
Michal Ludvig | 53b320f | 2002-09-23 13:30:09 +0000 | [diff] [blame] | 2454 | #ifdef LINUX |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 2455 | int |
| 2456 | sys_getcwd(tcp) |
| 2457 | struct tcb *tcp; |
| 2458 | { |
| 2459 | if (exiting(tcp)) { |
| 2460 | if (syserror(tcp)) |
| 2461 | tprintf("%#lx", tcp->u_arg[0]); |
| 2462 | else |
Wichert Akkerman | 2e2553a | 1999-05-09 00:29:58 +0000 | [diff] [blame] | 2463 | printpathn(tcp, tcp->u_arg[0], tcp->u_rval - 1); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 2464 | tprintf(", %lu", tcp->u_arg[1]); |
| 2465 | } |
| 2466 | return 0; |
| 2467 | } |
Michal Ludvig | 53b320f | 2002-09-23 13:30:09 +0000 | [diff] [blame] | 2468 | #endif /* LINUX */ |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 2469 | |
Wichert Akkerman | bf79f2e | 2000-09-01 21:03:06 +0000 | [diff] [blame] | 2470 | #ifdef FREEBSD |
| 2471 | int |
| 2472 | sys___getcwd(tcp) |
| 2473 | struct tcb *tcp; |
| 2474 | { |
| 2475 | if (exiting(tcp)) { |
| 2476 | if (syserror(tcp)) |
| 2477 | tprintf("%#lx", tcp->u_arg[0]); |
| 2478 | else |
| 2479 | printpathn(tcp, tcp->u_arg[0], tcp->u_arg[1]); |
| 2480 | tprintf(", %lu", tcp->u_arg[1]); |
| 2481 | } |
| 2482 | return 0; |
| 2483 | } |
| 2484 | #endif |
| 2485 | |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 2486 | #ifdef HAVE_SYS_ASYNCH_H |
| 2487 | |
| 2488 | int |
| 2489 | sys_aioread(tcp) |
| 2490 | struct tcb *tcp; |
| 2491 | { |
| 2492 | struct aio_result_t res; |
| 2493 | |
| 2494 | if (entering(tcp)) { |
| 2495 | tprintf("%lu, ", tcp->u_arg[0]); |
| 2496 | } else { |
| 2497 | if (syserror(tcp)) |
| 2498 | tprintf("%#lx", tcp->u_arg[1]); |
| 2499 | else |
| 2500 | printstr(tcp, tcp->u_arg[1], tcp->u_arg[2]); |
| 2501 | tprintf(", %lu, %lu, ", tcp->u_arg[2], tcp->u_arg[3]); |
| 2502 | printxval(whence, tcp->u_arg[4], "L_???"); |
| 2503 | if (syserror(tcp) || tcp->u_arg[5] == 0 |
| 2504 | || umove(tcp, tcp->u_arg[5], &res) < 0) |
| 2505 | tprintf(", %#lx", tcp->u_arg[5]); |
| 2506 | else |
| 2507 | tprintf(", {aio_return %d aio_errno %d}", |
| 2508 | res.aio_return, res.aio_errno); |
| 2509 | } |
| 2510 | return 0; |
| 2511 | } |
| 2512 | |
| 2513 | int |
| 2514 | sys_aiowrite(tcp) |
| 2515 | struct tcb *tcp; |
| 2516 | { |
| 2517 | struct aio_result_t res; |
| 2518 | |
| 2519 | if (entering(tcp)) { |
| 2520 | tprintf("%lu, ", tcp->u_arg[0]); |
| 2521 | printstr(tcp, tcp->u_arg[1], tcp->u_arg[2]); |
| 2522 | tprintf(", %lu, %lu, ", tcp->u_arg[2], tcp->u_arg[3]); |
| 2523 | printxval(whence, tcp->u_arg[4], "L_???"); |
| 2524 | } |
| 2525 | else { |
| 2526 | if (tcp->u_arg[5] == 0) |
| 2527 | tprintf(", NULL"); |
| 2528 | else if (syserror(tcp) |
| 2529 | || umove(tcp, tcp->u_arg[5], &res) < 0) |
| 2530 | tprintf(", %#lx", tcp->u_arg[5]); |
| 2531 | else |
| 2532 | tprintf(", {aio_return %d aio_errno %d}", |
| 2533 | res.aio_return, res.aio_errno); |
| 2534 | } |
| 2535 | return 0; |
| 2536 | } |
| 2537 | |
| 2538 | int |
| 2539 | sys_aiowait(tcp) |
| 2540 | struct tcb *tcp; |
| 2541 | { |
| 2542 | if (entering(tcp)) |
| 2543 | printtv(tcp, tcp->u_arg[0]); |
| 2544 | return 0; |
| 2545 | } |
| 2546 | |
| 2547 | int |
| 2548 | sys_aiocancel(tcp) |
| 2549 | struct tcb *tcp; |
| 2550 | { |
| 2551 | struct aio_result_t res; |
| 2552 | |
| 2553 | if (exiting(tcp)) { |
| 2554 | if (tcp->u_arg[0] == 0) |
| 2555 | tprintf("NULL"); |
| 2556 | else if (syserror(tcp) |
| 2557 | || umove(tcp, tcp->u_arg[0], &res) < 0) |
| 2558 | tprintf("%#lx", tcp->u_arg[0]); |
| 2559 | else |
| 2560 | tprintf("{aio_return %d aio_errno %d}", |
| 2561 | res.aio_return, res.aio_errno); |
| 2562 | } |
| 2563 | return 0; |
| 2564 | } |
| 2565 | |
| 2566 | #endif /* HAVE_SYS_ASYNCH_H */ |
Roland McGrath | 186c5ac | 2002-12-15 23:58:23 +0000 | [diff] [blame] | 2567 | |
Roland McGrath | a4d4853 | 2005-06-08 20:45:28 +0000 | [diff] [blame] | 2568 | static const struct xlat xattrflags[] = { |
Roland McGrath | 561c799 | 2003-04-02 01:10:44 +0000 | [diff] [blame] | 2569 | #ifdef XATTR_CREATE |
Roland McGrath | 186c5ac | 2002-12-15 23:58:23 +0000 | [diff] [blame] | 2570 | { XATTR_CREATE, "XATTR_CREATE" }, |
| 2571 | { XATTR_REPLACE, "XATTR_REPLACE" }, |
Roland McGrath | 561c799 | 2003-04-02 01:10:44 +0000 | [diff] [blame] | 2572 | #endif |
Roland McGrath | 186c5ac | 2002-12-15 23:58:23 +0000 | [diff] [blame] | 2573 | { 0, NULL } |
| 2574 | }; |
| 2575 | |
Roland McGrath | 3292e22 | 2004-08-31 06:30:48 +0000 | [diff] [blame] | 2576 | static void |
| 2577 | print_xattr_val(tcp, failed, arg, insize, size) |
| 2578 | struct tcb *tcp; |
| 2579 | int failed; |
| 2580 | unsigned long arg; |
Roland McGrath | aa524c8 | 2005-06-01 19:22:06 +0000 | [diff] [blame] | 2581 | unsigned long insize, size; |
Roland McGrath | 3292e22 | 2004-08-31 06:30:48 +0000 | [diff] [blame] | 2582 | { |
Roland McGrath | 883567c | 2005-02-02 03:38:32 +0000 | [diff] [blame] | 2583 | if (!failed) { |
Roland McGrath | aa524c8 | 2005-06-01 19:22:06 +0000 | [diff] [blame] | 2584 | unsigned long capacity = 4 * size + 1; |
| 2585 | unsigned char *buf = (capacity < size) ? NULL : malloc(capacity); |
Roland McGrath | 883567c | 2005-02-02 03:38:32 +0000 | [diff] [blame] | 2586 | if (buf == NULL || /* probably a bogus size argument */ |
Roland McGrath | f774642 | 2005-03-01 23:02:32 +0000 | [diff] [blame] | 2587 | umoven(tcp, arg, size, (char *) &buf[3 * size]) < 0) { |
Roland McGrath | 883567c | 2005-02-02 03:38:32 +0000 | [diff] [blame] | 2588 | failed = 1; |
| 2589 | } |
| 2590 | else { |
| 2591 | unsigned char *out = buf; |
| 2592 | unsigned char *in = &buf[3 * size]; |
| 2593 | size_t i; |
| 2594 | for (i = 0; i < size; ++i) |
| 2595 | if (isprint(in[i])) |
| 2596 | *out++ = in[i]; |
| 2597 | else { |
Roland McGrath | 3292e22 | 2004-08-31 06:30:48 +0000 | [diff] [blame] | 2598 | #define tohex(n) "0123456789abcdef"[n] |
Roland McGrath | 883567c | 2005-02-02 03:38:32 +0000 | [diff] [blame] | 2599 | *out++ = '\\'; |
| 2600 | *out++ = 'x'; |
| 2601 | *out++ = tohex(in[i] / 16); |
| 2602 | *out++ = tohex(in[i] % 16); |
| 2603 | } |
| 2604 | /* Don't print terminating NUL if there is one. */ |
Dmitry V. Levin | 504eb0b | 2006-10-11 22:58:31 +0000 | [diff] [blame] | 2605 | if (i > 0 && in[i - 1] == '\0') |
Roland McGrath | 883567c | 2005-02-02 03:38:32 +0000 | [diff] [blame] | 2606 | out -= 4; |
| 2607 | *out = '\0'; |
| 2608 | tprintf(", \"%s\", %ld", buf, insize); |
| 2609 | } |
| 2610 | free(buf); |
| 2611 | } |
| 2612 | if (failed) |
| 2613 | tprintf(", 0x%lx, %ld", arg, insize); |
Roland McGrath | 3292e22 | 2004-08-31 06:30:48 +0000 | [diff] [blame] | 2614 | } |
| 2615 | |
Roland McGrath | 186c5ac | 2002-12-15 23:58:23 +0000 | [diff] [blame] | 2616 | int |
| 2617 | sys_setxattr(tcp) |
| 2618 | struct tcb *tcp; |
| 2619 | { |
| 2620 | if (entering(tcp)) { |
| 2621 | printpath(tcp, tcp->u_arg[0]); |
| 2622 | tprintf(", "); |
| 2623 | printstr(tcp, tcp->u_arg[1], -1); |
Roland McGrath | 3292e22 | 2004-08-31 06:30:48 +0000 | [diff] [blame] | 2624 | print_xattr_val(tcp, 0, tcp->u_arg[2], tcp->u_arg[3], tcp->u_arg[3]); |
| 2625 | tprintf(", "); |
Roland McGrath | b2dee13 | 2005-06-01 19:02:36 +0000 | [diff] [blame] | 2626 | printflags(xattrflags, tcp->u_arg[4], "XATTR_???"); |
Roland McGrath | 186c5ac | 2002-12-15 23:58:23 +0000 | [diff] [blame] | 2627 | } |
| 2628 | return 0; |
| 2629 | } |
| 2630 | |
| 2631 | int |
| 2632 | sys_fsetxattr(tcp) |
| 2633 | struct tcb *tcp; |
| 2634 | { |
| 2635 | if (entering(tcp)) { |
| 2636 | tprintf("%ld, ", tcp->u_arg[0]); |
| 2637 | printstr(tcp, tcp->u_arg[1], -1); |
Roland McGrath | 3292e22 | 2004-08-31 06:30:48 +0000 | [diff] [blame] | 2638 | print_xattr_val(tcp, 0, tcp->u_arg[2], tcp->u_arg[3], tcp->u_arg[3]); |
| 2639 | tprintf(", "); |
Roland McGrath | b2dee13 | 2005-06-01 19:02:36 +0000 | [diff] [blame] | 2640 | printflags(xattrflags, tcp->u_arg[4], "XATTR_???"); |
Roland McGrath | 186c5ac | 2002-12-15 23:58:23 +0000 | [diff] [blame] | 2641 | } |
| 2642 | return 0; |
| 2643 | } |
| 2644 | |
| 2645 | int |
| 2646 | sys_getxattr(tcp) |
| 2647 | struct tcb *tcp; |
| 2648 | { |
| 2649 | if (entering(tcp)) { |
| 2650 | printpath(tcp, tcp->u_arg[0]); |
| 2651 | tprintf(", "); |
| 2652 | printstr(tcp, tcp->u_arg[1], -1); |
| 2653 | } else { |
Roland McGrath | 3292e22 | 2004-08-31 06:30:48 +0000 | [diff] [blame] | 2654 | print_xattr_val(tcp, syserror(tcp), tcp->u_arg[2], tcp->u_arg[3], |
| 2655 | tcp->u_rval); |
Roland McGrath | 186c5ac | 2002-12-15 23:58:23 +0000 | [diff] [blame] | 2656 | } |
| 2657 | return 0; |
| 2658 | } |
| 2659 | |
| 2660 | int |
| 2661 | sys_fgetxattr(tcp) |
| 2662 | struct tcb *tcp; |
| 2663 | { |
| 2664 | if (entering(tcp)) { |
| 2665 | tprintf("%ld, ", tcp->u_arg[0]); |
| 2666 | printstr(tcp, tcp->u_arg[1], -1); |
| 2667 | } else { |
Roland McGrath | 3292e22 | 2004-08-31 06:30:48 +0000 | [diff] [blame] | 2668 | print_xattr_val(tcp, syserror(tcp), tcp->u_arg[2], tcp->u_arg[3], |
| 2669 | tcp->u_rval); |
Roland McGrath | 186c5ac | 2002-12-15 23:58:23 +0000 | [diff] [blame] | 2670 | } |
| 2671 | return 0; |
| 2672 | } |
| 2673 | |
| 2674 | int |
| 2675 | sys_listxattr(tcp) |
| 2676 | struct tcb *tcp; |
| 2677 | { |
| 2678 | if (entering(tcp)) { |
| 2679 | printpath(tcp, tcp->u_arg[0]); |
| 2680 | } else { |
| 2681 | /* XXX Print value in format */ |
| 2682 | tprintf(", %p, %lu", (void *) tcp->u_arg[1], tcp->u_arg[2]); |
| 2683 | } |
| 2684 | return 0; |
| 2685 | } |
| 2686 | |
| 2687 | int |
| 2688 | sys_flistxattr(tcp) |
| 2689 | struct tcb *tcp; |
| 2690 | { |
| 2691 | if (entering(tcp)) { |
| 2692 | tprintf("%ld", tcp->u_arg[0]); |
| 2693 | } else { |
| 2694 | /* XXX Print value in format */ |
| 2695 | tprintf(", %p, %lu", (void *) tcp->u_arg[1], tcp->u_arg[2]); |
| 2696 | } |
| 2697 | return 0; |
| 2698 | } |
| 2699 | |
| 2700 | int |
| 2701 | sys_removexattr(tcp) |
| 2702 | struct tcb *tcp; |
| 2703 | { |
| 2704 | if (entering(tcp)) { |
| 2705 | printpath(tcp, tcp->u_arg[0]); |
| 2706 | tprintf(", "); |
| 2707 | printstr(tcp, tcp->u_arg[1], -1); |
| 2708 | } |
| 2709 | return 0; |
| 2710 | } |
| 2711 | |
| 2712 | int |
| 2713 | sys_fremovexattr(tcp) |
| 2714 | struct tcb *tcp; |
| 2715 | { |
| 2716 | if (entering(tcp)) { |
| 2717 | tprintf("%ld, ", tcp->u_arg[0]); |
| 2718 | printstr(tcp, tcp->u_arg[1], -1); |
| 2719 | } |
| 2720 | return 0; |
| 2721 | } |
Roland McGrath | df13e8f | 2004-10-07 18:51:19 +0000 | [diff] [blame] | 2722 | |
| 2723 | |
| 2724 | static const struct xlat advise[] = { |
| 2725 | { POSIX_FADV_NORMAL, "POSIX_FADV_NORMAL" }, |
| 2726 | { POSIX_FADV_RANDOM, "POSIX_FADV_RANDOM" }, |
| 2727 | { POSIX_FADV_SEQUENTIAL, "POSIX_FADV_SEQUENTIAL" }, |
| 2728 | { POSIX_FADV_WILLNEED, "POSIX_FADV_WILLNEED" }, |
| 2729 | { POSIX_FADV_DONTNEED, "POSIX_FADV_DONTNEED" }, |
| 2730 | { POSIX_FADV_NOREUSE, "POSIX_FADV_NOREUSE" }, |
| 2731 | { 0, NULL } |
| 2732 | }; |
| 2733 | |
| 2734 | |
Roland McGrath | e27ed34 | 2004-10-20 02:24:19 +0000 | [diff] [blame] | 2735 | #ifdef LINUX |
Roland McGrath | df13e8f | 2004-10-07 18:51:19 +0000 | [diff] [blame] | 2736 | int |
| 2737 | sys_fadvise64(tcp) |
| 2738 | struct tcb *tcp; |
| 2739 | { |
| 2740 | if (entering(tcp)) { |
| 2741 | tprintf("%ld, %lld, %ld, ", |
| 2742 | tcp->u_arg[0], |
| 2743 | # if defined IA64 || defined X86_64 || defined ALPHA |
| 2744 | (long long int) tcp->u_arg[1], tcp->u_arg[2]); |
| 2745 | printxval(advise, tcp->u_arg[3], "POSIX_FADV_???"); |
| 2746 | #else |
Roland McGrath | 2fe2a3e | 2004-10-07 19:09:16 +0000 | [diff] [blame] | 2747 | LONG_LONG(tcp->u_arg[1], tcp->u_arg[2]), tcp->u_arg[3]); |
| 2748 | printxval(advise, tcp->u_arg[4], "POSIX_FADV_???"); |
Roland McGrath | df13e8f | 2004-10-07 18:51:19 +0000 | [diff] [blame] | 2749 | #endif |
| 2750 | } |
| 2751 | return 0; |
| 2752 | } |
| 2753 | #endif |
| 2754 | |
| 2755 | |
| 2756 | int |
| 2757 | sys_fadvise64_64(tcp) |
| 2758 | struct tcb *tcp; |
| 2759 | { |
| 2760 | if (entering(tcp)) { |
| 2761 | tprintf("%ld, %lld, %lld, ", |
| 2762 | tcp->u_arg[0], |
| 2763 | # if defined IA64 || defined X86_64 || defined ALPHA |
| 2764 | (long long int) tcp->u_arg[1], (long long int) tcp->u_arg[2]); |
| 2765 | printxval(advise, tcp->u_arg[3], "POSIX_FADV_???"); |
| 2766 | #else |
Roland McGrath | 2fe2a3e | 2004-10-07 19:09:16 +0000 | [diff] [blame] | 2767 | LONG_LONG(tcp->u_arg[1], tcp->u_arg[2]), |
| 2768 | LONG_LONG(tcp->u_arg[3], tcp->u_arg[4])); |
Roland McGrath | df13e8f | 2004-10-07 18:51:19 +0000 | [diff] [blame] | 2769 | printxval(advise, tcp->u_arg[5], "POSIX_FADV_???"); |
| 2770 | #endif |
| 2771 | } |
| 2772 | return 0; |
| 2773 | } |
Dmitry V. Levin | 95ebf5a | 2006-10-13 20:25:12 +0000 | [diff] [blame] | 2774 | |
| 2775 | #ifdef LINUX |
| 2776 | static const struct xlat inotify_modes[] = { |
| 2777 | { 0x00000001, "IN_ACCESS" }, |
| 2778 | { 0x00000002, "IN_MODIFY" }, |
| 2779 | { 0x00000004, "IN_ATTRIB" }, |
| 2780 | { 0x00000008, "IN_CLOSE_WRITE" }, |
| 2781 | { 0x00000010, "IN_CLOSE_NOWRITE" }, |
| 2782 | { 0x00000020, "IN_OPEN" }, |
| 2783 | { 0x00000040, "IN_MOVED_FROM" }, |
| 2784 | { 0x00000080, "IN_MOVED_TO" }, |
| 2785 | { 0x00000100, "IN_CREATE" }, |
| 2786 | { 0x00000200, "IN_DELETE" }, |
| 2787 | { 0x00000400, "IN_DELETE_SELF" }, |
| 2788 | { 0x00000800, "IN_MOVE_SELF" }, |
| 2789 | { 0x00002000, "IN_UNMOUNT" }, |
| 2790 | { 0x00004000, "IN_Q_OVERFLOW" }, |
| 2791 | { 0x00008000, "IN_IGNORED" }, |
| 2792 | { 0x01000000, "IN_ONLYDIR" }, |
| 2793 | { 0x02000000, "IN_DONT_FOLLOW" }, |
| 2794 | { 0x20000000, "IN_MASK_ADD" }, |
| 2795 | { 0x40000000, "IN_ISDIR" }, |
| 2796 | { 0x80000000, "IN_ONESHOT" } |
| 2797 | }; |
| 2798 | |
| 2799 | int |
| 2800 | sys_inotify_add_watch(struct tcb *tcp) |
| 2801 | { |
| 2802 | if (entering(tcp)) { |
| 2803 | tprintf("%ld, ", tcp->u_arg[0]); |
| 2804 | printpath(tcp, tcp->u_arg[1]); |
| 2805 | tprintf(", "); |
| 2806 | printflags(inotify_modes, tcp->u_arg[2], "IN_???"); |
| 2807 | } |
| 2808 | return 0; |
| 2809 | } |
| 2810 | |
| 2811 | int |
| 2812 | sys_inotify_rm_watch(struct tcb *tcp) |
| 2813 | { |
| 2814 | if (entering(tcp)) { |
| 2815 | tprintf("%ld, %ld", tcp->u_arg[0], tcp->u_arg[1]); |
| 2816 | } |
| 2817 | return 0; |
| 2818 | } |
| 2819 | #endif |