diff options
Diffstat (limited to 'fs/pipe.c')
-rw-r--r-- | fs/pipe.c | 29 |
1 files changed, 12 insertions, 17 deletions
@@ -974,7 +974,7 @@ struct file *create_write_pipe(int flags) | |||
974 | int err; | 974 | int err; |
975 | struct inode *inode; | 975 | struct inode *inode; |
976 | struct file *f; | 976 | struct file *f; |
977 | struct dentry *dentry; | 977 | struct path path; |
978 | struct qstr name = { .name = "" }; | 978 | struct qstr name = { .name = "" }; |
979 | 979 | ||
980 | err = -ENFILE; | 980 | err = -ENFILE; |
@@ -983,21 +983,22 @@ struct file *create_write_pipe(int flags) | |||
983 | goto err; | 983 | goto err; |
984 | 984 | ||
985 | err = -ENOMEM; | 985 | err = -ENOMEM; |
986 | dentry = d_alloc(pipe_mnt->mnt_sb->s_root, &name); | 986 | path.dentry = d_alloc(pipe_mnt->mnt_sb->s_root, &name); |
987 | if (!dentry) | 987 | if (!path.dentry) |
988 | goto err_inode; | 988 | goto err_inode; |
989 | path.mnt = mntget(pipe_mnt); | ||
989 | 990 | ||
990 | dentry->d_op = &pipefs_dentry_operations; | 991 | path.dentry->d_op = &pipefs_dentry_operations; |
991 | /* | 992 | /* |
992 | * We dont want to publish this dentry into global dentry hash table. | 993 | * We dont want to publish this dentry into global dentry hash table. |
993 | * We pretend dentry is already hashed, by unsetting DCACHE_UNHASHED | 994 | * We pretend dentry is already hashed, by unsetting DCACHE_UNHASHED |
994 | * This permits a working /proc/$pid/fd/XXX on pipes | 995 | * This permits a working /proc/$pid/fd/XXX on pipes |
995 | */ | 996 | */ |
996 | dentry->d_flags &= ~DCACHE_UNHASHED; | 997 | path.dentry->d_flags &= ~DCACHE_UNHASHED; |
997 | d_instantiate(dentry, inode); | 998 | d_instantiate(path.dentry, inode); |
998 | 999 | ||
999 | err = -ENFILE; | 1000 | err = -ENFILE; |
1000 | f = alloc_file(pipe_mnt, dentry, FMODE_WRITE, &write_pipefifo_fops); | 1001 | f = alloc_file(&path, FMODE_WRITE, &write_pipefifo_fops); |
1001 | if (!f) | 1002 | if (!f) |
1002 | goto err_dentry; | 1003 | goto err_dentry; |
1003 | f->f_mapping = inode->i_mapping; | 1004 | f->f_mapping = inode->i_mapping; |
@@ -1009,7 +1010,7 @@ struct file *create_write_pipe(int flags) | |||
1009 | 1010 | ||
1010 | err_dentry: | 1011 | err_dentry: |
1011 | free_pipe_info(inode); | 1012 | free_pipe_info(inode); |
1012 | dput(dentry); | 1013 | path_put(&path); |
1013 | return ERR_PTR(err); | 1014 | return ERR_PTR(err); |
1014 | 1015 | ||
1015 | err_inode: | 1016 | err_inode: |
@@ -1028,20 +1029,14 @@ void free_write_pipe(struct file *f) | |||
1028 | 1029 | ||
1029 | struct file *create_read_pipe(struct file *wrf, int flags) | 1030 | struct file *create_read_pipe(struct file *wrf, int flags) |
1030 | { | 1031 | { |
1031 | struct file *f = get_empty_filp(); | 1032 | /* Grab pipe from the writer */ |
1033 | struct file *f = alloc_file(&wrf->f_path, FMODE_READ, | ||
1034 | &read_pipefifo_fops); | ||
1032 | if (!f) | 1035 | if (!f) |
1033 | return ERR_PTR(-ENFILE); | 1036 | return ERR_PTR(-ENFILE); |
1034 | 1037 | ||
1035 | /* Grab pipe from the writer */ | ||
1036 | f->f_path = wrf->f_path; | ||
1037 | path_get(&wrf->f_path); | 1038 | path_get(&wrf->f_path); |
1038 | f->f_mapping = wrf->f_path.dentry->d_inode->i_mapping; | ||
1039 | |||
1040 | f->f_pos = 0; | ||
1041 | f->f_flags = O_RDONLY | (flags & O_NONBLOCK); | 1039 | f->f_flags = O_RDONLY | (flags & O_NONBLOCK); |
1042 | f->f_op = &read_pipefifo_fops; | ||
1043 | f->f_mode = FMODE_READ; | ||
1044 | f->f_version = 0; | ||
1045 | 1040 | ||
1046 | return f; | 1041 | return f; |
1047 | } | 1042 | } |