mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 11:38:11 +00:00
FileSystem: Port most of the code over to using custodies.
The current working directory is now stored as a custody. Likewise for a process executable file. This unbreaks /proc/PID/fd which has not been working since we made the filesystem bigger. This still needs a bunch of work, for instance when renaming or removing a file somewhere, we have to update the relevant custody links.
This commit is contained in:
parent
4cb87b1753
commit
393851418b
11 changed files with 280 additions and 220 deletions
|
@ -1,5 +1,6 @@
|
|||
#include "ProcFS.h"
|
||||
#include "Process.h"
|
||||
#include <Kernel/FileSystem/Custody.h>
|
||||
#include <Kernel/FileSystem/FileDescriptor.h>
|
||||
#include <Kernel/FileSystem/VirtualFileSystem.h>
|
||||
#include <Kernel/VM/MemoryManager.h>
|
||||
|
@ -359,12 +360,9 @@ ByteBuffer procfs$pid_exe(InodeIdentifier identifier)
|
|||
if (!handle)
|
||||
return { };
|
||||
auto& process = handle->process();
|
||||
auto inode = process.executable_inode();
|
||||
ASSERT(inode);
|
||||
auto result = VFS::the().absolute_path(*inode);
|
||||
if (result.is_error())
|
||||
return { };
|
||||
return result.value().to_byte_buffer();
|
||||
auto* custody = process.executable_custody();
|
||||
ASSERT(custody);
|
||||
return custody->absolute_path().to_byte_buffer();
|
||||
}
|
||||
|
||||
ByteBuffer procfs$pid_cwd(InodeIdentifier identifier)
|
||||
|
@ -372,10 +370,7 @@ ByteBuffer procfs$pid_cwd(InodeIdentifier identifier)
|
|||
auto handle = ProcessInspectionHandle::from_pid(to_pid(identifier));
|
||||
if (!handle)
|
||||
return { };
|
||||
auto result = VFS::the().absolute_path(handle->process().cwd_inode());
|
||||
if (result.is_error())
|
||||
return { };
|
||||
return result.value().to_byte_buffer();
|
||||
return handle->process().cwd_custody().absolute_path().to_byte_buffer();
|
||||
}
|
||||
|
||||
ByteBuffer procfs$self(InodeIdentifier)
|
||||
|
@ -958,7 +953,7 @@ bool ProcFSInode::traverse_as_directory(Function<bool(const FS::DirectoryEntry&)
|
|||
auto& process = handle->process();
|
||||
for (auto& entry : fs().m_entries) {
|
||||
if (entry.proc_file_type > __FI_PID_Start && entry.proc_file_type < __FI_PID_End) {
|
||||
if (entry.proc_file_type == FI_PID_exe && !process.executable_inode())
|
||||
if (entry.proc_file_type == FI_PID_exe && !process.executable_custody())
|
||||
continue;
|
||||
// FIXME: strlen() here is sad.
|
||||
callback({ entry.name, (int)strlen(entry.name), to_identifier(fsid(), PDI_PID, pid, (ProcFileType)entry.proc_file_type), 0 });
|
||||
|
@ -1039,7 +1034,7 @@ InodeIdentifier ProcFSInode::lookup(const String& name)
|
|||
auto& process = handle->process();
|
||||
for (auto& entry : fs().m_entries) {
|
||||
if (entry.proc_file_type > __FI_PID_Start && entry.proc_file_type < __FI_PID_End) {
|
||||
if (entry.proc_file_type == FI_PID_exe && !process.executable_inode())
|
||||
if (entry.proc_file_type == FI_PID_exe && !process.executable_custody())
|
||||
continue;
|
||||
if (entry.name == nullptr)
|
||||
continue;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue