aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--arch/x86_64/support/grub.cfg.in1
-rw-r--r--arch/x86_64/support/modules/ext2_2KB_fs.img3
-rw-r--r--kernel/src/main.cpp28
3 files changed, 29 insertions, 3 deletions
diff --git a/arch/x86_64/support/grub.cfg.in b/arch/x86_64/support/grub.cfg.in
index 35621f9..45c3356 100644
--- a/arch/x86_64/support/grub.cfg.in
+++ b/arch/x86_64/support/grub.cfg.in
@@ -5,5 +5,6 @@ menuentry "TeachOS" {
multiboot2 /$<TARGET_FILE_NAME:kernel>
module2 /modules/ext2_4KB_fs.img
module2 /modules/ext2_1KB_fs.img
+ module2 /modules/ext2_2KB_fs.img
boot
} \ No newline at end of file
diff --git a/arch/x86_64/support/modules/ext2_2KB_fs.img b/arch/x86_64/support/modules/ext2_2KB_fs.img
new file mode 100644
index 0000000..1880911
--- /dev/null
+++ b/arch/x86_64/support/modules/ext2_2KB_fs.img
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:9a13da5abb9c65c737105b1da0d4344c7cd7604c7952c762c4f4e3d3f96fd42d
+size 5242880
diff --git a/kernel/src/main.cpp b/kernel/src/main.cpp
index 1d73e20..79ed703 100644
--- a/kernel/src/main.cpp
+++ b/kernel/src/main.cpp
@@ -139,15 +139,37 @@ auto test_file_lookup() -> void
"limits_for_testing_purposes_and_we_add_more_characters_to_make_it_even_longer_30.txt");
auto storage_mgmt = kernel::devices::storage::management::get();
- auto device = storage_mgmt.device_by_major_minor(1, 16);
- auto new_filesystem = kernel::filesystem::filesystem::probe_and_mount(device);
+ auto device_1 = storage_mgmt.device_by_major_minor(1, 16);
+ auto fs_1 = kernel::filesystem::filesystem::probe_and_mount(device_1);
- vfs.do_mount("/enclosures/aquarium", new_filesystem);
+ vfs.do_mount("/enclosures/aquarium", fs_1);
read_and_write_file("/enclosures/aquarium/closed.txt");
read_and_write_file("/enclosures/aquarium/information/info_2.txt");
vfs.unmount("/enclosures/aquarium");
read_and_write_file("/enclosures/aquarium/tank_1/fish_4.txt");
+
+ auto device_2 = storage_mgmt.device_by_major_minor(1, 32);
+ auto fs_2 = kernel::filesystem::filesystem::probe_and_mount(device_2);
+
+ vfs.do_mount("/enclosures/elephant_house", fs_2);
+ read_and_write_file("/enclosures/elephant_house/monkey_house/infrastructure/info.txt");
+
+ vfs.do_mount("/enclosures/elephant_house/monkey_house", fs_1);
+ read_and_write_file("/enclosures/elephant_house/monkey_house/information/info_2.txt");
+
+ auto result = vfs.unmount("/enclosures/elephant_house");
+ if (result == kernel::filesystem::vfs::operation_result::unmount_failed)
+ {
+ kstd::println("[TEST] Unmount failed as expected due to active child mount.");
+ }
+
+ vfs.unmount("/enclosures/elephant_house/monkey_house");
+ result = vfs.unmount("/enclosures/elephant_house");
+ if (result == kernel::filesystem::vfs::operation_result::success)
+ {
+ kstd::println("[TEST] Unmount succeeded after unmounting child mount.");
+ }
}
auto run_test_code() -> void