diff --git a/include/client/hooks.hpp b/include/client/hooks.hpp index 9af366dd40d38eb7b08f46b073b76fa698c52416..fcc043717edd649c5fb94d18ed817544b19fb636 100644 --- a/include/client/hooks.hpp +++ b/include/client/hooks.hpp @@ -105,6 +105,8 @@ int hook_statfs(const char* path, struct statfs* buf); int hook_fstatfs(unsigned int fd, struct statfs* buf); +int hook_fsync(unsigned int fd); + } // namespace hook } // namespace gkfs diff --git a/src/client/hooks.cpp b/src/client/hooks.cpp index 7ca89a4fe762b03cbe908cb0a1701b8943beca32..a16d9ea9670301ae6c21e40e61293618dc2c5231 100644 --- a/src/client/hooks.cpp +++ b/src/client/hooks.cpp @@ -814,5 +814,19 @@ int hook_fstatfs(unsigned int fd, struct statfs* buf) { return syscall_no_intercept(SYS_fstatfs, fd, buf); } +/* The function should broadcast a flush message (pmem_persist i.e.) if the application needs the capabilities*/ +int hook_fsync(unsigned int fd) { + + LOG(DEBUG, "{}() called with fd: {}", + __func__, fd); + + if (CTX->file_map()->exist(fd)) { + errno = 0; + return 0; + } + + return syscall_no_intercept(SYS_fsync, fd); +} + } // namespace hook } // namespace gkfs diff --git a/src/client/intercept.cpp b/src/client/intercept.cpp index 708cafe6d5e2560d9ce25c42025d11486b706827..19f786a9bb164f28df471d3568e0fe62306c618e 100644 --- a/src/client/intercept.cpp +++ b/src/client/intercept.cpp @@ -726,6 +726,10 @@ int hook(long syscall_number, reinterpret_cast(arg1)); break; + case SYS_fsync: + *result = gkfs::hook::hook_fsync(static_cast(arg0)); + break; + default: // ignore any other syscalls, i.e.: pass them on to the kernel // (syscalls forwarded to the kernel that return are logged in