kernel: Add functionality to allow external inodes (such as sockets) to acquire an inode number from a file system

This is only implemented in tmpfs.
This commit is contained in:
apio 2023-07-27 16:36:36 +02:00
parent c1d08b904e
commit c4e30c3029
Signed by: apio
GPG Key ID: B8A7D06E42258954
3 changed files with 12 additions and 0 deletions

View File

@ -35,6 +35,11 @@ namespace VFS
virtual Result<SharedPtr<Inode>> create_symlink_inode(StringView link) = 0;
virtual Result<u64> allocate_inode_number()
{
return err(ENOTSUP);
}
virtual Result<void> set_mount_dir(SharedPtr<Inode> parent) = 0;
virtual Result<void> reset_mount_dir() = 0;

View File

@ -16,6 +16,11 @@ namespace TmpFS
return (SharedPtr<VFS::FileSystem>)fs;
}
Result<u64> FileSystem::allocate_inode_number()
{
return m_next_inode_number++;
}
Result<SharedPtr<VFS::Inode>> FileSystem::create_file_inode()
{
SharedPtr<FileInode> inode = TRY(make_shared<FileInode>());

View File

@ -18,6 +18,8 @@ namespace TmpFS
Result<SharedPtr<VFS::Inode>> create_device_inode(u32 major, u32 minor) override;
Result<SharedPtr<VFS::Inode>> create_symlink_inode(StringView link) override;
Result<u64> allocate_inode_number() override;
Result<void> set_mount_dir(SharedPtr<VFS::Inode> parent) override;
Result<void> reset_mount_dir() override;