blob: addea3e373e11ac7fe91e6964bbc49764f884c91 [file] [log] [blame]
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001/*
Michal Ludvig53b320f2002-09-23 13:30:09 +00002#ifdef LINUX
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00003 * 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 Akkerman4dc8a2a1999-12-23 14:20:14 +00006 * Copyright (c) 1996-1999 Wichert Akkerman <wichert@cistron.nl>
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00007 * 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 Ludvig53b320f2002-09-23 13:30:09 +000037#ifdef LINUX
Wichert Akkerman9524bb91999-05-25 23:11:18 +000038#define dirent kernel_dirent
Wichert Akkerman9b0c31d2000-09-03 21:56:29 +000039#define dirent64 kernel_dirent64
Wichert Akkerman9524bb91999-05-25 23:11:18 +000040#include <linux/types.h>
41#include <linux/dirent.h>
42#undef dirent
Michal Ludvig10a88d02002-10-07 14:31:00 +000043#undef dirent64
Wichert Akkerman9524bb91999-05-25 23:11:18 +000044#else
45#define kernel_dirent dirent
46#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000047
Michal Ludvig53b320f2002-09-23 13:30:09 +000048#ifdef LINUX
Wichert Akkermandacfb6e1999-06-03 14:21:07 +000049# ifdef LINUXSPARC
50struct 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};
69# define stat kernel_stat
70# include <asm/stat.h>
71# undef stat
72# else
Wichert Akkerman5b4d1281999-07-09 00:32:54 +000073# undef dev_t
74# undef ino_t
75# undef mode_t
76# undef nlink_t
77# undef uid_t
78# undef gid_t
79# undef off_t
80# undef loff_t
81
Wichert Akkermana6013701999-07-08 14:00:58 +000082# define dev_t __kernel_dev_t
83# define ino_t __kernel_ino_t
84# define mode_t __kernel_mode_t
85# define nlink_t __kernel_nlink_t
86# define uid_t __kernel_uid_t
87# define gid_t __kernel_gid_t
88# define off_t __kernel_off_t
89# define loff_t __kernel_loff_t
90
Wichert Akkermandacfb6e1999-06-03 14:21:07 +000091# include <asm/stat.h>
Wichert Akkermana6013701999-07-08 14:00:58 +000092
93# undef dev_t
94# undef ino_t
95# undef mode_t
96# undef nlink_t
97# undef uid_t
98# undef gid_t
99# undef off_t
100# undef loff_t
Wichert Akkerman5b4d1281999-07-09 00:32:54 +0000101
102# define dev_t dev_t
103# define ino_t ino_t
104# define mode_t mode_t
105# define nlink_t nlink_t
106# define uid_t uid_t
107# define gid_t gid_t
108# define off_t off_t
109# define loff_t loff_t
Wichert Akkermandacfb6e1999-06-03 14:21:07 +0000110# endif
Wichert Akkermanc1652e22001-03-27 12:17:16 +0000111# ifdef HPPA /* asm-parisc/stat.h defines stat64 */
112# undef stat64
113# endif
Wichert Akkermand4d8e921999-04-18 23:30:29 +0000114# define stat libc_stat
Ulrich Drepper0fa01d71999-12-24 07:18:28 +0000115# define stat64 libc_stat64
Wichert Akkermand4d8e921999-04-18 23:30:29 +0000116# include <sys/stat.h>
117# undef stat
Ulrich Drepper0fa01d71999-12-24 07:18:28 +0000118# undef stat64
Wichert Akkermanc1652e22001-03-27 12:17:16 +0000119# ifdef HPPA
120# define stat64 hpux_stat64
121# endif
Wichert Akkermand4d8e921999-04-18 23:30:29 +0000122#else
123# include <sys/stat.h>
Wichert Akkerman328c5e71999-04-16 00:21:26 +0000124#endif
Wichert Akkermand4d8e921999-04-18 23:30:29 +0000125
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000126#include <fcntl.h>
127
128#ifdef SVR4
129# include <sys/cred.h>
130#endif /* SVR4 */
131
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +0000132#ifdef HAVE_SYS_VFS_H
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000133#include <sys/vfs.h>
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +0000134#endif
135
Roland McGrath186c5ac2002-12-15 23:58:23 +0000136#ifdef HAVE_LINUX_XATTR_H
137#include <linux/xattr.h>
138#elif defined linux
139#define XATTR_CREATE 1
140#define XATTR_REPLACE 2
141#endif
142
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +0000143#ifdef FREEBSD
144#include <sys/param.h>
145#include <sys/mount.h>
146#include <sys/stat.h>
John Hughes70623be2001-03-08 13:59:00 +0000147#endif
148
149#if HAVE_LONG_LONG_OFF_T
150/*
151 * Ugly hacks for systems that have typedef long long off_t
152 */
John Hughesb8c9f772001-03-07 16:53:07 +0000153
154#define stat64 stat
155#define HAVE_STAT64 1 /* Ugly hack */
John Hughes70623be2001-03-08 13:59:00 +0000156
157#define sys_stat64 sys_stat
158#define sys_fstat64 sys_fstat
159#define sys_lstat64 sys_lstat
160#define sys_lseek64 sys_lseek
161#define sys_truncate64 sys_truncate
162#define sys_ftruncate64 sys_ftruncate
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +0000163#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000164
165#ifdef MAJOR_IN_SYSMACROS
166#include <sys/sysmacros.h>
167#endif
168
169#ifdef MAJOR_IN_MKDEV
170#include <sys/mkdev.h>
171#endif
172
173#ifdef HAVE_SYS_ASYNCH_H
174#include <sys/asynch.h>
175#endif
176
177#ifdef SUNOS4
178#include <ustat.h>
179#endif
180
181/*
182 * This is a really dirty trick but it should always work. Traditional
183 * Unix says r/w/rw are 0/1/2, so we make them true flags 1/2/3 by
184 * adding 1. Just remember to add 1 to any arg decoded with openmodes.
185 */
186struct xlat openmodes[] = {
187 { O_RDWR+1, "O_RDWR" },
188 { O_RDONLY+1, "O_RDONLY" },
189 { O_WRONLY+1, "O_WRONLY" },
190 { O_NONBLOCK, "O_NONBLOCK" },
191 { O_APPEND, "O_APPEND" },
192 { O_CREAT, "O_CREAT" },
193 { O_TRUNC, "O_TRUNC" },
194 { O_EXCL, "O_EXCL" },
195 { O_NOCTTY, "O_NOCTTY" },
196#ifdef O_SYNC
197 { O_SYNC, "O_SYNC" },
198#endif
199#ifdef O_ASYNC
200 { O_ASYNC, "O_ASYNC" },
201#endif
202#ifdef O_DSYNC
203 { O_DSYNC, "O_DSYNC" },
204#endif
205#ifdef O_RSYNC
206 { O_RSYNC, "O_RSYNC" },
207#endif
208#ifdef O_NDELAY
209 { O_NDELAY, "O_NDELAY" },
210#endif
211#ifdef O_PRIV
212 { O_PRIV, "O_PRIV" },
213#endif
214#ifdef O_DIRECT
Wichert Akkerman5ae21ea2000-05-01 01:53:59 +0000215 { O_DIRECT, "O_DIRECT" },
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000216#endif
217#ifdef O_LARGEFILE
Wichert Akkerman5ae21ea2000-05-01 01:53:59 +0000218 { O_LARGEFILE, "O_LARGEFILE" },
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000219#endif
220#ifdef O_DIRECTORY
Wichert Akkerman5ae21ea2000-05-01 01:53:59 +0000221 { O_DIRECTORY, "O_DIRECTORY" },
222#endif
223#ifdef O_NOFOLLOW
224 { O_NOFOLLOW, "O_NOFOLLOW" },
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000225#endif
226
227#ifdef FNDELAY
228 { FNDELAY, "FNDELAY" },
229#endif
230#ifdef FAPPEND
231 { FAPPEND, "FAPPEND" },
232#endif
233#ifdef FMARK
234 { FMARK, "FMARK" },
235#endif
236#ifdef FDEFER
237 { FDEFER, "FDEFER" },
238#endif
239#ifdef FASYNC
240 { FASYNC, "FASYNC" },
241#endif
242#ifdef FSHLOCK
243 { FSHLOCK, "FSHLOCK" },
244#endif
245#ifdef FEXLOCK
246 { FEXLOCK, "FEXLOCK" },
247#endif
248#ifdef FCREAT
249 { FCREAT, "FCREAT" },
250#endif
251#ifdef FTRUNC
252 { FTRUNC, "FTRUNC" },
253#endif
254#ifdef FEXCL
255 { FEXCL, "FEXCL" },
256#endif
257#ifdef FNBIO
258 { FNBIO, "FNBIO" },
259#endif
260#ifdef FSYNC
261 { FSYNC, "FSYNC" },
262#endif
263#ifdef FNOCTTY
264 { FNOCTTY, "FNOCTTY" },
Roland McGrath186c5ac2002-12-15 23:58:23 +0000265#endif
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +0000266#ifdef O_SHLOCK
267 { O_SHLOCK, "O_SHLOCK" },
268#endif
269#ifdef O_EXLOCK
270 { O_EXLOCK, "O_EXLOCK" },
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000271#endif
272 { 0, NULL },
273};
274
275int
276sys_open(tcp)
277struct tcb *tcp;
278{
279 if (entering(tcp)) {
280 printpath(tcp, tcp->u_arg[0]);
281 tprintf(", ");
282 /* flags */
283 printflags(openmodes, tcp->u_arg[1] + 1);
284 if (tcp->u_arg[1] & O_CREAT) {
285 /* mode */
286 tprintf(", %#lo", tcp->u_arg[2]);
287 }
288 }
289 return 0;
290}
291
292#ifdef LINUXSPARC
293struct xlat openmodessol[] = {
294 { 0, "O_RDWR" },
295 { 1, "O_RDONLY" },
296 { 2, "O_WRONLY" },
297 { 0x80, "O_NONBLOCK" },
298 { 8, "O_APPEND" },
299 { 0x100, "O_CREAT" },
300 { 0x200, "O_TRUNC" },
301 { 0x400, "O_EXCL" },
302 { 0x800, "O_NOCTTY" },
303 { 0x10, "O_SYNC" },
304 { 0x40, "O_DSYNC" },
305 { 0x8000, "O_RSYNC" },
306 { 4, "O_NDELAY" },
307 { 0x1000, "O_PRIV" },
308 { 0, NULL },
309};
310
311int
312solaris_open(tcp)
313struct tcb *tcp;
314{
315 if (entering(tcp)) {
316 printpath(tcp, tcp->u_arg[0]);
317 tprintf(", ");
318 /* flags */
319 printflags(openmodessol, tcp->u_arg[1] + 1);
320 if (tcp->u_arg[1] & 0x100) {
321 /* mode */
322 tprintf(", %#lo", tcp->u_arg[2]);
323 }
324 }
325 return 0;
326}
327
328#endif
329
330int
331sys_creat(tcp)
332struct tcb *tcp;
333{
334 if (entering(tcp)) {
335 printpath(tcp, tcp->u_arg[0]);
336 tprintf(", %#lo", tcp->u_arg[1]);
337 }
338 return 0;
339}
340
341static struct xlat access_flags[] = {
342 { F_OK, "F_OK", },
343 { R_OK, "R_OK" },
344 { W_OK, "W_OK" },
345 { X_OK, "X_OK" },
346#ifdef EFF_ONLY_OK
347 { EFF_ONLY_OK, "EFF_ONLY_OK" },
348#endif
349#ifdef EX_OK
350 { EX_OK, "EX_OK" },
351#endif
352 { 0, NULL },
353};
354
355int
356sys_access(tcp)
357struct tcb *tcp;
358{
359 if (entering(tcp)) {
360 printpath(tcp, tcp->u_arg[0]);
361 tprintf(", ");
362 printflags(access_flags, tcp->u_arg[1]);
363 }
364 return 0;
365}
366
367int
368sys_umask(tcp)
369struct tcb *tcp;
370{
371 if (entering(tcp)) {
372 tprintf("%#lo", tcp->u_arg[0]);
373 }
374 return RVAL_OCTAL;
375}
376
377static struct xlat whence[] = {
378 { SEEK_SET, "SEEK_SET" },
379 { SEEK_CUR, "SEEK_CUR" },
380 { SEEK_END, "SEEK_END" },
381 { 0, NULL },
382};
383
John Hughes70623be2001-03-08 13:59:00 +0000384#ifndef HAVE_LONG_LONG_OFF_T
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000385int
386sys_lseek(tcp)
387struct tcb *tcp;
388{
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +0000389 off_t offset;
390 int _whence;
391
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000392 if (entering(tcp)) {
393 tprintf("%ld, ", tcp->u_arg[0]);
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +0000394 offset = tcp->u_arg[1];
395 _whence = tcp->u_arg[2];
396 if (_whence == SEEK_SET)
397 tprintf("%lu, ", offset);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000398 else
Roland McGrath186c5ac2002-12-15 23:58:23 +0000399 tprintf("%ld, ", offset);
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +0000400 printxval(whence, _whence, "SEEK_???");
Roland McGrath186c5ac2002-12-15 23:58:23 +0000401 }
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000402 return RVAL_UDECIMAL;
403}
John Hughes5a826b82001-03-07 13:21:24 +0000404#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000405
Michal Ludvig53b320f2002-09-23 13:30:09 +0000406#ifdef LINUX
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000407int
408sys_llseek (tcp)
409struct tcb *tcp;
410{
411 if (entering(tcp)) {
412 if (tcp->u_arg[4] == SEEK_SET)
413 tprintf("%ld, %llu, ", tcp->u_arg[0],
Wichert Akkerman2e2553a1999-05-09 00:29:58 +0000414 (((long long int) tcp->u_arg[1]) << 32
Wichert Akkerman7ab47b62002-03-31 19:00:02 +0000415 | (unsigned long long) (unsigned) tcp->u_arg[2]));
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000416 else
417 tprintf("%ld, %lld, ", tcp->u_arg[0],
418 (((long long int) tcp->u_arg[1]) << 32
Wichert Akkerman7ab47b62002-03-31 19:00:02 +0000419 | (unsigned long long) (unsigned) tcp->u_arg[2]));
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000420 }
421 else {
Wichert Akkerman2e2553a1999-05-09 00:29:58 +0000422 long long int off;
423 if (syserror(tcp) || umove(tcp, tcp->u_arg[3], &off) < 0)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000424 tprintf("%#lx, ", tcp->u_arg[3]);
Wichert Akkerman2e2553a1999-05-09 00:29:58 +0000425 else
426 tprintf("[%llu], ", off);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000427 printxval(whence, tcp->u_arg[4], "SEEK_???");
428 }
429 return 0;
430}
Roland McGrath186c5ac2002-12-15 23:58:23 +0000431
432int
433sys_readahead (tcp)
434struct tcb *tcp;
435{
436 if (entering(tcp)) {
437 tprintf("%ld, %lld, %ld", tcp->u_arg[0],
438# if defined IA64 || defined X86_64 || defined ALPHA
439 (long long int) tcp->u_arg[1], tcp->u_arg[2]
440# else
441 (((long long int) tcp->u_arg[1]) << 32
442 | ((unsigned long *) tcp->u_arg)[2]),
443 tcp->u_arg[3]
444# endif
445 );
446 }
447 return 0;
448}
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000449#endif
450
John Hughes70623be2001-03-08 13:59:00 +0000451#if _LFS64_LARGEFILE || HAVE_LONG_LONG_OFF_T
John Hughesbdf48f52001-03-06 15:08:09 +0000452int
453sys_lseek64 (tcp)
454struct tcb *tcp;
455{
456 if (entering(tcp)) {
John Hughes5a826b82001-03-07 13:21:24 +0000457 long long offset;
458 ALIGN64 (tcp, 1); /* FreeBSD aligns off_t args */
John Hughes0c79e012001-03-08 14:40:06 +0000459 offset = LONG_LONG(tcp->u_arg [1], tcp->u_arg[2]);
John Hughesbdf48f52001-03-06 15:08:09 +0000460 if (tcp->u_arg[3] == SEEK_SET)
461 tprintf("%ld, %llu, ", tcp->u_arg[0], offset);
462 else
463 tprintf("%ld, %lld, ", tcp->u_arg[0], offset);
464 printxval(whence, tcp->u_arg[3], "SEEK_???");
465 }
466 return RVAL_LUDECIMAL;
467}
468#endif
469
John Hughes70623be2001-03-08 13:59:00 +0000470#ifndef HAVE_LONG_LONG_OFF_T
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000471int
472sys_truncate(tcp)
473struct tcb *tcp;
474{
475 if (entering(tcp)) {
476 printpath(tcp, tcp->u_arg[0]);
477 tprintf(", %lu", tcp->u_arg[1]);
478 }
479 return 0;
480}
John Hughes5a826b82001-03-07 13:21:24 +0000481#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000482
John Hughes70623be2001-03-08 13:59:00 +0000483#if _LFS64_LARGEFILE || HAVE_LONG_LONG_OFF_T
John Hughes96f51472001-03-06 16:50:41 +0000484int
485sys_truncate64(tcp)
486struct tcb *tcp;
487{
488 if (entering(tcp)) {
John Hughes5a826b82001-03-07 13:21:24 +0000489 ALIGN64 (tcp, 1);
John Hughes96f51472001-03-06 16:50:41 +0000490 printpath(tcp, tcp->u_arg[0]);
John Hughes0c79e012001-03-08 14:40:06 +0000491 tprintf(", %llu", LONG_LONG(tcp->u_arg[1],tcp->u_arg[2]));
John Hughes96f51472001-03-06 16:50:41 +0000492 }
493 return 0;
494}
495#endif
496
John Hughes70623be2001-03-08 13:59:00 +0000497#ifndef HAVE_LONG_LONG_OFF_T
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000498int
499sys_ftruncate(tcp)
500struct tcb *tcp;
501{
502 if (entering(tcp)) {
503 tprintf("%ld, %lu", tcp->u_arg[0], tcp->u_arg[1]);
504 }
505 return 0;
506}
John Hughes5a826b82001-03-07 13:21:24 +0000507#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000508
John Hughes70623be2001-03-08 13:59:00 +0000509#if _LFS64_LARGEFILE || HAVE_LONG_LONG_OFF_T
John Hughes96f51472001-03-06 16:50:41 +0000510int
511sys_ftruncate64(tcp)
512struct tcb *tcp;
513{
514 if (entering(tcp)) {
John Hughes5a826b82001-03-07 13:21:24 +0000515 ALIGN64 (tcp, 1);
John Hughes96f51472001-03-06 16:50:41 +0000516 tprintf("%ld, %llu", tcp->u_arg[0],
John Hughes0c79e012001-03-08 14:40:06 +0000517 LONG_LONG(tcp->u_arg[1] ,tcp->u_arg[2]));
John Hughes96f51472001-03-06 16:50:41 +0000518 }
519 return 0;
520}
521#endif
522
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000523/* several stats */
524
525static struct xlat modetypes[] = {
526 { S_IFREG, "S_IFREG" },
527 { S_IFSOCK, "S_IFSOCK" },
528 { S_IFIFO, "S_IFIFO" },
529 { S_IFLNK, "S_IFLNK" },
530 { S_IFDIR, "S_IFDIR" },
531 { S_IFBLK, "S_IFBLK" },
532 { S_IFCHR, "S_IFCHR" },
533 { 0, NULL },
534};
535
536static char *
537sprintmode(mode)
538int mode;
539{
540 static char buf[64];
541 char *s;
542
543 if ((mode & S_IFMT) == 0)
544 s = "";
545 else if ((s = xlookup(modetypes, mode & S_IFMT)) == NULL) {
546 sprintf(buf, "%#o", mode);
547 return buf;
548 }
549 sprintf(buf, "%s%s%s%s", s,
550 (mode & S_ISUID) ? "|S_ISUID" : "",
551 (mode & S_ISGID) ? "|S_ISGID" : "",
552 (mode & S_ISVTX) ? "|S_ISVTX" : "");
553 mode &= ~(S_IFMT|S_ISUID|S_ISGID|S_ISVTX);
554 if (mode)
555 sprintf(buf + strlen(buf), "|%#o", mode);
556 s = (*buf == '|') ? buf + 1 : buf;
557 return *s ? s : "0";
558}
559
560static char *
561sprinttime(t)
562time_t t;
563{
564 struct tm *tmp;
565 static char buf[32];
566
567 if (t == 0) {
568 sprintf(buf, "0");
569 return buf;
570 }
571 tmp = localtime(&t);
572 sprintf(buf, "%02d/%02d/%02d-%02d:%02d:%02d",
Wichert Akkerman3ed6dc22000-01-11 14:41:09 +0000573 tmp->tm_year + 1900, tmp->tm_mon + 1, tmp->tm_mday,
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000574 tmp->tm_hour, tmp->tm_min, tmp->tm_sec);
575 return buf;
576}
577
578#ifdef LINUXSPARC
579typedef struct {
580 int tv_sec;
581 int tv_nsec;
582} timestruct_t;
583
584struct solstat {
585 unsigned st_dev;
586 int st_pad1[3]; /* network id */
587 unsigned st_ino;
588 unsigned st_mode;
589 unsigned st_nlink;
590 unsigned st_uid;
591 unsigned st_gid;
592 unsigned st_rdev;
593 int st_pad2[2];
594 int st_size;
595 int st_pad3; /* st_size, off_t expansion */
596 timestruct_t st_atime;
597 timestruct_t st_mtime;
598 timestruct_t st_ctime;
599 int st_blksize;
600 int st_blocks;
601 char st_fstype[16];
602 int st_pad4[8]; /* expansion area */
603};
604
605static void
606printstatsol(tcp, addr)
607struct tcb *tcp;
Wichert Akkerman8b1b40c2000-02-03 21:58:30 +0000608long addr;
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000609{
610 struct solstat statbuf;
611
612 if (!addr) {
613 tprintf("NULL");
614 return;
615 }
616 if (syserror(tcp) || !verbose(tcp)) {
Wichert Akkerman8b1b40c2000-02-03 21:58:30 +0000617 tprintf("%#lx", addr);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000618 return;
619 }
620 if (umove(tcp, addr, &statbuf) < 0) {
621 tprintf("{...}");
622 return;
623 }
624 if (!abbrev(tcp)) {
625 tprintf("{st_dev=makedev(%lu, %lu), st_ino=%lu, st_mode=%s, ",
626 (unsigned long) ((statbuf.st_dev >> 18) & 0x3fff),
627 (unsigned long) (statbuf.st_dev & 0x3ffff),
628 (unsigned long) statbuf.st_ino,
629 sprintmode(statbuf.st_mode));
630 tprintf("st_nlink=%lu, st_uid=%lu, st_gid=%lu, ",
631 (unsigned long) statbuf.st_nlink,
632 (unsigned long) statbuf.st_uid,
633 (unsigned long) statbuf.st_gid);
634 tprintf("st_blksize=%lu, ", (unsigned long) statbuf.st_blksize);
635 tprintf("st_blocks=%lu, ", (unsigned long) statbuf.st_blocks);
636 }
637 else
638 tprintf("{st_mode=%s, ", sprintmode(statbuf.st_mode));
639 switch (statbuf.st_mode & S_IFMT) {
640 case S_IFCHR: case S_IFBLK:
641 tprintf("st_rdev=makedev(%lu, %lu), ",
642 (unsigned long) ((statbuf.st_rdev >> 18) & 0x3fff),
643 (unsigned long) (statbuf.st_rdev & 0x3ffff));
644 break;
645 default:
646 tprintf("st_size=%u, ", statbuf.st_size);
647 break;
648 }
649 if (!abbrev(tcp)) {
650 tprintf("st_atime=%s, ", sprinttime(statbuf.st_atime));
651 tprintf("st_mtime=%s, ", sprinttime(statbuf.st_mtime));
652 tprintf("st_ctime=%s}", sprinttime(statbuf.st_ctime));
653 }
654 else
655 tprintf("...}");
656}
Wichert Akkermanb859bea1999-04-18 22:50:50 +0000657#endif /* LINUXSPARC */
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000658
Michal Ludvig53b320f2002-09-23 13:30:09 +0000659struct xlat fileflags[] = {
John Hughesc0fc3fd2001-03-08 16:10:40 +0000660#ifdef FREEBSD
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +0000661 { UF_NODUMP, "UF_NODUMP" },
662 { UF_IMMUTABLE, "UF_IMMUTABLE" },
663 { UF_APPEND, "UF_APPEND" },
664 { UF_OPAQUE, "UF_OPAQUE" },
665 { UF_NOUNLINK, "UF_NOUNLINK" },
666 { SF_ARCHIVED, "SF_ARCHIVED" },
667 { SF_IMMUTABLE, "SF_IMMUTABLE" },
668 { SF_APPEND, "SF_APPEND" },
669 { SF_NOUNLINK, "SF_NOUNLINK" },
John Hughesc0fc3fd2001-03-08 16:10:40 +0000670#elif UNIXWARE >= 2
671#ifdef _S_ISMLD
672 { _S_ISMLD, "_S_ISMLD" },
673#endif
674#ifdef _S_ISMOUNTED
675 { _S_ISMOUNTED, "_S_ISMOUNTED" },
676#endif
677#endif
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +0000678 { 0, NULL },
679};
680
John Hughesc0fc3fd2001-03-08 16:10:40 +0000681#ifdef FREEBSD
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +0000682int
683sys_chflags(tcp)
684struct tcb *tcp;
685{
686 if (entering(tcp)) {
687 printpath(tcp, tcp->u_arg[0]);
688 tprintf(", ");
689 if (tcp->u_arg[1])
690 printflags(fileflags, tcp->u_arg[1]);
691 else
692 tprintf("0");
693 }
694 return 0;
695}
696
697int
698sys_fchflags(tcp)
699struct tcb *tcp;
700{
701 if (entering(tcp)) {
702 tprintf("%ld, ", tcp->u_arg[0]);
703 if (tcp->u_arg[1])
704 printflags(fileflags, tcp->u_arg[1]);
705 else
706 tprintf("0");
707 }
708 return 0;
709}
710#endif
711
John Hughes70623be2001-03-08 13:59:00 +0000712#ifndef HAVE_LONG_LONG_OFF_T
Wichert Akkerman328c5e71999-04-16 00:21:26 +0000713static void
714realprintstat(tcp, statbuf)
715struct tcb *tcp;
Wichert Akkerman328c5e71999-04-16 00:21:26 +0000716struct stat *statbuf;
Wichert Akkerman328c5e71999-04-16 00:21:26 +0000717{
718 if (!abbrev(tcp)) {
719 tprintf("{st_dev=makedev(%lu, %lu), st_ino=%lu, st_mode=%s, ",
720 (unsigned long) major(statbuf->st_dev),
721 (unsigned long) minor(statbuf->st_dev),
722 (unsigned long) statbuf->st_ino,
723 sprintmode(statbuf->st_mode));
724 tprintf("st_nlink=%lu, st_uid=%lu, st_gid=%lu, ",
725 (unsigned long) statbuf->st_nlink,
726 (unsigned long) statbuf->st_uid,
727 (unsigned long) statbuf->st_gid);
728#ifdef HAVE_ST_BLKSIZE
729 tprintf("st_blksize=%lu, ", (unsigned long) statbuf->st_blksize);
730#endif /* HAVE_ST_BLKSIZE */
731#ifdef HAVE_ST_BLOCKS
732 tprintf("st_blocks=%lu, ", (unsigned long) statbuf->st_blocks);
733#endif /* HAVE_ST_BLOCKS */
734 }
735 else
736 tprintf("{st_mode=%s, ", sprintmode(statbuf->st_mode));
737 switch (statbuf->st_mode & S_IFMT) {
738 case S_IFCHR: case S_IFBLK:
739#ifdef HAVE_ST_RDEV
740 tprintf("st_rdev=makedev(%lu, %lu), ",
741 (unsigned long) major(statbuf->st_rdev),
742 (unsigned long) minor(statbuf->st_rdev));
743#else /* !HAVE_ST_RDEV */
744 tprintf("st_size=makedev(%lu, %lu), ",
745 (unsigned long) major(statbuf->st_size),
746 (unsigned long) minor(statbuf->st_size));
747#endif /* !HAVE_ST_RDEV */
748 break;
749 default:
750 tprintf("st_size=%lu, ", statbuf->st_size);
751 break;
752 }
753 if (!abbrev(tcp)) {
754 tprintf("st_atime=%s, ", sprinttime(statbuf->st_atime));
755 tprintf("st_mtime=%s, ", sprinttime(statbuf->st_mtime));
John Hughesc0fc3fd2001-03-08 16:10:40 +0000756 tprintf("st_ctime=%s", sprinttime(statbuf->st_ctime));
757#if HAVE_ST_FLAGS
758 tprintf(", st_flags=");
759 if (statbuf->st_flags) {
760 printflags(fileflags, statbuf->st_flags);
761 } else
762 tprintf("0");
763#endif
764#if HAVE_ST_ACLCNT
765 tprintf(", st_aclcnt=%d", statbuf->st_aclcnt);
766#endif
767#if HAVE_ST_LEVEL
768 tprintf(", st_level=%ld", statbuf->st_level);
769#endif
770#if HAVE_ST_FSTYPE
771 tprintf(", st_fstype=%.*s",
772 (int) sizeof statbuf->st_fstype, statbuf->st_fstype);
773#endif
774#if HAVE_ST_GEN
775 tprintf(", st_gen=%u", statbuf->st_gen);
776#endif
777 tprintf("}");
Wichert Akkerman328c5e71999-04-16 00:21:26 +0000778 }
779 else
780 tprintf("...}");
781}
782
Nate Sammons771a6ff1999-04-05 22:39:31 +0000783
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000784static void
785printstat(tcp, addr)
786struct tcb *tcp;
Wichert Akkerman8b1b40c2000-02-03 21:58:30 +0000787long addr;
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000788{
Wichert Akkerman328c5e71999-04-16 00:21:26 +0000789 struct stat statbuf;
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000790
791#ifdef LINUXSPARC
792 if (current_personality == 1) {
793 printstatsol(tcp, addr);
794 return;
795 }
796#endif /* LINUXSPARC */
797
798 if (!addr) {
799 tprintf("NULL");
800 return;
801 }
802 if (syserror(tcp) || !verbose(tcp)) {
Wichert Akkerman8b1b40c2000-02-03 21:58:30 +0000803 tprintf("%#lx", addr);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000804 return;
805 }
806 if (umove(tcp, addr, &statbuf) < 0) {
807 tprintf("{...}");
808 return;
809 }
Wichert Akkerman328c5e71999-04-16 00:21:26 +0000810
811 realprintstat(tcp, &statbuf);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000812}
John Hughes70623be2001-03-08 13:59:00 +0000813#endif /* !HAVE_LONG_LONG_OFF_T */
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000814
Wichert Akkermanc7926982000-04-10 22:22:31 +0000815#ifdef HAVE_STAT64
Wichert Akkerman328c5e71999-04-16 00:21:26 +0000816static void
Ulrich Drepper7f02c4d1999-12-24 08:01:34 +0000817printstat64(tcp, addr)
818struct tcb *tcp;
Wichert Akkerman8b1b40c2000-02-03 21:58:30 +0000819long addr;
Ulrich Drepper7f02c4d1999-12-24 08:01:34 +0000820{
821 struct stat64 statbuf;
822
823#ifdef LINUXSPARC
824 if (current_personality == 1) {
825 printstatsol(tcp, addr);
826 return;
827 }
828#endif /* LINUXSPARC */
829
830 if (!addr) {
831 tprintf("NULL");
832 return;
833 }
834 if (syserror(tcp) || !verbose(tcp)) {
Wichert Akkerman8b1b40c2000-02-03 21:58:30 +0000835 tprintf("%#lx", addr);
Ulrich Drepper7f02c4d1999-12-24 08:01:34 +0000836 return;
837 }
838 if (umove(tcp, addr, &statbuf) < 0) {
839 tprintf("{...}");
840 return;
841 }
842
843 if (!abbrev(tcp)) {
Wichert Akkermand077c452000-08-10 18:16:15 +0000844#ifdef HAVE_LONG_LONG
845 tprintf("{st_dev=makedev(%lu, %lu), st_ino=%llu, st_mode=%s, ",
846#else
Ulrich Drepper7f02c4d1999-12-24 08:01:34 +0000847 tprintf("{st_dev=makedev(%lu, %lu), st_ino=%lu, st_mode=%s, ",
Wichert Akkermand077c452000-08-10 18:16:15 +0000848#endif
Ulrich Drepper7f02c4d1999-12-24 08:01:34 +0000849 (unsigned long) major(statbuf.st_dev),
850 (unsigned long) minor(statbuf.st_dev),
Wichert Akkermand077c452000-08-10 18:16:15 +0000851#ifdef HAVE_LONG_LONG
852 (unsigned long long) statbuf.st_ino,
853#else
Ulrich Drepper7f02c4d1999-12-24 08:01:34 +0000854 (unsigned long) statbuf.st_ino,
Wichert Akkermand077c452000-08-10 18:16:15 +0000855#endif
Ulrich Drepper7f02c4d1999-12-24 08:01:34 +0000856 sprintmode(statbuf.st_mode));
857 tprintf("st_nlink=%lu, st_uid=%lu, st_gid=%lu, ",
858 (unsigned long) statbuf.st_nlink,
859 (unsigned long) statbuf.st_uid,
860 (unsigned long) statbuf.st_gid);
861#ifdef HAVE_ST_BLKSIZE
862 tprintf("st_blksize=%lu, ",
863 (unsigned long) statbuf.st_blksize);
864#endif /* HAVE_ST_BLKSIZE */
865#ifdef HAVE_ST_BLOCKS
866 tprintf("st_blocks=%lu, ", (unsigned long) statbuf.st_blocks);
867#endif /* HAVE_ST_BLOCKS */
868 }
869 else
870 tprintf("{st_mode=%s, ", sprintmode(statbuf.st_mode));
871 switch (statbuf.st_mode & S_IFMT) {
872 case S_IFCHR: case S_IFBLK:
873#ifdef HAVE_ST_RDEV
874 tprintf("st_rdev=makedev(%lu, %lu), ",
875 (unsigned long) major(statbuf.st_rdev),
876 (unsigned long) minor(statbuf.st_rdev));
877#else /* !HAVE_ST_RDEV */
878 tprintf("st_size=makedev(%lu, %lu), ",
879 (unsigned long) major(statbuf.st_size),
880 (unsigned long) minor(statbuf.st_size));
881#endif /* !HAVE_ST_RDEV */
882 break;
883 default:
884 tprintf("st_size=%llu, ", statbuf.st_size);
885 break;
886 }
887 if (!abbrev(tcp)) {
888 tprintf("st_atime=%s, ", sprinttime(statbuf.st_atime));
889 tprintf("st_mtime=%s, ", sprinttime(statbuf.st_mtime));
John Hughesc0fc3fd2001-03-08 16:10:40 +0000890 tprintf("st_ctime=%s", sprinttime(statbuf.st_ctime));
891#if HAVE_ST_FLAGS
892 tprintf(", st_flags=");
John Hughesb8c9f772001-03-07 16:53:07 +0000893 if (statbuf.st_flags) {
894 printflags(fileflags, statbuf.st_flags);
895 } else
896 tprintf("0");
John Hughesc0fc3fd2001-03-08 16:10:40 +0000897#endif
898#if HAVE_ST_ACLCNT
899 tprintf(", st_aclcnt=%d", statbuf.st_aclcnt);
900#endif
901#if HAVE_ST_LEVEL
902 tprintf(", st_level=%ld", statbuf.st_level);
903#endif
904#if HAVE_ST_FSTYPE
905 tprintf(", st_fstype=%.*s",
906 (int) sizeof statbuf.st_fstype, statbuf.st_fstype);
907#endif
908#if HAVE_ST_GEN
909 tprintf(", st_gen=%u", statbuf.st_gen);
910#endif
911 tprintf("}");
Ulrich Drepper7f02c4d1999-12-24 08:01:34 +0000912 }
913 else
914 tprintf("...}");
915}
Wichert Akkermanc7926982000-04-10 22:22:31 +0000916#endif /* HAVE_STAT64 */
Ulrich Drepper7f02c4d1999-12-24 08:01:34 +0000917
Michal Ludvig10a88d02002-10-07 14:31:00 +0000918#if defined(LINUX) && !defined(IA64) && !defined(HPPA) && !defined(X86_64) \
919 && !defined(S390) && !defined(S390X)
Ulrich Drepper7f02c4d1999-12-24 08:01:34 +0000920static void
Wichert Akkerman328c5e71999-04-16 00:21:26 +0000921convertoldstat(oldbuf, newbuf)
Wichert Akkerman25d0c4f1999-04-18 19:35:42 +0000922const struct __old_kernel_stat *oldbuf;
923struct stat *newbuf;
Wichert Akkerman328c5e71999-04-16 00:21:26 +0000924{
925 newbuf->st_dev=oldbuf->st_dev;
926 newbuf->st_ino=oldbuf->st_ino;
927 newbuf->st_mode=oldbuf->st_mode;
928 newbuf->st_nlink=oldbuf->st_nlink;
929 newbuf->st_uid=oldbuf->st_uid;
930 newbuf->st_gid=oldbuf->st_gid;
931 newbuf->st_rdev=oldbuf->st_rdev;
932 newbuf->st_size=oldbuf->st_size;
933 newbuf->st_atime=oldbuf->st_atime;
934 newbuf->st_mtime=oldbuf->st_mtime;
935 newbuf->st_ctime=oldbuf->st_ctime;
936 newbuf->st_blksize=0; /* not supported in old_stat */
937 newbuf->st_blocks=0; /* not supported in old_stat */
938}
Wichert Akkerman328c5e71999-04-16 00:21:26 +0000939
940
Wichert Akkerman328c5e71999-04-16 00:21:26 +0000941static void
942printoldstat(tcp, addr)
943struct tcb *tcp;
Wichert Akkerman8b1b40c2000-02-03 21:58:30 +0000944long addr;
Wichert Akkerman328c5e71999-04-16 00:21:26 +0000945{
Wichert Akkerman25d0c4f1999-04-18 19:35:42 +0000946 struct __old_kernel_stat statbuf;
947 struct stat newstatbuf;
Wichert Akkerman328c5e71999-04-16 00:21:26 +0000948
949#ifdef LINUXSPARC
950 if (current_personality == 1) {
951 printstatsol(tcp, addr);
952 return;
953 }
954#endif /* LINUXSPARC */
955
956 if (!addr) {
957 tprintf("NULL");
958 return;
959 }
960 if (syserror(tcp) || !verbose(tcp)) {
Wichert Akkerman8b1b40c2000-02-03 21:58:30 +0000961 tprintf("%#lx", addr);
Wichert Akkerman328c5e71999-04-16 00:21:26 +0000962 return;
963 }
964 if (umove(tcp, addr, &statbuf) < 0) {
965 tprintf("{...}");
966 return;
967 }
968
969 convertoldstat(&statbuf, &newstatbuf);
970 realprintstat(tcp, &newstatbuf);
971}
Michal Ludvig10a88d02002-10-07 14:31:00 +0000972#endif /* LINUX && !IA64 && !HPPA && !X86_64 && !S390 && !S390X */
Wichert Akkerman328c5e71999-04-16 00:21:26 +0000973
John Hughes70623be2001-03-08 13:59:00 +0000974#ifndef HAVE_LONG_LONG_OFF_T
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000975int
976sys_stat(tcp)
977struct tcb *tcp;
978{
979 if (entering(tcp)) {
980 printpath(tcp, tcp->u_arg[0]);
981 tprintf(", ");
982 } else {
983 printstat(tcp, tcp->u_arg[1]);
984 }
985 return 0;
986}
John Hughesb8c9f772001-03-07 16:53:07 +0000987#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000988
Wichert Akkerman328c5e71999-04-16 00:21:26 +0000989int
Ulrich Drepper7f02c4d1999-12-24 08:01:34 +0000990sys_stat64(tcp)
991struct tcb *tcp;
992{
993#ifdef HAVE_STAT64
994 if (entering(tcp)) {
995 printpath(tcp, tcp->u_arg[0]);
996 tprintf(", ");
997 } else {
998 printstat64(tcp, tcp->u_arg[1]);
999 }
1000 return 0;
1001#else
1002 return printargs(tcp);
1003#endif
1004}
1005
Michal Ludvig53b320f2002-09-23 13:30:09 +00001006#ifdef LINUX
Michal Ludvig10a88d02002-10-07 14:31:00 +00001007# if !defined(IA64) && !defined(HPPA) && !defined(X86_64) \
1008 && !defined(S390) && !defined(S390X)
Ulrich Drepper7f02c4d1999-12-24 08:01:34 +00001009int
Wichert Akkerman328c5e71999-04-16 00:21:26 +00001010sys_oldstat(tcp)
1011struct tcb *tcp;
1012{
1013 if (entering(tcp)) {
1014 printpath(tcp, tcp->u_arg[0]);
1015 tprintf(", ");
1016 } else {
1017 printoldstat(tcp, tcp->u_arg[1]);
1018 }
1019 return 0;
1020}
Wichert Akkerman7b3346b2001-10-09 23:47:38 +00001021# endif /* !IA64 && !HPPA*/
Michal Ludvig53b320f2002-09-23 13:30:09 +00001022#endif /* LINUX */
Wichert Akkerman328c5e71999-04-16 00:21:26 +00001023
John Hughes70623be2001-03-08 13:59:00 +00001024#ifndef HAVE_LONG_LONG_OFF_T
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001025int
1026sys_fstat(tcp)
1027struct tcb *tcp;
1028{
1029 if (entering(tcp))
1030 tprintf("%ld, ", tcp->u_arg[0]);
1031 else {
1032 printstat(tcp, tcp->u_arg[1]);
1033 }
1034 return 0;
1035}
John Hughesb8c9f772001-03-07 16:53:07 +00001036#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001037
Wichert Akkerman328c5e71999-04-16 00:21:26 +00001038int
Ulrich Drepper7f02c4d1999-12-24 08:01:34 +00001039sys_fstat64(tcp)
1040struct tcb *tcp;
1041{
1042#ifdef HAVE_STAT64
1043 if (entering(tcp))
1044 tprintf("%ld, ", tcp->u_arg[0]);
1045 else {
1046 printstat64(tcp, tcp->u_arg[1]);
1047 }
1048 return 0;
1049#else
1050 return printargs(tcp);
1051#endif
1052}
1053
Michal Ludvig53b320f2002-09-23 13:30:09 +00001054#ifdef LINUX
Michal Ludvig10a88d02002-10-07 14:31:00 +00001055# if !defined(IA64) && !defined(HPPA) && !defined(X86_64) \
1056 && !defined(S390) && !defined(S390X)
Ulrich Drepper7f02c4d1999-12-24 08:01:34 +00001057int
Wichert Akkerman328c5e71999-04-16 00:21:26 +00001058sys_oldfstat(tcp)
1059struct tcb *tcp;
1060{
1061 if (entering(tcp))
1062 tprintf("%ld, ", tcp->u_arg[0]);
1063 else {
1064 printoldstat(tcp, tcp->u_arg[1]);
1065 }
1066 return 0;
1067}
Michal Ludvig10a88d02002-10-07 14:31:00 +00001068# endif /* !IA64 && !HPPA && !X86_64 && !S390 && !S390X */
Wichert Akkerman328c5e71999-04-16 00:21:26 +00001069#endif
1070
John Hughes70623be2001-03-08 13:59:00 +00001071#ifndef HAVE_LONG_LONG_OFF_T
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001072int
1073sys_lstat(tcp)
1074struct tcb *tcp;
1075{
1076 if (entering(tcp)) {
1077 printpath(tcp, tcp->u_arg[0]);
1078 tprintf(", ");
1079 } else {
1080 printstat(tcp, tcp->u_arg[1]);
1081 }
1082 return 0;
1083}
John Hughesb8c9f772001-03-07 16:53:07 +00001084#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001085
Wichert Akkerman328c5e71999-04-16 00:21:26 +00001086int
Ulrich Drepper7f02c4d1999-12-24 08:01:34 +00001087sys_lstat64(tcp)
1088struct tcb *tcp;
1089{
1090#ifdef HAVE_STAT64
1091 if (entering(tcp)) {
1092 printpath(tcp, tcp->u_arg[0]);
1093 tprintf(", ");
1094 } else {
1095 printstat64(tcp, tcp->u_arg[1]);
1096 }
1097 return 0;
1098#else
1099 return printargs(tcp);
1100#endif
1101}
1102
Michal Ludvig53b320f2002-09-23 13:30:09 +00001103#ifdef LINUX
Michal Ludvig10a88d02002-10-07 14:31:00 +00001104# if !defined(IA64) && !defined(HPPA) && !defined(X86_64) \
1105 && !defined(S390) && !defined(S390X)
Ulrich Drepper7f02c4d1999-12-24 08:01:34 +00001106int
Wichert Akkerman328c5e71999-04-16 00:21:26 +00001107sys_oldlstat(tcp)
1108struct tcb *tcp;
1109{
1110 if (entering(tcp)) {
1111 printpath(tcp, tcp->u_arg[0]);
1112 tprintf(", ");
1113 } else {
1114 printoldstat(tcp, tcp->u_arg[1]);
1115 }
1116 return 0;
1117}
Michal Ludvig10a88d02002-10-07 14:31:00 +00001118# endif /* !IA64 && !HPPA && !X86_64 && !S390 && !S390X */
Wichert Akkerman328c5e71999-04-16 00:21:26 +00001119#endif
1120
1121
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001122#if defined(SVR4) || defined(LINUXSPARC)
1123
1124int
1125sys_xstat(tcp)
1126struct tcb *tcp;
1127{
1128 if (entering(tcp)) {
1129 tprintf("%ld, ", tcp->u_arg[0]);
1130 printpath(tcp, tcp->u_arg[1]);
1131 tprintf(", ");
1132 } else {
John Hughes8fe2c982001-03-06 09:45:18 +00001133#ifdef _STAT64_VER
1134 if (tcp->u_arg[0] == _STAT64_VER)
1135 printstat64 (tcp, tcp->u_arg[2]);
1136 else
1137#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001138 printstat(tcp, tcp->u_arg[2]);
1139 }
1140 return 0;
1141}
1142
1143int
1144sys_fxstat(tcp)
1145struct tcb *tcp;
1146{
1147 if (entering(tcp))
1148 tprintf("%ld, %ld, ", tcp->u_arg[0], tcp->u_arg[1]);
1149 else {
John Hughes8fe2c982001-03-06 09:45:18 +00001150#ifdef _STAT64_VER
1151 if (tcp->u_arg[0] == _STAT64_VER)
1152 printstat64 (tcp, tcp->u_arg[2]);
1153 else
1154#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001155 printstat(tcp, tcp->u_arg[2]);
1156 }
1157 return 0;
1158}
1159
1160int
1161sys_lxstat(tcp)
1162struct tcb *tcp;
1163{
1164 if (entering(tcp)) {
1165 tprintf("%ld, ", tcp->u_arg[0]);
1166 printpath(tcp, tcp->u_arg[1]);
1167 tprintf(", ");
1168 } else {
John Hughes8fe2c982001-03-06 09:45:18 +00001169#ifdef _STAT64_VER
1170 if (tcp->u_arg[0] == _STAT64_VER)
1171 printstat64 (tcp, tcp->u_arg[2]);
1172 else
1173#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001174 printstat(tcp, tcp->u_arg[2]);
1175 }
1176 return 0;
1177}
1178
1179int
1180sys_xmknod(tcp)
1181struct tcb *tcp;
1182{
1183 int mode = tcp->u_arg[2];
1184
1185 if (entering(tcp)) {
1186 tprintf("%ld, ", tcp->u_arg[0]);
1187 printpath(tcp, tcp->u_arg[1]);
1188 tprintf(", %s", sprintmode(mode));
1189 switch (mode & S_IFMT) {
1190 case S_IFCHR: case S_IFBLK:
1191#ifdef LINUXSPARC
1192 tprintf(", makedev(%lu, %lu)",
1193 (unsigned long) ((tcp->u_arg[3] >> 18) & 0x3fff),
1194 (unsigned long) (tcp->u_arg[3] & 0x3ffff));
Roland McGrath186c5ac2002-12-15 23:58:23 +00001195#else
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001196 tprintf(", makedev(%lu, %lu)",
1197 (unsigned long) major(tcp->u_arg[3]),
1198 (unsigned long) minor(tcp->u_arg[3]));
Roland McGrath186c5ac2002-12-15 23:58:23 +00001199#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001200 break;
1201 default:
1202 break;
1203 }
1204 }
1205 return 0;
1206}
1207
Wichert Akkerman8829a551999-06-11 13:18:40 +00001208#ifdef HAVE_SYS_ACL_H
1209
1210#include <sys/acl.h>
1211
1212struct xlat aclcmds[] = {
Wichert Akkermane4aafd41999-11-26 09:54:08 +00001213#ifdef SETACL
Wichert Akkerman8829a551999-06-11 13:18:40 +00001214 { SETACL, "SETACL" },
Wichert Akkermane4aafd41999-11-26 09:54:08 +00001215#endif
1216#ifdef GETACL
Wichert Akkerman8829a551999-06-11 13:18:40 +00001217 { GETACL, "GETACL" },
Wichert Akkermane4aafd41999-11-26 09:54:08 +00001218#endif
1219#ifdef GETACLCNT
Wichert Akkerman8829a551999-06-11 13:18:40 +00001220 { GETACLCNT, "GETACLCNT" },
Wichert Akkermane4aafd41999-11-26 09:54:08 +00001221#endif
1222#ifdef ACL_GET
1223 { ACL_GET, "ACL_GET" },
Roland McGrath186c5ac2002-12-15 23:58:23 +00001224#endif
Wichert Akkermane4aafd41999-11-26 09:54:08 +00001225#ifdef ACL_SET
1226 { ACL_SET, "ACL_SET" },
Roland McGrath186c5ac2002-12-15 23:58:23 +00001227#endif
Wichert Akkermane4aafd41999-11-26 09:54:08 +00001228#ifdef ACL_CNT
1229 { ACL_CNT, "ACL_CNT" },
Roland McGrath186c5ac2002-12-15 23:58:23 +00001230#endif
Wichert Akkerman8829a551999-06-11 13:18:40 +00001231 { 0, NULL },
1232};
1233
1234int
1235sys_acl(tcp)
1236struct tcb *tcp;
1237{
1238 if (entering(tcp)) {
1239 printpath(tcp, tcp->u_arg[0]);
1240 tprintf(", ");
1241 printxval(aclcmds, tcp->u_arg[1], "???ACL???");
1242 tprintf(", %ld", tcp->u_arg[2]);
1243 /*
1244 * FIXME - dump out the list of aclent_t's pointed to
1245 * by "tcp->u_arg[3]" if it's not NULL.
1246 */
1247 if (tcp->u_arg[3])
1248 tprintf(", %#lx", tcp->u_arg[3]);
1249 else
1250 tprintf(", NULL");
1251 }
1252 return 0;
1253}
1254
1255
1256int
1257sys_facl(tcp)
1258struct tcb *tcp;
1259{
1260 if (entering(tcp)) {
1261 tprintf("%ld, ", tcp->u_arg[0]);
1262 printxval(aclcmds, tcp->u_arg[1], "???ACL???");
1263 tprintf(", %ld", tcp->u_arg[2]);
1264 /*
1265 * FIXME - dump out the list of aclent_t's pointed to
1266 * by "tcp->u_arg[3]" if it's not NULL.
1267 */
1268 if (tcp->u_arg[3])
1269 tprintf(", %#lx", tcp->u_arg[3]);
1270 else
1271 tprintf(", NULL");
1272 }
1273 return 0;
1274}
1275
Wichert Akkermane4aafd41999-11-26 09:54:08 +00001276
1277struct xlat aclipc[] = {
1278#ifdef IPC_SHM
1279 { IPC_SHM, "IPC_SHM" },
Roland McGrath186c5ac2002-12-15 23:58:23 +00001280#endif
Wichert Akkermane4aafd41999-11-26 09:54:08 +00001281#ifdef IPC_SEM
1282 { IPC_SEM, "IPC_SEM" },
Roland McGrath186c5ac2002-12-15 23:58:23 +00001283#endif
Wichert Akkermane4aafd41999-11-26 09:54:08 +00001284#ifdef IPC_MSG
1285 { IPC_MSG, "IPC_MSG" },
Roland McGrath186c5ac2002-12-15 23:58:23 +00001286#endif
Wichert Akkermane4aafd41999-11-26 09:54:08 +00001287 { 0, NULL },
1288};
1289
1290
1291int
1292sys_aclipc(tcp)
1293struct tcb *tcp;
1294{
1295 if (entering(tcp)) {
1296 printxval(aclipc, tcp->u_arg[0], "???IPC???");
1297 tprintf(", %#lx, ", tcp->u_arg[1]);
1298 printxval(aclcmds, tcp->u_arg[2], "???ACL???");
1299 tprintf(", %ld", tcp->u_arg[3]);
1300 /*
1301 * FIXME - dump out the list of aclent_t's pointed to
1302 * by "tcp->u_arg[4]" if it's not NULL.
1303 */
1304 if (tcp->u_arg[4])
1305 tprintf(", %#lx", tcp->u_arg[4]);
1306 else
1307 tprintf(", NULL");
1308 }
1309 return 0;
1310}
1311
1312
1313
Wichert Akkerman8829a551999-06-11 13:18:40 +00001314#endif /* HAVE_SYS_ACL_H */
1315
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001316#endif /* SVR4 || LINUXSPARC */
1317
Michal Ludvig53b320f2002-09-23 13:30:09 +00001318#ifdef LINUX
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001319
1320static struct xlat fsmagic[] = {
Wichert Akkerman43a74822000-06-27 17:33:32 +00001321 { 0x73757245, "CODA_SUPER_MAGIC" },
1322 { 0x012ff7b7, "COH_SUPER_MAGIC" },
1323 { 0x1373, "DEVFS_SUPER_MAGIC" },
1324 { 0x1cd1, "DEVPTS_SUPER_MAGIC" },
1325 { 0x414A53, "EFS_SUPER_MAGIC" },
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001326 { 0xef51, "EXT2_OLD_SUPER_MAGIC" },
1327 { 0xef53, "EXT2_SUPER_MAGIC" },
1328 { 0x137d, "EXT_SUPER_MAGIC" },
Wichert Akkerman43a74822000-06-27 17:33:32 +00001329 { 0xf995e849, "HPFS_SUPER_MAGIC" },
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001330 { 0x9660, "ISOFS_SUPER_MAGIC" },
1331 { 0x137f, "MINIX_SUPER_MAGIC" },
1332 { 0x138f, "MINIX_SUPER_MAGIC2" },
Wichert Akkerman2e2553a1999-05-09 00:29:58 +00001333 { 0x2468, "MINIX2_SUPER_MAGIC" },
1334 { 0x2478, "MINIX2_SUPER_MAGIC2" },
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001335 { 0x4d44, "MSDOS_SUPER_MAGIC" },
Wichert Akkerman43a74822000-06-27 17:33:32 +00001336 { 0x564c, "NCP_SUPER_MAGIC" },
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001337 { 0x6969, "NFS_SUPER_MAGIC" },
1338 { 0x9fa0, "PROC_SUPER_MAGIC" },
Wichert Akkerman43a74822000-06-27 17:33:32 +00001339 { 0x002f, "QNX4_SUPER_MAGIC" },
1340 { 0x52654973, "REISERFS_SUPER_MAGIC" },
1341 { 0x02011994, "SHMFS_SUPER_MAGIC" },
1342 { 0x517b, "SMB_SUPER_MAGIC" },
1343 { 0x012ff7b6, "SYSV2_SUPER_MAGIC" },
1344 { 0x012ff7b5, "SYSV4_SUPER_MAGIC" },
1345 { 0x00011954, "UFS_MAGIC" },
1346 { 0x54190100, "UFS_CIGAM" },
1347 { 0x012ff7b4, "XENIX_SUPER_MAGIC" },
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001348 { 0x012fd16d, "XIAFS_SUPER_MAGIC" },
1349 { 0, NULL },
1350};
1351
Michal Ludvig53b320f2002-09-23 13:30:09 +00001352#endif /* LINUX */
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001353
1354#ifndef SVR4
1355
1356static char *
1357sprintfstype(magic)
1358int magic;
1359{
1360 static char buf[32];
Michal Ludvig53b320f2002-09-23 13:30:09 +00001361#ifdef LINUX
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001362 char *s;
1363
1364 s = xlookup(fsmagic, magic);
1365 if (s) {
1366 sprintf(buf, "\"%s\"", s);
1367 return buf;
1368 }
Michal Ludvig53b320f2002-09-23 13:30:09 +00001369#endif /* LINUX */
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001370 sprintf(buf, "%#x", magic);
1371 return buf;
1372}
1373
1374static void
1375printstatfs(tcp, addr)
1376struct tcb *tcp;
1377long addr;
1378{
1379 struct statfs statbuf;
1380
1381 if (syserror(tcp) || !verbose(tcp)) {
1382 tprintf("%#lx", addr);
1383 return;
1384 }
1385 if (umove(tcp, addr, &statbuf) < 0) {
1386 tprintf("{...}");
1387 return;
1388 }
1389#ifdef ALPHA
1390
1391 tprintf("{f_type=%s, f_fbsize=%u, f_blocks=%u, f_bfree=%u, ",
1392 sprintfstype(statbuf.f_type),
1393 statbuf.f_bsize, statbuf.f_blocks, statbuf.f_bfree);
Wichert Akkerman2e2553a1999-05-09 00:29:58 +00001394 tprintf("f_bavail=%u, f_files=%u, f_ffree=%u, f_namelen=%u",
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001395 statbuf.f_bavail,statbuf.f_files, statbuf.f_ffree, statbuf.f_namelen);
1396#else /* !ALPHA */
1397 tprintf("{f_type=%s, f_bsize=%lu, f_blocks=%lu, f_bfree=%lu, ",
1398 sprintfstype(statbuf.f_type),
Nate Sammons5c74d201999-04-06 01:37:51 +00001399 (unsigned long)statbuf.f_bsize,
1400 (unsigned long)statbuf.f_blocks,
1401 (unsigned long)statbuf.f_bfree);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001402 tprintf("f_files=%lu, f_ffree=%lu",
Nate Sammons5c74d201999-04-06 01:37:51 +00001403 (unsigned long)statbuf.f_files,
1404 (unsigned long)statbuf.f_ffree);
Michal Ludvig53b320f2002-09-23 13:30:09 +00001405#ifdef LINUX
Wichert Akkerman2e2553a1999-05-09 00:29:58 +00001406 tprintf(", f_namelen=%lu", (unsigned long)statbuf.f_namelen);
Michal Ludvig53b320f2002-09-23 13:30:09 +00001407#endif /* LINUX */
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001408#endif /* !ALPHA */
1409 tprintf("}");
1410}
1411
1412int
1413sys_statfs(tcp)
1414struct tcb *tcp;
1415{
1416 if (entering(tcp)) {
1417 printpath(tcp, tcp->u_arg[0]);
1418 tprintf(", ");
1419 } else {
1420 printstatfs(tcp, tcp->u_arg[1]);
1421 }
1422 return 0;
1423}
1424
1425int
1426sys_fstatfs(tcp)
1427struct tcb *tcp;
1428{
1429 if (entering(tcp)) {
1430 tprintf("%lu, ", tcp->u_arg[0]);
1431 } else {
1432 printstatfs(tcp, tcp->u_arg[1]);
1433 }
1434 return 0;
1435}
1436
Michal Ludvig53b320f2002-09-23 13:30:09 +00001437#if defined(LINUX) && defined(__alpha)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001438
1439int
1440osf_statfs(tcp)
1441struct tcb *tcp;
1442{
1443 if (entering(tcp)) {
1444 printpath(tcp, tcp->u_arg[0]);
1445 tprintf(", ");
1446 } else {
1447 printstatfs(tcp, tcp->u_arg[1]);
1448 tprintf(", %lu", tcp->u_arg[2]);
1449 }
1450 return 0;
1451}
1452
1453int
1454osf_fstatfs(tcp)
1455struct tcb *tcp;
1456{
1457 if (entering(tcp)) {
1458 tprintf("%lu, ", tcp->u_arg[0]);
1459 } else {
1460 printstatfs(tcp, tcp->u_arg[1]);
1461 tprintf(", %lu", tcp->u_arg[2]);
1462 }
1463 return 0;
1464}
Michal Ludvig53b320f2002-09-23 13:30:09 +00001465#endif /* LINUX && __alpha */
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001466
1467#endif /* !SVR4 */
1468
1469#ifdef SUNOS4
1470
1471int
1472sys_ustat(tcp)
1473struct tcb *tcp;
1474{
1475 struct ustat statbuf;
1476
1477 if (entering(tcp)) {
1478 tprintf("makedev(%lu, %lu), ",
1479 (long) major(tcp->u_arg[0]),
1480 (long) minor(tcp->u_arg[0]));
1481 }
1482 else {
1483 if (syserror(tcp) || !verbose(tcp))
1484 tprintf("%#lx", tcp->u_arg[1]);
1485 else if (umove(tcp, tcp->u_arg[1], &statbuf) < 0)
1486 tprintf("{...}");
1487 else {
1488 tprintf("{f_tfree=%lu, f_tinode=%lu, ",
1489 statbuf.f_tfree, statbuf.f_tinode);
1490 tprintf("f_fname=\"%.*s\", ",
1491 (int) sizeof(statbuf.f_fname),
1492 statbuf.f_fname);
1493 tprintf("f_fpack=\"%.*s\"}",
1494 (int) sizeof(statbuf.f_fpack),
1495 statbuf.f_fpack);
1496 }
1497 }
1498 return 0;
1499}
1500
1501#endif /* SUNOS4 */
1502
Wichert Akkermanc7926982000-04-10 22:22:31 +00001503int
1504sys_pivotroot(tcp)
1505struct tcb *tcp;
1506{
1507 if (entering(tcp)) {
1508 printpath(tcp, tcp->u_arg[0]);
1509 tprintf(", ");
1510 printpath(tcp, tcp->u_arg[1]);
1511 }
1512 return 0;
1513}
1514
1515
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001516/* directory */
1517int
1518sys_chdir(tcp)
1519struct tcb *tcp;
1520{
1521 if (entering(tcp)) {
1522 printpath(tcp, tcp->u_arg[0]);
1523 }
1524 return 0;
1525}
1526
1527int
1528sys_mkdir(tcp)
1529struct tcb *tcp;
1530{
1531 if (entering(tcp)) {
1532 printpath(tcp, tcp->u_arg[0]);
1533 tprintf(", %#lo", tcp->u_arg[1]);
1534 }
1535 return 0;
1536}
1537
1538int
1539sys_rmdir(tcp)
1540struct tcb *tcp;
1541{
1542 if (entering(tcp)) {
1543 printpath(tcp, tcp->u_arg[0]);
1544 }
1545 return 0;
1546}
1547
1548int
1549sys_fchdir(tcp)
1550struct tcb *tcp;
1551{
1552 if (entering(tcp)) {
1553 tprintf("%ld", tcp->u_arg[0]);
1554 }
1555 return 0;
1556}
1557
1558int
1559sys_chroot(tcp)
1560struct tcb *tcp;
1561{
1562 if (entering(tcp)) {
1563 printpath(tcp, tcp->u_arg[0]);
1564 }
1565 return 0;
1566}
1567
1568int
1569sys_fchroot(tcp)
1570struct tcb *tcp;
1571{
1572 if (entering(tcp)) {
1573 tprintf("%ld", tcp->u_arg[0]);
1574 }
1575 return 0;
1576}
1577
1578int
1579sys_link(tcp)
1580struct tcb *tcp;
1581{
1582 if (entering(tcp)) {
1583 printpath(tcp, tcp->u_arg[0]);
1584 tprintf(", ");
1585 printpath(tcp, tcp->u_arg[1]);
1586 }
1587 return 0;
1588}
1589
1590int
1591sys_unlink(tcp)
1592struct tcb *tcp;
1593{
1594 if (entering(tcp)) {
1595 printpath(tcp, tcp->u_arg[0]);
1596 }
1597 return 0;
1598}
1599
1600int
1601sys_symlink(tcp)
1602struct tcb *tcp;
1603{
1604 if (entering(tcp)) {
1605 printpath(tcp, tcp->u_arg[0]);
1606 tprintf(", ");
1607 printpath(tcp, tcp->u_arg[1]);
1608 }
1609 return 0;
1610}
1611
1612int
1613sys_readlink(tcp)
1614struct tcb *tcp;
1615{
1616 if (entering(tcp)) {
1617 printpath(tcp, tcp->u_arg[0]);
1618 tprintf(", ");
1619 } else {
1620 if (syserror(tcp))
1621 tprintf("%#lx", tcp->u_arg[1]);
1622 else
1623 printpathn(tcp, tcp->u_arg[1], tcp->u_rval);
1624 tprintf(", %lu", tcp->u_arg[2]);
1625 }
1626 return 0;
1627}
1628
1629int
1630sys_rename(tcp)
1631struct tcb *tcp;
1632{
1633 if (entering(tcp)) {
1634 printpath(tcp, tcp->u_arg[0]);
1635 tprintf(", ");
1636 printpath(tcp, tcp->u_arg[1]);
1637 }
1638 return 0;
1639}
1640
1641int
1642sys_chown(tcp)
1643struct tcb *tcp;
1644{
1645 if (entering(tcp)) {
1646 printpath(tcp, tcp->u_arg[0]);
1647 tprintf(", %lu, %lu", tcp->u_arg[1], tcp->u_arg[2]);
1648 }
1649 return 0;
1650}
1651
1652int
1653sys_fchown(tcp)
1654struct tcb *tcp;
1655{
1656 if (entering(tcp)) {
1657 tprintf("%ld, %lu, %lu",
1658 tcp->u_arg[0], tcp->u_arg[1], tcp->u_arg[2]);
1659 }
1660 return 0;
1661}
1662
1663int
1664sys_chmod(tcp)
1665struct tcb *tcp;
1666{
1667 if (entering(tcp)) {
1668 printpath(tcp, tcp->u_arg[0]);
1669 tprintf(", %#lo", tcp->u_arg[1]);
1670 }
1671 return 0;
1672}
1673
1674int
1675sys_fchmod(tcp)
1676struct tcb *tcp;
1677{
1678 if (entering(tcp)) {
1679 tprintf("%ld, %#lo", tcp->u_arg[0], tcp->u_arg[1]);
1680 }
1681 return 0;
1682}
1683
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +00001684#ifdef ALPHA
1685int
1686sys_osf_utimes(tcp)
1687struct tcb *tcp;
1688{
1689 if (entering(tcp)) {
1690 printpath(tcp, tcp->u_arg[0]);
1691 tprintf(", ");
1692 printtv32(tcp, tcp->u_arg[1]);
1693 }
1694 return 0;
1695}
1696#endif
1697
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001698int
1699sys_utimes(tcp)
1700struct tcb *tcp;
1701{
1702 if (entering(tcp)) {
1703 printpath(tcp, tcp->u_arg[0]);
1704 tprintf(", ");
1705 printtv(tcp, tcp->u_arg[1]);
1706 }
1707 return 0;
1708}
1709
1710int
1711sys_utime(tcp)
1712struct tcb *tcp;
1713{
1714 long ut[2];
1715
1716 if (entering(tcp)) {
1717 printpath(tcp, tcp->u_arg[0]);
1718 tprintf(", ");
1719 if (!tcp->u_arg[1])
1720 tprintf("NULL");
1721 else if (!verbose(tcp))
1722 tprintf("%#lx", tcp->u_arg[1]);
1723 else if (umoven(tcp, tcp->u_arg[1], sizeof ut,
1724 (char *) ut) < 0)
1725 tprintf("[?, ?]");
1726 else {
1727 tprintf("[%s,", sprinttime(ut[0]));
1728 tprintf(" %s]", sprinttime(ut[1]));
1729 }
1730 }
1731 return 0;
1732}
1733
1734int
1735sys_mknod(tcp)
1736struct tcb *tcp;
1737{
1738 int mode = tcp->u_arg[1];
1739
1740 if (entering(tcp)) {
1741 printpath(tcp, tcp->u_arg[0]);
1742 tprintf(", %s", sprintmode(mode));
1743 switch (mode & S_IFMT) {
1744 case S_IFCHR: case S_IFBLK:
1745#ifdef LINUXSPARC
1746 if (current_personality == 1)
1747 tprintf(", makedev(%lu, %lu)",
1748 (unsigned long) ((tcp->u_arg[2] >> 18) & 0x3fff),
1749 (unsigned long) (tcp->u_arg[2] & 0x3ffff));
1750 else
Roland McGrath186c5ac2002-12-15 23:58:23 +00001751#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001752 tprintf(", makedev(%lu, %lu)",
1753 (unsigned long) major(tcp->u_arg[2]),
1754 (unsigned long) minor(tcp->u_arg[2]));
1755 break;
1756 default:
1757 break;
1758 }
1759 }
1760 return 0;
1761}
1762
1763int
1764sys_mkfifo(tcp)
1765struct tcb *tcp;
1766{
1767 if (entering(tcp)) {
1768 printpath(tcp, tcp->u_arg[0]);
1769 tprintf(", %#lo", tcp->u_arg[1]);
1770 }
1771 return 0;
1772}
1773
1774int
1775sys_fsync(tcp)
1776struct tcb *tcp;
1777{
1778 if (entering(tcp)) {
1779 tprintf("%ld", tcp->u_arg[0]);
1780 }
1781 return 0;
1782}
1783
Michal Ludvig53b320f2002-09-23 13:30:09 +00001784#ifdef LINUX
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001785
1786static void
1787printdir(tcp, addr)
1788struct tcb *tcp;
1789long addr;
1790{
1791 struct dirent d;
1792
1793 if (!verbose(tcp)) {
1794 tprintf("%#lx", addr);
1795 return;
1796 }
1797 if (umove(tcp, addr, &d) < 0) {
1798 tprintf("{...}");
1799 return;
1800 }
1801 tprintf("{d_ino=%ld, ", (unsigned long) d.d_ino);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001802 tprintf("d_name=");
1803 printpathn(tcp, (long) ((struct dirent *) addr)->d_name, d.d_reclen);
1804 tprintf("}");
1805}
1806
1807int
1808sys_readdir(tcp)
1809struct tcb *tcp;
1810{
1811 if (entering(tcp)) {
1812 tprintf("%lu, ", tcp->u_arg[0]);
1813 } else {
1814 if (syserror(tcp) || tcp->u_rval == 0 || !verbose(tcp))
1815 tprintf("%#lx", tcp->u_arg[1]);
1816 else
1817 printdir(tcp, tcp->u_arg[1]);
1818 /* Not much point in printing this out, it is always 1. */
1819 if (tcp->u_arg[2] != 1)
1820 tprintf(", %lu", tcp->u_arg[2]);
1821 }
1822 return 0;
1823}
1824
Michal Ludvig53b320f2002-09-23 13:30:09 +00001825#endif /* LINUX */
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001826
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +00001827#ifdef FREEBSD
1828struct xlat direnttypes[] = {
1829 { DT_FIFO, "DT_FIFO" },
1830 { DT_CHR, "DT_CHR" },
1831 { DT_DIR, "DT_DIR" },
1832 { DT_BLK, "DT_BLK" },
1833 { DT_REG, "DT_REG" },
1834 { DT_LNK, "DT_LNK" },
1835 { DT_SOCK, "DT_SOCK" },
1836 { DT_WHT, "DT_WHT" },
1837 { 0, NULL },
1838};
1839
1840#endif
1841
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001842int
1843sys_getdents(tcp)
1844struct tcb *tcp;
1845{
1846 int i, len, dents = 0;
1847 char *buf;
1848
1849 if (entering(tcp)) {
1850 tprintf("%lu, ", tcp->u_arg[0]);
1851 return 0;
1852 }
1853 if (syserror(tcp) || !verbose(tcp)) {
1854 tprintf("%#lx, %lu", tcp->u_arg[1], tcp->u_arg[2]);
1855 return 0;
1856 }
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001857 len = tcp->u_rval;
1858 if ((buf = malloc(len)) == NULL) {
1859 tprintf("out of memory\n");
1860 return 0;
1861 }
1862 if (umoven(tcp, tcp->u_arg[1], len, buf) < 0) {
1863 tprintf("{...}, %lu", tcp->u_arg[2]);
1864 free(buf);
1865 return 0;
1866 }
1867 if (!abbrev(tcp))
1868 tprintf("{");
1869 for (i = 0; i < len;) {
Wichert Akkerman9524bb91999-05-25 23:11:18 +00001870 struct kernel_dirent *d = (struct kernel_dirent *) &buf[i];
Michal Ludvig53b320f2002-09-23 13:30:09 +00001871#ifdef LINUX
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001872 if (!abbrev(tcp)) {
1873 tprintf("%s{d_ino=%lu, d_off=%lu, ",
1874 i ? " " : "", d->d_ino, d->d_off);
1875 tprintf("d_reclen=%u, d_name=\"%s\"}",
1876 d->d_reclen, d->d_name);
1877 }
Michal Ludvig53b320f2002-09-23 13:30:09 +00001878#endif /* LINUX */
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001879#ifdef SVR4
1880 if (!abbrev(tcp)) {
1881 tprintf("%s{d_ino=%lu, d_off=%lu, ",
Roland McGrath186c5ac2002-12-15 23:58:23 +00001882 i ? " " : "",
1883 (unsigned long) d->d_ino,
1884 (unsigned long) d->d_off);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001885 tprintf("d_reclen=%u, d_name=\"%s\"}",
1886 d->d_reclen, d->d_name);
1887 }
1888#endif /* SVR4 */
1889#ifdef SUNOS4
1890 if (!abbrev(tcp)) {
1891 tprintf("%s{d_off=%lu, d_fileno=%lu, d_reclen=%u, ",
1892 i ? " " : "", d->d_off, d->d_fileno,
1893 d->d_reclen);
1894 tprintf("d_namlen=%u, d_name=\"%.*s\"}",
1895 d->d_namlen, d->d_namlen, d->d_name);
1896 }
1897#endif /* SUNOS4 */
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +00001898#ifdef FREEBSD
1899 if (!abbrev(tcp)) {
1900 tprintf("%s{d_fileno=%u, d_reclen=%u, d_type=",
1901 i ? " " : "", d->d_fileno, d->d_reclen);
1902 printxval(direnttypes, d->d_type, "DT_???");
1903 tprintf(", d_namlen=%u, d_name=\"%.*s\"}",
1904 d->d_namlen, d->d_namlen, d->d_name);
1905 }
Roland McGrath186c5ac2002-12-15 23:58:23 +00001906#endif /* FREEBSD */
Pavel Machek9a9f10b2000-02-01 16:22:52 +00001907 if (!d->d_reclen) {
1908 tprintf("/* d_reclen == 0, problem here */");
1909 break;
1910 }
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001911 i += d->d_reclen;
1912 dents++;
1913 }
1914 if (!abbrev(tcp))
1915 tprintf("}");
1916 else
1917 tprintf("/* %u entries */", dents);
1918 tprintf(", %lu", tcp->u_arg[2]);
1919 free(buf);
1920 return 0;
1921}
1922
John Hughesbdf48f52001-03-06 15:08:09 +00001923
1924#if _LFS64_LARGEFILE
1925int
1926sys_getdents64(tcp)
1927struct tcb *tcp;
1928{
1929 int i, len, dents = 0;
1930 char *buf;
1931
1932 if (entering(tcp)) {
1933 tprintf("%lu, ", tcp->u_arg[0]);
1934 return 0;
1935 }
1936 if (syserror(tcp) || !verbose(tcp)) {
1937 tprintf("%#lx, %lu", tcp->u_arg[1], tcp->u_arg[2]);
1938 return 0;
1939 }
1940 len = tcp->u_rval;
1941 if ((buf = malloc(len)) == NULL) {
1942 tprintf("out of memory\n");
1943 return 0;
1944 }
1945 if (umoven(tcp, tcp->u_arg[1], len, buf) < 0) {
1946 tprintf("{...}, %lu", tcp->u_arg[2]);
1947 free(buf);
1948 return 0;
1949 }
1950 if (!abbrev(tcp))
1951 tprintf("{");
1952 for (i = 0; i < len;) {
1953 struct dirent64 *d = (struct dirent64 *) &buf[i];
Michal Ludvig53b320f2002-09-23 13:30:09 +00001954#if defined(LINUX) || defined(SVR4)
John Hughesbdf48f52001-03-06 15:08:09 +00001955 if (!abbrev(tcp)) {
1956 tprintf("%s{d_ino=%lu, d_off=%lu, ",
Roland McGrath186c5ac2002-12-15 23:58:23 +00001957 i ? " " : "",
1958 (unsigned long)d->d_ino,
Michal Ludvig53b320f2002-09-23 13:30:09 +00001959 (unsigned long)d->d_off);
John Hughesbdf48f52001-03-06 15:08:09 +00001960 tprintf("d_reclen=%u, d_name=\"%s\"}",
1961 d->d_reclen, d->d_name);
1962 }
Michal Ludvig53b320f2002-09-23 13:30:09 +00001963#endif /* LINUX || SVR4 */
John Hughesbdf48f52001-03-06 15:08:09 +00001964#ifdef SUNOS4
1965 if (!abbrev(tcp)) {
1966 tprintf("%s{d_off=%lu, d_fileno=%lu, d_reclen=%u, ",
1967 i ? " " : "", d->d_off, d->d_fileno,
1968 d->d_reclen);
1969 tprintf("d_namlen=%u, d_name=\"%.*s\"}",
1970 d->d_namlen, d->d_namlen, d->d_name);
1971 }
1972#endif /* SUNOS4 */
1973 i += d->d_reclen;
1974 dents++;
1975 }
1976 if (!abbrev(tcp))
1977 tprintf("}");
1978 else
1979 tprintf("/* %u entries */", dents);
1980 tprintf(", %lu", tcp->u_arg[2]);
1981 free(buf);
1982 return 0;
1983}
1984#endif
Roland McGrath186c5ac2002-12-15 23:58:23 +00001985
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +00001986#ifdef FREEBSD
1987int
1988sys_getdirentries(tcp)
1989struct tcb * tcp;
1990{
1991 int i, len, dents = 0;
1992 long basep;
1993 char *buf;
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001994
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +00001995 if (entering(tcp)) {
1996 tprintf("%lu, ", tcp->u_arg[0]);
1997 return 0;
1998 }
1999 if (syserror(tcp) || !verbose(tcp)) {
2000 tprintf("%#lx, %lu, %#lx", tcp->u_arg[1], tcp->u_arg[2], tcp->u_arg[3]);
2001 return 0;
2002 }
2003 len = tcp->u_rval;
2004 if ((buf = malloc(len)) == NULL) {
2005 tprintf("out of memory\n");
2006 return 0;
2007 }
2008 if (umoven(tcp, tcp->u_arg[1], len, buf) < 0) {
2009 tprintf("{...}, %lu, %#lx", tcp->u_arg[2], tcp->u_arg[3]);
2010 free(buf);
2011 return 0;
2012 }
2013 if (!abbrev(tcp))
2014 tprintf("{");
2015 for (i = 0; i < len;) {
2016 struct kernel_dirent *d = (struct kernel_dirent *) &buf[i];
2017 if (!abbrev(tcp)) {
2018 tprintf("%s{d_fileno=%u, d_reclen=%u, d_type=",
2019 i ? " " : "", d->d_fileno, d->d_reclen);
2020 printxval(direnttypes, d->d_type, "DT_???");
2021 tprintf(", d_namlen=%u, d_name=\"%.*s\"}",
2022 d->d_namlen, d->d_namlen, d->d_name);
2023 }
2024 i += d->d_reclen;
2025 dents++;
2026 }
2027 if (!abbrev(tcp))
2028 tprintf("}");
2029 else
2030 tprintf("/* %u entries */", dents);
2031 free(buf);
2032 tprintf(", %lu", tcp->u_arg[2]);
2033 if (umove(tcp, tcp->u_arg[3], &basep) < 0)
2034 tprintf(", %#lx", tcp->u_arg[3]);
2035 else
2036 tprintf(", [%lu]", basep);
2037 return 0;
2038}
2039#endif
2040
Michal Ludvig53b320f2002-09-23 13:30:09 +00002041#ifdef LINUX
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002042int
2043sys_getcwd(tcp)
2044struct tcb *tcp;
2045{
2046 if (exiting(tcp)) {
2047 if (syserror(tcp))
2048 tprintf("%#lx", tcp->u_arg[0]);
2049 else
Wichert Akkerman2e2553a1999-05-09 00:29:58 +00002050 printpathn(tcp, tcp->u_arg[0], tcp->u_rval - 1);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002051 tprintf(", %lu", tcp->u_arg[1]);
2052 }
2053 return 0;
2054}
Michal Ludvig53b320f2002-09-23 13:30:09 +00002055#endif /* LINUX */
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002056
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +00002057#ifdef FREEBSD
2058int
2059sys___getcwd(tcp)
2060struct tcb *tcp;
2061{
2062 if (exiting(tcp)) {
2063 if (syserror(tcp))
2064 tprintf("%#lx", tcp->u_arg[0]);
2065 else
2066 printpathn(tcp, tcp->u_arg[0], tcp->u_arg[1]);
2067 tprintf(", %lu", tcp->u_arg[1]);
2068 }
2069 return 0;
2070}
2071#endif
2072
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002073#ifdef HAVE_SYS_ASYNCH_H
2074
2075int
2076sys_aioread(tcp)
2077struct tcb *tcp;
2078{
2079 struct aio_result_t res;
2080
2081 if (entering(tcp)) {
2082 tprintf("%lu, ", tcp->u_arg[0]);
2083 } else {
2084 if (syserror(tcp))
2085 tprintf("%#lx", tcp->u_arg[1]);
2086 else
2087 printstr(tcp, tcp->u_arg[1], tcp->u_arg[2]);
2088 tprintf(", %lu, %lu, ", tcp->u_arg[2], tcp->u_arg[3]);
2089 printxval(whence, tcp->u_arg[4], "L_???");
2090 if (syserror(tcp) || tcp->u_arg[5] == 0
2091 || umove(tcp, tcp->u_arg[5], &res) < 0)
2092 tprintf(", %#lx", tcp->u_arg[5]);
2093 else
2094 tprintf(", {aio_return %d aio_errno %d}",
2095 res.aio_return, res.aio_errno);
2096 }
2097 return 0;
2098}
2099
2100int
2101sys_aiowrite(tcp)
2102struct tcb *tcp;
2103{
2104 struct aio_result_t res;
2105
2106 if (entering(tcp)) {
2107 tprintf("%lu, ", tcp->u_arg[0]);
2108 printstr(tcp, tcp->u_arg[1], tcp->u_arg[2]);
2109 tprintf(", %lu, %lu, ", tcp->u_arg[2], tcp->u_arg[3]);
2110 printxval(whence, tcp->u_arg[4], "L_???");
2111 }
2112 else {
2113 if (tcp->u_arg[5] == 0)
2114 tprintf(", NULL");
2115 else if (syserror(tcp)
2116 || umove(tcp, tcp->u_arg[5], &res) < 0)
2117 tprintf(", %#lx", tcp->u_arg[5]);
2118 else
2119 tprintf(", {aio_return %d aio_errno %d}",
2120 res.aio_return, res.aio_errno);
2121 }
2122 return 0;
2123}
2124
2125int
2126sys_aiowait(tcp)
2127struct tcb *tcp;
2128{
2129 if (entering(tcp))
2130 printtv(tcp, tcp->u_arg[0]);
2131 return 0;
2132}
2133
2134int
2135sys_aiocancel(tcp)
2136struct tcb *tcp;
2137{
2138 struct aio_result_t res;
2139
2140 if (exiting(tcp)) {
2141 if (tcp->u_arg[0] == 0)
2142 tprintf("NULL");
2143 else if (syserror(tcp)
2144 || umove(tcp, tcp->u_arg[0], &res) < 0)
2145 tprintf("%#lx", tcp->u_arg[0]);
2146 else
2147 tprintf("{aio_return %d aio_errno %d}",
2148 res.aio_return, res.aio_errno);
2149 }
2150 return 0;
2151}
2152
2153#endif /* HAVE_SYS_ASYNCH_H */
Roland McGrath186c5ac2002-12-15 23:58:23 +00002154
2155#ifdef XATTR_CREATE
2156
2157struct xlat xattrflags[] = {
2158 { XATTR_CREATE, "XATTR_CREATE" },
2159 { XATTR_REPLACE, "XATTR_REPLACE" },
2160 { 0, NULL }
2161};
2162
2163int
2164sys_setxattr(tcp)
2165struct tcb *tcp;
2166{
2167 if (entering(tcp)) {
2168 printpath(tcp, tcp->u_arg[0]);
2169 tprintf(", ");
2170 printstr(tcp, tcp->u_arg[1], -1);
2171 /* XXX Print value in format */
2172 tprintf(", %p, %ld, ", (void *) tcp->u_arg[2], tcp->u_arg[3]);
2173 printflags(xattrflags, tcp->u_arg[4]);
2174 }
2175 return 0;
2176}
2177
2178int
2179sys_fsetxattr(tcp)
2180struct tcb *tcp;
2181{
2182 if (entering(tcp)) {
2183 tprintf("%ld, ", tcp->u_arg[0]);
2184 printstr(tcp, tcp->u_arg[1], -1);
2185 /* XXX Print value in format */
2186 tprintf(", %p, %ld, ", (void *) tcp->u_arg[2], tcp->u_arg[3]);
2187 printflags(xattrflags, tcp->u_arg[4]);
2188 }
2189 return 0;
2190}
2191
2192int
2193sys_getxattr(tcp)
2194struct tcb *tcp;
2195{
2196 if (entering(tcp)) {
2197 printpath(tcp, tcp->u_arg[0]);
2198 tprintf(", ");
2199 printstr(tcp, tcp->u_arg[1], -1);
2200 } else {
2201 /* XXX Print value in format */
2202 tprintf(", %p, %ld", (void *) tcp->u_arg[2], tcp->u_arg[3]);
2203 }
2204 return 0;
2205}
2206
2207int
2208sys_fgetxattr(tcp)
2209struct tcb *tcp;
2210{
2211 if (entering(tcp)) {
2212 tprintf("%ld, ", tcp->u_arg[0]);
2213 printstr(tcp, tcp->u_arg[1], -1);
2214 } else {
2215 /* XXX Print value in format */
2216 tprintf(", %p, %ld", (void *) tcp->u_arg[2], tcp->u_arg[3]);
2217 }
2218 return 0;
2219}
2220
2221int
2222sys_listxattr(tcp)
2223struct tcb *tcp;
2224{
2225 if (entering(tcp)) {
2226 printpath(tcp, tcp->u_arg[0]);
2227 } else {
2228 /* XXX Print value in format */
2229 tprintf(", %p, %lu", (void *) tcp->u_arg[1], tcp->u_arg[2]);
2230 }
2231 return 0;
2232}
2233
2234int
2235sys_flistxattr(tcp)
2236struct tcb *tcp;
2237{
2238 if (entering(tcp)) {
2239 tprintf("%ld", tcp->u_arg[0]);
2240 } else {
2241 /* XXX Print value in format */
2242 tprintf(", %p, %lu", (void *) tcp->u_arg[1], tcp->u_arg[2]);
2243 }
2244 return 0;
2245}
2246
2247int
2248sys_removexattr(tcp)
2249struct tcb *tcp;
2250{
2251 if (entering(tcp)) {
2252 printpath(tcp, tcp->u_arg[0]);
2253 tprintf(", ");
2254 printstr(tcp, tcp->u_arg[1], -1);
2255 }
2256 return 0;
2257}
2258
2259int
2260sys_fremovexattr(tcp)
2261struct tcb *tcp;
2262{
2263 if (entering(tcp)) {
2264 tprintf("%ld, ", tcp->u_arg[0]);
2265 printstr(tcp, tcp->u_arg[1], -1);
2266 }
2267 return 0;
2268}
2269
2270#endif