-
Notifications
You must be signed in to change notification settings - Fork 72
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Weijie Liu
committed
Jun 1, 2024
1 parent
8e874e6
commit b869c33
Showing
2 changed files
with
33 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
// SPDX-License-Identifier: MPL-2.0 | ||
|
||
use super::*; | ||
|
||
/// Represents the inode at `/proc/[pid]/cmdline`. | ||
pub struct CmdlineFileOps(Arc<Process>); | ||
|
||
impl CmdlineFileOps { | ||
pub fn new_inode(process_ref: Arc<Process>, parent: Weak<dyn Inode>) -> Arc<dyn Inode> { | ||
ProcFileBuilder::new(Self(process_ref)) | ||
.parent(parent) | ||
.build() | ||
.unwrap() | ||
} | ||
} | ||
|
||
impl FileOps for CmdlineFileOps { | ||
fn data(&self) -> Result<Vec<u8>> { | ||
let exe_path = self.0.executable_path(); | ||
|
||
let mut cmdline_output = exe_path.into_bytes(); | ||
cmdline_output.push(0); // Append a single NUL character at the end | ||
|
||
Ok(cmdline_output) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters