aboutsummaryrefslogtreecommitdiffstats
path: root/fs/namei.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/namei.c')
-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 /*