| Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1 | /* | 
 | 2 |  * Copyright (c) 1991, 1992 Paul Kranenburg <pk@cs.few.eur.nl> | 
 | 3 |  * Copyright (c) 1993 Branko Lankester <branko@hacktic.nl> | 
 | 4 |  * Copyright (c) 1993, 1994, 1995, 1996 Rick Sladkey <jrs@world.std.com> | 
| Wichert Akkerman | 4dc8a2a | 1999-12-23 14:20:14 +0000 | [diff] [blame] | 5 |  * Copyright (c) 1996-1999 Wichert Akkerman <wichert@cistron.nl> | 
| Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 6 |  * All rights reserved. | 
 | 7 |  * | 
 | 8 |  * Redistribution and use in source and binary forms, with or without | 
 | 9 |  * modification, are permitted provided that the following conditions | 
 | 10 |  * are met: | 
 | 11 |  * 1. Redistributions of source code must retain the above copyright | 
 | 12 |  *    notice, this list of conditions and the following disclaimer. | 
 | 13 |  * 2. Redistributions in binary form must reproduce the above copyright | 
 | 14 |  *    notice, this list of conditions and the following disclaimer in the | 
 | 15 |  *    documentation and/or other materials provided with the distribution. | 
 | 16 |  * 3. The name of the author may not be used to endorse or promote products | 
 | 17 |  *    derived from this software without specific prior written permission. | 
 | 18 |  * | 
 | 19 |  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR | 
 | 20 |  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | 
 | 21 |  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. | 
 | 22 |  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, | 
 | 23 |  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | 
 | 24 |  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 
 | 25 |  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 
 | 26 |  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 
 | 27 |  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | 
 | 28 |  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 
 | 29 |  * | 
 | 30 |  *	$Id$ | 
 | 31 |  */ | 
 | 32 |  | 
 | 33 | #include "defs.h" | 
 | 34 |  | 
 | 35 | #include <dirent.h> | 
| Wichert Akkerman | 9524bb9 | 1999-05-25 23:11:18 +0000 | [diff] [blame] | 36 | #ifdef linux | 
 | 37 | #define dirent kernel_dirent | 
 | 38 | #include <linux/types.h> | 
 | 39 | #include <linux/dirent.h> | 
 | 40 | #undef dirent | 
 | 41 | #else | 
 | 42 | #define kernel_dirent dirent | 
 | 43 | #endif | 
| Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 44 |  | 
| Wichert Akkerman | 8bc6cfd | 1999-04-21 15:57:38 +0000 | [diff] [blame] | 45 | #ifdef linux | 
| Wichert Akkerman | dacfb6e | 1999-06-03 14:21:07 +0000 | [diff] [blame] | 46 | #  ifdef LINUXSPARC | 
 | 47 | struct stat { | 
 | 48 | 	unsigned short	st_dev; | 
 | 49 | 	unsigned int	st_ino; | 
 | 50 | 	unsigned short	st_mode; | 
 | 51 | 	short		st_nlink; | 
 | 52 | 	unsigned short	st_uid; | 
 | 53 | 	unsigned short	st_gid; | 
 | 54 | 	unsigned short	st_rdev; | 
 | 55 | 	unsigned int	st_size; | 
 | 56 | 	int		st_atime; | 
 | 57 | 	unsigned int	__unused1; | 
 | 58 | 	int		st_mtime; | 
 | 59 | 	unsigned int	__unused2; | 
 | 60 | 	int		st_ctime; | 
 | 61 | 	unsigned int	__unused3; | 
 | 62 | 	int		st_blksize; | 
 | 63 | 	int		st_blocks; | 
 | 64 | 	unsigned int	__unused4[2]; | 
 | 65 | }; | 
 | 66 | #    define stat kernel_stat | 
 | 67 | #    include <asm/stat.h> | 
 | 68 | #    undef stat | 
 | 69 | #  else | 
| Wichert Akkerman | 5b4d128 | 1999-07-09 00:32:54 +0000 | [diff] [blame] | 70 | #    undef dev_t | 
 | 71 | #    undef ino_t | 
 | 72 | #    undef mode_t | 
 | 73 | #    undef nlink_t | 
 | 74 | #    undef uid_t | 
 | 75 | #    undef gid_t | 
 | 76 | #    undef off_t | 
 | 77 | #    undef loff_t | 
 | 78 |  | 
| Wichert Akkerman | a601370 | 1999-07-08 14:00:58 +0000 | [diff] [blame] | 79 | #    define dev_t __kernel_dev_t | 
 | 80 | #    define ino_t __kernel_ino_t | 
 | 81 | #    define mode_t __kernel_mode_t | 
 | 82 | #    define nlink_t __kernel_nlink_t | 
 | 83 | #    define uid_t __kernel_uid_t | 
 | 84 | #    define gid_t __kernel_gid_t | 
 | 85 | #    define off_t __kernel_off_t | 
 | 86 | #    define loff_t __kernel_loff_t | 
 | 87 |  | 
| Wichert Akkerman | dacfb6e | 1999-06-03 14:21:07 +0000 | [diff] [blame] | 88 | #    include <asm/stat.h> | 
| Wichert Akkerman | a601370 | 1999-07-08 14:00:58 +0000 | [diff] [blame] | 89 |  | 
 | 90 | #    undef dev_t | 
 | 91 | #    undef ino_t | 
 | 92 | #    undef mode_t | 
 | 93 | #    undef nlink_t | 
 | 94 | #    undef uid_t | 
 | 95 | #    undef gid_t | 
 | 96 | #    undef off_t | 
 | 97 | #    undef loff_t | 
| Wichert Akkerman | 5b4d128 | 1999-07-09 00:32:54 +0000 | [diff] [blame] | 98 |  | 
 | 99 | #    define dev_t dev_t | 
 | 100 | #    define ino_t ino_t | 
 | 101 | #    define mode_t mode_t | 
 | 102 | #    define nlink_t nlink_t | 
 | 103 | #    define uid_t uid_t | 
 | 104 | #    define gid_t gid_t | 
 | 105 | #    define off_t off_t | 
 | 106 | #    define loff_t loff_t | 
| Wichert Akkerman | dacfb6e | 1999-06-03 14:21:07 +0000 | [diff] [blame] | 107 | #  endif | 
| Wichert Akkerman | d4d8e92 | 1999-04-18 23:30:29 +0000 | [diff] [blame] | 108 | #  define stat libc_stat | 
| Ulrich Drepper | 0fa01d7 | 1999-12-24 07:18:28 +0000 | [diff] [blame^] | 109 | #  define stat64 libc_stat64 | 
| Wichert Akkerman | d4d8e92 | 1999-04-18 23:30:29 +0000 | [diff] [blame] | 110 | #  include <sys/stat.h> | 
 | 111 | #  undef stat | 
| Ulrich Drepper | 0fa01d7 | 1999-12-24 07:18:28 +0000 | [diff] [blame^] | 112 | #  undef stat64 | 
| Wichert Akkerman | d4d8e92 | 1999-04-18 23:30:29 +0000 | [diff] [blame] | 113 | #else | 
 | 114 | #  include <sys/stat.h> | 
| Wichert Akkerman | 328c5e7 | 1999-04-16 00:21:26 +0000 | [diff] [blame] | 115 | #endif | 
| Wichert Akkerman | d4d8e92 | 1999-04-18 23:30:29 +0000 | [diff] [blame] | 116 |  | 
| Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 117 | #include <fcntl.h> | 
 | 118 |  | 
 | 119 | #ifdef SVR4 | 
 | 120 | #  include <sys/cred.h> | 
 | 121 | #endif /* SVR4 */ | 
 | 122 |  | 
 | 123 | #include <sys/vfs.h> | 
 | 124 |  | 
 | 125 | #ifdef MAJOR_IN_SYSMACROS | 
 | 126 | #include <sys/sysmacros.h> | 
 | 127 | #endif | 
 | 128 |  | 
 | 129 | #ifdef MAJOR_IN_MKDEV | 
 | 130 | #include <sys/mkdev.h> | 
 | 131 | #endif | 
 | 132 |  | 
 | 133 | #ifdef HAVE_SYS_ASYNCH_H | 
 | 134 | #include <sys/asynch.h> | 
 | 135 | #endif | 
 | 136 |  | 
 | 137 | #ifdef SUNOS4 | 
 | 138 | #include <ustat.h> | 
 | 139 | #endif | 
 | 140 |  | 
 | 141 | /* | 
 | 142 |  * This is a really dirty trick but it should always work.  Traditional | 
 | 143 |  * Unix says r/w/rw are 0/1/2, so we make them true flags 1/2/3 by | 
 | 144 |  * adding 1.  Just remember to add 1 to any arg decoded with openmodes. | 
 | 145 |  */ | 
 | 146 | struct xlat openmodes[] = { | 
 | 147 | 	{ O_RDWR+1,	"O_RDWR"	}, | 
 | 148 | 	{ O_RDONLY+1,	"O_RDONLY"	}, | 
 | 149 | 	{ O_WRONLY+1,	"O_WRONLY"	}, | 
 | 150 | 	{ O_NONBLOCK,	"O_NONBLOCK"	}, | 
 | 151 | 	{ O_APPEND,	"O_APPEND"	}, | 
 | 152 | 	{ O_CREAT,	"O_CREAT"	}, | 
 | 153 | 	{ O_TRUNC,	"O_TRUNC"	}, | 
 | 154 | 	{ O_EXCL,	"O_EXCL"	}, | 
 | 155 | 	{ O_NOCTTY,	"O_NOCTTY"	}, | 
 | 156 | #ifdef O_SYNC | 
 | 157 | 	{ O_SYNC,	"O_SYNC"	}, | 
 | 158 | #endif | 
 | 159 | #ifdef O_ASYNC | 
 | 160 | 	{ O_ASYNC,	"O_ASYNC"	}, | 
 | 161 | #endif | 
 | 162 | #ifdef O_DSYNC | 
 | 163 | 	{ O_DSYNC,	"O_DSYNC"	}, | 
 | 164 | #endif | 
 | 165 | #ifdef O_RSYNC | 
 | 166 | 	{ O_RSYNC,	"O_RSYNC"	}, | 
 | 167 | #endif | 
 | 168 | #ifdef O_NDELAY | 
 | 169 | 	{ O_NDELAY,	"O_NDELAY"	}, | 
 | 170 | #endif | 
 | 171 | #ifdef O_PRIV | 
 | 172 | 	{ O_PRIV,	"O_PRIV"	}, | 
 | 173 | #endif | 
 | 174 | #ifdef O_DIRECT | 
 | 175 |    { O_DIRECT, "O_DIRECT"  }, | 
 | 176 | #endif | 
 | 177 | #ifdef O_LARGEFILE | 
 | 178 |    { O_LARGEFILE,  "O_LARGEFILE"   }, | 
 | 179 | #endif | 
 | 180 | #ifdef O_DIRECTORY | 
 | 181 |    { O_DIRECTORY,  "O_DIRECTORY"   }, | 
 | 182 | #endif | 
 | 183 |  | 
 | 184 | #ifdef FNDELAY | 
 | 185 | 	{ FNDELAY,	"FNDELAY"	}, | 
 | 186 | #endif | 
 | 187 | #ifdef FAPPEND | 
 | 188 | 	{ FAPPEND,	"FAPPEND"	}, | 
 | 189 | #endif | 
 | 190 | #ifdef FMARK | 
 | 191 | 	{ FMARK,	"FMARK"		}, | 
 | 192 | #endif | 
 | 193 | #ifdef FDEFER | 
 | 194 | 	{ FDEFER,	"FDEFER"	}, | 
 | 195 | #endif | 
 | 196 | #ifdef FASYNC | 
 | 197 | 	{ FASYNC,	"FASYNC"	}, | 
 | 198 | #endif | 
 | 199 | #ifdef FSHLOCK | 
 | 200 | 	{ FSHLOCK,	"FSHLOCK"	}, | 
 | 201 | #endif | 
 | 202 | #ifdef FEXLOCK | 
 | 203 | 	{ FEXLOCK,	"FEXLOCK"	}, | 
 | 204 | #endif | 
 | 205 | #ifdef FCREAT | 
 | 206 | 	{ FCREAT,	"FCREAT"	}, | 
 | 207 | #endif | 
 | 208 | #ifdef FTRUNC | 
 | 209 | 	{ FTRUNC,	"FTRUNC"	}, | 
 | 210 | #endif | 
 | 211 | #ifdef FEXCL | 
 | 212 | 	{ FEXCL,	"FEXCL"		}, | 
 | 213 | #endif | 
 | 214 | #ifdef FNBIO | 
 | 215 | 	{ FNBIO,	"FNBIO"		}, | 
 | 216 | #endif | 
 | 217 | #ifdef FSYNC | 
 | 218 | 	{ FSYNC,	"FSYNC"		}, | 
 | 219 | #endif | 
 | 220 | #ifdef FNOCTTY | 
 | 221 | 	{ FNOCTTY,	"FNOCTTY"	}, | 
 | 222 | #endif | 
 | 223 | 	{ 0,		NULL		}, | 
 | 224 | }; | 
 | 225 |  | 
 | 226 | int | 
 | 227 | sys_open(tcp) | 
 | 228 | struct tcb *tcp; | 
 | 229 | { | 
 | 230 | 	if (entering(tcp)) { | 
 | 231 | 		printpath(tcp, tcp->u_arg[0]); | 
 | 232 | 		tprintf(", "); | 
 | 233 | 		/* flags */ | 
 | 234 | 		printflags(openmodes, tcp->u_arg[1] + 1); | 
 | 235 | 		if (tcp->u_arg[1] & O_CREAT) { | 
 | 236 | 			/* mode */ | 
 | 237 | 			tprintf(", %#lo", tcp->u_arg[2]); | 
 | 238 | 		} | 
 | 239 | 	} | 
 | 240 | 	return 0; | 
 | 241 | } | 
 | 242 |  | 
 | 243 | #ifdef LINUXSPARC | 
 | 244 | struct xlat openmodessol[] = { | 
 | 245 | 	{ 0,		"O_RDWR"	}, | 
 | 246 | 	{ 1,		"O_RDONLY"	}, | 
 | 247 | 	{ 2,		"O_WRONLY"	}, | 
 | 248 | 	{ 0x80,		"O_NONBLOCK"	}, | 
 | 249 | 	{ 8,		"O_APPEND"	}, | 
 | 250 | 	{ 0x100,	"O_CREAT"	}, | 
 | 251 | 	{ 0x200,	"O_TRUNC"	}, | 
 | 252 | 	{ 0x400,	"O_EXCL"	}, | 
 | 253 | 	{ 0x800,	"O_NOCTTY"	}, | 
 | 254 | 	{ 0x10,		"O_SYNC"	}, | 
 | 255 | 	{ 0x40,		"O_DSYNC"	}, | 
 | 256 | 	{ 0x8000,	"O_RSYNC"	}, | 
 | 257 | 	{ 4,		"O_NDELAY"	}, | 
 | 258 | 	{ 0x1000,	"O_PRIV"	}, | 
 | 259 | 	{ 0,		NULL		}, | 
 | 260 | }; | 
 | 261 |  | 
 | 262 | int | 
 | 263 | solaris_open(tcp) | 
 | 264 | struct tcb *tcp; | 
 | 265 | { | 
 | 266 | 	if (entering(tcp)) { | 
 | 267 | 		printpath(tcp, tcp->u_arg[0]); | 
 | 268 | 		tprintf(", "); | 
 | 269 | 		/* flags */ | 
 | 270 | 		printflags(openmodessol, tcp->u_arg[1] + 1); | 
 | 271 | 		if (tcp->u_arg[1] & 0x100) { | 
 | 272 | 			/* mode */ | 
 | 273 | 			tprintf(", %#lo", tcp->u_arg[2]); | 
 | 274 | 		} | 
 | 275 | 	} | 
 | 276 | 	return 0; | 
 | 277 | } | 
 | 278 |  | 
 | 279 | #endif | 
 | 280 |  | 
 | 281 | int | 
 | 282 | sys_creat(tcp) | 
 | 283 | struct tcb *tcp; | 
 | 284 | { | 
 | 285 | 	if (entering(tcp)) { | 
 | 286 | 		printpath(tcp, tcp->u_arg[0]); | 
 | 287 | 		tprintf(", %#lo", tcp->u_arg[1]); | 
 | 288 | 	} | 
 | 289 | 	return 0; | 
 | 290 | } | 
 | 291 |  | 
 | 292 | static struct xlat access_flags[] = { | 
 | 293 | 	{ F_OK,		"F_OK",		}, | 
 | 294 | 	{ R_OK,		"R_OK"		}, | 
 | 295 | 	{ W_OK,		"W_OK"		}, | 
 | 296 | 	{ X_OK,		"X_OK"		}, | 
 | 297 | #ifdef EFF_ONLY_OK | 
 | 298 | 	{ EFF_ONLY_OK,	"EFF_ONLY_OK"	}, | 
 | 299 | #endif | 
 | 300 | #ifdef EX_OK | 
 | 301 | 	{ EX_OK,	"EX_OK"		}, | 
 | 302 | #endif | 
 | 303 | 	{ 0,		NULL		}, | 
 | 304 | }; | 
 | 305 |  | 
 | 306 | int | 
 | 307 | sys_access(tcp) | 
 | 308 | struct tcb *tcp; | 
 | 309 | { | 
 | 310 | 	if (entering(tcp)) { | 
 | 311 | 		printpath(tcp, tcp->u_arg[0]); | 
 | 312 | 		tprintf(", "); | 
 | 313 | 		printflags(access_flags, tcp->u_arg[1]); | 
 | 314 | 	} | 
 | 315 | 	return 0; | 
 | 316 | } | 
 | 317 |  | 
 | 318 | int | 
 | 319 | sys_umask(tcp) | 
 | 320 | struct tcb *tcp; | 
 | 321 | { | 
 | 322 | 	if (entering(tcp)) { | 
 | 323 | 		tprintf("%#lo", tcp->u_arg[0]); | 
 | 324 | 	} | 
 | 325 | 	return RVAL_OCTAL; | 
 | 326 | } | 
 | 327 |  | 
 | 328 | static struct xlat whence[] = { | 
 | 329 | 	{ SEEK_SET,	"SEEK_SET"	}, | 
 | 330 | 	{ SEEK_CUR,	"SEEK_CUR"	}, | 
 | 331 | 	{ SEEK_END,	"SEEK_END"	}, | 
 | 332 | 	{ 0,		NULL		}, | 
 | 333 | }; | 
 | 334 |  | 
 | 335 | int | 
 | 336 | sys_lseek(tcp) | 
 | 337 | struct tcb *tcp; | 
 | 338 | { | 
 | 339 | 	if (entering(tcp)) { | 
 | 340 | 		tprintf("%ld, ", tcp->u_arg[0]); | 
 | 341 | 		if (tcp->u_arg[2] == SEEK_SET) | 
 | 342 | 			tprintf("%lu, ", tcp->u_arg[1]); | 
 | 343 | 		else | 
 | 344 | 			tprintf("%ld, ", tcp->u_arg[1]); | 
 | 345 | 		printxval(whence, tcp->u_arg[2], "SEEK_???"); | 
 | 346 | 	} | 
 | 347 | 	return RVAL_UDECIMAL; | 
 | 348 | } | 
 | 349 |  | 
| Wichert Akkerman | 328c5e7 | 1999-04-16 00:21:26 +0000 | [diff] [blame] | 350 | #ifdef linux | 
| Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 351 | int | 
 | 352 | sys_llseek (tcp) | 
 | 353 | struct tcb *tcp; | 
 | 354 | { | 
 | 355 |     if (entering(tcp)) { | 
 | 356 | 	if (tcp->u_arg[4] == SEEK_SET) | 
 | 357 | 	    tprintf("%ld, %llu, ", tcp->u_arg[0], | 
| Wichert Akkerman | 2e2553a | 1999-05-09 00:29:58 +0000 | [diff] [blame] | 358 | 		    (((long long int) tcp->u_arg[1]) << 32 | 
 | 359 | 		     | (unsigned long long) tcp->u_arg[2])); | 
| Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 360 | 	else | 
 | 361 | 	    tprintf("%ld, %lld, ", tcp->u_arg[0], | 
 | 362 | 		    (((long long int) tcp->u_arg[1]) << 32 | 
| Wichert Akkerman | 2e2553a | 1999-05-09 00:29:58 +0000 | [diff] [blame] | 363 | 		     | (unsigned long long) tcp->u_arg[2])); | 
| Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 364 |     } | 
 | 365 |     else { | 
| Wichert Akkerman | 2e2553a | 1999-05-09 00:29:58 +0000 | [diff] [blame] | 366 | 	long long int off; | 
 | 367 | 	if (syserror(tcp) || umove(tcp, tcp->u_arg[3], &off) < 0) | 
| Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 368 | 	    tprintf("%#lx, ", tcp->u_arg[3]); | 
| Wichert Akkerman | 2e2553a | 1999-05-09 00:29:58 +0000 | [diff] [blame] | 369 | 	else | 
 | 370 | 	    tprintf("[%llu], ", off); | 
| Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 371 | 	printxval(whence, tcp->u_arg[4], "SEEK_???"); | 
 | 372 |     } | 
 | 373 |     return 0; | 
 | 374 | } | 
 | 375 | #endif | 
 | 376 |  | 
 | 377 | int | 
 | 378 | sys_truncate(tcp) | 
 | 379 | struct tcb *tcp; | 
 | 380 | { | 
 | 381 | 	if (entering(tcp)) { | 
 | 382 | 		printpath(tcp, tcp->u_arg[0]); | 
 | 383 | 		tprintf(", %lu", tcp->u_arg[1]); | 
 | 384 | 	} | 
 | 385 | 	return 0; | 
 | 386 | } | 
 | 387 |  | 
 | 388 | int | 
 | 389 | sys_ftruncate(tcp) | 
 | 390 | struct tcb *tcp; | 
 | 391 | { | 
 | 392 | 	if (entering(tcp)) { | 
 | 393 | 		tprintf("%ld, %lu", tcp->u_arg[0], tcp->u_arg[1]); | 
 | 394 | 	} | 
 | 395 | 	return 0; | 
 | 396 | } | 
 | 397 |  | 
 | 398 | /* several stats */ | 
 | 399 |  | 
 | 400 | static struct xlat modetypes[] = { | 
 | 401 | 	{ S_IFREG,	"S_IFREG"	}, | 
 | 402 | 	{ S_IFSOCK,	"S_IFSOCK"	}, | 
 | 403 | 	{ S_IFIFO,	"S_IFIFO"	}, | 
 | 404 | 	{ S_IFLNK,	"S_IFLNK"	}, | 
 | 405 | 	{ S_IFDIR,	"S_IFDIR"	}, | 
 | 406 | 	{ S_IFBLK,	"S_IFBLK"	}, | 
 | 407 | 	{ S_IFCHR,	"S_IFCHR"	}, | 
 | 408 | 	{ 0,		NULL		}, | 
 | 409 | }; | 
 | 410 |  | 
 | 411 | static char * | 
 | 412 | sprintmode(mode) | 
 | 413 | int mode; | 
 | 414 | { | 
 | 415 | 	static char buf[64]; | 
 | 416 | 	char *s; | 
 | 417 |  | 
 | 418 | 	if ((mode & S_IFMT) == 0) | 
 | 419 | 		s = ""; | 
 | 420 | 	else if ((s = xlookup(modetypes, mode & S_IFMT)) == NULL) { | 
 | 421 | 		sprintf(buf, "%#o", mode); | 
 | 422 | 		return buf; | 
 | 423 | 	} | 
 | 424 | 	sprintf(buf, "%s%s%s%s", s, | 
 | 425 | 		(mode & S_ISUID) ? "|S_ISUID" : "", | 
 | 426 | 		(mode & S_ISGID) ? "|S_ISGID" : "", | 
 | 427 | 		(mode & S_ISVTX) ? "|S_ISVTX" : ""); | 
 | 428 | 	mode &= ~(S_IFMT|S_ISUID|S_ISGID|S_ISVTX); | 
 | 429 | 	if (mode) | 
 | 430 | 		sprintf(buf + strlen(buf), "|%#o", mode); | 
 | 431 | 	s = (*buf == '|') ? buf + 1 : buf; | 
 | 432 | 	return *s ? s : "0"; | 
 | 433 | } | 
 | 434 |  | 
 | 435 | static char * | 
 | 436 | sprinttime(t) | 
 | 437 | time_t t; | 
 | 438 | { | 
 | 439 | 	struct tm *tmp; | 
 | 440 | 	static char buf[32]; | 
 | 441 |  | 
 | 442 | 	if (t == 0) { | 
 | 443 | 		sprintf(buf, "0"); | 
 | 444 | 		return buf; | 
 | 445 | 	} | 
 | 446 | 	tmp = localtime(&t); | 
 | 447 | 	sprintf(buf, "%02d/%02d/%02d-%02d:%02d:%02d", | 
 | 448 | 		tmp->tm_year, tmp->tm_mon + 1, tmp->tm_mday, | 
 | 449 | 		tmp->tm_hour, tmp->tm_min, tmp->tm_sec); | 
 | 450 | 	return buf; | 
 | 451 | } | 
 | 452 |  | 
 | 453 | #ifdef LINUXSPARC | 
 | 454 | typedef struct { | 
 | 455 |         int     tv_sec; | 
 | 456 |         int     tv_nsec; | 
 | 457 | } timestruct_t; | 
 | 458 |  | 
 | 459 | struct solstat { | 
 | 460 |         unsigned        st_dev; | 
 | 461 |         int             st_pad1[3];     /* network id */ | 
 | 462 |         unsigned        st_ino; | 
 | 463 |         unsigned        st_mode; | 
 | 464 |         unsigned        st_nlink; | 
 | 465 |         unsigned        st_uid; | 
 | 466 |         unsigned        st_gid; | 
 | 467 |         unsigned        st_rdev; | 
 | 468 |         int             st_pad2[2]; | 
 | 469 |         int             st_size; | 
 | 470 |         int             st_pad3;        /* st_size, off_t expansion */ | 
 | 471 |         timestruct_t    st_atime; | 
 | 472 |         timestruct_t    st_mtime; | 
 | 473 |         timestruct_t    st_ctime; | 
 | 474 |         int             st_blksize; | 
 | 475 |         int             st_blocks; | 
 | 476 |         char            st_fstype[16]; | 
 | 477 |         int             st_pad4[8];     /* expansion area */ | 
 | 478 | }; | 
 | 479 |  | 
 | 480 | static void | 
 | 481 | printstatsol(tcp, addr) | 
 | 482 | struct tcb *tcp; | 
 | 483 | int addr; | 
 | 484 | { | 
 | 485 | 	struct solstat statbuf; | 
 | 486 |  | 
 | 487 | 	if (!addr) { | 
 | 488 | 		tprintf("NULL"); | 
 | 489 | 		return; | 
 | 490 | 	} | 
 | 491 | 	if (syserror(tcp) || !verbose(tcp)) { | 
 | 492 | 		tprintf("%#x", addr); | 
 | 493 | 		return; | 
 | 494 | 	} | 
 | 495 | 	if (umove(tcp, addr, &statbuf) < 0) { | 
 | 496 | 		tprintf("{...}"); | 
 | 497 | 		return; | 
 | 498 | 	} | 
 | 499 | 	if (!abbrev(tcp)) { | 
 | 500 | 		tprintf("{st_dev=makedev(%lu, %lu), st_ino=%lu, st_mode=%s, ", | 
 | 501 | 			(unsigned long) ((statbuf.st_dev >> 18) & 0x3fff), | 
 | 502 | 			(unsigned long) (statbuf.st_dev & 0x3ffff), | 
 | 503 | 			(unsigned long) statbuf.st_ino, | 
 | 504 | 			sprintmode(statbuf.st_mode)); | 
 | 505 | 		tprintf("st_nlink=%lu, st_uid=%lu, st_gid=%lu, ", | 
 | 506 | 			(unsigned long) statbuf.st_nlink, | 
 | 507 | 			(unsigned long) statbuf.st_uid, | 
 | 508 | 			(unsigned long) statbuf.st_gid); | 
 | 509 | 		tprintf("st_blksize=%lu, ", (unsigned long) statbuf.st_blksize); | 
 | 510 | 		tprintf("st_blocks=%lu, ", (unsigned long) statbuf.st_blocks); | 
 | 511 | 	} | 
 | 512 | 	else | 
 | 513 | 		tprintf("{st_mode=%s, ", sprintmode(statbuf.st_mode)); | 
 | 514 | 	switch (statbuf.st_mode & S_IFMT) { | 
 | 515 | 	case S_IFCHR: case S_IFBLK: | 
 | 516 | 		tprintf("st_rdev=makedev(%lu, %lu), ", | 
 | 517 | 			(unsigned long) ((statbuf.st_rdev >> 18) & 0x3fff), | 
 | 518 | 			(unsigned long) (statbuf.st_rdev & 0x3ffff)); | 
 | 519 | 		break; | 
 | 520 | 	default: | 
 | 521 | 		tprintf("st_size=%u, ", statbuf.st_size); | 
 | 522 | 		break; | 
 | 523 | 	} | 
 | 524 | 	if (!abbrev(tcp)) { | 
 | 525 | 		tprintf("st_atime=%s, ", sprinttime(statbuf.st_atime)); | 
 | 526 | 		tprintf("st_mtime=%s, ", sprinttime(statbuf.st_mtime)); | 
 | 527 | 		tprintf("st_ctime=%s}", sprinttime(statbuf.st_ctime)); | 
 | 528 | 	} | 
 | 529 | 	else | 
 | 530 | 		tprintf("...}"); | 
 | 531 | } | 
| Wichert Akkerman | b859bea | 1999-04-18 22:50:50 +0000 | [diff] [blame] | 532 | #endif /* LINUXSPARC */ | 
| Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 533 |  | 
| Wichert Akkerman | 328c5e7 | 1999-04-16 00:21:26 +0000 | [diff] [blame] | 534 | static void | 
 | 535 | realprintstat(tcp, statbuf) | 
 | 536 | struct tcb *tcp; | 
| Wichert Akkerman | 328c5e7 | 1999-04-16 00:21:26 +0000 | [diff] [blame] | 537 | struct stat *statbuf; | 
| Wichert Akkerman | 328c5e7 | 1999-04-16 00:21:26 +0000 | [diff] [blame] | 538 | { | 
 | 539 |     if (!abbrev(tcp)) { | 
 | 540 | 	    tprintf("{st_dev=makedev(%lu, %lu), st_ino=%lu, st_mode=%s, ", | 
 | 541 | 		    (unsigned long) major(statbuf->st_dev), | 
 | 542 | 		    (unsigned long) minor(statbuf->st_dev), | 
 | 543 | 		    (unsigned long) statbuf->st_ino, | 
 | 544 | 		    sprintmode(statbuf->st_mode)); | 
 | 545 | 	    tprintf("st_nlink=%lu, st_uid=%lu, st_gid=%lu, ", | 
 | 546 | 		    (unsigned long) statbuf->st_nlink, | 
 | 547 | 		    (unsigned long) statbuf->st_uid, | 
 | 548 | 		    (unsigned long) statbuf->st_gid); | 
 | 549 | #ifdef HAVE_ST_BLKSIZE | 
 | 550 | 	    tprintf("st_blksize=%lu, ", (unsigned long) statbuf->st_blksize); | 
 | 551 | #endif /* HAVE_ST_BLKSIZE */ | 
 | 552 | #ifdef HAVE_ST_BLOCKS | 
 | 553 | 	    tprintf("st_blocks=%lu, ", (unsigned long) statbuf->st_blocks); | 
 | 554 | #endif /* HAVE_ST_BLOCKS */ | 
 | 555 |     } | 
 | 556 |     else | 
 | 557 | 	    tprintf("{st_mode=%s, ", sprintmode(statbuf->st_mode)); | 
 | 558 |     switch (statbuf->st_mode & S_IFMT) { | 
 | 559 |     case S_IFCHR: case S_IFBLK: | 
 | 560 | #ifdef HAVE_ST_RDEV | 
 | 561 | 	    tprintf("st_rdev=makedev(%lu, %lu), ", | 
 | 562 | 		    (unsigned long) major(statbuf->st_rdev), | 
 | 563 | 		    (unsigned long) minor(statbuf->st_rdev)); | 
 | 564 | #else /* !HAVE_ST_RDEV */ | 
 | 565 | 	    tprintf("st_size=makedev(%lu, %lu), ", | 
 | 566 | 		    (unsigned long) major(statbuf->st_size), | 
 | 567 | 		    (unsigned long) minor(statbuf->st_size)); | 
 | 568 | #endif /* !HAVE_ST_RDEV */ | 
 | 569 | 	    break; | 
 | 570 |     default: | 
 | 571 | 	    tprintf("st_size=%lu, ", statbuf->st_size); | 
 | 572 | 	    break; | 
 | 573 |     } | 
 | 574 |     if (!abbrev(tcp)) { | 
 | 575 | 	    tprintf("st_atime=%s, ", sprinttime(statbuf->st_atime)); | 
 | 576 | 	    tprintf("st_mtime=%s, ", sprinttime(statbuf->st_mtime)); | 
 | 577 | 	    tprintf("st_ctime=%s}", sprinttime(statbuf->st_ctime)); | 
 | 578 |     } | 
 | 579 |     else | 
 | 580 | 	    tprintf("...}"); | 
 | 581 | } | 
 | 582 |  | 
| Nate Sammons | 771a6ff | 1999-04-05 22:39:31 +0000 | [diff] [blame] | 583 |  | 
| Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 584 | static void | 
 | 585 | printstat(tcp, addr) | 
 | 586 | struct tcb *tcp; | 
 | 587 | int addr; | 
 | 588 | { | 
| Wichert Akkerman | 328c5e7 | 1999-04-16 00:21:26 +0000 | [diff] [blame] | 589 | 	struct stat statbuf; | 
| Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 590 |  | 
 | 591 | #ifdef LINUXSPARC | 
 | 592 |  	if (current_personality == 1) { | 
 | 593 |  		printstatsol(tcp, addr); | 
 | 594 |  		return; | 
 | 595 |  	} | 
 | 596 | #endif /* LINUXSPARC */ | 
 | 597 |  | 
 | 598 | 	if (!addr) { | 
 | 599 | 		tprintf("NULL"); | 
 | 600 | 		return; | 
 | 601 | 	} | 
 | 602 | 	if (syserror(tcp) || !verbose(tcp)) { | 
 | 603 | 		tprintf("%#x", addr); | 
 | 604 | 		return; | 
 | 605 | 	} | 
 | 606 | 	if (umove(tcp, addr, &statbuf) < 0) { | 
 | 607 | 		tprintf("{...}"); | 
 | 608 | 		return; | 
 | 609 | 	} | 
| Wichert Akkerman | 328c5e7 | 1999-04-16 00:21:26 +0000 | [diff] [blame] | 610 |  | 
 | 611 | 	realprintstat(tcp, &statbuf); | 
| Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 612 | } | 
 | 613 |  | 
| Wichert Akkerman | 328c5e7 | 1999-04-16 00:21:26 +0000 | [diff] [blame] | 614 | #ifdef linux | 
 | 615 | static void | 
 | 616 | convertoldstat(oldbuf, newbuf) | 
| Wichert Akkerman | 25d0c4f | 1999-04-18 19:35:42 +0000 | [diff] [blame] | 617 | const struct __old_kernel_stat *oldbuf; | 
 | 618 | struct stat *newbuf; | 
| Wichert Akkerman | 328c5e7 | 1999-04-16 00:21:26 +0000 | [diff] [blame] | 619 | { | 
 | 620 |     newbuf->st_dev=oldbuf->st_dev; | 
 | 621 |     newbuf->st_ino=oldbuf->st_ino; | 
 | 622 |     newbuf->st_mode=oldbuf->st_mode; | 
 | 623 |     newbuf->st_nlink=oldbuf->st_nlink; | 
 | 624 |     newbuf->st_uid=oldbuf->st_uid; | 
 | 625 |     newbuf->st_gid=oldbuf->st_gid; | 
 | 626 |     newbuf->st_rdev=oldbuf->st_rdev; | 
 | 627 |     newbuf->st_size=oldbuf->st_size; | 
 | 628 |     newbuf->st_atime=oldbuf->st_atime; | 
 | 629 |     newbuf->st_mtime=oldbuf->st_mtime; | 
 | 630 |     newbuf->st_ctime=oldbuf->st_ctime; | 
 | 631 |     newbuf->st_blksize=0;	/* not supported in old_stat */ | 
 | 632 |     newbuf->st_blocks=0;		/* not supported in old_stat */ | 
 | 633 | } | 
 | 634 | #endif | 
 | 635 |  | 
 | 636 |  | 
 | 637 | #ifdef linux | 
 | 638 | static void | 
 | 639 | printoldstat(tcp, addr) | 
 | 640 | struct tcb *tcp; | 
 | 641 | int addr; | 
 | 642 | { | 
| Wichert Akkerman | 25d0c4f | 1999-04-18 19:35:42 +0000 | [diff] [blame] | 643 | 	struct __old_kernel_stat statbuf; | 
 | 644 | 	struct stat newstatbuf; | 
| Wichert Akkerman | 328c5e7 | 1999-04-16 00:21:26 +0000 | [diff] [blame] | 645 |  | 
 | 646 | #ifdef LINUXSPARC | 
 | 647 |  	if (current_personality == 1) { | 
 | 648 |  		printstatsol(tcp, addr); | 
 | 649 |  		return; | 
 | 650 |  	} | 
 | 651 | #endif /* LINUXSPARC */ | 
 | 652 |  | 
 | 653 | 	if (!addr) { | 
 | 654 | 		tprintf("NULL"); | 
 | 655 | 		return; | 
 | 656 | 	} | 
 | 657 | 	if (syserror(tcp) || !verbose(tcp)) { | 
 | 658 | 		tprintf("%#x", addr); | 
 | 659 | 		return; | 
 | 660 | 	} | 
 | 661 | 	if (umove(tcp, addr, &statbuf) < 0) { | 
 | 662 | 		tprintf("{...}"); | 
 | 663 | 		return; | 
 | 664 | 	} | 
 | 665 |  | 
 | 666 | 	convertoldstat(&statbuf, &newstatbuf); | 
 | 667 | 	realprintstat(tcp, &newstatbuf); | 
 | 668 | } | 
 | 669 | #endif | 
 | 670 |  | 
 | 671 |  | 
| Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 672 | int | 
 | 673 | sys_stat(tcp) | 
 | 674 | struct tcb *tcp; | 
 | 675 | { | 
 | 676 | 	if (entering(tcp)) { | 
 | 677 | 		printpath(tcp, tcp->u_arg[0]); | 
 | 678 | 		tprintf(", "); | 
 | 679 | 	} else { | 
 | 680 | 		printstat(tcp, tcp->u_arg[1]); | 
 | 681 | 	} | 
 | 682 | 	return 0; | 
 | 683 | } | 
 | 684 |  | 
| Wichert Akkerman | 328c5e7 | 1999-04-16 00:21:26 +0000 | [diff] [blame] | 685 | #ifdef linux | 
 | 686 | int | 
 | 687 | sys_oldstat(tcp) | 
 | 688 | struct tcb *tcp; | 
 | 689 | { | 
 | 690 | 	if (entering(tcp)) { | 
 | 691 | 		printpath(tcp, tcp->u_arg[0]); | 
 | 692 | 		tprintf(", "); | 
 | 693 | 	} else { | 
 | 694 | 		printoldstat(tcp, tcp->u_arg[1]); | 
 | 695 | 	} | 
 | 696 | 	return 0; | 
 | 697 | } | 
 | 698 | #endif | 
 | 699 |  | 
| Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 700 | int | 
 | 701 | sys_fstat(tcp) | 
 | 702 | struct tcb *tcp; | 
 | 703 | { | 
 | 704 | 	if (entering(tcp)) | 
 | 705 | 		tprintf("%ld, ", tcp->u_arg[0]); | 
 | 706 | 	else { | 
 | 707 | 		printstat(tcp, tcp->u_arg[1]); | 
 | 708 | 	} | 
 | 709 | 	return 0; | 
 | 710 | } | 
 | 711 |  | 
| Wichert Akkerman | 328c5e7 | 1999-04-16 00:21:26 +0000 | [diff] [blame] | 712 | #ifdef linux | 
 | 713 | int | 
 | 714 | sys_oldfstat(tcp) | 
 | 715 | struct tcb *tcp; | 
 | 716 | { | 
 | 717 | 	if (entering(tcp)) | 
 | 718 | 		tprintf("%ld, ", tcp->u_arg[0]); | 
 | 719 | 	else { | 
 | 720 | 		printoldstat(tcp, tcp->u_arg[1]); | 
 | 721 | 	} | 
 | 722 | 	return 0; | 
 | 723 | } | 
 | 724 | #endif | 
 | 725 |  | 
| Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 726 | int | 
 | 727 | sys_lstat(tcp) | 
 | 728 | struct tcb *tcp; | 
 | 729 | { | 
 | 730 | 	if (entering(tcp)) { | 
 | 731 | 		printpath(tcp, tcp->u_arg[0]); | 
 | 732 | 		tprintf(", "); | 
 | 733 | 	} else { | 
 | 734 | 		printstat(tcp, tcp->u_arg[1]); | 
 | 735 | 	} | 
 | 736 | 	return 0; | 
 | 737 | } | 
 | 738 |  | 
| Wichert Akkerman | 328c5e7 | 1999-04-16 00:21:26 +0000 | [diff] [blame] | 739 | #ifdef linux | 
 | 740 | int | 
 | 741 | sys_oldlstat(tcp) | 
 | 742 | struct tcb *tcp; | 
 | 743 | { | 
 | 744 | 	if (entering(tcp)) { | 
 | 745 | 		printpath(tcp, tcp->u_arg[0]); | 
 | 746 | 		tprintf(", "); | 
 | 747 | 	} else { | 
 | 748 | 		printoldstat(tcp, tcp->u_arg[1]); | 
 | 749 | 	} | 
 | 750 | 	return 0; | 
 | 751 | } | 
 | 752 | #endif | 
 | 753 |  | 
 | 754 |  | 
| Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 755 | #if defined(SVR4) || defined(LINUXSPARC) | 
 | 756 |  | 
 | 757 | int | 
 | 758 | sys_xstat(tcp) | 
 | 759 | struct tcb *tcp; | 
 | 760 | { | 
 | 761 | 	if (entering(tcp)) { | 
 | 762 | 		tprintf("%ld, ", tcp->u_arg[0]); | 
 | 763 | 		printpath(tcp, tcp->u_arg[1]); | 
 | 764 | 		tprintf(", "); | 
 | 765 | 	} else { | 
 | 766 | 		printstat(tcp, tcp->u_arg[2]); | 
 | 767 | 	} | 
 | 768 | 	return 0; | 
 | 769 | } | 
 | 770 |  | 
 | 771 | int | 
 | 772 | sys_fxstat(tcp) | 
 | 773 | struct tcb *tcp; | 
 | 774 | { | 
 | 775 | 	if (entering(tcp)) | 
 | 776 | 		tprintf("%ld, %ld, ", tcp->u_arg[0], tcp->u_arg[1]); | 
 | 777 | 	else { | 
 | 778 | 		printstat(tcp, tcp->u_arg[2]); | 
 | 779 | 	} | 
 | 780 | 	return 0; | 
 | 781 | } | 
 | 782 |  | 
 | 783 | int | 
 | 784 | sys_lxstat(tcp) | 
 | 785 | struct tcb *tcp; | 
 | 786 | { | 
 | 787 | 	if (entering(tcp)) { | 
 | 788 | 		tprintf("%ld, ", tcp->u_arg[0]); | 
 | 789 | 		printpath(tcp, tcp->u_arg[1]); | 
 | 790 | 		tprintf(", "); | 
 | 791 | 	} else { | 
 | 792 | 		printstat(tcp, tcp->u_arg[2]); | 
 | 793 | 	} | 
 | 794 | 	return 0; | 
 | 795 | } | 
 | 796 |  | 
 | 797 | int | 
 | 798 | sys_xmknod(tcp) | 
 | 799 | struct tcb *tcp; | 
 | 800 | { | 
 | 801 | 	int mode = tcp->u_arg[2]; | 
 | 802 |  | 
 | 803 | 	if (entering(tcp)) { | 
 | 804 | 		tprintf("%ld, ", tcp->u_arg[0]); | 
 | 805 | 		printpath(tcp, tcp->u_arg[1]); | 
 | 806 | 		tprintf(", %s", sprintmode(mode)); | 
 | 807 | 		switch (mode & S_IFMT) { | 
 | 808 | 		case S_IFCHR: case S_IFBLK: | 
 | 809 | #ifdef LINUXSPARC | 
 | 810 | 			tprintf(", makedev(%lu, %lu)", | 
 | 811 | 				(unsigned long) ((tcp->u_arg[3] >> 18) & 0x3fff), | 
 | 812 | 				(unsigned long) (tcp->u_arg[3] & 0x3ffff)); | 
 | 813 | #else		 | 
 | 814 | 			tprintf(", makedev(%lu, %lu)", | 
 | 815 | 				(unsigned long) major(tcp->u_arg[3]), | 
 | 816 | 				(unsigned long) minor(tcp->u_arg[3])); | 
 | 817 | #endif				 | 
 | 818 | 			break; | 
 | 819 | 		default: | 
 | 820 | 			break; | 
 | 821 | 		} | 
 | 822 | 	} | 
 | 823 | 	return 0; | 
 | 824 | } | 
 | 825 |  | 
| Wichert Akkerman | 8829a55 | 1999-06-11 13:18:40 +0000 | [diff] [blame] | 826 | #ifdef HAVE_SYS_ACL_H | 
 | 827 |  | 
 | 828 | #include <sys/acl.h> | 
 | 829 |  | 
 | 830 | struct xlat aclcmds[] = { | 
| Wichert Akkerman | e4aafd4 | 1999-11-26 09:54:08 +0000 | [diff] [blame] | 831 | #ifdef SETACL | 
| Wichert Akkerman | 8829a55 | 1999-06-11 13:18:40 +0000 | [diff] [blame] | 832 | 	{ SETACL,	"SETACL"	}, | 
| Wichert Akkerman | e4aafd4 | 1999-11-26 09:54:08 +0000 | [diff] [blame] | 833 | #endif | 
 | 834 | #ifdef GETACL | 
| Wichert Akkerman | 8829a55 | 1999-06-11 13:18:40 +0000 | [diff] [blame] | 835 | 	{ GETACL,	"GETACL"	}, | 
| Wichert Akkerman | e4aafd4 | 1999-11-26 09:54:08 +0000 | [diff] [blame] | 836 | #endif | 
 | 837 | #ifdef GETACLCNT | 
| Wichert Akkerman | 8829a55 | 1999-06-11 13:18:40 +0000 | [diff] [blame] | 838 | 	{ GETACLCNT,	"GETACLCNT"	}, | 
| Wichert Akkerman | e4aafd4 | 1999-11-26 09:54:08 +0000 | [diff] [blame] | 839 | #endif | 
 | 840 | #ifdef ACL_GET | 
 | 841 | 	{ ACL_GET,	"ACL_GET"	}, | 
 | 842 | #endif	 | 
 | 843 | #ifdef ACL_SET | 
 | 844 | 	{ ACL_SET,	"ACL_SET"	}, | 
 | 845 | #endif	 | 
 | 846 | #ifdef ACL_CNT | 
 | 847 | 	{ ACL_CNT,	"ACL_CNT"	}, | 
 | 848 | #endif	 | 
| Wichert Akkerman | 8829a55 | 1999-06-11 13:18:40 +0000 | [diff] [blame] | 849 | 	{ 0,		NULL		}, | 
 | 850 | }; | 
 | 851 |  | 
 | 852 | int | 
 | 853 | sys_acl(tcp) | 
 | 854 | struct tcb *tcp; | 
 | 855 | { | 
 | 856 | 	if (entering(tcp)) { | 
 | 857 | 		printpath(tcp, tcp->u_arg[0]); | 
 | 858 | 		tprintf(", "); | 
 | 859 | 		printxval(aclcmds, tcp->u_arg[1], "???ACL???"); | 
 | 860 | 		tprintf(", %ld", tcp->u_arg[2]); | 
 | 861 | 		/* | 
 | 862 | 		 * FIXME - dump out the list of aclent_t's pointed to | 
 | 863 | 		 * by "tcp->u_arg[3]" if it's not NULL. | 
 | 864 | 		 */ | 
 | 865 | 		if (tcp->u_arg[3]) | 
 | 866 | 			tprintf(", %#lx", tcp->u_arg[3]); | 
 | 867 | 		else | 
 | 868 | 			tprintf(", NULL"); | 
 | 869 | 	} | 
 | 870 | 	return 0; | 
 | 871 | } | 
 | 872 |  | 
 | 873 |  | 
 | 874 | int | 
 | 875 | sys_facl(tcp) | 
 | 876 | struct tcb *tcp; | 
 | 877 | { | 
 | 878 | 	if (entering(tcp)) { | 
 | 879 | 		tprintf("%ld, ", tcp->u_arg[0]); | 
 | 880 | 		printxval(aclcmds, tcp->u_arg[1], "???ACL???"); | 
 | 881 | 		tprintf(", %ld", tcp->u_arg[2]); | 
 | 882 | 		/* | 
 | 883 | 		 * FIXME - dump out the list of aclent_t's pointed to | 
 | 884 | 		 * by "tcp->u_arg[3]" if it's not NULL. | 
 | 885 | 		 */ | 
 | 886 | 		if (tcp->u_arg[3]) | 
 | 887 | 			tprintf(", %#lx", tcp->u_arg[3]); | 
 | 888 | 		else | 
 | 889 | 			tprintf(", NULL"); | 
 | 890 | 	} | 
 | 891 | 	return 0; | 
 | 892 | } | 
 | 893 |  | 
| Wichert Akkerman | e4aafd4 | 1999-11-26 09:54:08 +0000 | [diff] [blame] | 894 |  | 
 | 895 | struct xlat aclipc[] = { | 
 | 896 | #ifdef IPC_SHM | 
 | 897 | 	{ IPC_SHM,	"IPC_SHM"	}, | 
 | 898 | #endif	 | 
 | 899 | #ifdef IPC_SEM | 
 | 900 | 	{ IPC_SEM,	"IPC_SEM"	}, | 
 | 901 | #endif	 | 
 | 902 | #ifdef IPC_MSG | 
 | 903 | 	{ IPC_MSG,	"IPC_MSG"	}, | 
 | 904 | #endif	 | 
 | 905 | 	{ 0,		NULL		}, | 
 | 906 | }; | 
 | 907 |  | 
 | 908 |  | 
 | 909 | int | 
 | 910 | sys_aclipc(tcp) | 
 | 911 | struct tcb *tcp; | 
 | 912 | { | 
 | 913 | 	if (entering(tcp)) { | 
 | 914 | 		printxval(aclipc, tcp->u_arg[0], "???IPC???"); | 
 | 915 | 		tprintf(", %#lx, ", tcp->u_arg[1]); | 
 | 916 | 		printxval(aclcmds, tcp->u_arg[2], "???ACL???"); | 
 | 917 | 		tprintf(", %ld", tcp->u_arg[3]); | 
 | 918 | 		/* | 
 | 919 | 		 * FIXME - dump out the list of aclent_t's pointed to | 
 | 920 | 		 * by "tcp->u_arg[4]" if it's not NULL. | 
 | 921 | 		 */ | 
 | 922 | 		if (tcp->u_arg[4]) | 
 | 923 | 			tprintf(", %#lx", tcp->u_arg[4]); | 
 | 924 | 		else | 
 | 925 | 			tprintf(", NULL"); | 
 | 926 | 	} | 
 | 927 | 	return 0; | 
 | 928 | } | 
 | 929 |  | 
 | 930 |  | 
 | 931 |  | 
| Wichert Akkerman | 8829a55 | 1999-06-11 13:18:40 +0000 | [diff] [blame] | 932 | #endif /* HAVE_SYS_ACL_H */ | 
 | 933 |  | 
| Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 934 | #endif /* SVR4 || LINUXSPARC */ | 
 | 935 |  | 
| Wichert Akkerman | 328c5e7 | 1999-04-16 00:21:26 +0000 | [diff] [blame] | 936 | #ifdef linux | 
| Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 937 |  | 
 | 938 | static struct xlat fsmagic[] = { | 
 | 939 | 	{ 0xef51,	"EXT2_OLD_SUPER_MAGIC"	}, | 
 | 940 | 	{ 0xef53,	"EXT2_SUPER_MAGIC"	}, | 
 | 941 | 	{ 0x137d,	"EXT_SUPER_MAGIC"	}, | 
 | 942 | 	{ 0x9660,	"ISOFS_SUPER_MAGIC"	}, | 
 | 943 | 	{ 0x137f,	"MINIX_SUPER_MAGIC"	}, | 
 | 944 | 	{ 0x138f,	"MINIX_SUPER_MAGIC2"	}, | 
| Wichert Akkerman | 2e2553a | 1999-05-09 00:29:58 +0000 | [diff] [blame] | 945 | 	{ 0x2468,	"MINIX2_SUPER_MAGIC"	}, | 
 | 946 | 	{ 0x2478,	"MINIX2_SUPER_MAGIC2"	}, | 
| Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 947 | 	{ 0x4d44,	"MSDOS_SUPER_MAGIC"	}, | 
 | 948 | 	{ 0x6969,	"NFS_SUPER_MAGIC"	}, | 
 | 949 | 	{ 0x9fa0,	"PROC_SUPER_MAGIC"	}, | 
 | 950 | 	{ 0x012fd16d,	"XIAFS_SUPER_MAGIC"	}, | 
 | 951 | 	{ 0,		NULL			}, | 
 | 952 | }; | 
 | 953 |  | 
| Wichert Akkerman | 328c5e7 | 1999-04-16 00:21:26 +0000 | [diff] [blame] | 954 | #endif /* linux */ | 
| Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 955 |  | 
 | 956 | #ifndef SVR4 | 
 | 957 |  | 
 | 958 | static char * | 
 | 959 | sprintfstype(magic) | 
 | 960 | int magic; | 
 | 961 | { | 
 | 962 | 	static char buf[32]; | 
| Wichert Akkerman | 328c5e7 | 1999-04-16 00:21:26 +0000 | [diff] [blame] | 963 | #ifdef linux | 
| Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 964 | 	char *s; | 
 | 965 |  | 
 | 966 | 	s = xlookup(fsmagic, magic); | 
 | 967 | 	if (s) { | 
 | 968 | 		sprintf(buf, "\"%s\"", s); | 
 | 969 | 		return buf; | 
 | 970 | 	} | 
| Wichert Akkerman | 328c5e7 | 1999-04-16 00:21:26 +0000 | [diff] [blame] | 971 | #endif /* linux */ | 
| Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 972 | 	sprintf(buf, "%#x", magic); | 
 | 973 | 	return buf; | 
 | 974 | } | 
 | 975 |  | 
 | 976 | static void | 
 | 977 | printstatfs(tcp, addr) | 
 | 978 | struct tcb *tcp; | 
 | 979 | long addr; | 
 | 980 | { | 
 | 981 | 	struct statfs statbuf; | 
 | 982 |  | 
 | 983 | 	if (syserror(tcp) || !verbose(tcp)) { | 
 | 984 | 		tprintf("%#lx", addr); | 
 | 985 | 		return; | 
 | 986 | 	} | 
 | 987 | 	if (umove(tcp, addr, &statbuf) < 0) { | 
 | 988 | 		tprintf("{...}"); | 
 | 989 | 		return; | 
 | 990 | 	} | 
 | 991 | #ifdef ALPHA | 
 | 992 |  | 
 | 993 | 	tprintf("{f_type=%s, f_fbsize=%u, f_blocks=%u, f_bfree=%u, ", | 
 | 994 | 		sprintfstype(statbuf.f_type), | 
 | 995 | 		statbuf.f_bsize, statbuf.f_blocks, statbuf.f_bfree); | 
| Wichert Akkerman | 2e2553a | 1999-05-09 00:29:58 +0000 | [diff] [blame] | 996 | 	tprintf("f_bavail=%u, f_files=%u, f_ffree=%u, f_namelen=%u", | 
| Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 997 | 		statbuf.f_bavail,statbuf.f_files, statbuf.f_ffree, statbuf.f_namelen); | 
 | 998 | #else /* !ALPHA */ | 
 | 999 | 	tprintf("{f_type=%s, f_bsize=%lu, f_blocks=%lu, f_bfree=%lu, ", | 
 | 1000 | 		sprintfstype(statbuf.f_type), | 
| Nate Sammons | 5c74d20 | 1999-04-06 01:37:51 +0000 | [diff] [blame] | 1001 | 		(unsigned long)statbuf.f_bsize, | 
 | 1002 | 		(unsigned long)statbuf.f_blocks, | 
 | 1003 | 		(unsigned long)statbuf.f_bfree); | 
| Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1004 | 	tprintf("f_files=%lu, f_ffree=%lu", | 
| Nate Sammons | 5c74d20 | 1999-04-06 01:37:51 +0000 | [diff] [blame] | 1005 | 		(unsigned long)statbuf.f_files, | 
 | 1006 | 		(unsigned long)statbuf.f_ffree); | 
| Wichert Akkerman | 328c5e7 | 1999-04-16 00:21:26 +0000 | [diff] [blame] | 1007 | #ifdef linux | 
| Wichert Akkerman | 2e2553a | 1999-05-09 00:29:58 +0000 | [diff] [blame] | 1008 | 	tprintf(", f_namelen=%lu", (unsigned long)statbuf.f_namelen); | 
| Wichert Akkerman | 328c5e7 | 1999-04-16 00:21:26 +0000 | [diff] [blame] | 1009 | #endif /* linux */ | 
| Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1010 | #endif /* !ALPHA */ | 
 | 1011 | 	tprintf("}"); | 
 | 1012 | } | 
 | 1013 |  | 
 | 1014 | int | 
 | 1015 | sys_statfs(tcp) | 
 | 1016 | struct tcb *tcp; | 
 | 1017 | { | 
 | 1018 | 	if (entering(tcp)) { | 
 | 1019 | 		printpath(tcp, tcp->u_arg[0]); | 
 | 1020 | 		tprintf(", "); | 
 | 1021 | 	} else { | 
 | 1022 | 		printstatfs(tcp, tcp->u_arg[1]); | 
 | 1023 | 	} | 
 | 1024 | 	return 0; | 
 | 1025 | } | 
 | 1026 |  | 
 | 1027 | int | 
 | 1028 | sys_fstatfs(tcp) | 
 | 1029 | struct tcb *tcp; | 
 | 1030 | { | 
 | 1031 | 	if (entering(tcp)) { | 
 | 1032 | 		tprintf("%lu, ", tcp->u_arg[0]); | 
 | 1033 | 	} else { | 
 | 1034 | 		printstatfs(tcp, tcp->u_arg[1]); | 
 | 1035 | 	} | 
 | 1036 | 	return 0; | 
 | 1037 | } | 
 | 1038 |  | 
| Wichert Akkerman | a0f36c6 | 1999-04-16 14:01:34 +0000 | [diff] [blame] | 1039 | #if defined(linux) && defined(__alpha) | 
| Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1040 |  | 
 | 1041 | int | 
 | 1042 | osf_statfs(tcp) | 
 | 1043 | struct tcb *tcp; | 
 | 1044 | { | 
 | 1045 | 	if (entering(tcp)) { | 
 | 1046 | 		printpath(tcp, tcp->u_arg[0]); | 
 | 1047 | 		tprintf(", "); | 
 | 1048 | 	} else { | 
 | 1049 | 		printstatfs(tcp, tcp->u_arg[1]); | 
 | 1050 | 		tprintf(", %lu", tcp->u_arg[2]); | 
 | 1051 | 	} | 
 | 1052 | 	return 0; | 
 | 1053 | } | 
 | 1054 |  | 
 | 1055 | int | 
 | 1056 | osf_fstatfs(tcp) | 
 | 1057 | struct tcb *tcp; | 
 | 1058 | { | 
 | 1059 | 	if (entering(tcp)) { | 
 | 1060 | 		tprintf("%lu, ", tcp->u_arg[0]); | 
 | 1061 | 	} else { | 
 | 1062 | 		printstatfs(tcp, tcp->u_arg[1]); | 
 | 1063 | 		tprintf(", %lu", tcp->u_arg[2]); | 
 | 1064 | 	} | 
 | 1065 | 	return 0; | 
 | 1066 | } | 
| Wichert Akkerman | a0f36c6 | 1999-04-16 14:01:34 +0000 | [diff] [blame] | 1067 | #endif /* linux && __alpha */ | 
| Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1068 |  | 
 | 1069 | #endif /* !SVR4 */ | 
 | 1070 |  | 
 | 1071 | #ifdef SUNOS4 | 
 | 1072 |  | 
 | 1073 | int | 
 | 1074 | sys_ustat(tcp) | 
 | 1075 | struct tcb *tcp; | 
 | 1076 | { | 
 | 1077 | 	struct ustat statbuf; | 
 | 1078 |  | 
 | 1079 | 	if (entering(tcp)) { | 
 | 1080 | 		tprintf("makedev(%lu, %lu), ", | 
 | 1081 | 				(long) major(tcp->u_arg[0]), | 
 | 1082 | 				(long) minor(tcp->u_arg[0])); | 
 | 1083 | 	} | 
 | 1084 | 	else { | 
 | 1085 | 		if (syserror(tcp) || !verbose(tcp)) | 
 | 1086 | 			tprintf("%#lx", tcp->u_arg[1]); | 
 | 1087 | 		else if (umove(tcp, tcp->u_arg[1], &statbuf) < 0) | 
 | 1088 | 			tprintf("{...}"); | 
 | 1089 | 		else { | 
 | 1090 | 			tprintf("{f_tfree=%lu, f_tinode=%lu, ", | 
 | 1091 | 				statbuf.f_tfree, statbuf.f_tinode); | 
 | 1092 | 			tprintf("f_fname=\"%.*s\", ", | 
 | 1093 | 				(int) sizeof(statbuf.f_fname), | 
 | 1094 | 				statbuf.f_fname); | 
 | 1095 | 			tprintf("f_fpack=\"%.*s\"}", | 
 | 1096 | 				(int) sizeof(statbuf.f_fpack), | 
 | 1097 | 				statbuf.f_fpack); | 
 | 1098 | 		} | 
 | 1099 | 	} | 
 | 1100 | 	return 0; | 
 | 1101 | } | 
 | 1102 |  | 
 | 1103 | #endif /* SUNOS4 */ | 
 | 1104 |  | 
 | 1105 | /* directory */ | 
 | 1106 | int | 
 | 1107 | sys_chdir(tcp) | 
 | 1108 | struct tcb *tcp; | 
 | 1109 | { | 
 | 1110 | 	if (entering(tcp)) { | 
 | 1111 | 		printpath(tcp, tcp->u_arg[0]); | 
 | 1112 | 	} | 
 | 1113 | 	return 0; | 
 | 1114 | } | 
 | 1115 |  | 
 | 1116 | int | 
 | 1117 | sys_mkdir(tcp) | 
 | 1118 | struct tcb *tcp; | 
 | 1119 | { | 
 | 1120 | 	if (entering(tcp)) { | 
 | 1121 | 		printpath(tcp, tcp->u_arg[0]); | 
 | 1122 | 		tprintf(", %#lo", tcp->u_arg[1]); | 
 | 1123 | 	} | 
 | 1124 | 	return 0; | 
 | 1125 | } | 
 | 1126 |  | 
 | 1127 | int | 
 | 1128 | sys_rmdir(tcp) | 
 | 1129 | struct tcb *tcp; | 
 | 1130 | { | 
 | 1131 | 	if (entering(tcp)) { | 
 | 1132 | 		printpath(tcp, tcp->u_arg[0]); | 
 | 1133 | 	} | 
 | 1134 | 	return 0; | 
 | 1135 | } | 
 | 1136 |  | 
 | 1137 | int | 
 | 1138 | sys_fchdir(tcp) | 
 | 1139 | struct tcb *tcp; | 
 | 1140 | { | 
 | 1141 | 	if (entering(tcp)) { | 
 | 1142 | 		tprintf("%ld", tcp->u_arg[0]); | 
 | 1143 | 	} | 
 | 1144 | 	return 0; | 
 | 1145 | } | 
 | 1146 |  | 
 | 1147 | int | 
 | 1148 | sys_chroot(tcp) | 
 | 1149 | struct tcb *tcp; | 
 | 1150 | { | 
 | 1151 | 	if (entering(tcp)) { | 
 | 1152 | 		printpath(tcp, tcp->u_arg[0]); | 
 | 1153 | 	} | 
 | 1154 | 	return 0; | 
 | 1155 | } | 
 | 1156 |  | 
 | 1157 | int | 
 | 1158 | sys_fchroot(tcp) | 
 | 1159 | struct tcb *tcp; | 
 | 1160 | { | 
 | 1161 | 	if (entering(tcp)) { | 
 | 1162 | 		tprintf("%ld", tcp->u_arg[0]); | 
 | 1163 | 	} | 
 | 1164 | 	return 0; | 
 | 1165 | } | 
 | 1166 |  | 
 | 1167 | int | 
 | 1168 | sys_link(tcp) | 
 | 1169 | struct tcb *tcp; | 
 | 1170 | { | 
 | 1171 | 	if (entering(tcp)) { | 
 | 1172 | 		printpath(tcp, tcp->u_arg[0]); | 
 | 1173 | 		tprintf(", "); | 
 | 1174 | 		printpath(tcp, tcp->u_arg[1]); | 
 | 1175 | 	} | 
 | 1176 | 	return 0; | 
 | 1177 | } | 
 | 1178 |  | 
 | 1179 | int | 
 | 1180 | sys_unlink(tcp) | 
 | 1181 | struct tcb *tcp; | 
 | 1182 | { | 
 | 1183 | 	if (entering(tcp)) { | 
 | 1184 | 		printpath(tcp, tcp->u_arg[0]); | 
 | 1185 | 	} | 
 | 1186 | 	return 0; | 
 | 1187 | } | 
 | 1188 |  | 
 | 1189 | int | 
 | 1190 | sys_symlink(tcp) | 
 | 1191 | struct tcb *tcp; | 
 | 1192 | { | 
 | 1193 | 	if (entering(tcp)) { | 
 | 1194 | 		printpath(tcp, tcp->u_arg[0]); | 
 | 1195 | 		tprintf(", "); | 
 | 1196 | 		printpath(tcp, tcp->u_arg[1]); | 
 | 1197 | 	} | 
 | 1198 | 	return 0; | 
 | 1199 | } | 
 | 1200 |  | 
 | 1201 | int | 
 | 1202 | sys_readlink(tcp) | 
 | 1203 | struct tcb *tcp; | 
 | 1204 | { | 
 | 1205 | 	if (entering(tcp)) { | 
 | 1206 | 		printpath(tcp, tcp->u_arg[0]); | 
 | 1207 | 		tprintf(", "); | 
 | 1208 | 	} else { | 
 | 1209 | 		if (syserror(tcp)) | 
 | 1210 | 			tprintf("%#lx", tcp->u_arg[1]); | 
 | 1211 | 		else | 
 | 1212 | 			printpathn(tcp, tcp->u_arg[1], tcp->u_rval); | 
 | 1213 | 		tprintf(", %lu", tcp->u_arg[2]); | 
 | 1214 | 	} | 
 | 1215 | 	return 0; | 
 | 1216 | } | 
 | 1217 |  | 
 | 1218 | int | 
 | 1219 | sys_rename(tcp) | 
 | 1220 | struct tcb *tcp; | 
 | 1221 | { | 
 | 1222 | 	if (entering(tcp)) { | 
 | 1223 | 		printpath(tcp, tcp->u_arg[0]); | 
 | 1224 | 		tprintf(", "); | 
 | 1225 | 		printpath(tcp, tcp->u_arg[1]); | 
 | 1226 | 	} | 
 | 1227 | 	return 0; | 
 | 1228 | } | 
 | 1229 |  | 
 | 1230 | int | 
 | 1231 | sys_chown(tcp) | 
 | 1232 | struct tcb *tcp; | 
 | 1233 | { | 
 | 1234 | 	if (entering(tcp)) { | 
 | 1235 | 		printpath(tcp, tcp->u_arg[0]); | 
 | 1236 | 		tprintf(", %lu, %lu", tcp->u_arg[1], tcp->u_arg[2]); | 
 | 1237 | 	} | 
 | 1238 | 	return 0; | 
 | 1239 | } | 
 | 1240 |  | 
 | 1241 | int | 
 | 1242 | sys_fchown(tcp) | 
 | 1243 | struct tcb *tcp; | 
 | 1244 | { | 
 | 1245 | 	if (entering(tcp)) { | 
 | 1246 | 		tprintf("%ld, %lu, %lu", | 
 | 1247 | 			tcp->u_arg[0], tcp->u_arg[1], tcp->u_arg[2]); | 
 | 1248 | 	} | 
 | 1249 | 	return 0; | 
 | 1250 | } | 
 | 1251 |  | 
 | 1252 | int | 
 | 1253 | sys_chmod(tcp) | 
 | 1254 | struct tcb *tcp; | 
 | 1255 | { | 
 | 1256 | 	if (entering(tcp)) { | 
 | 1257 | 		printpath(tcp, tcp->u_arg[0]); | 
 | 1258 | 		tprintf(", %#lo", tcp->u_arg[1]); | 
 | 1259 | 	} | 
 | 1260 | 	return 0; | 
 | 1261 | } | 
 | 1262 |  | 
 | 1263 | int | 
 | 1264 | sys_fchmod(tcp) | 
 | 1265 | struct tcb *tcp; | 
 | 1266 | { | 
 | 1267 | 	if (entering(tcp)) { | 
 | 1268 | 		tprintf("%ld, %#lo", tcp->u_arg[0], tcp->u_arg[1]); | 
 | 1269 | 	} | 
 | 1270 | 	return 0; | 
 | 1271 | } | 
 | 1272 |  | 
| Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 1273 | #ifdef ALPHA | 
 | 1274 | int | 
 | 1275 | sys_osf_utimes(tcp) | 
 | 1276 | struct tcb *tcp; | 
 | 1277 | { | 
 | 1278 |     if (entering(tcp)) { | 
 | 1279 | 	printpath(tcp, tcp->u_arg[0]); | 
 | 1280 | 	tprintf(", "); | 
 | 1281 | 	printtv32(tcp, tcp->u_arg[1]); | 
 | 1282 |     } | 
 | 1283 |     return 0; | 
 | 1284 | } | 
 | 1285 | #endif | 
 | 1286 |  | 
| Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1287 | int | 
 | 1288 | sys_utimes(tcp) | 
 | 1289 | struct tcb *tcp; | 
 | 1290 | { | 
 | 1291 | 	if (entering(tcp)) { | 
 | 1292 | 		printpath(tcp, tcp->u_arg[0]); | 
 | 1293 | 		tprintf(", "); | 
 | 1294 | 		printtv(tcp, tcp->u_arg[1]); | 
 | 1295 | 	} | 
 | 1296 | 	return 0; | 
 | 1297 | } | 
 | 1298 |  | 
 | 1299 | int | 
 | 1300 | sys_utime(tcp) | 
 | 1301 | struct tcb *tcp; | 
 | 1302 | { | 
 | 1303 | 	long ut[2]; | 
 | 1304 |  | 
 | 1305 | 	if (entering(tcp)) { | 
 | 1306 | 		printpath(tcp, tcp->u_arg[0]); | 
 | 1307 | 		tprintf(", "); | 
 | 1308 | 		if (!tcp->u_arg[1]) | 
 | 1309 | 			tprintf("NULL"); | 
 | 1310 | 		else if (!verbose(tcp)) | 
 | 1311 | 			tprintf("%#lx", tcp->u_arg[1]); | 
 | 1312 | 		else if (umoven(tcp, tcp->u_arg[1], sizeof ut, | 
 | 1313 | 		    (char *) ut) < 0) | 
 | 1314 | 			tprintf("[?, ?]"); | 
 | 1315 | 		else { | 
 | 1316 | 			tprintf("[%s,", sprinttime(ut[0])); | 
 | 1317 | 			tprintf(" %s]", sprinttime(ut[1])); | 
 | 1318 | 		} | 
 | 1319 | 	} | 
 | 1320 | 	return 0; | 
 | 1321 | } | 
 | 1322 |  | 
 | 1323 | int | 
 | 1324 | sys_mknod(tcp) | 
 | 1325 | struct tcb *tcp; | 
 | 1326 | { | 
 | 1327 | 	int mode = tcp->u_arg[1]; | 
 | 1328 |  | 
 | 1329 | 	if (entering(tcp)) { | 
 | 1330 | 		printpath(tcp, tcp->u_arg[0]); | 
 | 1331 | 		tprintf(", %s", sprintmode(mode)); | 
 | 1332 | 		switch (mode & S_IFMT) { | 
 | 1333 | 		case S_IFCHR: case S_IFBLK: | 
 | 1334 | #ifdef LINUXSPARC | 
 | 1335 | 			if (current_personality == 1) | 
 | 1336 | 			tprintf(", makedev(%lu, %lu)", | 
 | 1337 | 				(unsigned long) ((tcp->u_arg[2] >> 18) & 0x3fff), | 
 | 1338 | 				(unsigned long) (tcp->u_arg[2] & 0x3ffff)); | 
 | 1339 | 			else | 
 | 1340 | #endif	 | 
 | 1341 | 			tprintf(", makedev(%lu, %lu)", | 
 | 1342 | 				(unsigned long) major(tcp->u_arg[2]), | 
 | 1343 | 				(unsigned long) minor(tcp->u_arg[2])); | 
 | 1344 | 			break; | 
 | 1345 | 		default: | 
 | 1346 | 			break; | 
 | 1347 | 		} | 
 | 1348 | 	} | 
 | 1349 | 	return 0; | 
 | 1350 | } | 
 | 1351 |  | 
 | 1352 | int | 
 | 1353 | sys_mkfifo(tcp) | 
 | 1354 | struct tcb *tcp; | 
 | 1355 | { | 
 | 1356 | 	if (entering(tcp)) { | 
 | 1357 | 		printpath(tcp, tcp->u_arg[0]); | 
 | 1358 | 		tprintf(", %#lo", tcp->u_arg[1]); | 
 | 1359 | 	} | 
 | 1360 | 	return 0; | 
 | 1361 | } | 
 | 1362 |  | 
 | 1363 | int | 
 | 1364 | sys_fsync(tcp) | 
 | 1365 | struct tcb *tcp; | 
 | 1366 | { | 
 | 1367 | 	if (entering(tcp)) { | 
 | 1368 | 		tprintf("%ld", tcp->u_arg[0]); | 
 | 1369 | 	} | 
 | 1370 | 	return 0; | 
 | 1371 | } | 
 | 1372 |  | 
| Wichert Akkerman | 328c5e7 | 1999-04-16 00:21:26 +0000 | [diff] [blame] | 1373 | #ifdef linux | 
| Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1374 |  | 
 | 1375 | static void | 
 | 1376 | printdir(tcp, addr) | 
 | 1377 | struct tcb *tcp; | 
 | 1378 | long addr; | 
 | 1379 | { | 
 | 1380 | 	struct dirent d; | 
 | 1381 |  | 
 | 1382 | 	if (!verbose(tcp)) { | 
 | 1383 | 		tprintf("%#lx", addr); | 
 | 1384 | 		return; | 
 | 1385 | 	} | 
 | 1386 | 	if (umove(tcp, addr, &d) < 0) { | 
 | 1387 | 		tprintf("{...}"); | 
 | 1388 | 		return; | 
 | 1389 | 	} | 
 | 1390 | 	tprintf("{d_ino=%ld, ", (unsigned long) d.d_ino); | 
| Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1391 | 	tprintf("d_name="); | 
 | 1392 | 	printpathn(tcp, (long) ((struct dirent *) addr)->d_name, d.d_reclen); | 
 | 1393 | 	tprintf("}"); | 
 | 1394 | } | 
 | 1395 |  | 
 | 1396 | int | 
 | 1397 | sys_readdir(tcp) | 
 | 1398 | struct tcb *tcp; | 
 | 1399 | { | 
 | 1400 | 	if (entering(tcp)) { | 
 | 1401 | 		tprintf("%lu, ", tcp->u_arg[0]); | 
 | 1402 | 	} else { | 
 | 1403 | 		if (syserror(tcp) || tcp->u_rval == 0 || !verbose(tcp)) | 
 | 1404 | 			tprintf("%#lx", tcp->u_arg[1]); | 
 | 1405 | 		else | 
 | 1406 | 			printdir(tcp, tcp->u_arg[1]); | 
 | 1407 | 		/* Not much point in printing this out, it is always 1. */ | 
 | 1408 | 		if (tcp->u_arg[2] != 1) | 
 | 1409 | 			tprintf(", %lu", tcp->u_arg[2]); | 
 | 1410 | 	} | 
 | 1411 | 	return 0; | 
 | 1412 | } | 
 | 1413 |  | 
| Wichert Akkerman | 328c5e7 | 1999-04-16 00:21:26 +0000 | [diff] [blame] | 1414 | #endif /* linux */ | 
| Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1415 |  | 
 | 1416 | int | 
 | 1417 | sys_getdents(tcp) | 
 | 1418 | struct tcb *tcp; | 
 | 1419 | { | 
 | 1420 | 	int i, len, dents = 0; | 
 | 1421 | 	char *buf; | 
 | 1422 |  | 
 | 1423 | 	if (entering(tcp)) { | 
 | 1424 | 		tprintf("%lu, ", tcp->u_arg[0]); | 
 | 1425 | 		return 0; | 
 | 1426 | 	} | 
 | 1427 | 	if (syserror(tcp) || !verbose(tcp)) { | 
 | 1428 | 		tprintf("%#lx, %lu", tcp->u_arg[1], tcp->u_arg[2]); | 
 | 1429 | 		return 0; | 
 | 1430 | 	} | 
| Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1431 | 	len = tcp->u_rval; | 
 | 1432 | 	if ((buf = malloc(len)) == NULL) { | 
 | 1433 | 		tprintf("out of memory\n"); | 
 | 1434 | 		return 0; | 
 | 1435 | 	} | 
 | 1436 | 	if (umoven(tcp, tcp->u_arg[1], len, buf) < 0) { | 
 | 1437 | 		tprintf("{...}, %lu", tcp->u_arg[2]); | 
 | 1438 | 		free(buf); | 
 | 1439 | 		return 0; | 
 | 1440 | 	} | 
 | 1441 | 	if (!abbrev(tcp)) | 
 | 1442 | 		tprintf("{"); | 
 | 1443 | 	for (i = 0; i < len;) { | 
| Wichert Akkerman | 9524bb9 | 1999-05-25 23:11:18 +0000 | [diff] [blame] | 1444 | 		struct kernel_dirent *d = (struct kernel_dirent *) &buf[i]; | 
| Wichert Akkerman | 328c5e7 | 1999-04-16 00:21:26 +0000 | [diff] [blame] | 1445 | #ifdef linux | 
| Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1446 | 		if (!abbrev(tcp)) { | 
 | 1447 | 			tprintf("%s{d_ino=%lu, d_off=%lu, ", | 
 | 1448 | 				i ? " " : "", d->d_ino, d->d_off); | 
 | 1449 | 			tprintf("d_reclen=%u, d_name=\"%s\"}", | 
 | 1450 | 				d->d_reclen, d->d_name); | 
 | 1451 | 		} | 
| Wichert Akkerman | 328c5e7 | 1999-04-16 00:21:26 +0000 | [diff] [blame] | 1452 | #endif /* linux */ | 
| Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1453 | #ifdef SVR4 | 
 | 1454 | 		if (!abbrev(tcp)) { | 
 | 1455 | 			tprintf("%s{d_ino=%lu, d_off=%lu, ", | 
 | 1456 | 				i ? " " : "", d->d_ino, d->d_off); | 
 | 1457 | 			tprintf("d_reclen=%u, d_name=\"%s\"}", | 
 | 1458 | 				d->d_reclen, d->d_name); | 
 | 1459 | 		} | 
 | 1460 | #endif /* SVR4 */ | 
 | 1461 | #ifdef SUNOS4 | 
 | 1462 | 		if (!abbrev(tcp)) { | 
 | 1463 | 			tprintf("%s{d_off=%lu, d_fileno=%lu, d_reclen=%u, ", | 
 | 1464 | 				i ? " " : "", d->d_off, d->d_fileno, | 
 | 1465 | 				d->d_reclen); | 
 | 1466 | 			tprintf("d_namlen=%u, d_name=\"%.*s\"}", | 
 | 1467 | 				d->d_namlen, d->d_namlen, d->d_name); | 
 | 1468 | 		} | 
 | 1469 | #endif /* SUNOS4 */ | 
 | 1470 | 		i += d->d_reclen; | 
 | 1471 | 		dents++; | 
 | 1472 | 	} | 
 | 1473 | 	if (!abbrev(tcp)) | 
 | 1474 | 		tprintf("}"); | 
 | 1475 | 	else | 
 | 1476 | 		tprintf("/* %u entries */", dents); | 
 | 1477 | 	tprintf(", %lu", tcp->u_arg[2]); | 
 | 1478 | 	free(buf); | 
 | 1479 | 	return 0; | 
 | 1480 | } | 
 | 1481 |  | 
| Wichert Akkerman | 328c5e7 | 1999-04-16 00:21:26 +0000 | [diff] [blame] | 1482 | #ifdef linux | 
| Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1483 |  | 
 | 1484 | int | 
 | 1485 | sys_getcwd(tcp) | 
 | 1486 | struct tcb *tcp; | 
 | 1487 | { | 
 | 1488 |     if (exiting(tcp)) { | 
 | 1489 | 	if (syserror(tcp)) | 
 | 1490 | 	    tprintf("%#lx", tcp->u_arg[0]); | 
 | 1491 | 	else | 
| Wichert Akkerman | 2e2553a | 1999-05-09 00:29:58 +0000 | [diff] [blame] | 1492 | 	    printpathn(tcp, tcp->u_arg[0], tcp->u_rval - 1); | 
| Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1493 | 	tprintf(", %lu", tcp->u_arg[1]); | 
 | 1494 |     } | 
 | 1495 |     return 0; | 
 | 1496 | } | 
| Wichert Akkerman | 328c5e7 | 1999-04-16 00:21:26 +0000 | [diff] [blame] | 1497 | #endif /* linux */ | 
| Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1498 |  | 
 | 1499 | #ifdef HAVE_SYS_ASYNCH_H | 
 | 1500 |  | 
 | 1501 | int | 
 | 1502 | sys_aioread(tcp) | 
 | 1503 | struct tcb *tcp; | 
 | 1504 | { | 
 | 1505 | 	struct aio_result_t res; | 
 | 1506 |  | 
 | 1507 | 	if (entering(tcp)) { | 
 | 1508 | 		tprintf("%lu, ", tcp->u_arg[0]); | 
 | 1509 | 	} else { | 
 | 1510 | 		if (syserror(tcp)) | 
 | 1511 | 			tprintf("%#lx", tcp->u_arg[1]); | 
 | 1512 | 		else | 
 | 1513 | 			printstr(tcp, tcp->u_arg[1], tcp->u_arg[2]); | 
 | 1514 | 		tprintf(", %lu, %lu, ", tcp->u_arg[2], tcp->u_arg[3]); | 
 | 1515 | 		printxval(whence, tcp->u_arg[4], "L_???"); | 
 | 1516 | 		if (syserror(tcp) || tcp->u_arg[5] == 0 | 
 | 1517 | 		    || umove(tcp, tcp->u_arg[5], &res) < 0) | 
 | 1518 | 			tprintf(", %#lx", tcp->u_arg[5]); | 
 | 1519 | 		else | 
 | 1520 | 			tprintf(", {aio_return %d aio_errno %d}", | 
 | 1521 | 				res.aio_return, res.aio_errno); | 
 | 1522 | 	} | 
 | 1523 | 	return 0; | 
 | 1524 | } | 
 | 1525 |  | 
 | 1526 | int | 
 | 1527 | sys_aiowrite(tcp) | 
 | 1528 | struct tcb *tcp; | 
 | 1529 | { | 
 | 1530 | 	struct aio_result_t res; | 
 | 1531 |  | 
 | 1532 | 	if (entering(tcp)) { | 
 | 1533 | 		tprintf("%lu, ", tcp->u_arg[0]); | 
 | 1534 | 		printstr(tcp, tcp->u_arg[1], tcp->u_arg[2]); | 
 | 1535 | 		tprintf(", %lu, %lu, ", tcp->u_arg[2], tcp->u_arg[3]); | 
 | 1536 | 		printxval(whence, tcp->u_arg[4], "L_???"); | 
 | 1537 | 	} | 
 | 1538 | 	else { | 
 | 1539 | 		if (tcp->u_arg[5] == 0) | 
 | 1540 | 			tprintf(", NULL"); | 
 | 1541 | 		else if (syserror(tcp) | 
 | 1542 | 		    || umove(tcp, tcp->u_arg[5], &res) < 0) | 
 | 1543 | 			tprintf(", %#lx", tcp->u_arg[5]); | 
 | 1544 | 		else | 
 | 1545 | 			tprintf(", {aio_return %d aio_errno %d}", | 
 | 1546 | 				res.aio_return, res.aio_errno); | 
 | 1547 | 	} | 
 | 1548 | 	return 0; | 
 | 1549 | } | 
 | 1550 |  | 
 | 1551 | int | 
 | 1552 | sys_aiowait(tcp) | 
 | 1553 | struct tcb *tcp; | 
 | 1554 | { | 
 | 1555 | 	if (entering(tcp)) | 
 | 1556 | 		printtv(tcp, tcp->u_arg[0]); | 
 | 1557 | 	return 0; | 
 | 1558 | } | 
 | 1559 |  | 
 | 1560 | int | 
 | 1561 | sys_aiocancel(tcp) | 
 | 1562 | struct tcb *tcp; | 
 | 1563 | { | 
 | 1564 | 	struct aio_result_t res; | 
 | 1565 |  | 
 | 1566 | 	if (exiting(tcp)) { | 
 | 1567 | 		if (tcp->u_arg[0] == 0) | 
 | 1568 | 			tprintf("NULL"); | 
 | 1569 | 		else if (syserror(tcp) | 
 | 1570 | 		    || umove(tcp, tcp->u_arg[0], &res) < 0) | 
 | 1571 | 			tprintf("%#lx", tcp->u_arg[0]); | 
 | 1572 | 		else | 
 | 1573 | 			tprintf("{aio_return %d aio_errno %d}", | 
 | 1574 | 				res.aio_return, res.aio_errno); | 
 | 1575 | 	} | 
 | 1576 | 	return 0; | 
 | 1577 | } | 
 | 1578 |  | 
 | 1579 | #endif /* HAVE_SYS_ASYNCH_H */ |