1use std::fs::File;
2use std::io;
3use std::path::Path;
4
5pub(crate) use nix::errno::errno;
6
7use crate::env::emulate_freebsd;
8use crate::sys::{DirMeta, FileSystemFlags};
9
10pub fn path_disk_allocation(path: &Path) -> std::io::Result<u64> {
11 let metadata = std::fs::metadata(path)?;
12 use std::os::unix::fs::MetadataExt;
13 Ok(metadata.blocks() * 512)
14}
15
16struct UnixFilesystemFlags {}
17
18impl FileSystemFlags for UnixFilesystemFlags {
19 fn supports_sparse_files(&self) -> bool {
20 true
22 }
23
24 fn supports_block_cloning(&self) -> Option<bool> {
25 if emulate_freebsd() {
29 Some(false)
30 } else {
31 None
32 }
33 }
34}
35
36impl DirMeta for File {
37 fn file_system_flags(&self) -> io::Result<impl FileSystemFlags> {
38 Ok(UnixFilesystemFlags {})
39 }
40}