From 05b9ae703187e63aca6861f615268abc0b3dba09 Mon Sep 17 00:00:00 2001 From: kib Date: Thu, 23 Jan 2014 17:24:26 +0000 Subject: The posix_fallocate(2) syscall should return error number on error, without modifying errno. Reported and tested by: Gennady Proskurin Reviewed by: mdf PR: standards/186028 Sponsored by: The FreeBSD Foundation MFC after: 1 week --- lib/libc/sys/posix_fallocate.2 | 4 ++-- sys/compat/freebsd32/freebsd32_misc.c | 5 +++-- sys/kern/vfs_syscalls.c | 4 +++- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/lib/libc/sys/posix_fallocate.2 b/lib/libc/sys/posix_fallocate.2 index 7b17133..1460764 100644 --- a/lib/libc/sys/posix_fallocate.2 +++ b/lib/libc/sys/posix_fallocate.2 @@ -83,9 +83,9 @@ that reduces the file size to a size smaller than If successful, .Fn posix_fallocate returns zero. -It returns -1 on failure, and sets +It returns error number on failure, without setting .Va errno -to indicate the error. +variable. .Sh ERRORS Possible failure conditions: .Bl -tag -width Er diff --git a/sys/compat/freebsd32/freebsd32_misc.c b/sys/compat/freebsd32/freebsd32_misc.c index 719a057..e4ffbe4 100644 --- a/sys/compat/freebsd32/freebsd32_misc.c +++ b/sys/compat/freebsd32/freebsd32_misc.c @@ -2995,8 +2995,9 @@ freebsd32_posix_fallocate(struct thread *td, struct freebsd32_posix_fallocate_args *uap) { - return (kern_posix_fallocate(td, uap->fd, - PAIR32TO64(off_t, uap->offset), PAIR32TO64(off_t, uap->len))); + td->td_retval[0] = kern_posix_fallocate(td, uap->fd, + PAIR32TO64(off_t, uap->offset), PAIR32TO64(off_t, uap->len)); + return (0); } int diff --git a/sys/kern/vfs_syscalls.c b/sys/kern/vfs_syscalls.c index dbad1ae..b864c90 100644 --- a/sys/kern/vfs_syscalls.c +++ b/sys/kern/vfs_syscalls.c @@ -4584,7 +4584,9 @@ int sys_posix_fallocate(struct thread *td, struct posix_fallocate_args *uap) { - return (kern_posix_fallocate(td, uap->fd, uap->offset, uap->len)); + td->td_retval[0] = kern_posix_fallocate(td, uap->fd, uap->offset, + uap->len); + return (0); } /* -- cgit v1.1