summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorErik M. Bray <erik.m.bray@gmail.com>2017-11-02 16:45:34 +0100
committerCorinna Vinschen <corinna@vinschen.de>2017-11-02 17:58:18 +0100
commit8c8cdd9ad72b07c1edefb5264cdcb4927700e813 (patch)
tree0abb51b5a4107cffe8d2a645b6a6eebe1c62eb31
parent076ce7098f5806bf29ff0ba0dbeba4f335786b3c (diff)
downloadcygnal-8c8cdd9ad72b07c1edefb5264cdcb4927700e813.tar.gz
cygnal-8c8cdd9ad72b07c1edefb5264cdcb4927700e813.tar.bz2
cygnal-8c8cdd9ad72b07c1edefb5264cdcb4927700e813.zip
posix_fadvise() *returns* error codes but does not set errno
Also updates the fhandler_*::fadvise implementations to adhere to the same semantics.
-rw-r--r--winsup/cygwin/fhandler_disk_file.cc11
-rw-r--r--winsup/cygwin/pipe.cc3
-rw-r--r--winsup/cygwin/syscalls.cc2
3 files changed, 5 insertions, 11 deletions
diff --git a/winsup/cygwin/fhandler_disk_file.cc b/winsup/cygwin/fhandler_disk_file.cc
index 2144a4cdc..252dc660c 100644
--- a/winsup/cygwin/fhandler_disk_file.cc
+++ b/winsup/cygwin/fhandler_disk_file.cc
@@ -1075,10 +1075,7 @@ int
fhandler_disk_file::fadvise (off_t offset, off_t length, int advice)
{
if (advice < POSIX_FADV_NORMAL || advice > POSIX_FADV_NOREUSE)
- {
- set_errno (EINVAL);
- return -1;
- }
+ return EINVAL;
/* Windows only supports advice flags for the whole file. We're using
a simplified test here so that we don't have to ask for the actual
@@ -1097,9 +1094,7 @@ fhandler_disk_file::fadvise (off_t offset, off_t length, int advice)
NTSTATUS status = NtQueryInformationFile (get_handle (), &io,
&fmi, sizeof fmi,
FileModeInformation);
- if (!NT_SUCCESS (status))
- __seterrno_from_nt_status (status);
- else
+ if (NT_SUCCESS (status))
{
fmi.Mode &= ~FILE_SEQUENTIAL_ONLY;
if (advice == POSIX_FADV_SEQUENTIAL)
@@ -1111,7 +1106,7 @@ fhandler_disk_file::fadvise (off_t offset, off_t length, int advice)
__seterrno_from_nt_status (status);
}
- return -1;
+ return geterrno_from_nt_status (status);
}
int
diff --git a/winsup/cygwin/pipe.cc b/winsup/cygwin/pipe.cc
index 79b796631..8738d34b9 100644
--- a/winsup/cygwin/pipe.cc
+++ b/winsup/cygwin/pipe.cc
@@ -165,8 +165,7 @@ fhandler_pipe::lseek (off_t offset, int whence)
int
fhandler_pipe::fadvise (off_t offset, off_t length, int advice)
{
- set_errno (ESPIPE);
- return -1;
+ return ESPIPE;
}
int
diff --git a/winsup/cygwin/syscalls.cc b/winsup/cygwin/syscalls.cc
index caa3a77b3..d0d735bde 100644
--- a/winsup/cygwin/syscalls.cc
+++ b/winsup/cygwin/syscalls.cc
@@ -2937,7 +2937,7 @@ posix_fadvise (int fd, off_t offset, off_t len, int advice)
if (cfd >= 0)
res = cfd->fadvise (offset, len, advice);
else
- set_errno (EBADF);
+ res = EBADF;
syscall_printf ("%R = posix_fadvice(%d, %D, %D, %d)",
res, fd, offset, len, advice);
return res;