aboutsummaryrefslogtreecommitdiff
path: root/sysdeps
diff options
context:
space:
mode:
authorRoland McGrath <roland@gnu.org>2002-06-11 23:04:51 +0000
committerRoland McGrath <roland@gnu.org>2002-06-11 23:04:51 +0000
commit337738b77123cbfed07d53c9408eb74109856d0a (patch)
treeb5eba5547489c0efef99967e7f427f4ae4b4e727 /sysdeps
parent522c33f6bb802f6bf7840c78a5805b6929fd3ccd (diff)
downloadglibc-337738b77123cbfed07d53c9408eb74109856d0a.zip
glibc-337738b77123cbfed07d53c9408eb74109856d0a.tar.gz
glibc-337738b77123cbfed07d53c9408eb74109856d0a.tar.bz2
* sysdeps/mach/hurd/xstat64.c: Conditionalize entire contents of the
file on [!RTLD_STAT64]. * sysdeps/mach/hurd/fxstat64.c: Likewise. * sysdeps/mach/hurd/tmpfile.c (tmpfile64): Define as alias of tmpfile. (__fdopen): Use INTUSE. * sysdeps/mach/hurd/tmpfile64.c: New file, empty placeholder. * stdio-common/tmpfile64.c: File removed. * sysdeps/generic/tmpfile64.c: New file. * sysdeps/generic/tmpfile.c (GEN_THIS): New macro, define to __GT_FILE if not already defined. (tmpfile): Use it in place of __GT_FILE. * include/unistd.h: Declare __chown_internal. * sysdeps/mach/hurd/sendfile64.c (sendfile64): Do real work here. * sysdeps/mach/hurd/sendfile.c (sendfile): Call that. 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. 2002-06-08 Roland McGrath <roland@frob.com> * sysdeps/mach/hurd/dirstream.h (struct __dirstream): Use size_t instead of unsigned long int for __allocation and __size members. 2002-05-19 Ulrich Drepper <drepper@redhat.com>
Diffstat (limited to 'sysdeps')
-rw-r--r--sysdeps/generic/tmpfile.c6
-rw-r--r--sysdeps/generic/tmpfile64.c3
-rwxr-xr-xsysdeps/mach/hurd/configure38
-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.c26
-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.c22
-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/sendfile.c39
-rw-r--r--sysdeps/mach/hurd/sendfile64.c41
-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/tmpfile.c4
-rw-r--r--sysdeps/mach/hurd/tmpfile64.c1
-rw-r--r--sysdeps/mach/hurd/xstat.c23
-rw-r--r--sysdeps/mach/hurd/xstat64.c34
-rw-r--r--sysdeps/mach/hurd/xstatconv.c72
33 files changed, 525 insertions, 486 deletions
diff --git a/sysdeps/generic/tmpfile.c b/sysdeps/generic/tmpfile.c
index 9b60dbb..051cb79 100644
--- a/sysdeps/generic/tmpfile.c
+++ b/sysdeps/generic/tmpfile.c
@@ -26,6 +26,10 @@
# define tmpfile __new_tmpfile
#endif
+#ifndef GEN_THIS
+# define GEN_THIS __GT_FILE
+#endif
+
/* This returns a new stream opened on a temporary file (generated
by tmpnam). The file is opened with mode "w+b" (binary read/write).
If we couldn't generate a unique filename or the file couldn't
@@ -39,7 +43,7 @@ tmpfile (void)
if (__path_search (buf, FILENAME_MAX, NULL, "tmpf", 0))
return NULL;
- fd = __gen_tempname (buf, __GT_FILE);
+ fd = __gen_tempname (buf, GEN_THIS);
if (fd < 0)
return NULL;
diff --git a/sysdeps/generic/tmpfile64.c b/sysdeps/generic/tmpfile64.c
new file mode 100644
index 0000000..adce634
--- /dev/null
+++ b/sysdeps/generic/tmpfile64.c
@@ -0,0 +1,3 @@
+#define GEN_THIS __GT_BIGFILE
+#define tmpfile tmpfile64
+#include "tmpfile.c"
diff --git a/sysdeps/mach/hurd/configure b/sysdeps/mach/hurd/configure
index 7017ea4..56355b1 100755
--- a/sysdeps/mach/hurd/configure
+++ b/sysdeps/mach/hurd/configure
@@ -20,11 +20,45 @@ case "$machine" in
;;
esac
+echo $ac_n "checking Hurd header version""... $ac_c" 1>&6
+echo "configure:25: 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 30 "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:41: \"$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
+
# See if mig groks `retcode'.
echo $ac_n "checking whether $MIG supports the retcode keyword""... $ac_c" 1>&6
-echo "configure:28: checking whether $MIG supports the retcode keyword" >&5
+echo "configure:62: checking whether $MIG supports the retcode keyword" >&5
if eval "test \"`echo '$''{'hurd_cv_mig_retcode'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@@ -38,7 +72,7 @@ simpleroutine foobar_reply (
reply_port: reply_port_t;
err: kern_return_t, RetCode);
EOF
-if { ac_try='CC="${CC}" ${MIG-false} -n conftest.defs 1>&5'; { (eval echo configure:42: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; }; then
+if { ac_try='CC="${CC}" ${MIG-false} -n conftest.defs 1>&5'; { (eval echo configure:76: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; }; then
hurd_cv_mig_retcode=yes
else
hurd_cv_mig_retcode=no
diff --git a/sysdeps/mach/hurd/configure.in b/sysdeps/mach/hurd/configure.in
index f5afe2f..2945dc1 100644
--- a/sysdeps/mach/hurd/configure.in
+++ b/sysdeps/mach/hurd/configure.in
@@ -22,6 +22,19 @@ case "$machine" in
;;
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
+
dnl Swiped from hurd/aclocal.m4
AC_DEFUN([hurd_MIG_RETCODE], [dnl
# See if mig groks `retcode'.
diff --git a/sysdeps/mach/hurd/dl-sysdep.c b/sysdeps/mach/hurd/dl-sysdep.c
index 88e3c8b..4beb3b8 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,2002 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
@@ -280,7 +280,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! */
@@ -417,8 +417,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;
@@ -491,7 +491,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;
@@ -505,7 +505,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 eea8493..5949b49 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 e32be12..d87aa37 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 8a90c00..28cfbbb 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, 2002 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,8 +19,8 @@
#include <errno.h>
#include <stddef.h>
#include <sys/stat.h>
-#include <hurd.h>
-#include <hurd/fd.h>
+
+#include "xstatconv.c"
#undef __fxstat
@@ -28,15 +28,8 @@
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);
}
INTDEF(__fxstat)
diff --git a/sysdeps/mach/hurd/fxstat64.c b/sysdeps/mach/hurd/fxstat64.c
index a81e754..c0d4767 100644
--- a/sysdeps/mach/hurd/fxstat64.c
+++ b/sysdeps/mach/hurd/fxstat64.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 2000, 2002 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,11 +16,13 @@
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307 USA. */
+#ifndef RTLD_STAT64 /* dl-fxstat64.c, but we don't want it. */
+
#include <errno.h>
#include <stddef.h>
#include <sys/stat.h>
-
-#include "xstatconv.c"
+#include <hurd.h>
+#include <hurd/fd.h>
#undef __fxstat64
@@ -28,17 +30,17 @@
int
__fxstat64 (int vers, int fd, struct stat64 *buf)
{
- int result;
- struct stat buf32;
+ error_t err;
- /* 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 (vers != _STAT_VER)
+ return __hurd_fail (EINVAL);
- return result;
+ if (err = HURD_DPORT_USE (fd, __io_stat (port, buf)))
+ return __hurd_dfail (fd, err);
+
+ return 0;
}
INTDEF(__fxstat64)
+
+#endif
diff --git a/sysdeps/mach/hurd/getcwd.c b/sysdeps/mach/hurd/getcwd.c
index 9efcf1a..136202a 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 d82fc88..87cc69d 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 051c8d4..0345d38 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 3d6f981..9987e25 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, 2002 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,28 +19,16 @@
#include <errno.h>
#include <sys/stat.h>
#include <stddef.h>
-#include <fcntl.h>
-#include <hurd.h>
+
+#include "xstatconv.c"
#undef __lxstat
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);
}
INTDEF(__lxstat)
diff --git a/sysdeps/mach/hurd/lxstat64.c b/sysdeps/mach/hurd/lxstat64.c
index 57f67c0..6dabdb3 100644
--- a/sysdeps/mach/hurd/lxstat64.c
+++ b/sysdeps/mach/hurd/lxstat64.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 2000, 2002 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,8 +19,8 @@
#include <errno.h>
#include <stddef.h>
#include <sys/stat.h>
-
-#include "xstatconv.c"
+#include <fcntl.h>
+#include <hurd.h>
#undef __lxstat64
@@ -28,16 +28,19 @@
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;
}
INTDEF(__lxstat64)
diff --git a/sysdeps/mach/hurd/pread.c b/sysdeps/mach/hurd/pread.c
index 81db77b..a14553b 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 098b897..fc69ae5 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 83288ac..42236e4 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 9f15fb5..9d27ae0 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 6e986f3..4bf1956 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 2d03ec3..1953e81 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 7cb40bc..c26b35b 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 1b7d76c..b740721 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 a952b22..f95b6c0 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/sendfile.c b/sysdeps/mach/hurd/sendfile.c
index b1849d2..683365f 100644
--- a/sysdeps/mach/hurd/sendfile.c
+++ b/sysdeps/mach/hurd/sendfile.c
@@ -18,43 +18,20 @@
02111-1307 USA. */
#include <sys/sendfile.h>
-#include <hurd.h>
-#include <hurd/fd.h>
-#include <sys/mman.h>
+#include <stddef.h>
/* Send COUNT bytes from file associated with IN_FD starting at OFFSET to
descriptor OUT_FD. */
ssize_t
sendfile (int out_fd, int in_fd, off_t *offset, size_t count)
{
- /* We just do a vanilla io_read followed by a vanilla io_write here.
- In theory the IN_FD filesystem can return us out-of-line data that
- we then send out-of-line to the OUT_FD filesystem and no copying
- takes place until those pages need to be flushed or packaged by
- that filesystem (e.g. packetized by a network socket). However,
- we momentarily consume COUNT bytes of our local address space,
- which might blow if it's huge or address space is real tight. */
-
- char *data = 0;
- size_t datalen = 0;
- error_t err = HURD_DPORT_USE (in_fd,
- __io_read (port, &data, &datalen,
- offset ? *offset : (off_t) -1,
- count));
- if (err == 0)
+ if (offset == NULL || sizeof (off_t) == sizeof (off64_t))
+ return sendfile64 (out_fd, in_fd, (off64_t *) offset, count);
+ else
{
- size_t nwrote;
- if (datalen == 0)
- return 0;
- err = HURD_DPORT_USE (out_fd, __io_write (port, data, datalen,
- (off_t) -1, &nwrote));
- munmap (data, datalen);
- if (err == 0)
- {
- if (offset)
- *offset += datalen;
- return nwrote;
- }
+ off64_t ofs = *offset;
+ ssize_t ret = sendfile64 (out_fd, in_fd, &ofs, count);
+ *offset = ofs;
+ return ret;
}
- return __hurd_fail (err);
}
diff --git a/sysdeps/mach/hurd/sendfile64.c b/sysdeps/mach/hurd/sendfile64.c
index 40ce271..1f63d2a 100644
--- a/sysdeps/mach/hurd/sendfile64.c
+++ b/sysdeps/mach/hurd/sendfile64.c
@@ -18,26 +18,43 @@
02111-1307 USA. */
#include <sys/sendfile.h>
-#include <errno.h>
-#include <stddef.h>
+#include <hurd.h>
+#include <hurd/fd.h>
+#include <sys/mman.h>
/* Send COUNT bytes from file associated with IN_FD starting at OFFSET to
descriptor OUT_FD. */
ssize_t
sendfile64 (int out_fd, int in_fd, off64_t *offset, size_t count)
{
- if (offset == NULL)
- return sendfile (out_fd, in_fd, NULL, count);
- else
+ /* We just do a vanilla io_read followed by a vanilla io_write here.
+ In theory the IN_FD filesystem can return us out-of-line data that
+ we then send out-of-line to the OUT_FD filesystem and no copying
+ takes place until those pages need to be flushed or packaged by
+ that filesystem (e.g. packetized by a network socket). However,
+ we momentarily consume COUNT bytes of our local address space,
+ which might blow if it's huge or address space is real tight. */
+
+ char *data = 0;
+ size_t datalen = 0;
+ error_t err = HURD_DPORT_USE (in_fd,
+ __io_read (port, &data, &datalen,
+ offset ? *offset : (off_t) -1,
+ count));
+ if (err == 0)
{
- off_t ofs = *offset;
- if (ofs != *offset)
+ size_t nwrote;
+ if (datalen == 0)
+ return 0;
+ err = HURD_DPORT_USE (out_fd, __io_write (port, data, datalen,
+ (off_t) -1, &nwrote));
+ munmap (data, datalen);
+ if (err == 0)
{
- __set_errno (EOVERFLOW);
- return -1;
+ if (offset)
+ *offset += datalen;
+ return nwrote;
}
- ssize_t ret = sendfile (out_fd, in_fd, &ofs, count);
- *offset = ofs;
- return ret;
}
+ return __hurd_fail (err);
}
diff --git a/sysdeps/mach/hurd/statfs.c b/sysdeps/mach/hurd/statfs.c
index 9fc471e..aa6b300 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 b46a512..2d5b036 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 daea4dd..57a06c4 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/tmpfile.c b/sysdeps/mach/hurd/tmpfile.c
index e738dc9..8ac80e2 100644
--- a/sysdeps/mach/hurd/tmpfile.c
+++ b/sysdeps/mach/hurd/tmpfile.c
@@ -26,7 +26,7 @@
#ifdef USE_IN_LIBIO
# include <iolibio.h>
-# define __fdopen _IO_fdopen
+# define __fdopen INTUSE(_IO_fdopen)
# define tmpfile __new_tmpfile
#endif
@@ -73,3 +73,5 @@ tmpfile (void)
# include <shlib-compat.h>
versioned_symbol (libc, __new_tmpfile, tmpfile, GLIBC_2_1);
#endif
+
+weak_alias (tmpfile, tmpfile64)
diff --git a/sysdeps/mach/hurd/tmpfile64.c b/sysdeps/mach/hurd/tmpfile64.c
new file mode 100644
index 0000000..094304a
--- /dev/null
+++ b/sysdeps/mach/hurd/tmpfile64.c
@@ -0,0 +1 @@
+/* tmpfile64 is an alias for tmpfile, defined in tmpfile.c. */
diff --git a/sysdeps/mach/hurd/xstat.c b/sysdeps/mach/hurd/xstat.c
index 8fa89b3..2ae9598 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 74a7678..3ca3400 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
@@ -16,25 +16,31 @@
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307 USA. */
+#ifndef RTLD_STAT64 /* dl-xstat64.c, but we don't want it. */
+
#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;
}
+
+#endif
diff --git a/sysdeps/mach/hurd/xstatconv.c b/sysdeps/mach/hurd/xstatconv.c
index 3a5fbe7..e28643c 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;
}