* [PATCH e2fsprogs 1/2] configure.ac: call AC_SYS_LARGEFILE before checking the size of off_t
@ 2023-11-07 23:33 Sam James
2023-11-07 23:33 ` [PATCH e2fsprogs 2/2] lib/ext2fs: llseek: simplify linux section Sam James
2024-04-17 2:03 ` [PATCH e2fsprogs 1/2] configure.ac: call AC_SYS_LARGEFILE before checking the size of off_t Theodore Ts'o
0 siblings, 2 replies; 3+ messages in thread
From: Sam James @ 2023-11-07 23:33 UTC (permalink / raw)
To: linux-ext4; +Cc: Mike Gilbert, Sam James
From: Mike Gilbert <floppym@gentoo.org>
Signed-off-by: Mike Gilbert <floppym@gentoo.org>
Signed-off-by: Sam James <sam@gentoo.org>
---
configure.ac | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/configure.ac b/configure.ac
index b905e999..6b4484b0 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1116,6 +1116,7 @@ AC_CHECK_DECL(fsmap_sizeof,[AC_DEFINE(HAVE_FSMAP_SIZEOF, 1,
dnl
dnl Word sizes...
dnl
+AC_SYS_LARGEFILE
AC_CHECK_SIZEOF(short)
AC_CHECK_SIZEOF(int)
AC_CHECK_SIZEOF(long)
@@ -1901,8 +1902,6 @@ OS_IO_FILE=""
esac]
AC_SUBST(OS_IO_FILE)
-AC_SYS_LARGEFILE
-
dnl
dnl Make our output files, being sure that we create the some miscellaneous
dnl directories
--
2.42.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [PATCH e2fsprogs 2/2] lib/ext2fs: llseek: simplify linux section
2023-11-07 23:33 [PATCH e2fsprogs 1/2] configure.ac: call AC_SYS_LARGEFILE before checking the size of off_t Sam James
@ 2023-11-07 23:33 ` Sam James
2024-04-17 2:03 ` [PATCH e2fsprogs 1/2] configure.ac: call AC_SYS_LARGEFILE before checking the size of off_t Theodore Ts'o
1 sibling, 0 replies; 3+ messages in thread
From: Sam James @ 2023-11-07 23:33 UTC (permalink / raw)
To: linux-ext4; +Cc: Mike Gilbert, Sam James
From: Mike Gilbert <floppym@gentoo.org>
On 32-bit musl systems, off_t is always 8 bytes regardless of
_FILE_OFFSET_BITS. The previous code did not cover this case.
The previous #ifdef logic was rather confusing, so I reworked it into a
more understandable form.
Bug: https://bugs.gentoo.org/908892
Signed-off-by: Mike Gilbert <floppym@gentoo.org>
Closes: https://github.com/tytso/e2fsprogs/pull/150
Signed-off-by: Sam James <sam@gentoo.org>
---
lib/ext2fs/llseek.c | 67 ++++++++++-----------------------------------
1 file changed, 15 insertions(+), 52 deletions(-)
diff --git a/lib/ext2fs/llseek.c b/lib/ext2fs/llseek.c
index 45f21d09..9118b23f 100644
--- a/lib/ext2fs/llseek.c
+++ b/lib/ext2fs/llseek.c
@@ -35,68 +35,32 @@
#ifdef __linux__
-#if defined(HAVE_LSEEK64) && defined(HAVE_LSEEK64_PROTOTYPE)
-
-#define my_llseek lseek64
-
-#else
-#if defined(HAVE_LLSEEK)
-#include <sys/syscall.h>
-
-#ifndef HAVE_LLSEEK_PROTOTYPE
-extern long long llseek (int fd, long long offset, int origin);
-#endif
-
-#define my_llseek llseek
-
-#else /* ! HAVE_LLSEEK */
-
-#if SIZEOF_LONG == SIZEOF_LONG_LONG || _FILE_OFFSET_BITS+0 == 64
-
-#define my_llseek lseek
-
-#else /* SIZEOF_LONG != SIZEOF_LONG_LONG */
-
#include <linux/unistd.h>
-#ifndef __NR__llseek
-#define __NR__llseek 140
-#endif
-
-#ifndef __i386__
-static int _llseek (unsigned int, unsigned long,
- unsigned long, ext2_loff_t *, unsigned int);
-
-static _syscall5(int,_llseek,unsigned int,fd,unsigned long,offset_high,
- unsigned long, offset_low,ext2_loff_t *,result,
- unsigned int, origin);
-#endif
-
static ext2_loff_t my_llseek (int fd, ext2_loff_t offset, int origin)
{
- ext2_loff_t result;
+#if SIZEOF_OFF_T >= 8
+ return lseek(fd, offset, origin);
+#elif HAVE_LSEEK64_PROTOTYPE
+ return lseek64(fd, offset, origin);
+#elif HAVE_LLSEEK_PROTOTYPE
+ return llseek(fd, offset, origin);
+#elif defined(__NR__llseek)
+ loff_t result;
int retval;
-
-#ifndef __i386__
- retval = _llseek(fd, ((unsigned long long) offset) >> 32,
+ retval = syscall(__NR__llseek, fd,
+ (unsigned long)(offset >> 32),
+ (unsigned long)(offset & 0xffffffff),
+ &result, origin);
+ return (retval == -1 ? retval : result);
#else
- retval = syscall(__NR__llseek, fd, (unsigned long long) (offset >> 32),
+ errno = ENOSYS;
+ return -1;
#endif
- ((unsigned long long) offset) & 0xffffffff,
- &result, origin);
- return (retval == -1 ? (ext2_loff_t) retval : result);
}
-#endif /* SIZE_LONG == SIZEOF_LONG_LONG */
-
-#endif /* HAVE_LLSEEK */
-#endif /* defined(HAVE_LSEEK64) && defined(HAVE_LSEEK64_PROTOTYPE) */
-
ext2_loff_t ext2fs_llseek (int fd, ext2_loff_t offset, int origin)
{
-#if SIZEOF_OFF_T >= SIZEOF_LONG_LONG
- return my_llseek (fd, offset, origin);
-#else
ext2_loff_t result;
static int do_compat = 0;
@@ -117,7 +81,6 @@ ext2_loff_t ext2fs_llseek (int fd, ext2_loff_t offset, int origin)
return -1;
}
return result;
-#endif
}
#else /* !linux */
--
2.42.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH e2fsprogs 1/2] configure.ac: call AC_SYS_LARGEFILE before checking the size of off_t
2023-11-07 23:33 [PATCH e2fsprogs 1/2] configure.ac: call AC_SYS_LARGEFILE before checking the size of off_t Sam James
2023-11-07 23:33 ` [PATCH e2fsprogs 2/2] lib/ext2fs: llseek: simplify linux section Sam James
@ 2024-04-17 2:03 ` Theodore Ts'o
1 sibling, 0 replies; 3+ messages in thread
From: Theodore Ts'o @ 2024-04-17 2:03 UTC (permalink / raw)
To: linux-ext4, Sam James; +Cc: Theodore Ts'o, Mike Gilbert
On Tue, 07 Nov 2023 23:33:21 +0000, Sam James wrote:
>
Applied, thanks!
[1/2] configure.ac: call AC_SYS_LARGEFILE before checking the size of off_t
commit: fed000ae01749e938d7c4e612fb9a6659127096c
[2/2] lib/ext2fs: llseek: simplify linux section
commit: 24181bb25e52fdecadbc7e434834e6ece85ff932
Best regards,
--
Theodore Ts'o <tytso@mit.edu>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2024-04-17 2:04 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-11-07 23:33 [PATCH e2fsprogs 1/2] configure.ac: call AC_SYS_LARGEFILE before checking the size of off_t Sam James
2023-11-07 23:33 ` [PATCH e2fsprogs 2/2] lib/ext2fs: llseek: simplify linux section Sam James
2024-04-17 2:03 ` [PATCH e2fsprogs 1/2] configure.ac: call AC_SYS_LARGEFILE before checking the size of off_t Theodore Ts'o
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).