summaryrefslogtreecommitdiff
path: root/fs/fd.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/fd.c')
-rw-r--r--fs/fd.c58
1 files changed, 45 insertions, 13 deletions
diff --git a/fs/fd.c b/fs/fd.c
index fe34003..1936f37 100644
--- a/fs/fd.c
+++ b/fs/fd.c
@@ -149,25 +149,57 @@ fd fd_from_fifo(fifo* fif)
return f;
}
-fd fd_from_pipe()
+uint8_t pipe_get(uint32_t *data)
{
- fd f;
- f.type=FD_TYPE_PIPE;
- f.data=kballoc(1);
+ return ringbuffer_get(data);
+}
+
+void pipe_put(void* data,uint8_t b)
+{
+ ringbuffer_put(data,b);
+}
+
+bool pipe_has(uint32_t *data)
+{
+ return ringbuffer_has(data);
+}
+
+bool pipe_eof(uint32_t *data)
+{
+ return 0;
+}
+
+int fds_from_pipe(fd pipefds[2])
+{
+ fd read;
+ fd wrt;
+
+ read.type=FD_TYPE_PIPE;
+ wrt.type=FD_TYPE_PIPE;
+
+ read.data=kballoc(1);
+ wrt.data=read.type;
+
ringbuffer r=ringbuffer_init(1);
- memcpy(f.data,&r,sizeof(ringbuffer));
+ memcpy(read.data,&r,sizeof(ringbuffer));
+
+ read.read=pipe_get;
+ wrt.write=pipe_put;
- /*
- f.read=sysfs_get;
- f.write=0;
- f.has=sysfs_has;
- f.eof=sysfs_eof;
- */
+ read.has=pipe_has;
+ wrt.has=pipe_has;
- f.close=pipe_close;
+ read.eof=pipe_eof;
+ wrt.eof=pipe_eof;
+
+ read.close=0;
+ wrt.close=0;
+
+ pipefds[0]=read;
+ pipefds[1]=wrt;
- return f;
+ return 0;
}
fd fd_from_path(char* path)