Commit 9eed1fb7 authored by Dmitry Monakhov's avatar Dmitry Monakhov Committed by Al Viro

minix: replace inode uid,gid,mode init with helper

- also redesign minix_new_inode interface
Signed-off-by: default avatarDmitry Monakhov <dmonakhov@openvz.org>
Signed-off-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
parent b10b8520
...@@ -221,7 +221,7 @@ void minix_free_inode(struct inode * inode) ...@@ -221,7 +221,7 @@ void minix_free_inode(struct inode * inode)
clear_inode(inode); /* clear in-memory copy */ clear_inode(inode); /* clear in-memory copy */
} }
struct inode * minix_new_inode(const struct inode * dir, int * error) struct inode *minix_new_inode(const struct inode *dir, int mode, int *error)
{ {
struct super_block *sb = dir->i_sb; struct super_block *sb = dir->i_sb;
struct minix_sb_info *sbi = minix_sb(sb); struct minix_sb_info *sbi = minix_sb(sb);
...@@ -263,8 +263,7 @@ struct inode * minix_new_inode(const struct inode * dir, int * error) ...@@ -263,8 +263,7 @@ struct inode * minix_new_inode(const struct inode * dir, int * error)
iput(inode); iput(inode);
return NULL; return NULL;
} }
inode->i_uid = current_fsuid(); inode_init_owner(inode, dir, mode);
inode->i_gid = (dir->i_mode & S_ISGID) ? dir->i_gid : current_fsgid();
inode->i_ino = j; inode->i_ino = j;
inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME_SEC; inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME_SEC;
inode->i_blocks = 0; inode->i_blocks = 0;
......
...@@ -46,7 +46,7 @@ struct minix_sb_info { ...@@ -46,7 +46,7 @@ struct minix_sb_info {
extern struct inode *minix_iget(struct super_block *, unsigned long); extern struct inode *minix_iget(struct super_block *, unsigned long);
extern struct minix_inode * minix_V1_raw_inode(struct super_block *, ino_t, struct buffer_head **); extern struct minix_inode * minix_V1_raw_inode(struct super_block *, ino_t, struct buffer_head **);
extern struct minix2_inode * minix_V2_raw_inode(struct super_block *, ino_t, struct buffer_head **); extern struct minix2_inode * minix_V2_raw_inode(struct super_block *, ino_t, struct buffer_head **);
extern struct inode * minix_new_inode(const struct inode * dir, int * error); extern struct inode * minix_new_inode(const struct inode *, int, int *);
extern void minix_free_inode(struct inode * inode); extern void minix_free_inode(struct inode * inode);
extern unsigned long minix_count_free_inodes(struct minix_sb_info *sbi); extern unsigned long minix_count_free_inodes(struct minix_sb_info *sbi);
extern int minix_new_block(struct inode * inode); extern int minix_new_block(struct inode * inode);
......
...@@ -46,10 +46,9 @@ static int minix_mknod(struct inode * dir, struct dentry *dentry, int mode, dev_ ...@@ -46,10 +46,9 @@ static int minix_mknod(struct inode * dir, struct dentry *dentry, int mode, dev_
if (!old_valid_dev(rdev)) if (!old_valid_dev(rdev))
return -EINVAL; return -EINVAL;
inode = minix_new_inode(dir, &error); inode = minix_new_inode(dir, mode, &error);
if (inode) { if (inode) {
inode->i_mode = mode;
minix_set_inode(inode, rdev); minix_set_inode(inode, rdev);
mark_inode_dirty(inode); mark_inode_dirty(inode);
error = add_nondir(dentry, inode); error = add_nondir(dentry, inode);
...@@ -73,11 +72,10 @@ static int minix_symlink(struct inode * dir, struct dentry *dentry, ...@@ -73,11 +72,10 @@ static int minix_symlink(struct inode * dir, struct dentry *dentry,
if (i > dir->i_sb->s_blocksize) if (i > dir->i_sb->s_blocksize)
goto out; goto out;
inode = minix_new_inode(dir, &err); inode = minix_new_inode(dir, S_IFLNK | 0777, &err);
if (!inode) if (!inode)
goto out; goto out;
inode->i_mode = S_IFLNK | 0777;
minix_set_inode(inode, 0); minix_set_inode(inode, 0);
err = page_symlink(inode, symname, i); err = page_symlink(inode, symname, i);
if (err) if (err)
...@@ -117,13 +115,10 @@ static int minix_mkdir(struct inode * dir, struct dentry *dentry, int mode) ...@@ -117,13 +115,10 @@ static int minix_mkdir(struct inode * dir, struct dentry *dentry, int mode)
inode_inc_link_count(dir); inode_inc_link_count(dir);
inode = minix_new_inode(dir, &err); inode = minix_new_inode(dir, mode, &err);
if (!inode) if (!inode)
goto out_dir; goto out_dir;
inode->i_mode = S_IFDIR | mode;
if (dir->i_mode & S_ISGID)
inode->i_mode |= S_ISGID;
minix_set_inode(inode, 0); minix_set_inode(inode, 0);
inode_inc_link_count(inode); inode_inc_link_count(inode);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment