patch-1.3.44 linux/fs/pipe.c

Next file: linux/fs/proc/fd.c
Previous file: linux/fs/nfs/nfsroot.c
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v1.3.43/linux/fs/pipe.c linux/fs/pipe.c
@@ -240,10 +240,6 @@
 	return 0;
 }
 
-/*
- * Ok, these three routines NOW keep track of readers/writers,
- * Linus previously did it with inode->i_count checking.
- */
 static void pipe_read_release(struct inode * inode, struct file * filp)
 {
 	PIPE_READERS(*inode)--;
@@ -263,6 +259,25 @@
 	wake_up_interruptible(&PIPE_WAIT(*inode));
 }
 
+static int pipe_read_open(struct inode * inode, struct file * filp)
+{
+	PIPE_READERS(*inode)++;
+	return 0;
+}
+
+static int pipe_write_open(struct inode * inode, struct file * filp)
+{
+	PIPE_WRITERS(*inode)++;
+	return 0;
+}
+
+static int pipe_rdwr_open(struct inode * inode, struct file * filp)
+{
+	PIPE_READERS(*inode)++;
+	PIPE_WRITERS(*inode)++;
+	return 0;
+}
+
 /*
  * The file_operations structs are not static because they
  * are also used in linux/fs/fifo.c to do operations on fifo's.
@@ -275,7 +290,7 @@
 	connect_select,
 	pipe_ioctl,
 	NULL,		/* no mmap on pipes.. surprise */
-	NULL,		/* no special open code */
+	pipe_read_open,
 	pipe_read_release,
 	NULL
 };
@@ -288,7 +303,7 @@
 	fifo_select,
 	pipe_ioctl,
 	NULL,		/* no mmap on pipes.. surprise */
-	NULL,		/* no special open code */
+	pipe_read_open,
 	pipe_read_release,
 	NULL
 };
@@ -301,7 +316,7 @@
 	fifo_select,
 	pipe_ioctl,
 	NULL,		/* mmap */
-	NULL,		/* no special open code */
+	pipe_write_open,
 	pipe_write_release,
 	NULL
 };
@@ -314,7 +329,7 @@
 	fifo_select,
 	pipe_ioctl,
 	NULL,		/* mmap */
-	NULL,		/* no special open code */
+	pipe_rdwr_open,
 	pipe_rdwr_release,
 	NULL
 };
@@ -327,7 +342,7 @@
 	pipe_select,
 	pipe_ioctl,
 	NULL,		/* no mmap on pipes.. surprise */
-	NULL,		/* no special open code */
+	pipe_read_open,
 	pipe_read_release,
 	NULL
 };
@@ -340,7 +355,7 @@
 	pipe_select,
 	pipe_ioctl,
 	NULL,		/* mmap */
-	NULL,		/* no special open code */
+	pipe_write_open,
 	pipe_write_release,
 	NULL
 };
@@ -353,7 +368,7 @@
 	pipe_select,
 	pipe_ioctl,
 	NULL,		/* mmap */
-	NULL,		/* no special open code */
+	pipe_rdwr_open,
 	pipe_rdwr_release,
 	NULL
 };

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen, slshen@lbl.gov with Sam's (original) version
of this