summary refs log tree commit diff
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>2000-04-14 07:51:02 +0000
committerUlrich Drepper <drepper@redhat.com>2000-04-14 07:51:02 +0000
commitbb8e0116cd59b11053154fb4adbad9f06a344147 (patch)
tree97c55ce5db305776761fb56145f0f3d59cc2afa6
parent8f6f7a31c9aea07b4f364fe1ba33fa099169a007 (diff)
downloadglibc-bb8e0116cd59b11053154fb4adbad9f06a344147.tar.gz
glibc-bb8e0116cd59b11053154fb4adbad9f06a344147.tar.xz
glibc-bb8e0116cd59b11053154fb4adbad9f06a344147.zip
update.
2000-04-14  Ulrich Drepper  <drepper@redhat.com>

	* include/sys/statfs.h: Add prototypes for __statfs64 and __fstatfs64.
	* sysdeps/generic/fstatfs64.c (__fstatfs64): Renamed to fstatfs64.
	Make old name weak alias.
	* sysdeps/unix/sysv/linux/fstatfs64.c: Likewise.
	* sysdeps/generic/statfs64.c (__statfs64): Renamed to statfs64.
	Make old name weak alias.
	* sysdeps/unix/sysv/linux/statfs64.c: Likewise.

	* io/Makefile (routines): Add posix_fadvise, posix_fadvise64,
	posix_fallocate, and posix_fallocate64.
	* io/Versions [libc] (GLIBC_2.2): Add posix_fadvise, posix_fadvise64,
	posix_fallocate, and posix_fallocate64.
	* io/fcntl.h: Declare posix_fadvise, posix_fadvise64,
	posix_fallocate, and posix_fallocate64.
	* sysdeps/generic/fadvise.c: New file.
	* sysdeps/generic/fadvise64.c: New file.
	* sysdeps/generic/fallocate.c: New file.
	* sysdeps/generic/fallocate64.c: New file.
	* sysdeps/posix/fallocate.c: New file.
	* sysdeps/posix/fallocate64.c: New file.
	* sysdeps/generic/bits/fcntl.h: Define POSIX_FADV_NORMAL,
	POSIX_FADV_RANDOM, POSIX_FADV_SEQUENTIAL, POSIX_FADV_WILLNEED,
	POSIX_FADV_DONTNEED, and POSIX_FADV_NOREUSE.
	* sysdeps/mach/hurd/bits/fcntl.h: Likewise.
	* sysdeps/unix/sysv/linux/alpha/bits/fcntl.h: Likewise.
	* sysdeps/unix/sysv/linux/bits/fcntl.h: Likewise.
	* sysdeps/unix/sysv/linux/i386/bits/fcntl.h: Likewise.
	* sysdeps/unix/sysv/linux/mips/bits/fcntl.h: Likewise.
	* sysdeps/unix/sysv/linux/sparc/bits/fcntl.h: Likewise.

	* sysdeps/generic/madvise.c (__madvise): Renamed to posix_madvise.
	* sysdeps/unix/sysv/linux/syscalls.list: Likewise.
-rw-r--r--ChangeLog35
-rw-r--r--bits/fcntl.h12
-rw-r--r--include/sys/statfs.h2
-rw-r--r--io/Makefile6
-rw-r--r--io/Versions4
-rw-r--r--io/fcntl.h41
-rw-r--r--sysdeps/generic/bits/fcntl.h12
-rw-r--r--sysdeps/generic/fstatfs64.c5
-rw-r--r--sysdeps/generic/madvise.c5
-rw-r--r--sysdeps/generic/posix_fadvise.c32
-rw-r--r--sysdeps/generic/posix_fadvise64.c32
-rw-r--r--sysdeps/generic/posix_fallocate.c31
-rw-r--r--sysdeps/generic/posix_fallocate64.c31
-rw-r--r--sysdeps/generic/statfs64.c5
-rw-r--r--sysdeps/mach/hurd/bits/fcntl.h12
-rw-r--r--sysdeps/posix/posix_fallocate.c71
-rw-r--r--sysdeps/posix/posix_fallocate64.c71
-rw-r--r--sysdeps/unix/sysv/linux/alpha/bits/fcntl.h16
-rw-r--r--sysdeps/unix/sysv/linux/bits/fcntl.h12
-rw-r--r--sysdeps/unix/sysv/linux/fstatfs64.c5
-rw-r--r--sysdeps/unix/sysv/linux/i386/bits/fcntl.h12
-rw-r--r--sysdeps/unix/sysv/linux/mips/bits/fcntl.h12
-rw-r--r--sysdeps/unix/sysv/linux/sparc/bits/fcntl.h13
-rw-r--r--sysdeps/unix/sysv/linux/statfs64.c5
-rw-r--r--sysdeps/unix/sysv/linux/syscalls.list2
25 files changed, 458 insertions, 26 deletions
diff --git a/ChangeLog b/ChangeLog
index 9ffbe6305a..cdcf29f3b4 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,38 @@
+2000-04-14  Ulrich Drepper  <drepper@redhat.com>
+
+	* include/sys/statfs.h: Add prototypes for __statfs64 and __fstatfs64.
+	* sysdeps/generic/fstatfs64.c (__fstatfs64): Renamed to fstatfs64.
+	Make old name weak alias.
+	* sysdeps/unix/sysv/linux/fstatfs64.c: Likewise.
+	* sysdeps/generic/statfs64.c (__statfs64): Renamed to statfs64.
+	Make old name weak alias.
+	* sysdeps/unix/sysv/linux/statfs64.c: Likewise.
+
+	* io/Makefile (routines): Add posix_fadvise, posix_fadvise64,
+	posix_fallocate, and posix_fallocate64.
+	* io/Versions [libc] (GLIBC_2.2): Add posix_fadvise, posix_fadvise64,
+	posix_fallocate, and posix_fallocate64.
+	* io/fcntl.h: Declare posix_fadvise, posix_fadvise64,
+	posix_fallocate, and posix_fallocate64.
+	* sysdeps/generic/fadvise.c: New file.
+	* sysdeps/generic/fadvise64.c: New file.
+	* sysdeps/generic/fallocate.c: New file.
+	* sysdeps/generic/fallocate64.c: New file.
+	* sysdeps/posix/fallocate.c: New file.
+	* sysdeps/posix/fallocate64.c: New file.
+	* sysdeps/generic/bits/fcntl.h: Define POSIX_FADV_NORMAL,
+	POSIX_FADV_RANDOM, POSIX_FADV_SEQUENTIAL, POSIX_FADV_WILLNEED,
+	POSIX_FADV_DONTNEED, and POSIX_FADV_NOREUSE.
+	* sysdeps/mach/hurd/bits/fcntl.h: Likewise.
+	* sysdeps/unix/sysv/linux/alpha/bits/fcntl.h: Likewise.
+	* sysdeps/unix/sysv/linux/bits/fcntl.h: Likewise.
+	* sysdeps/unix/sysv/linux/i386/bits/fcntl.h: Likewise.
+	* sysdeps/unix/sysv/linux/mips/bits/fcntl.h: Likewise.
+	* sysdeps/unix/sysv/linux/sparc/bits/fcntl.h: Likewise.
+
+	* sysdeps/generic/madvise.c (__madvise): Renamed to posix_madvise.
+	* sysdeps/unix/sysv/linux/syscalls.list: Likewise.
+
 2000-04-13  Ulrich Drepper  <drepper@redhat.com>
 
 	* misc/Versions [libc] (GLIBC_2.2): Add posix_madvice.
diff --git a/bits/fcntl.h b/bits/fcntl.h
index 24a1c38be6..2984100eff 100644
--- a/bits/fcntl.h
+++ b/bits/fcntl.h
@@ -1,5 +1,5 @@
 /* O_*, F_*, FD_* bit values for stub configuration.
-   Copyright (C) 1991, 1992, 1997 Free Software Foundation, Inc.
+   Copyright (C) 1991, 1992, 1997, 2000 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
@@ -83,3 +83,13 @@ struct flock
 #define	F_RDLCK	1	/* Read lock.  */
 #define	F_WRLCK	2	/* Write lock.  */
 #define	F_UNLCK	3	/* Remove lock.  */
+
+/* Advise to `posix_fadvise'.  */
+#ifdef __USE_XOPEN2K
+# define POSIX_FADV_NORMAL	0 /* No further special treatment.  */
+# define POSIX_FADV_RANDOM	1 /* Expect random page references.  */
+# define POSIX_FADV_SEQUENTIAL	2 /* Expect sequential page references.  */
+# define POSIX_FADV_WILLNEED	3 /* Will need these pages.  */
+# define POSIX_FADV_DONTNEED	4 /* Don't need these pages.  */
+# define POSIX_FADV_NOREUSE	5 /* Data will be accessed once.  */
+#endif
diff --git a/include/sys/statfs.h b/include/sys/statfs.h
index d6a5bcfe38..1df3d8c270 100644
--- a/include/sys/statfs.h
+++ b/include/sys/statfs.h
@@ -4,4 +4,6 @@
 /* Now define the internal interfaces.  */
 extern int __statfs (__const char *__file, struct statfs *__buf);
 extern int __fstatfs (int __fildes, struct statfs *__buf);
+extern int __statfs64 (__const char *__file, struct statfs64 *__buf);
+extern int __fstatfs64 (int __fildes, struct statfs64 *__buf);
 #endif
diff --git a/io/Makefile b/io/Makefile
index 9dccdb96df..5d7c4c864e 100644
--- a/io/Makefile
+++ b/io/Makefile
@@ -1,4 +1,4 @@
-# Copyright (C) 1992, 93, 94, 95, 96, 97, 98, 99 Free Software Foundation, Inc.
+# Copyright (C) 1992-1999, 2000 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,9 @@ routines :=							      \
 	ttyname ttyname_r isatty				      \
 	link symlink readlink					      \
 	unlink rmdir						      \
-	ftw ftw64 fts poll
+	ftw ftw64 fts poll					      \
+	posix_fadvise posix_fadvise64				      \
+	posix_fallocate posix_fallocate64
 
 # These routines will be omitted from the libc shared object.
 # Instead the static object files will be included in a special archive
diff --git a/io/Versions b/io/Versions
index 3cfe41511a..10df42253a 100644
--- a/io/Versions
+++ b/io/Versions
@@ -91,4 +91,8 @@ libc {
     # For the cancelation wrappers.
     __libc_open64; __libc_lseek64;
   }
+  GLIBC_2.2 {
+    # p*
+    posix_fadvise; posix_fadvise64; posix_fallocate; posix_fallocate64;
+  }
 }
diff --git a/io/fcntl.h b/io/fcntl.h
index 8706a44dc8..7ab542642c 100644
--- a/io/fcntl.h
+++ b/io/fcntl.h
@@ -1,4 +1,4 @@
-/* Copyright (C) 1991,92,94,95,96,97,98,99 Free Software Foundation, Inc.
+/* Copyright (C) 1991,92,94,95,96,97,98,99, 2000 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
@@ -125,6 +125,45 @@ extern int lockf64 (int __fd, int __cmd, __off64_t __len) __THROW;
 # endif
 #endif
 
+#ifdef __USE_XOPEN2K
+/* Advice the system about the expected behaviour of the application with
+   respect to the file associated with FD.  */
+# ifndef __USE_FILE_OFFSET64
+extern int posix_fadvise (int __fd, __off_t __offset, size_t __len,
+			  int __advise) __THROW;
+# else
+# ifdef __REDIRECT
+extern int __REDIRECT (posix_fadvise, (int __fd, __off64_t __offset,
+				       size_t __len, int __advise) __THROW,
+		       posix_fadvise64);
+# else
+#  define posix_fadvise posix_fadvise64
+# endif
+# endif
+# ifdef __USE_LARGEFILE64
+extern int posix_fadvise64 (int __fd, __off64_t __offset, size_t __len,
+			    int __advise) __THROW;
+# endif
+
+
+/* Reserve storage for the data of the file associated with FD.  */
+# ifndef __USE_FILE_OFFSET64
+extern int posix_fallocate (int __fd, __off_t __offset, size_t __len) __THROW;
+# else
+# ifdef __REDIRECT
+extern int __REDIRECT (posix_fallocate, (int __fd, __off64_t __offset,
+					 size_t __len) __THROW,
+		       posix_fallocate64);
+# else
+#  define posix_fallocate posix_fallocate64
+# endif
+# endif
+# ifdef __USE_LARGEFILE64
+extern int posix_fallocate64 (int __fd, __off64_t __offset, size_t __len)
+     __THROW;
+# endif
+#endif
+
 __END_DECLS
 
 #endif /* fcntl.h  */
diff --git a/sysdeps/generic/bits/fcntl.h b/sysdeps/generic/bits/fcntl.h
index 24a1c38be6..2984100eff 100644
--- a/sysdeps/generic/bits/fcntl.h
+++ b/sysdeps/generic/bits/fcntl.h
@@ -1,5 +1,5 @@
 /* O_*, F_*, FD_* bit values for stub configuration.
-   Copyright (C) 1991, 1992, 1997 Free Software Foundation, Inc.
+   Copyright (C) 1991, 1992, 1997, 2000 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
@@ -83,3 +83,13 @@ struct flock
 #define	F_RDLCK	1	/* Read lock.  */
 #define	F_WRLCK	2	/* Write lock.  */
 #define	F_UNLCK	3	/* Remove lock.  */
+
+/* Advise to `posix_fadvise'.  */
+#ifdef __USE_XOPEN2K
+# define POSIX_FADV_NORMAL	0 /* No further special treatment.  */
+# define POSIX_FADV_RANDOM	1 /* Expect random page references.  */
+# define POSIX_FADV_SEQUENTIAL	2 /* Expect sequential page references.  */
+# define POSIX_FADV_WILLNEED	3 /* Will need these pages.  */
+# define POSIX_FADV_DONTNEED	4 /* Don't need these pages.  */
+# define POSIX_FADV_NOREUSE	5 /* Data will be accessed once.  */
+#endif
diff --git a/sysdeps/generic/fstatfs64.c b/sysdeps/generic/fstatfs64.c
index cefaa75677..583ecfc62a 100644
--- a/sysdeps/generic/fstatfs64.c
+++ b/sysdeps/generic/fstatfs64.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1998 Free Software Foundation, Inc.
+/* Copyright (C) 1998, 2000 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
@@ -21,11 +21,12 @@
 
 /* Return information about the filesystem on which FD resides.  */
 int
-fstatfs64 (int fd, struct statfs64 *buf)
+__fstatfs64 (int fd, struct statfs64 *buf)
 {
   __set_errno (ENOSYS);
   return -1;
 }
+weak_alias (__fstatfs64, fstatfs64)
 
 stub_warning (fstatfs64)
 #include <stub-tag.h>
diff --git a/sysdeps/generic/madvise.c b/sysdeps/generic/madvise.c
index d6c2322d25..d7379b15cb 100644
--- a/sysdeps/generic/madvise.c
+++ b/sysdeps/generic/madvise.c
@@ -24,12 +24,11 @@
    for the region starting at ADDR and extending LEN bytes.  */
 
 int
-__madvise (__ptr_t addr, size_t len, int advice)
+posix_madvise (__ptr_t addr, size_t len, int advice)
 {
   __set_errno (ENOSYS);
   return -1;
 }
-weak_alias (__madvice, madvice)
-weak_alias (__madvice, posix_madvise)
+weak_alias (posix_madvice, madvice)
 stub_warning (madvise)
 #include <stub-tag.h>
diff --git a/sysdeps/generic/posix_fadvise.c b/sysdeps/generic/posix_fadvise.c
new file mode 100644
index 0000000000..a2bd1d91ee
--- /dev/null
+++ b/sysdeps/generic/posix_fadvise.c
@@ -0,0 +1,32 @@
+/* Copyright (C) 2000 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
+   modify it under the terms of the GNU Library General Public License as
+   published by the Free Software Foundation; either version 2 of the
+   License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Library General Public License for more details.
+
+   You should have received a copy of the GNU Library General Public
+   License along with the GNU C Library; see the file COPYING.LIB.  If not,
+   write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+   Boston, MA 02111-1307, USA.  */
+
+#include <errno.h>
+#include <fcntl.h>
+
+/* Advice the system about the expected behaviour of the application with
+   respect to the file associated with FD.  */
+
+int
+posix_fadvise (int fd, __off_t offset, size_t len, int advise)
+{
+  __set_errno (ENOSYS);
+  return -1;
+}
+stub_warning (posix_fadvise)
+#include <stub-tag.h>
diff --git a/sysdeps/generic/posix_fadvise64.c b/sysdeps/generic/posix_fadvise64.c
new file mode 100644
index 0000000000..15cb60e00c
--- /dev/null
+++ b/sysdeps/generic/posix_fadvise64.c
@@ -0,0 +1,32 @@
+/* Copyright (C) 2000 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
+   modify it under the terms of the GNU Library General Public License as
+   published by the Free Software Foundation; either version 2 of the
+   License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Library General Public License for more details.
+
+   You should have received a copy of the GNU Library General Public
+   License along with the GNU C Library; see the file COPYING.LIB.  If not,
+   write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+   Boston, MA 02111-1307, USA.  */
+
+#include <errno.h>
+#include <fcntl.h>
+
+/* Advice the system about the expected behaviour of the application with
+   respect to the file associated with FD.  */
+
+int
+posix_fadvise64 (int fd, __off64_t offset, size_t len, int advise)
+{
+  __set_errno (ENOSYS);
+  return -1;
+}
+stub_warning (posix_fadvise64)
+#include <stub-tag.h>
diff --git a/sysdeps/generic/posix_fallocate.c b/sysdeps/generic/posix_fallocate.c
new file mode 100644
index 0000000000..59c17e40d2
--- /dev/null
+++ b/sysdeps/generic/posix_fallocate.c
@@ -0,0 +1,31 @@
+/* Copyright (C) 2000 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
+   modify it under the terms of the GNU Library General Public License as
+   published by the Free Software Foundation; either version 2 of the
+   License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Library General Public License for more details.
+
+   You should have received a copy of the GNU Library General Public
+   License along with the GNU C Library; see the file COPYING.LIB.  If not,
+   write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+   Boston, MA 02111-1307, USA.  */
+
+#include <errno.h>
+#include <fcntl.h>
+
+/* Reserve storage for the data of the file associated with FD.  */
+
+int
+posix_fallocate (int fd, __off_t offset, size_t len)
+{
+  __set_errno (ENOSYS);
+  return -1;
+}
+stub_warning (posix_fallocate)
+#include <stub-tag.h>
diff --git a/sysdeps/generic/posix_fallocate64.c b/sysdeps/generic/posix_fallocate64.c
new file mode 100644
index 0000000000..efb7be5ad4
--- /dev/null
+++ b/sysdeps/generic/posix_fallocate64.c
@@ -0,0 +1,31 @@
+/* Copyright (C) 2000 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
+   modify it under the terms of the GNU Library General Public License as
+   published by the Free Software Foundation; either version 2 of the
+   License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Library General Public License for more details.
+
+   You should have received a copy of the GNU Library General Public
+   License along with the GNU C Library; see the file COPYING.LIB.  If not,
+   write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+   Boston, MA 02111-1307, USA.  */
+
+#include <errno.h>
+#include <fcntl.h>
+
+/* Reserve storage for the data of the file associated with FD.  */
+
+int
+posix_fallocate64 (int fd, __off64_t offset, size_t len)
+{
+  __set_errno (ENOSYS);
+  return -1;
+}
+stub_warning (posix_fallocate64)
+#include <stub-tag.h>
diff --git a/sysdeps/generic/statfs64.c b/sysdeps/generic/statfs64.c
index 6b4baff292..8d53d419a2 100644
--- a/sysdeps/generic/statfs64.c
+++ b/sysdeps/generic/statfs64.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1998 Free Software Foundation, Inc.
+/* Copyright (C) 1998, 2000 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
@@ -21,11 +21,12 @@
 
 /* Return information about the filesystem on which FILE resides.  */
 int
-statfs64 (const char *file, struct statfs64 *buf)
+__statfs64 (const char *file, struct statfs64 *buf)
 {
   __set_errno (ENOSYS);
   return -1;
 }
+weak_alias (__statfs64, statfs64)
 
 stub_warning (statfs64)
 #include <stub-tag.h>
diff --git a/sysdeps/mach/hurd/bits/fcntl.h b/sysdeps/mach/hurd/bits/fcntl.h
index 9195d8c52a..b5696eb716 100644
--- a/sysdeps/mach/hurd/bits/fcntl.h
+++ b/sysdeps/mach/hurd/bits/fcntl.h
@@ -1,5 +1,5 @@
 /* O_*, F_*, FD_* bit values for GNU.
-   Copyright (C) 1993,94,96,97,98,99 Free Software Foundation, Inc.
+   Copyright (C) 1993,94,96,97,98,99, 2000 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
@@ -193,3 +193,13 @@ struct flock64
 #define	F_RDLCK	1	/* Read lock.  */
 #define	F_WRLCK	2	/* Write lock.  */
 #define	F_UNLCK	3	/* Remove lock.  */
+
+/* Advise to `posix_fadvise'.  */
+#ifdef __USE_XOPEN2K
+# define POSIX_FADV_NORMAL	0 /* No further special treatment.  */
+# define POSIX_FADV_RANDOM	1 /* Expect random page references.  */
+# define POSIX_FADV_SEQUENTIAL	2 /* Expect sequential page references.  */
+# define POSIX_FADV_WILLNEED	3 /* Will need these pages.  */
+# define POSIX_FADV_DONTNEED	4 /* Don't need these pages.  */
+# define POSIX_FADV_NOREUSE	5 /* Data will be accessed once.  */
+#endif
diff --git a/sysdeps/posix/posix_fallocate.c b/sysdeps/posix/posix_fallocate.c
new file mode 100644
index 0000000000..cd0f96113e
--- /dev/null
+++ b/sysdeps/posix/posix_fallocate.c
@@ -0,0 +1,71 @@
+/* Copyright (C) 2000 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
+   modify it under the terms of the GNU Library General Public License as
+   published by the Free Software Foundation; either version 2 of the
+   License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Library General Public License for more details.
+
+   You should have received a copy of the GNU Library General Public
+   License along with the GNU C Library; see the file COPYING.LIB.  If not,
+   write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+   Boston, MA 02111-1307, USA.  */
+
+#include <errno.h>
+#include <fcntl.h>
+#include <unistd.h>
+#include <sys/stat.h>
+#include <sys/statfs.h>
+
+/* Reserve storage for the data of the file associated with FD.  */
+
+int
+posix_fallocate (int fd, __off_t offset, size_t len)
+{
+  struct stat st;
+  struct statfs f;
+  size_t step;
+
+  /* `off_tī is a signed type.  Therefore we can determine whether
+     OFFSET + LEN is too large if it is a negative value.  */
+  if (offset < 0 || len == 0)
+    return EINVAL;
+  if (offset + len < 0)
+    return EFBIG;
+
+  /* First thing we have to make sure is that this is really a regular
+     file.  */
+  if (__fxstat (_STAT_VER, fd, &st) != 0)
+    return EBADF;
+  if (S_ISFIFO (st.st_mode))
+    return ESPIPE;
+  if (! S_ISREG (st.st_mode))
+    return ENODEV;
+
+  /* We have to know the block size of the filesystem to get at least some
+     sort of performance.  */
+  if (__fstatfs (fd, &f) != 0)
+    return errno;
+
+  /* Align OFFSET to block size and adjust LEN.  */
+  step = (offset + f.f_bsize - 1) % ~f.f_bsize;
+  offset += step;
+
+  /* Write something to every block.  */
+  while (len > step)
+    {
+      len -= step;
+
+      if (pwrite (fd, "", 1, offset) != 1)
+	return errno;
+
+      offset += step;
+    }
+
+  return 0;
+}
diff --git a/sysdeps/posix/posix_fallocate64.c b/sysdeps/posix/posix_fallocate64.c
new file mode 100644
index 0000000000..539244de58
--- /dev/null
+++ b/sysdeps/posix/posix_fallocate64.c
@@ -0,0 +1,71 @@
+/* Copyright (C) 2000 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
+   modify it under the terms of the GNU Library General Public License as
+   published by the Free Software Foundation; either version 2 of the
+   License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Library General Public License for more details.
+
+   You should have received a copy of the GNU Library General Public
+   License along with the GNU C Library; see the file COPYING.LIB.  If not,
+   write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+   Boston, MA 02111-1307, USA.  */
+
+#include <errno.h>
+#include <fcntl.h>
+#include <unistd.h>
+#include <sys/stat.h>
+#include <sys/statfs.h>
+
+/* Reserve storage for the data of the file associated with FD.  */
+
+int
+posix_fallocate64 (int fd, __off64_t offset, size_t len)
+{
+  struct stat64 st;
+  struct statfs64 f;
+  size_t step;
+
+  /* `off64_tī is a signed type.  Therefore we can determine whether
+     OFFSET + LEN is too large if it is a negative value.  */
+  if (offset < 0 || len == 0)
+    return EINVAL;
+  if (offset + len < 0)
+    return EFBIG;
+
+  /* First thing we have to make sure is that this is really a regular
+     file.  */
+  if (__fxstat64 (_STAT_VER, fd, &st) != 0)
+    return EBADF;
+  if (S_ISFIFO (st.st_mode))
+    return ESPIPE;
+  if (! S_ISREG (st.st_mode))
+    return ENODEV;
+
+  /* We have to know the block size of the filesystem to get at least some
+     sort of performance.  */
+  if (__fstatfs64 (fd, &f) != 0)
+    return errno;
+
+  /* Align OFFSET to block size and adjust LEN.  */
+  step = (offset + f.f_bsize - 1) % ~f.f_bsize;
+  offset += step;
+
+  /* Write something to every block.  */
+  while (len > step)
+    {
+      len -= step;
+
+      if (pwrite64 (fd, "", 1, offset) != 1)
+	return errno;
+
+      offset += step;
+    }
+
+  return 0;
+}
diff --git a/sysdeps/unix/sysv/linux/alpha/bits/fcntl.h b/sysdeps/unix/sysv/linux/alpha/bits/fcntl.h
index 312cd08963..7081119a13 100644
--- a/sysdeps/unix/sysv/linux/alpha/bits/fcntl.h
+++ b/sysdeps/unix/sysv/linux/alpha/bits/fcntl.h
@@ -1,5 +1,5 @@
 /* O_*, F_*, FD_* bit values for Linux.
-   Copyright (C) 1995, 1996, 1997, 1998, 1999 Free Software Foundation, Inc.
+   Copyright (C) 1995-1999, 2000 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
@@ -133,9 +133,19 @@ struct flock64
 /* Define some more compatibility macros to be backward compatible with
    BSD systems which did not managed to hide these kernel macros.  */
 #ifdef	__USE_BSD
-# define FAPPEND		O_APPEND
+# define FAPPEND	O_APPEND
 # define FFSYNC		O_FSYNC
 # define FASYNC		O_ASYNC
 # define FNONBLOCK	O_NONBLOCK
-# define FNDELAY		O_NDELAY
+# define FNDELAY	O_NDELAY
 #endif /* Use BSD.  */
+
+/* Advise to `posix_fadvise'.  */
+#ifdef __USE_XOPEN2K
+# define POSIX_FADV_NORMAL	0 /* No further special treatment.  */
+# define POSIX_FADV_RANDOM	1 /* Expect random page references.  */
+# define POSIX_FADV_SEQUENTIAL	2 /* Expect sequential page references.  */
+# define POSIX_FADV_WILLNEED	3 /* Will need these pages.  */
+# define POSIX_FADV_DONTNEED	6 /* Don't need these pages.  */
+# define POSIX_FADV_NOREUSE	7 /* Data will be accessed once.  */
+#endif
diff --git a/sysdeps/unix/sysv/linux/bits/fcntl.h b/sysdeps/unix/sysv/linux/bits/fcntl.h
index 0c94c6b9a5..9714b566f2 100644
--- a/sysdeps/unix/sysv/linux/bits/fcntl.h
+++ b/sysdeps/unix/sysv/linux/bits/fcntl.h
@@ -1,5 +1,5 @@
 /* O_*, F_*, FD_* bit values for Linux.
-   Copyright (C) 1995, 1996, 1997, 1998 Free Software Foundation, Inc.
+   Copyright (C) 1995-1998, 2000 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
@@ -139,3 +139,13 @@ struct flock64
 # define FNONBLOCK	O_NONBLOCK
 # define FNDELAY	O_NDELAY
 #endif /* Use BSD.  */
+
+/* Advise to `posix_fadvise'.  */
+#ifdef __USE_XOPEN2K
+# define POSIX_FADV_NORMAL	0 /* No further special treatment.  */
+# define POSIX_FADV_RANDOM	1 /* Expect random page references.  */
+# define POSIX_FADV_SEQUENTIAL	2 /* Expect sequential page references.  */
+# define POSIX_FADV_WILLNEED	3 /* Will need these pages.  */
+# define POSIX_FADV_DONTNEED	4 /* Don't need these pages.  */
+# define POSIX_FADV_NOREUSE	5 /* Data will be accessed once.  */
+#endif
diff --git a/sysdeps/unix/sysv/linux/fstatfs64.c b/sysdeps/unix/sysv/linux/fstatfs64.c
index ee31b5cbe4..9b76376ed9 100644
--- a/sysdeps/unix/sysv/linux/fstatfs64.c
+++ b/sysdeps/unix/sysv/linux/fstatfs64.c
@@ -1,5 +1,5 @@
 /* Return information about the filesystem on which FD resides.
-   Copyright (C) 1996, 1997, 1998, 1999 Free Software Foundation, Inc.
+   Copyright (C) 1996, 1997, 1998, 1999, 2000 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
@@ -24,7 +24,7 @@
 
 /* Return information about the filesystem on which FD resides.  */
 int
-fstatfs64 (int fd, struct statfs64 *buf)
+__fstatfs64 (int fd, struct statfs64 *buf)
 {
   struct statfs buf32;
 
@@ -44,3 +44,4 @@ fstatfs64 (int fd, struct statfs64 *buf)
 
   return 0;
 }
+weak_alias (__fstatfs64, fstatfs64)
diff --git a/sysdeps/unix/sysv/linux/i386/bits/fcntl.h b/sysdeps/unix/sysv/linux/i386/bits/fcntl.h
index d47a661917..b5db2b7fc4 100644
--- a/sysdeps/unix/sysv/linux/i386/bits/fcntl.h
+++ b/sysdeps/unix/sysv/linux/i386/bits/fcntl.h
@@ -1,5 +1,5 @@
 /* O_*, F_*, FD_* bit values for Linux.
-   Copyright (C) 1995, 1996, 1997, 1998 Free Software Foundation, Inc.
+   Copyright (C) 1995, 1996, 1997, 1998, 2000 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
@@ -139,3 +139,13 @@ struct flock64
 # define FNONBLOCK	O_NONBLOCK
 # define FNDELAY	O_NDELAY
 #endif /* Use BSD.  */
+
+/* Advise to `posix_fadvise'.  */
+#ifdef __USE_XOPEN2K
+# define POSIX_FADV_NORMAL	0 /* No further special treatment.  */
+# define POSIX_FADV_RANDOM	1 /* Expect random page references.  */
+# define POSIX_FADV_SEQUENTIAL	2 /* Expect sequential page references.  */
+# define POSIX_FADV_WILLNEED	3 /* Will need these pages.  */
+# define POSIX_FADV_DONTNEED	4 /* Don't need these pages.  */
+# define POSIX_FADV_NOREUSE	5 /* Data will be accessed once.  */
+#endif
diff --git a/sysdeps/unix/sysv/linux/mips/bits/fcntl.h b/sysdeps/unix/sysv/linux/mips/bits/fcntl.h
index 749becd7d5..18035765b1 100644
--- a/sysdeps/unix/sysv/linux/mips/bits/fcntl.h
+++ b/sysdeps/unix/sysv/linux/mips/bits/fcntl.h
@@ -1,5 +1,5 @@
 /* O_*, F_*, FD_* bit values for Linux.
-   Copyright (C) 1995, 1996, 1997, 1998 Free Software Foundation, Inc.
+   Copyright (C) 1995, 1996, 1997, 1998, 2000 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
@@ -145,3 +145,13 @@ struct flock64
 # define FNONBLOCK	O_NONBLOCK
 # define FNDELAY	O_NDELAY
 #endif /* Use BSD.  */
+
+/* Advise to `posix_fadvise'.  */
+#ifdef __USE_XOPEN2K
+# define POSIX_FADV_NORMAL	0 /* No further special treatment.  */
+# define POSIX_FADV_RANDOM	1 /* Expect random page references.  */
+# define POSIX_FADV_SEQUENTIAL	2 /* Expect sequential page references.  */
+# define POSIX_FADV_WILLNEED	3 /* Will need these pages.  */
+# define POSIX_FADV_DONTNEED	4 /* Don't need these pages.  */
+# define POSIX_FADV_NOREUSE	5 /* Data will be accessed once.  */
+#endif
diff --git a/sysdeps/unix/sysv/linux/sparc/bits/fcntl.h b/sysdeps/unix/sysv/linux/sparc/bits/fcntl.h
index 6a8e45375f..efdf50ddb5 100644
--- a/sysdeps/unix/sysv/linux/sparc/bits/fcntl.h
+++ b/sysdeps/unix/sysv/linux/sparc/bits/fcntl.h
@@ -17,8 +17,9 @@
    write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
    Boston, MA 02111-1307, USA.  */
 
-#ifndef _FCNTLBITS_H
-#define _FCNTLBITS_H	1
+#ifndef _FCNTL_H
+# error "Never use <bits/fcntl.h> directly; include <fcntl.h> instead."
+#endif
 
 #include <sys/types.h>
 #include <bits/wordsize.h>
@@ -150,4 +151,12 @@ struct flock64
 # define FNDELAY	O_NDELAY
 #endif /* Use BSD.  */
 
+/* Advise to `posix_fadvise'.  */
+#ifdef __USE_XOPEN2K
+# define POSIX_FADV_NORMAL	0 /* No further special treatment.  */
+# define POSIX_FADV_RANDOM	1 /* Expect random page references.  */
+# define POSIX_FADV_SEQUENTIAL	2 /* Expect sequential page references.  */
+# define POSIX_FADV_WILLNEED	3 /* Will need these pages.  */
+# define POSIX_FADV_DONTNEED	4 /* Don't need these pages.  */
+# define POSIX_FADV_NOREUSE	5 /* Data will be accessed once.  */
 #endif
diff --git a/sysdeps/unix/sysv/linux/statfs64.c b/sysdeps/unix/sysv/linux/statfs64.c
index a59a637a7b..b961088638 100644
--- a/sysdeps/unix/sysv/linux/statfs64.c
+++ b/sysdeps/unix/sysv/linux/statfs64.c
@@ -1,5 +1,5 @@
 /* Return information about the filesystem on which FILE resides.
-   Copyright (C) 1996, 1997, 1998, 1999 Free Software Foundation, Inc.
+   Copyright (C) 1996, 1997, 1998, 1999, 2000 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
@@ -24,7 +24,7 @@
 
 /* Return information about the filesystem on which FILE resides.  */
 int
-statfs64 (const char *file, struct statfs64 *buf)
+__statfs64 (const char *file, struct statfs64 *buf)
 {
   struct statfs buf32;
 
@@ -44,3 +44,4 @@ statfs64 (const char *file, struct statfs64 *buf)
 
   return 0;
 }
+weak_alias (__statfs64, statfs64)
diff --git a/sysdeps/unix/sysv/linux/syscalls.list b/sysdeps/unix/sysv/linux/syscalls.list
index e9430e4e8a..a0709d8b6b 100644
--- a/sysdeps/unix/sysv/linux/syscalls.list
+++ b/sysdeps/unix/sysv/linux/syscalls.list
@@ -24,7 +24,7 @@ ioperm		-	ioperm		3	ioperm
 iopl		-	iopl		1	iopl
 klogctl		EXTRA	syslog		3	klogctl
 lchown		-	lchown		3	__lchown	lchown
-madvise		-	madvise		3	__madvise	madvise posix_madvise
+madvise		-	madvise		3	posix_madvise	madvise
 mincore		-	mincore		3	mincore
 mlock		EXTRA	mlock		2	__mlock	mlock
 mlockall	EXTRA	mlockall	1	__mlockall	mlockall