inode: rearrange NET bits so netd can also use them
authorAlan Cox <alan@linux.intel.com>
Sat, 3 Jan 2015 13:39:20 +0000 (13:39 +0000)
committerAlan Cox <alan@linux.intel.com>
Sat, 3 Jan 2015 13:39:20 +0000 (13:39 +0000)
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.

Kernel/inode.c

index d4481b2..6acf085 100644 (file)
@@ -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;
        }