Commit 3e297b613491f0d4928aa652a2cd266aa06dc409
1 parent
01e77706cd
Exists in
master
and in
7 other branches
Restore LOOKUP_DIRECTORY hint handling in final lookup on open()
Lose want_dir argument, while we are at it - since now nd->flags & LOOKUP_DIRECTORY is equivalent to it. Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Showing 1 changed file with 10 additions and 8 deletions Side-by-side Diff
fs/namei.c
... | ... | @@ -1610,8 +1610,7 @@ |
1610 | 1610 | |
1611 | 1611 | static struct file *do_last(struct nameidata *nd, struct path *path, |
1612 | 1612 | int open_flag, int acc_mode, |
1613 | - int mode, const char *pathname, | |
1614 | - int *want_dir) | |
1613 | + int mode, const char *pathname) | |
1615 | 1614 | { |
1616 | 1615 | struct dentry *dir = nd->path.dentry; |
1617 | 1616 | struct file *filp; |
... | ... | @@ -1642,7 +1641,7 @@ |
1642 | 1641 | if (nd->last.name[nd->last.len]) { |
1643 | 1642 | if (open_flag & O_CREAT) |
1644 | 1643 | goto exit; |
1645 | - *want_dir = 1; | |
1644 | + nd->flags |= LOOKUP_DIRECTORY; | |
1646 | 1645 | } |
1647 | 1646 | |
1648 | 1647 | /* just plain open? */ |
... | ... | @@ -1656,8 +1655,10 @@ |
1656 | 1655 | if (path->dentry->d_inode->i_op->follow_link) |
1657 | 1656 | return NULL; |
1658 | 1657 | error = -ENOTDIR; |
1659 | - if (*want_dir && !path->dentry->d_inode->i_op->lookup) | |
1660 | - goto exit_dput; | |
1658 | + if (nd->flags & LOOKUP_DIRECTORY) { | |
1659 | + if (!path->dentry->d_inode->i_op->lookup) | |
1660 | + goto exit_dput; | |
1661 | + } | |
1661 | 1662 | path_to_nameidata(path, nd); |
1662 | 1663 | audit_inode(pathname, nd->path.dentry); |
1663 | 1664 | goto ok; |
... | ... | @@ -1766,7 +1767,6 @@ |
1766 | 1767 | int count = 0; |
1767 | 1768 | int flag = open_to_namei_flags(open_flag); |
1768 | 1769 | int force_reval = 0; |
1769 | - int want_dir = open_flag & O_DIRECTORY; | |
1770 | 1770 | |
1771 | 1771 | if (!(open_flag & O_CREAT)) |
1772 | 1772 | mode = 0; |
... | ... | @@ -1828,7 +1828,9 @@ |
1828 | 1828 | if (open_flag & O_EXCL) |
1829 | 1829 | nd.flags |= LOOKUP_EXCL; |
1830 | 1830 | } |
1831 | - filp = do_last(&nd, &path, open_flag, acc_mode, mode, pathname, &want_dir); | |
1831 | + if (open_flag & O_DIRECTORY) | |
1832 | + nd.flags |= LOOKUP_DIRECTORY; | |
1833 | + filp = do_last(&nd, &path, open_flag, acc_mode, mode, pathname); | |
1832 | 1834 | while (unlikely(!filp)) { /* trailing symlink */ |
1833 | 1835 | struct path holder; |
1834 | 1836 | struct inode *inode = path.dentry->d_inode; |
... | ... | @@ -1866,7 +1868,7 @@ |
1866 | 1868 | } |
1867 | 1869 | holder = path; |
1868 | 1870 | nd.flags &= ~LOOKUP_PARENT; |
1869 | - filp = do_last(&nd, &path, open_flag, acc_mode, mode, pathname, &want_dir); | |
1871 | + filp = do_last(&nd, &path, open_flag, acc_mode, mode, pathname); | |
1870 | 1872 | if (inode->i_op->put_link) |
1871 | 1873 | inode->i_op->put_link(holder.dentry, &nd, cookie); |
1872 | 1874 | path_put(&holder); |