Skip to main content

forensic_mount/
fuse_windows.rs

1#![forbid(unsafe_code)]
2
3use crate::session::Session;
4use crate::ForensicFs;
5use crate::MountOptions;
6use std::io;
7use std::path::Path;
8
9/// Mount a `ForensicFs` via `WinFSP` on Windows.
10///
11/// This is a stub -- `WinFSP` support will be implemented when the
12/// `winfsp-wrs` crate is integrated.  Until then it unconditionally
13/// returns `io::ErrorKind::Unsupported`.
14pub fn mount_windows(
15    _fs: Box<dyn ForensicFs + Send>,
16    _mountpoint: &Path,
17    _session: Option<Session>,
18    _options: &MountOptions,
19) -> io::Result<()> {
20    Err(io::Error::new(
21        io::ErrorKind::Unsupported,
22        "Windows FUSE (WinFSP) support not yet implemented",
23    ))
24}
25
26#[cfg(test)]
27mod tests {
28    use super::*;
29    use crate::types::*;
30
31    // Minimal mock so we can call mount_windows without a real fs.
32    struct StubFs;
33
34    impl crate::ForensicFs for StubFs {
35        fn root_ino(&self) -> u64 {
36            2
37        }
38        fn read_dir(&mut self, _ino: u64) -> FsResult<Vec<FsDirEntry>> {
39            Ok(vec![])
40        }
41        fn lookup(&mut self, _parent: u64, _name: &[u8]) -> FsResult<Option<u64>> {
42            Ok(None)
43        }
44        fn metadata(&mut self, _ino: u64) -> FsResult<FsMetadata> {
45            Err(FsError::NotFound("stub".into()))
46        }
47        fn read_file(&mut self, _ino: u64) -> FsResult<Vec<u8>> {
48            Err(FsError::NotFound("stub".into()))
49        }
50        fn read_file_range(&mut self, _ino: u64, _off: u64, _len: u64) -> FsResult<Vec<u8>> {
51            Err(FsError::NotFound("stub".into()))
52        }
53        fn read_link(&mut self, _ino: u64) -> FsResult<Vec<u8>> {
54            Err(FsError::NotFound("stub".into()))
55        }
56    }
57
58    #[test]
59    fn windows_mount_returns_unsupported() {
60        let fs: Box<dyn ForensicFs + Send> = Box::new(StubFs);
61        let opts = MountOptions::default();
62        let result = mount_windows(fs, Path::new("/mnt"), None, &opts);
63        assert!(result.is_err());
64        let err = result.unwrap_err();
65        assert_eq!(err.kind(), io::ErrorKind::Unsupported);
66        assert!(err.to_string().contains("WinFSP"));
67    }
68}