afs: Remote abort can cause BUG in rxrpc code
[linux-2.6.git] / fs / fifo.c
index 6e7df72..b1a524d 100644 (file)
--- a/fs/fifo.c
+++ b/fs/fifo.c
@@ -10,8 +10,8 @@
  */
 
 #include <linux/mm.h>
-#include <linux/slab.h>
 #include <linux/fs.h>
+#include <linux/sched.h>
 #include <linux/pipe_fs_i.h>
 
 static void wait_for_partner(struct inode* inode, unsigned int *cnt)
@@ -50,13 +50,13 @@ static int fifo_open(struct inode *inode, struct file *filp)
        filp->f_mode &= (FMODE_READ | FMODE_WRITE);
 
        switch (filp->f_mode) {
-       case 1:
+       case FMODE_READ:
        /*
         *  O_RDONLY
         *  POSIX.1 says that O_NONBLOCK means return with the FIFO
         *  opened, even when there is no process writing the FIFO.
         */
-               filp->f_op = &read_fifo_fops;
+               filp->f_op = &read_pipefifo_fops;
                pipe->r_counter++;
                if (pipe->readers++ == 0)
                        wake_up_partner(inode);
@@ -66,8 +66,7 @@ static int fifo_open(struct inode *inode, struct file *filp)
                                /* suppress POLLHUP until we have
                                 * seen a writer */
                                filp->f_version = pipe->w_counter;
-                       } else 
-                       {
+                       } else {
                                wait_for_partner(inode, &pipe->w_counter);
                                if(signal_pending(current))
                                        goto err_rd;
@@ -75,7 +74,7 @@ static int fifo_open(struct inode *inode, struct file *filp)
                }
                break;
        
-       case 2:
+       case FMODE_WRITE:
        /*
         *  O_WRONLY
         *  POSIX.1 says that O_NONBLOCK means return -1 with
@@ -85,7 +84,7 @@ static int fifo_open(struct inode *inode, struct file *filp)
                if ((filp->f_flags & O_NONBLOCK) && !pipe->readers)
                        goto err;
 
-               filp->f_op = &write_fifo_fops;
+               filp->f_op = &write_pipefifo_fops;
                pipe->w_counter++;
                if (!pipe->writers++)
                        wake_up_partner(inode);
@@ -97,14 +96,14 @@ static int fifo_open(struct inode *inode, struct file *filp)
                }
                break;
        
-       case 3:
+       case FMODE_READ | FMODE_WRITE:
        /*
         *  O_RDWR
         *  POSIX.1 leaves this case "undefined" when O_NONBLOCK is set.
         *  This implementation will NEVER block on a O_RDWR open, since
         *  the process can at least talk to itself.
         */
-               filp->f_op = &rdwr_fifo_fops;
+               filp->f_op = &rdwr_pipefifo_fops;
 
                pipe->readers++;
                pipe->writers++;
@@ -150,5 +149,6 @@ err_nocleanup:
  * depending on the access mode of the file...
  */
 const struct file_operations def_fifo_fops = {
-       .open           = fifo_open,    /* will set read or write pipe_fops */
+       .open           = fifo_open,    /* will set read_ or write_pipefifo_fops */
+       .llseek         = noop_llseek,
 };