This change fixes incorrect return of error codes in the pipe module of
vfscore. Specifically:
- Return positive error codes from internal functions; syscall handlers
expect positive errors and will negate them as required
- Do not set errno, rather return the error code
- Correctly return EINVAL when attempting to open a pipe with O_DIRECT,
as we do not support packet mode pipes, and calling code needs to be
made aware of this
Signed-off-by: Andrei Tatar <andrei@unikraft.io>
Reviewed-by: Stefan Jumarea <stefanjumarea02@gmail.com>
Reviewed-by: Radu Nichita <radunichita99@gmail.com>
Approved-by: Razvan Deaconescu <razvand@unikraft.io>
GitHub-Closes: #1093
if (!pipe_file->r_refcount) {
/* TODO before returning the error, send a SIGPIPE signal */
- return -EPIPE;
+ return EPIPE;
}
uk_mutex_lock(&pipe_buf->wrlock);
struct vfscore_file *vfscore_file __unused,
off_t off1 __unused, off_t off2 __unused)
{
- errno = ESPIPE;
- return -1;
+ return ESPIPE;
}
static int pipe_ioctl(struct vnode *vnode,
/* sys_ioctl() already sets f_flags, no need to do anything */
return 0;
default:
- return -EINVAL;
+ return EINVAL;
}
}
{
int rc;
+ if (flags & O_DIRECT)
+ return -EINVAL;
+
rc = uk_syscall_r_pipe((long) pipefd);
if (rc)
return rc;