From 63e5017d9863d4ed215782e469e8ee2c6ff8473d Mon Sep 17 00:00:00 2001 From: Miguel Date: Tue, 9 Oct 2018 16:21:32 +0200 Subject: fix pipers --- fs/fd.c | 10 ++++++++++ fs/fd.h | 2 ++ 2 files changed, 12 insertions(+) (limited to 'fs') diff --git a/fs/fd.c b/fs/fd.c index 7ba7142..740bf35 100644 --- a/fs/fd.c +++ b/fs/fd.c @@ -25,6 +25,11 @@ bool fd_has(fd* f) if(!f->has)kpanic("no has func") return f->has(f->data); } +bool fd_can_write(fd* f) +{ + if(!f->can_write)kpanic("no has func") + return f->can_write(f->data); +} bool fd_eof(fd* f) { @@ -203,6 +208,10 @@ bool pipe_has(uint32_t *data) { return ringbuffer_has(data); } +bool pipe_can_write(uint32_t *data) +{ + return !ringbuffer_full(data); +} bool pipe_eof(uint8_t *data) { @@ -248,6 +257,7 @@ int fds_from_pipe(fd pipefds[2]) read.eof=pipe_eof; wrt.eof=0; + wrt.can_write=pipe_can_write; read.close=pipe_r_close; wrt.close=pipe_w_close; diff --git a/fs/fd.h b/fs/fd.h index 21037c8..4bee666 100644 --- a/fs/fd.h +++ b/fs/fd.h @@ -22,6 +22,7 @@ typedef struct fd_struct bool (*write)(struct fd_struct*,uint8_t); uint8_t (*read)(struct fd_struct*); bool (*has)(struct fd_struct*); + bool (*can_write)(struct fd_struct*); bool (*eof)(struct fd_struct*); bool (*close)(struct fd_struct*); struct fd_struct (*dupl)(struct fd_struct *); @@ -34,6 +35,7 @@ uint8_t fd_read(fd*); bool fd_has(fd*); bool fd_eof(fd*); bool fd_write(fd*,uint8_t); +bool fd_can_write(fd*); bool fd_close(fd*); fd fd_dupl(fd*); -- cgit v1.2.3