| 59 | /// Creates a new empty memory filesystem. |
| 60 | #[allow(clippy::new_ret_no_self)] |
| 61 | pub fn new() -> Filesystem { |
| 62 | let fs = Arc::new(Self { |
| 63 | inodes: Mutex::new(Slab::new()), |
| 64 | root: Mutex::default(), |
| 65 | }); |
| 66 | let root_ino = Inode::new( |
| 67 | &fs, |
| 68 | None, |
| 69 | NodeType::Directory, |
| 70 | NodePermission::from_bits_truncate(0o755), |
| 71 | ); |
| 72 | *fs.root.lock() = Some(DirEntry::new_dir( |
| 73 | |this| DirNode::new(MemoryNode::new(fs.clone(), root_ino, Some(this))), |
| 74 | Reference::root(), |
| 75 | )); |
| 76 | Filesystem::new(fs) |
| 77 | } |
| 78 | |
| 79 | fn get(&self, ino: u64) -> Arc<Inode> { |
| 80 | self.inodes.lock()[ino as usize - 1].clone() |