MCPcopy Create free account
hub / github.com/chyyuu/os_kernel_lab / ls

Method ls

easy-fs/src/vfs.rs:142–157  ·  view source on GitHub ↗
(&self)

Source from the content-addressed store, hash-verified

140 }
141
142 pub fn ls(&self) -> Vec<String> {
143 let _fs = self.fs.lock();
144 self.read_disk_inode(|disk_inode| {
145 let file_count = (disk_inode.size as usize) / DIRENT_SZ;
146 let mut v: Vec<String> = Vec::new();
147 for i in 0..file_count {
148 let mut dirent = DirEntry::empty();
149 assert_eq!(
150 disk_inode.read_at(i * DIRENT_SZ, dirent.as_bytes_mut(), &self.block_device,),
151 DIRENT_SZ,
152 );
153 v.push(String::from(dirent.name()));
154 }
155 v
156 })
157 }
158
159 pub fn read_at(&self, offset: usize, buf: &mut [u8]) -> usize {
160 let _fs = self.fs.lock();

Callers 3

list_appsFunction · 0.80
easy_fs_packFunction · 0.80
efs_testFunction · 0.80

Calls 4

lockMethod · 0.80
read_disk_inodeMethod · 0.80
nameMethod · 0.80
pushMethod · 0.45

Tested by 1

efs_testFunction · 0.64