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" |
Roland McGrath | c531e57 | 2008-08-01 01:13:10 +0000 | [diff] [blame] | 32 | |
Denys Vlasenko | 9472a27 | 2013-02-12 11:43:46 +0100 | [diff] [blame] | 33 | #if defined(SPARC) || defined(SPARC64) |
Wichert Akkerman | dacfb6e | 1999-06-03 14:21:07 +0000 | [diff] [blame] | 34 | struct stat { |
| 35 | unsigned short st_dev; |
| 36 | unsigned int st_ino; |
| 37 | unsigned short st_mode; |
| 38 | short st_nlink; |
| 39 | unsigned short st_uid; |
| 40 | unsigned short st_gid; |
| 41 | unsigned short st_rdev; |
| 42 | unsigned int st_size; |
| 43 | int st_atime; |
| 44 | unsigned int __unused1; |
| 45 | int st_mtime; |
| 46 | unsigned int __unused2; |
| 47 | int st_ctime; |
| 48 | unsigned int __unused3; |
| 49 | int st_blksize; |
| 50 | int st_blocks; |
| 51 | unsigned int __unused4[2]; |
| 52 | }; |
Denys Vlasenko | 8470374 | 2012-02-25 02:38:52 +0100 | [diff] [blame] | 53 | # if defined(SPARC64) |
Roland McGrath | 6d1a65c | 2004-07-12 07:44:08 +0000 | [diff] [blame] | 54 | struct stat_sparc64 { |
| 55 | unsigned int st_dev; |
| 56 | unsigned long st_ino; |
| 57 | unsigned int st_mode; |
| 58 | unsigned int st_nlink; |
| 59 | unsigned int st_uid; |
| 60 | unsigned int st_gid; |
| 61 | unsigned int st_rdev; |
| 62 | long st_size; |
| 63 | long st_atime; |
| 64 | long st_mtime; |
| 65 | long st_ctime; |
| 66 | long st_blksize; |
| 67 | long st_blocks; |
| 68 | unsigned long __unused4[2]; |
| 69 | }; |
Denys Vlasenko | 8470374 | 2012-02-25 02:38:52 +0100 | [diff] [blame] | 70 | # endif /* SPARC64 */ |
| 71 | # define stat kernel_stat |
| 72 | # include <asm/stat.h> |
| 73 | # undef stat |
Dmitry V. Levin | 8d41108 | 2014-12-28 16:41:24 +0000 | [diff] [blame^] | 74 | #else /* !SPARC && !SPARC64 */ |
Denys Vlasenko | 8470374 | 2012-02-25 02:38:52 +0100 | [diff] [blame] | 75 | # undef dev_t |
| 76 | # undef ino_t |
| 77 | # undef mode_t |
| 78 | # undef nlink_t |
| 79 | # undef uid_t |
| 80 | # undef gid_t |
| 81 | # undef off_t |
| 82 | # undef loff_t |
Denys Vlasenko | 8470374 | 2012-02-25 02:38:52 +0100 | [diff] [blame] | 83 | # define dev_t __kernel_dev_t |
| 84 | # define ino_t __kernel_ino_t |
| 85 | # define mode_t __kernel_mode_t |
| 86 | # define nlink_t __kernel_nlink_t |
| 87 | # define uid_t __kernel_uid_t |
| 88 | # define gid_t __kernel_gid_t |
| 89 | # define off_t __kernel_off_t |
| 90 | # define loff_t __kernel_loff_t |
Wichert Akkerman | a601370 | 1999-07-08 14:00:58 +0000 | [diff] [blame] | 91 | |
Denys Vlasenko | 8470374 | 2012-02-25 02:38:52 +0100 | [diff] [blame] | 92 | # include <asm/stat.h> |
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 | # undef dev_t |
| 95 | # undef ino_t |
| 96 | # undef mode_t |
| 97 | # undef nlink_t |
| 98 | # undef uid_t |
| 99 | # undef gid_t |
| 100 | # undef off_t |
| 101 | # undef loff_t |
Denys Vlasenko | 8470374 | 2012-02-25 02:38:52 +0100 | [diff] [blame] | 102 | # define dev_t dev_t |
| 103 | # define ino_t ino_t |
| 104 | # define mode_t mode_t |
| 105 | # define nlink_t nlink_t |
| 106 | # define uid_t uid_t |
| 107 | # define gid_t gid_t |
| 108 | # define off_t off_t |
| 109 | # define loff_t loff_t |
| 110 | #endif |
| 111 | |
Denys Vlasenko | 8470374 | 2012-02-25 02:38:52 +0100 | [diff] [blame] | 112 | #define stat libc_stat |
| 113 | #define stat64 libc_stat64 |
| 114 | #include <sys/stat.h> |
| 115 | #undef stat |
| 116 | #undef stat64 |
Denys Vlasenko | a6d91de | 2012-03-16 12:02:22 +0100 | [diff] [blame] | 117 | /* These might be macros. */ |
Denys Vlasenko | 8470374 | 2012-02-25 02:38:52 +0100 | [diff] [blame] | 118 | #undef st_atime |
| 119 | #undef st_mtime |
| 120 | #undef st_ctime |
Wichert Akkerman | d4d8e92 | 1999-04-18 23:30:29 +0000 | [diff] [blame] | 121 | |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 122 | #ifdef MAJOR_IN_SYSMACROS |
Denys Vlasenko | 8470374 | 2012-02-25 02:38:52 +0100 | [diff] [blame] | 123 | # include <sys/sysmacros.h> |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 124 | #endif |
| 125 | |
| 126 | #ifdef MAJOR_IN_MKDEV |
Denys Vlasenko | 8470374 | 2012-02-25 02:38:52 +0100 | [diff] [blame] | 127 | # include <sys/mkdev.h> |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 128 | #endif |
| 129 | |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 130 | /* several stats */ |
| 131 | |
Denys Vlasenko | 9472a27 | 2013-02-12 11:43:46 +0100 | [diff] [blame] | 132 | #if defined(SPARC) || defined(SPARC64) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 133 | typedef struct { |
Denys Vlasenko | adedb51 | 2008-12-30 18:47:55 +0000 | [diff] [blame] | 134 | int tv_sec; |
| 135 | int tv_nsec; |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 136 | } timestruct_t; |
| 137 | |
| 138 | struct solstat { |
Denys Vlasenko | adedb51 | 2008-12-30 18:47:55 +0000 | [diff] [blame] | 139 | unsigned st_dev; |
| 140 | int st_pad1[3]; /* network id */ |
| 141 | unsigned st_ino; |
| 142 | unsigned st_mode; |
| 143 | unsigned st_nlink; |
| 144 | unsigned st_uid; |
| 145 | unsigned st_gid; |
| 146 | unsigned st_rdev; |
| 147 | int st_pad2[2]; |
| 148 | int st_size; |
| 149 | int st_pad3; /* st_size, off_t expansion */ |
| 150 | timestruct_t st_atime; |
| 151 | timestruct_t st_mtime; |
| 152 | timestruct_t st_ctime; |
| 153 | int st_blksize; |
| 154 | int st_blocks; |
| 155 | char st_fstype[16]; |
| 156 | int st_pad4[8]; /* expansion area */ |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 157 | }; |
| 158 | |
| 159 | static void |
Dmitry V. Levin | b838b1e | 2008-04-19 23:47:47 +0000 | [diff] [blame] | 160 | printstatsol(struct tcb *tcp, long addr) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 161 | { |
| 162 | struct solstat statbuf; |
| 163 | |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 164 | if (umove(tcp, addr, &statbuf) < 0) { |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 165 | tprints("{...}"); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 166 | return; |
| 167 | } |
| 168 | if (!abbrev(tcp)) { |
| 169 | tprintf("{st_dev=makedev(%lu, %lu), st_ino=%lu, st_mode=%s, ", |
| 170 | (unsigned long) ((statbuf.st_dev >> 18) & 0x3fff), |
| 171 | (unsigned long) (statbuf.st_dev & 0x3ffff), |
| 172 | (unsigned long) statbuf.st_ino, |
| 173 | sprintmode(statbuf.st_mode)); |
| 174 | tprintf("st_nlink=%lu, st_uid=%lu, st_gid=%lu, ", |
| 175 | (unsigned long) statbuf.st_nlink, |
| 176 | (unsigned long) statbuf.st_uid, |
| 177 | (unsigned long) statbuf.st_gid); |
| 178 | tprintf("st_blksize=%lu, ", (unsigned long) statbuf.st_blksize); |
| 179 | tprintf("st_blocks=%lu, ", (unsigned long) statbuf.st_blocks); |
| 180 | } |
| 181 | else |
| 182 | tprintf("{st_mode=%s, ", sprintmode(statbuf.st_mode)); |
| 183 | switch (statbuf.st_mode & S_IFMT) { |
| 184 | case S_IFCHR: case S_IFBLK: |
| 185 | tprintf("st_rdev=makedev(%lu, %lu), ", |
| 186 | (unsigned long) ((statbuf.st_rdev >> 18) & 0x3fff), |
| 187 | (unsigned long) (statbuf.st_rdev & 0x3ffff)); |
| 188 | break; |
| 189 | default: |
| 190 | tprintf("st_size=%u, ", statbuf.st_size); |
| 191 | break; |
| 192 | } |
| 193 | if (!abbrev(tcp)) { |
Dmitry V. Levin | b838b1e | 2008-04-19 23:47:47 +0000 | [diff] [blame] | 194 | tprintf("st_atime=%s, ", sprinttime(statbuf.st_atime.tv_sec)); |
| 195 | tprintf("st_mtime=%s, ", sprinttime(statbuf.st_mtime.tv_sec)); |
| 196 | tprintf("st_ctime=%s}", sprinttime(statbuf.st_ctime.tv_sec)); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 197 | } |
| 198 | else |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 199 | tprints("...}"); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 200 | } |
Roland McGrath | 6d1a65c | 2004-07-12 07:44:08 +0000 | [diff] [blame] | 201 | |
Denys Vlasenko | 9472a27 | 2013-02-12 11:43:46 +0100 | [diff] [blame] | 202 | # if defined(SPARC64) |
Roland McGrath | 6d1a65c | 2004-07-12 07:44:08 +0000 | [diff] [blame] | 203 | static void |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 204 | printstat_sparc64(struct tcb *tcp, long addr) |
Roland McGrath | 6d1a65c | 2004-07-12 07:44:08 +0000 | [diff] [blame] | 205 | { |
| 206 | struct stat_sparc64 statbuf; |
| 207 | |
Roland McGrath | 6d1a65c | 2004-07-12 07:44:08 +0000 | [diff] [blame] | 208 | if (umove(tcp, addr, &statbuf) < 0) { |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 209 | tprints("{...}"); |
Roland McGrath | 6d1a65c | 2004-07-12 07:44:08 +0000 | [diff] [blame] | 210 | return; |
| 211 | } |
| 212 | |
| 213 | if (!abbrev(tcp)) { |
| 214 | tprintf("{st_dev=makedev(%lu, %lu), st_ino=%lu, st_mode=%s, ", |
| 215 | (unsigned long) major(statbuf.st_dev), |
| 216 | (unsigned long) minor(statbuf.st_dev), |
| 217 | (unsigned long) statbuf.st_ino, |
| 218 | sprintmode(statbuf.st_mode)); |
| 219 | tprintf("st_nlink=%lu, st_uid=%lu, st_gid=%lu, ", |
| 220 | (unsigned long) statbuf.st_nlink, |
| 221 | (unsigned long) statbuf.st_uid, |
| 222 | (unsigned long) statbuf.st_gid); |
| 223 | tprintf("st_blksize=%lu, ", |
| 224 | (unsigned long) statbuf.st_blksize); |
| 225 | tprintf("st_blocks=%lu, ", |
| 226 | (unsigned long) statbuf.st_blocks); |
| 227 | } |
| 228 | else |
| 229 | tprintf("{st_mode=%s, ", sprintmode(statbuf.st_mode)); |
| 230 | switch (statbuf.st_mode & S_IFMT) { |
| 231 | case S_IFCHR: case S_IFBLK: |
| 232 | tprintf("st_rdev=makedev(%lu, %lu), ", |
| 233 | (unsigned long) major(statbuf.st_rdev), |
| 234 | (unsigned long) minor(statbuf.st_rdev)); |
| 235 | break; |
| 236 | default: |
| 237 | tprintf("st_size=%lu, ", statbuf.st_size); |
| 238 | break; |
| 239 | } |
| 240 | if (!abbrev(tcp)) { |
| 241 | tprintf("st_atime=%s, ", sprinttime(statbuf.st_atime)); |
| 242 | tprintf("st_mtime=%s, ", sprinttime(statbuf.st_mtime)); |
Denys Vlasenko | 1945ccc | 2012-02-27 14:37:48 +0100 | [diff] [blame] | 243 | tprintf("st_ctime=%s}", sprinttime(statbuf.st_ctime)); |
Roland McGrath | 6d1a65c | 2004-07-12 07:44:08 +0000 | [diff] [blame] | 244 | } |
| 245 | else |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 246 | tprints("...}"); |
Roland McGrath | 6d1a65c | 2004-07-12 07:44:08 +0000 | [diff] [blame] | 247 | } |
Denys Vlasenko | 9472a27 | 2013-02-12 11:43:46 +0100 | [diff] [blame] | 248 | # endif /* SPARC64 */ |
| 249 | #endif /* SPARC[64] */ |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 250 | |
Denys Vlasenko | 8470374 | 2012-02-25 02:38:52 +0100 | [diff] [blame] | 251 | #if defined POWERPC64 |
Andreas Schwab | d69fa49 | 2010-07-12 21:39:57 +0200 | [diff] [blame] | 252 | struct stat_powerpc32 { |
| 253 | unsigned int st_dev; |
| 254 | unsigned int st_ino; |
| 255 | unsigned int st_mode; |
| 256 | unsigned short st_nlink; |
| 257 | unsigned int st_uid; |
| 258 | unsigned int st_gid; |
| 259 | unsigned int st_rdev; |
| 260 | unsigned int st_size; |
| 261 | unsigned int st_blksize; |
| 262 | unsigned int st_blocks; |
| 263 | unsigned int st_atime; |
| 264 | unsigned int st_atime_nsec; |
| 265 | unsigned int st_mtime; |
| 266 | unsigned int st_mtime_nsec; |
| 267 | unsigned int st_ctime; |
| 268 | unsigned int st_ctime_nsec; |
| 269 | unsigned int __unused4; |
| 270 | unsigned int __unused5; |
| 271 | }; |
| 272 | |
| 273 | static void |
| 274 | printstat_powerpc32(struct tcb *tcp, long addr) |
| 275 | { |
| 276 | struct stat_powerpc32 statbuf; |
| 277 | |
| 278 | if (umove(tcp, addr, &statbuf) < 0) { |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 279 | tprints("{...}"); |
Andreas Schwab | d69fa49 | 2010-07-12 21:39:57 +0200 | [diff] [blame] | 280 | return; |
| 281 | } |
| 282 | |
| 283 | if (!abbrev(tcp)) { |
| 284 | tprintf("{st_dev=makedev(%u, %u), st_ino=%u, st_mode=%s, ", |
| 285 | major(statbuf.st_dev), minor(statbuf.st_dev), |
| 286 | statbuf.st_ino, |
| 287 | sprintmode(statbuf.st_mode)); |
| 288 | tprintf("st_nlink=%u, st_uid=%u, st_gid=%u, ", |
| 289 | statbuf.st_nlink, statbuf.st_uid, statbuf.st_gid); |
| 290 | tprintf("st_blksize=%u, ", statbuf.st_blksize); |
| 291 | tprintf("st_blocks=%u, ", statbuf.st_blocks); |
| 292 | } |
| 293 | else |
| 294 | tprintf("{st_mode=%s, ", sprintmode(statbuf.st_mode)); |
| 295 | switch (statbuf.st_mode & S_IFMT) { |
| 296 | case S_IFCHR: case S_IFBLK: |
| 297 | tprintf("st_rdev=makedev(%lu, %lu), ", |
| 298 | (unsigned long) major(statbuf.st_rdev), |
| 299 | (unsigned long) minor(statbuf.st_rdev)); |
| 300 | break; |
| 301 | default: |
| 302 | tprintf("st_size=%u, ", statbuf.st_size); |
| 303 | break; |
| 304 | } |
| 305 | if (!abbrev(tcp)) { |
| 306 | tprintf("st_atime=%s, ", sprinttime(statbuf.st_atime)); |
| 307 | tprintf("st_mtime=%s, ", sprinttime(statbuf.st_mtime)); |
Denys Vlasenko | 1945ccc | 2012-02-27 14:37:48 +0100 | [diff] [blame] | 308 | tprintf("st_ctime=%s}", sprinttime(statbuf.st_ctime)); |
Andreas Schwab | d69fa49 | 2010-07-12 21:39:57 +0200 | [diff] [blame] | 309 | } |
| 310 | else |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 311 | tprints("...}"); |
Andreas Schwab | d69fa49 | 2010-07-12 21:39:57 +0200 | [diff] [blame] | 312 | } |
Denys Vlasenko | 8470374 | 2012-02-25 02:38:52 +0100 | [diff] [blame] | 313 | #endif /* POWERPC64 */ |
Andreas Schwab | d69fa49 | 2010-07-12 21:39:57 +0200 | [diff] [blame] | 314 | |
Dmitry V. Levin | ab21a94 | 2014-12-28 18:15:25 +0000 | [diff] [blame] | 315 | #include "printstat.h" |
Wichert Akkerman | 328c5e7 | 1999-04-16 00:21:26 +0000 | [diff] [blame] | 316 | |
Dmitry V. Levin | 0eeda2c | 2013-05-01 16:37:08 +0000 | [diff] [blame] | 317 | #ifndef X32 |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 318 | static void |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 319 | printstat(struct tcb *tcp, long addr) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 320 | { |
Wichert Akkerman | 328c5e7 | 1999-04-16 00:21:26 +0000 | [diff] [blame] | 321 | struct stat statbuf; |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 322 | |
Denys Vlasenko | 4e718b5 | 2009-04-20 18:30:13 +0000 | [diff] [blame] | 323 | if (!addr) { |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 324 | tprints("NULL"); |
Denys Vlasenko | 4e718b5 | 2009-04-20 18:30:13 +0000 | [diff] [blame] | 325 | return; |
| 326 | } |
| 327 | if (syserror(tcp) || !verbose(tcp)) { |
| 328 | tprintf("%#lx", addr); |
| 329 | return; |
| 330 | } |
| 331 | |
Denys Vlasenko | 9472a27 | 2013-02-12 11:43:46 +0100 | [diff] [blame] | 332 | #if defined(SPARC) || defined(SPARC64) |
Denys Vlasenko | 5ae2b7c | 2009-02-27 20:32:52 +0000 | [diff] [blame] | 333 | if (current_personality == 1) { |
| 334 | printstatsol(tcp, addr); |
| 335 | return; |
| 336 | } |
Roland McGrath | 6d1a65c | 2004-07-12 07:44:08 +0000 | [diff] [blame] | 337 | #ifdef SPARC64 |
| 338 | else if (current_personality == 2) { |
| 339 | printstat_sparc64(tcp, addr); |
| 340 | return; |
| 341 | } |
| 342 | #endif |
Denys Vlasenko | 9472a27 | 2013-02-12 11:43:46 +0100 | [diff] [blame] | 343 | #endif /* SPARC[64] */ |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 344 | |
Denys Vlasenko | 8470374 | 2012-02-25 02:38:52 +0100 | [diff] [blame] | 345 | #if defined POWERPC64 |
Andreas Schwab | d69fa49 | 2010-07-12 21:39:57 +0200 | [diff] [blame] | 346 | if (current_personality == 1) { |
| 347 | printstat_powerpc32(tcp, addr); |
| 348 | return; |
| 349 | } |
| 350 | #endif |
| 351 | |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 352 | if (umove(tcp, addr, &statbuf) < 0) { |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 353 | tprints("{...}"); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 354 | return; |
| 355 | } |
Wichert Akkerman | 328c5e7 | 1999-04-16 00:21:26 +0000 | [diff] [blame] | 356 | |
Dmitry V. Levin | d01f0a8 | 2014-12-28 18:00:39 +0000 | [diff] [blame] | 357 | do_printstat(tcp, &statbuf); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 358 | } |
Dmitry V. Levin | 0eeda2c | 2013-05-01 16:37:08 +0000 | [diff] [blame] | 359 | #else /* X32 */ |
| 360 | # define printstat printstat64 |
| 361 | #endif |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 362 | |
Dmitry V. Levin | 8d41108 | 2014-12-28 16:41:24 +0000 | [diff] [blame^] | 363 | #if !defined HAVE_STAT64 && (defined AARCH64 || defined X86_64 || defined X32) |
Roland McGrath | e6d0f71 | 2007-08-07 01:22:49 +0000 | [diff] [blame] | 364 | /* |
Dmitry V. Levin | 8d41108 | 2014-12-28 16:41:24 +0000 | [diff] [blame^] | 365 | * Linux x86_64 and x32 have unified `struct stat' but their i386 personality |
| 366 | * needs `struct stat64'. |
| 367 | * linux/arch/x86/include/uapi/asm/stat.h defines `struct stat64' only for i386. |
Roland McGrath | e6d0f71 | 2007-08-07 01:22:49 +0000 | [diff] [blame] | 368 | * __GNUC__ is needed for the required __attribute__ below. |
Elliott Hughes | 391c0d8 | 2014-04-03 17:50:14 -0700 | [diff] [blame] | 369 | * |
| 370 | * Similarly, aarch64 has a unified `struct stat' but its arm personality |
Dmitry V. Levin | 8d41108 | 2014-12-28 16:41:24 +0000 | [diff] [blame^] | 371 | * needs `struct stat64' (unlike x86, it shouldn't be packed). |
Roland McGrath | e6d0f71 | 2007-08-07 01:22:49 +0000 | [diff] [blame] | 372 | */ |
| 373 | struct stat64 { |
| 374 | unsigned long long st_dev; |
| 375 | unsigned char __pad0[4]; |
| 376 | unsigned int __st_ino; |
| 377 | unsigned int st_mode; |
| 378 | unsigned int st_nlink; |
| 379 | unsigned int st_uid; |
| 380 | unsigned int st_gid; |
| 381 | unsigned long long st_rdev; |
| 382 | unsigned char __pad3[4]; |
| 383 | long long st_size; |
| 384 | unsigned int st_blksize; |
| 385 | unsigned long long st_blocks; |
| 386 | unsigned int st_atime; |
| 387 | unsigned int st_atime_nsec; |
| 388 | unsigned int st_mtime; |
| 389 | unsigned int st_mtime_nsec; |
| 390 | unsigned int st_ctime; |
| 391 | unsigned int st_ctime_nsec; |
| 392 | unsigned long long st_ino; |
Elliott Hughes | 391c0d8 | 2014-04-03 17:50:14 -0700 | [diff] [blame] | 393 | } |
Dmitry V. Levin | 8d41108 | 2014-12-28 16:41:24 +0000 | [diff] [blame^] | 394 | # if defined X86_64 || defined X32 |
Elliott Hughes | 391c0d8 | 2014-04-03 17:50:14 -0700 | [diff] [blame] | 395 | __attribute__((packed)) |
| 396 | # define STAT64_SIZE 96 |
| 397 | #else |
| 398 | # define STAT64_SIZE 104 |
| 399 | # endif |
| 400 | ; |
Roland McGrath | e6d0f71 | 2007-08-07 01:22:49 +0000 | [diff] [blame] | 401 | # define HAVE_STAT64 1 |
Dmitry V. Levin | 8d41108 | 2014-12-28 16:41:24 +0000 | [diff] [blame^] | 402 | #endif /* AARCH64 || X86_64 || X32 */ |
Roland McGrath | e6d0f71 | 2007-08-07 01:22:49 +0000 | [diff] [blame] | 403 | |
Wichert Akkerman | c792698 | 2000-04-10 22:22:31 +0000 | [diff] [blame] | 404 | #ifdef HAVE_STAT64 |
Wichert Akkerman | 328c5e7 | 1999-04-16 00:21:26 +0000 | [diff] [blame] | 405 | static void |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 406 | printstat64(struct tcb *tcp, long addr) |
Ulrich Drepper | 7f02c4d | 1999-12-24 08:01:34 +0000 | [diff] [blame] | 407 | { |
Dmitry V. Levin | 0eeda2c | 2013-05-01 16:37:08 +0000 | [diff] [blame] | 408 | #ifdef X32 |
| 409 | struct stat statbuf; |
| 410 | #else |
Ulrich Drepper | 7f02c4d | 1999-12-24 08:01:34 +0000 | [diff] [blame] | 411 | struct stat64 statbuf; |
Dmitry V. Levin | 0eeda2c | 2013-05-01 16:37:08 +0000 | [diff] [blame] | 412 | #endif |
Ulrich Drepper | 7f02c4d | 1999-12-24 08:01:34 +0000 | [diff] [blame] | 413 | |
Denys Vlasenko | 4e718b5 | 2009-04-20 18:30:13 +0000 | [diff] [blame] | 414 | #ifdef STAT64_SIZE |
Roland McGrath | e6d0f71 | 2007-08-07 01:22:49 +0000 | [diff] [blame] | 415 | (void) sizeof(char[sizeof statbuf == STAT64_SIZE ? 1 : -1]); |
| 416 | #endif |
| 417 | |
Ulrich Drepper | 7f02c4d | 1999-12-24 08:01:34 +0000 | [diff] [blame] | 418 | if (!addr) { |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 419 | tprints("NULL"); |
Ulrich Drepper | 7f02c4d | 1999-12-24 08:01:34 +0000 | [diff] [blame] | 420 | return; |
| 421 | } |
| 422 | if (syserror(tcp) || !verbose(tcp)) { |
Wichert Akkerman | 8b1b40c | 2000-02-03 21:58:30 +0000 | [diff] [blame] | 423 | tprintf("%#lx", addr); |
Ulrich Drepper | 7f02c4d | 1999-12-24 08:01:34 +0000 | [diff] [blame] | 424 | return; |
| 425 | } |
Denys Vlasenko | 4e718b5 | 2009-04-20 18:30:13 +0000 | [diff] [blame] | 426 | |
Denys Vlasenko | 9472a27 | 2013-02-12 11:43:46 +0100 | [diff] [blame] | 427 | #if defined(SPARC) || defined(SPARC64) |
Denys Vlasenko | 4e718b5 | 2009-04-20 18:30:13 +0000 | [diff] [blame] | 428 | if (current_personality == 1) { |
| 429 | printstatsol(tcp, addr); |
| 430 | return; |
| 431 | } |
| 432 | # ifdef SPARC64 |
| 433 | else if (current_personality == 2) { |
| 434 | printstat_sparc64(tcp, addr); |
| 435 | return; |
| 436 | } |
| 437 | # endif |
Denys Vlasenko | 9472a27 | 2013-02-12 11:43:46 +0100 | [diff] [blame] | 438 | #endif /* SPARC[64] */ |
Denys Vlasenko | 4e718b5 | 2009-04-20 18:30:13 +0000 | [diff] [blame] | 439 | |
Elliott Hughes | 391c0d8 | 2014-04-03 17:50:14 -0700 | [diff] [blame] | 440 | #if defined AARCH64 |
| 441 | if (current_personality != 0) { |
| 442 | printstat(tcp, addr); |
| 443 | return; |
| 444 | } |
| 445 | #endif |
Denys Vlasenko | 8470374 | 2012-02-25 02:38:52 +0100 | [diff] [blame] | 446 | #if defined X86_64 |
H.J. Lu | 35be581 | 2012-04-16 13:00:01 +0200 | [diff] [blame] | 447 | if (current_personality != 1) { |
Andreas Schwab | 61b7435 | 2009-10-16 11:37:13 +0200 | [diff] [blame] | 448 | printstat(tcp, addr); |
| 449 | return; |
| 450 | } |
| 451 | #endif |
Dmitry V. Levin | ff896f7 | 2009-10-21 13:43:57 +0000 | [diff] [blame] | 452 | |
Ulrich Drepper | 7f02c4d | 1999-12-24 08:01:34 +0000 | [diff] [blame] | 453 | if (umove(tcp, addr, &statbuf) < 0) { |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 454 | tprints("{...}"); |
Ulrich Drepper | 7f02c4d | 1999-12-24 08:01:34 +0000 | [diff] [blame] | 455 | return; |
| 456 | } |
| 457 | |
| 458 | if (!abbrev(tcp)) { |
Wichert Akkerman | d077c45 | 2000-08-10 18:16:15 +0000 | [diff] [blame] | 459 | tprintf("{st_dev=makedev(%lu, %lu), st_ino=%llu, st_mode=%s, ", |
Ulrich Drepper | 7f02c4d | 1999-12-24 08:01:34 +0000 | [diff] [blame] | 460 | (unsigned long) major(statbuf.st_dev), |
| 461 | (unsigned long) minor(statbuf.st_dev), |
Wichert Akkerman | d077c45 | 2000-08-10 18:16:15 +0000 | [diff] [blame] | 462 | (unsigned long long) statbuf.st_ino, |
Ulrich Drepper | 7f02c4d | 1999-12-24 08:01:34 +0000 | [diff] [blame] | 463 | sprintmode(statbuf.st_mode)); |
| 464 | tprintf("st_nlink=%lu, st_uid=%lu, st_gid=%lu, ", |
| 465 | (unsigned long) statbuf.st_nlink, |
| 466 | (unsigned long) statbuf.st_uid, |
| 467 | (unsigned long) statbuf.st_gid); |
Roland McGrath | 6d2b349 | 2002-12-30 00:51:30 +0000 | [diff] [blame] | 468 | #ifdef HAVE_STRUCT_STAT_ST_BLKSIZE |
Ulrich Drepper | 7f02c4d | 1999-12-24 08:01:34 +0000 | [diff] [blame] | 469 | tprintf("st_blksize=%lu, ", |
| 470 | (unsigned long) statbuf.st_blksize); |
Roland McGrath | 6d2b349 | 2002-12-30 00:51:30 +0000 | [diff] [blame] | 471 | #endif /* HAVE_STRUCT_STAT_ST_BLKSIZE */ |
| 472 | #ifdef HAVE_STRUCT_STAT_ST_BLOCKS |
Ulrich Drepper | 7f02c4d | 1999-12-24 08:01:34 +0000 | [diff] [blame] | 473 | tprintf("st_blocks=%lu, ", (unsigned long) statbuf.st_blocks); |
Roland McGrath | 6d2b349 | 2002-12-30 00:51:30 +0000 | [diff] [blame] | 474 | #endif /* HAVE_STRUCT_STAT_ST_BLOCKS */ |
Ulrich Drepper | 7f02c4d | 1999-12-24 08:01:34 +0000 | [diff] [blame] | 475 | } |
| 476 | else |
| 477 | tprintf("{st_mode=%s, ", sprintmode(statbuf.st_mode)); |
| 478 | switch (statbuf.st_mode & S_IFMT) { |
| 479 | case S_IFCHR: case S_IFBLK: |
Roland McGrath | 6d2b349 | 2002-12-30 00:51:30 +0000 | [diff] [blame] | 480 | #ifdef HAVE_STRUCT_STAT_ST_RDEV |
Ulrich Drepper | 7f02c4d | 1999-12-24 08:01:34 +0000 | [diff] [blame] | 481 | tprintf("st_rdev=makedev(%lu, %lu), ", |
| 482 | (unsigned long) major(statbuf.st_rdev), |
| 483 | (unsigned long) minor(statbuf.st_rdev)); |
Roland McGrath | 6d2b349 | 2002-12-30 00:51:30 +0000 | [diff] [blame] | 484 | #else /* !HAVE_STRUCT_STAT_ST_RDEV */ |
Ulrich Drepper | 7f02c4d | 1999-12-24 08:01:34 +0000 | [diff] [blame] | 485 | tprintf("st_size=makedev(%lu, %lu), ", |
| 486 | (unsigned long) major(statbuf.st_size), |
| 487 | (unsigned long) minor(statbuf.st_size)); |
Roland McGrath | 6d2b349 | 2002-12-30 00:51:30 +0000 | [diff] [blame] | 488 | #endif /* !HAVE_STRUCT_STAT_ST_RDEV */ |
Ulrich Drepper | 7f02c4d | 1999-12-24 08:01:34 +0000 | [diff] [blame] | 489 | break; |
| 490 | default: |
Roland McGrath | c7bd4d3 | 2007-08-07 01:05:19 +0000 | [diff] [blame] | 491 | tprintf("st_size=%llu, ", (unsigned long long) statbuf.st_size); |
Ulrich Drepper | 7f02c4d | 1999-12-24 08:01:34 +0000 | [diff] [blame] | 492 | break; |
| 493 | } |
| 494 | if (!abbrev(tcp)) { |
| 495 | tprintf("st_atime=%s, ", sprinttime(statbuf.st_atime)); |
| 496 | tprintf("st_mtime=%s, ", sprinttime(statbuf.st_mtime)); |
John Hughes | c0fc3fd | 2001-03-08 16:10:40 +0000 | [diff] [blame] | 497 | tprintf("st_ctime=%s", sprinttime(statbuf.st_ctime)); |
Roland McGrath | 6d2b349 | 2002-12-30 00:51:30 +0000 | [diff] [blame] | 498 | #if HAVE_STRUCT_STAT_ST_FLAGS |
Dmitry V. Levin | 2928afe | 2014-12-28 17:44:13 +0000 | [diff] [blame] | 499 | tprintf(", st_flags=%u", statbuf->st_flags); |
John Hughes | c0fc3fd | 2001-03-08 16:10:40 +0000 | [diff] [blame] | 500 | #endif |
Roland McGrath | 6d2b349 | 2002-12-30 00:51:30 +0000 | [diff] [blame] | 501 | #if HAVE_STRUCT_STAT_ST_FSTYPE |
John Hughes | c0fc3fd | 2001-03-08 16:10:40 +0000 | [diff] [blame] | 502 | tprintf(", st_fstype=%.*s", |
| 503 | (int) sizeof statbuf.st_fstype, statbuf.st_fstype); |
| 504 | #endif |
Roland McGrath | 6d2b349 | 2002-12-30 00:51:30 +0000 | [diff] [blame] | 505 | #if HAVE_STRUCT_STAT_ST_GEN |
John Hughes | c0fc3fd | 2001-03-08 16:10:40 +0000 | [diff] [blame] | 506 | tprintf(", st_gen=%u", statbuf.st_gen); |
| 507 | #endif |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 508 | tprints("}"); |
Ulrich Drepper | 7f02c4d | 1999-12-24 08:01:34 +0000 | [diff] [blame] | 509 | } |
| 510 | else |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 511 | tprints("...}"); |
Ulrich Drepper | 7f02c4d | 1999-12-24 08:01:34 +0000 | [diff] [blame] | 512 | } |
Wichert Akkerman | c792698 | 2000-04-10 22:22:31 +0000 | [diff] [blame] | 513 | #endif /* HAVE_STAT64 */ |
Ulrich Drepper | 7f02c4d | 1999-12-24 08:01:34 +0000 | [diff] [blame] | 514 | |
Denys Vlasenko | 8435d67 | 2013-02-18 15:47:57 +0100 | [diff] [blame] | 515 | #if defined(HAVE_STRUCT___OLD_KERNEL_STAT) |
Ulrich Drepper | 7f02c4d | 1999-12-24 08:01:34 +0000 | [diff] [blame] | 516 | static void |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 517 | convertoldstat(const struct __old_kernel_stat *oldbuf, struct stat *newbuf) |
Wichert Akkerman | 328c5e7 | 1999-04-16 00:21:26 +0000 | [diff] [blame] | 518 | { |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 519 | newbuf->st_dev = oldbuf->st_dev; |
| 520 | newbuf->st_ino = oldbuf->st_ino; |
| 521 | newbuf->st_mode = oldbuf->st_mode; |
| 522 | newbuf->st_nlink = oldbuf->st_nlink; |
| 523 | newbuf->st_uid = oldbuf->st_uid; |
| 524 | newbuf->st_gid = oldbuf->st_gid; |
| 525 | newbuf->st_rdev = oldbuf->st_rdev; |
| 526 | newbuf->st_size = oldbuf->st_size; |
| 527 | newbuf->st_atime = oldbuf->st_atime; |
| 528 | newbuf->st_mtime = oldbuf->st_mtime; |
| 529 | newbuf->st_ctime = oldbuf->st_ctime; |
| 530 | newbuf->st_blksize = 0; /* not supported in old_stat */ |
| 531 | newbuf->st_blocks = 0; /* not supported in old_stat */ |
Wichert Akkerman | 328c5e7 | 1999-04-16 00:21:26 +0000 | [diff] [blame] | 532 | } |
Wichert Akkerman | 328c5e7 | 1999-04-16 00:21:26 +0000 | [diff] [blame] | 533 | |
Wichert Akkerman | 328c5e7 | 1999-04-16 00:21:26 +0000 | [diff] [blame] | 534 | static void |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 535 | printoldstat(struct tcb *tcp, long addr) |
Wichert Akkerman | 328c5e7 | 1999-04-16 00:21:26 +0000 | [diff] [blame] | 536 | { |
Wichert Akkerman | 25d0c4f | 1999-04-18 19:35:42 +0000 | [diff] [blame] | 537 | struct __old_kernel_stat statbuf; |
| 538 | struct stat newstatbuf; |
Wichert Akkerman | 328c5e7 | 1999-04-16 00:21:26 +0000 | [diff] [blame] | 539 | |
Wichert Akkerman | 328c5e7 | 1999-04-16 00:21:26 +0000 | [diff] [blame] | 540 | if (!addr) { |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 541 | tprints("NULL"); |
Wichert Akkerman | 328c5e7 | 1999-04-16 00:21:26 +0000 | [diff] [blame] | 542 | return; |
| 543 | } |
| 544 | if (syserror(tcp) || !verbose(tcp)) { |
Wichert Akkerman | 8b1b40c | 2000-02-03 21:58:30 +0000 | [diff] [blame] | 545 | tprintf("%#lx", addr); |
Wichert Akkerman | 328c5e7 | 1999-04-16 00:21:26 +0000 | [diff] [blame] | 546 | return; |
| 547 | } |
Denys Vlasenko | 4e718b5 | 2009-04-20 18:30:13 +0000 | [diff] [blame] | 548 | |
Denys Vlasenko | 9472a27 | 2013-02-12 11:43:46 +0100 | [diff] [blame] | 549 | # if defined(SPARC) || defined(SPARC64) |
Denys Vlasenko | 4e718b5 | 2009-04-20 18:30:13 +0000 | [diff] [blame] | 550 | if (current_personality == 1) { |
| 551 | printstatsol(tcp, addr); |
| 552 | return; |
| 553 | } |
Denys Vlasenko | 8470374 | 2012-02-25 02:38:52 +0100 | [diff] [blame] | 554 | # endif |
Denys Vlasenko | 4e718b5 | 2009-04-20 18:30:13 +0000 | [diff] [blame] | 555 | |
Wichert Akkerman | 328c5e7 | 1999-04-16 00:21:26 +0000 | [diff] [blame] | 556 | if (umove(tcp, addr, &statbuf) < 0) { |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 557 | tprints("{...}"); |
Wichert Akkerman | 328c5e7 | 1999-04-16 00:21:26 +0000 | [diff] [blame] | 558 | return; |
| 559 | } |
| 560 | |
| 561 | convertoldstat(&statbuf, &newstatbuf); |
Dmitry V. Levin | d01f0a8 | 2014-12-28 18:00:39 +0000 | [diff] [blame] | 562 | do_printstat(tcp, &newstatbuf); |
Wichert Akkerman | 328c5e7 | 1999-04-16 00:21:26 +0000 | [diff] [blame] | 563 | } |
Denys Vlasenko | 8470374 | 2012-02-25 02:38:52 +0100 | [diff] [blame] | 564 | #endif |
Wichert Akkerman | 328c5e7 | 1999-04-16 00:21:26 +0000 | [diff] [blame] | 565 | |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 566 | int |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 567 | sys_stat(struct tcb *tcp) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 568 | { |
| 569 | if (entering(tcp)) { |
| 570 | printpath(tcp, tcp->u_arg[0]); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 571 | tprints(", "); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 572 | } else { |
| 573 | printstat(tcp, tcp->u_arg[1]); |
| 574 | } |
| 575 | return 0; |
| 576 | } |
| 577 | |
Dmitry V. Levin | 0eeda2c | 2013-05-01 16:37:08 +0000 | [diff] [blame] | 578 | #ifdef X32 |
| 579 | static void |
| 580 | printstat64_x32(struct tcb *tcp, long addr) |
| 581 | { |
| 582 | struct stat64 statbuf; |
| 583 | |
| 584 | if (!addr) { |
| 585 | tprints("NULL"); |
| 586 | return; |
| 587 | } |
| 588 | if (syserror(tcp) || !verbose(tcp)) { |
| 589 | tprintf("%#lx", addr); |
| 590 | return; |
| 591 | } |
| 592 | |
| 593 | if (umove(tcp, addr, &statbuf) < 0) { |
| 594 | tprints("{...}"); |
| 595 | return; |
| 596 | } |
| 597 | |
| 598 | if (!abbrev(tcp)) { |
| 599 | tprintf("{st_dev=makedev(%lu, %lu), st_ino=%llu, st_mode=%s, ", |
| 600 | (unsigned long) major(statbuf.st_dev), |
| 601 | (unsigned long) minor(statbuf.st_dev), |
| 602 | (unsigned long long) statbuf.st_ino, |
| 603 | sprintmode(statbuf.st_mode)); |
| 604 | tprintf("st_nlink=%lu, st_uid=%lu, st_gid=%lu, ", |
| 605 | (unsigned long) statbuf.st_nlink, |
| 606 | (unsigned long) statbuf.st_uid, |
| 607 | (unsigned long) statbuf.st_gid); |
| 608 | tprintf("st_blksize=%lu, ", |
| 609 | (unsigned long) statbuf.st_blksize); |
| 610 | tprintf("st_blocks=%lu, ", (unsigned long) statbuf.st_blocks); |
| 611 | } |
| 612 | else |
| 613 | tprintf("{st_mode=%s, ", sprintmode(statbuf.st_mode)); |
| 614 | switch (statbuf.st_mode & S_IFMT) { |
| 615 | case S_IFCHR: case S_IFBLK: |
| 616 | tprintf("st_rdev=makedev(%lu, %lu), ", |
| 617 | (unsigned long) major(statbuf.st_rdev), |
| 618 | (unsigned long) minor(statbuf.st_rdev)); |
| 619 | break; |
| 620 | default: |
| 621 | tprintf("st_size=%llu, ", (unsigned long long) statbuf.st_size); |
| 622 | break; |
| 623 | } |
| 624 | if (!abbrev(tcp)) { |
| 625 | tprintf("st_atime=%s, ", sprinttime(statbuf.st_atime)); |
| 626 | tprintf("st_mtime=%s, ", sprinttime(statbuf.st_mtime)); |
| 627 | tprintf("st_ctime=%s", sprinttime(statbuf.st_ctime)); |
| 628 | tprints("}"); |
| 629 | } |
| 630 | else |
| 631 | tprints("...}"); |
| 632 | } |
| 633 | #endif /* X32 */ |
| 634 | |
Wichert Akkerman | 328c5e7 | 1999-04-16 00:21:26 +0000 | [diff] [blame] | 635 | int |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 636 | sys_stat64(struct tcb *tcp) |
Ulrich Drepper | 7f02c4d | 1999-12-24 08:01:34 +0000 | [diff] [blame] | 637 | { |
| 638 | #ifdef HAVE_STAT64 |
| 639 | if (entering(tcp)) { |
| 640 | printpath(tcp, tcp->u_arg[0]); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 641 | tprints(", "); |
Ulrich Drepper | 7f02c4d | 1999-12-24 08:01:34 +0000 | [diff] [blame] | 642 | } else { |
Dmitry V. Levin | 0eeda2c | 2013-05-01 16:37:08 +0000 | [diff] [blame] | 643 | # ifdef X32 |
| 644 | printstat64_x32(tcp, tcp->u_arg[1]); |
| 645 | # else |
Ulrich Drepper | 7f02c4d | 1999-12-24 08:01:34 +0000 | [diff] [blame] | 646 | printstat64(tcp, tcp->u_arg[1]); |
Dmitry V. Levin | 0eeda2c | 2013-05-01 16:37:08 +0000 | [diff] [blame] | 647 | # endif |
Ulrich Drepper | 7f02c4d | 1999-12-24 08:01:34 +0000 | [diff] [blame] | 648 | } |
| 649 | return 0; |
| 650 | #else |
| 651 | return printargs(tcp); |
| 652 | #endif |
| 653 | } |
| 654 | |
Dmitry V. Levin | 95ebf5a | 2006-10-13 20:25:12 +0000 | [diff] [blame] | 655 | int |
| 656 | sys_newfstatat(struct tcb *tcp) |
| 657 | { |
| 658 | if (entering(tcp)) { |
Dmitry V. Levin | 3138213 | 2011-03-04 05:08:02 +0300 | [diff] [blame] | 659 | print_dirfd(tcp, tcp->u_arg[0]); |
Dmitry V. Levin | 95ebf5a | 2006-10-13 20:25:12 +0000 | [diff] [blame] | 660 | printpath(tcp, tcp->u_arg[1]); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 661 | tprints(", "); |
Dmitry V. Levin | 95ebf5a | 2006-10-13 20:25:12 +0000 | [diff] [blame] | 662 | } else { |
Andreas Schwab | d69fa49 | 2010-07-12 21:39:57 +0200 | [diff] [blame] | 663 | #ifdef POWERPC64 |
| 664 | if (current_personality == 0) |
| 665 | printstat(tcp, tcp->u_arg[2]); |
| 666 | else |
| 667 | printstat64(tcp, tcp->u_arg[2]); |
| 668 | #elif defined HAVE_STAT64 |
Dmitry V. Levin | 95ebf5a | 2006-10-13 20:25:12 +0000 | [diff] [blame] | 669 | printstat64(tcp, tcp->u_arg[2]); |
| 670 | #else |
| 671 | printstat(tcp, tcp->u_arg[2]); |
| 672 | #endif |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 673 | tprints(", "); |
Dmitry V. Levin | 7989ad4 | 2012-03-13 23:26:01 +0000 | [diff] [blame] | 674 | printflags(at_flags, tcp->u_arg[3], "AT_???"); |
Dmitry V. Levin | 95ebf5a | 2006-10-13 20:25:12 +0000 | [diff] [blame] | 675 | } |
| 676 | return 0; |
| 677 | } |
Dmitry V. Levin | 95ebf5a | 2006-10-13 20:25:12 +0000 | [diff] [blame] | 678 | |
Denys Vlasenko | 8435d67 | 2013-02-18 15:47:57 +0100 | [diff] [blame] | 679 | #if defined(HAVE_STRUCT___OLD_KERNEL_STAT) |
Ulrich Drepper | 7f02c4d | 1999-12-24 08:01:34 +0000 | [diff] [blame] | 680 | int |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 681 | sys_oldstat(struct tcb *tcp) |
Wichert Akkerman | 328c5e7 | 1999-04-16 00:21:26 +0000 | [diff] [blame] | 682 | { |
| 683 | if (entering(tcp)) { |
| 684 | printpath(tcp, tcp->u_arg[0]); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 685 | tprints(", "); |
Wichert Akkerman | 328c5e7 | 1999-04-16 00:21:26 +0000 | [diff] [blame] | 686 | } else { |
| 687 | printoldstat(tcp, tcp->u_arg[1]); |
| 688 | } |
| 689 | return 0; |
| 690 | } |
Denys Vlasenko | 8470374 | 2012-02-25 02:38:52 +0100 | [diff] [blame] | 691 | #endif |
Wichert Akkerman | 328c5e7 | 1999-04-16 00:21:26 +0000 | [diff] [blame] | 692 | |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 693 | int |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 694 | sys_fstat(struct tcb *tcp) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 695 | { |
Dmitry V. Levin | 3138213 | 2011-03-04 05:08:02 +0300 | [diff] [blame] | 696 | if (entering(tcp)) { |
| 697 | printfd(tcp, tcp->u_arg[0]); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 698 | tprints(", "); |
Dmitry V. Levin | 3138213 | 2011-03-04 05:08:02 +0300 | [diff] [blame] | 699 | } else { |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 700 | printstat(tcp, tcp->u_arg[1]); |
| 701 | } |
| 702 | return 0; |
| 703 | } |
| 704 | |
Wichert Akkerman | 328c5e7 | 1999-04-16 00:21:26 +0000 | [diff] [blame] | 705 | int |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 706 | sys_fstat64(struct tcb *tcp) |
Ulrich Drepper | 7f02c4d | 1999-12-24 08:01:34 +0000 | [diff] [blame] | 707 | { |
| 708 | #ifdef HAVE_STAT64 |
Dmitry V. Levin | 3138213 | 2011-03-04 05:08:02 +0300 | [diff] [blame] | 709 | if (entering(tcp)) { |
| 710 | printfd(tcp, tcp->u_arg[0]); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 711 | tprints(", "); |
Dmitry V. Levin | 3138213 | 2011-03-04 05:08:02 +0300 | [diff] [blame] | 712 | } else { |
Dmitry V. Levin | 0eeda2c | 2013-05-01 16:37:08 +0000 | [diff] [blame] | 713 | # ifdef X32 |
| 714 | printstat64_x32(tcp, tcp->u_arg[1]); |
| 715 | # else |
Ulrich Drepper | 7f02c4d | 1999-12-24 08:01:34 +0000 | [diff] [blame] | 716 | printstat64(tcp, tcp->u_arg[1]); |
Dmitry V. Levin | 0eeda2c | 2013-05-01 16:37:08 +0000 | [diff] [blame] | 717 | # endif |
Ulrich Drepper | 7f02c4d | 1999-12-24 08:01:34 +0000 | [diff] [blame] | 718 | } |
| 719 | return 0; |
| 720 | #else |
| 721 | return printargs(tcp); |
| 722 | #endif |
| 723 | } |
| 724 | |
Denys Vlasenko | 8435d67 | 2013-02-18 15:47:57 +0100 | [diff] [blame] | 725 | #if defined(HAVE_STRUCT___OLD_KERNEL_STAT) |
Ulrich Drepper | 7f02c4d | 1999-12-24 08:01:34 +0000 | [diff] [blame] | 726 | int |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 727 | sys_oldfstat(struct tcb *tcp) |
Wichert Akkerman | 328c5e7 | 1999-04-16 00:21:26 +0000 | [diff] [blame] | 728 | { |
Dmitry V. Levin | 3138213 | 2011-03-04 05:08:02 +0300 | [diff] [blame] | 729 | if (entering(tcp)) { |
| 730 | printfd(tcp, tcp->u_arg[0]); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 731 | tprints(", "); |
Dmitry V. Levin | 3138213 | 2011-03-04 05:08:02 +0300 | [diff] [blame] | 732 | } else { |
Wichert Akkerman | 328c5e7 | 1999-04-16 00:21:26 +0000 | [diff] [blame] | 733 | printoldstat(tcp, tcp->u_arg[1]); |
| 734 | } |
| 735 | return 0; |
| 736 | } |
Denys Vlasenko | 8470374 | 2012-02-25 02:38:52 +0100 | [diff] [blame] | 737 | #endif |
Wichert Akkerman | 328c5e7 | 1999-04-16 00:21:26 +0000 | [diff] [blame] | 738 | |
Denys Vlasenko | 9472a27 | 2013-02-12 11:43:46 +0100 | [diff] [blame] | 739 | #if defined(SPARC) || defined(SPARC64) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 740 | |
| 741 | int |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 742 | sys_xstat(struct tcb *tcp) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 743 | { |
| 744 | if (entering(tcp)) { |
| 745 | tprintf("%ld, ", tcp->u_arg[0]); |
| 746 | printpath(tcp, tcp->u_arg[1]); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 747 | tprints(", "); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 748 | } else { |
| 749 | printstat(tcp, tcp->u_arg[2]); |
| 750 | } |
| 751 | return 0; |
| 752 | } |
| 753 | |
| 754 | int |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 755 | sys_fxstat(struct tcb *tcp) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 756 | { |
Dmitry V. Levin | e00a957 | 2014-12-29 03:15:42 +0000 | [diff] [blame] | 757 | if (entering(tcp)) { |
| 758 | tprintf("%ld, ", tcp->u_arg[0]); |
| 759 | printfd(tcp, tcp->u_arg[1]); |
| 760 | tprints(", "); |
| 761 | } else { |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 762 | printstat(tcp, tcp->u_arg[2]); |
| 763 | } |
| 764 | return 0; |
| 765 | } |
| 766 | |
Dmitry V. Levin | 964d80a | 2014-12-06 03:53:16 +0000 | [diff] [blame] | 767 | #endif /* SPARC || SPARC64 */ |