Andrew Geissler | 517393d | 2023-01-13 08:55:19 -0600 | [diff] [blame^] | 1 | From 37425f422e46003ed623f8e6387bed1aa5778b96 Mon Sep 17 00:00:00 2001 |
| 2 | From: Khem Raj <raj.khem@gmail.com> |
| 3 | Date: Fri, 11 Nov 2022 11:26:05 -0800 |
| 4 | Subject: [PATCH] Use pread/pwrite/ftruncate/stat instead of 64bit equivalents |
| 5 | |
| 6 | 64bit functions are aliases to original functions when largefile feature |
| 7 | is enabled via autoconf or right macro is passed on compiler cmdline |
| 8 | |
| 9 | -D_FILE_OFFSET_BITS=64 |
| 10 | |
| 11 | Upstream-Status: Submitted [https://lore.kernel.org/linux-btrfs/20221215084046.122836-1-raj.khem@gmail.com/T/#u] |
| 12 | Signed-off-by: Khem Raj <raj.khem@gmail.com> |
| 13 | --- |
| 14 | cmds/rescue-chunk-recover.c | 4 +- |
| 15 | image/main.c | 14 +-- |
| 16 | kernel-shared/zoned.c | 6 +- |
| 17 | kernel-shared/zoned.h | 4 +- |
| 18 | mkfs/main.c | 4 +- |
| 19 | mkfs/rootdir.c | 10 +- |
| 20 | tests/fsstress.c | 192 ++++++++++++++++++------------------ |
| 21 | tests/fssum.c | 8 +- |
| 22 | 8 files changed, 121 insertions(+), 121 deletions(-) |
| 23 | |
| 24 | --- a/cmds/rescue-chunk-recover.c |
| 25 | +++ b/cmds/rescue-chunk-recover.c |
| 26 | @@ -755,7 +755,7 @@ static int scan_one_device(void *dev_sca |
| 27 | if (is_super_block_address(bytenr)) |
| 28 | bytenr += rc->sectorsize; |
| 29 | |
| 30 | - if (pread64(fd, buf->data, rc->nodesize, bytenr) < |
| 31 | + if (pread(fd, buf->data, rc->nodesize, bytenr) < |
| 32 | rc->nodesize) |
| 33 | break; |
| 34 | |
| 35 | @@ -1875,7 +1875,7 @@ static int check_one_csum(int fd, u64 st |
| 36 | data = malloc(len); |
| 37 | if (!data) |
| 38 | return -1; |
| 39 | - ret = pread64(fd, data, len, start); |
| 40 | + ret = pread(fd, data, len, start); |
| 41 | if (ret < 0 || ret != len) { |
| 42 | ret = -1; |
| 43 | goto out; |
| 44 | --- a/image/main.c |
| 45 | +++ b/image/main.c |
| 46 | @@ -691,7 +691,7 @@ static int flush_pending(struct metadump |
| 47 | if (start == BTRFS_SUPER_INFO_OFFSET) { |
| 48 | int fd = get_dev_fd(md->root); |
| 49 | |
| 50 | - ret = pread64(fd, async->buffer, size, start); |
| 51 | + ret = pread(fd, async->buffer, size, start); |
| 52 | if (ret < size) { |
| 53 | free(async->buffer); |
| 54 | free(async); |
| 55 | @@ -1366,7 +1366,7 @@ static void write_backup_supers(int fd, |
| 56 | break; |
| 57 | btrfs_set_super_bytenr(super, bytenr); |
| 58 | csum_block(buf, BTRFS_SUPER_INFO_SIZE); |
| 59 | - ret = pwrite64(fd, buf, BTRFS_SUPER_INFO_SIZE, bytenr); |
| 60 | + ret = pwrite(fd, buf, BTRFS_SUPER_INFO_SIZE, bytenr); |
| 61 | if (ret < BTRFS_SUPER_INFO_SIZE) { |
| 62 | if (ret < 0) |
| 63 | error( |
| 64 | @@ -1487,12 +1487,12 @@ static int restore_one_work(struct mdres |
| 65 | else |
| 66 | bytenr = logical; |
| 67 | |
| 68 | - ret = pwrite64(outfd, buffer + offset, chunk_size, bytenr); |
| 69 | + ret = pwrite(outfd, buffer + offset, chunk_size, bytenr); |
| 70 | if (ret != chunk_size) |
| 71 | goto write_error; |
| 72 | |
| 73 | if (physical_dup) |
| 74 | - ret = pwrite64(outfd, buffer + offset, |
| 75 | + ret = pwrite(outfd, buffer + offset, |
| 76 | chunk_size, physical_dup); |
| 77 | if (ret != chunk_size) |
| 78 | goto write_error; |
| 79 | @@ -2454,7 +2454,7 @@ static int fixup_device_size(struct btrf |
| 80 | } |
| 81 | if (S_ISREG(buf.st_mode)) { |
| 82 | /* Don't forget to enlarge the real file */ |
| 83 | - ret = ftruncate64(out_fd, dev_size); |
| 84 | + ret = ftruncate(out_fd, dev_size); |
| 85 | if (ret < 0) { |
| 86 | error("failed to enlarge result image: %m"); |
| 87 | return -errno; |
| 88 | @@ -2913,7 +2913,7 @@ static int restore_metadump(const char * |
| 89 | goto out; |
| 90 | } |
| 91 | if (S_ISREG(st.st_mode) && st.st_size < dev_size) { |
| 92 | - ret = ftruncate64(fileno(out), dev_size); |
| 93 | + ret = ftruncate(fileno(out), dev_size); |
| 94 | if (ret < 0) { |
| 95 | error( |
| 96 | "failed to enlarge result image file from %llu to %llu: %m", |
| 97 | @@ -3010,7 +3010,7 @@ static int update_disk_super_on_device(s |
| 98 | memcpy(dev_item->fsid, fs_uuid, BTRFS_UUID_SIZE); |
| 99 | csum_block((u8 *)&disk_super, BTRFS_SUPER_INFO_SIZE); |
| 100 | |
| 101 | - ret = pwrite64(fp, &disk_super, BTRFS_SUPER_INFO_SIZE, BTRFS_SUPER_INFO_OFFSET); |
| 102 | + ret = pwrite(fp, &disk_super, BTRFS_SUPER_INFO_SIZE, BTRFS_SUPER_INFO_OFFSET); |
| 103 | if (ret != BTRFS_SUPER_INFO_SIZE) { |
| 104 | if (ret < 0) { |
| 105 | errno = ret; |
| 106 | --- a/kernel-shared/zoned.c |
| 107 | +++ b/kernel-shared/zoned.c |
| 108 | @@ -194,7 +194,7 @@ static int sb_write_pointer(int fd, stru |
| 109 | bytenr = ((zones[i].start + zones[i].len) |
| 110 | << SECTOR_SHIFT) - BTRFS_SUPER_INFO_SIZE; |
| 111 | |
| 112 | - ret = pread64(fd, buf[i], BTRFS_SUPER_INFO_SIZE, bytenr); |
| 113 | + ret = pread(fd, buf[i], BTRFS_SUPER_INFO_SIZE, bytenr); |
| 114 | if (ret != BTRFS_SUPER_INFO_SIZE) |
| 115 | return -EIO; |
| 116 | super[i] = (struct btrfs_super_block *)&buf[i]; |
| 117 | @@ -515,8 +515,8 @@ size_t btrfs_sb_io(int fd, void *buf, of |
| 118 | /* We can call pread/pwrite if 'fd' is non-zoned device/file */ |
| 119 | if (zone_size_sector == 0) { |
| 120 | if (rw == READ) |
| 121 | - return pread64(fd, buf, count, offset); |
| 122 | - return pwrite64(fd, buf, count, offset); |
| 123 | + return pread(fd, buf, count, offset); |
| 124 | + return pwrite(fd, buf, count, offset); |
| 125 | } |
| 126 | |
| 127 | ASSERT(IS_ALIGNED(zone_size_sector, sb_size_sector)); |
| 128 | --- a/kernel-shared/zoned.h |
| 129 | +++ b/kernel-shared/zoned.h |
| 130 | @@ -150,9 +150,9 @@ int btrfs_wipe_temporary_sb(struct btrfs |
| 131 | #else |
| 132 | |
| 133 | #define sbread(fd, buf, offset) \ |
| 134 | - pread64(fd, buf, BTRFS_SUPER_INFO_SIZE, offset) |
| 135 | + pread(fd, buf, BTRFS_SUPER_INFO_SIZE, offset) |
| 136 | #define sbwrite(fd, buf, offset) \ |
| 137 | - pwrite64(fd, buf, BTRFS_SUPER_INFO_SIZE, offset) |
| 138 | + pwrite(fd, buf, BTRFS_SUPER_INFO_SIZE, offset) |
| 139 | |
| 140 | static inline int btrfs_reset_dev_zone(int fd, struct blk_zone *zone) |
| 141 | { |
| 142 | --- a/mkfs/main.c |
| 143 | +++ b/mkfs/main.c |
| 144 | @@ -453,14 +453,14 @@ static int zero_output_file(int out_fd, |
| 145 | /* Only zero out the first 1M */ |
| 146 | loop_num = SZ_1M / SZ_4K; |
| 147 | for (i = 0; i < loop_num; i++) { |
| 148 | - written = pwrite64(out_fd, buf, SZ_4K, location); |
| 149 | + written = pwrite(out_fd, buf, SZ_4K, location); |
| 150 | if (written != SZ_4K) |
| 151 | ret = -EIO; |
| 152 | location += SZ_4K; |
| 153 | } |
| 154 | |
| 155 | /* Then enlarge the file to size */ |
| 156 | - written = pwrite64(out_fd, buf, 1, size - 1); |
| 157 | + written = pwrite(out_fd, buf, 1, size - 1); |
| 158 | if (written < 1) |
| 159 | ret = -EIO; |
| 160 | return ret; |
| 161 | --- a/mkfs/rootdir.c |
| 162 | +++ b/mkfs/rootdir.c |
| 163 | @@ -340,7 +340,7 @@ static int add_file_items(struct btrfs_t |
| 164 | goto end; |
| 165 | } |
| 166 | |
| 167 | - ret_read = pread64(fd, buffer, st->st_size, bytes_read); |
| 168 | + ret_read = pread(fd, buffer, st->st_size, bytes_read); |
| 169 | if (ret_read == -1) { |
| 170 | error("cannot read %s at offset %llu length %llu: %m", |
| 171 | path_name, bytes_read, (unsigned long long)st->st_size); |
| 172 | @@ -386,7 +386,7 @@ again: |
| 173 | |
| 174 | memset(eb->data, 0, sectorsize); |
| 175 | |
| 176 | - ret_read = pread64(fd, eb->data, sectorsize, file_pos + |
| 177 | + ret_read = pread(fd, eb->data, sectorsize, file_pos + |
| 178 | bytes_read); |
| 179 | if (ret_read == -1) { |
| 180 | error("cannot read %s at offset %llu length %u: %m", |
| 181 | @@ -929,7 +929,7 @@ int btrfs_mkfs_shrink_fs(struct btrfs_fs |
| 182 | u64 new_size; |
| 183 | struct btrfs_device *device; |
| 184 | struct list_head *cur; |
| 185 | - struct stat64 file_stat; |
| 186 | + struct stat file_stat; |
| 187 | int nr_devs = 0; |
| 188 | int ret; |
| 189 | |
| 190 | @@ -963,14 +963,14 @@ int btrfs_mkfs_shrink_fs(struct btrfs_fs |
| 191 | *new_size_ret = new_size; |
| 192 | |
| 193 | if (shrink_file_size) { |
| 194 | - ret = fstat64(device->fd, &file_stat); |
| 195 | + ret = fstat(device->fd, &file_stat); |
| 196 | if (ret < 0) { |
| 197 | error("failed to stat devid %llu: %m", device->devid); |
| 198 | return ret; |
| 199 | } |
| 200 | if (!S_ISREG(file_stat.st_mode)) |
| 201 | return ret; |
| 202 | - ret = ftruncate64(device->fd, new_size); |
| 203 | + ret = ftruncate(device->fd, new_size); |
| 204 | if (ret < 0) { |
| 205 | error("failed to truncate device file of devid %llu: %m", |
| 206 | device->devid); |
| 207 | --- a/tests/fsstress.c |
| 208 | +++ b/tests/fsstress.c |
| 209 | @@ -458,7 +458,7 @@ int get_fname(int, long, pathname_t *, f |
| 210 | void init_pathname(pathname_t *); |
| 211 | int lchown_path(pathname_t *, uid_t, gid_t); |
| 212 | int link_path(pathname_t *, pathname_t *); |
| 213 | -int lstat64_path(pathname_t *, struct stat64 *); |
| 214 | +int lstat_path(pathname_t *, struct stat *); |
| 215 | void make_freq_table(void); |
| 216 | int mkdir_path(pathname_t *, mode_t); |
| 217 | int mknod_path(pathname_t *, mode_t, dev_t); |
| 218 | @@ -472,9 +472,9 @@ int rename_path(pathname_t *, pathname_t |
| 219 | int rmdir_path(pathname_t *); |
| 220 | void separate_pathname(pathname_t *, char *, pathname_t *); |
| 221 | void show_ops(int, char *); |
| 222 | -int stat64_path(pathname_t *, struct stat64 *); |
| 223 | +int stat_path(pathname_t *, struct stat *); |
| 224 | int symlink_path(const char *, pathname_t *); |
| 225 | -int truncate64_path(pathname_t *, off64_t); |
| 226 | +int truncate_path(pathname_t *, off64_t); |
| 227 | int unlink_path(pathname_t *); |
| 228 | void usage(void); |
| 229 | void write_freq(void); |
| 230 | @@ -998,12 +998,12 @@ void |
| 231 | check_cwd(void) |
| 232 | { |
| 233 | #ifdef DEBUG |
| 234 | - struct stat64 statbuf; |
| 235 | + struct stat statbuf; |
| 236 | int ret; |
| 237 | |
| 238 | - ret = stat64(".", &statbuf); |
| 239 | + ret = stat(".", &statbuf); |
| 240 | if (ret != 0) { |
| 241 | - fprintf(stderr, "fsstress: check_cwd stat64() returned %d with errno: %d (%m)\n", |
| 242 | + fprintf(stderr, "fsstress: check_cwd stat() returned %d with errno: %d (%m)\n", |
| 243 | ret, errno); |
| 244 | goto out; |
| 245 | } |
| 246 | @@ -1171,7 +1171,7 @@ again: |
| 247 | void |
| 248 | doproc(void) |
| 249 | { |
| 250 | - struct stat64 statbuf; |
| 251 | + struct stat statbuf; |
| 252 | char buf[10]; |
| 253 | char cmd[64]; |
| 254 | opnum_t opno; |
| 255 | @@ -1182,7 +1182,7 @@ doproc(void) |
| 256 | dividend = (operations + execute_freq) / (execute_freq + 1); |
| 257 | sprintf(buf, "p%x", procid); |
| 258 | (void)mkdir(buf, 0777); |
| 259 | - if (chdir(buf) < 0 || stat64(".", &statbuf) < 0) { |
| 260 | + if (chdir(buf) < 0 || stat(".", &statbuf) < 0) { |
| 261 | perror(buf); |
| 262 | _exit(1); |
| 263 | } |
| 264 | @@ -1214,7 +1214,7 @@ doproc(void) |
| 265 | * the forced shutdown happened. |
| 266 | */ |
| 267 | if (errtag != 0 && opno % 100 == 0) { |
| 268 | - rval = stat64(".", &statbuf); |
| 269 | + rval = stat(".", &statbuf); |
| 270 | if (rval == EIO) { |
| 271 | fprintf(stderr, "Detected EIO\n"); |
| 272 | goto errout; |
| 273 | @@ -1537,18 +1537,18 @@ link_path(pathname_t *name1, pathname_t |
| 274 | } |
| 275 | |
| 276 | int |
| 277 | -lstat64_path(pathname_t *name, struct stat64 *sbuf) |
| 278 | +lstat_path(pathname_t *name, struct stat *sbuf) |
| 279 | { |
| 280 | char buf[NAME_MAX + 1]; |
| 281 | pathname_t newname; |
| 282 | int rval; |
| 283 | |
| 284 | - rval = lstat64(name->path, sbuf); |
| 285 | + rval = lstat(name->path, sbuf); |
| 286 | if (rval >= 0 || errno != ENAMETOOLONG) |
| 287 | return rval; |
| 288 | separate_pathname(name, buf, &newname); |
| 289 | if (chdir(buf) == 0) { |
| 290 | - rval = lstat64_path(&newname, sbuf); |
| 291 | + rval = lstat_path(&newname, sbuf); |
| 292 | assert(chdir("..") == 0); |
| 293 | } |
| 294 | free_pathname(&newname); |
| 295 | @@ -1870,18 +1870,18 @@ show_ops(int flag, char *lead_str) |
| 296 | } |
| 297 | |
| 298 | int |
| 299 | -stat64_path(pathname_t *name, struct stat64 *sbuf) |
| 300 | +stat_path(pathname_t *name, struct stat *sbuf) |
| 301 | { |
| 302 | char buf[NAME_MAX + 1]; |
| 303 | pathname_t newname; |
| 304 | int rval; |
| 305 | |
| 306 | - rval = stat64(name->path, sbuf); |
| 307 | + rval = stat(name->path, sbuf); |
| 308 | if (rval >= 0 || errno != ENAMETOOLONG) |
| 309 | return rval; |
| 310 | separate_pathname(name, buf, &newname); |
| 311 | if (chdir(buf) == 0) { |
| 312 | - rval = stat64_path(&newname, sbuf); |
| 313 | + rval = stat_path(&newname, sbuf); |
| 314 | assert(chdir("..") == 0); |
| 315 | } |
| 316 | free_pathname(&newname); |
| 317 | @@ -1913,18 +1913,18 @@ symlink_path(const char *name1, pathname |
| 318 | } |
| 319 | |
| 320 | int |
| 321 | -truncate64_path(pathname_t *name, off64_t length) |
| 322 | +truncate_path(pathname_t *name, off64_t length) |
| 323 | { |
| 324 | char buf[NAME_MAX + 1]; |
| 325 | pathname_t newname; |
| 326 | int rval; |
| 327 | |
| 328 | - rval = truncate64(name->path, length); |
| 329 | + rval = truncate(name->path, length); |
| 330 | if (rval >= 0 || errno != ENAMETOOLONG) |
| 331 | return rval; |
| 332 | separate_pathname(name, buf, &newname); |
| 333 | if (chdir(buf) == 0) { |
| 334 | - rval = truncate64_path(&newname, length); |
| 335 | + rval = truncate_path(&newname, length); |
| 336 | assert(chdir("..") == 0); |
| 337 | } |
| 338 | free_pathname(&newname); |
| 339 | @@ -2026,7 +2026,7 @@ non_btrfs_freq(const char *path) |
| 340 | ops[btrfs_ops[i]].freq = 0; |
| 341 | } |
| 342 | |
| 343 | -void inode_info(char *str, size_t sz, struct stat64 *s, int verbose) |
| 344 | +void inode_info(char *str, size_t sz, struct stat *s, int verbose) |
| 345 | { |
| 346 | if (verbose) |
| 347 | snprintf(str, sz, "[%ld %ld %d %d %lld %lld]", |
| 348 | @@ -2101,7 +2101,7 @@ allocsp_f(opnum_t opno, long r) |
| 349 | struct xfs_flock64 fl; |
| 350 | int64_t lr; |
| 351 | off64_t off; |
| 352 | - struct stat64 stb; |
| 353 | + struct stat stb; |
| 354 | int v; |
| 355 | char st[1024]; |
| 356 | |
| 357 | @@ -2122,9 +2122,9 @@ allocsp_f(opnum_t opno, long r) |
| 358 | free_pathname(&f); |
| 359 | return; |
| 360 | } |
| 361 | - if (fstat64(fd, &stb) < 0) { |
| 362 | + if (fstat(fd, &stb) < 0) { |
| 363 | if (v) |
| 364 | - printf("%d/%lld: allocsp - fstat64 %s failed %d\n", |
| 365 | + printf("%d/%lld: allocsp - fstat %s failed %d\n", |
| 366 | procid, opno, f.path, errno); |
| 367 | free_pathname(&f); |
| 368 | close(fd); |
| 369 | @@ -2160,7 +2160,7 @@ do_aio_rw(opnum_t opno, long r, int flag |
| 370 | size_t len; |
| 371 | int64_t lr; |
| 372 | off64_t off; |
| 373 | - struct stat64 stb; |
| 374 | + struct stat stb; |
| 375 | int v; |
| 376 | char st[1024]; |
| 377 | char *dio_env; |
| 378 | @@ -2184,9 +2184,9 @@ do_aio_rw(opnum_t opno, long r, int flag |
| 379 | procid, opno, f.path, e); |
| 380 | goto aio_out; |
| 381 | } |
| 382 | - if (fstat64(fd, &stb) < 0) { |
| 383 | + if (fstat(fd, &stb) < 0) { |
| 384 | if (v) |
| 385 | - printf("%d/%lld: do_aio_rw - fstat64 %s failed %d\n", |
| 386 | + printf("%d/%lld: do_aio_rw - fstat %s failed %d\n", |
| 387 | procid, opno, f.path, errno); |
| 388 | goto aio_out; |
| 389 | } |
| 390 | @@ -2278,7 +2278,7 @@ do_uring_rw(opnum_t opno, long r, int fl |
| 391 | size_t len; |
| 392 | int64_t lr; |
| 393 | off64_t off; |
| 394 | - struct stat64 stb; |
| 395 | + struct stat stb; |
| 396 | int v; |
| 397 | char st[1024]; |
| 398 | struct io_uring_sqe *sqe; |
| 399 | @@ -2304,9 +2304,9 @@ do_uring_rw(opnum_t opno, long r, int fl |
| 400 | procid, opno, f.path, e); |
| 401 | goto uring_out; |
| 402 | } |
| 403 | - if (fstat64(fd, &stb) < 0) { |
| 404 | + if (fstat(fd, &stb) < 0) { |
| 405 | if (v) |
| 406 | - printf("%d/%lld: do_uring_rw - fstat64 %s failed %d\n", |
| 407 | + printf("%d/%lld: do_uring_rw - fstat %s failed %d\n", |
| 408 | procid, opno, f.path, errno); |
| 409 | goto uring_out; |
| 410 | } |
| 411 | @@ -2522,7 +2522,7 @@ bulkstat1_f(opnum_t opno, long r) |
| 412 | int fd; |
| 413 | int good; |
| 414 | __u64 ino; |
| 415 | - struct stat64 s; |
| 416 | + struct stat s; |
| 417 | struct xfs_bstat t; |
| 418 | int v; |
| 419 | struct xfs_fsop_bulkreq bsr; |
| 420 | @@ -2534,7 +2534,7 @@ bulkstat1_f(opnum_t opno, long r) |
| 421 | init_pathname(&f); |
| 422 | if (!get_fname(FT_ANYm, r, &f, NULL, NULL, &v)) |
| 423 | append_pathname(&f, "."); |
| 424 | - ino = stat64_path(&f, &s) < 0 ? (ino64_t)r : s.st_ino; |
| 425 | + ino = stat_path(&f, &s) < 0 ? (ino64_t)r : s.st_ino; |
| 426 | check_cwd(); |
| 427 | free_pathname(&f); |
| 428 | } else { |
| 429 | @@ -2605,8 +2605,8 @@ clonerange_f( |
| 430 | struct file_clone_range fcr; |
| 431 | struct pathname fpath1; |
| 432 | struct pathname fpath2; |
| 433 | - struct stat64 stat1; |
| 434 | - struct stat64 stat2; |
| 435 | + struct stat stat1; |
| 436 | + struct stat stat2; |
| 437 | char inoinfo1[1024]; |
| 438 | char inoinfo2[1024]; |
| 439 | off64_t lr; |
| 440 | @@ -2660,17 +2660,17 @@ clonerange_f( |
| 441 | } |
| 442 | |
| 443 | /* Get file stats */ |
| 444 | - if (fstat64(fd1, &stat1) < 0) { |
| 445 | + if (fstat(fd1, &stat1) < 0) { |
| 446 | if (v1) |
| 447 | - printf("%d/%lld: clonerange read - fstat64 %s failed %d\n", |
| 448 | + printf("%d/%lld: clonerange read - fstat %s failed %d\n", |
| 449 | procid, opno, fpath1.path, errno); |
| 450 | goto out_fd2; |
| 451 | } |
| 452 | inode_info(inoinfo1, sizeof(inoinfo1), &stat1, v1); |
| 453 | |
| 454 | - if (fstat64(fd2, &stat2) < 0) { |
| 455 | + if (fstat(fd2, &stat2) < 0) { |
| 456 | if (v2) |
| 457 | - printf("%d/%lld: clonerange write - fstat64 %s failed %d\n", |
| 458 | + printf("%d/%lld: clonerange write - fstat %s failed %d\n", |
| 459 | procid, opno, fpath2.path, errno); |
| 460 | goto out_fd2; |
| 461 | } |
| 462 | @@ -2743,8 +2743,8 @@ copyrange_f( |
| 463 | #ifdef HAVE_COPY_FILE_RANGE |
| 464 | struct pathname fpath1; |
| 465 | struct pathname fpath2; |
| 466 | - struct stat64 stat1; |
| 467 | - struct stat64 stat2; |
| 468 | + struct stat stat1; |
| 469 | + struct stat stat2; |
| 470 | char inoinfo1[1024]; |
| 471 | char inoinfo2[1024]; |
| 472 | loff_t lr; |
| 473 | @@ -2802,17 +2802,17 @@ copyrange_f( |
| 474 | } |
| 475 | |
| 476 | /* Get file stats */ |
| 477 | - if (fstat64(fd1, &stat1) < 0) { |
| 478 | + if (fstat(fd1, &stat1) < 0) { |
| 479 | if (v1) |
| 480 | - printf("%d/%lld: copyrange read - fstat64 %s failed %d\n", |
| 481 | + printf("%d/%lld: copyrange read - fstat %s failed %d\n", |
| 482 | procid, opno, fpath1.path, errno); |
| 483 | goto out_fd2; |
| 484 | } |
| 485 | inode_info(inoinfo1, sizeof(inoinfo1), &stat1, v1); |
| 486 | |
| 487 | - if (fstat64(fd2, &stat2) < 0) { |
| 488 | + if (fstat(fd2, &stat2) < 0) { |
| 489 | if (v2) |
| 490 | - printf("%d/%lld: copyrange write - fstat64 %s failed %d\n", |
| 491 | + printf("%d/%lld: copyrange write - fstat %s failed %d\n", |
| 492 | procid, opno, fpath2.path, errno); |
| 493 | goto out_fd2; |
| 494 | } |
| 495 | @@ -2900,7 +2900,7 @@ deduperange_f( |
| 496 | #define INFO_SZ 1024 |
| 497 | struct file_dedupe_range *fdr; |
| 498 | struct pathname *fpath; |
| 499 | - struct stat64 *stat; |
| 500 | + struct stat *stat; |
| 501 | char *info; |
| 502 | off64_t *off; |
| 503 | int *v; |
| 504 | @@ -2938,7 +2938,7 @@ deduperange_f( |
| 505 | goto out_fdr; |
| 506 | } |
| 507 | |
| 508 | - stat = calloc(nr, sizeof(struct stat64)); |
| 509 | + stat = calloc(nr, sizeof(struct stat)); |
| 510 | if (!stat) { |
| 511 | printf("%d/%lld: line %d error %d\n", |
| 512 | procid, opno, __LINE__, errno); |
| 513 | @@ -3017,9 +3017,9 @@ deduperange_f( |
| 514 | } |
| 515 | |
| 516 | /* Get file stats */ |
| 517 | - if (fstat64(fd[0], &stat[0]) < 0) { |
| 518 | + if (fstat(fd[0], &stat[0]) < 0) { |
| 519 | if (v[0]) |
| 520 | - printf("%d/%lld: deduperange read - fstat64 %s failed %d\n", |
| 521 | + printf("%d/%lld: deduperange read - fstat %s failed %d\n", |
| 522 | procid, opno, fpath[0].path, errno); |
| 523 | goto out_fds; |
| 524 | } |
| 525 | @@ -3027,9 +3027,9 @@ deduperange_f( |
| 526 | inode_info(&info[0], INFO_SZ, &stat[0], v[0]); |
| 527 | |
| 528 | for (i = 1; i < nr; i++) { |
| 529 | - if (fstat64(fd[i], &stat[i]) < 0) { |
| 530 | + if (fstat(fd[i], &stat[i]) < 0) { |
| 531 | if (v[i]) |
| 532 | - printf("%d/%lld: deduperange write - fstat64 %s failed %d\n", |
| 533 | + printf("%d/%lld: deduperange write - fstat %s failed %d\n", |
| 534 | procid, opno, fpath[i].path, errno); |
| 535 | goto out_fds; |
| 536 | } |
| 537 | @@ -3179,8 +3179,8 @@ splice_f(opnum_t opno, long r) |
| 538 | { |
| 539 | struct pathname fpath1; |
| 540 | struct pathname fpath2; |
| 541 | - struct stat64 stat1; |
| 542 | - struct stat64 stat2; |
| 543 | + struct stat stat1; |
| 544 | + struct stat stat2; |
| 545 | char inoinfo1[1024]; |
| 546 | char inoinfo2[1024]; |
| 547 | loff_t lr; |
| 548 | @@ -3237,17 +3237,17 @@ splice_f(opnum_t opno, long r) |
| 549 | } |
| 550 | |
| 551 | /* Get file stats */ |
| 552 | - if (fstat64(fd1, &stat1) < 0) { |
| 553 | + if (fstat(fd1, &stat1) < 0) { |
| 554 | if (v1) |
| 555 | - printf("%d/%lld: splice read - fstat64 %s failed %d\n", |
| 556 | + printf("%d/%lld: splice read - fstat %s failed %d\n", |
| 557 | procid, opno, fpath1.path, errno); |
| 558 | goto out_fd2; |
| 559 | } |
| 560 | inode_info(inoinfo1, sizeof(inoinfo1), &stat1, v1); |
| 561 | |
| 562 | - if (fstat64(fd2, &stat2) < 0) { |
| 563 | + if (fstat(fd2, &stat2) < 0) { |
| 564 | if (v2) |
| 565 | - printf("%d/%lld: splice write - fstat64 %s failed %d\n", |
| 566 | + printf("%d/%lld: splice write - fstat %s failed %d\n", |
| 567 | procid, opno, fpath2.path, errno); |
| 568 | goto out_fd2; |
| 569 | } |
| 570 | @@ -3432,7 +3432,7 @@ dread_f(opnum_t opno, long r) |
| 571 | size_t len; |
| 572 | int64_t lr; |
| 573 | off64_t off; |
| 574 | - struct stat64 stb; |
| 575 | + struct stat stb; |
| 576 | int v; |
| 577 | char st[1024]; |
| 578 | char *dio_env; |
| 579 | @@ -3454,9 +3454,9 @@ dread_f(opnum_t opno, long r) |
| 580 | free_pathname(&f); |
| 581 | return; |
| 582 | } |
| 583 | - if (fstat64(fd, &stb) < 0) { |
| 584 | + if (fstat(fd, &stb) < 0) { |
| 585 | if (v) |
| 586 | - printf("%d/%lld: dread - fstat64 %s failed %d\n", |
| 587 | + printf("%d/%lld: dread - fstat %s failed %d\n", |
| 588 | procid, opno, f.path, errno); |
| 589 | free_pathname(&f); |
| 590 | close(fd); |
| 591 | @@ -3522,7 +3522,7 @@ dwrite_f(opnum_t opno, long r) |
| 592 | size_t len; |
| 593 | int64_t lr; |
| 594 | off64_t off; |
| 595 | - struct stat64 stb; |
| 596 | + struct stat stb; |
| 597 | int v; |
| 598 | char st[1024]; |
| 599 | char *dio_env; |
| 600 | @@ -3544,9 +3544,9 @@ dwrite_f(opnum_t opno, long r) |
| 601 | free_pathname(&f); |
| 602 | return; |
| 603 | } |
| 604 | - if (fstat64(fd, &stb) < 0) { |
| 605 | + if (fstat(fd, &stb) < 0) { |
| 606 | if (v) |
| 607 | - printf("%d/%lld: dwrite - fstat64 %s failed %d\n", |
| 608 | + printf("%d/%lld: dwrite - fstat %s failed %d\n", |
| 609 | procid, opno, f.path, errno); |
| 610 | free_pathname(&f); |
| 611 | close(fd); |
| 612 | @@ -3620,7 +3620,7 @@ do_fallocate(opnum_t opno, long r, int m |
| 613 | int64_t lr; |
| 614 | off64_t off; |
| 615 | off64_t len; |
| 616 | - struct stat64 stb; |
| 617 | + struct stat stb; |
| 618 | int v; |
| 619 | char st[1024]; |
| 620 | |
| 621 | @@ -3640,9 +3640,9 @@ do_fallocate(opnum_t opno, long r, int m |
| 622 | return; |
| 623 | } |
| 624 | check_cwd(); |
| 625 | - if (fstat64(fd, &stb) < 0) { |
| 626 | + if (fstat(fd, &stb) < 0) { |
| 627 | if (v) |
| 628 | - printf("%d/%lld: do_fallocate - fstat64 %s failed %d\n", |
| 629 | + printf("%d/%lld: do_fallocate - fstat %s failed %d\n", |
| 630 | procid, opno, f.path, errno); |
| 631 | free_pathname(&f); |
| 632 | close(fd); |
| 633 | @@ -3734,7 +3734,7 @@ fiemap_f(opnum_t opno, long r) |
| 634 | int fd; |
| 635 | int64_t lr; |
| 636 | off64_t off; |
| 637 | - struct stat64 stb; |
| 638 | + struct stat stb; |
| 639 | int v; |
| 640 | char st[1024]; |
| 641 | int blocks_to_map; |
| 642 | @@ -3757,9 +3757,9 @@ fiemap_f(opnum_t opno, long r) |
| 643 | free_pathname(&f); |
| 644 | return; |
| 645 | } |
| 646 | - if (fstat64(fd, &stb) < 0) { |
| 647 | + if (fstat(fd, &stb) < 0) { |
| 648 | if (v) |
| 649 | - printf("%d/%lld: fiemap - fstat64 %s failed %d\n", |
| 650 | + printf("%d/%lld: fiemap - fstat %s failed %d\n", |
| 651 | procid, opno, f.path, errno); |
| 652 | free_pathname(&f); |
| 653 | close(fd); |
| 654 | @@ -3807,7 +3807,7 @@ freesp_f(opnum_t opno, long r) |
| 655 | struct xfs_flock64 fl; |
| 656 | int64_t lr; |
| 657 | off64_t off; |
| 658 | - struct stat64 stb; |
| 659 | + struct stat stb; |
| 660 | int v; |
| 661 | char st[1024]; |
| 662 | |
| 663 | @@ -3828,9 +3828,9 @@ freesp_f(opnum_t opno, long r) |
| 664 | free_pathname(&f); |
| 665 | return; |
| 666 | } |
| 667 | - if (fstat64(fd, &stb) < 0) { |
| 668 | + if (fstat(fd, &stb) < 0) { |
| 669 | if (v) |
| 670 | - printf("%d/%lld: freesp - fstat64 %s failed %d\n", |
| 671 | + printf("%d/%lld: freesp - fstat %s failed %d\n", |
| 672 | procid, opno, f.path, errno); |
| 673 | free_pathname(&f); |
| 674 | close(fd); |
| 675 | @@ -4226,7 +4226,7 @@ do_mmap(opnum_t opno, long r, int prot) |
| 676 | int64_t lr; |
| 677 | off64_t off; |
| 678 | int flags; |
| 679 | - struct stat64 stb; |
| 680 | + struct stat stb; |
| 681 | int v; |
| 682 | char st[1024]; |
| 683 | sigjmp_buf sigbus_jmpbuf; |
| 684 | @@ -4248,9 +4248,9 @@ do_mmap(opnum_t opno, long r, int prot) |
| 685 | free_pathname(&f); |
| 686 | return; |
| 687 | } |
| 688 | - if (fstat64(fd, &stb) < 0) { |
| 689 | + if (fstat(fd, &stb) < 0) { |
| 690 | if (v) |
| 691 | - printf("%d/%lld: do_mmap - fstat64 %s failed %d\n", |
| 692 | + printf("%d/%lld: do_mmap - fstat %s failed %d\n", |
| 693 | procid, opno, f.path, errno); |
| 694 | free_pathname(&f); |
| 695 | close(fd); |
| 696 | @@ -4370,7 +4370,7 @@ read_f(opnum_t opno, long r) |
| 697 | size_t len; |
| 698 | int64_t lr; |
| 699 | off64_t off; |
| 700 | - struct stat64 stb; |
| 701 | + struct stat stb; |
| 702 | int v; |
| 703 | char st[1024]; |
| 704 | |
| 705 | @@ -4391,9 +4391,9 @@ read_f(opnum_t opno, long r) |
| 706 | free_pathname(&f); |
| 707 | return; |
| 708 | } |
| 709 | - if (fstat64(fd, &stb) < 0) { |
| 710 | + if (fstat(fd, &stb) < 0) { |
| 711 | if (v) |
| 712 | - printf("%d/%lld: read - fstat64 %s failed %d\n", |
| 713 | + printf("%d/%lld: read - fstat %s failed %d\n", |
| 714 | procid, opno, f.path, errno); |
| 715 | free_pathname(&f); |
| 716 | close(fd); |
| 717 | @@ -4454,7 +4454,7 @@ readv_f(opnum_t opno, long r) |
| 718 | size_t len; |
| 719 | int64_t lr; |
| 720 | off64_t off; |
| 721 | - struct stat64 stb; |
| 722 | + struct stat stb; |
| 723 | int v; |
| 724 | char st[1024]; |
| 725 | struct iovec *iov = NULL; |
| 726 | @@ -4480,9 +4480,9 @@ readv_f(opnum_t opno, long r) |
| 727 | free_pathname(&f); |
| 728 | return; |
| 729 | } |
| 730 | - if (fstat64(fd, &stb) < 0) { |
| 731 | + if (fstat(fd, &stb) < 0) { |
| 732 | if (v) |
| 733 | - printf("%d/%lld: readv - fstat64 %s failed %d\n", |
| 734 | + printf("%d/%lld: readv - fstat %s failed %d\n", |
| 735 | procid, opno, f.path, errno); |
| 736 | free_pathname(&f); |
| 737 | close(fd); |
| 738 | @@ -4739,7 +4739,7 @@ resvsp_f(opnum_t opno, long r) |
| 739 | struct xfs_flock64 fl; |
| 740 | int64_t lr; |
| 741 | off64_t off; |
| 742 | - struct stat64 stb; |
| 743 | + struct stat stb; |
| 744 | int v; |
| 745 | char st[1024]; |
| 746 | |
| 747 | @@ -4760,9 +4760,9 @@ resvsp_f(opnum_t opno, long r) |
| 748 | free_pathname(&f); |
| 749 | return; |
| 750 | } |
| 751 | - if (fstat64(fd, &stb) < 0) { |
| 752 | + if (fstat(fd, &stb) < 0) { |
| 753 | if (v) |
| 754 | - printf("%d/%lld: resvsp - fstat64 %s failed %d\n", |
| 755 | + printf("%d/%lld: resvsp - fstat %s failed %d\n", |
| 756 | procid, opno, f.path, errno); |
| 757 | free_pathname(&f); |
| 758 | close(fd); |
| 759 | @@ -4971,7 +4971,7 @@ stat_f(opnum_t opno, long r) |
| 760 | { |
| 761 | int e; |
| 762 | pathname_t f; |
| 763 | - struct stat64 stb; |
| 764 | + struct stat stb; |
| 765 | int v; |
| 766 | |
| 767 | init_pathname(&f); |
| 768 | @@ -4981,7 +4981,7 @@ stat_f(opnum_t opno, long r) |
| 769 | free_pathname(&f); |
| 770 | return; |
| 771 | } |
| 772 | - e = lstat64_path(&f, &stb) < 0 ? errno : 0; |
| 773 | + e = lstat_path(&f, &stb) < 0 ? errno : 0; |
| 774 | check_cwd(); |
| 775 | if (v) |
| 776 | printf("%d/%lld: stat %s %d\n", procid, opno, f.path, e); |
| 777 | @@ -5133,7 +5133,7 @@ truncate_f(opnum_t opno, long r) |
| 778 | pathname_t f; |
| 779 | int64_t lr; |
| 780 | off64_t off; |
| 781 | - struct stat64 stb; |
| 782 | + struct stat stb; |
| 783 | int v; |
| 784 | char st[1024]; |
| 785 | |
| 786 | @@ -5144,11 +5144,11 @@ truncate_f(opnum_t opno, long r) |
| 787 | free_pathname(&f); |
| 788 | return; |
| 789 | } |
| 790 | - e = stat64_path(&f, &stb) < 0 ? errno : 0; |
| 791 | + e = stat_path(&f, &stb) < 0 ? errno : 0; |
| 792 | check_cwd(); |
| 793 | if (e > 0) { |
| 794 | if (v) |
| 795 | - printf("%d/%lld: truncate - stat64 %s failed %d\n", |
| 796 | + printf("%d/%lld: truncate - stat %s failed %d\n", |
| 797 | procid, opno, f.path, e); |
| 798 | free_pathname(&f); |
| 799 | return; |
| 800 | @@ -5157,7 +5157,7 @@ truncate_f(opnum_t opno, long r) |
| 801 | lr = ((int64_t)random() << 32) + random(); |
| 802 | off = (off64_t)(lr % MIN(stb.st_size + (1024 * 1024), MAXFSIZE)); |
| 803 | off %= maxfsize; |
| 804 | - e = truncate64_path(&f, off) < 0 ? errno : 0; |
| 805 | + e = truncate_path(&f, off) < 0 ? errno : 0; |
| 806 | check_cwd(); |
| 807 | if (v) |
| 808 | printf("%d/%lld: truncate %s%s %lld %d\n", procid, opno, f.path, |
| 809 | @@ -5209,7 +5209,7 @@ unresvsp_f(opnum_t opno, long r) |
| 810 | struct xfs_flock64 fl; |
| 811 | int64_t lr; |
| 812 | off64_t off; |
| 813 | - struct stat64 stb; |
| 814 | + struct stat stb; |
| 815 | int v; |
| 816 | char st[1024]; |
| 817 | |
| 818 | @@ -5230,9 +5230,9 @@ unresvsp_f(opnum_t opno, long r) |
| 819 | free_pathname(&f); |
| 820 | return; |
| 821 | } |
| 822 | - if (fstat64(fd, &stb) < 0) { |
| 823 | + if (fstat(fd, &stb) < 0) { |
| 824 | if (v) |
| 825 | - printf("%d/%lld: unresvsp - fstat64 %s failed %d\n", |
| 826 | + printf("%d/%lld: unresvsp - fstat %s failed %d\n", |
| 827 | procid, opno, f.path, errno); |
| 828 | free_pathname(&f); |
| 829 | close(fd); |
| 830 | @@ -5281,7 +5281,7 @@ write_f(opnum_t opno, long r) |
| 831 | size_t len; |
| 832 | int64_t lr; |
| 833 | off64_t off; |
| 834 | - struct stat64 stb; |
| 835 | + struct stat stb; |
| 836 | int v; |
| 837 | char st[1024]; |
| 838 | |
| 839 | @@ -5302,9 +5302,9 @@ write_f(opnum_t opno, long r) |
| 840 | free_pathname(&f); |
| 841 | return; |
| 842 | } |
| 843 | - if (fstat64(fd, &stb) < 0) { |
| 844 | + if (fstat(fd, &stb) < 0) { |
| 845 | if (v) |
| 846 | - printf("%d/%lld: write - fstat64 %s failed %d\n", |
| 847 | + printf("%d/%lld: write - fstat %s failed %d\n", |
| 848 | procid, opno, f.path, errno); |
| 849 | free_pathname(&f); |
| 850 | close(fd); |
| 851 | @@ -5337,7 +5337,7 @@ writev_f(opnum_t opno, long r) |
| 852 | size_t len; |
| 853 | int64_t lr; |
| 854 | off64_t off; |
| 855 | - struct stat64 stb; |
| 856 | + struct stat stb; |
| 857 | int v; |
| 858 | char st[1024]; |
| 859 | struct iovec *iov = NULL; |
| 860 | @@ -5363,9 +5363,9 @@ writev_f(opnum_t opno, long r) |
| 861 | free_pathname(&f); |
| 862 | return; |
| 863 | } |
| 864 | - if (fstat64(fd, &stb) < 0) { |
| 865 | + if (fstat(fd, &stb) < 0) { |
| 866 | if (v) |
| 867 | - printf("%d/%lld: writev - fstat64 %s failed %d\n", |
| 868 | + printf("%d/%lld: writev - fstat %s failed %d\n", |
| 869 | procid, opno, f.path, errno); |
| 870 | free_pathname(&f); |
| 871 | close(fd); |
| 872 | --- a/tests/fssum.c |
| 873 | +++ b/tests/fssum.c |
| 874 | @@ -519,9 +519,9 @@ sum(int dirfd, int level, sum_t *dircs, |
| 875 | int excl; |
| 876 | sum_file_data_t sum_file_data = flags[FLAG_STRUCTURE] ? |
| 877 | sum_file_data_strict : sum_file_data_permissive; |
| 878 | - struct stat64 dir_st; |
| 879 | + struct stat dir_st; |
| 880 | |
| 881 | - if (fstat64(dirfd, &dir_st)) { |
| 882 | + if (fstat(dirfd, &dir_st)) { |
| 883 | perror("fstat"); |
| 884 | exit(-1); |
| 885 | } |
| 886 | @@ -552,7 +552,7 @@ sum(int dirfd, int level, sum_t *dircs, |
| 887 | } |
| 888 | qsort(namelist, entries, sizeof(*namelist), namecmp); |
| 889 | for (i = 0; i < entries; ++i) { |
| 890 | - struct stat64 st; |
| 891 | + struct stat st; |
| 892 | sum_t cs; |
| 893 | sum_t meta; |
| 894 | char *path; |
| 895 | @@ -572,7 +572,7 @@ sum(int dirfd, int level, sum_t *dircs, |
| 896 | perror("fchdir"); |
| 897 | exit(-1); |
| 898 | } |
| 899 | - ret = lstat64(namelist[i], &st); |
| 900 | + ret = lstat(namelist[i], &st); |
| 901 | if (ret) { |
| 902 | fprintf(stderr, "stat failed for %s/%s: %m\n", |
| 903 | path_prefix, path); |