summaryrefslogtreecommitdiff
path: root/fs
diff options
context:
space:
mode:
authorMiguel <m.i@gmx.at>2018-10-09 16:21:32 +0200
committerMiguel <m.i@gmx.at>2018-10-09 16:21:32 +0200
commit63e5017d9863d4ed215782e469e8ee2c6ff8473d (patch)
treef12d149ffa34e6a39f4bce4fe9a001e4ca8c6027 /fs
parenta6a11437a390fb7e95fe995214d82bf5dbfe1eaf (diff)
fix pipers
Diffstat (limited to 'fs')
-rw-r--r--fs/fd.c10
-rw-r--r--fs/fd.h2
2 files changed, 12 insertions, 0 deletions
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*);