From 3521bcc25c3f69d1af51b2c467ac1166386662cb Mon Sep 17 00:00:00 2001 From: manuel Date: Fri, 27 Nov 2026 23:39:13 +0000 Subject: kernel/filesystem: create file / inode --- kernel/kapi/filesystem.tests.cpp | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) (limited to 'kernel/kapi/filesystem.tests.cpp') diff --git a/kernel/kapi/filesystem.tests.cpp b/kernel/kapi/filesystem.tests.cpp index baa587e5..0a787a32 100644 --- a/kernel/kapi/filesystem.tests.cpp +++ b/kernel/kapi/filesystem.tests.cpp @@ -406,6 +406,36 @@ SCENARIO_METHOD(kernel::tests::vfs::storage_boot_module_vfs_fixture, "Kapi files REQUIRE(status->size == image::hello_size); } + THEN("a new file with an 8.3 name can be created, written to, and read back after reopening it") + { + auto const path = "/information/new.txt"; + REQUIRE(kapi::filesystem::create(path)); + + auto fd = kapi::filesystem::open(path); + REQUIRE(fd); + auto const content = std::string_view{"Hello FAT!"}; + REQUIRE(kapi::filesystem::write(*fd, std::as_bytes(std::span{content})) == kstd::bytes{content.size()}); + REQUIRE(kapi::filesystem::close(*fd)); + + fd = kapi::filesystem::open(path); + REQUIRE(fd); + REQUIRE(read_text(*fd, 4) == content); + REQUIRE(kapi::filesystem::close(*fd)); + + REQUIRE(kapi::filesystem::status(path)->size == kstd::bytes{content.size()}); + } + + THEN("a file that already exists cannot be created again, regardless of the case of its name") + { + REQUIRE(!kapi::filesystem::create("/information/hello.txt")); + REQUIRE(!kapi::filesystem::create("/information/HELLO.TXT")); + } + + THEN("a file with a name that is not a valid 8.3 name cannot be created") + { + REQUIRE(!kapi::filesystem::create("/information/new_information.txt")); + } + THEN("the mounted root directory can be listed") { auto const directory = kapi::filesystem::open("/information"); -- cgit v1.2.3