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