aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2008-07-01 08:16:09 -0400
committerAl Viro <viro@zeniv.linux.org.uk>2008-07-26 20:53:06 -0400
commitd2d9648ec6858e19d16a0b16da62534e85888653 (patch)
treeba3d66e3ed90ef56ec58e699beeb487db930375b /fs
parentd70b67c8bc72ee23b55381bd6a884f4796692f77 (diff)
[PATCH] reuse xxx_fifo_fops for xxx_pipe_fops
Merge fifo and pipe file_operations. Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com> Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'fs')
-rw-r--r--fs/fifo.c8
-rw-r--r--fs/pipe.c51
2 files changed, 12 insertions, 47 deletions
diff --git a/fs/fifo.c b/fs/fifo.c
index 9785e36f81e7..987bf9411495 100644
--- a/fs/fifo.c
+++ b/fs/fifo.c
@@ -57,7 +57,7 @@ static int fifo_open(struct inode *inode, struct file *filp)
57 * POSIX.1 says that O_NONBLOCK means return with the FIFO 57 * POSIX.1 says that O_NONBLOCK means return with the FIFO
58 * opened, even when there is no process writing the FIFO. 58 * opened, even when there is no process writing the FIFO.
59 */ 59 */
60 filp->f_op = &read_fifo_fops; 60 filp->f_op = &read_pipefifo_fops;
61 pipe->r_counter++; 61 pipe->r_counter++;
62 if (pipe->readers++ == 0) 62 if (pipe->readers++ == 0)
63 wake_up_partner(inode); 63 wake_up_partner(inode);
@@ -86,7 +86,7 @@ static int fifo_open(struct inode *inode, struct file *filp)
86 if ((filp->f_flags & O_NONBLOCK) && !pipe->readers) 86 if ((filp->f_flags & O_NONBLOCK) && !pipe->readers)
87 goto err; 87 goto err;
88 88
89 filp->f_op = &write_fifo_fops; 89 filp->f_op = &write_pipefifo_fops;
90 pipe->w_counter++; 90 pipe->w_counter++;
91 if (!pipe->writers++) 91 if (!pipe->writers++)
92 wake_up_partner(inode); 92 wake_up_partner(inode);
@@ -105,7 +105,7 @@ static int fifo_open(struct inode *inode, struct file *filp)
105 * This implementation will NEVER block on a O_RDWR open, since 105 * This implementation will NEVER block on a O_RDWR open, since
106 * the process can at least talk to itself. 106 * the process can at least talk to itself.
107 */ 107 */
108 filp->f_op = &rdwr_fifo_fops; 108 filp->f_op = &rdwr_pipefifo_fops;
109 109
110 pipe->readers++; 110 pipe->readers++;
111 pipe->writers++; 111 pipe->writers++;
@@ -151,5 +151,5 @@ err_nocleanup:
151 * depending on the access mode of the file... 151 * depending on the access mode of the file...
152 */ 152 */
153const struct file_operations def_fifo_fops = { 153const struct file_operations def_fifo_fops = {
154 .open = fifo_open, /* will set read or write pipe_fops */ 154 .open = fifo_open, /* will set read_ or write_pipefifo_fops */
155}; 155};
diff --git a/fs/pipe.c b/fs/pipe.c
index 10c4e9aa5c49..fcba6542b8d0 100644
--- a/fs/pipe.c
+++ b/fs/pipe.c
@@ -777,45 +777,10 @@ pipe_rdwr_open(struct inode *inode, struct file *filp)
777/* 777/*
778 * The file_operations structs are not static because they 778 * The file_operations structs are not static because they
779 * are also used in linux/fs/fifo.c to do operations on FIFOs. 779 * are also used in linux/fs/fifo.c to do operations on FIFOs.
780 *
781 * Pipes reuse fifos' file_operations structs.
780 */ 782 */
781const struct file_operations read_fifo_fops = { 783const struct file_operations read_pipefifo_fops = {
782 .llseek = no_llseek,
783 .read = do_sync_read,
784 .aio_read = pipe_read,
785 .write = bad_pipe_w,
786 .poll = pipe_poll,
787 .unlocked_ioctl = pipe_ioctl,
788 .open = pipe_read_open,
789 .release = pipe_read_release,
790 .fasync = pipe_read_fasync,
791};
792
793const struct file_operations write_fifo_fops = {
794 .llseek = no_llseek,
795 .read = bad_pipe_r,
796 .write = do_sync_write,
797 .aio_write = pipe_write,
798 .poll = pipe_poll,
799 .unlocked_ioctl = pipe_ioctl,
800 .open = pipe_write_open,
801 .release = pipe_write_release,
802 .fasync = pipe_write_fasync,
803};
804
805const struct file_operations rdwr_fifo_fops = {
806 .llseek = no_llseek,
807 .read = do_sync_read,
808 .aio_read = pipe_read,
809 .write = do_sync_write,
810 .aio_write = pipe_write,
811 .poll = pipe_poll,
812 .unlocked_ioctl = pipe_ioctl,
813 .open = pipe_rdwr_open,
814 .release = pipe_rdwr_release,
815 .fasync = pipe_rdwr_fasync,
816};
817
818static const struct file_operations read_pipe_fops = {
819 .llseek = no_llseek, 784 .llseek = no_llseek,
820 .read = do_sync_read, 785 .read = do_sync_read,
821 .aio_read = pipe_read, 786 .aio_read = pipe_read,
@@ -827,7 +792,7 @@ static const struct file_operations read_pipe_fops = {
827 .fasync = pipe_read_fasync, 792 .fasync = pipe_read_fasync,
828}; 793};
829 794
830static const struct file_operations write_pipe_fops = { 795const struct file_operations write_pipefifo_fops = {
831 .llseek = no_llseek, 796 .llseek = no_llseek,
832 .read = bad_pipe_r, 797 .read = bad_pipe_r,
833 .write = do_sync_write, 798 .write = do_sync_write,
@@ -839,7 +804,7 @@ static const struct file_operations write_pipe_fops = {
839 .fasync = pipe_write_fasync, 804 .fasync = pipe_write_fasync,
840}; 805};
841 806
842static const struct file_operations rdwr_pipe_fops = { 807const struct file_operations rdwr_pipefifo_fops = {
843 .llseek = no_llseek, 808 .llseek = no_llseek,
844 .read = do_sync_read, 809 .read = do_sync_read,
845 .aio_read = pipe_read, 810 .aio_read = pipe_read,
@@ -927,7 +892,7 @@ static struct inode * get_pipe_inode(void)
927 inode->i_pipe = pipe; 892 inode->i_pipe = pipe;
928 893
929 pipe->readers = pipe->writers = 1; 894 pipe->readers = pipe->writers = 1;
930 inode->i_fop = &rdwr_pipe_fops; 895 inode->i_fop = &rdwr_pipefifo_fops;
931 896
932 /* 897 /*
933 * Mark the inode dirty from the very beginning, 898 * Mark the inode dirty from the very beginning,
@@ -978,7 +943,7 @@ struct file *create_write_pipe(int flags)
978 d_instantiate(dentry, inode); 943 d_instantiate(dentry, inode);
979 944
980 err = -ENFILE; 945 err = -ENFILE;
981 f = alloc_file(pipe_mnt, dentry, FMODE_WRITE, &write_pipe_fops); 946 f = alloc_file(pipe_mnt, dentry, FMODE_WRITE, &write_pipefifo_fops);
982 if (!f) 947 if (!f)
983 goto err_dentry; 948 goto err_dentry;
984 f->f_mapping = inode->i_mapping; 949 f->f_mapping = inode->i_mapping;
@@ -1020,7 +985,7 @@ struct file *create_read_pipe(struct file *wrf, int flags)
1020 985
1021 f->f_pos = 0; 986 f->f_pos = 0;
1022 f->f_flags = O_RDONLY | (flags & O_NONBLOCK); 987 f->f_flags = O_RDONLY | (flags & O_NONBLOCK);
1023 f->f_op = &read_pipe_fops; 988 f->f_op = &read_pipefifo_fops;
1024 f->f_mode = FMODE_READ; 989 f->f_mode = FMODE_READ;
1025 f->f_version = 0; 990 f->f_version = 0;
1026 991