From: Darrick J. Wong <djwong@xxxxxxxxxx> Enable syncfs calls in fuse2fs. Signed-off-by: "Darrick J. Wong" <djwong@xxxxxxxxxx> --- misc/fuse2fs.c | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/misc/fuse2fs.c b/misc/fuse2fs.c index 15595fdf0b19ba..66baca72ad49d1 100644 --- a/misc/fuse2fs.c +++ b/misc/fuse2fs.c @@ -5099,6 +5099,42 @@ static int op_fallocate(const char *path EXT2FS_ATTR((unused)), int mode, # endif /* SUPPORT_FALLOCATE */ #endif /* FUSE 29 */ +#if FUSE_VERSION >= FUSE_MAKE_VERSION(3, 18) +static int op_syncfs(const char *path) +{ + struct fuse_context *ctxt = fuse_get_context(); + struct fuse2fs *ff = (struct fuse2fs *)ctxt->private_data; + ext2_filsys fs; + errcode_t err; + int ret = 0; + + FUSE2FS_CHECK_CONTEXT(ff); + dbg_printf(ff, "%s: path=%s\n", __func__, path); + fs = fuse2fs_start(ff); + + if (ff->opstate == F2OP_WRITABLE) { + if (fs->super->s_error_count) + fs->super->s_state |= EXT2_ERROR_FS; + ext2fs_mark_super_dirty(fs); + err = ext2fs_set_gdt_csum(fs); + if (err) { + ret = translate_error(fs, 0, err); + goto out_unlock; + } + + err = ext2fs_flush2(fs, 0); + if (err) { + ret = translate_error(fs, 0, err); + goto out_unlock; + } + } + +out_unlock: + fuse2fs_finish(ff, ret); + return ret; +} +#endif + #ifdef HAVE_FUSE_IOMAP static void fuse2fs_iomap_hole(struct fuse2fs *ff, struct fuse_iomap *iomap, off_t pos, uint64_t count) @@ -6301,6 +6337,9 @@ static struct fuse_operations fs_ops = { .fallocate = op_fallocate, # endif #endif +#if FUSE_VERSION >= FUSE_MAKE_VERSION(3, 18) + .syncfs = op_syncfs, +#endif #ifdef HAVE_FUSE_IOMAP .iomap_begin = op_iomap_begin, .iomap_end = op_iomap_end,