mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-11-11 04:18:39 +08:00
minix: make minix_new_inode() return error as ERR_PTR(-E...)
adjust the callers Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
This commit is contained in:
parent
b7bfaa761d
commit
4a29a1262a
@ -210,7 +210,7 @@ void minix_free_inode(struct inode * inode)
|
||||
mark_buffer_dirty(bh);
|
||||
}
|
||||
|
||||
struct inode *minix_new_inode(const struct inode *dir, umode_t mode, int *error)
|
||||
struct inode *minix_new_inode(const struct inode *dir, umode_t mode)
|
||||
{
|
||||
struct super_block *sb = dir->i_sb;
|
||||
struct minix_sb_info *sbi = minix_sb(sb);
|
||||
@ -220,13 +220,10 @@ struct inode *minix_new_inode(const struct inode *dir, umode_t mode, int *error)
|
||||
unsigned long j;
|
||||
int i;
|
||||
|
||||
if (!inode) {
|
||||
*error = -ENOMEM;
|
||||
return NULL;
|
||||
}
|
||||
if (!inode)
|
||||
return ERR_PTR(-ENOMEM);
|
||||
j = bits_per_zone;
|
||||
bh = NULL;
|
||||
*error = -ENOSPC;
|
||||
spin_lock(&bitmap_lock);
|
||||
for (i = 0; i < sbi->s_imap_blocks; i++) {
|
||||
bh = sbi->s_imap[i];
|
||||
@ -237,20 +234,20 @@ struct inode *minix_new_inode(const struct inode *dir, umode_t mode, int *error)
|
||||
if (!bh || j >= bits_per_zone) {
|
||||
spin_unlock(&bitmap_lock);
|
||||
iput(inode);
|
||||
return NULL;
|
||||
return ERR_PTR(-ENOSPC);
|
||||
}
|
||||
if (minix_test_and_set_bit(j, bh->b_data)) { /* shouldn't happen */
|
||||
spin_unlock(&bitmap_lock);
|
||||
printk("minix_new_inode: bit already set\n");
|
||||
iput(inode);
|
||||
return NULL;
|
||||
return ERR_PTR(-ENOSPC);
|
||||
}
|
||||
spin_unlock(&bitmap_lock);
|
||||
mark_buffer_dirty(bh);
|
||||
j += i * bits_per_zone;
|
||||
if (!j || j > sbi->s_ninodes) {
|
||||
iput(inode);
|
||||
return NULL;
|
||||
return ERR_PTR(-ENOSPC);
|
||||
}
|
||||
inode_init_owner(&init_user_ns, inode, dir, mode);
|
||||
inode->i_ino = j;
|
||||
@ -260,7 +257,6 @@ struct inode *minix_new_inode(const struct inode *dir, umode_t mode, int *error)
|
||||
insert_inode_hash(inode);
|
||||
mark_inode_dirty(inode);
|
||||
|
||||
*error = 0;
|
||||
return inode;
|
||||
}
|
||||
|
||||
|
@ -45,7 +45,7 @@ struct minix_sb_info {
|
||||
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 minix2_inode * minix_V2_raw_inode(struct super_block *, ino_t, struct buffer_head **);
|
||||
extern struct inode * minix_new_inode(const struct inode *, umode_t, int *);
|
||||
extern struct inode * minix_new_inode(const struct inode *, umode_t);
|
||||
extern void minix_free_inode(struct inode * inode);
|
||||
extern unsigned long minix_count_free_inodes(struct super_block *sb);
|
||||
extern int minix_new_block(struct inode * inode);
|
||||
|
@ -36,33 +36,31 @@ static struct dentry *minix_lookup(struct inode * dir, struct dentry *dentry, un
|
||||
static int minix_mknod(struct user_namespace *mnt_userns, struct inode *dir,
|
||||
struct dentry *dentry, umode_t mode, dev_t rdev)
|
||||
{
|
||||
int error;
|
||||
struct inode *inode;
|
||||
|
||||
if (!old_valid_dev(rdev))
|
||||
return -EINVAL;
|
||||
|
||||
inode = minix_new_inode(dir, mode, &error);
|
||||
inode = minix_new_inode(dir, mode);
|
||||
if (IS_ERR(inode))
|
||||
return PTR_ERR(inode);
|
||||
|
||||
if (inode) {
|
||||
minix_set_inode(inode, rdev);
|
||||
mark_inode_dirty(inode);
|
||||
error = add_nondir(dentry, inode);
|
||||
}
|
||||
return error;
|
||||
minix_set_inode(inode, rdev);
|
||||
mark_inode_dirty(inode);
|
||||
return add_nondir(dentry, inode);
|
||||
}
|
||||
|
||||
static int minix_tmpfile(struct user_namespace *mnt_userns, struct inode *dir,
|
||||
struct file *file, umode_t mode)
|
||||
{
|
||||
int error;
|
||||
struct inode *inode = minix_new_inode(dir, mode, &error);
|
||||
if (inode) {
|
||||
minix_set_inode(inode, 0);
|
||||
mark_inode_dirty(inode);
|
||||
d_tmpfile(file, inode);
|
||||
}
|
||||
return finish_open_simple(file, error);
|
||||
struct inode *inode = minix_new_inode(dir, mode);
|
||||
|
||||
if (IS_ERR(inode))
|
||||
return finish_open_simple(file, PTR_ERR(inode));
|
||||
minix_set_inode(inode, 0);
|
||||
mark_inode_dirty(inode);
|
||||
d_tmpfile(file, inode);
|
||||
return finish_open_simple(file, 0);
|
||||
}
|
||||
|
||||
static int minix_create(struct user_namespace *mnt_userns, struct inode *dir,
|
||||
@ -74,30 +72,25 @@ static int minix_create(struct user_namespace *mnt_userns, struct inode *dir,
|
||||
static int minix_symlink(struct user_namespace *mnt_userns, struct inode *dir,
|
||||
struct dentry *dentry, const char *symname)
|
||||
{
|
||||
int err = -ENAMETOOLONG;
|
||||
int i = strlen(symname)+1;
|
||||
struct inode * inode;
|
||||
int err;
|
||||
|
||||
if (i > dir->i_sb->s_blocksize)
|
||||
goto out;
|
||||
return -ENAMETOOLONG;
|
||||
|
||||
inode = minix_new_inode(dir, S_IFLNK | 0777, &err);
|
||||
if (!inode)
|
||||
goto out;
|
||||
inode = minix_new_inode(dir, S_IFLNK | 0777);
|
||||
if (IS_ERR(inode))
|
||||
return PTR_ERR(inode);
|
||||
|
||||
minix_set_inode(inode, 0);
|
||||
err = page_symlink(inode, symname, i);
|
||||
if (err)
|
||||
goto out_fail;
|
||||
|
||||
err = add_nondir(dentry, inode);
|
||||
out:
|
||||
return err;
|
||||
|
||||
out_fail:
|
||||
inode_dec_link_count(inode);
|
||||
iput(inode);
|
||||
goto out;
|
||||
if (unlikely(err)) {
|
||||
inode_dec_link_count(inode);
|
||||
iput(inode);
|
||||
return err;
|
||||
}
|
||||
return add_nondir(dentry, inode);
|
||||
}
|
||||
|
||||
static int minix_link(struct dentry * old_dentry, struct inode * dir,
|
||||
@ -117,14 +110,12 @@ static int minix_mkdir(struct user_namespace *mnt_userns, struct inode *dir,
|
||||
struct inode * inode;
|
||||
int err;
|
||||
|
||||
inode = minix_new_inode(dir, S_IFDIR | mode);
|
||||
if (IS_ERR(inode))
|
||||
return PTR_ERR(inode);
|
||||
|
||||
inode_inc_link_count(dir);
|
||||
|
||||
inode = minix_new_inode(dir, S_IFDIR | mode, &err);
|
||||
if (!inode)
|
||||
goto out_dir;
|
||||
|
||||
minix_set_inode(inode, 0);
|
||||
|
||||
inode_inc_link_count(inode);
|
||||
|
||||
err = minix_make_empty(inode, dir);
|
||||
@ -143,7 +134,6 @@ out_fail:
|
||||
inode_dec_link_count(inode);
|
||||
inode_dec_link_count(inode);
|
||||
iput(inode);
|
||||
out_dir:
|
||||
inode_dec_link_count(dir);
|
||||
goto out;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user