Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

[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>

authored by

Denys Vlasenko and committed by
Al Viro
d2d9648e d70b67c8

+15 -50
+4 -4
fs/fifo.c
··· 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 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 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 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 };
+8 -43
fs/pipe.c
··· 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, ··· 792 790 .fasync = pipe_read_fasync, 793 791 }; 794 792 795 - const struct file_operations write_fifo_fops = { 793 + const struct file_operations write_pipefifo_fops = { 796 794 .llseek = no_llseek, 797 795 .read = bad_pipe_r, 798 796 .write = do_sync_write, ··· 804 802 .fasync = pipe_write_fasync, 805 803 }; 806 804 807 - const struct file_operations rdwr_fifo_fops = { 808 - .llseek = no_llseek, 809 - .read = do_sync_read, 810 - .aio_read = pipe_read, 811 - .write = do_sync_write, 812 - .aio_write = pipe_write, 813 - .poll = pipe_poll, 814 - .unlocked_ioctl = pipe_ioctl, 815 - .open = pipe_rdwr_open, 816 - .release = pipe_rdwr_release, 817 - .fasync = pipe_rdwr_fasync, 818 - }; 819 - 820 - static const struct file_operations read_pipe_fops = { 821 - .llseek = no_llseek, 822 - .read = do_sync_read, 823 - .aio_read = pipe_read, 824 - .write = bad_pipe_w, 825 - .poll = pipe_poll, 826 - .unlocked_ioctl = pipe_ioctl, 827 - .open = pipe_read_open, 828 - .release = pipe_read_release, 829 - .fasync = pipe_read_fasync, 830 - }; 831 - 832 - static const struct file_operations write_pipe_fops = { 833 - .llseek = no_llseek, 834 - .read = bad_pipe_r, 835 - .write = do_sync_write, 836 - .aio_write = pipe_write, 837 - .poll = pipe_poll, 838 - .unlocked_ioctl = pipe_ioctl, 839 - .open = pipe_write_open, 840 - .release = pipe_write_release, 841 - .fasync = pipe_write_fasync, 842 - }; 843 - 844 - static const struct file_operations rdwr_pipe_fops = { 805 + const struct file_operations rdwr_pipefifo_fops = { 845 806 .llseek = no_llseek, 846 807 .read = do_sync_read, 847 808 .aio_read = pipe_read, ··· 892 927 inode->i_pipe = pipe; 893 928 894 929 pipe->readers = pipe->writers = 1; 895 - inode->i_fop = &rdwr_pipe_fops; 930 + inode->i_fop = &rdwr_pipefifo_fops; 896 931 897 932 /* 898 933 * Mark the inode dirty from the very beginning, ··· 943 978 d_instantiate(dentry, inode); 944 979 945 980 err = -ENFILE; 946 - f = alloc_file(pipe_mnt, dentry, FMODE_WRITE, &write_pipe_fops); 981 + f = alloc_file(pipe_mnt, dentry, FMODE_WRITE, &write_pipefifo_fops); 947 982 if (!f) 948 983 goto err_dentry; 949 984 f->f_mapping = inode->i_mapping; ··· 985 1020 986 1021 f->f_pos = 0; 987 1022 f->f_flags = O_RDONLY | (flags & O_NONBLOCK); 988 - f->f_op = &read_pipe_fops; 1023 + f->f_op = &read_pipefifo_fops; 989 1024 f->f_mode = FMODE_READ; 990 1025 f->f_version = 0; 991 1026
+3 -3
include/linux/fs.h
··· 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