mirror of
https://github.com/Mathewnd/Astral.git
synced 2026-10-28 05:08:22 +00:00
kernel: do preparation work for copyless read/write
This commit is contained in:
@@ -1317,6 +1317,8 @@ static int ext2_readlink(vnode_t *vnode, char **link, cred_t *cred) {
|
||||
return err;
|
||||
}
|
||||
|
||||
// this *should*, by the rules of the vnode ops, accept a user buffer. however, this will never be the case. all I/O will
|
||||
// go through the page cache
|
||||
static int ext2_read(vnode_t *vnode, void *buffer, size_t size, uintmax_t offset, int flags, size_t *readc, cred_t *cred) {
|
||||
if (vnode->type == V_TYPE_DIR)
|
||||
return EISDIR;
|
||||
@@ -1356,6 +1358,8 @@ static int ext2_read(vnode_t *vnode, void *buffer, size_t size, uintmax_t offset
|
||||
return err;
|
||||
}
|
||||
|
||||
// this *should*, by the rules of the vnode ops, accept a user buffer. however, this will never be the case. all I/O will
|
||||
// go through the page cache
|
||||
int ext2_write(vnode_t *vnode, void *buffer, size_t size, uintmax_t offset, int flags, size_t *writec, cred_t *cred) {
|
||||
if (vnode->type == V_TYPE_DIR)
|
||||
return EISDIR;
|
||||
|
||||
@@ -130,6 +130,7 @@ static int internalpoll(vnode_t *node, polldata_t *data, int events) {
|
||||
return revents;
|
||||
}
|
||||
|
||||
// buffer can possibly be a user address
|
||||
int pipefs_read(vnode_t *node, void *buffer, size_t size, uintmax_t offset, int flags, size_t *readc, cred_t *cred) {
|
||||
pipenode_t *pipenode = (pipenode_t *)node;
|
||||
INTERNAL_LOCK(node);
|
||||
@@ -171,6 +172,8 @@ int pipefs_read(vnode_t *node, void *buffer, size_t size, uintmax_t offset, int
|
||||
}
|
||||
|
||||
*readc = ringbuffer_read(&pipenode->data, buffer, size);
|
||||
if (*readc == RINGBUFFER_USER_COPY_FAILED)
|
||||
error = EFAULT;
|
||||
|
||||
// signal that there is space to write for any threads blocked on this pipe
|
||||
if (RINGBUFFER_DATACOUNT(&pipenode->data) < BUFFER_SIZE - PIPE_ATOMIC_SIZE)
|
||||
@@ -190,6 +193,8 @@ static int writetopipe(pipenode_t *pipenode, void *buffer, size_t size, size_t *
|
||||
}
|
||||
|
||||
*writec = ringbuffer_write(&pipenode->data, buffer, size);
|
||||
if (*writec == RINGBUFFER_USER_COPY_FAILED)
|
||||
return EFAULT;
|
||||
|
||||
__assert(*writec);
|
||||
poll_event(&pipenode->pollheader, POLLIN);
|
||||
|
||||
Reference in New Issue
Block a user