From 3bac4caa2bc64db313aaee54fffb90383e118517 Mon Sep 17 00:00:00 2001
From: Felix Janda <felix.janda@posteo.de>
Date: Thu, 22 Jan 2015 19:54:36 +0100
Subject: [PATCH] Remove direct _llseek code and require long filesystem libc.

Signed-off-by: Khem Raj <raj.khem@gmail.com>
---
Upstream-Status: Backport
 configure.ac                    |  8 ++++++++
 grub-core/osdep/unix/hostdisk.c | 24 ------------------------
 4 files changed, 13 insertions(+), 24 deletions(-)

Index: grub-2.00/configure.ac
===================================================================
--- grub-2.00.orig/configure.ac
+++ grub-2.00/configure.ac
@@ -306,6 +306,14 @@ if test x$grub_cv_apple_cc = xyes ; then
   HOST_LDFLAGS="$HOST_LDFLAGS -Wl,-allow_stack_execute"
 fi
 
+case "$host_os" in
+  cygwin | windows* | mingw32* | aros*)
+     ;;
+  *)
+     AC_CHECK_SIZEOF(off_t)
+     test x"$ac_cv_sizeof_off_t" = x8 || AC_MSG_ERROR([Large file support is required]);;
+esac
+
 if test x$USE_NLS = xno; then
   HOST_CFLAGS="$HOST_CFLAGS -fno-builtin-gettext"
 fi
Index: grub-2.00/grub-core/kern/emu/hostdisk.c
===================================================================
--- grub-2.00.orig/grub-core/kern/emu/hostdisk.c
+++ grub-2.00/grub-core/kern/emu/hostdisk.c
@@ -44,11 +44,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)) */
 # ifndef BLKFLSBUF
 #  define BLKFLSBUF     _IO (0x12,97)   /* flush buffer cache */
 # endif /* ! BLKFLSBUF */
@@ -761,25 +756,6 @@ linux_find_partition (char *dev, grub_di
 }
 #endif /* __linux__ */
 
-#if defined(__linux__) && (!defined(__GLIBC__) || \
-        ((__GLIBC__ < 2) || ((__GLIBC__ == 2) && (__GLIBC_MINOR__ < 1))))
-  /* Maybe libc doesn't have large file support.  */
-grub_err_t
-grub_util_fd_seek (int fd, const char *name, 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 grub_error (GRUB_ERR_BAD_DEVICE, N_("cannot seek `%s': %s"),
-		       name, strerror (errno));
-  return GRUB_ERR_NONE;
-}
-#else
 grub_err_t
 grub_util_fd_seek (int fd, const char *name, grub_uint64_t off)
 {
@@ -790,7 +766,6 @@ grub_util_fd_seek (int fd, const char *n
 		       name, strerror (errno));
   return 0;
 }
-#endif
 
 static void
 flush_initial_buffer (const char *os_dev __attribute__ ((unused)))
