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