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