aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorDave Hansen <haveblue@us.ibm.com>2006-10-01 02:29:02 -0400
committerLinus Torvalds <torvalds@g5.osdl.org>2006-10-01 03:39:30 -0400
commitaab520e2f6c80160cabd187a8d0292d1cec8ff68 (patch)
treee066da750f4aba3e5b472a2fafd5d267876420e2 /fs
parent6902d925d568cd5bfda8a1a328bf08d26d1bab46 (diff)
[PATCH] r/o bind mount prepwork: move open_namei()'s vfs_create()
The code around vfs_create() in open_namei() is getting a bit too complex. Right now, there is at least the reference count on the dentry, and the i_mutex to worry about. Soon, we'll also have mnt_writecount. So, break the vfs_create() call out of open_namei(), and into a helper function. This duplicates the call to may_open(), but that isn't such a bad thing since the arguments (acc_mode and flag) were being heavily massaged anyway. Signed-off-by: Dave Hansen <haveblue@us.ibm.com> Acked-by: Christoph Hellwig <hch@lst.de> Cc: Al Viro <viro@zeniv.linux.org.uk> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'fs')
-rw-r--r--fs/namei.c30
1 files changed, 20 insertions, 10 deletions
diff --git a/fs/namei.c b/fs/namei.c
index 7bdceedd254c..28d49b301d55 100644
--- a/fs/namei.c
+++ b/fs/namei.c
@@ -1595,6 +1595,24 @@ int may_open(struct nameidata *nd, int acc_mode, int flag)
1595 return 0; 1595 return 0;
1596} 1596}
1597 1597
1598static int open_namei_create(struct nameidata *nd, struct path *path,
1599 int flag, int mode)
1600{
1601 int error;
1602 struct dentry *dir = nd->dentry;
1603
1604 if (!IS_POSIXACL(dir->d_inode))
1605 mode &= ~current->fs->umask;
1606 error = vfs_create(dir->d_inode, path->dentry, mode, nd);
1607 mutex_unlock(&dir->d_inode->i_mutex);
1608 dput(nd->dentry);
1609 nd->dentry = path->dentry;
1610 if (error)
1611 return error;
1612 /* Don't check for write permission, don't truncate */
1613 return may_open(nd, 0, flag & ~O_TRUNC);
1614}
1615
1598/* 1616/*
1599 * open_namei() 1617 * open_namei()
1600 * 1618 *
@@ -1676,18 +1694,10 @@ do_last:
1676 1694
1677 /* Negative dentry, just create the file */ 1695 /* Negative dentry, just create the file */
1678 if (!path.dentry->d_inode) { 1696 if (!path.dentry->d_inode) {
1679 if (!IS_POSIXACL(dir->d_inode)) 1697 error = open_namei_create(nd, &path, flag, mode);
1680 mode &= ~current->fs->umask;
1681 error = vfs_create(dir->d_inode, path.dentry, mode, nd);
1682 mutex_unlock(&dir->d_inode->i_mutex);
1683 dput(nd->dentry);
1684 nd->dentry = path.dentry;
1685 if (error) 1698 if (error)
1686 goto exit; 1699 goto exit;
1687 /* Don't check for write permission, don't truncate */ 1700 return 0;
1688 acc_mode = 0;
1689 flag &= ~O_TRUNC;
1690 goto ok;
1691 } 1701 }
1692 1702
1693 /* 1703 /*