(host_buf: &Vec<u8>, in_idx: usize)
| 47 | impl Dirent { |
| 48 | #[requires(in_idx < host_buf.len())] |
| 49 | pub fn parse(host_buf: &Vec<u8>, in_idx: usize) -> RuntimeResult<Dirent> { |
| 50 | assert!(false); |
| 51 | // Inode number |
| 52 | let d_ino = u32::from_le_bytes([ |
| 53 | host_buf[in_idx + 0], |
| 54 | host_buf[in_idx + 1], |
| 55 | host_buf[in_idx + 2], |
| 56 | host_buf[in_idx + 3], |
| 57 | ]); |
| 58 | |
| 59 | // Offset to next linux_dirent |
| 60 | let d_reclen = u16::from_le_bytes([host_buf[in_idx + 4], host_buf[in_idx + 5]]); |
| 61 | |
| 62 | // File type |
| 63 | let d_type = host_buf[in_idx + 6]; |
| 64 | |
| 65 | // Length of this linux_dirent |
| 66 | let d_namlen = host_buf[in_idx + 7]; |
| 67 | |
| 68 | // If we would overflow - don't :) |
| 69 | if d_reclen < 8 || (in_idx + d_reclen as usize) > host_buf.len() { |
| 70 | return Err(RuntimeError::Eoverflow); |
| 71 | } |
| 72 | |
| 73 | let out_namlen = first_null(&host_buf, in_idx, 8, d_reclen as usize); |
| 74 | let dirent = Dirent { |
| 75 | ino: d_ino as u64, |
| 76 | reclen: d_reclen, |
| 77 | name_start: 8, |
| 78 | out_namlen, |
| 79 | typ: d_type, |
| 80 | }; |
| 81 | |
| 82 | Ok(dirent) |
| 83 | } |
| 84 | } |
nothing calls this directly
no test coverage detected