summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Kling <awesomekling@gmail.com>2018-11-10 16:50:42 +0100
committerAndreas Kling <awesomekling@gmail.com>2018-11-10 16:50:42 +0100
commita768c2b919a679b98201bc49dbbce7e861491d7d (patch)
treea7fced0a882e4dd0b55e5f1d47332d72682c72b6
parent2ac5e14c08a4d855f53e7b7c519e0864ffe469bf (diff)
downloadserenity-a768c2b919a679b98201bc49dbbce7e861491d7d.zip
Rename ProcessInspectionScope to ProcessInspectionHandle.
It might be useful to pass these things around.
-rw-r--r--Kernel/ProcFileSystem.cpp12
-rw-r--r--Kernel/Process.h14
2 files changed, 16 insertions, 10 deletions
diff --git a/Kernel/ProcFileSystem.cpp b/Kernel/ProcFileSystem.cpp
index f63b540996..c0efdbe89a 100644
--- a/Kernel/ProcFileSystem.cpp
+++ b/Kernel/ProcFileSystem.cpp
@@ -30,7 +30,7 @@ ProcFileSystem::~ProcFileSystem()
ByteBuffer procfs$pid_fds(Process& process)
{
- ProcessInspectionScope scope(process);
+ ProcessInspectionHandle handle(process);
char* buffer;
auto stringImpl = StringImpl::createUninitialized(process.number_of_open_file_descriptors() * 80, buffer);
memset(buffer, 0, stringImpl->length());
@@ -47,7 +47,7 @@ ByteBuffer procfs$pid_fds(Process& process)
ByteBuffer procfs$pid_vm(Process& process)
{
- ProcessInspectionScope scope(process);
+ ProcessInspectionHandle handle(process);
char* buffer;
auto stringImpl = StringImpl::createUninitialized(80 + process.regionCount() * 160 + 4096, buffer);
memset(buffer, 0, stringImpl->length());
@@ -80,7 +80,7 @@ ByteBuffer procfs$pid_vm(Process& process)
ByteBuffer procfs$pid_stack(Process& process)
{
- ProcessInspectionScope scope(process);
+ ProcessInspectionHandle handle(process);
ProcessPagingScope pagingScope(process);
struct RecognizedSymbol {
dword address;
@@ -112,7 +112,7 @@ ByteBuffer procfs$pid_stack(Process& process)
ByteBuffer procfs$pid_regs(Process& process)
{
- ProcessInspectionScope scope(process);
+ ProcessInspectionHandle handle(process);
auto& tss = process.tss();
auto buffer = ByteBuffer::createUninitialized(1024);
char* ptr = (char*)buffer.pointer();
@@ -133,7 +133,7 @@ ByteBuffer procfs$pid_regs(Process& process)
ByteBuffer procfs$pid_exe(Process& process)
{
- ProcessInspectionScope scope(process);
+ ProcessInspectionHandle handle(process);
auto inode = process.executableInode();
return VirtualFileSystem::the().absolutePath(inode).toByteBuffer();
}
@@ -285,7 +285,6 @@ ByteBuffer procfs$cpuinfo()
ByteBuffer procfs$kmalloc()
{
- InterruptDisabler disabler;
auto buffer = ByteBuffer::createUninitialized(256);
char* ptr = (char*)buffer.pointer();
ptr += ksprintf(ptr, "eternal: %u\npage-aligned: %u\nallocated: %u\nfree: %u\n", kmalloc_sum_eternal, sum_alloc, sum_free);
@@ -326,6 +325,7 @@ ByteBuffer procfs$vnodes()
char* ptr = (char*)buffer.pointer();
for (size_t i = 0; i < vfs.m_maxNodeCount; ++i) {
auto& vnode = vfs.m_nodes[i];
+ // FIXME: Retain the vnode while inspecting it.
if (!vnode.inUse())
continue;
auto path = vfs.absolutePath(vnode.inode);
diff --git a/Kernel/Process.h b/Kernel/Process.h
index 9716c218fc..bff7d61115 100644
--- a/Kernel/Process.h
+++ b/Kernel/Process.h
@@ -288,19 +288,25 @@ private:
Region* m_signal_stack_kernel_region { nullptr };
};
-class ProcessInspectionScope {
+extern Process* current;
+
+class ProcessInspectionHandle {
public:
- ProcessInspectionScope(Process& process)
+ ProcessInspectionHandle(Process& process)
: m_process(process)
, m_original_state(process.state())
{
- m_process.set_state(Process::BeingInspected);
+ if (&process != current)
+ m_process.set_state(Process::BeingInspected);
}
- ~ProcessInspectionScope()
+ ~ProcessInspectionHandle()
{
m_process.set_state(m_original_state);
}
+
+ Process* operator->() { return &m_process; }
+ Process& operator*() { return m_process; }
private:
Process& m_process;
Process::State m_original_state { Process::Invalid };