New helper - current_umask()
authorAl Viro <viro@zeniv.linux.org.uk>
Sun, 29 Mar 2009 23:08:22 +0000 (19:08 -0400)
committerAl Viro <viro@zeniv.linux.org.uk>
Wed, 1 Apr 2009 03:00:26 +0000 (23:00 -0400)
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>
26 files changed:
arch/powerpc/platforms/cell/spufs/inode.c
fs/btrfs/acl.c
fs/btrfs/ioctl.c
fs/cifs/dir.c
fs/cifs/inode.c
fs/ext2/acl.c
fs/ext3/acl.c
fs/ext4/acl.c
fs/fat/inode.c
fs/fs_struct.c
fs/generic_acl.c
fs/gfs2/acl.c
fs/hfsplus/options.c
fs/hpfs/super.c
fs/jffs2/acl.c
fs/jfs/acl.c
fs/namei.c
fs/nfs/nfs3proc.c
fs/nfs/nfs4proc.c
fs/ocfs2/acl.c
fs/omfs/inode.c
fs/reiserfs/xattr_acl.c
fs/xfs/linux-2.6/xfs_iops.c
include/linux/fs.h
ipc/mqueue.c
net/unix/af_unix.c

index 64f068540d0dab1f33c21e2518f8aef23040239c..706eb5c7e2ee45c9cb71d5c09fc5517d12966df4 100644 (file)
@@ -635,7 +635,7 @@ long spufs_create(struct nameidata *nd, unsigned int flags, mode_t mode,
        if (dentry->d_inode)
                goto out_dput;
 
-       mode &= ~current->fs->umask;
+       mode &= ~current_umask();
 
        if (flags & SPU_CREATE_GANG)
                ret = spufs_create_gang(nd->path.dentry->d_inode,
index 1d53b62dbba51aa61896c8e78ab50b6544e5c267..7fdd184a528d11caa58ddb37f8d59d07de17a517 100644 (file)
@@ -256,7 +256,7 @@ int btrfs_init_acl(struct inode *inode, struct inode *dir)
                }
 
                if (!acl)
-                       inode->i_mode &= ~current->fs->umask;
+                       inode->i_mode &= ~current_umask();
        }
 
        if (IS_POSIXACL(dir) && acl) {
index bca729fc80c83e07a3847b2b7bb6e73123d6c30f..7594bec1be10066619db8ebb578d03f5d2101de1 100644 (file)
@@ -267,7 +267,7 @@ static noinline int btrfs_mksubvol(struct path *parent, char *name,
                goto out_dput;
 
        if (!IS_POSIXACL(parent->dentry->d_inode))
-               mode &= ~current->fs->umask;
+               mode &= ~current_umask();
 
        error = mnt_want_write(parent->mnt);
        if (error)
index 2f35cccfcd8d202423c4e9e1434d139cf78dc084..54dce78fbb7320cdc7d6449fa347142838d51eba 100644 (file)
@@ -254,7 +254,7 @@ cifs_create(struct inode *inode, struct dentry *direntry, int mode,
                return -ENOMEM;
        }
 
-       mode &= ~current->fs->umask;
+       mode &= ~current_umask();
        if (oplockEnabled)
                oplock = REQ_OPLOCK;
 
@@ -479,7 +479,7 @@ int cifs_mknod(struct inode *inode, struct dentry *direntry, int mode,
                rc = -ENOMEM;
        else if (pTcon->unix_ext) {
                struct cifs_unix_set_info_args args = {
-                       .mode   = mode & ~current->fs->umask,
+                       .mode   = mode & ~current_umask(),
                        .ctime  = NO_CHANGE_64,
                        .atime  = NO_CHANGE_64,
                        .mtime  = NO_CHANGE_64,
index a8797cc60805e4b732a4f1557f8590f353073455..f121a80fdd6fa15e7d6d61ddc8576f9be46550f0 100644 (file)
@@ -1125,7 +1125,7 @@ int cifs_mkdir(struct inode *inode, struct dentry *direntry, int mode)
                        goto mkdir_out;
                }
 
-               mode &= ~current->fs->umask;
+               mode &= ~current_umask();
                rc = CIFSPOSIXCreate(xid, pTcon, SMB_O_DIRECTORY | SMB_O_CREAT,
                                mode, NULL /* netfid */, pInfo, &oplock,
                                full_path, cifs_sb->local_nls,
@@ -1204,7 +1204,7 @@ mkdir_get_info:
                if ((direntry->d_inode) && (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 */
                if (inode->i_mode & S_ISGID)
                        mode |= S_ISGID;
index ae8c4f850b27d0e83e28e684a07637a992abbe69..d46e38cb85c557e273e8206c32b38c9426799ae3 100644 (file)
@@ -318,7 +318,7 @@ ext2_init_acl(struct inode *inode, struct inode *dir)
                                return PTR_ERR(acl);
                }
                if (!acl)
-                       inode->i_mode &= ~current->fs->umask;
+                       inode->i_mode &= ~current_umask();
        }
        if (test_opt(inode->i_sb, POSIX_ACL) && acl) {
                struct posix_acl *clone;
index b60bb241880c86f50420e13411dc19b1148e1a51..d81ef2fdb08e0aeca8e533963db7f7feeecbd386 100644 (file)
@@ -323,7 +323,7 @@ ext3_init_acl(handle_t *handle, struct inode *inode, struct inode *dir)
                                return PTR_ERR(acl);
                }
                if (!acl)
-                       inode->i_mode &= ~current->fs->umask;
+                       inode->i_mode &= ~current_umask();
        }
        if (test_opt(inode->i_sb, POSIX_ACL) && acl) {
                struct posix_acl *clone;
index 694ed6fadcc8c59e1936a49919c67a427ba670e5..647e0d65a2844e227a774cf4b629e5739a0df0cd 100644 (file)
@@ -323,7 +323,7 @@ ext4_init_acl(handle_t *handle, struct inode *inode, struct inode *dir)
                                return PTR_ERR(acl);
                }
                if (!acl)
-                       inode->i_mode &= ~current->fs->umask;
+                       inode->i_mode &= ~current_umask();
        }
        if (test_opt(inode->i_sb, POSIX_ACL) && acl) {
                struct posix_acl *clone;
index de0004fe6e0049c8a09a494444d19831313da64c..ab657db4c94eaedc1fa46be41b07942558b65df5 100644 (file)
@@ -930,7 +930,7 @@ static int parse_options(char *options, int is_vfat, int silent, int *debug,
 
        opts->fs_uid = current_uid();
        opts->fs_gid = current_gid();
-       opts->fs_fmask = opts->fs_dmask = current->fs->umask;
+       opts->fs_fmask = current_umask();
        opts->allow_utime = -1;
        opts->codepage = fat_default_codepage;
        opts->iocharset = fat_default_iocharset;
index 41cff72b377b450273876cdd03a850789a409560..6ac2193386704621e5acb0d08d0f9f1fa4b7138a 100644 (file)
@@ -138,6 +138,12 @@ int unshare_fs_struct(void)
 }
 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 */
 struct fs_struct init_fs = {
        .users          = 1,
index 995d63b2e747556c879c52be194375196995b58a..e0b53aa7bbec11037ba8f9c2bd35f33392249ecd 100644 (file)
@@ -134,7 +134,7 @@ generic_acl_init(struct inode *inode, struct inode *dir,
        mode_t mode = inode->i_mode;
        int error;
 
-       inode->i_mode = mode & ~current->fs->umask;
+       inode->i_mode = mode & ~current_umask();
        if (!S_ISLNK(inode->i_mode))
                acl = ops->getacl(dir, ACL_TYPE_DEFAULT);
        if (acl) {
index 43764f4fa763a148f8bd0b67ed69b8755fa070be..fa881bdc3d8577647d486aa7772eecc3b72177d3 100644 (file)
@@ -215,7 +215,7 @@ int gfs2_acl_create(struct gfs2_inode *dip, struct gfs2_inode *ip)
        if (error)
                return error;
        if (!acl) {
-               mode &= ~current->fs->umask;
+               mode &= ~current_umask();
                if (mode != ip->i_inode.i_mode)
                        error = munge_mode(ip, mode);
                return error;
index bab7f8d1bdfa9f97ad8f3c85786daf9ecbc3c9df..3fcbb0e1f6fc09ea43f1918d4099f695937b0db1 100644 (file)
@@ -48,7 +48,7 @@ void hfsplus_fill_defaults(struct hfsplus_sb_info *opts)
 
        opts->creator = HFSPLUS_DEF_CR_TYPE;
        opts->type = HFSPLUS_DEF_CR_TYPE;
-       opts->umask = current->fs->umask;
+       opts->umask = current_umask();
        opts->uid = current_uid();
        opts->gid = current_gid();
        opts->part = -1;
index 0d049b8919c42ed1c62871f26815994a5f00e254..c696d01bc8f7954c8d7cfc12b3e3c714f8ebc20f 100644 (file)
@@ -477,7 +477,7 @@ static int hpfs_fill_super(struct super_block *s, void *options, int silent)
 
        uid = current_uid();
        gid = current_gid();
-       umask = current->fs->umask;
+       umask = current_umask();
        lowercase = 0;
        conv = CONV_BINARY;
        eas = 2;
index d98713777a1b62f2aa12f659dd872616d2dbeb4a..77ccf8cb0823c805ff9af233aba63404d0df01a2 100644 (file)
@@ -336,7 +336,7 @@ int jffs2_init_acl_pre(struct inode *dir_i, struct inode *inode, int *i_mode)
                return PTR_ERR(acl);
 
        if (!acl) {
-               *i_mode &= ~current->fs->umask;
+               *i_mode &= ~current_umask();
        } else {
                if (S_ISDIR(*i_mode))
                        jffs2_iset_acl(inode, &f->i_acl_default, acl);
index a166c1669e823823844790f43e04ee13a14a6011..06ca1b8d205459e2a2bbbfb35282d0f576ee788c 100644 (file)
@@ -182,7 +182,7 @@ int jfs_init_acl(tid_t tid, struct inode *inode, struct inode *dir)
 cleanup:
                posix_acl_release(acl);
        } else
-               inode->i_mode &= ~current->fs->umask;
+               inode->i_mode &= ~current_umask();
 
        JFS_IP(inode)->mode2 = (JFS_IP(inode)->mode2 & 0xffff0000) |
                               inode->i_mode;
index 4c65a64601384470db0d58c2df63317c0da0f14c..964c0249444bda7e7050a8fcd7ccfd1c94ff4f0a 100644 (file)
@@ -1578,7 +1578,7 @@ static int __open_namei_create(struct nameidata *nd, struct path *path,
        struct dentry *dir = nd->path.dentry;
 
        if (!IS_POSIXACL(dir->d_inode))
-               mode &= ~current->fs->umask;
+               mode &= ~current_umask();
        error = security_path_mknod(&nd->path, path->dentry, mode, 0);
        if (error)
                goto out_unlock;
@@ -1989,7 +1989,7 @@ SYSCALL_DEFINE4(mknodat, int, dfd, const char __user *, filename, int, mode,
                goto out_unlock;
        }
        if (!IS_POSIXACL(nd.path.dentry->d_inode))
-               mode &= ~current->fs->umask;
+               mode &= ~current_umask();
        error = may_mknod(mode);
        if (error)
                goto out_dput;
@@ -2067,7 +2067,7 @@ SYSCALL_DEFINE3(mkdirat, int, dfd, const char __user *, pathname, int, mode)
                goto out_unlock;
 
        if (!IS_POSIXACL(nd.path.dentry->d_inode))
-               mode &= ~current->fs->umask;
+               mode &= ~current_umask();
        error = mnt_want_write(nd.path.mnt);
        if (error)
                goto out_dput;
index c55be7a7679e27f6c011766add0b2bf8e9cfc447..e47d4400fb87b1b4eb9302f1ee3b29fcf744b7e0 100644 (file)
@@ -328,7 +328,7 @@ nfs3_proc_create(struct inode *dir, struct dentry *dentry, struct iattr *sattr,
                data->arg.create.verifier[1] = current->pid;
        }
 
-       sattr->ia_mode &= ~current->fs->umask;
+       sattr->ia_mode &= ~current_umask();
 
        for (;;) {
                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);
 
-       sattr->ia_mode &= ~current->fs->umask;
+       sattr->ia_mode &= ~current_umask();
 
        data = nfs3_alloc_createdata();
        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,
                        MAJOR(rdev), MINOR(rdev));
 
-       sattr->ia_mode &= ~current->fs->umask;
+       sattr->ia_mode &= ~current_umask();
 
        data = nfs3_alloc_createdata();
        if (data == NULL)
index 8dde84b988d9cd349604eb4663a70fc4333fe367..bbee587dd597925249dcebcf2ded9b13303d67fc 100644 (file)
@@ -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_valid = ATTR_MODE;
                if (!IS_POSIXACL(dir))
-                       attr.ia_mode &= ~current->fs->umask;
+                       attr.ia_mode &= ~current_umask();
        } else {
                attr.ia_valid = 0;
                BUG_ON(nd->intent.open.flags & O_CREAT);
index 12dfb44c22e57d3e82e8ed038de231008e926c9a..fbeaec762103a91eacd396f47a999244303954ee 100644 (file)
@@ -296,7 +296,7 @@ int ocfs2_init_acl(handle_t *handle,
                                return PTR_ERR(acl);
                }
                if (!acl)
-                       inode->i_mode &= ~current->fs->umask;
+                       inode->i_mode &= ~current_umask();
        }
        if ((osb->s_mount_opt & OCFS2_MOUNT_POSIX_ACL) && acl) {
                struct posix_acl *clone;
index 633e9dc972bbc63edb052e89cd924aad8e25e8c3..aa6fc30772af278500145b7667a515508a19dd9c 100644 (file)
@@ -421,7 +421,7 @@ static int omfs_fill_super(struct super_block *sb, void *data, int silent)
 
        sbi->s_uid = current_uid();
        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))
                goto end;
index d423416d93d14a90e894331b574f238b45055d78..c303c426fe2ba6ffec8d708323026f36fbd40f90 100644 (file)
@@ -428,7 +428,7 @@ reiserfs_inherit_default_acl(struct reiserfs_transaction_handle *th,
        } else {
              apply_umask:
                /* no ACL, apply umask */
-               inode->i_mode &= ~current->fs->umask;
+               inode->i_mode &= ~current_umask();
        }
 
        return err;
index 7aa53fefc67fafe14bb54db40398f79945f1baae..2940612e3aeb4bf2f47c17bed0ed7982e121f327 100644 (file)
@@ -227,7 +227,7 @@ xfs_vn_mknod(
        xfs_dentry_to_name(&name, dentry);
 
        if (IS_POSIXACL(dir) && !default_acl)
-               mode &= ~current->fs->umask;
+               mode &= ~current_umask();
 
        switch (mode & S_IFMT) {
        case S_IFCHR:
@@ -416,7 +416,7 @@ xfs_vn_symlink(
        mode_t          mode;
 
        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);
 
        error = xfs_symlink(XFS_I(dir), &name, symname, mode, &cip, NULL);
index 87e7bfc5ebd7f5e198b324f4b7d6877f664856a7..3d7bd5447ca3f9e86557d2705e96be0b6034da8f 100644 (file)
@@ -1741,6 +1741,8 @@ extern void drop_collected_mounts(struct vfsmount *);
 
 extern int vfs_statfs(struct dentry *, struct kstatfs *);
 
+extern int current_umask(void);
+
 /* /sys/fs */
 extern struct kobject *fs_kobj;
 
index a8ddadbc74594cc6822c706b92f9f429359d0cce..916785363f0f104ac6820fd27dfeaba71bde2727 100644 (file)
@@ -602,7 +602,7 @@ static struct file *do_create(struct dentry *dir, struct dentry *dentry,
                dentry->d_fsdata = attr;
        }
 
-       mode &= ~current->fs->umask;
+       mode &= ~current_umask();
        ret = mnt_want_write(mqueue_mnt);
        if (ret)
                goto out;
index baac91049b0ea0efcafb0259ff4146cc2d0e41f6..9dcc6e7f96ec2126039ce6b57768b7274bf5f19e 100644 (file)
@@ -832,7 +832,7 @@ static int unix_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len)
                 * All right, let's create it.
                 */
                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);
                if (err)
                        goto out_mknod_dput;