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