diff options
author | Corinna Vinschen <corinna@vinschen.de> | 2023-11-25 20:56:52 +0100 |
---|---|---|
committer | Corinna Vinschen <corinna@vinschen.de> | 2023-11-28 10:55:52 +0100 |
commit | 8e009dce7c82538119766cc0e3a6c91f3248ea5a (patch) | |
tree | 7870b7eefabf87b27bd3ea18476027f709f8958f | |
parent | 4a7cc5af01e438b33f6544d99548fe5f4d2cb776 (diff) | |
download | newlib-8e009dce7c82538119766cc0e3a6c91f3248ea5a.zip newlib-8e009dce7c82538119766cc0e3a6c91f3248ea5a.tar.gz newlib-8e009dce7c82538119766cc0e3a6c91f3248ea5a.tar.bz2 |
Cygwin: posix_fallocate: return ENODEV
The fhandler method ftruncate returns either EISDIR if it has been
called on directories, or EINVAL if called on files other than
regular files. This matches what ftruncate(2) is supposed to return,
but it doesn't match posix_fallocate(3), which is supposed to return
ENODEV in both cases.
To accomplish that, return ENODEV from fhandler_base::ftruncate()
and convert it to EINVAL in ftruncate(2). In posix_fallocate(3),
convert EISDIR to ENODEV.
Fixes: 7636b58590621 ("* autoload.cc (NtSetInformationFile): Define.")
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
-rw-r--r-- | winsup/cygwin/fhandler/base.cc | 2 | ||||
-rw-r--r-- | winsup/cygwin/release/3.4.10 | 3 | ||||
-rw-r--r-- | winsup/cygwin/syscalls.cc | 4 |
3 files changed, 8 insertions, 1 deletions
diff --git a/winsup/cygwin/fhandler/base.cc b/winsup/cygwin/fhandler/base.cc index 9b49ec7..58b63da 100644 --- a/winsup/cygwin/fhandler/base.cc +++ b/winsup/cygwin/fhandler/base.cc @@ -1705,7 +1705,7 @@ fhandler_base::fadvise (off_t offset, off_t length, int advice) int fhandler_base::ftruncate (off_t length, bool allow_truncate) { - return EINVAL; + return ENODEV; } int diff --git a/winsup/cygwin/release/3.4.10 b/winsup/cygwin/release/3.4.10 index 758a6e0..02f6885 100644 --- a/winsup/cygwin/release/3.4.10 +++ b/winsup/cygwin/release/3.4.10 @@ -18,3 +18,6 @@ Bug Fixes - Align behaviour of rand(3) to ISO C. Adresses: https://cygwin.com/pipermail/cygwin/2023-November/254735.html + +- Fix posix_fallocate(3) return value in case of being called on + other than regular files. diff --git a/winsup/cygwin/syscalls.cc b/winsup/cygwin/syscalls.cc index ba0cd05..bc32323 100644 --- a/winsup/cygwin/syscalls.cc +++ b/winsup/cygwin/syscalls.cc @@ -2998,6 +2998,8 @@ posix_fallocate (int fd, off_t offset, off_t len) res = cfd->ftruncate (offset + len, false); else res = EBADF; + if (res == EISDIR) + res = ENODEV; } syscall_printf ("%R = posix_fallocate(%d, %D, %D)", res, fd, offset, len); return res; @@ -3013,6 +3015,8 @@ ftruncate (int fd, off_t length) res = cfd->ftruncate (length, true); if (res) { + if (res == ENODEV) + res = EINVAL; set_errno (res); res = -1; } |