1
0
Fork 0

switch do_dentry_open() to returning int

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
hifive-unleashed-5.1
Al Viro 2012-06-10 14:22:04 -04:00
parent e45198a6ac
commit 96b7e579ad
1 changed files with 20 additions and 20 deletions

View File

@ -667,10 +667,10 @@ int open_check_o_direct(struct file *f)
return 0; return 0;
} }
static struct file *do_dentry_open(struct dentry *dentry, struct vfsmount *mnt, static int do_dentry_open(struct dentry *dentry, struct vfsmount *mnt,
struct file *f, struct file *f,
int (*open)(struct inode *, struct file *), int (*open)(struct inode *, struct file *),
const struct cred *cred) const struct cred *cred)
{ {
static const struct file_operations empty_fops = {}; static const struct file_operations empty_fops = {};
struct inode *inode; struct inode *inode;
@ -699,7 +699,7 @@ static struct file *do_dentry_open(struct dentry *dentry, struct vfsmount *mnt,
if (unlikely(f->f_mode & FMODE_PATH)) { if (unlikely(f->f_mode & FMODE_PATH)) {
f->f_op = &empty_fops; f->f_op = &empty_fops;
return f; return 0;
} }
f->f_op = fops_get(inode->i_fop); f->f_op = fops_get(inode->i_fop);
@ -726,7 +726,7 @@ static struct file *do_dentry_open(struct dentry *dentry, struct vfsmount *mnt,
file_ra_state_init(&f->f_ra, f->f_mapping->host->i_mapping); file_ra_state_init(&f->f_ra, f->f_mapping->host->i_mapping);
return f; return 0;
cleanup_all: cleanup_all:
fops_put(f->f_op); fops_put(f->f_op);
@ -749,7 +749,7 @@ cleanup_all:
cleanup_file: cleanup_file:
dput(dentry); dput(dentry);
mntput(mnt); mntput(mnt);
return ERR_PTR(error); return error;
} }
static struct file *__dentry_open(struct dentry *dentry, struct vfsmount *mnt, static struct file *__dentry_open(struct dentry *dentry, struct vfsmount *mnt,
@ -757,17 +757,19 @@ static struct file *__dentry_open(struct dentry *dentry, struct vfsmount *mnt,
int (*open)(struct inode *, struct file *), int (*open)(struct inode *, struct file *),
const struct cred *cred) const struct cred *cred)
{ {
struct file *res = do_dentry_open(dentry, mnt, f, open, cred); int error;
if (!IS_ERR(res)) { error = do_dentry_open(dentry, mnt, f, open, cred);
int error = open_check_o_direct(f); if (!error) {
error = open_check_o_direct(f);
if (error) { if (error) {
fput(res); fput(f);
res = ERR_PTR(error); f = ERR_PTR(error);
} }
} else { } else {
put_filp(f); put_filp(f);
f = ERR_PTR(error);
} }
return res; return f;
} }
/** /**
@ -785,19 +787,17 @@ int finish_open(struct file *file, struct dentry *dentry,
int (*open)(struct inode *, struct file *), int (*open)(struct inode *, struct file *),
int *opened) int *opened)
{ {
struct file *res; int error;
BUG_ON(*opened & FILE_OPENED); /* once it's opened, it's opened */ BUG_ON(*opened & FILE_OPENED); /* once it's opened, it's opened */
mntget(file->f_path.mnt); mntget(file->f_path.mnt);
dget(dentry); dget(dentry);
res = do_dentry_open(dentry, file->f_path.mnt, file, open, current_cred()); error = do_dentry_open(dentry, file->f_path.mnt, file, open, current_cred());
if (!IS_ERR(res)) { if (!error)
*opened |= FILE_OPENED; *opened |= FILE_OPENED;
return 0;
}
return PTR_ERR(res); return error;
} }
EXPORT_SYMBOL(finish_open); EXPORT_SYMBOL(finish_open);