From e4fa8e8fcf09fc5f3db9bb95634e26ad4d2d496e Mon Sep 17 00:00:00 2001 From: Christian Prochaska Date: Thu, 28 Sep 2017 18:20:03 +0200 Subject: [PATCH] vfs server: remove special case of rootdir handles With this patch, the VFS server returns distinguishable IDs when opening the root directory multiple times. --- repos/os/src/server/vfs/main.cc | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/repos/os/src/server/vfs/main.cc b/repos/os/src/server/vfs/main.cc index 867422982..944e0c3d6 100644 --- a/repos/os/src/server/vfs/main.cc +++ b/repos/os/src/server/vfs/main.cc @@ -421,11 +421,9 @@ class Vfs_server::Session_component : public File_system::Session_rpc_object, throw Permission_denied(); char const *path_str = path.string(); - /* '/' is bound to '0' */ - if (!strcmp(path_str, "/")) { - if (create) throw Node_already_exists(); - return Dir_handle(0); - } + + if (!strcmp(path_str, "/") && create) + throw Node_already_exists(); _assert_valid_path(path_str); Vfs_server::Path fullpath(_root->path()); @@ -477,9 +475,6 @@ class Vfs_server::Session_component : public File_system::Session_rpc_object, Node_handle node(File_system::Path const &path) override { char const *path_str = path.string(); - /* '/' is bound to '0' */ - if (!strcmp(path_str, "/")) - return Node_handle { 0 }; _assert_valid_path(path_str); @@ -501,9 +496,7 @@ class Vfs_server::Session_component : public File_system::Session_rpc_object, void close(Node_handle handle) override { try { _apply(handle, [&] (Node &node) { - /* root directory should not be freed */ - if (!(node.id() == _root->id())) - _close(node); + _close(node); }); } catch (File_system::Invalid_handle) { } }