From 2da239d0c8efd2e14a76afa6e0baae9edd1664be Mon Sep 17 00:00:00 2001 From: Emery Hemingway Date: Wed, 7 Oct 2015 17:02:52 +0200 Subject: [PATCH] void sync(char const *path) Sync now takes a path argument at VFS and File system interfaces. Issue #1648 --- repos/dde_rump/src/server/rump_fs/main.cc | 2 +- repos/libports/src/lib/libc/vfs_plugin.cc | 2 +- repos/libports/src/server/ffat_fs/main.cc | 3 --- repos/libports/src/server/fuse_fs/fuse_fs_main.cc | 2 +- repos/os/include/file_system_session/client.h | 4 ++-- .../file_system_session/file_system_session.h | 4 ++-- repos/os/include/vfs/dir_file_system.h | 14 ++++++++++++-- repos/os/include/vfs/file_system.h | 6 ++---- repos/os/include/vfs/fs_file_system.h | 8 ++++++-- repos/os/include/vfs/ram_file_system.h | 2 -- repos/os/src/server/lx_fs/main.cc | 2 +- repos/os/src/server/ram_fs/main.cc | 2 -- repos/os/src/server/tar_fs/main.cc | 3 --- repos/os/src/server/trace_fs/main.cc | 2 -- repos/ports/src/noux/main.cc | 2 +- 15 files changed, 29 insertions(+), 29 deletions(-) diff --git a/repos/dde_rump/src/server/rump_fs/main.cc b/repos/dde_rump/src/server/rump_fs/main.cc index f4a04d3e3..5d352634b 100644 --- a/repos/dde_rump/src/server/rump_fs/main.cc +++ b/repos/dde_rump/src/server/rump_fs/main.cc @@ -355,7 +355,7 @@ class File_system::Session_component : public Session_rpc_object _handle_registry.sigh(node_handle, sigh); } - void sync() { rump_sys_sync(); } + void sync(Node_handle) override { rump_sys_sync(); } }; class File_system::Root : public Root_component diff --git a/repos/libports/src/lib/libc/vfs_plugin.cc b/repos/libports/src/lib/libc/vfs_plugin.cc index 749ec2ae4..531077fbd 100644 --- a/repos/libports/src/lib/libc/vfs_plugin.cc +++ b/repos/libports/src/lib/libc/vfs_plugin.cc @@ -715,7 +715,7 @@ int Libc::Vfs_plugin::fcntl(Libc::File_descriptor *fd, int cmd, long arg) int Libc::Vfs_plugin::fsync(Libc::File_descriptor *fd) { - _root_dir.sync(); + _root_dir.sync(fd->fd_path); return 0; } diff --git a/repos/libports/src/server/ffat_fs/main.cc b/repos/libports/src/server/ffat_fs/main.cc index 75daa9076..e3cad4205 100644 --- a/repos/libports/src/server/ffat_fs/main.cc +++ b/repos/libports/src/server/ffat_fs/main.cc @@ -852,9 +852,6 @@ namespace File_system { { PWRN("File_system::Session::sigh not supported"); } - - /* ffat only supports fsync(2) */ - void sync() { } }; diff --git a/repos/libports/src/server/fuse_fs/fuse_fs_main.cc b/repos/libports/src/server/fuse_fs/fuse_fs_main.cc index 0c8a4bd34..f1959d16b 100644 --- a/repos/libports/src/server/fuse_fs/fuse_fs_main.cc +++ b/repos/libports/src/server/fuse_fs/fuse_fs_main.cc @@ -418,7 +418,7 @@ class File_system::Session_component : public Session_rpc_object _handle_registry.sigh(node_handle, sigh); } - void sync() + void sync(Node_handle) override { Fuse::sync_fs(); } diff --git a/repos/os/include/file_system_session/client.h b/repos/os/include/file_system_session/client.h index b1026a6d8..2ba41cc26 100644 --- a/repos/os/include/file_system_session/client.h +++ b/repos/os/include/file_system_session/client.h @@ -106,9 +106,9 @@ class File_system::Session_client : public Rpc_client call(node, sigh); } - void sync() override + void sync(Node_handle node) override { - call(); + call(node); } }; diff --git a/repos/os/include/file_system_session/file_system_session.h b/repos/os/include/file_system_session/file_system_session.h index d1a03938c..5ab438647 100644 --- a/repos/os/include/file_system_session/file_system_session.h +++ b/repos/os/include/file_system_session/file_system_session.h @@ -289,7 +289,7 @@ struct File_system::Session : public Genode::Session * cache, which needs to be flushed on certain occasions. Therefore, * the default implementation just serves as a reminder. */ - virtual void sync() { PWRN("sync() not implemented!"); } + virtual void sync(Node_handle) { } /******************* @@ -328,7 +328,7 @@ struct File_system::Session : public Genode::Session GENODE_RPC_THROW(Rpc_sigh, void, sigh, GENODE_TYPE_LIST(Invalid_handle), Node_handle, Signal_context_capability); - GENODE_RPC(Rpc_sync, void, sync); + GENODE_RPC(Rpc_sync, void, sync, Node_handle); /* * Manual type-list definition, needed because the RPC interface diff --git a/repos/os/include/vfs/dir_file_system.h b/repos/os/include/vfs/dir_file_system.h index ade9ac7c8..d6de58e53 100644 --- a/repos/os/include/vfs/dir_file_system.h +++ b/repos/os/include/vfs/dir_file_system.h @@ -514,10 +514,20 @@ class Vfs::Dir_file_system : public File_system /** * Synchronize all file systems */ - void sync() override + void sync(char const *path) override { + if (strcmp("/", path, 2) == 0) { + for (File_system *fs = _first_file_system; fs; fs = fs->next) + fs->sync("/"); + return; + } + + path = _sub_path(path); + if (!path) + return; + for (File_system *fs = _first_file_system; fs; fs = fs->next) - fs->sync(); + fs->sync(path); } diff --git a/repos/os/include/vfs/file_system.h b/repos/os/include/vfs/file_system.h index 164460536..c9e881bda 100644 --- a/repos/os/include/vfs/file_system.h +++ b/repos/os/include/vfs/file_system.h @@ -32,11 +32,9 @@ struct Vfs::File_system : Directory_service, File_io_service /** * Synchronize file system * - * This method is only used by a Fs_file_system because such a file - * system may employ a backend, which maintains a internal cache, that - * needs to be flushed. + * This method flushes any delayed operations from the file system. */ - virtual void sync() { } + virtual void sync(char const *path) { } }; #endif /* _INCLUDE__VFS__FILE_SYSTEM_H_ */ diff --git a/repos/os/include/vfs/fs_file_system.h b/repos/os/include/vfs/fs_file_system.h index 5322d8898..3284b6d2f 100644 --- a/repos/os/include/vfs/fs_file_system.h +++ b/repos/os/include/vfs/fs_file_system.h @@ -568,9 +568,13 @@ class Vfs::Fs_file_system : public File_system static char const *name() { return "fs"; } - void sync() override + void sync(char const *path) override { - _fs.sync(); + try { + ::File_system::Node_handle node = _fs.node(path); + Fs_handle_guard node_guard(_fs, node); + _fs.sync(node); + } catch (...) { } } diff --git a/repos/os/include/vfs/ram_file_system.h b/repos/os/include/vfs/ram_file_system.h index bd372ee1d..480b0d582 100644 --- a/repos/os/include/vfs/ram_file_system.h +++ b/repos/os/include/vfs/ram_file_system.h @@ -57,8 +57,6 @@ class Vfs::Ram_file_system : public File_system, private ::File_system::Director static char const *name() { return "ram"; } - void sync() { } - /******************************** ** File I/O service interface ** ********************************/ diff --git a/repos/os/src/server/lx_fs/main.cc b/repos/os/src/server/lx_fs/main.cc index 5e256898c..58b14a5d0 100644 --- a/repos/os/src/server/lx_fs/main.cc +++ b/repos/os/src/server/lx_fs/main.cc @@ -311,7 +311,7 @@ class File_system::Session_component : public Session_rpc_object * reminder because besides testing, there is currently no * use-case. */ - void sync() { PWRN("sync() not implemented!"); } + void sync(Node_handle) override { PWRN("sync() not implemented!"); } }; diff --git a/repos/os/src/server/ram_fs/main.cc b/repos/os/src/server/ram_fs/main.cc index d09372a36..a3b79dc6d 100644 --- a/repos/os/src/server/ram_fs/main.cc +++ b/repos/os/src/server/ram_fs/main.cc @@ -408,8 +408,6 @@ namespace File_system { { _handle_registry.sigh(node_handle, sigh); } - - void sync() { } }; diff --git a/repos/os/src/server/tar_fs/main.cc b/repos/os/src/server/tar_fs/main.cc index f8a698cdd..7d7b983b8 100644 --- a/repos/os/src/server/tar_fs/main.cc +++ b/repos/os/src/server/tar_fs/main.cc @@ -440,9 +440,6 @@ namespace File_system { { PWRN("File_system::Session::sigh not supported"); } - - /* merely readonly, no need to sync */ - void sync() { } }; diff --git a/repos/os/src/server/trace_fs/main.cc b/repos/os/src/server/trace_fs/main.cc index eed11e9bb..febf842f2 100644 --- a/repos/os/src/server/trace_fs/main.cc +++ b/repos/os/src/server/trace_fs/main.cc @@ -914,8 +914,6 @@ class File_system::Session_component : public Session_rpc_object void sigh(Node_handle node_handle, Signal_context_capability sigh) { _handle_registry.sigh(node_handle, sigh); } - - void sync() { } }; diff --git a/repos/ports/src/noux/main.cc b/repos/ports/src/noux/main.cc index 5455389c4..dc1b375f4 100644 --- a/repos/ports/src/noux/main.cc +++ b/repos/ports/src/noux/main.cc @@ -835,7 +835,7 @@ bool Noux::Child::syscall(Noux::Session::Syscall sc) case SYSCALL_SYNC: { - root_dir()->sync(); + root_dir()->sync("/"); result = true; break; }