Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F145555540
D5425.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
2 KB
Referenced Files
None
Subscribers
None
D5425.diff
View Options
Index: sys/compat/freebsd32/freebsd32_misc.c
===================================================================
--- sys/compat/freebsd32/freebsd32_misc.c
+++ sys/compat/freebsd32/freebsd32_misc.c
@@ -2965,21 +2965,22 @@
freebsd32_posix_fallocate(struct thread *td,
struct freebsd32_posix_fallocate_args *uap)
{
+ int error;
- td->td_retval[0] = kern_posix_fallocate(td, uap->fd,
+ error = kern_posix_fallocate(td, uap->fd,
PAIR32TO64(off_t, uap->offset), PAIR32TO64(off_t, uap->len));
- return (0);
+ return (kern_posix_error(td, error));
}
int
freebsd32_posix_fadvise(struct thread *td,
struct freebsd32_posix_fadvise_args *uap)
{
+ int error;
- td->td_retval[0] = kern_posix_fadvise(td, uap->fd,
- PAIR32TO64(off_t, uap->offset), PAIR32TO64(off_t, uap->len),
- uap->advice);
- return (0);
+ error = kern_posix_fadvise(td, uap->fd, PAIR32TO64(off_t, uap->offset),
+ PAIR32TO64(off_t, uap->len), uap->advice);
+ return (kern_posix_error(td, error));
}
int
Index: sys/kern/sys_generic.c
===================================================================
--- sys/kern/sys_generic.c
+++ sys/kern/sys_generic.c
@@ -1910,3 +1910,19 @@
NULL, NULL, UMA_ALIGN_PTR, 0);
mtxpool_select = mtx_pool_create("select mtxpool", 128, MTX_DEF);
}
+
+/*
+ * Set up a syscall return value that follows the convention specified for
+ * posix_* functions.
+ */
+int
+kern_posix_error(struct thread *td, int error)
+{
+
+ if (error <= 0)
+ return (error);
+ td->td_errno = error;
+ td->td_pflags |= TDP_NERRNO;
+ td->td_retval[0] = error;
+ return (0);
+}
Index: sys/kern/vfs_syscalls.c
===================================================================
--- sys/kern/vfs_syscalls.c
+++ sys/kern/vfs_syscalls.c
@@ -4533,10 +4533,10 @@
int
sys_posix_fallocate(struct thread *td, struct posix_fallocate_args *uap)
{
+ int error;
- td->td_retval[0] = kern_posix_fallocate(td, uap->fd, uap->offset,
- uap->len);
- return (0);
+ error = kern_posix_fallocate(td, uap->fd, uap->offset, uap->len);
+ return (kern_posix_error(td, error));
}
/*
@@ -4668,8 +4668,9 @@
int
sys_posix_fadvise(struct thread *td, struct posix_fadvise_args *uap)
{
+ int error;
- td->td_retval[0] = kern_posix_fadvise(td, uap->fd, uap->offset,
- uap->len, uap->advice);
- return (0);
+ error = kern_posix_fadvise(td, uap->fd, uap->offset, uap->len,
+ uap->advice);
+ return (kern_posix_error(td, error));
}
Index: sys/sys/syscallsubr.h
===================================================================
--- sys/sys/syscallsubr.h
+++ sys/sys/syscallsubr.h
@@ -158,6 +158,7 @@
struct filecaps *fcaps1, struct filecaps *fcaps2);
int kern_poll(struct thread *td, struct pollfd *fds, u_int nfds,
struct timespec *tsp, sigset_t *uset);
+int kern_posix_error(struct thread *td, int error);
int kern_posix_fadvise(struct thread *td, int fd, off_t offset, off_t len,
int advice);
int kern_posix_fallocate(struct thread *td, int fd, off_t offset,
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sun, Feb 22, 10:26 AM (12 h, 18 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
28935906
Default Alt Text
D5425.diff (2 KB)
Attached To
Mode
D5425: Improve error handling for posix file syscalls
Attached
Detach File
Event Timeline
Log In to Comment