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