fuse: break up fuse_open_common()
fuse_open_common() has a lot of code relevant only for regular files and O_TRUNC in particular. Copy the little bit of remaining code into fuse_dir_open() and stop using this common helper for directory open. Also split out fuse_dir_finish_open() from fuse_finish_open() before we add inode io modes to fuse_finish_open(). Suggested-by: Miklos Szeredi <miklos@szeredi.hu> Signed-off-by: Amir Goldstein <amir73il@gmail.com> Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
This commit is contained in:
parent
e26ee4efbc
commit
7de64d521b
@ -1630,7 +1630,30 @@ out_err:
|
|||||||
|
|
||||||
static int fuse_dir_open(struct inode *inode, struct file *file)
|
static int fuse_dir_open(struct inode *inode, struct file *file)
|
||||||
{
|
{
|
||||||
return fuse_open_common(inode, file, true);
|
struct fuse_mount *fm = get_fuse_mount(inode);
|
||||||
|
int err;
|
||||||
|
|
||||||
|
if (fuse_is_bad(inode))
|
||||||
|
return -EIO;
|
||||||
|
|
||||||
|
err = generic_file_open(inode, file);
|
||||||
|
if (err)
|
||||||
|
return err;
|
||||||
|
|
||||||
|
err = fuse_do_open(fm, get_node_id(inode), file, true);
|
||||||
|
if (!err) {
|
||||||
|
struct fuse_file *ff = file->private_data;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Keep handling FOPEN_STREAM and FOPEN_NONSEEKABLE for
|
||||||
|
* directories for backward compatibility, though it's unlikely
|
||||||
|
* to be useful.
|
||||||
|
*/
|
||||||
|
if (ff->open_flags & (FOPEN_STREAM | FOPEN_NONSEEKABLE))
|
||||||
|
nonseekable_open(inode, file);
|
||||||
|
}
|
||||||
|
|
||||||
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int fuse_dir_release(struct inode *inode, struct file *file)
|
static int fuse_dir_release(struct inode *inode, struct file *file)
|
||||||
|
@ -227,7 +227,7 @@ static void fuse_truncate_update_attr(struct inode *inode, struct file *file)
|
|||||||
fuse_invalidate_attr_mask(inode, FUSE_STATX_MODSIZE);
|
fuse_invalidate_attr_mask(inode, FUSE_STATX_MODSIZE);
|
||||||
}
|
}
|
||||||
|
|
||||||
int fuse_open_common(struct inode *inode, struct file *file, bool isdir)
|
static int fuse_open(struct inode *inode, struct file *file)
|
||||||
{
|
{
|
||||||
struct fuse_mount *fm = get_fuse_mount(inode);
|
struct fuse_mount *fm = get_fuse_mount(inode);
|
||||||
struct fuse_conn *fc = fm->fc;
|
struct fuse_conn *fc = fm->fc;
|
||||||
@ -256,7 +256,7 @@ int fuse_open_common(struct inode *inode, struct file *file, bool isdir)
|
|||||||
if (is_wb_truncate || dax_truncate)
|
if (is_wb_truncate || dax_truncate)
|
||||||
fuse_set_nowrite(inode);
|
fuse_set_nowrite(inode);
|
||||||
|
|
||||||
err = fuse_do_open(fm, get_node_id(inode), file, isdir);
|
err = fuse_do_open(fm, get_node_id(inode), file, false);
|
||||||
if (!err) {
|
if (!err) {
|
||||||
fuse_finish_open(inode, file);
|
fuse_finish_open(inode, file);
|
||||||
if (is_truncate)
|
if (is_truncate)
|
||||||
@ -354,11 +354,6 @@ void fuse_release_common(struct file *file, bool isdir)
|
|||||||
(fl_owner_t) file, isdir);
|
(fl_owner_t) file, isdir);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int fuse_open(struct inode *inode, struct file *file)
|
|
||||||
{
|
|
||||||
return fuse_open_common(inode, file, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
static int fuse_release(struct inode *inode, struct file *file)
|
static int fuse_release(struct inode *inode, struct file *file)
|
||||||
{
|
{
|
||||||
struct fuse_conn *fc = get_fuse_conn(inode);
|
struct fuse_conn *fc = get_fuse_conn(inode);
|
||||||
|
@ -1031,11 +1031,6 @@ void fuse_read_args_fill(struct fuse_io_args *ia, struct file *file, loff_t pos,
|
|||||||
size_t count, int opcode);
|
size_t count, int opcode);
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Send OPEN or OPENDIR request
|
|
||||||
*/
|
|
||||||
int fuse_open_common(struct inode *inode, struct file *file, bool isdir);
|
|
||||||
|
|
||||||
struct fuse_file *fuse_file_alloc(struct fuse_mount *fm, bool release);
|
struct fuse_file *fuse_file_alloc(struct fuse_mount *fm, bool release);
|
||||||
void fuse_file_free(struct fuse_file *ff);
|
void fuse_file_free(struct fuse_file *ff);
|
||||||
void fuse_finish_open(struct inode *inode, struct file *file);
|
void fuse_finish_open(struct inode *inode, struct file *file);
|
||||||
|
Loading…
Reference in New Issue
Block a user