starnix_core/vfs/pseudo/
stub_empty_file.rs1use crate::vfs::pseudo::simple_file::SimpleFileNode;
6use crate::vfs::{
7 FileOps, FsNodeOps, fileops_impl_dataless, fileops_impl_nonseekable, fileops_impl_noop_sync,
8};
9use bstr::ByteSlice;
10use starnix_logging::BugRef;
11use std::panic::Location;
12
13#[derive(Clone, Debug)]
14pub struct StubEmptyFile {
15 bug: BugRef,
16 location: &'static Location<'static>,
17}
18
19impl StubEmptyFile {
20 #[track_caller]
21 pub fn new_node(bug: BugRef) -> impl FsNodeOps {
22 SimpleFileNode::new(move |_| Ok(StubEmptyFile::new(bug)))
23 }
24
25 #[track_caller]
26 pub fn new(bug: BugRef) -> Self {
27 let location = Location::caller();
29 Self { bug, location }
30 }
31}
32
33impl FileOps for StubEmptyFile {
34 fileops_impl_dataless!();
35 fileops_impl_nonseekable!();
36 fileops_impl_noop_sync!();
37
38 fn open(
39 &self,
40 file: &crate::vfs::FileObject,
41 current_task: &crate::task::CurrentTask,
42 ) -> Result<(), starnix_uapi::errors::Errno> {
43 let path = file.name.path(¤t_task.fs());
44 starnix_logging::__track_stub_inner(
45 self.bug,
46 path.to_str_lossy().as_ref(),
47 None,
48 &self.location,
49 );
50 Ok(())
51 }
52}