summaryrefslogtreecommitdiffstats
path: root/lib/libc/gen
diff options
context:
space:
mode:
authorkib <kib@FreeBSD.org>2014-01-30 18:04:39 +0000
committerkib <kib@FreeBSD.org>2014-01-30 18:04:39 +0000
commitf0cb8e7d88037c15a00b061150929a9edf7ec886 (patch)
tree9a201009ee35135b56bc2706031305325070a4ac /lib/libc/gen
parent8ca08329cac24ebe4162ebae134a49a1871d6709 (diff)
downloadFreeBSD-src-f0cb8e7d88037c15a00b061150929a9edf7ec886.zip
FreeBSD-src-f0cb8e7d88037c15a00b061150929a9edf7ec886.tar.gz
The posix_madvise(3) and posix_fadvise(2) should return error on
failure, same as posix_fallocate(2). Noted by: Bob Bishop <rb@gid.co.uk> Discussed with: bde Sponsored by: The FreeBSD Foundation MFC after: 1 week
Diffstat (limited to 'lib/libc/gen')
-rw-r--r--lib/libc/gen/pmadvise.c12
1 files changed, 11 insertions, 1 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);
}
OpenPOWER on IntegriCloud