summaryrefslogtreecommitdiff
path: root/kernel/entry.cpp
diff options
context:
space:
mode:
authorBenji Dial <benji@benjidial.net>2024-01-10 00:47:09 -0500
committerBenji Dial <benji@benjidial.net>2024-01-10 00:47:09 -0500
commit88816732b53eb536fe0e8db3d9ed15f0d1c29bb4 (patch)
tree9dbc02f91158ce38ee59e6ae9b83f7888e193cd5 /kernel/entry.cpp
parent15e62510104bc0e2b9180b66e5845d985cac03cc (diff)
downloadhilbert-os-88816732b53eb536fe0e8db3d9ed15f0d1c29bb4.tar.gz
more tests, a few fixes
Diffstat (limited to 'kernel/entry.cpp')
-rw-r--r--kernel/entry.cpp45
1 files changed, 28 insertions, 17 deletions
diff --git a/kernel/entry.cpp b/kernel/entry.cpp
index fb85ad2..915bc8b 100644
--- a/kernel/entry.cpp
+++ b/kernel/entry.cpp
@@ -184,6 +184,30 @@ extern "C" [[noreturn]] void entry() {
;
}
+static void find_file(const char *path, size_t path_len) {
+
+ storage::canon_path cp;
+ storage::canonize_path(path, path_len, cp);
+
+ storage::block_device *bd;
+ storage::node_id_t node_id;
+ storage::canon_path cp_without_symlinks;
+
+ if (storage::look_up_absolute_path(cp, bd, node_id, true,
+ cp_without_symlinks) != storage::io_result::success) {
+ terminal::put_string_sz("failed to look up ");
+ terminal::put_string(path, path_len);
+ terminal::put_string_sz(" in vfs.");
+ halt();
+ }
+
+ terminal::put_string(path, path_len);
+ terminal::put_string_sz(" has node id ");
+ terminal::put_int_decimal(node_id);
+ terminal::put_string_sz(" in its file system.\n");
+
+}
+
[[noreturn]] static void with_kernel_p4() {
terminal::init_terminal();
@@ -211,23 +235,10 @@ extern "C" [[noreturn]] void entry() {
terminal::put_int_decimal(free_pram_kib);
terminal::put_string_sz(" kiB physical memory free.\n");
- storage::canon_path test_path;
- storage::canonize_path("/test.txt", 9, test_path);
-
- storage::block_device *test_bd;
- storage::node_id_t test_node_id;
- storage::canon_path test_path_without_symlinks;
-
- if (storage::look_up_absolute_path(
- test_path, test_bd, test_node_id, true, test_path_without_symlinks) !=
- storage::io_result::success) {
- terminal::put_string_sz("failed to look up /test.txt in vfs.");
- halt();
- }
-
- terminal::put_string_sz("/test.txt has node id ");
- terminal::put_int_decimal(test_node_id);
- terminal::put_string_sz(" in its file system.");
+ find_file("/", 1);
+ find_file("/test.txt", 9);
+ find_file("/dir", 4);
+ find_file("/dir/dir2", 9);
halt();