mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 09:38:11 +00:00
Kernel: Enable early-returns from VFS::for_each_mount
This commit is contained in:
parent
735da58d44
commit
88ca12f037
4 changed files with 19 additions and 15 deletions
|
@ -724,11 +724,12 @@ KResult VirtualFileSystem::rmdir(StringView path, Custody& base)
|
|||
return parent_inode.remove_child(KLexicalPath::basename(path));
|
||||
}
|
||||
|
||||
void VirtualFileSystem::for_each_mount(Function<void(Mount const&)> callback) const
|
||||
void VirtualFileSystem::for_each_mount(Function<IterationDecision(Mount const&)> callback) const
|
||||
{
|
||||
m_mounts.with_shared([&](auto& mounts) {
|
||||
for (auto& mount : mounts) {
|
||||
callback(mount);
|
||||
if (callback(mount) == IterationDecision::Break)
|
||||
break;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
@ -66,7 +66,7 @@ public:
|
|||
KResult mknod(StringView path, mode_t, dev_t, Custody& base);
|
||||
KResultOr<NonnullRefPtr<Custody>> open_directory(StringView path, Custody& base);
|
||||
|
||||
void for_each_mount(Function<void(const Mount&)>) const;
|
||||
void for_each_mount(Function<IterationDecision(const Mount&)>) const;
|
||||
|
||||
InodeIdentifier root_inode_id() const;
|
||||
|
||||
|
|
|
@ -351,7 +351,8 @@ private:
|
|||
virtual KResult try_generate(KBufferBuilder& builder) override
|
||||
{
|
||||
JsonArraySerializer array { builder };
|
||||
VirtualFileSystem::the().for_each_mount([&array](auto& mount) {
|
||||
KResult result = KSuccess;
|
||||
VirtualFileSystem::the().for_each_mount([&array, &result](auto& mount) {
|
||||
auto& fs = mount.guest_fs();
|
||||
auto fs_object = array.add_object();
|
||||
fs_object.add("class_name", fs.class_name());
|
||||
|
@ -368,6 +369,8 @@ private:
|
|||
fs_object.add("source", static_cast<const FileBackedFileSystem&>(fs).file_description().absolute_path());
|
||||
else
|
||||
fs_object.add("source", "none");
|
||||
|
||||
return IterationDecision::Continue;
|
||||
});
|
||||
array.finish();
|
||||
return KSuccess;
|
||||
|
|
|
@ -38,19 +38,19 @@ KResultOr<FlatPtr> Process::do_statvfs(StringView path, statvfs* buf)
|
|||
|
||||
while (current_custody) {
|
||||
VirtualFileSystem::the().for_each_mount([&kernelbuf, ¤t_custody](auto& mount) {
|
||||
if (current_custody) {
|
||||
if (¤t_custody->inode() == &mount.guest()) {
|
||||
int mountflags = mount.flags();
|
||||
int flags = 0;
|
||||
if (mountflags & MS_RDONLY)
|
||||
flags = flags | ST_RDONLY;
|
||||
if (mountflags & MS_NOSUID)
|
||||
flags = flags | ST_NOSUID;
|
||||
if (¤t_custody->inode() == &mount.guest()) {
|
||||
int mountflags = mount.flags();
|
||||
int flags = 0;
|
||||
if (mountflags & MS_RDONLY)
|
||||
flags = flags | ST_RDONLY;
|
||||
if (mountflags & MS_NOSUID)
|
||||
flags = flags | ST_NOSUID;
|
||||
|
||||
kernelbuf.f_flag = flags;
|
||||
current_custody = nullptr;
|
||||
}
|
||||
kernelbuf.f_flag = flags;
|
||||
current_custody = nullptr;
|
||||
return IterationDecision::Break;
|
||||
}
|
||||
return IterationDecision::Continue;
|
||||
});
|
||||
|
||||
if (current_custody) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue