From 763f85c55fdb5a2c4f5bf98e4989a69d27da6e4f Mon Sep 17 00:00:00 2001 From: Miguel Date: Thu, 20 Sep 2018 10:46:00 +0200 Subject: pipes do not work :( --- fs/fd.c | 58 +++++++++++++++++++++++++++++++++++++++++++++------------- 1 file changed, 45 insertions(+), 13 deletions(-) (limited to 'fs/fd.c') 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) -- cgit v1.2.3