diff options
author | Corinna Vinschen <corinna@vinschen.de> | 2023-11-25 22:56:52 +0300 |
---|---|---|
committer | Corinna Vinschen <corinna@vinschen.de> | 2023-11-28 12:51:47 +0300 |
commit | fedd7fae77303ee3caf7c87510a03a9157deb06f (patch) | |
tree | 750a5728d2aafd8e53268d85edabef49e871e5d4 /winsup/cygwin/syscalls.cc | |
parent | d5dcb484c705a214b30826c82b9fd8bf83772093 (diff) |
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>
Diffstat (limited to 'winsup/cygwin/syscalls.cc')
-rw-r--r-- | winsup/cygwin/syscalls.cc | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/winsup/cygwin/syscalls.cc b/winsup/cygwin/syscalls.cc index e4b3dd2f3..c3c17d604 100644 --- a/winsup/cygwin/syscalls.cc +++ b/winsup/cygwin/syscalls.cc @@ -3000,6 +3000,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; @@ -3015,6 +3017,8 @@ ftruncate (int fd, off_t length) res = cfd->ftruncate (length, true); if (res) { + if (res == ENODEV) + res = EINVAL; set_errno (res); res = -1; } |