From: Alan Cox Date: Sat, 3 Jan 2015 13:39:20 +0000 (+0000) Subject: inode: rearrange NET bits so netd can also use them X-Git-Url: https://git.ndcode.org/public/gitweb.cgi?a=commitdiff_plain;h=a99524e7dab4bf47592a601af4d232229d2e6927;p=FUZIX.git inode: rearrange NET bits so netd can also use them This lets us borrow the pipe read code for processes and the pipe write code for the net daemon to queue data into a socket. --- diff --git a/Kernel/inode.c b/Kernel/inode.c index d4481b2c..6acf0852 100644 --- a/Kernel/inode.c +++ b/Kernel/inode.c @@ -26,6 +26,10 @@ void readi(inoptr ino, uint8_t flag) goto loop; case F_SOCK: +#ifdef CONFIG_NET + if (is_netd()) + return netd_sock_read(ino, flag); +#endif case F_PIPE: ispipe = true; while (ino->c_node.i_size == 0 && !(flag & O_NDELAY)) { @@ -109,6 +113,13 @@ void writei(inoptr ino, uint8_t flag) towrite = udata.u_count; goto loop; +#ifdef CONFIG_NET + case F_SOCK: + if (!is_netd()) { + udata.u_count = sock_write(ino, flag); + break; + } +#endif case F_PIPE: ispipe = true; /* FIXME: this will hang if you ever write > 16 * BLKSIZE @@ -178,11 +189,6 @@ void writei(inoptr ino, uint8_t flag) if (udata.u_count != -1) udata.u_offset += udata.u_count; break; -#ifdef CONFIG_NET - case F_SOCK: - udata.u_count = sock_write(ino, flag); - break; -#endif default: udata.u_error = ENODEV; }