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