diff options
author | Al Viro <viro@zeniv.linux.org.uk> | 2009-12-24 02:12:06 -0500 |
---|---|---|
committer | Al Viro <viro@zeniv.linux.org.uk> | 2010-03-05 09:01:20 -0500 |
commit | a1e28038df98e186807ff55a49c1c26d33d530a5 (patch) | |
tree | a72a14858ae883b333b4a0cf6bbf52d33a6bdb82 /fs/namei.c | |
parent | c41c14056210e4a328659c82b1edaccb0910d18c (diff) |
pull the common predecessors into do_last()
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'fs/namei.c')
-rw-r--r-- | fs/namei.c | 21 |
1 files changed, 9 insertions, 12 deletions
diff --git a/fs/namei.c b/fs/namei.c index 30ba3f3a25e2..976fc323272e 100644 --- a/fs/namei.c +++ b/fs/namei.c | |||
@@ -1648,13 +1648,19 @@ exit: | |||
1648 | static struct file *do_last(struct nameidata *nd, struct path *path, | 1648 | static struct file *do_last(struct nameidata *nd, struct path *path, |
1649 | int open_flag, int flag, int acc_mode, | 1649 | int open_flag, int flag, int acc_mode, |
1650 | int mode, const char *pathname, | 1650 | int mode, const char *pathname, |
1651 | struct dentry *dir, int *is_link) | 1651 | int *is_link) |
1652 | { | 1652 | { |
1653 | struct dentry *dir = nd->path.dentry; | ||
1653 | struct file *filp; | 1654 | struct file *filp; |
1654 | int error; | 1655 | int error; |
1655 | 1656 | ||
1656 | *is_link = 0; | 1657 | *is_link = 0; |
1657 | 1658 | ||
1659 | mutex_lock(&dir->d_inode->i_mutex); | ||
1660 | |||
1661 | path->dentry = lookup_hash(nd); | ||
1662 | path->mnt = nd->path.mnt; | ||
1663 | |||
1658 | error = PTR_ERR(path->dentry); | 1664 | error = PTR_ERR(path->dentry); |
1659 | if (IS_ERR(path->dentry)) { | 1665 | if (IS_ERR(path->dentry)) { |
1660 | mutex_unlock(&dir->d_inode->i_mutex); | 1666 | mutex_unlock(&dir->d_inode->i_mutex); |
@@ -1749,7 +1755,6 @@ struct file *do_filp_open(int dfd, const char *pathname, | |||
1749 | struct nameidata nd; | 1755 | struct nameidata nd; |
1750 | int error; | 1756 | int error; |
1751 | struct path path; | 1757 | struct path path; |
1752 | struct dentry *dir; | ||
1753 | int count = 0; | 1758 | int count = 0; |
1754 | int flag = open_to_namei_flags(open_flag); | 1759 | int flag = open_to_namei_flags(open_flag); |
1755 | int force_reval = 0; | 1760 | int force_reval = 0; |
@@ -1837,16 +1842,12 @@ reval: | |||
1837 | filp->f_flags = open_flag; | 1842 | filp->f_flags = open_flag; |
1838 | nd.intent.open.flags = flag; | 1843 | nd.intent.open.flags = flag; |
1839 | nd.intent.open.create_mode = mode; | 1844 | nd.intent.open.create_mode = mode; |
1840 | dir = nd.path.dentry; | ||
1841 | nd.flags &= ~LOOKUP_PARENT; | 1845 | nd.flags &= ~LOOKUP_PARENT; |
1842 | nd.flags |= LOOKUP_CREATE | LOOKUP_OPEN; | 1846 | nd.flags |= LOOKUP_CREATE | LOOKUP_OPEN; |
1843 | if (flag & O_EXCL) | 1847 | if (flag & O_EXCL) |
1844 | nd.flags |= LOOKUP_EXCL; | 1848 | nd.flags |= LOOKUP_EXCL; |
1845 | mutex_lock(&dir->d_inode->i_mutex); | ||
1846 | path.dentry = lookup_hash(&nd); | ||
1847 | path.mnt = nd.path.mnt; | ||
1848 | filp = do_last(&nd, &path, open_flag, flag, acc_mode, mode, | 1849 | filp = do_last(&nd, &path, open_flag, flag, acc_mode, mode, |
1849 | pathname, dir, &is_link); | 1850 | pathname, &is_link); |
1850 | if (is_link) | 1851 | if (is_link) |
1851 | goto do_link; | 1852 | goto do_link; |
1852 | if (nd.root.mnt) | 1853 | if (nd.root.mnt) |
@@ -1919,12 +1920,8 @@ do_link: | |||
1919 | __putname(nd.last.name); | 1920 | __putname(nd.last.name); |
1920 | goto exit; | 1921 | goto exit; |
1921 | } | 1922 | } |
1922 | dir = nd.path.dentry; | ||
1923 | mutex_lock(&dir->d_inode->i_mutex); | ||
1924 | path.dentry = lookup_hash(&nd); | ||
1925 | path.mnt = nd.path.mnt; | ||
1926 | filp = do_last(&nd, &path, open_flag, flag, acc_mode, mode, | 1923 | filp = do_last(&nd, &path, open_flag, flag, acc_mode, mode, |
1927 | pathname, dir, &is_link); | 1924 | pathname, &is_link); |
1928 | __putname(nd.last.name); | 1925 | __putname(nd.last.name); |
1929 | if (is_link) | 1926 | if (is_link) |
1930 | goto do_link; | 1927 | goto do_link; |