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