erofs-utils: Enable 64-bit off_t with AC_SYS_LARGEFILE
A message that is not in the archive (sent off-list or not yet received): [email protected]
A message that is not in the archive (sent off-list or not yet received): [email protected]
A message that is not in the archive (sent off-list or not yet received): rlp54h7fqffgfms2hgabxyjdbzmqx6xdhmj7gb2tarro32gj5p@nwb3nqv7jafq
Hi Jame,
Quoted 92 lines · James Le Cuirot
Quoted 91 lines · James Le Cuirot
I was initially just going go fix the += Bashism, but this is the safe and portable way to enable 64-bit
off_t. It is not possible to enable it on some very old systems.erofs_off_tis hardcoded to u64, but I believe this will still work correctly alongside a 32-bitoff_t.Either way, you don't need
HAVE_PREAD64orHAVE_PWRITE64because pread64/pwrite64 are aliases of pread/pwrite whenoff_tis 64-bit. Seeunistd.hand man pread(2).Signed-off-by James Le Cuirot <[email protected]>--- configure.ac | 4 +--- lib/io.c | 20 +------------------- 2 files changed, 2 insertions(+), 22 deletions(-)configure.ac +1
-3@@ -251,8 +251,6 @@ AC_CHECK_FUNCS(m4_flatten([ lsetxattr memset realpath - pread64 - pwrite64 pwritev posix_fadvise fstatfs@@ -554,7 +552,7 @@ AS_IF([test "x$with_xxhash" != "xno"], [ ]) # Enable 64-bit off_t -CFLAGS+=" -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64" +AC_SYS_LARGEFILE # Configure fuzzing mode AS_IF([test "x$enable_fuzzing" != "xyes"], [], [lib/io.c +1
-19@@ -74,11 +74,7 @@ ssize_t erofs_io_pwrite(struct erofs_vfile *vf, const void *buf, pos += vf->offset; do { -#ifdef HAVE_PWRITE64 - ret = pwrite64(vf->fd, buf, len, (off64_t)pos); -#else ret = pwrite(vf->fd, buf, len, (off_t)pos); -#endif if (ret <= 0) { if (!ret) break;@@ -208,11 +204,7 @@ ssize_t erofs_io_pread(struct erofs_vfile *vf, void *buf, u64 pos, size_t len) pos += vf->offset; do { -#ifdef HAVE_PREAD64 - ret = pread64(vf->fd, buf, len, (off64_t)pos); -#else ret = pread(vf->fd, buf, len, (off_t)pos); -#endif if (ret <= 0) { if (!ret) break;@@ -436,11 +428,7 @@ static ssize_t __erofs_copy_file_range(int fd_in, u64 *off_in,char *end, *p; to_read =min_t (size_t, length,sizeof (buf)); -#ifdef HAVE_PREAD64 - read_count =pread64 (fd_in, buf, to_read, *off_in); -#else read_count =pread (fd_in, buf, to_read, *off_in); -#endif if (read_count ==0 )/* End of file reached prematurely. */ return copied;@@ -455,13 +443,7 @@ static ssize_t __erofs_copy_file_range(int fd_in, u64 *off_in,/* Write the buffer part which was read to the destination. */ end = buf + read_count;for (p = buf; p < end; ) { -ssize_t write_count; - -#ifdef HAVE_PWRITE64 - write_count =pwrite64 (fd_out, p, end - p, *off_out); -#else - write_count =pwrite (fd_out, p, end - p, *off_out); -#endif +ssize_t write_count =pwrite (fd_out, p, end - p, *off_out);if (write_count <0 ) {/*
Quoted 8 lines
Quoted 4 lines
lib/io.c +0
-0* Adjust the input read position to match what Signature · 1 line
2.51.2Unfortunately, it's been pointed out to me that this change isn't safe because the
config.hgenerated by configure is not consistently included everywhere. That could be fixed, but I don't feel like untangling that myself.
Sorry for late response.
Yes, currently config.h is not used everywhere, so it's still perferred to use CFLAGS for now.
Thanks,
Gao Xiang
Re: [PATCH 1/2] erofs-utils: Drop configure checks for unused functions
In reply to a message not in the archiveHi James,
Quoted 1 line · James Le Cuirot
Signed-off-by James Le Cuirot <[email protected]>
I will apply this patch, but Cc the erofs mailing list as well.
Thanks,
Gao Xiang
Quoted 47 lines
--- configure.ac | 25 ------------------------- 1 file changed, 25 deletions(-)configure.ac +0
-25@@ -233,29 +233,6 @@ AC_CHECK_MEMBERS([struct stat.st_atim]) AC_CHECK_MEMBERS([struct stat.st_atimensec]) AC_TYPE_UINT64_T -# -# Check to see if llseek() is declared in unistd.h. On some libc's -# it is, and on others it isn't..... Thank you glibc developers.... -# -AC_CHECK_DECL(llseek, - [AC_DEFINE(HAVE_LLSEEK_PROTOTYPE, 1, - [Define to 1 if llseek declared in unistd.h])],, - [#include <unistd.h>]) - -# -# Check to see if lseek64() is declared in unistd.h. Glibc's header files -# are so convoluted that I can't tell whether it will always be defined, -# and if it isn't defined while lseek64 is defined in the library, -# disaster will strike. -# -# Warning! Use of --enable-gcc-wall may throw off this test. -# -AC_CHECK_DECL(lseek64,[AC_DEFINE(HAVE_LSEEK64_PROTOTYPE, 1, - [Define to 1 if lseek64 declared in unistd.h])],, - [#define _LARGEFILE_SOURCE - #define _LARGEFILE64_SOURCE - #include <unistd.h>]) - AC_CHECK_DECL(memrchr,[AC_DEFINE(HAVE_MEMRCHR, 1, [Define to 1 if memrchr declared in string.h])],, [#define _GNU_SOURCE@@ -274,8 +251,6 @@ AC_CHECK_FUNCS(m4_flatten([ lsetxattr memset realpath - lseek64 - ftello64 pread64 pwrite64 pwritev