New helper - current_umask()
current->fs->umask is what most of fs_struct users are doing. Put that into a helper function. Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
This commit is contained in:
Родитель
f1191b50ec
Коммит
ce3b0f8d5c
|
@ -635,7 +635,7 @@ long spufs_create(struct nameidata *nd, unsigned int flags, mode_t mode,
|
||||||
if (dentry->d_inode)
|
if (dentry->d_inode)
|
||||||
goto out_dput;
|
goto out_dput;
|
||||||
|
|
||||||
mode &= ~current->fs->umask;
|
mode &= ~current_umask();
|
||||||
|
|
||||||
if (flags & SPU_CREATE_GANG)
|
if (flags & SPU_CREATE_GANG)
|
||||||
ret = spufs_create_gang(nd->path.dentry->d_inode,
|
ret = spufs_create_gang(nd->path.dentry->d_inode,
|
||||||
|
|
|
@ -256,7 +256,7 @@ int btrfs_init_acl(struct inode *inode, struct inode *dir)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!acl)
|
if (!acl)
|
||||||
inode->i_mode &= ~current->fs->umask;
|
inode->i_mode &= ~current_umask();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (IS_POSIXACL(dir) && acl) {
|
if (IS_POSIXACL(dir) && acl) {
|
||||||
|
|
|
@ -267,7 +267,7 @@ static noinline int btrfs_mksubvol(struct path *parent, char *name,
|
||||||
goto out_dput;
|
goto out_dput;
|
||||||
|
|
||||||
if (!IS_POSIXACL(parent->dentry->d_inode))
|
if (!IS_POSIXACL(parent->dentry->d_inode))
|
||||||
mode &= ~current->fs->umask;
|
mode &= ~current_umask();
|
||||||
|
|
||||||
error = mnt_want_write(parent->mnt);
|
error = mnt_want_write(parent->mnt);
|
||||||
if (error)
|
if (error)
|
||||||
|
|
|
@ -254,7 +254,7 @@ cifs_create(struct inode *inode, struct dentry *direntry, int mode,
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
}
|
}
|
||||||
|
|
||||||
mode &= ~current->fs->umask;
|
mode &= ~current_umask();
|
||||||
if (oplockEnabled)
|
if (oplockEnabled)
|
||||||
oplock = REQ_OPLOCK;
|
oplock = REQ_OPLOCK;
|
||||||
|
|
||||||
|
@ -479,7 +479,7 @@ int cifs_mknod(struct inode *inode, struct dentry *direntry, int mode,
|
||||||
rc = -ENOMEM;
|
rc = -ENOMEM;
|
||||||
else if (pTcon->unix_ext) {
|
else if (pTcon->unix_ext) {
|
||||||
struct cifs_unix_set_info_args args = {
|
struct cifs_unix_set_info_args args = {
|
||||||
.mode = mode & ~current->fs->umask,
|
.mode = mode & ~current_umask(),
|
||||||
.ctime = NO_CHANGE_64,
|
.ctime = NO_CHANGE_64,
|
||||||
.atime = NO_CHANGE_64,
|
.atime = NO_CHANGE_64,
|
||||||
.mtime = NO_CHANGE_64,
|
.mtime = NO_CHANGE_64,
|
||||||
|
|
|
@ -1125,7 +1125,7 @@ int cifs_mkdir(struct inode *inode, struct dentry *direntry, int mode)
|
||||||
goto mkdir_out;
|
goto mkdir_out;
|
||||||
}
|
}
|
||||||
|
|
||||||
mode &= ~current->fs->umask;
|
mode &= ~current_umask();
|
||||||
rc = CIFSPOSIXCreate(xid, pTcon, SMB_O_DIRECTORY | SMB_O_CREAT,
|
rc = CIFSPOSIXCreate(xid, pTcon, SMB_O_DIRECTORY | SMB_O_CREAT,
|
||||||
mode, NULL /* netfid */, pInfo, &oplock,
|
mode, NULL /* netfid */, pInfo, &oplock,
|
||||||
full_path, cifs_sb->local_nls,
|
full_path, cifs_sb->local_nls,
|
||||||
|
@ -1204,7 +1204,7 @@ mkdir_get_info:
|
||||||
if ((direntry->d_inode) && (direntry->d_inode->i_nlink < 2))
|
if ((direntry->d_inode) && (direntry->d_inode->i_nlink < 2))
|
||||||
direntry->d_inode->i_nlink = 2;
|
direntry->d_inode->i_nlink = 2;
|
||||||
|
|
||||||
mode &= ~current->fs->umask;
|
mode &= ~current_umask();
|
||||||
/* must turn on setgid bit if parent dir has it */
|
/* must turn on setgid bit if parent dir has it */
|
||||||
if (inode->i_mode & S_ISGID)
|
if (inode->i_mode & S_ISGID)
|
||||||
mode |= S_ISGID;
|
mode |= S_ISGID;
|
||||||
|
|
|
@ -318,7 +318,7 @@ ext2_init_acl(struct inode *inode, struct inode *dir)
|
||||||
return PTR_ERR(acl);
|
return PTR_ERR(acl);
|
||||||
}
|
}
|
||||||
if (!acl)
|
if (!acl)
|
||||||
inode->i_mode &= ~current->fs->umask;
|
inode->i_mode &= ~current_umask();
|
||||||
}
|
}
|
||||||
if (test_opt(inode->i_sb, POSIX_ACL) && acl) {
|
if (test_opt(inode->i_sb, POSIX_ACL) && acl) {
|
||||||
struct posix_acl *clone;
|
struct posix_acl *clone;
|
||||||
|
|
|
@ -323,7 +323,7 @@ ext3_init_acl(handle_t *handle, struct inode *inode, struct inode *dir)
|
||||||
return PTR_ERR(acl);
|
return PTR_ERR(acl);
|
||||||
}
|
}
|
||||||
if (!acl)
|
if (!acl)
|
||||||
inode->i_mode &= ~current->fs->umask;
|
inode->i_mode &= ~current_umask();
|
||||||
}
|
}
|
||||||
if (test_opt(inode->i_sb, POSIX_ACL) && acl) {
|
if (test_opt(inode->i_sb, POSIX_ACL) && acl) {
|
||||||
struct posix_acl *clone;
|
struct posix_acl *clone;
|
||||||
|
|
|
@ -323,7 +323,7 @@ ext4_init_acl(handle_t *handle, struct inode *inode, struct inode *dir)
|
||||||
return PTR_ERR(acl);
|
return PTR_ERR(acl);
|
||||||
}
|
}
|
||||||
if (!acl)
|
if (!acl)
|
||||||
inode->i_mode &= ~current->fs->umask;
|
inode->i_mode &= ~current_umask();
|
||||||
}
|
}
|
||||||
if (test_opt(inode->i_sb, POSIX_ACL) && acl) {
|
if (test_opt(inode->i_sb, POSIX_ACL) && acl) {
|
||||||
struct posix_acl *clone;
|
struct posix_acl *clone;
|
||||||
|
|
|
@ -930,7 +930,7 @@ static int parse_options(char *options, int is_vfat, int silent, int *debug,
|
||||||
|
|
||||||
opts->fs_uid = current_uid();
|
opts->fs_uid = current_uid();
|
||||||
opts->fs_gid = current_gid();
|
opts->fs_gid = current_gid();
|
||||||
opts->fs_fmask = opts->fs_dmask = current->fs->umask;
|
opts->fs_fmask = current_umask();
|
||||||
opts->allow_utime = -1;
|
opts->allow_utime = -1;
|
||||||
opts->codepage = fat_default_codepage;
|
opts->codepage = fat_default_codepage;
|
||||||
opts->iocharset = fat_default_iocharset;
|
opts->iocharset = fat_default_iocharset;
|
||||||
|
|
|
@ -138,6 +138,12 @@ int unshare_fs_struct(void)
|
||||||
}
|
}
|
||||||
EXPORT_SYMBOL_GPL(unshare_fs_struct);
|
EXPORT_SYMBOL_GPL(unshare_fs_struct);
|
||||||
|
|
||||||
|
int current_umask(void)
|
||||||
|
{
|
||||||
|
return current->fs->umask;
|
||||||
|
}
|
||||||
|
EXPORT_SYMBOL(current_umask);
|
||||||
|
|
||||||
/* to be mentioned only in INIT_TASK */
|
/* to be mentioned only in INIT_TASK */
|
||||||
struct fs_struct init_fs = {
|
struct fs_struct init_fs = {
|
||||||
.users = 1,
|
.users = 1,
|
||||||
|
|
|
@ -134,7 +134,7 @@ generic_acl_init(struct inode *inode, struct inode *dir,
|
||||||
mode_t mode = inode->i_mode;
|
mode_t mode = inode->i_mode;
|
||||||
int error;
|
int error;
|
||||||
|
|
||||||
inode->i_mode = mode & ~current->fs->umask;
|
inode->i_mode = mode & ~current_umask();
|
||||||
if (!S_ISLNK(inode->i_mode))
|
if (!S_ISLNK(inode->i_mode))
|
||||||
acl = ops->getacl(dir, ACL_TYPE_DEFAULT);
|
acl = ops->getacl(dir, ACL_TYPE_DEFAULT);
|
||||||
if (acl) {
|
if (acl) {
|
||||||
|
|
|
@ -215,7 +215,7 @@ int gfs2_acl_create(struct gfs2_inode *dip, struct gfs2_inode *ip)
|
||||||
if (error)
|
if (error)
|
||||||
return error;
|
return error;
|
||||||
if (!acl) {
|
if (!acl) {
|
||||||
mode &= ~current->fs->umask;
|
mode &= ~current_umask();
|
||||||
if (mode != ip->i_inode.i_mode)
|
if (mode != ip->i_inode.i_mode)
|
||||||
error = munge_mode(ip, mode);
|
error = munge_mode(ip, mode);
|
||||||
return error;
|
return error;
|
||||||
|
|
|
@ -48,7 +48,7 @@ void hfsplus_fill_defaults(struct hfsplus_sb_info *opts)
|
||||||
|
|
||||||
opts->creator = HFSPLUS_DEF_CR_TYPE;
|
opts->creator = HFSPLUS_DEF_CR_TYPE;
|
||||||
opts->type = HFSPLUS_DEF_CR_TYPE;
|
opts->type = HFSPLUS_DEF_CR_TYPE;
|
||||||
opts->umask = current->fs->umask;
|
opts->umask = current_umask();
|
||||||
opts->uid = current_uid();
|
opts->uid = current_uid();
|
||||||
opts->gid = current_gid();
|
opts->gid = current_gid();
|
||||||
opts->part = -1;
|
opts->part = -1;
|
||||||
|
|
|
@ -477,7 +477,7 @@ static int hpfs_fill_super(struct super_block *s, void *options, int silent)
|
||||||
|
|
||||||
uid = current_uid();
|
uid = current_uid();
|
||||||
gid = current_gid();
|
gid = current_gid();
|
||||||
umask = current->fs->umask;
|
umask = current_umask();
|
||||||
lowercase = 0;
|
lowercase = 0;
|
||||||
conv = CONV_BINARY;
|
conv = CONV_BINARY;
|
||||||
eas = 2;
|
eas = 2;
|
||||||
|
|
|
@ -336,7 +336,7 @@ int jffs2_init_acl_pre(struct inode *dir_i, struct inode *inode, int *i_mode)
|
||||||
return PTR_ERR(acl);
|
return PTR_ERR(acl);
|
||||||
|
|
||||||
if (!acl) {
|
if (!acl) {
|
||||||
*i_mode &= ~current->fs->umask;
|
*i_mode &= ~current_umask();
|
||||||
} else {
|
} else {
|
||||||
if (S_ISDIR(*i_mode))
|
if (S_ISDIR(*i_mode))
|
||||||
jffs2_iset_acl(inode, &f->i_acl_default, acl);
|
jffs2_iset_acl(inode, &f->i_acl_default, acl);
|
||||||
|
|
|
@ -182,7 +182,7 @@ int jfs_init_acl(tid_t tid, struct inode *inode, struct inode *dir)
|
||||||
cleanup:
|
cleanup:
|
||||||
posix_acl_release(acl);
|
posix_acl_release(acl);
|
||||||
} else
|
} else
|
||||||
inode->i_mode &= ~current->fs->umask;
|
inode->i_mode &= ~current_umask();
|
||||||
|
|
||||||
JFS_IP(inode)->mode2 = (JFS_IP(inode)->mode2 & 0xffff0000) |
|
JFS_IP(inode)->mode2 = (JFS_IP(inode)->mode2 & 0xffff0000) |
|
||||||
inode->i_mode;
|
inode->i_mode;
|
||||||
|
|
|
@ -1578,7 +1578,7 @@ static int __open_namei_create(struct nameidata *nd, struct path *path,
|
||||||
struct dentry *dir = nd->path.dentry;
|
struct dentry *dir = nd->path.dentry;
|
||||||
|
|
||||||
if (!IS_POSIXACL(dir->d_inode))
|
if (!IS_POSIXACL(dir->d_inode))
|
||||||
mode &= ~current->fs->umask;
|
mode &= ~current_umask();
|
||||||
error = security_path_mknod(&nd->path, path->dentry, mode, 0);
|
error = security_path_mknod(&nd->path, path->dentry, mode, 0);
|
||||||
if (error)
|
if (error)
|
||||||
goto out_unlock;
|
goto out_unlock;
|
||||||
|
@ -1989,7 +1989,7 @@ SYSCALL_DEFINE4(mknodat, int, dfd, const char __user *, filename, int, mode,
|
||||||
goto out_unlock;
|
goto out_unlock;
|
||||||
}
|
}
|
||||||
if (!IS_POSIXACL(nd.path.dentry->d_inode))
|
if (!IS_POSIXACL(nd.path.dentry->d_inode))
|
||||||
mode &= ~current->fs->umask;
|
mode &= ~current_umask();
|
||||||
error = may_mknod(mode);
|
error = may_mknod(mode);
|
||||||
if (error)
|
if (error)
|
||||||
goto out_dput;
|
goto out_dput;
|
||||||
|
@ -2067,7 +2067,7 @@ SYSCALL_DEFINE3(mkdirat, int, dfd, const char __user *, pathname, int, mode)
|
||||||
goto out_unlock;
|
goto out_unlock;
|
||||||
|
|
||||||
if (!IS_POSIXACL(nd.path.dentry->d_inode))
|
if (!IS_POSIXACL(nd.path.dentry->d_inode))
|
||||||
mode &= ~current->fs->umask;
|
mode &= ~current_umask();
|
||||||
error = mnt_want_write(nd.path.mnt);
|
error = mnt_want_write(nd.path.mnt);
|
||||||
if (error)
|
if (error)
|
||||||
goto out_dput;
|
goto out_dput;
|
||||||
|
|
|
@ -328,7 +328,7 @@ nfs3_proc_create(struct inode *dir, struct dentry *dentry, struct iattr *sattr,
|
||||||
data->arg.create.verifier[1] = current->pid;
|
data->arg.create.verifier[1] = current->pid;
|
||||||
}
|
}
|
||||||
|
|
||||||
sattr->ia_mode &= ~current->fs->umask;
|
sattr->ia_mode &= ~current_umask();
|
||||||
|
|
||||||
for (;;) {
|
for (;;) {
|
||||||
status = nfs3_do_create(dir, dentry, data);
|
status = nfs3_do_create(dir, dentry, data);
|
||||||
|
@ -528,7 +528,7 @@ nfs3_proc_mkdir(struct inode *dir, struct dentry *dentry, struct iattr *sattr)
|
||||||
|
|
||||||
dprintk("NFS call mkdir %s\n", dentry->d_name.name);
|
dprintk("NFS call mkdir %s\n", dentry->d_name.name);
|
||||||
|
|
||||||
sattr->ia_mode &= ~current->fs->umask;
|
sattr->ia_mode &= ~current_umask();
|
||||||
|
|
||||||
data = nfs3_alloc_createdata();
|
data = nfs3_alloc_createdata();
|
||||||
if (data == NULL)
|
if (data == NULL)
|
||||||
|
@ -639,7 +639,7 @@ nfs3_proc_mknod(struct inode *dir, struct dentry *dentry, struct iattr *sattr,
|
||||||
dprintk("NFS call mknod %s %u:%u\n", dentry->d_name.name,
|
dprintk("NFS call mknod %s %u:%u\n", dentry->d_name.name,
|
||||||
MAJOR(rdev), MINOR(rdev));
|
MAJOR(rdev), MINOR(rdev));
|
||||||
|
|
||||||
sattr->ia_mode &= ~current->fs->umask;
|
sattr->ia_mode &= ~current_umask();
|
||||||
|
|
||||||
data = nfs3_alloc_createdata();
|
data = nfs3_alloc_createdata();
|
||||||
if (data == NULL)
|
if (data == NULL)
|
||||||
|
|
|
@ -1509,7 +1509,7 @@ nfs4_atomic_open(struct inode *dir, struct dentry *dentry, struct nameidata *nd)
|
||||||
attr.ia_mode = nd->intent.open.create_mode;
|
attr.ia_mode = nd->intent.open.create_mode;
|
||||||
attr.ia_valid = ATTR_MODE;
|
attr.ia_valid = ATTR_MODE;
|
||||||
if (!IS_POSIXACL(dir))
|
if (!IS_POSIXACL(dir))
|
||||||
attr.ia_mode &= ~current->fs->umask;
|
attr.ia_mode &= ~current_umask();
|
||||||
} else {
|
} else {
|
||||||
attr.ia_valid = 0;
|
attr.ia_valid = 0;
|
||||||
BUG_ON(nd->intent.open.flags & O_CREAT);
|
BUG_ON(nd->intent.open.flags & O_CREAT);
|
||||||
|
|
|
@ -296,7 +296,7 @@ int ocfs2_init_acl(handle_t *handle,
|
||||||
return PTR_ERR(acl);
|
return PTR_ERR(acl);
|
||||||
}
|
}
|
||||||
if (!acl)
|
if (!acl)
|
||||||
inode->i_mode &= ~current->fs->umask;
|
inode->i_mode &= ~current_umask();
|
||||||
}
|
}
|
||||||
if ((osb->s_mount_opt & OCFS2_MOUNT_POSIX_ACL) && acl) {
|
if ((osb->s_mount_opt & OCFS2_MOUNT_POSIX_ACL) && acl) {
|
||||||
struct posix_acl *clone;
|
struct posix_acl *clone;
|
||||||
|
|
|
@ -421,7 +421,7 @@ static int omfs_fill_super(struct super_block *sb, void *data, int silent)
|
||||||
|
|
||||||
sbi->s_uid = current_uid();
|
sbi->s_uid = current_uid();
|
||||||
sbi->s_gid = current_gid();
|
sbi->s_gid = current_gid();
|
||||||
sbi->s_dmask = sbi->s_fmask = current->fs->umask;
|
sbi->s_dmask = sbi->s_fmask = current_umask();
|
||||||
|
|
||||||
if (!parse_options((char *) data, sbi))
|
if (!parse_options((char *) data, sbi))
|
||||||
goto end;
|
goto end;
|
||||||
|
|
|
@ -428,7 +428,7 @@ reiserfs_inherit_default_acl(struct reiserfs_transaction_handle *th,
|
||||||
} else {
|
} else {
|
||||||
apply_umask:
|
apply_umask:
|
||||||
/* no ACL, apply umask */
|
/* no ACL, apply umask */
|
||||||
inode->i_mode &= ~current->fs->umask;
|
inode->i_mode &= ~current_umask();
|
||||||
}
|
}
|
||||||
|
|
||||||
return err;
|
return err;
|
||||||
|
|
|
@ -227,7 +227,7 @@ xfs_vn_mknod(
|
||||||
xfs_dentry_to_name(&name, dentry);
|
xfs_dentry_to_name(&name, dentry);
|
||||||
|
|
||||||
if (IS_POSIXACL(dir) && !default_acl)
|
if (IS_POSIXACL(dir) && !default_acl)
|
||||||
mode &= ~current->fs->umask;
|
mode &= ~current_umask();
|
||||||
|
|
||||||
switch (mode & S_IFMT) {
|
switch (mode & S_IFMT) {
|
||||||
case S_IFCHR:
|
case S_IFCHR:
|
||||||
|
@ -416,7 +416,7 @@ xfs_vn_symlink(
|
||||||
mode_t mode;
|
mode_t mode;
|
||||||
|
|
||||||
mode = S_IFLNK |
|
mode = S_IFLNK |
|
||||||
(irix_symlink_mode ? 0777 & ~current->fs->umask : S_IRWXUGO);
|
(irix_symlink_mode ? 0777 & ~current_umask() : S_IRWXUGO);
|
||||||
xfs_dentry_to_name(&name, dentry);
|
xfs_dentry_to_name(&name, dentry);
|
||||||
|
|
||||||
error = xfs_symlink(XFS_I(dir), &name, symname, mode, &cip, NULL);
|
error = xfs_symlink(XFS_I(dir), &name, symname, mode, &cip, NULL);
|
||||||
|
|
|
@ -1741,6 +1741,8 @@ extern void drop_collected_mounts(struct vfsmount *);
|
||||||
|
|
||||||
extern int vfs_statfs(struct dentry *, struct kstatfs *);
|
extern int vfs_statfs(struct dentry *, struct kstatfs *);
|
||||||
|
|
||||||
|
extern int current_umask(void);
|
||||||
|
|
||||||
/* /sys/fs */
|
/* /sys/fs */
|
||||||
extern struct kobject *fs_kobj;
|
extern struct kobject *fs_kobj;
|
||||||
|
|
||||||
|
|
|
@ -602,7 +602,7 @@ static struct file *do_create(struct dentry *dir, struct dentry *dentry,
|
||||||
dentry->d_fsdata = attr;
|
dentry->d_fsdata = attr;
|
||||||
}
|
}
|
||||||
|
|
||||||
mode &= ~current->fs->umask;
|
mode &= ~current_umask();
|
||||||
ret = mnt_want_write(mqueue_mnt);
|
ret = mnt_want_write(mqueue_mnt);
|
||||||
if (ret)
|
if (ret)
|
||||||
goto out;
|
goto out;
|
||||||
|
|
|
@ -832,7 +832,7 @@ static int unix_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len)
|
||||||
* All right, let's create it.
|
* All right, let's create it.
|
||||||
*/
|
*/
|
||||||
mode = S_IFSOCK |
|
mode = S_IFSOCK |
|
||||||
(SOCK_INODE(sock)->i_mode & ~current->fs->umask);
|
(SOCK_INODE(sock)->i_mode & ~current_umask());
|
||||||
err = mnt_want_write(nd.path.mnt);
|
err = mnt_want_write(nd.path.mnt);
|
||||||
if (err)
|
if (err)
|
||||||
goto out_mknod_dput;
|
goto out_mknod_dput;
|
||||||
|
|
Загрузка…
Ссылка в новой задаче