Skip to content

Commit 7de64d5

Browse files
amir73ilMiklos Szeredi
authored and
Miklos Szeredi
committed
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 <[email protected]> Signed-off-by: Amir Goldstein <[email protected]> Signed-off-by: Miklos Szeredi <[email protected]>
1 parent e26ee4e commit 7de64d5

File tree

3 files changed

+26
-13
lines changed

3 files changed

+26
-13
lines changed

fs/fuse/dir.c

+24-1
Original file line numberDiff line numberDiff line change
@@ -1630,7 +1630,30 @@ static const char *fuse_get_link(struct dentry *dentry, struct inode *inode,
16301630

16311631
static int fuse_dir_open(struct inode *inode, struct file *file)
16321632
{
1633-
return fuse_open_common(inode, file, true);
1633+
struct fuse_mount *fm = get_fuse_mount(inode);
1634+
int err;
1635+
1636+
if (fuse_is_bad(inode))
1637+
return -EIO;
1638+
1639+
err = generic_file_open(inode, file);
1640+
if (err)
1641+
return err;
1642+
1643+
err = fuse_do_open(fm, get_node_id(inode), file, true);
1644+
if (!err) {
1645+
struct fuse_file *ff = file->private_data;
1646+
1647+
/*
1648+
* Keep handling FOPEN_STREAM and FOPEN_NONSEEKABLE for
1649+
* directories for backward compatibility, though it's unlikely
1650+
* to be useful.
1651+
*/
1652+
if (ff->open_flags & (FOPEN_STREAM | FOPEN_NONSEEKABLE))
1653+
nonseekable_open(inode, file);
1654+
}
1655+
1656+
return err;
16341657
}
16351658

16361659
static int fuse_dir_release(struct inode *inode, struct file *file)

fs/fuse/file.c

+2-7
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ static void fuse_truncate_update_attr(struct inode *inode, struct file *file)
227227
fuse_invalidate_attr_mask(inode, FUSE_STATX_MODSIZE);
228228
}
229229

230-
int fuse_open_common(struct inode *inode, struct file *file, bool isdir)
230+
static int fuse_open(struct inode *inode, struct file *file)
231231
{
232232
struct fuse_mount *fm = get_fuse_mount(inode);
233233
struct fuse_conn *fc = fm->fc;
@@ -256,7 +256,7 @@ int fuse_open_common(struct inode *inode, struct file *file, bool isdir)
256256
if (is_wb_truncate || dax_truncate)
257257
fuse_set_nowrite(inode);
258258

259-
err = fuse_do_open(fm, get_node_id(inode), file, isdir);
259+
err = fuse_do_open(fm, get_node_id(inode), file, false);
260260
if (!err) {
261261
fuse_finish_open(inode, file);
262262
if (is_truncate)
@@ -354,11 +354,6 @@ void fuse_release_common(struct file *file, bool isdir)
354354
(fl_owner_t) file, isdir);
355355
}
356356

357-
static int fuse_open(struct inode *inode, struct file *file)
358-
{
359-
return fuse_open_common(inode, file, false);
360-
}
361-
362357
static int fuse_release(struct inode *inode, struct file *file)
363358
{
364359
struct fuse_conn *fc = get_fuse_conn(inode);

fs/fuse/fuse_i.h

-5
Original file line numberDiff line numberDiff line change
@@ -1031,11 +1031,6 @@ void fuse_read_args_fill(struct fuse_io_args *ia, struct file *file, loff_t pos,
10311031
size_t count, int opcode);
10321032

10331033

1034-
/**
1035-
* Send OPEN or OPENDIR request
1036-
*/
1037-
int fuse_open_common(struct inode *inode, struct file *file, bool isdir);
1038-
10391034
struct fuse_file *fuse_file_alloc(struct fuse_mount *fm, bool release);
10401035
void fuse_file_free(struct fuse_file *ff);
10411036
void fuse_finish_open(struct inode *inode, struct file *file);

0 commit comments

Comments
 (0)