diff options
Diffstat (limited to 'fs')
| -rw-r--r-- | fs/fd.c | 58 | ||||
| -rw-r--r-- | fs/fd.h | 1 | ||||
| -rw-r--r-- | fs/pipe.c | 4 |
3 files changed, 49 insertions, 14 deletions
@@ -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) @@ -38,5 +38,6 @@ bool fd_close(fd*); fd fd_from_fifo(fifo* f); fd fd_from_path(char *path); fd fd_from_sysfs(void(*g)(ringbuffer *r,void (*f)(ringbuffer *r,char *fmt, ...)),void(*h)(uint32_t in)); +int fds_from_pipe(fd pipefds[2]); #endif @@ -5,8 +5,10 @@ #include "lib/string/string.h" -/* mount interface */ +#define MAX_PIPES 100 + +/* mount interface */ fd pipe_file_open(mount *m,char *path) { fd a; |
