Commit d2d9648ec6858e19d16a0b16da62534e85888653
Committed by
Al Viro
1 parent
d70b67c8bc
Exists in
master
and in
39 other branches
[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>
Showing 3 changed files with 15 additions and 50 deletions Side-by-side Diff
fs/fifo.c
... | ... | @@ -57,7 +57,7 @@ |
57 | 57 | * POSIX.1 says that O_NONBLOCK means return with the FIFO |
58 | 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 | 61 | pipe->r_counter++; |
62 | 62 | if (pipe->readers++ == 0) |
63 | 63 | wake_up_partner(inode); |
... | ... | @@ -86,7 +86,7 @@ |
86 | 86 | if ((filp->f_flags & O_NONBLOCK) && !pipe->readers) |
87 | 87 | goto err; |
88 | 88 | |
89 | - filp->f_op = &write_fifo_fops; | |
89 | + filp->f_op = &write_pipefifo_fops; | |
90 | 90 | pipe->w_counter++; |
91 | 91 | if (!pipe->writers++) |
92 | 92 | wake_up_partner(inode); |
... | ... | @@ -105,7 +105,7 @@ |
105 | 105 | * This implementation will NEVER block on a O_RDWR open, since |
106 | 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 | 110 | pipe->readers++; |
111 | 111 | pipe->writers++; |
... | ... | @@ -151,6 +151,6 @@ |
151 | 151 | * depending on the access mode of the file... |
152 | 152 | */ |
153 | 153 | const 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 | }; |
fs/pipe.c
... | ... | @@ -777,8 +777,10 @@ |
777 | 777 | /* |
778 | 778 | * The file_operations structs are not static because they |
779 | 779 | * are also used in linux/fs/fifo.c to do operations on FIFOs. |
780 | + * | |
781 | + * Pipes reuse fifos' file_operations structs. | |
780 | 782 | */ |
781 | -const struct file_operations read_fifo_fops = { | |
783 | +const struct file_operations read_pipefifo_fops = { | |
782 | 784 | .llseek = no_llseek, |
783 | 785 | .read = do_sync_read, |
784 | 786 | .aio_read = pipe_read, |
... | ... | @@ -790,7 +792,7 @@ |
790 | 792 | .fasync = pipe_read_fasync, |
791 | 793 | }; |
792 | 794 | |
793 | -const struct file_operations write_fifo_fops = { | |
795 | +const struct file_operations write_pipefifo_fops = { | |
794 | 796 | .llseek = no_llseek, |
795 | 797 | .read = bad_pipe_r, |
796 | 798 | .write = do_sync_write, |
... | ... | @@ -802,7 +804,7 @@ |
802 | 804 | .fasync = pipe_write_fasync, |
803 | 805 | }; |
804 | 806 | |
805 | -const struct file_operations rdwr_fifo_fops = { | |
807 | +const struct file_operations rdwr_pipefifo_fops = { | |
806 | 808 | .llseek = no_llseek, |
807 | 809 | .read = do_sync_read, |
808 | 810 | .aio_read = pipe_read, |
... | ... | @@ -815,43 +817,6 @@ |
815 | 817 | .fasync = pipe_rdwr_fasync, |
816 | 818 | }; |
817 | 819 | |
818 | -static const struct file_operations read_pipe_fops = { | |
819 | - .llseek = no_llseek, | |
820 | - .read = do_sync_read, | |
821 | - .aio_read = pipe_read, | |
822 | - .write = bad_pipe_w, | |
823 | - .poll = pipe_poll, | |
824 | - .unlocked_ioctl = pipe_ioctl, | |
825 | - .open = pipe_read_open, | |
826 | - .release = pipe_read_release, | |
827 | - .fasync = pipe_read_fasync, | |
828 | -}; | |
829 | - | |
830 | -static const struct file_operations write_pipe_fops = { | |
831 | - .llseek = no_llseek, | |
832 | - .read = bad_pipe_r, | |
833 | - .write = do_sync_write, | |
834 | - .aio_write = pipe_write, | |
835 | - .poll = pipe_poll, | |
836 | - .unlocked_ioctl = pipe_ioctl, | |
837 | - .open = pipe_write_open, | |
838 | - .release = pipe_write_release, | |
839 | - .fasync = pipe_write_fasync, | |
840 | -}; | |
841 | - | |
842 | -static const struct file_operations rdwr_pipe_fops = { | |
843 | - .llseek = no_llseek, | |
844 | - .read = do_sync_read, | |
845 | - .aio_read = pipe_read, | |
846 | - .write = do_sync_write, | |
847 | - .aio_write = pipe_write, | |
848 | - .poll = pipe_poll, | |
849 | - .unlocked_ioctl = pipe_ioctl, | |
850 | - .open = pipe_rdwr_open, | |
851 | - .release = pipe_rdwr_release, | |
852 | - .fasync = pipe_rdwr_fasync, | |
853 | -}; | |
854 | - | |
855 | 820 | struct pipe_inode_info * alloc_pipe_info(struct inode *inode) |
856 | 821 | { |
857 | 822 | struct pipe_inode_info *pipe; |
... | ... | @@ -927,7 +892,7 @@ |
927 | 892 | inode->i_pipe = pipe; |
928 | 893 | |
929 | 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 | 898 | * Mark the inode dirty from the very beginning, |
... | ... | @@ -978,7 +943,7 @@ |
978 | 943 | d_instantiate(dentry, inode); |
979 | 944 | |
980 | 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 | 947 | if (!f) |
983 | 948 | goto err_dentry; |
984 | 949 | f->f_mapping = inode->i_mapping; |
... | ... | @@ -1020,7 +985,7 @@ |
1020 | 985 | |
1021 | 986 | f->f_pos = 0; |
1022 | 987 | f->f_flags = O_RDONLY | (flags & O_NONBLOCK); |
1023 | - f->f_op = &read_pipe_fops; | |
988 | + f->f_op = &read_pipefifo_fops; | |
1024 | 989 | f->f_mode = FMODE_READ; |
1025 | 990 | f->f_version = 0; |
1026 | 991 |
include/linux/fs.h
... | ... | @@ -1696,9 +1696,9 @@ |
1696 | 1696 | extern void make_bad_inode(struct inode *); |
1697 | 1697 | extern int is_bad_inode(struct inode *); |
1698 | 1698 | |
1699 | -extern const struct file_operations read_fifo_fops; | |
1700 | -extern const struct file_operations write_fifo_fops; | |
1701 | -extern const struct file_operations rdwr_fifo_fops; | |
1699 | +extern const struct file_operations read_pipefifo_fops; | |
1700 | +extern const struct file_operations write_pipefifo_fops; | |
1701 | +extern const struct file_operations rdwr_pipefifo_fops; | |
1702 | 1702 | |
1703 | 1703 | extern int fs_may_remount_ro(struct super_block *); |
1704 | 1704 |