@@ -878,6 +878,8 @@ static const struct dentry_operations pipefs_dentry_operations = {
878878 .d_dname = pipefs_dname ,
879879};
880880
881+ static const struct file_operations pipeanon_fops ;
882+
881883static struct inode * get_pipe_inode (void )
882884{
883885 struct inode * inode = new_inode_pseudo (pipe_mnt -> mnt_sb );
@@ -895,7 +897,7 @@ static struct inode * get_pipe_inode(void)
895897 inode -> i_pipe = pipe ;
896898 pipe -> files = 2 ;
897899 pipe -> readers = pipe -> writers = 1 ;
898- inode -> i_fop = & pipefifo_fops ;
900+ inode -> i_fop = & pipeanon_fops ;
899901
900902 /*
901903 * Mark the inode dirty from the very beginning,
@@ -938,7 +940,7 @@ int create_pipe_files(struct file **res, int flags)
938940
939941 f = alloc_file_pseudo (inode , pipe_mnt , "" ,
940942 O_WRONLY | (flags & (O_NONBLOCK | O_DIRECT )),
941- & pipefifo_fops );
943+ & pipeanon_fops );
942944 if (IS_ERR (f )) {
943945 free_pipe_info (inode -> i_pipe );
944946 iput (inode );
@@ -949,7 +951,7 @@ int create_pipe_files(struct file **res, int flags)
949951 f -> f_pipe = 0 ;
950952
951953 res [0 ] = alloc_file_clone (f , O_RDONLY | (flags & O_NONBLOCK ),
952- & pipefifo_fops );
954+ & pipeanon_fops );
953955 if (IS_ERR (res [0 ])) {
954956 put_pipe_info (inode , inode -> i_pipe );
955957 fput (f );
@@ -1107,8 +1109,8 @@ static void wake_up_partner(struct pipe_inode_info *pipe)
11071109
11081110static int fifo_open (struct inode * inode , struct file * filp )
11091111{
1112+ bool is_pipe = inode -> i_fop == & pipeanon_fops ;
11101113 struct pipe_inode_info * pipe ;
1111- bool is_pipe = inode -> i_sb -> s_magic == PIPEFS_MAGIC ;
11121114 int ret ;
11131115
11141116 filp -> f_pipe = 0 ;
@@ -1241,6 +1243,17 @@ const struct file_operations pipefifo_fops = {
12411243 .splice_write = iter_file_splice_write ,
12421244};
12431245
1246+ static const struct file_operations pipeanon_fops = {
1247+ .open = fifo_open ,
1248+ .read_iter = pipe_read ,
1249+ .write_iter = pipe_write ,
1250+ .poll = pipe_poll ,
1251+ .unlocked_ioctl = pipe_ioctl ,
1252+ .release = pipe_release ,
1253+ .fasync = pipe_fasync ,
1254+ .splice_write = iter_file_splice_write ,
1255+ };
1256+
12441257/*
12451258 * Currently we rely on the pipe array holding a power-of-2 number
12461259 * of pages. Returns 0 on error.
@@ -1388,7 +1401,9 @@ struct pipe_inode_info *get_pipe_info(struct file *file, bool for_splice)
13881401{
13891402 struct pipe_inode_info * pipe = file -> private_data ;
13901403
1391- if (file -> f_op != & pipefifo_fops || !pipe )
1404+ if (!pipe )
1405+ return NULL ;
1406+ if (file -> f_op != & pipefifo_fops && file -> f_op != & pipeanon_fops )
13921407 return NULL ;
13931408 if (for_splice && pipe_has_watch_queue (pipe ))
13941409 return NULL ;
0 commit comments