kernel: implement /proc/filesystems — supported filesystem types
Added ProcFilesystems ContextHandle that lists supported filesystems in Linux /proc/filesystems format. Lists sysfs, proc, devtmpfs, and redoxfs as supported types. Cross-referenced with Linux 7.1 fs/filesystems.c filesystems_proc_show(). 'nodev' prefix indicates filesystems not requiring a block device. Also added to ProcRoot directory listing.
This commit is contained in:
+14
-3
@@ -160,6 +160,7 @@ enum ContextHandle {
|
||||
ProcUptime,
|
||||
ProcLoadavg,
|
||||
ProcVersion,
|
||||
ProcFilesystems,
|
||||
ProcDir {
|
||||
pid: usize,
|
||||
},
|
||||
@@ -416,6 +417,9 @@ impl ProcScheme {
|
||||
if path == "proc/version" || path == "version" {
|
||||
return Some(ContextHandle::ProcVersion);
|
||||
}
|
||||
if path == "proc/filesystems" || path == "filesystems" {
|
||||
return Some(ContextHandle::ProcFilesystems);
|
||||
}
|
||||
let mut parts = path.split('/');
|
||||
let pid = parts.next()?.parse::<usize>().ok()?;
|
||||
match (parts.next(), parts.next()) {
|
||||
@@ -955,8 +959,8 @@ impl KernelScheme for ProcScheme {
|
||||
let mut buf = DirentBuf::new(buf, header_size).ok_or(Error::new(EIO))?;
|
||||
match handle.kind {
|
||||
ContextHandle::ProcRoot => {
|
||||
// First: system files (cpuinfo, meminfo, uptime, loadavg, version)
|
||||
for (idx, name) in ["cpuinfo", "meminfo", "uptime", "loadavg", "version"].iter().enumerate() {
|
||||
// First: system files (cpuinfo, meminfo, uptime, loadavg, version, filesystems)
|
||||
for (idx, name) in ["cpuinfo", "meminfo", "uptime", "loadavg", "version", "filesystems"].iter().enumerate() {
|
||||
buf.entry(DirEntry {
|
||||
inode: 0,
|
||||
next_opaque_id: (idx + 1) as u64,
|
||||
@@ -972,7 +976,7 @@ impl KernelScheme for ProcScheme {
|
||||
pids.push(context_ref.read(token.token()).pid);
|
||||
}
|
||||
pids.sort_unstable();
|
||||
let base_idx = 5; // after cpuinfo + meminfo + uptime + loadavg + version
|
||||
let base_idx = 6; // after 6 system files
|
||||
for (idx, pid) in pids.into_iter().enumerate().skip(opaque.saturating_sub(base_idx)) {
|
||||
let name = format!("{}", pid);
|
||||
buf.entry(DirEntry {
|
||||
@@ -1927,6 +1931,13 @@ impl ContextHandle {
|
||||
);
|
||||
read_from(buf, output.as_bytes(), offset)
|
||||
}
|
||||
ContextHandle::ProcFilesystems => {
|
||||
// Linux /proc/filesystems lists registered filesystem types.
|
||||
// Cross-referenced with Linux 7.1 fs/filesystems.c filesystems_proc_show().
|
||||
// Red Bear supports redoxfs as the native filesystem.
|
||||
let output = "nodev\tsysfs\nnodev\tproc\nnodev\tdevtmpfs\n\tredoxfs\n";
|
||||
read_from(buf, output.as_bytes(), offset)
|
||||
}
|
||||
ContextHandle::ProcStat { pid } => {
|
||||
let context = proc_context(*pid, token).ok_or(Error::new(ESRCH))?;
|
||||
let (pid, comm, state, ppid, priority, utime, stime, pgrp, session, starttime, owner_proc_id, addr_space) = {
|
||||
|
||||
Reference in New Issue
Block a user