no-lfs64.patch (13595B)
1 From b15b6cc56ac7764be17acbdbf96448f388992adc Mon Sep 17 00:00:00 2001 2 From: Waldemar Brodkorb <wbx@openadk.org> 3 Date: Wed, 23 Aug 2023 15:41:28 +0200 4 Subject: f2fs-tools: convert to lseek() and kill lseek64 5 6 This patch replaces lseek64 with lseek() having #define _FILE_OFFSET_BITS 64. 7 8 Signed-off-by: Waldemar Brodkorb <wbx@openadk.org> 9 Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org> 10 --- 11 configure.ac | 2 -- 12 fsck/Makefile.am | 2 +- 13 include/android_config.h | 4 ---- 14 lib/Makefile.am | 2 +- 15 lib/libf2fs.c | 3 --- 16 lib/libf2fs_io.c | 47 ++++++++++++++++++----------------------------- 17 lib/libf2fs_zoned.c | 1 - 18 mkfs/Makefile.am | 4 ++-- 19 mkfs/f2fs_format.c | 2 -- 20 mkfs/f2fs_format_main.c | 2 -- 21 mkfs/f2fs_format_utils.c | 10 ---------- 22 mkfs/f2fs_format_utils.h | 2 -- 23 tools/Makefile.am | 2 +- 24 tools/f2fs_io/Makefile.am | 2 +- 25 tools/f2fs_io/f2fs_io.c | 6 ------ 26 tools/f2fs_io_parse.c | 1 - 27 tools/f2fscrypt.c | 9 --------- 28 tools/fibmap.c | 7 ------- 29 18 files changed, 24 insertions(+), 84 deletions(-) 30 31 diff --git a/configure.ac b/configure.ac 32 index efab8d8..123ddbb 100644 33 --- a/configure.ac 34 +++ b/configure.ac 35 @@ -187,8 +187,6 @@ AC_CHECK_FUNCS_ONCE([ 36 getmntent 37 getuid 38 keyctl 39 - llseek 40 - lseek64 41 memset 42 setmntent 43 clock_gettime 44 diff --git a/fsck/Makefile.am b/fsck/Makefile.am 45 index 579dd26..40d31b8 100644 46 --- a/fsck/Makefile.am 47 +++ b/fsck/Makefile.am 48 @@ -1,7 +1,7 @@ 49 ## Makefile.am 50 51 AM_CPPFLAGS = ${libuuid_CFLAGS} -I$(top_srcdir)/include 52 -AM_CFLAGS = -Wall 53 +AM_CFLAGS = -Wall -D_FILE_OFFSET_BITS=64 54 sbin_PROGRAMS = fsck.f2fs 55 noinst_HEADERS = common.h dict.h dqblk_v2.h f2fs.h fsck.h node.h quotaio.h \ 56 quotaio_tree.h quotaio_v2.h xattr.h compress.h 57 diff --git a/include/android_config.h b/include/android_config.h 58 index 141fe06..da8abcb 100644 59 --- a/include/android_config.h 60 +++ b/include/android_config.h 61 @@ -30,8 +30,6 @@ 62 #define HAVE_FSTAT 1 63 #define HAVE_FSTAT64 1 64 #define HAVE_GETMNTENT 1 65 -#define HAVE_LLSEEK 1 66 -#define HAVE_LSEEK64 1 67 #define HAVE_MEMSET 1 68 #define HAVE_SELINUX_ANDROID_H 1 69 #define HAVE_SETMNTENT 1 70 @@ -67,7 +65,6 @@ 71 #define HAVE_FSTAT 1 72 #define HAVE_FSTAT64 1 73 #define HAVE_GETMNTENT 1 74 -#define HAVE_LLSEEK 1 75 #define HAVE_MEMSET 1 76 #define HAVE_SPARSE_SPARSE_H 1 77 #define HAVE_LIBLZ4 1 78 @@ -78,6 +75,5 @@ 79 #endif 80 81 #if defined(_WIN32) 82 -#define HAVE_LSEEK64 83 #define HAVE_SPARSE_SPARSE_H 1 84 #endif 85 diff --git a/lib/Makefile.am b/lib/Makefile.am 86 index 871d773..69d46f8 100644 87 --- a/lib/Makefile.am 88 +++ b/lib/Makefile.am 89 @@ -3,7 +3,7 @@ 90 lib_LTLIBRARIES = libf2fs.la 91 92 libf2fs_la_SOURCES = libf2fs.c libf2fs_io.c libf2fs_zoned.c nls_utf8.c 93 -libf2fs_la_CFLAGS = -Wall 94 +libf2fs_la_CFLAGS = -Wall -D_FILE_OFFSET_BITS=64 95 libf2fs_la_CPPFLAGS = -I$(top_srcdir)/include 96 libf2fs_la_LDFLAGS = -version-info $(LIBF2FS_CURRENT):$(LIBF2FS_REVISION):$(LIBF2FS_AGE) 97 98 diff --git a/lib/libf2fs.c b/lib/libf2fs.c 99 index 577a7e8..c3d5744 100644 100 --- a/lib/libf2fs.c 101 +++ b/lib/libf2fs.c 102 @@ -6,9 +6,6 @@ 103 * 104 * Dual licensed under the GPL or LGPL version 2 licenses. 105 */ 106 -#define _LARGEFILE64_SOURCE 107 -#define _FILE_OFFSET_BITS 64 108 - 109 #include <f2fs_fs.h> 110 #include <stdio.h> 111 #include <stdlib.h> 112 diff --git a/lib/libf2fs_io.c b/lib/libf2fs_io.c 113 index 1a8167d..74e5f3a 100644 114 --- a/lib/libf2fs_io.c 115 +++ b/lib/libf2fs_io.c 116 @@ -11,8 +11,6 @@ 117 * 118 * Dual licensed under the GPL or LGPL version 2 licenses. 119 */ 120 -#define _LARGEFILE64_SOURCE 121 - 122 #include <stdio.h> 123 #include <stdlib.h> 124 #include <string.h> 125 @@ -67,22 +65,13 @@ static int __get_device_fd(__u64 *offset) 126 return -1; 127 } 128 129 -#ifndef HAVE_LSEEK64 130 -typedef off_t off64_t; 131 - 132 -static inline off64_t lseek64(int fd, __u64 offset, int set) 133 -{ 134 - return lseek(fd, offset, set); 135 -} 136 -#endif 137 - 138 /* ---------- dev_cache, Least Used First (LUF) policy ------------------- */ 139 /* 140 * Least used block will be the first victim to be replaced when max hash 141 * collision exceeds 142 */ 143 static bool *dcache_valid; /* is the cached block valid? */ 144 -static off64_t *dcache_blk; /* which block it cached */ 145 +static off_t *dcache_blk; /* which block it cached */ 146 static uint64_t *dcache_lastused; /* last used ticks for cache entries */ 147 static char *dcache_buf; /* cached block data */ 148 static uint64_t dcache_usetick; /* current use tick */ 149 @@ -172,7 +161,7 @@ static int dcache_alloc_all(long n) 150 { 151 if (n <= 0) 152 return -1; 153 - if ((dcache_blk = (off64_t *) malloc(sizeof(off64_t) * n)) == NULL 154 + if ((dcache_blk = (off_t *) malloc(sizeof(off_t) * n)) == NULL 155 || (dcache_lastused = (uint64_t *) 156 malloc(sizeof(uint64_t) * n)) == NULL 157 || (dcache_buf = (char *) malloc (F2FS_BLKSIZE * n)) == NULL 158 @@ -257,7 +246,7 @@ static inline long dcache_relocate(long entry, int n) 159 dcache_config.num_cache_entry; 160 } 161 162 -static long dcache_find(off64_t blk) 163 +static long dcache_find(off_t blk) 164 { 165 register long n = dcache_config.num_cache_entry; 166 register unsigned m = dcache_config.max_hash_collision; 167 @@ -278,10 +267,10 @@ static long dcache_find(off64_t blk) 168 } 169 170 /* Physical read into cache */ 171 -static int dcache_io_read(int fd, long entry, off64_t offset, off64_t blk) 172 +static int dcache_io_read(int fd, long entry, off_t offset, off_t blk) 173 { 174 - if (lseek64(fd, offset, SEEK_SET) < 0) { 175 - MSG(0, "\n lseek64 fail.\n"); 176 + if (lseek(fd, offset, SEEK_SET) < 0) { 177 + MSG(0, "\n lseek fail.\n"); 178 return -1; 179 } 180 if (read(fd, dcache_buf + entry * F2FS_BLKSIZE, F2FS_BLKSIZE) < 0) { 181 @@ -308,12 +297,12 @@ static int dcache_io_read(int fd, long entry, off64_t offset, off64_t blk) 182 * 1: cache not available (uninitialized) 183 * -1: error 184 */ 185 -static int dcache_update_rw(int fd, void *buf, off64_t offset, 186 +static int dcache_update_rw(int fd, void *buf, off_t offset, 187 size_t byte_count, bool is_write) 188 { 189 - off64_t blk; 190 + off_t blk; 191 int addr_in_blk; 192 - off64_t start; 193 + off_t start; 194 195 if (!dcache_initialized) 196 dcache_init(); /* auto initialize */ 197 @@ -377,13 +366,13 @@ static int dcache_update_rw(int fd, void *buf, off64_t offset, 198 * return value: 1: cache not available 199 * 0: success, -1: I/O error 200 */ 201 -int dcache_update_cache(int fd, void *buf, off64_t offset, size_t count) 202 +int dcache_update_cache(int fd, void *buf, off_t offset, size_t count) 203 { 204 return dcache_update_rw(fd, buf, offset, count, true); 205 } 206 207 /* handles read into cache + read into buffer */ 208 -int dcache_read(int fd, void *buf, off64_t offset, size_t count) 209 +int dcache_read(int fd, void *buf, off_t offset, size_t count) 210 { 211 return dcache_update_rw(fd, buf, offset, count, false); 212 } 213 @@ -395,7 +384,7 @@ int dev_read_version(void *buf, __u64 offset, size_t len) 214 { 215 if (c.sparse_mode) 216 return 0; 217 - if (lseek64(c.kd, (off64_t)offset, SEEK_SET) < 0) 218 + if (lseek(c.kd, (off_t)offset, SEEK_SET) < 0) 219 return -1; 220 if (read(c.kd, buf, len) < 0) 221 return -1; 222 @@ -534,10 +523,10 @@ int dev_read(void *buf, __u64 offset, size_t len) 223 224 /* err = 1: cache not available, fall back to non-cache R/W */ 225 /* err = 0: success, err=-1: I/O error */ 226 - err = dcache_read(fd, buf, (off64_t)offset, len); 227 + err = dcache_read(fd, buf, (off_t)offset, len); 228 if (err <= 0) 229 return err; 230 - if (lseek64(fd, (off64_t)offset, SEEK_SET) < 0) 231 + if (lseek(fd, (off_t)offset, SEEK_SET) < 0) 232 return -1; 233 if (read(fd, buf, len) < 0) 234 return -1; 235 @@ -580,9 +569,9 @@ int dev_write(void *buf, __u64 offset, size_t len) 236 * dcache_update_cache() just update cache, won't do I/O. 237 * Thus even no error, we need normal non-cache I/O for actual write 238 */ 239 - if (dcache_update_cache(fd, buf, (off64_t)offset, len) < 0) 240 + if (dcache_update_cache(fd, buf, (off_t)offset, len) < 0) 241 return -1; 242 - if (lseek64(fd, (off64_t)offset, SEEK_SET) < 0) 243 + if (lseek(fd, (off_t)offset, SEEK_SET) < 0) 244 return -1; 245 if (write(fd, buf, len) < 0) 246 return -1; 247 @@ -596,7 +585,7 @@ int dev_write_block(void *buf, __u64 blk_addr) 248 249 int dev_write_dump(void *buf, __u64 offset, size_t len) 250 { 251 - if (lseek64(c.dump_fd, (off64_t)offset, SEEK_SET) < 0) 252 + if (lseek(c.dump_fd, (off_t)offset, SEEK_SET) < 0) 253 return -1; 254 if (write(c.dump_fd, buf, len) < 0) 255 return -1; 256 @@ -618,7 +607,7 @@ int dev_fill(void *buf, __u64 offset, size_t len) 257 /* Only allow fill to zero */ 258 if (*((__u8*)buf)) 259 return -1; 260 - if (lseek64(fd, (off64_t)offset, SEEK_SET) < 0) 261 + if (lseek(fd, (off_t)offset, SEEK_SET) < 0) 262 return -1; 263 if (write(fd, buf, len) < 0) 264 return -1; 265 diff --git a/lib/libf2fs_zoned.c b/lib/libf2fs_zoned.c 266 index a0dd8bd..2ab2497 100644 267 --- a/lib/libf2fs_zoned.c 268 +++ b/lib/libf2fs_zoned.c 269 @@ -6,7 +6,6 @@ 270 * 271 * Dual licensed under the GPL or LGPL version 2 licenses. 272 */ 273 -#define _LARGEFILE64_SOURCE 274 275 #include <f2fs_fs.h> 276 #include <stdio.h> 277 diff --git a/mkfs/Makefile.am b/mkfs/Makefile.am 278 index af5b1c7..bfffd88 100644 279 --- a/mkfs/Makefile.am 280 +++ b/mkfs/Makefile.am 281 @@ -1,7 +1,7 @@ 282 ## Makefile.am 283 284 AM_CPPFLAGS = ${libuuid_CFLAGS} ${libblkid_CFLAGS} -I$(top_srcdir)/include 285 -AM_CFLAGS = -Wall -DWITH_BLKDISCARD 286 +AM_CFLAGS = -Wall -DWITH_BLKDISCARD -D_FILE_OFFSET_BITS=64 287 sbin_PROGRAMS = mkfs.f2fs 288 noinst_HEADERS = f2fs_format_utils.h 289 include_HEADERS = $(top_srcdir)/include/f2fs_fs.h 290 @@ -10,7 +10,7 @@ mkfs_f2fs_LDADD = ${libuuid_LIBS} ${libblkid_LIBS} $(top_builddir)/lib/libf2fs.l 291 292 lib_LTLIBRARIES = libf2fs_format.la 293 libf2fs_format_la_SOURCES = f2fs_format_main.c f2fs_format.c f2fs_format_utils.c 294 -libf2fs_format_la_CFLAGS = -DWITH_BLKDISCARD 295 +libf2fs_format_la_CFLAGS = -DWITH_BLKDISCARD -D_FILE_OFFSET_BITS=64 296 libf2fs_format_la_LDFLAGS = ${libblkid_LIBS} ${libuuid_LIBS} -L$(top_builddir)/lib -lf2fs \ 297 -version-info $(FMT_CURRENT):$(FMT_REVISION):$(FMT_AGE) 298 299 diff --git a/mkfs/f2fs_format.c b/mkfs/f2fs_format.c 300 index 019fb3a..d937eda 100644 301 --- a/mkfs/f2fs_format.c 302 +++ b/mkfs/f2fs_format.c 303 @@ -6,8 +6,6 @@ 304 * 305 * Dual licensed under the GPL or LGPL version 2 licenses. 306 */ 307 -#define _LARGEFILE64_SOURCE 308 - 309 #include <stdio.h> 310 #include <stdlib.h> 311 #include <fcntl.h> 312 diff --git a/mkfs/f2fs_format_main.c b/mkfs/f2fs_format_main.c 313 index d8c9cea..08c1b25 100644 314 --- a/mkfs/f2fs_format_main.c 315 +++ b/mkfs/f2fs_format_main.c 316 @@ -6,8 +6,6 @@ 317 * 318 * Dual licensed under the GPL or LGPL version 2 licenses. 319 */ 320 -#define _LARGEFILE64_SOURCE 321 - 322 #include <stdio.h> 323 #include <stdlib.h> 324 #include <fcntl.h> 325 diff --git a/mkfs/f2fs_format_utils.c b/mkfs/f2fs_format_utils.c 326 index 448fbaa..437f113 100644 327 --- a/mkfs/f2fs_format_utils.c 328 +++ b/mkfs/f2fs_format_utils.c 329 @@ -6,20 +6,10 @@ 330 * 331 * Dual licensed under the GPL or LGPL version 2 licenses. 332 */ 333 -#ifndef _LARGEFILE_SOURCE 334 -#define _LARGEFILE_SOURCE 335 -#endif 336 -#ifndef _LARGEFILE64_SOURCE 337 -#define _LARGEFILE64_SOURCE 338 -#endif 339 #ifndef _GNU_SOURCE 340 #define _GNU_SOURCE 341 #endif 342 343 -#ifndef _FILE_OFFSET_BITS 344 -#define _FILE_OFFSET_BITS 64 345 -#endif 346 - 347 #include <f2fs_fs.h> 348 349 #include <stdio.h> 350 diff --git a/mkfs/f2fs_format_utils.h b/mkfs/f2fs_format_utils.h 351 index 807e7c3..6a7f687 100644 352 --- a/mkfs/f2fs_format_utils.h 353 +++ b/mkfs/f2fs_format_utils.h 354 @@ -6,8 +6,6 @@ 355 * 356 * Dual licensed under the GPL or LGPL version 2 licenses. 357 */ 358 -#define _LARGEFILE64_SOURCE 359 - 360 #include "f2fs_fs.h" 361 362 extern struct f2fs_configuration c; 363 diff --git a/tools/Makefile.am b/tools/Makefile.am 364 index 6b03814..7dfffb1 100644 365 --- a/tools/Makefile.am 366 +++ b/tools/Makefile.am 367 @@ -1,7 +1,7 @@ 368 ## Makefile.am 369 370 AM_CPPFLAGS = ${libuuid_CFLAGS} -I$(top_srcdir)/include 371 -AM_CFLAGS = -Wall 372 +AM_CFLAGS = -Wall -D_FILE_OFFSET_BITS=64 373 sbin_PROGRAMS = 374 if !WINDOWS 375 sbin_PROGRAMS += fibmap.f2fs parse.f2fs 376 diff --git a/tools/f2fs_io/Makefile.am b/tools/f2fs_io/Makefile.am 377 index bc4f9d0..f5227ce 100644 378 --- a/tools/f2fs_io/Makefile.am 379 +++ b/tools/f2fs_io/Makefile.am 380 @@ -2,7 +2,7 @@ 381 382 if LINUX 383 AM_CPPFLAGS = -I$(top_srcdir)/include 384 -AM_CFLAGS = -Wall 385 +AM_CFLAGS = -Wall -D_FILE_OFFSET_BITS=64 386 sbin_PROGRAMS = f2fs_io 387 f2fs_io_SOURCES = f2fs_io.c 388 endif 389 diff --git a/tools/f2fs_io/f2fs_io.c b/tools/f2fs_io/f2fs_io.c 390 index 771fd16..1f6549b 100644 391 --- a/tools/f2fs_io/f2fs_io.c 392 +++ b/tools/f2fs_io/f2fs_io.c 393 @@ -9,12 +9,6 @@ 394 #ifndef _GNU_SOURCE 395 #define _GNU_SOURCE 396 #endif 397 -#ifndef _LARGEFILE_SOURCE 398 -#define _LARGEFILE_SOURCE 399 -#endif 400 -#ifndef _LARGEFILE64_SOURCE 401 -#define _LARGEFILE64_SOURCE 402 -#endif 403 #ifndef O_LARGEFILE 404 #define O_LARGEFILE 0 405 #endif 406 diff --git a/tools/f2fs_io_parse.c b/tools/f2fs_io_parse.c 407 index 47f1194..c3c1005 100644 408 --- a/tools/f2fs_io_parse.c 409 +++ b/tools/f2fs_io_parse.c 410 @@ -8,7 +8,6 @@ 411 * it under the terms of the GNU General Public License version 2 as 412 * published by the Free Software Foundation. 413 */ 414 -#define _LARGEFILE64_SOURCE 415 #include <stdio.h> 416 #include <stdlib.h> 417 #include <unistd.h> 418 diff --git a/tools/f2fscrypt.c b/tools/f2fscrypt.c 419 index 8640ffa..d5222fb 100644 420 --- a/tools/f2fscrypt.c 421 +++ b/tools/f2fscrypt.c 422 @@ -7,15 +7,6 @@ 423 * Authors: Michael Halcrow <mhalcrow@google.com>, 424 * Ildar Muslukhov <ildarm@google.com> 425 */ 426 - 427 -#ifndef _LARGEFILE_SOURCE 428 -#define _LARGEFILE_SOURCE 429 -#endif 430 - 431 -#ifndef _LARGEFILE64_SOURCE 432 -#define _LARGEFILE64_SOURCE 433 -#endif 434 - 435 #ifndef _GNU_SOURCE 436 #define _GNU_SOURCE 437 #endif 438 diff --git a/tools/fibmap.c b/tools/fibmap.c 439 index bda8238..3acc77b 100644 440 --- a/tools/fibmap.c 441 +++ b/tools/fibmap.c 442 @@ -1,13 +1,6 @@ 443 #if !defined(__FreeBSD__) && !defined(__NetBSD__) && !defined(__OpenBSD__) 444 #define _XOPEN_SOURCE 600 445 #define _DARWIN_C_SOURCE 446 -#define _FILE_OFFSET_BITS 64 447 -#ifndef _LARGEFILE_SOURCE 448 -#define _LARGEFILE_SOURCE 449 -#endif 450 -#ifndef _LARGEFILE64_SOURCE 451 -#define _LARGEFILE64_SOURCE 452 -#endif 453 #ifndef _GNU_SOURCE 454 #define _GNU_SOURCE 455 #endif 456 -- 457 cgit 458