starnix_core/vfs/socket/
socket_fs.rs1use crate::task::{CurrentTask, Kernel};
6use crate::vfs::{
7 CacheMode, FileSystem, FileSystemHandle, FileSystemOps, FileSystemOptions, FsStr,
8};
9use starnix_types::vfs::default_statfs;
10use starnix_uapi::errors::Errno;
11use starnix_uapi::{SOCKFS_MAGIC, statfs};
12
13pub struct SocketFs;
16impl FileSystemOps for SocketFs {
17 fn statfs(&self, _fs: &FileSystem, _current_task: &CurrentTask) -> Result<statfs, Errno> {
18 Ok(default_statfs(SOCKFS_MAGIC))
19 }
20 fn name(&self) -> &'static FsStr {
21 "sockfs".into()
22 }
23}
24
25pub fn socket_fs(kernel: &Kernel) -> FileSystemHandle {
27 struct SocketFsHandle(FileSystemHandle);
28
29 kernel
30 .expando
31 .get_or_init(|| {
32 SocketFsHandle(
33 FileSystem::new(
34 kernel,
35 CacheMode::Uncached,
36 SocketFs,
37 FileSystemOptions::default(),
38 )
39 .expect("socketfs constructed with valid options"),
40 )
41 })
42 .0
43 .clone()
44}