Kernel/SysFS: Make it possible to have custom permissions for nodes
This commit is contained in:
parent
33f033066c
commit
06e95d0fd7
Notes:
sideshowbarker
2024-07-18 22:57:59 +09:00
Author: https://github.com/supercomputer7 Commit: https://github.com/SerenityOS/serenity/commit/06e95d0fd74 Pull-request: https://github.com/SerenityOS/serenity/pull/9958
3 changed files with 7 additions and 1 deletions
|
@ -140,7 +140,7 @@ InodeMetadata SysFSInode::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_IFREG | S_IRUSR | S_IRGRP | S_IROTH;
|
||||
metadata.mode = S_IFREG | m_associated_component->permissions();
|
||||
metadata.uid = 0;
|
||||
metadata.gid = 0;
|
||||
metadata.size = 0;
|
||||
|
|
|
@ -26,6 +26,11 @@ SysFSComponent::SysFSComponent(StringView name)
|
|||
{
|
||||
}
|
||||
|
||||
mode_t SysFSComponent::permissions() const
|
||||
{
|
||||
return S_IRUSR | S_IRGRP | S_IROTH;
|
||||
}
|
||||
|
||||
KResult SysFSDirectory::traverse_as_directory(unsigned fsid, Function<bool(FileSystem::DirectoryEntryView const&)> callback) const
|
||||
{
|
||||
MutexLocker locker(SysFSComponentRegistry::the().get_lock());
|
||||
|
|
|
@ -29,6 +29,7 @@ public:
|
|||
virtual KResultOr<size_t> read_bytes(off_t, size_t, UserOrKernelBuffer&, OpenFileDescription*) const { VERIFY_NOT_REACHED(); }
|
||||
virtual KResult traverse_as_directory(unsigned, Function<bool(FileSystem::DirectoryEntryView const&)>) const { VERIFY_NOT_REACHED(); }
|
||||
virtual RefPtr<SysFSComponent> lookup(StringView) { VERIFY_NOT_REACHED(); };
|
||||
virtual mode_t permissions() const;
|
||||
virtual KResultOr<size_t> write_bytes(off_t, size_t, UserOrKernelBuffer const&, OpenFileDescription*) { return EROFS; }
|
||||
virtual KResult refresh_data(OpenFileDescription&) const { return KSuccess; }
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue