posix_fallocate(2) && posix_fadvise(2) are somewhat broken
Maxim Sobolev
sobomax at FreeBSD.org
Tue Dec 8 09:35:34 UTC 2015
Hi, while working on some unrelated feature I've noticed that at least
those two system calls are not returning proper value (-1) on error.
Instead actual errno value is returned from the syscall verbatim,
i.e. posix_fadvise() returns 22 on EINVAL. Attached patch fixes that
problem, however I am not sure if I need to assign td->td_retval[0] at all,
those two operations by design never return anything but -1 on error and 0
on success. Can someone comment on this? Thanks!
-------------- next part --------------
diff --git a/sys/kern/vfs_syscalls.c b/sys/kern/vfs_syscalls.c
index e675b09..bdb1639 100644
--- a/sys/kern/vfs_syscalls.c
+++ b/sys/kern/vfs_syscalls.c
@@ -4528,7 +4528,7 @@ sys_posix_fallocate(struct thread *td, struct posix_fallocate_args *uap)
td->td_retval[0] = kern_posix_fallocate(td, uap->fd, uap->offset,
uap->len);
- return (0);
+ return (td->td_retval[0]);
}
/*
@@ -4665,5 +4665,5 @@ sys_posix_fadvise(struct thread *td, struct posix_fadvise_args *uap)
td->td_retval[0] = kern_posix_fadvise(td, uap->fd, uap->offset,
uap->len, uap->advice);
- return (0);
+ return (td->td_retval[0]);
}
More information about the freebsd-current
mailing list