summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorkib <kib@FreeBSD.org>2014-02-06 19:47:17 +0000
committerkib <kib@FreeBSD.org>2014-02-06 19:47:17 +0000
commitce48f3b35de8eeff2a37ad55803ef0e4c57a7f05 (patch)
tree5604fb1ed8b1e338d7fdf6a9c639512583952e1e /lib
parent88938f44a008c777d8811442d0121c4edd7c943d (diff)
downloadFreeBSD-src-ce48f3b35de8eeff2a37ad55803ef0e4c57a7f05.zip
FreeBSD-src-ce48f3b35de8eeff2a37ad55803ef0e4c57a7f05.tar.gz
MFC r261080:
The posix_fallocate(2) syscall should return error number on error, without modifying errno. MFC r261290: The posix_madvise(3) and posix_fadvise(2) should return error on failure, same as posix_fallocate(2).
Diffstat (limited to 'lib')
-rw-r--r--lib/libc/gen/pmadvise.c12
-rw-r--r--lib/libc/sys/madvise.27
-rw-r--r--lib/libc/sys/posix_fadvise.24
-rw-r--r--lib/libc/sys/posix_fallocate.25
4 files changed, 20 insertions, 8 deletions
diff --git a/lib/libc/gen/pmadvise.c b/lib/libc/gen/pmadvise.c
index 60cef63..0dc77e3 100644
--- a/lib/libc/gen/pmadvise.c
+++ b/lib/libc/gen/pmadvise.c
@@ -8,9 +8,19 @@
__FBSDID("$FreeBSD$");
#include <sys/mman.h>
+#include <errno.h>
int
posix_madvise(void *address, size_t size, int how)
{
- return madvise(address, size, how);
+ int ret, saved_errno;
+
+ saved_errno = errno;
+ if (madvise(address, size, how) == -1) {
+ ret = errno;
+ errno = saved_errno;
+ } else {
+ ret = 0;
+ }
+ return (ret);
}
diff --git a/lib/libc/sys/madvise.2 b/lib/libc/sys/madvise.2
index b5ea6b2..357e05e 100644
--- a/lib/libc/sys/madvise.2
+++ b/lib/libc/sys/madvise.2
@@ -28,7 +28,7 @@
.\" @(#)madvise.2 8.1 (Berkeley) 6/9/93
.\" $FreeBSD$
.\"
-.Dd July 19, 1996
+.Dd January 30, 2014
.Dt MADVISE 2
.Os
.Sh NAME
@@ -50,7 +50,10 @@ allows a process that has knowledge of its memory behavior
to describe it to the system.
The
.Fn posix_madvise
-interface is identical and is provided for standards conformance.
+interface is identical, except it returns an error number on error and does
+not modify
+.Va errno ,
+and is provided for standards conformance.
.Pp
The known behaviors are:
.Bl -tag -width MADV_SEQUENTIAL
diff --git a/lib/libc/sys/posix_fadvise.2 b/lib/libc/sys/posix_fadvise.2
index 7a9a648..8691f6b 100644
--- a/lib/libc/sys/posix_fadvise.2
+++ b/lib/libc/sys/posix_fadvise.2
@@ -28,7 +28,7 @@
.\" @(#)madvise.2 8.1 (Berkeley) 6/9/93
.\" $FreeBSD$
.\"
-.Dd June 19, 2012
+.Dd January 30, 2014
.Dt POSIX_FADVISE 2
.Os
.Sh NAME
@@ -93,7 +93,7 @@ Future access to this data may require a read operation.
.Sh ERRORS
The
.Fn posix_fadvise
-system call will fail if:
+system call returns zero on success, and an error on failure:
.Bl -tag -width Er
.It Bq Er EBADF
The
diff --git a/lib/libc/sys/posix_fallocate.2 b/lib/libc/sys/posix_fallocate.2
index 7b17133..7501777 100644
--- a/lib/libc/sys/posix_fallocate.2
+++ b/lib/libc/sys/posix_fallocate.2
@@ -83,9 +83,8 @@ that reduces the file size to a size smaller than
If successful,
.Fn posix_fallocate
returns zero.
-It returns -1 on failure, and sets
-.Va errno
-to indicate the error.
+It returns an error on failure, without setting
+.Va errno .
.Sh ERRORS
Possible failure conditions:
.Bl -tag -width Er
OpenPOWER on IntegriCloud