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