2025-10-24 02:36:47 +00:00
|
|
|
// SPDX-License-Identifier: MPL-2.0
|
|
|
|
|
|
2025-10-31 15:58:08 +00:00
|
|
|
use super::TidDirOps;
|
2025-10-24 02:36:47 +00:00
|
|
|
use crate::{
|
|
|
|
|
fs::{
|
|
|
|
|
procfs::template::{FileOps, ProcFileBuilder},
|
2025-12-08 12:53:18 +00:00
|
|
|
utils::{Inode, mkmod},
|
2025-10-24 02:36:47 +00:00
|
|
|
},
|
|
|
|
|
prelude::*,
|
|
|
|
|
process::posix_thread::AsPosixThread,
|
|
|
|
|
};
|
|
|
|
|
|
2025-10-24 06:06:55 +00:00
|
|
|
/// Represents the inode at `/proc/[pid]/task/[tid]/mountinfo` (and also `/proc/[pid]/mountinfo`).
|
2025-10-31 15:45:06 +00:00
|
|
|
pub struct MountInfoFileOps(TidDirOps);
|
2025-10-24 02:36:47 +00:00
|
|
|
|
|
|
|
|
impl MountInfoFileOps {
|
2025-10-31 15:58:08 +00:00
|
|
|
pub fn new_inode(dir: &TidDirOps, parent: Weak<dyn Inode>) -> Arc<dyn Inode> {
|
2025-10-24 06:06:55 +00:00
|
|
|
// Reference: <https://elixir.bootlin.com/linux/v6.16.5/source/fs/proc/base.c#L3352>
|
2025-10-31 15:45:06 +00:00
|
|
|
ProcFileBuilder::new(Self(dir.clone()), mkmod!(a+r))
|
2025-10-24 02:36:47 +00:00
|
|
|
.parent(parent)
|
|
|
|
|
.build()
|
|
|
|
|
.unwrap()
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
impl FileOps for MountInfoFileOps {
|
|
|
|
|
fn read_at(&self, offset: usize, writer: &mut VmWriter) -> Result<usize> {
|
2025-10-31 15:45:06 +00:00
|
|
|
let thread = self.0.thread();
|
|
|
|
|
let posix_thread = thread.as_posix_thread().unwrap();
|
|
|
|
|
|
2025-10-24 06:06:55 +00:00
|
|
|
let fs = posix_thread.read_fs();
|
2026-01-12 08:43:24 +00:00
|
|
|
let path_resolver = fs.resolver().read();
|
2025-10-24 02:36:47 +00:00
|
|
|
|
2026-01-16 02:12:20 +00:00
|
|
|
path_resolver.read_mount_info(offset, writer)
|
2025-10-24 02:36:47 +00:00
|
|
|
}
|
|
|
|
|
}
|