diff options
author | Al Viro <viro@zeniv.linux.org.uk> | 2011-07-24 20:20:48 -0400 |
---|---|---|
committer | Al Viro <viro@zeniv.linux.org.uk> | 2012-01-03 22:54:54 -0500 |
commit | 7d54fa6472609f2b0f2ea27e51ec2cf1fb27bd57 (patch) | |
tree | 822b4bbe8a1a9eda631502b02c9a18b82d7a0801 /fs/hugetlbfs | |
parent | 1a67aafb5f72a436ca044293309fa7e6351d6a35 (diff) |
hugetlbfs: switch to inode_init_owner()
... rather than open-coding it
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'fs/hugetlbfs')
-rw-r--r-- | fs/hugetlbfs/inode.c | 59 |
1 files changed, 32 insertions, 27 deletions
diff --git a/fs/hugetlbfs/inode.c b/fs/hugetlbfs/inode.c index 698485ce5f3f..aa93f9532607 100644 --- a/fs/hugetlbfs/inode.c +++ b/fs/hugetlbfs/inode.c | |||
@@ -447,8 +447,8 @@ static int hugetlbfs_setattr(struct dentry *dentry, struct iattr *attr) | |||
447 | return 0; | 447 | return 0; |
448 | } | 448 | } |
449 | 449 | ||
450 | static struct inode *hugetlbfs_get_inode(struct super_block *sb, uid_t uid, | 450 | static struct inode *hugetlbfs_get_root(struct super_block *sb, |
451 | gid_t gid, int mode, dev_t dev) | 451 | struct hugetlbfs_config *config) |
452 | { | 452 | { |
453 | struct inode *inode; | 453 | struct inode *inode; |
454 | 454 | ||
@@ -456,9 +456,31 @@ static struct inode *hugetlbfs_get_inode(struct super_block *sb, uid_t uid, | |||
456 | if (inode) { | 456 | if (inode) { |
457 | struct hugetlbfs_inode_info *info; | 457 | struct hugetlbfs_inode_info *info; |
458 | inode->i_ino = get_next_ino(); | 458 | inode->i_ino = get_next_ino(); |
459 | inode->i_mode = mode; | 459 | inode->i_mode = S_IFDIR | config->mode; |
460 | inode->i_uid = uid; | 460 | inode->i_uid = config->uid; |
461 | inode->i_gid = gid; | 461 | inode->i_gid = config->gid; |
462 | inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME; | ||
463 | info = HUGETLBFS_I(inode); | ||
464 | mpol_shared_policy_init(&info->policy, NULL); | ||
465 | inode->i_op = &hugetlbfs_dir_inode_operations; | ||
466 | inode->i_fop = &simple_dir_operations; | ||
467 | /* directory inodes start off with i_nlink == 2 (for "." entry) */ | ||
468 | inc_nlink(inode); | ||
469 | } | ||
470 | return inode; | ||
471 | } | ||
472 | |||
473 | static struct inode *hugetlbfs_get_inode(struct super_block *sb, | ||
474 | struct inode *dir, | ||
475 | int mode, dev_t dev) | ||
476 | { | ||
477 | struct inode *inode; | ||
478 | |||
479 | inode = new_inode(sb); | ||
480 | if (inode) { | ||
481 | struct hugetlbfs_inode_info *info; | ||
482 | inode->i_ino = get_next_ino(); | ||
483 | inode_init_owner(inode, dir, mode); | ||
462 | inode->i_mapping->a_ops = &hugetlbfs_aops; | 484 | inode->i_mapping->a_ops = &hugetlbfs_aops; |
463 | inode->i_mapping->backing_dev_info =&hugetlbfs_backing_dev_info; | 485 | inode->i_mapping->backing_dev_info =&hugetlbfs_backing_dev_info; |
464 | inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME; | 486 | inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME; |
@@ -504,16 +526,8 @@ static int hugetlbfs_mknod(struct inode *dir, | |||
504 | { | 526 | { |
505 | struct inode *inode; | 527 | struct inode *inode; |
506 | int error = -ENOSPC; | 528 | int error = -ENOSPC; |
507 | gid_t gid; | 529 | |
508 | 530 | inode = hugetlbfs_get_inode(dir->i_sb, dir, mode, dev); | |
509 | if (dir->i_mode & S_ISGID) { | ||
510 | gid = dir->i_gid; | ||
511 | if (S_ISDIR(mode)) | ||
512 | mode |= S_ISGID; | ||
513 | } else { | ||
514 | gid = current_fsgid(); | ||
515 | } | ||
516 | inode = hugetlbfs_get_inode(dir->i_sb, current_fsuid(), gid, mode, dev); | ||
517 | if (inode) { | 531 | if (inode) { |
518 | dir->i_ctime = dir->i_mtime = CURRENT_TIME; | 532 | dir->i_ctime = dir->i_mtime = CURRENT_TIME; |
519 | d_instantiate(dentry, inode); | 533 | d_instantiate(dentry, inode); |
@@ -541,15 +555,8 @@ static int hugetlbfs_symlink(struct inode *dir, | |||
541 | { | 555 | { |
542 | struct inode *inode; | 556 | struct inode *inode; |
543 | int error = -ENOSPC; | 557 | int error = -ENOSPC; |
544 | gid_t gid; | ||
545 | |||
546 | if (dir->i_mode & S_ISGID) | ||
547 | gid = dir->i_gid; | ||
548 | else | ||
549 | gid = current_fsgid(); | ||
550 | 558 | ||
551 | inode = hugetlbfs_get_inode(dir->i_sb, current_fsuid(), | 559 | inode = hugetlbfs_get_inode(dir->i_sb, dir, S_IFLNK|S_IRWXUGO, 0); |
552 | gid, S_IFLNK|S_IRWXUGO, 0); | ||
553 | if (inode) { | 560 | if (inode) { |
554 | int l = strlen(symname)+1; | 561 | int l = strlen(symname)+1; |
555 | error = page_symlink(inode, symname, l); | 562 | error = page_symlink(inode, symname, l); |
@@ -857,8 +864,7 @@ hugetlbfs_fill_super(struct super_block *sb, void *data, int silent) | |||
857 | sb->s_magic = HUGETLBFS_MAGIC; | 864 | sb->s_magic = HUGETLBFS_MAGIC; |
858 | sb->s_op = &hugetlbfs_ops; | 865 | sb->s_op = &hugetlbfs_ops; |
859 | sb->s_time_gran = 1; | 866 | sb->s_time_gran = 1; |
860 | inode = hugetlbfs_get_inode(sb, config.uid, config.gid, | 867 | inode = hugetlbfs_get_root(sb, &config); |
861 | S_IFDIR | config.mode, 0); | ||
862 | if (!inode) | 868 | if (!inode) |
863 | goto out_free; | 869 | goto out_free; |
864 | 870 | ||
@@ -956,8 +962,7 @@ struct file *hugetlb_file_setup(const char *name, size_t size, | |||
956 | 962 | ||
957 | path.mnt = mntget(hugetlbfs_vfsmount); | 963 | path.mnt = mntget(hugetlbfs_vfsmount); |
958 | error = -ENOSPC; | 964 | error = -ENOSPC; |
959 | inode = hugetlbfs_get_inode(root->d_sb, current_fsuid(), | 965 | inode = hugetlbfs_get_inode(root->d_sb, NULL, S_IFREG | S_IRWXUGO, 0); |
960 | current_fsgid(), S_IFREG | S_IRWXUGO, 0); | ||
961 | if (!inode) | 966 | if (!inode) |
962 | goto out_dentry; | 967 | goto out_dentry; |
963 | 968 | ||