os/fs/proc/generators/process/
cmdline.rs1use alloc::{sync::Weak, vec::Vec};
2
3use crate::{fs::proc::ContentGenerator, kernel::TaskStruct, sync::SpinLock, vfs::FsError};
4
5pub struct CmdlineGenerator {
7 task: Weak<SpinLock<TaskStruct>>,
8}
9
10impl CmdlineGenerator {
11 pub fn new(task: Weak<SpinLock<TaskStruct>>) -> Self {
12 Self { task }
13 }
14}
15
16impl ContentGenerator for CmdlineGenerator {
17 fn generate(&self) -> Result<Vec<u8>, FsError> {
18 let task_arc = self.task.upgrade().ok_or(FsError::NotFound)?;
19 let task = task_arc.lock();
20
21 let mut content = alloc::format!("task_{}", task.tid).into_bytes();
27 content.push(0); Ok(content)
30 }
31}