Skip to contentSkip to conversation

On linux require the libc to have large file support

PATCH In review Felix Janda 3 participants 6 messages Jan 17, 2015 – Jan 25, 2015

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 On linux require the libc to have large file support

With this, support code in grub-core/osdep/unix/hostdisk.c for old glibc releases could be removed.
---
This patch tries to address the issues raised in

http://lists.gnu.org/archive/html/grub-devel/2014-12/msg00030.html

---
 INSTALL                         |  1 +
 configure.ac                    |  5 +++++
 grub-core/osdep/unix/hostdisk.c | 25 -------------------------
 3 files changed, 6 insertions(+), 25 deletions(-)
INSTALL +1 -0
index b67cd7f..ac7c2aa 100644
@@ -39,6 +39,7 @@ configuring the GRUB.
 On GNU/Linux, you also need:
 
 * libdevmapper 1.02.34 or later (recommended)
+* a libc with large file support (e.g. glibc 2.1 or later)
 
 For optional grub-emu features, you need:
 
configure.ac +5 -0
index 31d2b0b..bdaebb8 100644
@@ -346,6 +346,11 @@ AC_GNU_SOURCE
 AM_GNU_GETTEXT([external])
 AC_SYS_LARGEFILE
 
+if test x"$host_kernel" = xlinux ; then
+  AC_CHECK_SIZEOF(off_t)
+  test x"$ac_cv_sizeof_off_t" = x8 || AC_MSG_ERROR([Large file support is required])
+fi
+
 # Identify characteristics of the host architecture.
 unset ac_cv_c_bigendian
 
grub-core/osdep/unix/hostdisk.c +0 -25
index 43b56ff..14cab1c 100644
@@ -48,11 +48,6 @@
 #ifdef __linux__
 # include <sys/ioctl.h>         /* ioctl */
 # include <sys/mount.h>
-# if !defined(__GLIBC__) || \
-        ((__GLIBC__ < 2) || ((__GLIBC__ == 2) && (__GLIBC_MINOR__ < 1)))
-/* Maybe libc doesn't have large file support.  */
-#  include <linux/unistd.h>     /* _llseek */
-# endif /* (GLIBC < 2) || ((__GLIBC__ == 2) && (__GLIBC_MINOR < 1)) */
 #endif /* __linux__ */
 
 grub_uint64_t
@@ -79,24 +74,6 @@ grub_util_get_fd_size (grub_util_fd_t fd, const char *name, unsigned *log_secsiz
   return st.st_size;
 }
 
-#if defined(__linux__) && (!defined(__GLIBC__) || \
-        ((__GLIBC__ < 2) || ((__GLIBC__ == 2) && (__GLIBC_MINOR__ < 1))))
-  /* Maybe libc doesn't have large file support.  */
-int
-grub_util_fd_seek (grub_util_fd_t fd, grub_uint64_t off)
-{
-  loff_t offset, result;
-  static int _llseek (uint filedes, ulong hi, ulong lo,
-		      loff_t *res, uint wh);
-  _syscall5 (int, _llseek, uint, filedes, ulong, hi, ulong, lo,
-	     loff_t *, res, uint, wh);
-
-  offset = (loff_t) off;
-  if (_llseek (fd, offset >> 32, offset & 0xffffffff, &result, SEEK_SET))
-    return -1;
-  return GRUB_ERR_NONE;
-}
-#else
 int
 grub_util_fd_seek (grub_util_fd_t fd, grub_uint64_t off)
 {
@@ -107,8 +84,6 @@ grub_util_fd_seek (grub_util_fd_t fd, grub_uint64_t off)
 
   return 0;
 }
-#endif
-
 
 /* Read LEN bytes from FD in BUF. Return less than or equal to zero if an
    error occurs, otherwise return LEN.  */
Signature · 1 line
2.0.5
#1 lore raw

В Sat, 17 Jan 2015 14:57:07 +0100
Felix Janda <[email protected]> пишет:

Quoted 29 lines

With this, support code in grub-core/osdep/unix/hostdisk.c for old glibc releases could be removed.
---
This patch tries to address the issues raised in

http://lists.gnu.org/archive/html/grub-devel/2014-12/msg00030.html

---
 INSTALL                         |  1 +
 configure.ac                    |  5 +++++
 grub-core/osdep/unix/hostdisk.c | 25 -------------------------
 3 files changed, 6 insertions(+), 25 deletions(-)
INSTALL +1 -0
index b67cd7f..ac7c2aa 100644
@@ -39,6 +39,7 @@ configuring the GRUB.
 On GNU/Linux, you also need:
 
 * libdevmapper 1.02.34 or later (recommended)
+* a libc with large file support (e.g. glibc 2.1 or later)
 
 For optional grub-emu features, you need:
 
configure.ac +0 -0
index 31d2b0b..bdaebb8 100644

configure.ac AC_GNU_SOURCE · line 349

Quoted 4 lines
configure.ac +1 -0
@@ -346,6 +346,11 @@ AC_GNU_SOURCE
 AM_GNU_GETTEXT([external])
 AC_SYS_LARGEFILE
 
+if test x"$host_kernel" = xlinux ; then

I wonder if we should do it unconditionally. Large files support is really presumed by current code.

Not for now, but something to keep in mind for next version.

Quoted 57 lines
configure.ac +4 -0
+  AC_CHECK_SIZEOF(off_t)
+  test x"$ac_cv_sizeof_off_t" = x8 || AC_MSG_ERROR([Large file support is required])
+fi
+
 # Identify characteristics of the host architecture.
 unset ac_cv_c_bigendian
 
grub-core/osdep/unix/hostdisk.c +0 -25
index 43b56ff..14cab1c 100644
@@ -48,11 +48,6 @@
 #ifdef __linux__
 # include <sys/ioctl.h>         /* ioctl */
 # include <sys/mount.h>
-# if !defined(__GLIBC__) || \
-        ((__GLIBC__ < 2) || ((__GLIBC__ == 2) && (__GLIBC_MINOR__ < 1)))
-/* Maybe libc doesn't have large file support.  */
-#  include <linux/unistd.h>     /* _llseek */
-# endif /* (GLIBC < 2) || ((__GLIBC__ == 2) && (__GLIBC_MINOR < 1)) */
 #endif /* __linux__ */
 
 grub_uint64_t
@@ -79,24 +74,6 @@ grub_util_get_fd_size (grub_util_fd_t fd, const char *name, unsigned *log_secsiz
   return st.st_size;
 }
 
-#if defined(__linux__) && (!defined(__GLIBC__) || \
-        ((__GLIBC__ < 2) || ((__GLIBC__ == 2) && (__GLIBC_MINOR__ < 1))))
-  /* Maybe libc doesn't have large file support.  */
-int
-grub_util_fd_seek (grub_util_fd_t fd, grub_uint64_t off)
-{
-  loff_t offset, result;
-  static int _llseek (uint filedes, ulong hi, ulong lo,
-		      loff_t *res, uint wh);
-  _syscall5 (int, _llseek, uint, filedes, ulong, hi, ulong, lo,
-	     loff_t *, res, uint, wh);
-
-  offset = (loff_t) off;
-  if (_llseek (fd, offset >> 32, offset & 0xffffffff, &result, SEEK_SET))
-    return -1;
-  return GRUB_ERR_NONE;
-}
-#else
 int
 grub_util_fd_seek (grub_util_fd_t fd, grub_uint64_t off)
 {
@@ -107,8 +84,6 @@ grub_util_fd_seek (grub_util_fd_t fd, grub_uint64_t off)
 
   return 0;
 }
-#endif
-
 
 /* Read LEN bytes from FD in BUF. Return less than or equal to zero if an
    error occurs, otherwise return LEN.  */
#2 lore raw
Quoted 35 lines · Andrei Borzenkov

В Sat, 17 Jan 2015 14:57:07 +0100
Felix Janda <[email protected]> пишет:

Quoted 32 lines

With this, support code in grub-core/osdep/unix/hostdisk.c for old glibc releases could be removed.
---
This patch tries to address the issues raised in

http://lists.gnu.org/archive/html/grub-devel/2014-12/msg00030.html

---
 INSTALL                         |  1 +
 configure.ac                    |  5 +++++
 grub-core/osdep/unix/hostdisk.c | 25 -------------------------
 3 files changed, 6 insertions(+), 25 deletions(-)
INSTALL +1 -0
index b67cd7f..ac7c2aa 100644
@@ -39,6 +39,7 @@ configuring the GRUB.
 On GNU/Linux, you also need:
 
 * libdevmapper 1.02.34 or later (recommended)
+* a libc with large file support (e.g. glibc 2.1 or later)
 
 For optional grub-emu features, you need:
 
configure.ac +0 -0
index 31d2b0b..bdaebb8 100644
@@ -346,6 +346,11 @@ AC_GNU_SOURCE
 AM_GNU_GETTEXT([external])
 AC_SYS_LARGEFILE
 
Quoted 6 lines

configure.ac AC_GNU_SOURCE · line 349

Quoted 1 line
configure.ac +1 -0
+if test x"$host_kernel" = xlinux ; then

I wonder if we should do it unconditionally. Large files support is really presumed by current code.

Not for now, but something to keep in mind for next version.

Yes, the test is not ideal. But enabling it for everything would break cygwin. (There sizeof(off_t)=4 and the windows hostdisk.c is used.)

It was not obvious for me how to detect all architectures that build grub-core/osdep/unix/hostdisk.c. It would also be possible to put something like

int get_a_libc_with_lfs_support[sizeof(off_t)-8];

into grub-core/osdep/unix/hostdisk.c making at least the build fail for the right architectures.

Quoted 8 lines
Quoted 8 lines
configure.ac +4 -0
+  AC_CHECK_SIZEOF(off_t)
+  test x"$ac_cv_sizeof_off_t" = x8 || AC_MSG_ERROR([Large file support is required])
+fi
+
 # Identify characteristics of the host architecture.
 unset ac_cv_c_bigendian
 
[..]
#3 lore raw
Quoted 41 lines · Felix Janda
Quoted 40 lines · Andrei Borzenkov

В Sat, 17 Jan 2015 14:57:07 +0100
Felix Janda <[email protected]> пишет:

Quoted 29 lines

With this, support code in grub-core/osdep/unix/hostdisk.c for old glibc releases could be removed.
---
This patch tries to address the issues raised in

http://lists.gnu.org/archive/html/grub-devel/2014-12/msg00030.html

---
 INSTALL                         |  1 +
 configure.ac                    |  5 +++++
 grub-core/osdep/unix/hostdisk.c | 25 -------------------------
 3 files changed, 6 insertions(+), 25 deletions(-)
INSTALL +1 -0
index b67cd7f..ac7c2aa 100644
@@ -39,6 +39,7 @@ configuring the GRUB.
 On GNU/Linux, you also need:
 
 * libdevmapper 1.02.34 or later (recommended)
+* a libc with large file support (e.g. glibc 2.1 or later)
 
 For optional grub-emu features, you need:
 
configure.ac +0 -0
index 31d2b0b..bdaebb8 100644

configure.ac AC_GNU_SOURCE · line 349

Quoted 4 lines
configure.ac +1 -0
@@ -346,6 +346,11 @@ AC_GNU_SOURCE
 AM_GNU_GETTEXT([external])
 AC_SYS_LARGEFILE
 
+if test x"$host_kernel" = xlinux ; then

I wonder if we should do it unconditionally. Large files support is really presumed by current code.

Quoted 5 lines
Quoted 1 line

Not for now, but something to keep in mind for next version.

Yes, the test is not ideal. But enabling it for everything would break cygwin. (There sizeof(off_t)=4 and the windows hostdisk.c is used.)

Sorry, that should be mingw. I've taken this from

http://stackoverflow.com/questions/18908557/how-to-enable-largefile-support-on-windows-using-mingw-autotools

Quoted 18 lines

It was not obvious for me how to detect all architectures that build grub-core/osdep/unix/hostdisk.c. It would also be possible to put something like

int get_a_libc_with_lfs_support[sizeof(off_t)-8];

into grub-core/osdep/unix/hostdisk.c making at least the build fail for the right architectures.

Quoted 8 lines
Quoted 8 lines
configure.ac +4 -0
+  AC_CHECK_SIZEOF(off_t)
+  test x"$ac_cv_sizeof_off_t" = x8 || AC_MSG_ERROR([Large file support is required])
+fi
+
 # Identify characteristics of the host architecture.
 unset ac_cv_c_bigendian
 
[..]
#4 lore raw
Quoted 42 lines · Felix Janda
Quoted 41 lines · Felix Janda
Quoted 40 lines · Andrei Borzenkov

В Sat, 17 Jan 2015 14:57:07 +0100
Felix Janda <[email protected]> пишет:

Quoted 29 lines

With this, support code in grub-core/osdep/unix/hostdisk.c for old glibc releases could be removed.
---
This patch tries to address the issues raised in

http://lists.gnu.org/archive/html/grub-devel/2014-12/msg00030.html

---
 INSTALL                         |  1 +
 configure.ac                    |  5 +++++
 grub-core/osdep/unix/hostdisk.c | 25 -------------------------
 3 files changed, 6 insertions(+), 25 deletions(-)
INSTALL +1 -0
index b67cd7f..ac7c2aa 100644
@@ -39,6 +39,7 @@ configuring the GRUB.
 On GNU/Linux, you also need:
 
 * libdevmapper 1.02.34 or later (recommended)
+* a libc with large file support (e.g. glibc 2.1 or later)
 
 For optional grub-emu features, you need:
 
configure.ac +0 -0
index 31d2b0b..bdaebb8 100644

configure.ac AC_GNU_SOURCE · line 349

Quoted 4 lines
configure.ac +1 -0
@@ -346,6 +346,11 @@ AC_GNU_SOURCE
 AM_GNU_GETTEXT([external])
 AC_SYS_LARGEFILE
 
+if test x"$host_kernel" = xlinux ; then

I wonder if we should do it unconditionally. Large files support is really presumed by current code.

Quoted 6 lines
Quoted 5 lines
Quoted 1 line

Not for now, but something to keep in mind for next version.

Yes, the test is not ideal. But enabling it for everything would break cygwin. (There sizeof(off_t)=4 and the windows hostdisk.c is used.)

I've put all windows flavours and AROS on whitelist. Everything else requires long-filesystem libc. Thank you for the patch.
Actually there may be a way to make mingw have long off_t, perhaps some define. If so, it would be better to add it and keep only AROS on whitelist.

Quoted 23 lines

Sorry, that should be mingw. I've taken this from

http://stackoverflow.com/questions/18908557/how-to-enable-largefile-support-on-windows-using-mingw-autotools

Quoted 18 lines

It was not obvious for me how to detect all architectures that build grub-core/osdep/unix/hostdisk.c. It would also be possible to put something like

int get_a_libc_with_lfs_support[sizeof(off_t)-8];

into grub-core/osdep/unix/hostdisk.c making at least the build fail for the right architectures.

Quoted 8 lines
Quoted 8 lines
configure.ac +4 -0
+  AC_CHECK_SIZEOF(off_t)
+  test x"$ac_cv_sizeof_off_t" = x8 || AC_MSG_ERROR([Large file support is required])
+fi
+
 # Identify characteristics of the host architecture.
 unset ac_cv_c_bigendian
 
[..]
#5 lore raw
Quoted 45 lines · Vladimir 'φ-coder/phcoder' Serbinenko
Quoted 44 lines · Felix Janda
Quoted 43 lines · Felix Janda
Quoted 41 lines · Andrei Borzenkov

В Sat, 17 Jan 2015 14:57:07 +0100
Felix Janda <[email protected]> пишет:

Quoted 29 lines

With this, support code in grub-core/osdep/unix/hostdisk.c for old glibc releases could be removed.
---
This patch tries to address the issues raised in

http://lists.gnu.org/archive/html/grub-devel/2014-12/msg00030.html

---
 INSTALL                         |  1 +
 configure.ac                    |  5 +++++
 grub-core/osdep/unix/hostdisk.c | 25 -------------------------
 3 files changed, 6 insertions(+), 25 deletions(-)
INSTALL +1 -0
index b67cd7f..ac7c2aa 100644
@@ -39,6 +39,7 @@ configuring the GRUB.
 On GNU/Linux, you also need:
 
 * libdevmapper 1.02.34 or later (recommended)
+* a libc with large file support (e.g. glibc 2.1 or later)
 
 For optional grub-emu features, you need:
 
configure.ac +0 -0
index 31d2b0b..bdaebb8 100644

configure.ac AC_GNU_SOURCE · line 349

Quoted 4 lines
configure.ac +1 -0
@@ -346,6 +346,11 @@ AC_GNU_SOURCE
 AM_GNU_GETTEXT([external])
 AC_SYS_LARGEFILE
 
+if test x"$host_kernel" = xlinux ; then

I wonder if we should do it unconditionally. Large files support is really presumed by current code.

Not for now, but something to keep in mind for next version.

Quoted 8 lines
Quoted 4 lines
Quoted 3 lines

Yes, the test is not ideal. But enabling it for everything would break cygwin. (There sizeof(off_t)=4 and the windows hostdisk.c is used.)

I've put all windows flavours and AROS on whitelist. Everything else requires long-filesystem libc. Thank you for the patch.
Actually there may be a way to make mingw have long off_t, perhaps some define. If so, it would be better to add it and keep only AROS on whitelist.

Thanks for fixing up the patch and committing!

Felix