Skip to content

Commit

Permalink
posix: Create /proc/filesystems
Browse files Browse the repository at this point in the history
  • Loading branch information
Dennisbonke committed Oct 28, 2023
1 parent cd4d5c2 commit 9f2eb3c
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
20 changes: 20 additions & 0 deletions posix/subsystem/src/procfs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,7 @@ std::shared_ptr<Link> DirectoryNode::createRootDirectory() {
the_node->_entries.insert(std::move(self_thread_link));

the_node->directMkregular("uptime", std::make_shared<UptimeNode>());
the_node->directMkregular("filesystems", std::make_shared<FilesystemsNode>());

return link;
}
Expand Down Expand Up @@ -358,6 +359,25 @@ async::result<void> UptimeNode::store(std::string) {
co_return;
}

async::result<std::string> FilesystemsNode::show() {
// See man 5 proc for more details.
// Based on the man page from Linux man-pages 6.01, updated on 2022-10-09.
std::stringstream stream;
stream << "nodev\tsysfs\n";
stream << "nodev\ttmpfs\n";
stream << "nodev\tproc\n";
stream << "nodev\tdevpts\n";
stream << "nodev\tdevtmpfs\n";
stream << "\text2\n";
co_return stream.str();
}

async::result<void> FilesystemsNode::store(std::string) {
// TODO: proper error reporting.
std::cout << "posix: Can't store to a /proc/filesystems file" << std::endl;
co_return;
}

VfsType SelfLink::getType() {
return VfsType::symlink;
}
Expand Down
7 changes: 7 additions & 0 deletions posix/subsystem/src/procfs.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,13 @@ struct UptimeNode final : RegularNode {
async::result<void> store(std::string) override;
};

struct FilesystemsNode final : RegularNode {
FilesystemsNode() {}

async::result<std::string> show() override;
async::result<void> store(std::string) override;
};

struct CommNode final : RegularNode {
CommNode(Process *process)
: _process(process)
Expand Down

0 comments on commit 9f2eb3c

Please sign in to comment.