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 | |
Dmitry V. Levin | f19836b | 2014-12-30 11:18:47 +0000 | [diff] [blame] | 33 | #undef dev_t |
| 34 | #undef ino_t |
| 35 | #undef mode_t |
| 36 | #undef nlink_t |
| 37 | #undef uid_t |
| 38 | #undef gid_t |
| 39 | #undef off_t |
| 40 | #undef loff_t |
| 41 | #define dev_t __kernel_dev_t |
| 42 | #define ino_t __kernel_ino_t |
| 43 | #define mode_t __kernel_mode_t |
| 44 | #define nlink_t __kernel_nlink_t |
| 45 | #define uid_t __kernel_uid_t |
| 46 | #define gid_t __kernel_gid_t |
| 47 | #define off_t __kernel_off_t |
| 48 | #define loff_t __kernel_loff_t |
Wichert Akkerman | a601370 | 1999-07-08 14:00:58 +0000 | [diff] [blame] | 49 | |
Dmitry V. Levin | c31481f | 2015-12-04 14:37:02 +0000 | [diff] [blame] | 50 | #include "asm_stat.h" |
Wichert Akkerman | a601370 | 1999-07-08 14:00:58 +0000 | [diff] [blame] | 51 | |
Dmitry V. Levin | f19836b | 2014-12-30 11:18:47 +0000 | [diff] [blame] | 52 | #undef dev_t |
| 53 | #undef ino_t |
| 54 | #undef mode_t |
| 55 | #undef nlink_t |
| 56 | #undef uid_t |
| 57 | #undef gid_t |
| 58 | #undef off_t |
| 59 | #undef loff_t |
| 60 | #define dev_t dev_t |
| 61 | #define ino_t ino_t |
| 62 | #define mode_t mode_t |
| 63 | #define nlink_t nlink_t |
| 64 | #define uid_t uid_t |
| 65 | #define gid_t gid_t |
| 66 | #define off_t off_t |
| 67 | #define loff_t loff_t |
Denys Vlasenko | 8470374 | 2012-02-25 02:38:52 +0100 | [diff] [blame] | 68 | |
Dmitry V. Levin | f19836b | 2014-12-30 11:18:47 +0000 | [diff] [blame] | 69 | /* for S_IFMT */ |
Denys Vlasenko | 8470374 | 2012-02-25 02:38:52 +0100 | [diff] [blame] | 70 | #define stat libc_stat |
| 71 | #define stat64 libc_stat64 |
| 72 | #include <sys/stat.h> |
| 73 | #undef stat |
| 74 | #undef stat64 |
Denys Vlasenko | a6d91de | 2012-03-16 12:02:22 +0100 | [diff] [blame] | 75 | /* These might be macros. */ |
Denys Vlasenko | 8470374 | 2012-02-25 02:38:52 +0100 | [diff] [blame] | 76 | #undef st_atime |
| 77 | #undef st_mtime |
| 78 | #undef st_ctime |
Wichert Akkerman | d4d8e92 | 1999-04-18 23:30:29 +0000 | [diff] [blame] | 79 | |
Dmitry V. Levin | f19836b | 2014-12-30 11:18:47 +0000 | [diff] [blame] | 80 | #if defined MAJOR_IN_SYSMACROS |
Denys Vlasenko | 8470374 | 2012-02-25 02:38:52 +0100 | [diff] [blame] | 81 | # include <sys/sysmacros.h> |
Dmitry V. Levin | f19836b | 2014-12-30 11:18:47 +0000 | [diff] [blame] | 82 | #elif defined MAJOR_IN_MKDEV |
Denys Vlasenko | 8470374 | 2012-02-25 02:38:52 +0100 | [diff] [blame] | 83 | # include <sys/mkdev.h> |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 84 | #endif |
| 85 | |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 86 | /* several stats */ |
| 87 | |
Dmitry V. Levin | 721de78 | 2015-01-08 02:59:04 +0000 | [diff] [blame] | 88 | #include "printstat.h" |
| 89 | |
Dmitry V. Levin | 525eed3 | 2015-08-08 12:12:13 +0000 | [diff] [blame] | 90 | /* all locally defined structures provide these fields */ |
Dmitry V. Levin | 525eed3 | 2015-08-08 12:12:13 +0000 | [diff] [blame] | 91 | #undef HAVE_STRUCT_STAT_ST_MTIME_NSEC |
| 92 | #define HAVE_STRUCT_STAT_ST_MTIME_NSEC 1 |
| 93 | |
Dmitry V. Levin | f19836b | 2014-12-30 11:18:47 +0000 | [diff] [blame] | 94 | #undef STAT32_PERSONALITY |
| 95 | #if SUPPORTED_PERSONALITIES > 1 |
Dmitry V. Levin | 09dee9a | 2016-08-09 09:50:13 +0000 | [diff] [blame] | 96 | # include "stat32.h" |
| 97 | #endif |
Andreas Schwab | d69fa49 | 2010-07-12 21:39:57 +0200 | [diff] [blame] | 98 | |
Dmitry V. Levin | f19836b | 2014-12-30 11:18:47 +0000 | [diff] [blame] | 99 | #ifdef STAT32_PERSONALITY |
Dmitry V. Levin | 721de78 | 2015-01-08 02:59:04 +0000 | [diff] [blame] | 100 | # define DO_PRINTSTAT do_printstat32 |
Dmitry V. Levin | f19836b | 2014-12-30 11:18:47 +0000 | [diff] [blame] | 101 | # define STRUCT_STAT struct stat32 |
Dmitry V. Levin | 721de78 | 2015-01-08 02:59:04 +0000 | [diff] [blame] | 102 | # include "printstat.h" |
Dmitry V. Levin | f19836b | 2014-12-30 11:18:47 +0000 | [diff] [blame] | 103 | #endif /* STAT32_PERSONALITY */ |
Andreas Schwab | d69fa49 | 2010-07-12 21:39:57 +0200 | [diff] [blame] | 104 | |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 105 | static void |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 106 | printstat(struct tcb *tcp, long addr) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 107 | { |
Wichert Akkerman | 328c5e7 | 1999-04-16 00:21:26 +0000 | [diff] [blame] | 108 | struct stat statbuf; |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 109 | |
Dmitry V. Levin | f19836b | 2014-12-30 11:18:47 +0000 | [diff] [blame] | 110 | #ifdef STAT32_PERSONALITY |
| 111 | if (current_personality == STAT32_PERSONALITY) { |
Dmitry V. Levin | b6d80ff | 2015-07-20 12:09:44 +0000 | [diff] [blame] | 112 | struct stat32 statbuf; |
| 113 | |
| 114 | if (!umove_or_printaddr(tcp, addr, &statbuf)) |
| 115 | do_printstat32(tcp, &statbuf); |
Dmitry V. Levin | f19836b | 2014-12-30 11:18:47 +0000 | [diff] [blame] | 116 | return; |
| 117 | } |
| 118 | #endif |
| 119 | |
Dmitry V. Levin | b6d80ff | 2015-07-20 12:09:44 +0000 | [diff] [blame] | 120 | if (!umove_or_printaddr(tcp, addr, &statbuf)) |
| 121 | do_printstat(tcp, &statbuf); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 122 | } |
| 123 | |
Dmitry V. Levin | a0bd374 | 2015-04-07 01:36:50 +0000 | [diff] [blame] | 124 | SYS_FUNC(stat) |
Dmitry V. Levin | c6ee0ec | 2015-01-08 01:14:53 +0000 | [diff] [blame] | 125 | { |
| 126 | if (entering(tcp)) { |
| 127 | printpath(tcp, tcp->u_arg[0]); |
| 128 | tprints(", "); |
| 129 | } else { |
| 130 | printstat(tcp, tcp->u_arg[1]); |
| 131 | } |
| 132 | return 0; |
| 133 | } |
| 134 | |
Dmitry V. Levin | a0bd374 | 2015-04-07 01:36:50 +0000 | [diff] [blame] | 135 | SYS_FUNC(fstat) |
Dmitry V. Levin | c6ee0ec | 2015-01-08 01:14:53 +0000 | [diff] [blame] | 136 | { |
| 137 | if (entering(tcp)) { |
| 138 | printfd(tcp, tcp->u_arg[0]); |
| 139 | tprints(", "); |
| 140 | } else { |
| 141 | printstat(tcp, tcp->u_arg[1]); |
| 142 | } |
| 143 | return 0; |
| 144 | } |
| 145 | |
Dmitry V. Levin | 7b9bc44 | 2015-01-08 04:06:06 +0000 | [diff] [blame] | 146 | #if defined STAT32_PERSONALITY && !defined HAVE_STRUCT_STAT64 |
Dmitry V. Levin | f19836b | 2014-12-30 11:18:47 +0000 | [diff] [blame] | 147 | # if defined AARCH64 || defined X86_64 || defined X32 |
Roland McGrath | e6d0f71 | 2007-08-07 01:22:49 +0000 | [diff] [blame] | 148 | /* |
Dmitry V. Levin | 8d41108 | 2014-12-28 16:41:24 +0000 | [diff] [blame] | 149 | * Linux x86_64 and x32 have unified `struct stat' but their i386 personality |
| 150 | * needs `struct stat64'. |
| 151 | * linux/arch/x86/include/uapi/asm/stat.h defines `struct stat64' only for i386. |
Elliott Hughes | 391c0d8 | 2014-04-03 17:50:14 -0700 | [diff] [blame] | 152 | * |
| 153 | * Similarly, aarch64 has a unified `struct stat' but its arm personality |
Dmitry V. Levin | 8d41108 | 2014-12-28 16:41:24 +0000 | [diff] [blame] | 154 | * needs `struct stat64' (unlike x86, it shouldn't be packed). |
Roland McGrath | e6d0f71 | 2007-08-07 01:22:49 +0000 | [diff] [blame] | 155 | */ |
| 156 | struct stat64 { |
| 157 | unsigned long long st_dev; |
| 158 | unsigned char __pad0[4]; |
| 159 | unsigned int __st_ino; |
| 160 | unsigned int st_mode; |
| 161 | unsigned int st_nlink; |
| 162 | unsigned int st_uid; |
| 163 | unsigned int st_gid; |
| 164 | unsigned long long st_rdev; |
| 165 | unsigned char __pad3[4]; |
| 166 | long long st_size; |
| 167 | unsigned int st_blksize; |
| 168 | unsigned long long st_blocks; |
| 169 | unsigned int st_atime; |
| 170 | unsigned int st_atime_nsec; |
| 171 | unsigned int st_mtime; |
| 172 | unsigned int st_mtime_nsec; |
| 173 | unsigned int st_ctime; |
| 174 | unsigned int st_ctime_nsec; |
| 175 | unsigned long long st_ino; |
Elliott Hughes | 391c0d8 | 2014-04-03 17:50:14 -0700 | [diff] [blame] | 176 | } |
Dmitry V. Levin | f19836b | 2014-12-30 11:18:47 +0000 | [diff] [blame] | 177 | # if defined X86_64 || defined X32 |
Dmitry V. Levin | 5647cf8 | 2015-03-29 22:45:03 +0000 | [diff] [blame] | 178 | ATTRIBUTE_PACKED |
Dmitry V. Levin | f19836b | 2014-12-30 11:18:47 +0000 | [diff] [blame] | 179 | # define STAT64_SIZE 96 |
| 180 | # else |
| 181 | # define STAT64_SIZE 104 |
| 182 | # endif |
Elliott Hughes | 391c0d8 | 2014-04-03 17:50:14 -0700 | [diff] [blame] | 183 | ; |
Dmitry V. Levin | 7b9bc44 | 2015-01-08 04:06:06 +0000 | [diff] [blame] | 184 | # define HAVE_STRUCT_STAT64 1 |
Dmitry V. Levin | f19836b | 2014-12-30 11:18:47 +0000 | [diff] [blame] | 185 | # else /* !(AARCH64 || X86_64 || X32) */ |
| 186 | # warning FIXME: check whether struct stat64 definition is needed for this architecture! |
| 187 | # endif |
Dmitry V. Levin | 7b9bc44 | 2015-01-08 04:06:06 +0000 | [diff] [blame] | 188 | #endif /* STAT32_PERSONALITY && !HAVE_STRUCT_STAT64 */ |
Roland McGrath | e6d0f71 | 2007-08-07 01:22:49 +0000 | [diff] [blame] | 189 | |
Dmitry V. Levin | 7b9bc44 | 2015-01-08 04:06:06 +0000 | [diff] [blame] | 190 | #ifdef HAVE_STRUCT_STAT64 |
Dmitry V. Levin | b8ad393 | 2014-12-28 18:56:23 +0000 | [diff] [blame] | 191 | |
| 192 | # define DO_PRINTSTAT do_printstat64 |
| 193 | # define STRUCT_STAT struct stat64 |
Dmitry V. Levin | b8ad393 | 2014-12-28 18:56:23 +0000 | [diff] [blame] | 194 | # include "printstat.h" |
| 195 | |
Wichert Akkerman | 328c5e7 | 1999-04-16 00:21:26 +0000 | [diff] [blame] | 196 | static void |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 197 | printstat64(struct tcb *tcp, long addr) |
Ulrich Drepper | 7f02c4d | 1999-12-24 08:01:34 +0000 | [diff] [blame] | 198 | { |
| 199 | struct stat64 statbuf; |
| 200 | |
Dmitry V. Levin | f19836b | 2014-12-30 11:18:47 +0000 | [diff] [blame] | 201 | # ifdef STAT64_SIZE |
Roland McGrath | e6d0f71 | 2007-08-07 01:22:49 +0000 | [diff] [blame] | 202 | (void) sizeof(char[sizeof statbuf == STAT64_SIZE ? 1 : -1]); |
Dmitry V. Levin | f19836b | 2014-12-30 11:18:47 +0000 | [diff] [blame] | 203 | # endif |
Roland McGrath | e6d0f71 | 2007-08-07 01:22:49 +0000 | [diff] [blame] | 204 | |
Dmitry V. Levin | 5f5fd0d | 2016-08-22 09:34:54 +0000 | [diff] [blame] | 205 | # if defined STAT32_PERSONALITY && !defined SPARC64 |
Dmitry V. Levin | f19836b | 2014-12-30 11:18:47 +0000 | [diff] [blame] | 206 | if (current_personality != STAT32_PERSONALITY) { |
Elliott Hughes | 391c0d8 | 2014-04-03 17:50:14 -0700 | [diff] [blame] | 207 | printstat(tcp, addr); |
| 208 | return; |
| 209 | } |
Dmitry V. Levin | 5f5fd0d | 2016-08-22 09:34:54 +0000 | [diff] [blame] | 210 | # endif /* STAT32_PERSONALITY && !SPARC64 */ |
Dmitry V. Levin | ff896f7 | 2009-10-21 13:43:57 +0000 | [diff] [blame] | 211 | |
Dmitry V. Levin | b6d80ff | 2015-07-20 12:09:44 +0000 | [diff] [blame] | 212 | if (!umove_or_printaddr(tcp, addr, &statbuf)) |
| 213 | do_printstat64(tcp, &statbuf); |
Ulrich Drepper | 7f02c4d | 1999-12-24 08:01:34 +0000 | [diff] [blame] | 214 | } |
| 215 | |
Dmitry V. Levin | a0bd374 | 2015-04-07 01:36:50 +0000 | [diff] [blame] | 216 | SYS_FUNC(stat64) |
Ulrich Drepper | 7f02c4d | 1999-12-24 08:01:34 +0000 | [diff] [blame] | 217 | { |
Ulrich Drepper | 7f02c4d | 1999-12-24 08:01:34 +0000 | [diff] [blame] | 218 | if (entering(tcp)) { |
| 219 | printpath(tcp, tcp->u_arg[0]); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 220 | tprints(", "); |
Ulrich Drepper | 7f02c4d | 1999-12-24 08:01:34 +0000 | [diff] [blame] | 221 | } else { |
| 222 | printstat64(tcp, tcp->u_arg[1]); |
| 223 | } |
| 224 | return 0; |
Ulrich Drepper | 7f02c4d | 1999-12-24 08:01:34 +0000 | [diff] [blame] | 225 | } |
| 226 | |
Dmitry V. Levin | a0bd374 | 2015-04-07 01:36:50 +0000 | [diff] [blame] | 227 | SYS_FUNC(fstat64) |
Dmitry V. Levin | c6ee0ec | 2015-01-08 01:14:53 +0000 | [diff] [blame] | 228 | { |
Dmitry V. Levin | c6ee0ec | 2015-01-08 01:14:53 +0000 | [diff] [blame] | 229 | if (entering(tcp)) { |
| 230 | printfd(tcp, tcp->u_arg[0]); |
| 231 | tprints(", "); |
| 232 | } else { |
| 233 | printstat64(tcp, tcp->u_arg[1]); |
| 234 | } |
| 235 | return 0; |
Dmitry V. Levin | c6ee0ec | 2015-01-08 01:14:53 +0000 | [diff] [blame] | 236 | } |
| 237 | |
Dmitry V. Levin | f19836b | 2014-12-30 11:18:47 +0000 | [diff] [blame] | 238 | #else |
| 239 | |
Dmitry V. Levin | a0bd374 | 2015-04-07 01:36:50 +0000 | [diff] [blame] | 240 | SYS_FUNC(stat64) |
Dmitry V. Levin | f19836b | 2014-12-30 11:18:47 +0000 | [diff] [blame] | 241 | { |
| 242 | return sys_stat(tcp); |
| 243 | } |
| 244 | |
Dmitry V. Levin | a0bd374 | 2015-04-07 01:36:50 +0000 | [diff] [blame] | 245 | SYS_FUNC(fstat64) |
Dmitry V. Levin | f19836b | 2014-12-30 11:18:47 +0000 | [diff] [blame] | 246 | { |
| 247 | return sys_fstat(tcp); |
| 248 | } |
| 249 | |
Dmitry V. Levin | 7b9bc44 | 2015-01-08 04:06:06 +0000 | [diff] [blame] | 250 | #endif /* HAVE_STRUCT_STAT64 */ |
Dmitry V. Levin | f19836b | 2014-12-30 11:18:47 +0000 | [diff] [blame] | 251 | |
Dmitry V. Levin | a0bd374 | 2015-04-07 01:36:50 +0000 | [diff] [blame] | 252 | SYS_FUNC(newfstatat) |
Dmitry V. Levin | 95ebf5a | 2006-10-13 20:25:12 +0000 | [diff] [blame] | 253 | { |
| 254 | if (entering(tcp)) { |
Dmitry V. Levin | 3138213 | 2011-03-04 05:08:02 +0300 | [diff] [blame] | 255 | print_dirfd(tcp, tcp->u_arg[0]); |
Dmitry V. Levin | 95ebf5a | 2006-10-13 20:25:12 +0000 | [diff] [blame] | 256 | printpath(tcp, tcp->u_arg[1]); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 257 | tprints(", "); |
Dmitry V. Levin | 95ebf5a | 2006-10-13 20:25:12 +0000 | [diff] [blame] | 258 | } else { |
Dmitry V. Levin | 5f5fd0d | 2016-08-22 09:34:54 +0000 | [diff] [blame] | 259 | #if defined STAT32_PERSONALITY && !defined SPARC64 |
Dmitry V. Levin | f19836b | 2014-12-30 11:18:47 +0000 | [diff] [blame] | 260 | if (current_personality == STAT32_PERSONALITY) |
Andreas Schwab | d69fa49 | 2010-07-12 21:39:57 +0200 | [diff] [blame] | 261 | printstat64(tcp, tcp->u_arg[2]); |
Dmitry V. Levin | f19836b | 2014-12-30 11:18:47 +0000 | [diff] [blame] | 262 | else |
| 263 | printstat(tcp, tcp->u_arg[2]); |
Dmitry V. Levin | 7b9bc44 | 2015-01-08 04:06:06 +0000 | [diff] [blame] | 264 | #elif defined HAVE_STRUCT_STAT64 |
Dmitry V. Levin | 95ebf5a | 2006-10-13 20:25:12 +0000 | [diff] [blame] | 265 | printstat64(tcp, tcp->u_arg[2]); |
| 266 | #else |
| 267 | printstat(tcp, tcp->u_arg[2]); |
Dmitry V. Levin | 7b9bc44 | 2015-01-08 04:06:06 +0000 | [diff] [blame] | 268 | #endif /* STAT32_PERSONALITY || HAVE_STRUCT_STAT64 */ |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 269 | tprints(", "); |
Dmitry V. Levin | 7989ad4 | 2012-03-13 23:26:01 +0000 | [diff] [blame] | 270 | printflags(at_flags, tcp->u_arg[3], "AT_???"); |
Dmitry V. Levin | 95ebf5a | 2006-10-13 20:25:12 +0000 | [diff] [blame] | 271 | } |
| 272 | return 0; |
| 273 | } |
Dmitry V. Levin | 95ebf5a | 2006-10-13 20:25:12 +0000 | [diff] [blame] | 274 | |
Denys Vlasenko | 8435d67 | 2013-02-18 15:47:57 +0100 | [diff] [blame] | 275 | #if defined(HAVE_STRUCT___OLD_KERNEL_STAT) |
Dmitry V. Levin | 1fb1c13 | 2014-12-28 19:10:58 +0000 | [diff] [blame] | 276 | |
| 277 | static void |
| 278 | convertoldstat(const struct __old_kernel_stat *oldbuf, struct stat *newbuf) |
| 279 | { |
| 280 | memset(newbuf, 0, sizeof(*newbuf)); |
| 281 | newbuf->st_dev = oldbuf->st_dev; |
| 282 | newbuf->st_ino = oldbuf->st_ino; |
| 283 | newbuf->st_mode = oldbuf->st_mode; |
| 284 | newbuf->st_nlink = oldbuf->st_nlink; |
| 285 | newbuf->st_uid = oldbuf->st_uid; |
| 286 | newbuf->st_gid = oldbuf->st_gid; |
| 287 | newbuf->st_rdev = oldbuf->st_rdev; |
| 288 | newbuf->st_size = oldbuf->st_size; |
| 289 | newbuf->st_atime = oldbuf->st_atime; |
| 290 | newbuf->st_mtime = oldbuf->st_mtime; |
| 291 | newbuf->st_ctime = oldbuf->st_ctime; |
| 292 | } |
| 293 | |
| 294 | static void |
| 295 | printoldstat(struct tcb *tcp, long addr) |
| 296 | { |
| 297 | struct __old_kernel_stat statbuf; |
| 298 | struct stat newstatbuf; |
| 299 | |
Dmitry V. Levin | b6d80ff | 2015-07-20 12:09:44 +0000 | [diff] [blame] | 300 | if (!umove_or_printaddr(tcp, addr, &statbuf)) { |
| 301 | convertoldstat(&statbuf, &newstatbuf); |
| 302 | do_printstat(tcp, &newstatbuf); |
Dmitry V. Levin | 1fb1c13 | 2014-12-28 19:10:58 +0000 | [diff] [blame] | 303 | } |
Dmitry V. Levin | 1fb1c13 | 2014-12-28 19:10:58 +0000 | [diff] [blame] | 304 | } |
| 305 | |
Dmitry V. Levin | a0bd374 | 2015-04-07 01:36:50 +0000 | [diff] [blame] | 306 | SYS_FUNC(oldstat) |
Dmitry V. Levin | 1fb1c13 | 2014-12-28 19:10:58 +0000 | [diff] [blame] | 307 | { |
| 308 | if (entering(tcp)) { |
| 309 | printpath(tcp, tcp->u_arg[0]); |
| 310 | tprints(", "); |
| 311 | } else { |
| 312 | printoldstat(tcp, tcp->u_arg[1]); |
| 313 | } |
| 314 | return 0; |
| 315 | } |
| 316 | |
Dmitry V. Levin | a0bd374 | 2015-04-07 01:36:50 +0000 | [diff] [blame] | 317 | SYS_FUNC(oldfstat) |
Wichert Akkerman | 328c5e7 | 1999-04-16 00:21:26 +0000 | [diff] [blame] | 318 | { |
Dmitry V. Levin | 3138213 | 2011-03-04 05:08:02 +0300 | [diff] [blame] | 319 | if (entering(tcp)) { |
| 320 | printfd(tcp, tcp->u_arg[0]); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 321 | tprints(", "); |
Dmitry V. Levin | 3138213 | 2011-03-04 05:08:02 +0300 | [diff] [blame] | 322 | } else { |
Wichert Akkerman | 328c5e7 | 1999-04-16 00:21:26 +0000 | [diff] [blame] | 323 | printoldstat(tcp, tcp->u_arg[1]); |
| 324 | } |
| 325 | return 0; |
| 326 | } |
Dmitry V. Levin | 1fb1c13 | 2014-12-28 19:10:58 +0000 | [diff] [blame] | 327 | |
| 328 | #endif /* HAVE_STRUCT___OLD_KERNEL_STAT */ |