Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

Al Viro ce3b0f8d f1191b50

+39 -31
+1 -1
arch/powerpc/platforms/cell/spufs/inode.c
··· 635 635 if (dentry->d_inode) 636 636 goto out_dput; 637 637 638 - mode &= ~current->fs->umask; 638 + mode &= ~current_umask(); 639 639 640 640 if (flags & SPU_CREATE_GANG) 641 641 ret = spufs_create_gang(nd->path.dentry->d_inode,
+1 -1
fs/btrfs/acl.c
··· 256 256 } 257 257 258 258 if (!acl) 259 - inode->i_mode &= ~current->fs->umask; 259 + inode->i_mode &= ~current_umask(); 260 260 } 261 261 262 262 if (IS_POSIXACL(dir) && acl) {
+1 -1
fs/btrfs/ioctl.c
··· 267 267 goto out_dput; 268 268 269 269 if (!IS_POSIXACL(parent->dentry->d_inode)) 270 - mode &= ~current->fs->umask; 270 + mode &= ~current_umask(); 271 271 272 272 error = mnt_want_write(parent->mnt); 273 273 if (error)
+2 -2
fs/cifs/dir.c
··· 254 254 return -ENOMEM; 255 255 } 256 256 257 - mode &= ~current->fs->umask; 257 + mode &= ~current_umask(); 258 258 if (oplockEnabled) 259 259 oplock = REQ_OPLOCK; 260 260 ··· 479 479 rc = -ENOMEM; 480 480 else if (pTcon->unix_ext) { 481 481 struct cifs_unix_set_info_args args = { 482 - .mode = mode & ~current->fs->umask, 482 + .mode = mode & ~current_umask(), 483 483 .ctime = NO_CHANGE_64, 484 484 .atime = NO_CHANGE_64, 485 485 .mtime = NO_CHANGE_64,
+2 -2
fs/cifs/inode.c
··· 1125 1125 goto mkdir_out; 1126 1126 } 1127 1127 1128 - mode &= ~current->fs->umask; 1128 + mode &= ~current_umask(); 1129 1129 rc = CIFSPOSIXCreate(xid, pTcon, SMB_O_DIRECTORY | SMB_O_CREAT, 1130 1130 mode, NULL /* netfid */, pInfo, &oplock, 1131 1131 full_path, cifs_sb->local_nls, ··· 1204 1204 if ((direntry->d_inode) && (direntry->d_inode->i_nlink < 2)) 1205 1205 direntry->d_inode->i_nlink = 2; 1206 1206 1207 - mode &= ~current->fs->umask; 1207 + mode &= ~current_umask(); 1208 1208 /* must turn on setgid bit if parent dir has it */ 1209 1209 if (inode->i_mode & S_ISGID) 1210 1210 mode |= S_ISGID;
+1 -1
fs/ext2/acl.c
··· 318 318 return PTR_ERR(acl); 319 319 } 320 320 if (!acl) 321 - inode->i_mode &= ~current->fs->umask; 321 + inode->i_mode &= ~current_umask(); 322 322 } 323 323 if (test_opt(inode->i_sb, POSIX_ACL) && acl) { 324 324 struct posix_acl *clone;
+1 -1
fs/ext3/acl.c
··· 323 323 return PTR_ERR(acl); 324 324 } 325 325 if (!acl) 326 - inode->i_mode &= ~current->fs->umask; 326 + inode->i_mode &= ~current_umask(); 327 327 } 328 328 if (test_opt(inode->i_sb, POSIX_ACL) && acl) { 329 329 struct posix_acl *clone;
+1 -1
fs/ext4/acl.c
··· 323 323 return PTR_ERR(acl); 324 324 } 325 325 if (!acl) 326 - inode->i_mode &= ~current->fs->umask; 326 + inode->i_mode &= ~current_umask(); 327 327 } 328 328 if (test_opt(inode->i_sb, POSIX_ACL) && acl) { 329 329 struct posix_acl *clone;
+1 -1
fs/fat/inode.c
··· 930 930 931 931 opts->fs_uid = current_uid(); 932 932 opts->fs_gid = current_gid(); 933 - opts->fs_fmask = opts->fs_dmask = current->fs->umask; 933 + opts->fs_fmask = current_umask(); 934 934 opts->allow_utime = -1; 935 935 opts->codepage = fat_default_codepage; 936 936 opts->iocharset = fat_default_iocharset;
+6
fs/fs_struct.c
··· 138 138 } 139 139 EXPORT_SYMBOL_GPL(unshare_fs_struct); 140 140 141 + int current_umask(void) 142 + { 143 + return current->fs->umask; 144 + } 145 + EXPORT_SYMBOL(current_umask); 146 + 141 147 /* to be mentioned only in INIT_TASK */ 142 148 struct fs_struct init_fs = { 143 149 .users = 1,
+1 -1
fs/generic_acl.c
··· 134 134 mode_t mode = inode->i_mode; 135 135 int error; 136 136 137 - inode->i_mode = mode & ~current->fs->umask; 137 + inode->i_mode = mode & ~current_umask(); 138 138 if (!S_ISLNK(inode->i_mode)) 139 139 acl = ops->getacl(dir, ACL_TYPE_DEFAULT); 140 140 if (acl) {
+1 -1
fs/gfs2/acl.c
··· 215 215 if (error) 216 216 return error; 217 217 if (!acl) { 218 - mode &= ~current->fs->umask; 218 + mode &= ~current_umask(); 219 219 if (mode != ip->i_inode.i_mode) 220 220 error = munge_mode(ip, mode); 221 221 return error;
+1 -1
fs/hfsplus/options.c
··· 48 48 49 49 opts->creator = HFSPLUS_DEF_CR_TYPE; 50 50 opts->type = HFSPLUS_DEF_CR_TYPE; 51 - opts->umask = current->fs->umask; 51 + opts->umask = current_umask(); 52 52 opts->uid = current_uid(); 53 53 opts->gid = current_gid(); 54 54 opts->part = -1;
+1 -1
fs/hpfs/super.c
··· 477 477 478 478 uid = current_uid(); 479 479 gid = current_gid(); 480 - umask = current->fs->umask; 480 + umask = current_umask(); 481 481 lowercase = 0; 482 482 conv = CONV_BINARY; 483 483 eas = 2;
+1 -1
fs/jffs2/acl.c
··· 336 336 return PTR_ERR(acl); 337 337 338 338 if (!acl) { 339 - *i_mode &= ~current->fs->umask; 339 + *i_mode &= ~current_umask(); 340 340 } else { 341 341 if (S_ISDIR(*i_mode)) 342 342 jffs2_iset_acl(inode, &f->i_acl_default, acl);
+1 -1
fs/jfs/acl.c
··· 182 182 cleanup: 183 183 posix_acl_release(acl); 184 184 } else 185 - inode->i_mode &= ~current->fs->umask; 185 + inode->i_mode &= ~current_umask(); 186 186 187 187 JFS_IP(inode)->mode2 = (JFS_IP(inode)->mode2 & 0xffff0000) | 188 188 inode->i_mode;
+3 -3
fs/namei.c
··· 1578 1578 struct dentry *dir = nd->path.dentry; 1579 1579 1580 1580 if (!IS_POSIXACL(dir->d_inode)) 1581 - mode &= ~current->fs->umask; 1581 + mode &= ~current_umask(); 1582 1582 error = security_path_mknod(&nd->path, path->dentry, mode, 0); 1583 1583 if (error) 1584 1584 goto out_unlock; ··· 1989 1989 goto out_unlock; 1990 1990 } 1991 1991 if (!IS_POSIXACL(nd.path.dentry->d_inode)) 1992 - mode &= ~current->fs->umask; 1992 + mode &= ~current_umask(); 1993 1993 error = may_mknod(mode); 1994 1994 if (error) 1995 1995 goto out_dput; ··· 2067 2067 goto out_unlock; 2068 2068 2069 2069 if (!IS_POSIXACL(nd.path.dentry->d_inode)) 2070 - mode &= ~current->fs->umask; 2070 + mode &= ~current_umask(); 2071 2071 error = mnt_want_write(nd.path.mnt); 2072 2072 if (error) 2073 2073 goto out_dput;
+3 -3
fs/nfs/nfs3proc.c
··· 328 328 data->arg.create.verifier[1] = current->pid; 329 329 } 330 330 331 - sattr->ia_mode &= ~current->fs->umask; 331 + sattr->ia_mode &= ~current_umask(); 332 332 333 333 for (;;) { 334 334 status = nfs3_do_create(dir, dentry, data); ··· 528 528 529 529 dprintk("NFS call mkdir %s\n", dentry->d_name.name); 530 530 531 - sattr->ia_mode &= ~current->fs->umask; 531 + sattr->ia_mode &= ~current_umask(); 532 532 533 533 data = nfs3_alloc_createdata(); 534 534 if (data == NULL) ··· 639 639 dprintk("NFS call mknod %s %u:%u\n", dentry->d_name.name, 640 640 MAJOR(rdev), MINOR(rdev)); 641 641 642 - sattr->ia_mode &= ~current->fs->umask; 642 + sattr->ia_mode &= ~current_umask(); 643 643 644 644 data = nfs3_alloc_createdata(); 645 645 if (data == NULL)
+1 -1
fs/nfs/nfs4proc.c
··· 1509 1509 attr.ia_mode = nd->intent.open.create_mode; 1510 1510 attr.ia_valid = ATTR_MODE; 1511 1511 if (!IS_POSIXACL(dir)) 1512 - attr.ia_mode &= ~current->fs->umask; 1512 + attr.ia_mode &= ~current_umask(); 1513 1513 } else { 1514 1514 attr.ia_valid = 0; 1515 1515 BUG_ON(nd->intent.open.flags & O_CREAT);
+1 -1
fs/ocfs2/acl.c
··· 296 296 return PTR_ERR(acl); 297 297 } 298 298 if (!acl) 299 - inode->i_mode &= ~current->fs->umask; 299 + inode->i_mode &= ~current_umask(); 300 300 } 301 301 if ((osb->s_mount_opt & OCFS2_MOUNT_POSIX_ACL) && acl) { 302 302 struct posix_acl *clone;
+1 -1
fs/omfs/inode.c
··· 421 421 422 422 sbi->s_uid = current_uid(); 423 423 sbi->s_gid = current_gid(); 424 - sbi->s_dmask = sbi->s_fmask = current->fs->umask; 424 + sbi->s_dmask = sbi->s_fmask = current_umask(); 425 425 426 426 if (!parse_options((char *) data, sbi)) 427 427 goto end;
+1 -1
fs/reiserfs/xattr_acl.c
··· 428 428 } else { 429 429 apply_umask: 430 430 /* no ACL, apply umask */ 431 - inode->i_mode &= ~current->fs->umask; 431 + inode->i_mode &= ~current_umask(); 432 432 } 433 433 434 434 return err;
+2 -2
fs/xfs/linux-2.6/xfs_iops.c
··· 227 227 xfs_dentry_to_name(&name, dentry); 228 228 229 229 if (IS_POSIXACL(dir) && !default_acl) 230 - mode &= ~current->fs->umask; 230 + mode &= ~current_umask(); 231 231 232 232 switch (mode & S_IFMT) { 233 233 case S_IFCHR: ··· 416 416 mode_t mode; 417 417 418 418 mode = S_IFLNK | 419 - (irix_symlink_mode ? 0777 & ~current->fs->umask : S_IRWXUGO); 419 + (irix_symlink_mode ? 0777 & ~current_umask() : S_IRWXUGO); 420 420 xfs_dentry_to_name(&name, dentry); 421 421 422 422 error = xfs_symlink(XFS_I(dir), &name, symname, mode, &cip, NULL);
+2
include/linux/fs.h
··· 1741 1741 1742 1742 extern int vfs_statfs(struct dentry *, struct kstatfs *); 1743 1743 1744 + extern int current_umask(void); 1745 + 1744 1746 /* /sys/fs */ 1745 1747 extern struct kobject *fs_kobj; 1746 1748
+1 -1
ipc/mqueue.c
··· 602 602 dentry->d_fsdata = attr; 603 603 } 604 604 605 - mode &= ~current->fs->umask; 605 + mode &= ~current_umask(); 606 606 ret = mnt_want_write(mqueue_mnt); 607 607 if (ret) 608 608 goto out;
+1 -1
net/unix/af_unix.c
··· 832 832 * All right, let's create it. 833 833 */ 834 834 mode = S_IFSOCK | 835 - (SOCK_INODE(sock)->i_mode & ~current->fs->umask); 835 + (SOCK_INODE(sock)->i_mode & ~current_umask()); 836 836 err = mnt_want_write(nd.path.mnt); 837 837 if (err) 838 838 goto out_mknod_dput;