diff options
Diffstat (limited to 'fs/autofs4')
-rw-r--r-- | fs/autofs4/root.c | 23 |
1 files changed, 19 insertions, 4 deletions
diff --git a/fs/autofs4/root.c b/fs/autofs4/root.c index 47adf270106a..b4631046867e 100644 --- a/fs/autofs4/root.c +++ b/fs/autofs4/root.c | |||
@@ -655,14 +655,29 @@ static struct dentry *autofs4_lookup(struct inode *dir, struct dentry *dentry, s | |||
655 | 655 | ||
656 | /* | 656 | /* |
657 | * If this dentry is unhashed, then we shouldn't honour this | 657 | * If this dentry is unhashed, then we shouldn't honour this |
658 | * lookup even if the dentry is positive. Returning ENOENT here | 658 | * lookup. Returning ENOENT here doesn't do the right thing |
659 | * doesn't do the right thing for all system calls, but it should | 659 | * for all system calls, but it should be OK for the operations |
660 | * be OK for the operations we permit from an autofs. | 660 | * we permit from an autofs. |
661 | */ | 661 | */ |
662 | if (dentry->d_inode && d_unhashed(dentry)) { | 662 | if (dentry->d_inode && d_unhashed(dentry)) { |
663 | /* | ||
664 | * A user space application can (and has done in the past) | ||
665 | * remove and re-create this directory during the callback. | ||
666 | * This can leave us with an unhashed dentry, but a | ||
667 | * successful mount! So we need to perform another | ||
668 | * cached lookup in case the dentry now exists. | ||
669 | */ | ||
670 | struct dentry *parent = dentry->d_parent; | ||
671 | struct dentry *new = d_lookup(parent, &dentry->d_name); | ||
672 | if (new != NULL) | ||
673 | dentry = new; | ||
674 | else | ||
675 | dentry = ERR_PTR(-ENOENT); | ||
676 | |||
663 | if (unhashed) | 677 | if (unhashed) |
664 | dput(unhashed); | 678 | dput(unhashed); |
665 | return ERR_PTR(-ENOENT); | 679 | |
680 | return dentry; | ||
666 | } | 681 | } |
667 | 682 | ||
668 | if (unhashed) | 683 | if (unhashed) |