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