mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-10 13:00:29 +03:00
Add /proc/vnodes, listing basic info about all open vnodes.
This commit is contained in:
parent
4914f3b837
commit
e0ca6bb97e
Notes:
sideshowbarker
2024-07-19 16:11:53 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/e0ca6bb97e2
@ -319,6 +319,29 @@ ByteBuffer procfs$summary()
|
||||
return buffer;
|
||||
}
|
||||
|
||||
ByteBuffer procfs$vnodes()
|
||||
{
|
||||
auto& vfs = VirtualFileSystem::the();
|
||||
auto buffer = ByteBuffer::createUninitialized(vfs.m_maxNodeCount * 256);
|
||||
char* ptr = (char*)buffer.pointer();
|
||||
for (size_t i = 0; i < vfs.m_maxNodeCount; ++i) {
|
||||
auto& vnode = vfs.m_nodes[i];
|
||||
if (!vnode.inUse())
|
||||
continue;
|
||||
auto path = vfs.absolutePath(vnode.inode);
|
||||
if (path.isEmpty()) {
|
||||
if (auto* dev = vnode.characterDevice()) {
|
||||
if (dev->isTTY())
|
||||
path = static_cast<const TTY*>(dev)->ttyName();
|
||||
}
|
||||
}
|
||||
ptr += ksprintf(ptr, "vnode %03u: %02u:%08u (%u) %s\n", i, vnode.inode.fileSystemID(), vnode.inode.index(), vnode.retain_count(), path.characters());
|
||||
}
|
||||
*ptr = '\0';
|
||||
buffer.trim(ptr - (char*)buffer.pointer());
|
||||
return buffer;
|
||||
}
|
||||
|
||||
bool ProcFileSystem::initialize()
|
||||
{
|
||||
SyntheticFileSystem::initialize();
|
||||
@ -328,6 +351,7 @@ bool ProcFileSystem::initialize()
|
||||
addFile(createGeneratedFile("kmalloc", procfs$kmalloc));
|
||||
addFile(createGeneratedFile("summary", procfs$summary));
|
||||
addFile(createGeneratedFile("cpuinfo", procfs$cpuinfo));
|
||||
addFile(createGeneratedFile("vnodes", procfs$vnodes));
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -28,6 +28,7 @@ inline constexpr dword encodedDevice(unsigned major, unsigned minor)
|
||||
|
||||
class VirtualFileSystem {
|
||||
AK_MAKE_ETERNAL
|
||||
friend ByteBuffer procfs$vnodes();
|
||||
public:
|
||||
static void initializeGlobals();
|
||||
|
||||
@ -68,6 +69,8 @@ public:
|
||||
void* vmo() { return m_vmo; }
|
||||
void set_vmo(void* vmo) { m_vmo = vmo; }
|
||||
|
||||
unsigned retain_count() const { return retainCount; }
|
||||
|
||||
private:
|
||||
friend class VirtualFileSystem;
|
||||
VirtualFileSystem* m_vfs { nullptr };
|
||||
|
Loading…
Reference in New Issue
Block a user