patch-2.3.9 linux/fs/pipe.c
Next file: linux/fs/proc/array.c
Previous file: linux/fs/open.c
Back to the patch index
Back to the overall index
- Lines: 88
- Date:
Mon Jun 28 14:56:19 1999
- Orig file:
v2.3.8/linux/fs/pipe.c
- Orig date:
Sat Jun 19 11:45:28 1999
diff -u --recursive --new-file v2.3.8/linux/fs/pipe.c linux/fs/pipe.c
@@ -8,6 +8,7 @@
#include <linux/file.h>
#include <linux/poll.h>
#include <linux/malloc.h>
+#include <linux/smp_lock.h>
#include <asm/uaccess.h>
@@ -28,16 +29,12 @@
/* in case of paging and multiple read/write on the same pipe. (FGC) */
-static ssize_t pipe_read(struct file * filp, char * buf,
- size_t count, loff_t *ppos)
+static ssize_t do_pipe_read(struct file * filp, char * buf, size_t count)
{
struct inode * inode = filp->f_dentry->d_inode;
ssize_t chars = 0, size = 0, read = 0;
char *pipebuf;
- if (ppos != &filp->f_pos)
- return -ESPIPE;
-
if (filp->f_flags & O_NONBLOCK) {
if (PIPE_LOCK(*inode))
return -EAGAIN;
@@ -82,17 +79,13 @@
return -EAGAIN;
return 0;
}
-
-static ssize_t pipe_write(struct file * filp, const char * buf,
- size_t count, loff_t *ppos)
+
+static ssize_t do_pipe_write(struct file * filp, const char * buf, size_t count)
{
struct inode * inode = filp->f_dentry->d_inode;
ssize_t chars = 0, free = 0, written = 0, err=0;
char *pipebuf;
- if (ppos != &filp->f_pos)
- return -ESPIPE;
-
if (!PIPE_READERS(*inode)) { /* no readers */
send_sig(SIGPIPE,current,0);
return -EPIPE;
@@ -147,6 +140,32 @@
return written ? written : err;
}
+static ssize_t pipe_read(struct file * filp, char * buf, size_t count, loff_t *ppos)
+{
+ ssize_t retval;
+
+ if (ppos != &filp->f_pos)
+ return -ESPIPE;
+
+ lock_kernel();
+ retval = do_pipe_read(filp, buf, count);
+ unlock_kernel();
+ return retval;
+}
+
+static ssize_t pipe_write(struct file * filp, const char * buf, size_t count, loff_t *ppos)
+{
+ ssize_t retval;
+
+ if (ppos != &filp->f_pos)
+ return -ESPIPE;
+
+ lock_kernel();
+ retval = do_pipe_write(filp, buf, count);
+ unlock_kernel();
+ return retval;
+}
+
static long long pipe_lseek(struct file * file, long long offset, int orig)
{
return -ESPIPE;
@@ -461,7 +480,7 @@
NULL, /* mknod */
NULL, /* rename */
NULL, /* readlink */
- NULL, /* bmap */
+ NULL, /* get_block */
NULL, /* readpage */
NULL, /* writepage */
NULL, /* flushpage */
FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)