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