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