Kernel: SYS_SYNC now schedules sync to happen soon

You can pass non-zero argument to the syscall to block until the
sync has finished.
This commit is contained in:
Bananymous
2023-09-27 00:34:00 +03:00
parent 11db49e2d3
commit 1e6930a3bc
5 changed files with 74 additions and 17 deletions

View File

@@ -2,6 +2,7 @@
#include <kernel/Device/Device.h>
#include <kernel/FS/RamFS/FileSystem.h>
#include <kernel/Semaphore.h>
namespace Kernel
{
@@ -19,6 +20,8 @@ namespace Kernel
dev_t get_next_dev();
void initiate_sync(bool should_block);
private:
DevFileSystem(size_t size)
: RamFileSystem(size)
@@ -26,6 +29,10 @@ namespace Kernel
private:
SpinLock m_device_lock;
Semaphore m_sync_done;
Semaphore m_sync_semaphore;
volatile bool m_should_sync { false };
};
}

View File

@@ -109,7 +109,7 @@ namespace Kernel
BAN::ErrorOr<long> sys_fstatat(int fd, const char* path, struct stat* buf, int flag);
BAN::ErrorOr<long> sys_stat(const char* path, struct stat* buf, int flag);
BAN::ErrorOr<long> sys_sync();
BAN::ErrorOr<long> sys_sync(bool should_block);
BAN::ErrorOr<void> mount(BAN::StringView source, BAN::StringView target);