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