about summary refs log tree commit diff
path: root/sysdeps
diff options
context:
space:
mode:
authorRoland McGrath <roland@gnu.org>2002-06-11 21:47:12 +0000
committerRoland McGrath <roland@gnu.org>2002-06-11 21:47:12 +0000
commit51dc4636e8030817fcedcb6ec309c3953bb70cb5 (patch)
tree6fd8efa66e1328dc5f532b5dcc57f170cc0846fc /sysdeps
parenta8ab0e34e37ac86a920ed9232c7cbce4dd71c04b (diff)
downloadglibc-51dc4636e8030817fcedcb6ec309c3953bb70cb5.tar.gz
glibc-51dc4636e8030817fcedcb6ec309c3953bb70cb5.tar.xz
glibc-51dc4636e8030817fcedcb6ec309c3953bb70cb5.zip
2002-06-09 Roland McGrath <roland@frob.com>
	Update to new Hurd RPC interfaces supporting 64-bit file sizes.
	* sysdeps/mach/hurd/configure.in: Check for <hurd/version.h> with
	value of HURD_INTERFACE_VERSION >= 20020609.
	* sysdeps/mach/hurd/configure: Regenerated.
	* shlib-versions (.*-.*-gnu-gnu.*): Set libhurduser=0.3.
	* sysdeps/mach/hurd/xstatconv.c (xstat64_conv): Rewritten to
	convert a struct stat64 into a struct stat and return 0 or -1
	with errno set to EOVERFLOW.
	* sysdeps/mach/hurd/statfsconv.c (statfs64_conv): Likewise
	for struct statfs64 to struct statfs.
	* sysdeps/mach/hurd/xstat.c (__xstat): Use converter and call ...
	* sysdeps/mach/hurd/xstat64.c (__xstat64): ... this, real work here.
	* sysdeps/mach/hurd/fxstat.c (__fxstat): Likewise.
	* sysdeps/mach/hurd/fxstat64.c (__fxstat64): Likewise.
	* sysdeps/mach/hurd/lxstat.c (__lxstat): Likewise.
	* sysdeps/mach/hurd/lxstat64.c (__lxstat64): Likewise.
	* sysdeps/mach/hurd/statfs.c (__statfs): Likewise.
	* sysdeps/mach/hurd/statfs64.c (__statfs64): Likewise.
	* sysdeps/mach/hurd/fstatfs.c (__fstatfs): Likewise.
	* sysdeps/mach/hurd/fstatfs64.c (__fstatfs64): Likewise.
	* sysdeps/mach/hurd/pwrite64.c (__libc_pwrite64): Do real work here.
	* sysdeps/mach/hurd/pwrite.c (__libc_pwrite): Call that.
	* sysdeps/mach/hurd/pread64.c (__libc_pread64): Do real work here.
	* sysdeps/mach/hurd/pread.c (__libc_pread): Call that.
	* sysdeps/mach/hurd/lseek64.c (__libc_lseek64): Do real work here.
	* sysdeps/mach/hurd/lseek.c (__libc_lseek): Call that.
	* sysdeps/mach/hurd/readdir64.c (__readdir64): Do real work here.
	* sysdeps/mach/hurd/readdir.c (__readdir): Call that.
	* sysdeps/mach/hurd/readdir64_r.c (__readdir64_r): Do real work here.
	* sysdeps/mach/hurd/readdir_r.c (__readdir64_r): Call that.
	* hurd/lookup-retry.c (__hurd_file_name_lookup_retry):
	Use struct stat64 for io_stat argument.
	* sysdeps/mach/hurd/readlink.c (__readlink): Likewise.
	* hurd/fopenport.c (seekio): Remove EOVERFLOW check, pass POS directly
	to io_seek.
	* hurd/fd-read.c (_hurd_fd_read): Use loff_t for OFFSET argument.
	* hurd/fd-write.c (_hurd_fd_write): Likewise.
	* hurd/hurd/fd.h: Update decls.
	* sysdeps/mach/hurd/getcwd.c
	(_hurd_canonicalize_directory_name_internal): Use ino64_t
	and struct dirent64.
	* sysdeps/mach/hurd/dl-sysdep.c (open_file): Use struct stat64.
	(__xstat): Renamed to __xstat64, use struct stat64 for argument.
	(__fxstat): Renamed to __fxstat64, use struct stat64 for argument.
	(__lseek): Renamed to __libc_lseek64, use off64_t for argument.
Diffstat (limited to 'sysdeps')
-rwxr-xr-xsysdeps/mach/hurd/configure34
-rw-r--r--sysdeps/mach/hurd/configure.in13
-rw-r--r--sysdeps/mach/hurd/dl-sysdep.c12
-rw-r--r--sysdeps/mach/hurd/fstatfs.c15
-rw-r--r--sysdeps/mach/hurd/fstatfs64.c18
-rw-r--r--sysdeps/mach/hurd/fxstat.c17
-rw-r--r--sysdeps/mach/hurd/fxstat64.c22
-rw-r--r--sysdeps/mach/hurd/getcwd.c12
-rw-r--r--sysdeps/mach/hurd/lseek.c11
-rw-r--r--sysdeps/mach/hurd/lseek64.c21
-rw-r--r--sysdeps/mach/hurd/lxstat.c23
-rw-r--r--sysdeps/mach/hurd/lxstat64.c31
-rw-r--r--sysdeps/mach/hurd/pread.c10
-rw-r--r--sysdeps/mach/hurd/pread64.c22
-rw-r--r--sysdeps/mach/hurd/pwrite.c10
-rw-r--r--sysdeps/mach/hurd/pwrite64.c22
-rw-r--r--sysdeps/mach/hurd/readdir.c111
-rw-r--r--sysdeps/mach/hurd/readdir64.c85
-rw-r--r--sysdeps/mach/hurd/readdir64_r.c98
-rw-r--r--sysdeps/mach/hurd/readdir_r.c97
-rw-r--r--sysdeps/mach/hurd/readlink.c4
-rw-r--r--sysdeps/mach/hurd/statfs.c19
-rw-r--r--sysdeps/mach/hurd/statfs64.c28
-rw-r--r--sysdeps/mach/hurd/statfsconv.c46
-rw-r--r--sysdeps/mach/hurd/xstat.c23
-rw-r--r--sysdeps/mach/hurd/xstat64.c30
-rw-r--r--sysdeps/mach/hurd/xstatconv.c72
27 files changed, 466 insertions, 440 deletions
diff --git a/sysdeps/mach/hurd/configure b/sysdeps/mach/hurd/configure
index 3faa1e5e84..7b5b336472 100755
--- a/sysdeps/mach/hurd/configure
+++ b/sysdeps/mach/hurd/configure
@@ -27,3 +27,37 @@ case "$machine" in
     fi
     ;;
 esac
+
+echo $ac_n "checking Hurd header version""... $ac_c" 1>&6
+echo "configure:33: checking Hurd header version" >&5
+if eval "test \"`echo '$''{'libc_cv_hurd_version'+set}'`\" = set"; then
+  echo $ac_n "(cached) $ac_c" 1>&6
+else
+  cat > conftest.$ac_ext <<EOF
+#line 38 "configure"
+#include "confdefs.h"
+#include <hurd/version.h>
+int main() {
+
+#define NEED_VERSION 20020609
+#if HURD_INTERFACE_VERSION < NEED_VERSION
+# error Hurd version too old: HURD_INTERFACE_VERSION < NEED_VERSION
+#endif
+; return 0; }
+EOF
+if { (eval echo configure:49: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+  rm -rf conftest*
+  libc_cv_hurd_version=ok
+else
+  echo "configure: failed program was:" >&5
+  cat conftest.$ac_ext >&5
+  rm -rf conftest*
+  libc_cv_hurd_version=bad
+fi
+rm -f conftest*
+fi
+
+echo "$ac_t""$libc_cv_hurd_version" 1>&6
+if test "x$libc_cv_hurd_version" != xok; then
+  { echo "configure: error: Hurd headers not installed or too old" 1>&2; exit 1; }
+fi
diff --git a/sysdeps/mach/hurd/configure.in b/sysdeps/mach/hurd/configure.in
index e45925c8bd..c71b339c39 100644
--- a/sysdeps/mach/hurd/configure.in
+++ b/sysdeps/mach/hurd/configure.in
@@ -29,3 +29,16 @@ case "$machine" in
     fi
     ;;
 esac
+
+AC_CACHE_CHECK(Hurd header version, libc_cv_hurd_version, [dnl
+AC_TRY_COMPILE(dnl
+[#include <hurd/version.h>], [
+#define NEED_VERSION 20020609
+#if HURD_INTERFACE_VERSION < NEED_VERSION
+# error Hurd version too old: HURD_INTERFACE_VERSION < NEED_VERSION
+#endif],
+	       libc_cv_hurd_version=ok,
+	       libc_cv_hurd_version=bad)])
+if test "x$libc_cv_hurd_version" != xok; then
+  AC_MSG_ERROR(Hurd headers not installed or too old)
+fi
diff --git a/sysdeps/mach/hurd/dl-sysdep.c b/sysdeps/mach/hurd/dl-sysdep.c
index a17e92aff3..644edeedb5 100644
--- a/sysdeps/mach/hurd/dl-sysdep.c
+++ b/sysdeps/mach/hurd/dl-sysdep.c
@@ -1,5 +1,5 @@
 /* Operating system support for run-time dynamic linker.  Hurd version.
-   Copyright (C) 1995,96,97,98,99,2000,2001 Free Software Foundation, Inc.
+   Copyright (C) 1995,96,97,98,99,2000,01,02 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
    The GNU C Library is free software; you can redistribute it and/or
@@ -269,7 +269,7 @@ _dl_sysdep_start_cleanup (void)
    error.  If STAT is non-zero, stat the file into that stat buffer.  */
 static error_t
 open_file (const char *file_name, int flags,
-	   mach_port_t *port, struct stat *stat)
+	   mach_port_t *port, struct stat64 *stat)
 {
   enum retry_type doretry;
   char retryname[1024];		/* XXX string_t LOSES! */
@@ -406,8 +406,8 @@ __writev (int fd, const struct iovec *iov, int niov)
 }
 
 
-off_t weak_function
-__lseek (int fd, off_t offset, int whence)
+off64_t weak_function
+__libc_lseek64 (int fd, off64_t offset, int whence)
 {
   error_t err;
 
@@ -477,7 +477,7 @@ __mmap (__ptr_t addr, size_t len, int prot, int flags, int fd, off_t offset)
 }
 
 int weak_function
-__fxstat (int vers, int fd, struct stat *buf)
+__fxstat64 (int vers, int fd, struct stat64 *buf)
 {
   error_t err;
 
@@ -491,7 +491,7 @@ __fxstat (int vers, int fd, struct stat *buf)
 }
 
 int weak_function
-__xstat (int vers, const char *file, struct stat *buf)
+__xstat64 (int vers, const char *file, struct stat64 *buf)
 {
   error_t err;
   mach_port_t port;
diff --git a/sysdeps/mach/hurd/fstatfs.c b/sysdeps/mach/hurd/fstatfs.c
index eea8493278..5949b497e3 100644
--- a/sysdeps/mach/hurd/fstatfs.c
+++ b/sysdeps/mach/hurd/fstatfs.c
@@ -1,5 +1,5 @@
 /* fstatfs -- Return information about the filesystem on which FD resides.
-   Copyright (C) 1996, 1997 Free Software Foundation, Inc.
+   Copyright (C) 1996,97,2002 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
    The GNU C Library is free software; you can redistribute it and/or
@@ -17,21 +17,16 @@
    Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
    02111-1307 USA.  */
 
-#include <hurd.h>
-#include <hurd/fd.h>
 #include <sys/statfs.h>
-#include <stddef.h>
+
+#include "statfsconv.c"
 
 /* Return information about the filesystem on which FD resides.  */
 int
 __fstatfs (int fd, struct statfs *buf)
 {
-  error_t err;
-
-  if (err = HURD_DPORT_USE (fd, __file_statfs (port, buf)))
-    return __hurd_dfail (fd, err);
-
-  return 0;
+  struct statfs64 buf64;
+  return __fstatfs64 (fd, &buf64) ?: statfs64_conv (buf, &buf64);
 }
 
 weak_alias (__fstatfs, fstatfs)
diff --git a/sysdeps/mach/hurd/fstatfs64.c b/sysdeps/mach/hurd/fstatfs64.c
index e32be12449..d87aa378a0 100644
--- a/sysdeps/mach/hurd/fstatfs64.c
+++ b/sysdeps/mach/hurd/fstatfs64.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 2001 Free Software Foundation, Inc.
+/* Copyright (C) 2001,02 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
    The GNU C Library is free software; you can redistribute it and/or
@@ -17,6 +17,8 @@
    02111-1307 USA.  */
 
 #include <sys/statfs.h>
+#include <hurd.h>
+#include <hurd/fd.h>
 
 #include "statfsconv.c"
 
@@ -24,17 +26,11 @@
 int
 __fstatfs64 (int fd, struct statfs64 *buf)
 {
-  int result;
-  struct statfs buf32;
+  error_t err;
 
-  /* XXX We simply call __fstatfs and convert the result to `struct
-     statfs64'.  We can probably get away with that since we don't
-     support large files on the Hurd yet.  */
-  result = __fstatfs (fd, &buf32);
-  if (result == 0)
-    statfs64_conv (&buf32, buf);
+  if (err = HURD_DPORT_USE (fd, __file_statfs (port, buf)))
+    return __hurd_dfail (fd, err);
 
-  return result;
+  return 0;
 }
-
 weak_alias (__fstatfs64, fstatfs64)
diff --git a/sysdeps/mach/hurd/fxstat.c b/sysdeps/mach/hurd/fxstat.c
index b4a5c8d9f4..3b95dcc8bf 100644
--- a/sysdeps/mach/hurd/fxstat.c
+++ b/sysdeps/mach/hurd/fxstat.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1992, 93, 94, 95, 96, 97 Free Software Foundation, Inc.
+/* Copyright (C) 1992,93,94,95,96,97,2002 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
    The GNU C Library is free software; you can redistribute it and/or
@@ -19,22 +19,15 @@
 #include <errno.h>
 #include <stddef.h>
 #include <sys/stat.h>
-#include <hurd.h>
-#include <hurd/fd.h>
+
+#include "xstatconv.c"
 
 /* Get information about the file descriptor FD in BUF.  */
 int
 __fxstat (int vers, int fd, struct stat *buf)
 {
-  error_t err;
-
-  if (vers != _STAT_VER)
-    return __hurd_fail (EINVAL);
-
-  if (err = HURD_DPORT_USE (fd, __io_stat (port, buf)))
-    return __hurd_dfail (fd, err);
-
-  return 0;
+  struct stat64 buf64;
+  return __fxstat64 (vers, fd, &buf64) ?: xstat64_conv (buf, &buf64);
 }
 
 weak_alias (__fxstat, _fxstat)
diff --git a/sysdeps/mach/hurd/fxstat64.c b/sysdeps/mach/hurd/fxstat64.c
index 6ebfc28756..4aa8c7d90d 100644
--- a/sysdeps/mach/hurd/fxstat64.c
+++ b/sysdeps/mach/hurd/fxstat64.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 2000 Free Software Foundation, Inc.
+/* Copyright (C) 2000,02 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
    The GNU C Library is free software; you can redistribute it and/or
@@ -19,22 +19,20 @@
 #include <errno.h>
 #include <stddef.h>
 #include <sys/stat.h>
-
-#include "xstatconv.c"
+#include <hurd.h>
+#include <hurd/fd.h>
 
 /* Get information about the file descriptor FD in BUF.  */
 int
 __fxstat64 (int vers, int fd, struct stat64 *buf)
 {
-  int result;
-  struct stat buf32;
+  error_t err;
+
+  if (vers != _STAT_VER)
+    return __hurd_fail (EINVAL);
 
-  /* XXX We simply call __fxstat and convert the result to `struct
-     stat64'.  We can probably get away with that since we don't
-     support large files on the Hurd yet.  */
-  result = __fxstat (vers, fd, &buf32);
-  if (result == 0)
-    xstat64_conv (&buf32, buf);
+  if (err = HURD_DPORT_USE (fd, __io_stat (port, buf)))
+    return __hurd_dfail (fd, err);
 
-  return result;
+  return 0;
 }
diff --git a/sysdeps/mach/hurd/getcwd.c b/sysdeps/mach/hurd/getcwd.c
index 9efcf1a5eb..136202a147 100644
--- a/sysdeps/mach/hurd/getcwd.c
+++ b/sysdeps/mach/hurd/getcwd.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1991, 92, 93, 94, 95, 96, 97, 98 Free Software Foundation, Inc.
+/* Copyright (C) 1991,92,93,94,95,96,97,98,2002 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
    The GNU C Library is free software; you can redistribute it and/or
@@ -44,7 +44,7 @@ _hurd_canonicalize_directory_name_internal (file_t thisdir,
 {
   error_t err;
   mach_port_t rootid, thisid, rootdevid, thisdevid;
-  ino_t rootino, thisino;
+  ino64_t rootino, thisino;
   char *file_name;
   register char *file_namep;
   file_t parent;
@@ -112,9 +112,9 @@ _hurd_canonicalize_directory_name_internal (file_t thisdir,
 	 THISID, THISDEV, and THISINO are its identity.
 	 Look in its parent (..) for a file with the same file number.  */
 
-      struct dirent *d;
+      struct dirent64 *d;
       mach_port_t dotid, dotdevid;
-      ino_t dotino;
+      ino64_t dotino;
       int mount_point;
       file_t newp;
       char *dirdata;
@@ -175,7 +175,7 @@ _hurd_canonicalize_directory_name_internal (file_t thisdir,
 	  offset = 0;
 	  while (offset < dirdatasize)
 	    {
-	      d = (struct dirent *) &dirdata[offset];
+	      d = (struct dirent64 *) &dirdata[offset];
 	      offset += d->d_reclen;
 
 	      /* Ignore `.' and `..'.  */
@@ -189,7 +189,7 @@ _hurd_canonicalize_directory_name_internal (file_t thisdir,
 		  file_t try = __file_name_lookup_under (parent, d->d_name,
 							 O_NOLINK, 0);
 		  file_t id, devid;
-		  ino_t fileno;
+		  ino64_t fileno;
 		  if (try == MACH_PORT_NULL)
 		    goto lose;
 		  err = __io_identity (try, &id, &devid, &fileno);
diff --git a/sysdeps/mach/hurd/lseek.c b/sysdeps/mach/hurd/lseek.c
index d82fc88c75..87cc69d9ef 100644
--- a/sysdeps/mach/hurd/lseek.c
+++ b/sysdeps/mach/hurd/lseek.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1991,92,93,94,95,97,2000 Free Software Foundation, Inc.
+/* Copyright (C) 1991,92,93,94,95,97,2000,02 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
    The GNU C Library is free software; you can redistribute it and/or
@@ -16,19 +16,14 @@
    Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
    02111-1307 USA.  */
 
-#include <errno.h>
 #include <unistd.h>
-#include <hurd.h>
-#include <hurd/fd.h>
+#include <sys/types.h>
 
 /* Seek to OFFSET on FD, starting from WHENCE.  */
 off_t
 __libc_lseek (int fd, off_t offset, int whence)
 {
-  error_t err;
-  if (err = HURD_DPORT_USE (fd, __io_seek (port, offset, whence, &offset)))
-    return __hurd_dfail (fd, err);
-  return offset;
+  return __libc_lseek64 (fd, (off64_t) offset, whence);
 }
 
 weak_alias (__libc_lseek, __lseek)
diff --git a/sysdeps/mach/hurd/lseek64.c b/sysdeps/mach/hurd/lseek64.c
index 051c8d40b9..0345d38f04 100644
--- a/sysdeps/mach/hurd/lseek64.c
+++ b/sysdeps/mach/hurd/lseek64.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 2000 Free Software Foundation, Inc.
+/* Copyright (C) 2000,02 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
    The GNU C Library is free software; you can redistribute it and/or
@@ -16,25 +16,18 @@
    Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
    02111-1307 USA.  */
 
-#include <errno.h>
 #include <unistd.h>
-#include <sys/types.h>
+#include <hurd.h>
+#include <hurd/fd.h>
 
 /* Seek to OFFSET on FD, starting from WHENCE.  */
 off64_t
 __libc_lseek64 (int fd, off64_t offset, int whence)
 {
-  /* XXX We don't really support large files on the Hurd.  So if
-     OFFSET doesn't fit in an `off_t', we'll return `-1' and set
-     errno.  EOVERFLOW probably isn't the right error value, but seems
-     appropriate here.  */
-  if ((off_t) offset != offset)
-    {
-      __set_errno (EOVERFLOW);
-      return -1;
-    }
-
-  return __libc_lseek (fd, offset, whence);
+  error_t err;
+  if (err = HURD_DPORT_USE (fd, __io_seek (port, offset, whence, &offset)))
+    return __hurd_dfail (fd, err);
+  return offset;
 }
 
 weak_alias (__libc_lseek64, __lseek64)
diff --git a/sysdeps/mach/hurd/lxstat.c b/sysdeps/mach/hurd/lxstat.c
index a928fae7d1..806b0eae34 100644
--- a/sysdeps/mach/hurd/lxstat.c
+++ b/sysdeps/mach/hurd/lxstat.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1992, 93, 94, 95, 96, 97 Free Software Foundation, Inc.
+/* Copyright (C) 1992,93,94,95,96,97,2002 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
    The GNU C Library is free software; you can redistribute it and/or
@@ -19,26 +19,13 @@
 #include <errno.h>
 #include <sys/stat.h>
 #include <stddef.h>
-#include <fcntl.h>
-#include <hurd.h>
+
+#include "xstatconv.c"
 
 int
 __lxstat (int vers, const char *file, struct stat *buf)
 {
-  error_t err;
-  file_t port;
-
-  if (vers != _STAT_VER)
-    return __hurd_fail (EINVAL);
-
-  port = __file_name_lookup (file, O_NOLINK, 0);
-  if (port == MACH_PORT_NULL)
-    return -1;
-  err = __io_stat (port, buf);
-  __mach_port_deallocate (__mach_task_self (), port);
-  if (err)
-    return __hurd_fail (err);
-  return 0;
+  struct stat64 buf64;
+  return __lxstat64 (vers, file, &buf64) ?: xstat64_conv (buf, &buf64);
 }
-
 weak_alias (__lxstat, _lxstat)
diff --git a/sysdeps/mach/hurd/lxstat64.c b/sysdeps/mach/hurd/lxstat64.c
index 0df4502e40..76de18e5e3 100644
--- a/sysdeps/mach/hurd/lxstat64.c
+++ b/sysdeps/mach/hurd/lxstat64.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 2000 Free Software Foundation, Inc.
+/* Copyright (C) 2000,02 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
    The GNU C Library is free software; you can redistribute it and/or
@@ -19,22 +19,25 @@
 #include <errno.h>
 #include <stddef.h>
 #include <sys/stat.h>
-
-#include "xstatconv.c"
+#include <fcntl.h>
+#include <hurd.h>
 
 /* Get information about the file descriptor FD in BUF.  */
 int
 __lxstat64 (int vers, const char *file, struct stat64 *buf)
 {
-  int result;
-  struct stat buf32;
-
-  /* XXX We simply call __lxstat and convert the result to `struct
-     stat64'.  We can probably get away with that since we don't
-     support large files on the Hurd yet.  */
-  result = __lxstat (vers, file, &buf32);
-  if (result == 0)
-    xstat64_conv (&buf32, buf);
-
-  return result;
+  error_t err;
+  file_t port;
+
+  if (vers != _STAT_VER)
+    return __hurd_fail (EINVAL);
+
+  port = __file_name_lookup (file, O_NOLINK, 0);
+  if (port == MACH_PORT_NULL)
+    return -1;
+  err = __io_stat (port, buf);
+  __mach_port_deallocate (__mach_task_self (), port);
+  if (err)
+    return __hurd_fail (err);
+  return 0;
 }
diff --git a/sysdeps/mach/hurd/pread.c b/sysdeps/mach/hurd/pread.c
index 81db77beef..a14553be7e 100644
--- a/sysdeps/mach/hurd/pread.c
+++ b/sysdeps/mach/hurd/pread.c
@@ -1,6 +1,6 @@
 /* Read block from given position in file without changing file pointer.
    Hurd version.
-   Copyright (C) 1999,2001 Free Software Foundation, Inc.
+   Copyright (C) 1999,2001,02 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
    The GNU C Library is free software; you can redistribute it and/or
@@ -20,17 +20,11 @@
 
 #include <errno.h>
 #include <unistd.h>
-#include <hurd/fd.h>
 
 ssize_t
 __libc_pread (int fd, void *buf, size_t nbytes, off_t offset)
 {
-  error_t err;
-  if (offset < 0)
-    err = EINVAL;
-  else
-    err = HURD_FD_USE (fd, _hurd_fd_read (descriptor, buf, &nbytes, offset));
-  return err ? __hurd_dfail (fd, err) : nbytes;
+  return __libc_pread64 (fd, buf, nbytes, (off64_t) offset);
 }
 
 #ifndef __libc_pread
diff --git a/sysdeps/mach/hurd/pread64.c b/sysdeps/mach/hurd/pread64.c
index 098b8970b7..fc69ae5056 100644
--- a/sysdeps/mach/hurd/pread64.c
+++ b/sysdeps/mach/hurd/pread64.c
@@ -1,6 +1,6 @@
 /* Read block from given position in file without changing file pointer.
    Hurd version.
-   Copyright (C) 2001 Free Software Foundation, Inc.
+   Copyright (C) 2001,02 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
    The GNU C Library is free software; you can redistribute it and/or
@@ -20,21 +20,17 @@
 
 #include <errno.h>
 #include <unistd.h>
+#include <hurd/fd.h>
 
 ssize_t
-__libc_pread64 (int fd, void *buf, size_t nbyte, off64_t offset)
+__libc_pread64 (int fd, void *buf, size_t nbytes, off64_t offset)
 {
-  /* XXX We don't really support large files on the Hurd.  So if
-     OFFSET doesn't fit in an `off_t', we'll return `-1' and set
-     errno.  EOVERFLOW probably isn't the right error value, but seems
-     appropriate here.  */
-  if ((off_t) offset != offset)
-    {
-      __set_errno (EOVERFLOW);
-      return -1;
-    }
-
-  return __libc_pread (fd, buf, nbyte, offset);
+  error_t err;
+  if (offset < 0)
+    err = EINVAL;
+  else
+    err = HURD_FD_USE (fd, _hurd_fd_read (descriptor, buf, &nbytes, offset));
+  return err ? __hurd_dfail (fd, err) : nbytes;
 }
 
 #ifndef __libc_pread64
diff --git a/sysdeps/mach/hurd/pwrite.c b/sysdeps/mach/hurd/pwrite.c
index 83288acce5..42236e4c3c 100644
--- a/sysdeps/mach/hurd/pwrite.c
+++ b/sysdeps/mach/hurd/pwrite.c
@@ -1,6 +1,6 @@
 /* Write block at given position in file without changing file pointer.
    Hurd version.
-   Copyright (C) 1999,2001 Free Software Foundation, Inc.
+   Copyright (C) 1999,2001,02 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
    The GNU C Library is free software; you can redistribute it and/or
@@ -20,19 +20,13 @@
 
 #include <errno.h>
 #include <unistd.h>
-#include <hurd/fd.h>
 
 /* Write NBYTES of BUF to FD at given position OFFSET without changing
    the file position.  Return the number written, or -1.  */
 ssize_t
 __libc_pwrite (int fd, const void *buf, size_t nbytes, off_t offset)
 {
-  error_t err;
-  if (offset < 0)
-    err = EINVAL;
-  else
-    err = HURD_FD_USE (fd, _hurd_fd_write (descriptor, buf, &nbytes, offset));
-  return err ? __hurd_dfail (fd, err) : nbytes;
+  return __libc_pwrite64 (fd, buf, nbytes, (off64_t) offset);
 }
 
 #ifndef __libc_pwrite
diff --git a/sysdeps/mach/hurd/pwrite64.c b/sysdeps/mach/hurd/pwrite64.c
index 9f15fb5a7c..9d27ae01e6 100644
--- a/sysdeps/mach/hurd/pwrite64.c
+++ b/sysdeps/mach/hurd/pwrite64.c
@@ -1,6 +1,6 @@
 /* Write block to given position in file without changing file pointer.
    Hurd version.
-   Copyright (C) 2001 Free Software Foundation, Inc.
+   Copyright (C) 2001,02 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
    The GNU C Library is free software; you can redistribute it and/or
@@ -20,21 +20,17 @@
 
 #include <errno.h>
 #include <unistd.h>
+#include <hurd/fd.h>
 
 ssize_t
-__libc_pwrite64 (int fd, const void *buf, size_t nbyte, off64_t offset)
+__libc_pwrite64 (int fd, const void *buf, size_t nbytes, off64_t offset)
 {
-  /* XXX We don't really support large files on the Hurd.  So if
-     OFFSET doesn't fit in an `off_t', we'll return `-1' and set
-     errno.  EOVERFLOW probably isn't the right error value, but seems
-     appropriate here.  */
-  if ((off_t) offset != offset)
-    {
-      __set_errno (EOVERFLOW);
-      return -1;
-    }
-
-  return __libc_pwrite (fd, buf, nbyte, offset);
+  error_t err;
+  if (offset < 0)
+    err = EINVAL;
+  else
+    err = HURD_FD_USE (fd, _hurd_fd_write (descriptor, buf, &nbytes, offset));
+  return err ? __hurd_dfail (fd, err) : nbytes;
 }
 
 #ifndef __libc_pwrite64
diff --git a/sysdeps/mach/hurd/readdir.c b/sysdeps/mach/hurd/readdir.c
index 6e986f3ebb..4bf19564d7 100644
--- a/sysdeps/mach/hurd/readdir.c
+++ b/sysdeps/mach/hurd/readdir.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1993, 1994, 1995, 1996, 1997 Free Software Foundation, Inc.
+/* Copyright (C) 1993,94,95,96,97,2002 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
    The GNU C Library is free software; you can redistribute it and/or
@@ -17,90 +17,51 @@
    02111-1307 USA.  */
 
 #include <errno.h>
-#include <limits.h>
 #include <stddef.h>
-#include <string.h>
 #include <dirent.h>
 #include <unistd.h>
-#include <sys/types.h>
-#include <hurd.h>
-#include <hurd/fd.h>
-#include "dirstream.h"
-
+#include <endian.h>
+#include <assert.h>
 
 /* Read a directory entry from DIRP.  */
 struct dirent *
 __readdir (DIR *dirp)
 {
-  struct dirent *dp;
-
-  if (dirp == NULL)
+  struct dirent64 *entry64 = __readdir64 (dirp);
+
+  if (sizeof (struct dirent64) == sizeof (struct dirent))
+    /* We should in fact just be an alias to readdir64 on this machine.  */
+    return (struct dirent *) entry64;
+
+  /* These are all compile-time constants.  We know that d_ino is the first
+     member and that the layout of the following members matches exactly in
+     both structures.  */
+  assert (offsetof (struct dirent, d_ino) == 0);
+  assert (offsetof (struct dirent64, d_ino) == 0);
+# define MATCH(memb)							      \
+  assert (offsetof (struct dirent64, memb) - sizeof (entry64->d_ino)	      \
+	  == offsetof (struct dirent, memb) - sizeof (ino_t))
+  MATCH (d_reclen);
+  MATCH (d_type);
+  MATCH (d_namlen);
+# undef MATCH
+
+  if (entry64 == NULL)
+    return NULL;
+
+  struct dirent *const entry = ((void *) (&entry64->d_ino + 1)
+				- sizeof entry->d_ino);
+  const ino_t d_ino = entry64->d_ino;
+  if (d_ino != entry64->d_ino)
     {
-      errno = EINVAL;
+      __set_errno (EOVERFLOW);
       return NULL;
     }
-
-  __libc_lock_lock (dirp->__lock);
-
-  do
-    {
-      if (dirp->__ptr - dirp->__data >= dirp->__size)
-	{
-	  /* We've emptied out our buffer.  Refill it.  */
-
-	  char *data = dirp->__data;
-	  int nentries;
-	  error_t err;
-
-	  if (err = HURD_FD_PORT_USE (dirp->__fd,
-				      __dir_readdir (port,
-						     &data, &dirp->__size,
-						     dirp->__entry_ptr,
-						     -1, 0, &nentries)))
-	    {
-	      __hurd_fail (err);
-	      dp = NULL;
-	      break;
-	    }
-
-	  /* DATA now corresponds to entry index DIRP->__entry_ptr.  */
-	  dirp->__entry_data = dirp->__entry_ptr;
-
-	  if (data != dirp->__data)
-	    {
-	      /* The data was passed out of line, so our old buffer is no
-		 longer useful.  Deallocate the old buffer and reset our
-		 information for the new buffer.  */
-	      __vm_deallocate (__mach_task_self (),
-			       (vm_address_t) dirp->__data,
-			       dirp->__allocation);
-	      dirp->__data = data;
-	      dirp->__allocation = round_page (dirp->__size);
-	    }
-
-	  /* Reset the pointer into the buffer.  */
-	  dirp->__ptr = dirp->__data;
-
-	  if (nentries == 0)
-	    {
-	      /* End of file.  */
-	      dp = NULL;
-	      break;
-	    }
-
-	  /* We trust the filesystem to return correct data and so we
-	     ignore NENTRIES.  */
-	}
-
-      dp = (struct dirent *) dirp->__ptr;
-      dirp->__ptr += dp->d_reclen;
-      ++dirp->__entry_ptr;
-
-      /* Loop to ignore deleted files.  */
-    } while (dp->d_fileno == 0);
-
-  __libc_lock_unlock (dirp->__lock);
-
-  return dp;
+# if BYTE_ORDER != BIG_ENDIAN	/* We just skipped over the zero high word.  */
+  entry->d_ino = d_ino;	/* ... or the nonzero low word, swap it.  */
+# endif
+  entry->d_reclen -= sizeof entry64->d_ino - sizeof entry->d_ino;
+  return entry;
 }
+
 weak_alias (__readdir, readdir)
diff --git a/sysdeps/mach/hurd/readdir64.c b/sysdeps/mach/hurd/readdir64.c
index 2d03ec381b..1953e81b31 100644
--- a/sysdeps/mach/hurd/readdir64.c
+++ b/sysdeps/mach/hurd/readdir64.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 2001 Free Software Foundation, Inc.
+/* Copyright (C) 2001,02 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
    The GNU C Library is free software; you can redistribute it and/or
@@ -17,25 +17,86 @@
    02111-1307 USA.  */
 
 #include <dirent.h>
-#include <limits.h>
 #include <stddef.h>
-#include <string.h>
+#include <hurd.h>
+#include <hurd/fs.h>
+#include <hurd/fd.h>
+#include "dirstream.h"
 
 /* Read a directory entry from DIRP.  */
 struct dirent64 *
 __readdir64 (DIR *dirp)
 {
-  struct dirent64 *result;
-  static union
-  {
-    struct dirent64 d;
-    char b[offsetof (struct dirent64, d_name) + UCHAR_MAX + 1];
-  } u;
-  int err;
+  struct dirent64 *dp;
 
-  err = __readdir64_r (dirp, &u.d, &result);
+  if (dirp == NULL)
+    {
+      errno = EINVAL;
+      return NULL;
+    }
 
-  return err ? NULL : result;
+  __libc_lock_lock (dirp->__lock);
+
+  do
+    {
+      if (dirp->__ptr - dirp->__data >= dirp->__size)
+	{
+	  /* We've emptied out our buffer.  Refill it.  */
+
+	  char *data = dirp->__data;
+	  int nentries;
+	  error_t err;
+
+	  if (err = HURD_FD_PORT_USE (dirp->__fd,
+				      __dir_readdir (port,
+						     &data, &dirp->__size,
+						     dirp->__entry_ptr,
+						     -1, 0, &nentries)))
+	    {
+	      __hurd_fail (err);
+	      dp = NULL;
+	      break;
+	    }
+
+	  /* DATA now corresponds to entry index DIRP->__entry_ptr.  */
+	  dirp->__entry_data = dirp->__entry_ptr;
+
+	  if (data != dirp->__data)
+	    {
+	      /* The data was passed out of line, so our old buffer is no
+		 longer useful.  Deallocate the old buffer and reset our
+		 information for the new buffer.  */
+	      __vm_deallocate (__mach_task_self (),
+			       (vm_address_t) dirp->__data,
+			       dirp->__allocation);
+	      dirp->__data = data;
+	      dirp->__allocation = round_page (dirp->__size);
+	    }
+
+	  /* Reset the pointer into the buffer.  */
+	  dirp->__ptr = dirp->__data;
+
+	  if (nentries == 0)
+	    {
+	      /* End of file.  */
+	      dp = NULL;
+	      break;
+	    }
+
+	  /* We trust the filesystem to return correct data and so we
+	     ignore NENTRIES.  */
+	}
+
+      dp = (struct dirent64 *) dirp->__ptr;
+      dirp->__ptr += dp->d_reclen;
+      ++dirp->__entry_ptr;
+
+      /* Loop to ignore deleted files.  */
+    } while (dp->d_fileno == 0);
+
+  __libc_lock_unlock (dirp->__lock);
+
+  return dp;
 }
 
 weak_alias (__readdir64, readdir64)
diff --git a/sysdeps/mach/hurd/readdir64_r.c b/sysdeps/mach/hurd/readdir64_r.c
index 7cb40bc0cc..c26b35bb70 100644
--- a/sysdeps/mach/hurd/readdir64_r.c
+++ b/sysdeps/mach/hurd/readdir64_r.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 2001 Free Software Foundation, Inc.
+/* Copyright (C) 2001,02 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
    The GNU C Library is free software; you can redistribute it and/or
@@ -17,36 +17,96 @@
    02111-1307 USA.  */
 
 #include <dirent.h>
-#include <limits.h>
 #include <stddef.h>
 #include <string.h>
+#include <hurd.h>
+#include <hurd/fs.h>
+#include <hurd/fd.h>
+#include "dirstream.h"
 
 /* Read a directory entry from DIRP.  */
 int
 __readdir64_r (DIR *dirp, struct dirent64 *entry, struct dirent64 **result)
 {
-  struct dirent *result32;
-  union
-  {
-    struct dirent d;
-    char b[offsetof (struct dirent, d_name) + UCHAR_MAX + 1];
-  } u;
-  int err;
-
-  err = __readdir_r (dirp, &u.d, &result32);
-  if (result32)
+  struct dirent64 *dp;
+  error_t err = 0;
+
+  if (dirp == NULL)
+    {
+      errno = EINVAL;
+      return errno;
+    }
+
+  __libc_lock_lock (dirp->__lock);
+
+  do
+    {
+      if (dirp->__ptr - dirp->__data >= dirp->__size)
+	{
+	  /* We've emptied out our buffer.  Refill it.  */
+
+	  char *data = dirp->__data;
+	  int nentries;
+
+	  if (err = HURD_FD_PORT_USE (dirp->__fd,
+				      __dir_readdir (port,
+						     &data, &dirp->__size,
+						     dirp->__entry_ptr,
+						     -1, 0, &nentries)))
+	    {
+	      __hurd_fail (err);
+	      dp = NULL;
+	      break;
+	    }
+
+	  /* DATA now corresponds to entry index DIRP->__entry_ptr.  */
+	  dirp->__entry_data = dirp->__entry_ptr;
+
+	  if (data != dirp->__data)
+	    {
+	      /* The data was passed out of line, so our old buffer is no
+		 longer useful.  Deallocate the old buffer and reset our
+		 information for the new buffer.  */
+	      __vm_deallocate (__mach_task_self (),
+			       (vm_address_t) dirp->__data,
+			       dirp->__allocation);
+	      dirp->__data = data;
+	      dirp->__allocation = round_page (dirp->__size);
+	    }
+
+	  /* Reset the pointer into the buffer.  */
+	  dirp->__ptr = dirp->__data;
+
+	  if (nentries == 0)
+	    {
+	      /* End of file.  */
+	      dp = NULL;
+	      break;
+	    }
+
+	  /* We trust the filesystem to return correct data and so we
+	     ignore NENTRIES.  */
+	}
+
+      dp = (struct dirent64 *) dirp->__ptr;
+      dirp->__ptr += dp->d_reclen;
+      ++dirp->__entry_ptr;
+
+      /* Loop to ignore deleted files.  */
+    } while (dp->d_fileno == 0);
+
+  if (dp)
     {
-      entry->d_fileno = result32->d_fileno;
-      entry->d_reclen = result32->d_reclen;
-      entry->d_type = result32->d_type;
-      entry->d_namlen = result32->d_namlen;
-      memcpy (entry->d_name, result32->d_name, result32->d_namlen + 1);
+      *entry = *dp;
+      memcpy (entry->d_name, dp->d_name, dp->d_namlen + 1);
       *result = entry;
     }
   else
     *result = NULL;
-      
-  return err;
+
+  __libc_lock_unlock (dirp->__lock);
+
+  return dp ? 0 : err ? errno : 0;
 }
 
 weak_alias(__readdir64_r, readdir64_r)
diff --git a/sysdeps/mach/hurd/readdir_r.c b/sysdeps/mach/hurd/readdir_r.c
index 1b7d76c461..b740721db6 100644
--- a/sysdeps/mach/hurd/readdir_r.c
+++ b/sysdeps/mach/hurd/readdir_r.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1993, 94, 95, 96, 1997, 2001 Free Software Foundation, Inc.
+/* Copyright (C) 1993,94,95,96,97,2001,02 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
    The GNU C Library is free software; you can redistribute it and/or
@@ -32,85 +32,34 @@
 int
 __readdir_r (DIR *dirp, struct dirent *entry, struct dirent **result)
 {
-  struct dirent *dp;
-  error_t err = 0;
-
-  if (dirp == NULL)
-    {
-      errno = EINVAL;
-      return errno;
-    }
-
-  __libc_lock_lock (dirp->__lock);
-
-  do
+  if (sizeof (struct dirent64) == sizeof (struct dirent))
+    /* We should in fact just be an alias to readdir64_r on this machine.  */
+    return __readdir64_r (dirp,
+			  (struct dirent64 *) entry,
+			  (struct dirent64 **) result);
+
+  struct dirent64 *result64;
+  union
+  {
+    struct dirent64 d;
+    char b[offsetof (struct dirent64, d_name) + UCHAR_MAX + 1];
+  } u;
+  int err;
+
+  err = __readdir64_r (dirp, &u.d, &result64);
+  if (result64)
     {
-      if (dirp->__ptr - dirp->__data >= dirp->__size)
-	{
-	  /* We've emptied out our buffer.  Refill it.  */
-
-	  char *data = dirp->__data;
-	  int nentries;
-
-	  if (err = HURD_FD_PORT_USE (dirp->__fd,
-				      __dir_readdir (port,
-						     &data, &dirp->__size,
-						     dirp->__entry_ptr,
-						     -1, 0, &nentries)))
-	    {
-	      __hurd_fail (err);
-	      dp = NULL;
-	      break;
-	    }
-
-	  /* DATA now corresponds to entry index DIRP->__entry_ptr.  */
-	  dirp->__entry_data = dirp->__entry_ptr;
-
-	  if (data != dirp->__data)
-	    {
-	      /* The data was passed out of line, so our old buffer is no
-		 longer useful.  Deallocate the old buffer and reset our
-		 information for the new buffer.  */
-	      __vm_deallocate (__mach_task_self (),
-			       (vm_address_t) dirp->__data,
-			       dirp->__allocation);
-	      dirp->__data = data;
-	      dirp->__allocation = round_page (dirp->__size);
-	    }
-
-	  /* Reset the pointer into the buffer.  */
-	  dirp->__ptr = dirp->__data;
-
-	  if (nentries == 0)
-	    {
-	      /* End of file.  */
-	      dp = NULL;
-	      break;
-	    }
-
-	  /* We trust the filesystem to return correct data and so we
-	     ignore NENTRIES.  */
-	}
-
-      dp = (struct dirent *) dirp->__ptr;
-      dirp->__ptr += dp->d_reclen;
-      ++dirp->__entry_ptr;
-
-      /* Loop to ignore deleted files.  */
-    } while (dp->d_fileno == 0);
-
-  if (dp)
-    {
-      *entry = *dp;
-      memcpy (entry->d_name, dp->d_name, dp->d_namlen + 1);
+      entry->d_fileno = result64->d_fileno;
+      entry->d_reclen = result64->d_reclen;
+      entry->d_type = result64->d_type;
+      entry->d_namlen = result64->d_namlen;
+      memcpy (entry->d_name, result64->d_name, result64->d_namlen + 1);
       *result = entry;
     }
   else
     *result = NULL;
 
-  __libc_lock_unlock (dirp->__lock);
-
-  return dp ? 0 : err ? errno : 0;
+  return err;
 }
 
 weak_alias (__readdir_r, readdir_r)
diff --git a/sysdeps/mach/hurd/readlink.c b/sysdeps/mach/hurd/readlink.c
index a952b2213d..f95b6c0b85 100644
--- a/sysdeps/mach/hurd/readlink.c
+++ b/sysdeps/mach/hurd/readlink.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1991, 92, 93, 94, 95, 97 Free Software Foundation, Inc.
+/* Copyright (C) 1991,92,93,94,95,97,2002 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
    The GNU C Library is free software; you can redistribute it and/or
@@ -33,7 +33,7 @@ __readlink (file_name, buf, len)
 {
   error_t err;
   file_t file;
-  struct stat st;
+  struct stat64 st;
 
   file = __file_name_lookup (file_name, O_READ | O_NOLINK, 0);
   if (file == MACH_PORT_NULL)
diff --git a/sysdeps/mach/hurd/statfs.c b/sysdeps/mach/hurd/statfs.c
index 9fc471e471..aa6b300373 100644
--- a/sysdeps/mach/hurd/statfs.c
+++ b/sysdeps/mach/hurd/statfs.c
@@ -1,5 +1,5 @@
 /* statfs -- Return information about the filesystem on which FILE resides.
-   Copyright (C) 1996, 1997 Free Software Foundation, Inc.
+   Copyright (C) 1996,97,2002 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
    The GNU C Library is free software; you can redistribute it and/or
@@ -17,25 +17,16 @@
    Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
    02111-1307 USA.  */
 
-#include <hurd.h>
 #include <sys/statfs.h>
-#include <stddef.h>
+
+#include "statfsconv.c"
 
 /* Return information about the filesystem on which FILE resides.  */
 int
 __statfs (const char *file, struct statfs *buf)
 {
-  error_t err;
-  file_t port;
-
-  port = __file_name_lookup (file, 0, 0);
-  if (port == MACH_PORT_NULL)
-    return -1;
-  err = __file_statfs (port, buf);
-  __mach_port_deallocate (__mach_task_self (), port);
-  if (err)
-    return __hurd_fail (err);
-  return 0;
+  struct statfs64 buf64;
+  return __statfs64 (file, &buf64) ?: statfs64_conv (buf, &buf64);
 }
 
 weak_alias (__statfs, statfs)
diff --git a/sysdeps/mach/hurd/statfs64.c b/sysdeps/mach/hurd/statfs64.c
index b46a5125c4..2d5b0363e7 100644
--- a/sysdeps/mach/hurd/statfs64.c
+++ b/sysdeps/mach/hurd/statfs64.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 2001 Free Software Foundation, Inc.
+/* Copyright (C) 2001,02 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
    The GNU C Library is free software; you can redistribute it and/or
@@ -17,24 +17,22 @@
    02111-1307 USA.  */
 
 #include <sys/statfs.h>
-
-#include "statfsconv.c"
+#include <hurd.h>
 
 /* Return information about the filesystem on which FILE resides.  */
 int
 __statfs64 (const char *file, struct statfs64 *buf)
 {
-  int result;
-  struct statfs buf32;
-
-  /* XXX We simply call __statfs and convert the result to `struct
-     statfs64'.  We can probably get away with that since we don't
-     support large files on the Hurd yet.  */
-  result = __statfs (file, &buf32);
-  if (result == 0)
-    statfs64_conv (&buf32, buf);
-
-  return result;
+  error_t err;
+  file_t port;
+
+  port = __file_name_lookup (file, 0, 0);
+  if (port == MACH_PORT_NULL)
+    return -1;
+  err = __file_statfs (port, buf);
+  __mach_port_deallocate (__mach_task_self (), port);
+  if (err)
+    return __hurd_fail (err);
+  return 0;
 }
-
 weak_alias (__statfs64, statfs64)
diff --git a/sysdeps/mach/hurd/statfsconv.c b/sysdeps/mach/hurd/statfsconv.c
index daea4dd060..57a06c450f 100644
--- a/sysdeps/mach/hurd/statfsconv.c
+++ b/sysdeps/mach/hurd/statfsconv.c
@@ -1,5 +1,5 @@
 /* Convert between `struct statfs' format, and `struct statfs64' format.
-   Copyright (C) 2001 Free Software Foundation, Inc.
+   Copyright (C) 2001,02 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
    The GNU C Library is free software; you can redistribute it and/or
@@ -17,23 +17,33 @@
    Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
    02111-1307 USA.  */
 
-#include <string.h>
-#include <sys/stat.h>
+#include <sys/statfs.h>
+#include <errno.h>
 
-static inline void
-statfs64_conv (struct statfs *buf, struct statfs64 *buf64)
+static inline int
+statfs64_conv (struct statfs *buf, const struct statfs64 *buf64)
 {
-  memset (buf64, 0, sizeof (struct statfs64));
-
-  buf64->f_type = buf->f_type;
-  buf64->f_bsize = buf->f_bsize;
-  buf64->f_blocks = buf->f_blocks;
-  buf64->f_bfree = buf->f_bfree;
-  buf64->f_bavail = buf->f_bavail;
-  buf64->f_files = buf->f_files;
-  buf64->f_fsid = buf->f_fsid;
-  buf64->f_namelen = buf->f_namelen;
-  buf64->f_favail = buf->f_favail;
-  buf64->f_frsize = buf->f_frsize;
-  buf64->f_flag = buf->f_flag;
+# define DO(memb)							      \
+  buf->memb = buf64->memb;						      \
+  if (sizeof buf->memb != sizeof buf64->memb && buf->memb != buf64->memb)     \
+    {									      \
+      __set_errno (EOVERFLOW);						      \
+      return -1;							      \
+    }
+
+  DO (f_type);
+  DO (f_bsize);
+  DO (f_blocks);
+  DO (f_bfree);
+  DO (f_bavail);
+  DO (f_files);
+  DO (f_fsid);
+  DO (f_namelen);
+  DO (f_favail);
+  DO (f_frsize);
+  DO (f_flag);
+
+# undef DO
+
+  return 0;
 }
diff --git a/sysdeps/mach/hurd/xstat.c b/sysdeps/mach/hurd/xstat.c
index 8fa89b3330..2ae9598d0a 100644
--- a/sysdeps/mach/hurd/xstat.c
+++ b/sysdeps/mach/hurd/xstat.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1992, 93, 94, 95, 96, 97 Free Software Foundation, Inc.
+/* Copyright (C) 1992,93,94,95,96,97,2002 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
    The GNU C Library is free software; you can redistribute it and/or
@@ -18,27 +18,14 @@
 
 #include <errno.h>
 #include <sys/stat.h>
-#include <stddef.h>
-#include <hurd.h>
+
+#include "xstatconv.c"
 
 /* Get file information about FILE in BUF.  */
 int
 __xstat (int vers, const char *file, struct stat *buf)
 {
-  error_t err;
-  file_t port;
-
-  if (vers != _STAT_VER)
-    return __hurd_fail (EINVAL);
-
-  port = __file_name_lookup (file, 0, 0);
-  if (port == MACH_PORT_NULL)
-    return -1;
-  err = __io_stat (port, buf);
-  __mach_port_deallocate (__mach_task_self (), port);
-  if (err)
-    return __hurd_fail (err);
-  return 0;
+  struct stat64 buf64;
+  return __xstat64 (vers, file, &buf64) ?: xstat64_conv (buf, &buf64);
 }
-
 weak_alias (__xstat, _xstat)
diff --git a/sysdeps/mach/hurd/xstat64.c b/sysdeps/mach/hurd/xstat64.c
index 74a7678bf1..ac1d43abdb 100644
--- a/sysdeps/mach/hurd/xstat64.c
+++ b/sysdeps/mach/hurd/xstat64.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 2000 Free Software Foundation, Inc.
+/* Copyright (C) 2000,02 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
    The GNU C Library is free software; you can redistribute it and/or
@@ -19,22 +19,24 @@
 #include <errno.h>
 #include <stddef.h>
 #include <sys/stat.h>
-
-#include "xstatconv.c"
+#include <hurd.h>
 
 /* Get information about the file descriptor FD in BUF.  */
 int
 __xstat64 (int vers, const char *file, struct stat64 *buf)
 {
-  int result;
-  struct stat buf32;
-
-  /* XXX We simply call __xstat and convert the result to `struct
-     stat64'.  We can probably get away with that since we don't
-     support large files on the Hurd yet.  */
-  result = __xstat (vers, file, &buf32);
-  if (result == 0)
-    xstat64_conv (&buf32, buf);
-
-  return result;
+  error_t err;
+  file_t port;
+
+  if (vers != _STAT_VER)
+    return __hurd_fail (EINVAL);
+
+  port = __file_name_lookup (file, 0, 0);
+  if (port == MACH_PORT_NULL)
+    return -1;
+  err = __io_stat (port, buf);
+  __mach_port_deallocate (__mach_task_self (), port);
+  if (err)
+    return __hurd_fail (err);
+  return 0;
 }
diff --git a/sysdeps/mach/hurd/xstatconv.c b/sysdeps/mach/hurd/xstatconv.c
index 3a5fbe73d1..e28643cd59 100644
--- a/sysdeps/mach/hurd/xstatconv.c
+++ b/sysdeps/mach/hurd/xstatconv.c
@@ -1,5 +1,5 @@
 /* Convert between `struct stat' format, and `struct stat64' format.
-   Copyright (C) 2000, 2001 Free Software Foundation, Inc.
+   Copyright (C) 2000,01,02 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
    The GNU C Library is free software; you can redistribute it and/or
@@ -17,32 +17,52 @@
    Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
    02111-1307 USA.  */
 
-#include <string.h>
+#include <errno.h>
 #include <sys/stat.h>
 
-static inline void
-xstat64_conv (struct stat *buf, struct stat64 *buf64)
+static inline int
+xstat64_conv (struct stat *buf, const struct stat64 *buf64)
 {
-  memset (buf64, 0, sizeof (struct stat64));
-
-  buf64->st_fstype = buf->st_fstype;
-  buf64->st_fsid = buf->st_fsid;
-  buf64->st_ino = buf->st_ino;
-  buf64->st_gen = buf->st_gen;
-  buf64->st_rdev = buf->st_rdev;
-  buf64->st_mode = buf->st_mode;
-  buf64->st_nlink = buf->st_nlink;
-  buf64->st_uid = buf->st_uid;
-  buf64->st_gid = buf->st_gid;
-  buf64->st_size = buf->st_size;
-  buf64->st_atime = buf->st_atime;
-  buf64->st_atime_usec = buf->st_atime_usec;
-  buf64->st_mtime = buf->st_mtime;
-  buf64->st_mtime_usec = buf->st_mtime_usec;
-  buf64->st_ctime = buf->st_ctime;
-  buf64->st_ctime_usec = buf->st_ctime_usec;
-  buf64->st_blksize = buf->st_blksize;
-  buf64->st_blocks = buf->st_blocks;
-  buf64->st_author = buf->st_author;
-  buf64->st_flags = buf->st_flags;
+  if (sizeof *buf == sizeof *buf64
+      && sizeof buf->st_ino == sizeof buf64->st_ino
+      && sizeof buf->st_size == sizeof buf64->st_size
+      && sizeof buf->st_blocks == sizeof buf64->st_blocks)
+    {
+      *buf = *(struct stat *) buf64;
+      return 0;
+    }
+
+  buf->st_fstype = buf64->st_fstype;
+  buf->st_fsid = buf64->st_fsid;
+  buf->st_ino = buf64->st_ino;
+  buf->st_gen = buf64->st_gen;
+  buf->st_rdev = buf64->st_rdev;
+  buf->st_mode = buf64->st_mode;
+  buf->st_nlink = buf64->st_nlink;
+  buf->st_uid = buf64->st_uid;
+  buf->st_gid = buf64->st_gid;
+  buf->st_size = buf64->st_size;
+  buf->st_atime = buf64->st_atime;
+  buf->st_atime_usec = buf64->st_atime_usec;
+  buf->st_mtime = buf64->st_mtime;
+  buf->st_mtime_usec = buf64->st_mtime_usec;
+  buf->st_ctime = buf64->st_ctime;
+  buf->st_ctime_usec = buf64->st_ctime_usec;
+  buf->st_blksize = buf64->st_blksize;
+  buf->st_blocks = buf64->st_blocks;
+  buf->st_author = buf64->st_author;
+  buf->st_flags = buf64->st_flags;
+
+  if ((sizeof buf->st_ino != sizeof buf64->st_ino
+       && buf->st_ino != buf64->st_ino)
+      || (sizeof buf->st_size != sizeof buf64->st_size
+	  && buf->st_size != buf64->st_size)
+      || (sizeof buf->st_blocks != sizeof buf64->st_blocks
+	  && buf->st_blocks != buf64->st_blocks))
+    {
+      __set_errno (EOVERFLOW);
+      return -1;
+    }
+
+  return 0;
 }