Deallocate the storage for `length` bytes starting at `address`. Any future reads of this range will return all zeroes.
(&mut self, address: u64, length: usize)
| 1814 | // Deallocate the storage for `length` bytes starting at `address`. |
| 1815 | // Any future reads of this range will return all zeroes. |
| 1816 | fn deallocate_bytes(&mut self, address: u64, length: usize) -> std::io::Result<()> { |
| 1817 | let write_count: usize = self.limit_range_file(address, length); |
| 1818 | |
| 1819 | let mut nwritten: usize = 0; |
| 1820 | while nwritten < write_count { |
| 1821 | let curr_addr = address + nwritten as u64; |
| 1822 | let count = self.limit_range_cluster(curr_addr, write_count - nwritten); |
| 1823 | |
| 1824 | if count == self.raw_file.cluster_size() as usize { |
| 1825 | // Full cluster - deallocate the storage. |
| 1826 | self.deallocate_cluster(curr_addr)?; |
| 1827 | } else { |
| 1828 | // Partial cluster - zero out the relevant bytes if it was allocated. |
| 1829 | // Any space in unallocated clusters can be left alone, since |
| 1830 | // unallocated clusters already read back as zeroes. |
| 1831 | let offset = self.file_offset_write(curr_addr)?; |
| 1832 | // Partial cluster - zero it out. |
| 1833 | self.raw_file.file_mut().write_zeroes_at(offset, count)?; |
| 1834 | } |
| 1835 | |
| 1836 | nwritten += count; |
| 1837 | } |
| 1838 | Ok(()) |
| 1839 | } |
| 1840 | |
| 1841 | // Reads an L2 cluster from the disk, returning an error if the file can't be read or if any |
| 1842 | // cluster is compressed. |
no test coverage detected