Kernel: Implement SYS_SYNC and add sync executable to userspace

You can (and have to) manually sync disk after writes to it.
This commit is contained in:
Bananymous
2023-09-11 01:26:27 +03:00
parent eee0537053
commit 63dc2b6aa6
14 changed files with 84 additions and 3 deletions

View File

@@ -13,6 +13,7 @@ namespace Kernel
virtual bool is_device() const override { return true; }
virtual bool is_partition() const { return false; }
virtual bool is_storage_device() const { return false; }
virtual dev_t rdev() const override = 0;

View File

@@ -15,6 +15,7 @@ namespace Kernel
void initialize_device_updater();
void add_device(BAN::StringView path, BAN::RefPtr<RamInode>);
void for_each_device(const BAN::Function<BAN::Iteration(Device*)>& callback);
dev_t get_next_dev();

View File

@@ -1,6 +1,7 @@
#pragma once
#include <BAN/HashMap.h>
#include <BAN/Iteration.h>
#include <kernel/FS/FileSystem.h>
#include <kernel/SpinLock.h>
@@ -25,7 +26,7 @@ namespace Kernel
blksize_t blksize() const { return m_blksize; }
ino_t next_ino() { return m_next_ino++; }
void for_each_inode(void (*callback)(BAN::RefPtr<RamInode>));
void for_each_inode(const BAN::Function<BAN::Iteration(BAN::RefPtr<RamInode>)>& callback);
protected:
RamFileSystem(size_t size)

View File

@@ -109,6 +109,8 @@ 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<void> mount(BAN::StringView source, BAN::StringView target);
BAN::ErrorOr<long> sys_read_dir_entries(int fd, DirectoryEntryList* buffer, size_t buffer_size);

View File

@@ -77,6 +77,7 @@ namespace Kernel
const BAN::Vector<Partition*>& partitions() const { return m_partitions; }
BAN::ErrorOr<void> sync_disk_cache();
virtual bool is_storage_device() const override { return true; }
protected:
virtual BAN::ErrorOr<void> read_sectors_impl(uint64_t lba, uint8_t sector_count, uint8_t* buffer) = 0;