diff options
-rw-r--r-- | fs/pipe.c | 22 |
1 files changed, 17 insertions, 5 deletions
@@ -830,7 +830,14 @@ void free_pipe_info(struct inode *inode) | |||
830 | static struct vfsmount *pipe_mnt __read_mostly; | 830 | static struct vfsmount *pipe_mnt __read_mostly; |
831 | static int pipefs_delete_dentry(struct dentry *dentry) | 831 | static int pipefs_delete_dentry(struct dentry *dentry) |
832 | { | 832 | { |
833 | return 1; | 833 | /* |
834 | * At creation time, we pretended this dentry was hashed | ||
835 | * (by clearing DCACHE_UNHASHED bit in d_flags) | ||
836 | * At delete time, we restore the truth : not hashed. | ||
837 | * (so that dput() can proceed correctly) | ||
838 | */ | ||
839 | dentry->d_flags |= DCACHE_UNHASHED; | ||
840 | return 0; | ||
834 | } | 841 | } |
835 | 842 | ||
836 | static struct dentry_operations pipefs_dentry_operations = { | 843 | static struct dentry_operations pipefs_dentry_operations = { |
@@ -891,17 +898,22 @@ struct file *create_write_pipe(void) | |||
891 | if (!inode) | 898 | if (!inode) |
892 | goto err_file; | 899 | goto err_file; |
893 | 900 | ||
894 | sprintf(name, "[%lu]", inode->i_ino); | 901 | this.len = sprintf(name, "[%lu]", inode->i_ino); |
895 | this.name = name; | 902 | this.name = name; |
896 | this.len = strlen(name); | 903 | this.hash = 0; |
897 | this.hash = inode->i_ino; /* will go */ | ||
898 | err = -ENOMEM; | 904 | err = -ENOMEM; |
899 | dentry = d_alloc(pipe_mnt->mnt_sb->s_root, &this); | 905 | dentry = d_alloc(pipe_mnt->mnt_sb->s_root, &this); |
900 | if (!dentry) | 906 | if (!dentry) |
901 | goto err_inode; | 907 | goto err_inode; |
902 | 908 | ||
903 | dentry->d_op = &pipefs_dentry_operations; | 909 | dentry->d_op = &pipefs_dentry_operations; |
904 | d_add(dentry, inode); | 910 | /* |
911 | * We dont want to publish this dentry into global dentry hash table. | ||
912 | * We pretend dentry is already hashed, by unsetting DCACHE_UNHASHED | ||
913 | * This permits a working /proc/$pid/fd/XXX on pipes | ||
914 | */ | ||
915 | dentry->d_flags &= ~DCACHE_UNHASHED; | ||
916 | d_instantiate(dentry, inode); | ||
905 | f->f_vfsmnt = mntget(pipe_mnt); | 917 | f->f_vfsmnt = mntget(pipe_mnt); |
906 | f->f_dentry = dentry; | 918 | f->f_dentry = dentry; |
907 | f->f_mapping = inode->i_mapping; | 919 | f->f_mapping = inode->i_mapping; |