mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 11:38:11 +00:00
Kernel/SysFS: Add Symbolic link functionality to the filesystem
This will be used later on to help connecting a node at /sys/dev/block/ that represents a Storage device to a directory in /sys/devices/storage/ with details on that device in that directory.
This commit is contained in:
parent
7e88bbe550
commit
ecc29bb52e
4 changed files with 104 additions and 0 deletions
|
@ -131,6 +131,31 @@ ErrorOr<void> SysFSInode::truncate(u64 size)
|
|||
return m_associated_component->truncate(size);
|
||||
}
|
||||
|
||||
ErrorOr<NonnullRefPtr<SysFSLinkInode>> SysFSLinkInode::try_create(SysFS const& sysfs, SysFSComponent const& component)
|
||||
{
|
||||
return adopt_nonnull_ref_or_enomem(new (nothrow) SysFSLinkInode(sysfs, component));
|
||||
}
|
||||
|
||||
SysFSLinkInode::SysFSLinkInode(SysFS const& fs, SysFSComponent const& component)
|
||||
: SysFSInode(fs, component)
|
||||
{
|
||||
}
|
||||
|
||||
SysFSLinkInode::~SysFSLinkInode() = default;
|
||||
|
||||
InodeMetadata SysFSLinkInode::metadata() const
|
||||
{
|
||||
// NOTE: No locking required as m_associated_component or its component index will never change during our lifetime.
|
||||
InodeMetadata metadata;
|
||||
metadata.inode = { fsid(), m_associated_component->component_index() };
|
||||
metadata.mode = S_IFLNK | S_IRUSR | S_IRGRP | S_IROTH | S_IXOTH;
|
||||
metadata.uid = 0;
|
||||
metadata.gid = 0;
|
||||
metadata.size = 0;
|
||||
metadata.mtime = TimeManagement::boot_time();
|
||||
return metadata;
|
||||
}
|
||||
|
||||
ErrorOr<NonnullRefPtr<SysFSDirectoryInode>> SysFSDirectoryInode::try_create(SysFS const& sysfs, SysFSComponent const& component)
|
||||
{
|
||||
return adopt_nonnull_ref_or_enomem(new (nothrow) SysFSDirectoryInode(sysfs, component));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue