From f3df6fe2537b31bb9b86d13bf02f9d01e903a524 Mon Sep 17 00:00:00 2001 From: manuel Date: Thu, 12 Nov 2026 08:52:16 +0000 Subject: kernel/filesystems: implement fat32 write files --- kernel/kapi/filesystem.tests.cpp | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'kernel/kapi/filesystem.tests.cpp') diff --git a/kernel/kapi/filesystem.tests.cpp b/kernel/kapi/filesystem.tests.cpp index f46c6bb8..f71eead0 100644 --- a/kernel/kapi/filesystem.tests.cpp +++ b/kernel/kapi/filesystem.tests.cpp @@ -12,6 +12,7 @@ #include #include #include +#include #include #include #include @@ -414,14 +415,21 @@ SCENARIO_METHOD(kernel::tests::vfs::storage_boot_module_vfs_fixture, "Kapi files REQUIRE(kapi::filesystem::read_directory(*directory, buffer) == 0); } - THEN("writing to a file fails because the filesystem is read only") + THEN("a file can be overwritten and extended through its file descriptor") { auto const fd = kapi::filesystem::open("/information/hello.txt"); REQUIRE(fd); - auto const buffer = std::vector{std::byte{'X'}}; - REQUIRE(kapi::filesystem::write(*fd, buffer).error() == kstd::errc::read_only_file_system); + auto const text = std::string_view{"Hello Peter! Goodbye"}; + REQUIRE(kapi::filesystem::seek(*fd, 6_B_off, kapi::filesystem::seek_origin::beginning) == 6_B); + REQUIRE(kapi::filesystem::write(*fd, std::as_bytes(std::span{text}.subspan(6))) == 14_B); REQUIRE(kapi::filesystem::close(*fd)); + + auto const reopened = kapi::filesystem::open("/information/hello.txt"); + REQUIRE(reopened); + REQUIRE(read_text(*reopened, 7) == text); + REQUIRE(kapi::filesystem::close(*reopened)); + REQUIRE(kapi::filesystem::status("/information/hello.txt")->size == 20_B); } THEN("opening a missing file fails") -- cgit v1.2.3