Skip to content

openvmm: virtiofs: microVM readdirplus continues listing when child entry aliases open directory node #1634

Open

Description

@tangruize

Summary

In microVM mode, VirtioFsFile::read_dir_microvm resolves each FUSE_READDIRPLUS entry by calling fs.lookup_helper(&self.inode, name) without checking whether the returned fuse_entry.nodeid equals the FUSE node ID of the open directory being enumerated (request.node_id()). If a child directory entry deduplicates onto self.inode's own node ID, InodeMap::insert rewrites self.inode.path from "dir" to "dir/child" in place, read_dir_microvm emits a self-referential child nodeid to the guest, and subsequent loop iterations resolve remaining snapshot names inside "dir/child" instead of "dir". Found by formal verification.

Root Cause

In vm/devices/virtio/virtiofs/src/lib.rs, Fuse::read_dir and Fuse::read_dir_plus do not pass request.node_id() to file.read_dir, and VirtioFsFile::read_dir_microvm accepts any fuse_entry returned by fs.lookup_helper(&self.inode, name) whose attr.ino matches the snapshot:

    fn read_dir_plus(&self, request: &Request, arg: &fuse_read_in) -> lx::Result<Vec<u8>> {
        if self.is_synthetic_root_handle(request.node_id(), arg.fh) {
            return self.read_synthetic_root_dir(arg.offset, arg.size, true);
        }
        let file = self.get_file(arg.fh)?;
        file.read_dir(self, arg.offset, arg.size, true)
    }
                    let fuse_entry = fs.lookup_helper(&self.inode, name)?;
                    if fuse_entry.attr.ino != entry.guest_inode_id {
                        return Err(lx::Error::EIO);
                    }
                    if !buffer.dir_entry_plus(name, entry.next_cookie, fuse_entry) {
                        return Err(lx::Error::EIO);
                    }

When lookup_helper resolves a child directory whose DedupKey matches self.inode (same file type S_IFDIR), InodeMap::insert takes the Entry::Occupied branch and calls VirtioFsInode::lookup, overwriting *self.inode.path.write() = new_path ("dir/child") and returning fuse_entry.nodeid == request.node_id(). Even the existing fuse_entry.attr.ino != entry.guest_inode_id check does not reject the entry when the snapshot already recorded that inode number.

Consequence

On local Linux filesystems (ext4, xfs, btrfs, tmpfs), an open directory file descriptor keeps its (st_dev, st_ino) allocated on the host until closed, preventing immediate (st_dev, st_ino) reuse by a newly created directory on the same device. However, synthetic, network, or FUSE-backed host shares that reuse or synthesize inode numbers, unlinked/retyped directory cases where the backing filesystem reuses (st_dev, st_ino), or nested subvolumes when DedupKey::Ino omits st_dev (for example a btrfs subvolume directory containing a nested subvolume, both having st_ino == 256) can hit this path. When triggered, read_dir_microvm returns a fuse_direntplus entry whose child nodeid equals its parent directory's nodeid (forming a directory cycle in the guest kernel's dcache) and continues iterating the snapshot while &self.inode now points at "dir/child", resolving later entries from the child directory rather than the open directory.

Reproduction

  1. Create a microVM VirtioFs share containing "dir/sub/after".
  2. Insert a directory VirtioFsInode at path "dir" with dir_node_id whose DedupKey matches "dir/sub" (modeling (dev, ino) reuse or collision), open it as a directory VirtioFsFile, and populate its directory snapshot with [".", "..", "sub", "after"].
  3. Call file.read_dir(&fs, dir_node_id, 0, 4096, true).
  4. Without the guard, lookup_helper on "sub" deduplicates onto dir_node_id, rewrites dir_inode's path from "dir" to "dir/sub", emits "sub" with nodeid == dir_node_id, and then resolves "after" against "dir/sub/after" even though "dir/after" does not exist.

Related: #1611, #1605, #1599.

Activity

  1. tangruize commented on Nov 15, 2026

    @tangruize
    ContributorAuthor

    Suggested Fix

    Thread dir_node_id: u64 (request.node_id()) through VirtioFsFile::read_dir into VirtioFsFile::read_dir_microvm. Immediately after fs.lookup_helper(&self.inode, name) succeeds in read_dir_microvm, check if fuse_entry.nodeid == dir_node_id: release the newly acquired lookup reference (fs.forget(fuse_entry.nodeid, 1)), and stop enumeration immediately — returning Ok(buffer) if earlier entries were already buffered (so the guest can release their lookup references) or Err(lx::Error::EIO) if buffer.is_empty(). When merging alongside the sibling read_dir_microvm fixes that roll back lookup references via fs.forget_lookups / stopped on mid-listing failures and drop the fuse_entry.attr.ino != entry.guest_inode_id check for btrfs subvolumes, combine the post-lookup guard into if node_id == dir_node_id || !buffer.dir_entry_plus(name, entry.next_cookie, fuse_entry) before calling fs.forget_lookups(node_id, 1) and setting stopped = Some(lx::Error::EIO).

    Patch against OpenVMM 9d64daad3cbe14fb0591081b73c6c9648e18d0fb. Save the contents below as fix.patch and run git apply fix.patch.

    fix.patch
    diff --git a/vm/devices/virtio/virtiofs/src/file.rs b/vm/devices/virtio/virtiofs/src/file.rs
    index e4b1f5567..ddd8feb56 100644
    --- a/vm/devices/virtio/virtiofs/src/file.rs
    +++ b/vm/devices/virtio/virtiofs/src/file.rs
    @@ -118,12 +118,13 @@ pub fn write(&self, buffer: &[u8], offset: u64, thread_uid: lx::uid_t) -> lx::Re
         pub fn read_dir(
             &self,
             fs: &super::VirtioFs,
    +        dir_node_id: u64,
             offset: u64,
             size: u32,
             plus: bool,
         ) -> lx::Result<Vec<u8>> {
             if fs.is_microvm() {
    -            return self.read_dir_microvm(fs, offset, size, plus);
    +            return self.read_dir_microvm(fs, dir_node_id, offset, size, plus);
             }
             self.read_dir_with(offset, size, plus, |name| {
                 fs.lookup_helper(&self.inode, name)
    diff --git a/vm/devices/virtio/virtiofs/src/inode.rs b/vm/devices/virtio/virtiofs/src/inode.rs
    index 6ec061ce3..791485abe 100644
    --- a/vm/devices/virtio/virtiofs/src/inode.rs
    +++ b/vm/devices/virtio/virtiofs/src/inode.rs
    @@ -722,7 +722,7 @@ fn path_keyed_sandbox_readdir_preserves_lookup_checks() {
                 let root_file = Arc::clone(&root_inode)
                     .open(lx::O_RDONLY | lx::O_DIRECTORY)
                     .unwrap();
    -            let entries = read_directory(&fs, &root_file, 0, 256, false);
    +            let entries = read_directory(&fs, &root_file, FUSE_ROOT_ID, 0, 256, false);
                 assert_eq!(
                     entries.keys().map(String::as_str).collect::<Vec<_>>(),
                     [".", "..", "allowed"]
    @@ -746,7 +746,10 @@ fn path_keyed_sandbox_readdir_preserves_lookup_checks() {
                 let initial_inodes = fs.inner.inodes.read().inodes_by_node_id.values.len();
                 for size in [256, 4096] {
                     for plus in [false, true] {
    -                    assert_eq!(read_directory(&fs, &file, 0, size, plus), expected);
    +                    assert_eq!(
    +                        read_directory(&fs, &file, entry.nodeid, 0, size, plus),
    +                        expected
    +                    );
                         assert_eq!(
                             fs.inner.inodes.read().inodes_by_node_id.values.len(),
                             initial_inodes
    @@ -756,7 +759,7 @@ fn path_keyed_sandbox_readdir_preserves_lookup_checks() {
                 fs.forget(existing.nodeid, 1);
                 assert!(fs.inner.inodes.read().get(existing.nodeid).is_none());
     
    -            let data = file.read_dir(&fs, 0, 96, false).unwrap();
    +            let data = file.read_dir(&fs, entry.nodeid, 0, 96, false).unwrap();
                 let mut remaining = data.as_slice();
                 let mut offset = 0;
                 while !remaining.is_empty() {
    @@ -780,14 +783,21 @@ fn path_keyed_sandbox_readdir_preserves_lookup_checks() {
                 }
                 expected.remove(&victim);
                 for plus in [false, true] {
    -                assert_eq!(read_directory(&fs, &file, offset, 256, plus), expected);
    +                assert_eq!(
    +                    read_directory(&fs, &file, entry.nodeid, offset, 256, plus),
    +                    expected
    +                );
                 }
     
                 let host = LxVolume::new(root.path()).unwrap();
                 host.rename("allowed", "blocked.EXE", 0).unwrap();
                 std::fs::create_dir(&allowed).unwrap();
                 for plus in [false, true] {
    -                assert!(file.read_dir(&fs, offset, 256, plus).unwrap().is_empty());
    +                assert!(
    +                    file.read_dir(&fs, entry.nodeid, offset, 256, plus)
    +                        .unwrap()
    +                        .is_empty()
    +                );
                 }
             }
         }
    diff --git a/vm/devices/virtio/virtiofs/src/lib.rs b/vm/devices/virtio/virtiofs/src/lib.rs
    index 71780f585..4378654fe 100644
    --- a/vm/devices/virtio/virtiofs/src/lib.rs
    +++ b/vm/devices/virtio/virtiofs/src/lib.rs
    @@ -484,7 +484,7 @@ fn read_dir(&self, request: &Request, arg: &fuse_read_in) -> lx::Result<Vec<u8>>
                 return self.read_synthetic_root_dir(arg.offset, arg.size, false);
             }
             let file = self.get_file(arg.fh)?;
    -        file.read_dir(self, arg.offset, arg.size, false)
    +        file.read_dir(self, request.node_id(), arg.offset, arg.size, false)
         }
     
         fn read_dir_plus(&self, request: &Request, arg: &fuse_read_in) -> lx::Result<Vec<u8>> {
    @@ -492,7 +492,7 @@ fn read_dir_plus(&self, request: &Request, arg: &fuse_read_in) -> lx::Result<Vec
                 return self.read_synthetic_root_dir(arg.offset, arg.size, true);
             }
             let file = self.get_file(arg.fh)?;
    -        file.read_dir(self, arg.offset, arg.size, true)
    +        file.read_dir(self, request.node_id(), arg.offset, arg.size, true)
         }
     
         fn release_dir(&self, request: &Request, arg: &fuse_release_in) -> lx::Result<()> {
    @@ -1298,6 +1298,7 @@ fn request(node_id: u64) -> Request {
         pub(super) fn read_directory(
             fs: &VirtioFs,
             file: &super::VirtioFsFile,
    +        node_id: u64,
             mut offset: u64,
             size: u32,
             plus: bool,
    @@ -1305,7 +1306,7 @@ pub(super) fn read_directory(
             let mut entries = BTreeMap::new();
             let mut offsets = HashSet::new();
             loop {
    -            let data = file.read_dir(fs, offset, size, plus).unwrap();
    +            let data = file.read_dir(fs, node_id, offset, size, plus).unwrap();
                 assert!(data.len() <= size as usize);
                 if data.is_empty() {
                     return entries;
    @@ -1379,7 +1380,7 @@ fn assert_directory_parity(
                             .unwrap();
                         let initial_inodes = fs.inner.inodes.read().inodes_by_node_id.values.len();
                         assert_eq!(
    -                        read_directory(&fs, &file, 0, size, plus),
    +                        read_directory(&fs, &file, node_id, 0, size, plus),
                             expected,
                             "aggregate={aggregate}, size={size}, plus={plus}"
                         );
    @@ -1388,7 +1389,7 @@ fn assert_directory_parity(
                             initial_inodes
                         );
                         assert_eq!(
    -                        file.read_dir(&fs, 0, 0, plus).unwrap_err(),
    +                        file.read_dir(&fs, node_id, 0, 0, plus).unwrap_err(),
                             lx::Error::EINVAL
                         );
                     }
    @@ -1425,7 +1426,12 @@ fn plain_readdir_does_not_increment_existing_lookup() {
             let entry = fs.lookup_helper(&inode, "file".as_ref()).unwrap();
             let file = inode.open(lx::O_RDONLY | lx::O_DIRECTORY).unwrap();
             for _ in 0..2 {
    -            assert!(!file.read_dir(&fs, 0, 4096, false).unwrap().is_empty());
    +            assert!(
    +                !file
    +                    .read_dir(&fs, FUSE_ROOT_ID, 0, 4096, false)
    +                    .unwrap()
    +                    .is_empty()
    +            );
             }
             fs.forget(entry.nodeid, 1);
             assert!(fs.inner.inodes.read().get(entry.nodeid).is_none());
    @@ -1439,7 +1445,7 @@ fn readdirplus_retains_lookup_references() {
             let inode = fs.get_inode(FUSE_ROOT_ID).unwrap();
             let entry = fs.lookup_helper(&inode, "file".as_ref()).unwrap();
             let file = inode.open(lx::O_RDONLY | lx::O_DIRECTORY).unwrap();
    -        let data = file.read_dir(&fs, 0, 4096, true).unwrap();
    +        let data = file.read_dir(&fs, FUSE_ROOT_ID, 0, 4096, true).unwrap();
             let mut remaining = data.as_slice();
             let mut found = false;
             while !remaining.is_empty() {
    @@ -1546,7 +1552,7 @@ fn readdirplus_skips_cached_entries_that_no_longer_pass_lookup() {
                 }
     
                 // Return the dots and one child, leaving the other children cached.
    -            let data = file.read_dir(&fs, 0, 96, false).unwrap();
    +            let data = file.read_dir(&fs, FUSE_ROOT_ID, 0, 96, false).unwrap();
                 let mut remaining = data.as_slice();
                 let mut offset = 0;
                 let mut first_child = None;
    @@ -1579,9 +1585,15 @@ fn readdirplus_skips_cached_entries_that_no_longer_pass_lookup() {
                         lx::Error::ENOENT
                     }
                 );
    -            assert_eq!(read_directory(&fs, &file, offset, 256, false), expected);
    +            assert_eq!(
    +                read_directory(&fs, &file, FUSE_ROOT_ID, offset, 256, false),
    +                expected
    +            );
                 expected.remove(&victim);
    -            assert_eq!(read_directory(&fs, &file, offset, 256, true), expected);
    +            assert_eq!(
    +                read_directory(&fs, &file, FUSE_ROOT_ID, offset, 256, true),
    +                expected
    +            );
             }
         }
     
    @@ -1621,7 +1633,7 @@ fn plain_readdir_rejects_renamed_and_replaced_directory() {
                     let mut expected_names =
                         BTreeMap::from([".", "..", "a", "b", "c"].map(|name| (name.to_owned(), ())));
                     if continuation {
    -                    let data = file.read_dir(&fs, 0, 96, false).unwrap();
    +                    let data = file.read_dir(&fs, entry.nodeid, 0, 96, false).unwrap();
                         let mut remaining = data.as_slice();
                         while !remaining.is_empty() {
                             let (entry, rest) = fuse_dirent::read_from_prefix(remaining).unwrap();
    @@ -1642,14 +1654,15 @@ fn plain_readdir_rejects_renamed_and_replaced_directory() {
                     // Both FUSE getters report the cached guest inode, hiding the mismatch.
                     assert_eq!(inode.get_attr().unwrap().ino, file.get_attr().unwrap().ino);
                     assert_eq!(
    -                    file.read_dir(&fs, offset, 4096, false).unwrap_err(),
    +                    file.read_dir(&fs, entry.nodeid, offset, 4096, false)
    +                        .unwrap_err(),
                         lx::Error::EACCES,
                         "aggregate={aggregate}, continuation={continuation}"
                     );
     
                     std::fs::remove_dir(root.path().join("allowed")).unwrap();
                     host.rename("blocked.EXE", "allowed", 0).unwrap();
    -                let entries = read_directory(&fs, &file, offset, 256, false);
    +                let entries = read_directory(&fs, &file, entry.nodeid, offset, 256, false);
                     assert_eq!(
                         entries.keys().collect::<Vec<_>>(),
                         expected_names.keys().collect::<Vec<_>>()
    @@ -1679,12 +1692,18 @@ fn plain_readdir_revalidates_sandbox_ancestors() {
             let file = Arc::clone(&inode)
                 .open(lx::O_RDONLY | lx::O_DIRECTORY)
                 .unwrap();
    -        assert!(!file.read_dir(&fs, 0, 4096, false).unwrap().is_empty());
    +        assert!(
    +            !file
    +                .read_dir(&fs, FUSE_ROOT_ID, 0, 4096, false)
    +                .unwrap()
    +                .is_empty()
    +        );
     
             // An open handle must not bypass policy after its inode path is refreshed.
             inode.lookup(std::path::PathBuf::from("blocked.EXE").join("child"));
             assert_eq!(
    -            file.read_dir(&fs, 0, 4096, false).unwrap_err(),
    +            file.read_dir(&fs, FUSE_ROOT_ID, 0, 4096, false)
    +                .unwrap_err(),
                 lx::Error::EACCES
             );
         }
    diff --git a/vm/devices/virtio/virtiofs/src/microvm/file.rs b/vm/devices/virtio/virtiofs/src/microvm/file.rs
    index 4451a5f8a..3bb9af654 100644
    --- a/vm/devices/virtio/virtiofs/src/microvm/file.rs
    +++ b/vm/devices/virtio/virtiofs/src/microvm/file.rs
    @@ -10,12 +10,14 @@
     use crate::VirtioFs;
     use crate::file::VirtioFsFile;
     use fuse::DirEntryWriter;
    +use fuse::Fuse;
     use fuse::protocol::fuse_entry_out;
     
     impl VirtioFsFile {
         pub(crate) fn read_dir_microvm(
             &self,
             fs: &VirtioFs,
    +        dir_node_id: u64,
             offset: u64,
             size: u32,
             plus: bool,
    @@ -68,6 +70,16 @@ pub(crate) fn read_dir_microvm(
                             break;
                         }
                         let fuse_entry = fs.lookup_helper(&self.inode, name)?;
    +                    if fuse_entry.nodeid == dir_node_id {
    +                        // A child entry that deduplicated onto the open directory
    +                        // has already overwritten `self.inode.path`; drop its
    +                        // lookup reference and stop before using that mutated path.
    +                        fs.forget(fuse_entry.nodeid, 1);
    +                        if buffer.is_empty() {
    +                            return Err(lx::Error::EIO);
    +                        }
    +                        return Ok(buffer);
    +                    }
                         if fuse_entry.attr.ino != entry.guest_inode_id {
                             return Err(lx::Error::EIO);
                         }
    diff --git a/vm/devices/virtio/virtiofs/src/microvm/fs_tests.rs b/vm/devices/virtio/virtiofs/src/microvm/fs_tests.rs
    index 3f3e952a8..d1697d69d 100644
    --- a/vm/devices/virtio/virtiofs/src/microvm/fs_tests.rs
    +++ b/vm/devices/virtio/virtiofs/src/microvm/fs_tests.rs
    @@ -293,14 +293,14 @@ fn directory_snapshot_survives_host_mutation_after_restore() {
             .unwrap();
         let file = source.get_file(handle).unwrap();
     
    -    let first_page = file.read_dir(&source, 0, 32, false).unwrap();
    +    let first_page = file.read_dir(&source, FUSE_ROOT_ID, 0, 32, false).unwrap();
         assert!(!first_page.is_empty());
         let snapshot = file.directory_entries();
         assert!(snapshot.len() > 1);
         let continuation_offset = snapshot[0].next_cookie;
         assert_ne!(continuation_offset, 0);
         let expected_continuation = file
    -        .read_dir(&source, continuation_offset, 4096, false)
    +        .read_dir(&source, FUSE_ROOT_ID, continuation_offset, 4096, false)
             .unwrap();
         let state = source
             .save_microvm_state(&profile, SessionState::default())
    @@ -317,7 +317,7 @@ fn directory_snapshot_survives_host_mutation_after_restore() {
         let continuation = destination
             .get_file(handle)
             .unwrap()
    -        .read_dir(&destination, continuation_offset, 4096, false)
    +        .read_dir(&destination, FUSE_ROOT_ID, continuation_offset, 4096, false)
             .unwrap();
         assert_eq!(continuation, expected_continuation);
     }
    @@ -391,3 +391,122 @@ fn relative_path_validation_rejects_platform_escapes() {
         assert!(validate_relative_path(Path::new("/outside"), true).is_err());
         assert!(validate_relative_path(Path::new("alternate:name"), true).is_err());
     }
    +
    +#[test]
    +fn readdirplus_stops_when_child_aliases_the_open_directory() {
    +    use super::saved_state::SavedDirectoryEntry;
    +    use fuse::protocol::fuse_dirent_align;
    +    use fuse::protocol::fuse_direntplus;
    +    use zerocopy::FromBytes;
    +
    +    fn direntplus_names(mut bytes: &[u8]) -> Vec<(String, u64)> {
    +        let mut out = Vec::new();
    +        while !bytes.is_empty() {
    +            let (entry, rest) = fuse_direntplus::read_from_prefix(bytes).unwrap();
    +            let namelen = entry.dirent.namelen as usize;
    +            let name = std::str::from_utf8(&rest[..namelen]).unwrap().to_owned();
    +            out.push((name, entry.entry_out.nodeid));
    +            bytes = &bytes[fuse_dirent_align(size_of::<fuse_direntplus>() + namelen)..];
    +        }
    +        out
    +    }
    +
    +    let temporary_directory = tempdir().unwrap();
    +    let root_path = temporary_directory.path();
    +    std::fs::create_dir_all(root_path.join("dir").join("sub")).unwrap();
    +    std::fs::write(root_path.join("dir").join("sub").join("after"), b"nested").unwrap();
    +
    +    let make_snapshot = |sub_ino: u64, after_ino: u64| {
    +        vec![
    +            SavedDirectoryEntry {
    +                name: b".".to_vec(),
    +                next_cookie: 1,
    +                guest_inode_id: sub_ino,
    +                kind: lx::DT_DIR as u32,
    +            },
    +            SavedDirectoryEntry {
    +                name: b"..".to_vec(),
    +                next_cookie: 2,
    +                guest_inode_id: sub_ino,
    +                kind: lx::DT_DIR as u32,
    +            },
    +            SavedDirectoryEntry {
    +                name: b"sub".to_vec(),
    +                next_cookie: 3,
    +                guest_inode_id: sub_ino,
    +                kind: lx::DT_DIR as u32,
    +            },
    +            SavedDirectoryEntry {
    +                name: b"after".to_vec(),
    +                next_cookie: 4,
    +                guest_inode_id: after_ino,
    +                kind: lx::DT_REG as u32,
    +            },
    +        ]
    +    };
    +
    +    // Case 1: `offset = 0` already buffered `.` and `..` before `"sub"`, so
    +    // `read_dir_microvm` must release `"sub"`'s lookup reference, return only
    +    // `.` and `..`, and never resolve `"after"` through the mutated path.
    +    let fs = VirtioFs::new_microvm(root_path, profile(root_path)).unwrap();
    +    let volume = fs.get_inode(FUSE_ROOT_ID).unwrap().volume();
    +    let sub_stat = volume.lstat(Path::new("dir/sub")).unwrap();
    +    let after_stat = volume.lstat(Path::new("dir/sub/after")).unwrap();
    +    let (dir_inode, dir_node_id) = fs
    +        .insert_inode(crate::inode::VirtioFsInode::with_attr(
    +            Arc::clone(&volume),
    +            PathBuf::from("dir"),
    +            &sub_stat,
    +        ))
    +        .unwrap();
    +    let file = Arc::clone(&dir_inode)
    +        .open(lx::O_RDONLY | lx::O_DIRECTORY)
    +        .unwrap();
    +    file.restore_directory_snapshot(
    +        true,
    +        make_snapshot(
    +            dir_inode.guest_inode_nr(),
    +            dir_inode.guest_ino(after_stat.inode_nr),
    +        ),
    +    )
    +    .unwrap();
    +
    +    let page = file.read_dir(&fs, dir_node_id, 0, 4096, true).unwrap();
    +    assert_eq!(
    +        direntplus_names(&page),
    +        vec![(".".to_owned(), 0), ("..".to_owned(), 0)]
    +    );
    +    assert_eq!(dir_inode.lookup_count(), 1);
    +    assert_eq!(fs.inner.inodes.read().inodes_by_node_id.values.len(), 2);
    +
    +    // Case 2: resuming at `"sub"` (`offset = 2`) starts with an empty buffer,
    +    // so `read_dir_microvm` must release `"sub"`'s lookup reference and return
    +    // `EIO` without resolving `"after"`.
    +    let fs = VirtioFs::new_microvm(root_path, profile(root_path)).unwrap();
    +    let volume = fs.get_inode(FUSE_ROOT_ID).unwrap().volume();
    +    let (dir_inode, dir_node_id) = fs
    +        .insert_inode(crate::inode::VirtioFsInode::with_attr(
    +            Arc::clone(&volume),
    +            PathBuf::from("dir"),
    +            &sub_stat,
    +        ))
    +        .unwrap();
    +    let file = Arc::clone(&dir_inode)
    +        .open(lx::O_RDONLY | lx::O_DIRECTORY)
    +        .unwrap();
    +    file.restore_directory_snapshot(
    +        true,
    +        make_snapshot(
    +            dir_inode.guest_inode_nr(),
    +            dir_inode.guest_ino(after_stat.inode_nr),
    +        ),
    +    )
    +    .unwrap();
    +
    +    assert_eq!(
    +        file.read_dir(&fs, dir_node_id, 2, 4096, true).unwrap_err(),
    +        lx::Error::EIO
    +    );
    +    assert_eq!(dir_inode.lookup_count(), 1);
    +    assert_eq!(fs.inner.inodes.read().inodes_by_node_id.values.len(), 2);
    +}
    diff --git a/vm/devices/virtio/virtiofs/src/microvm/symlink_tests.rs b/vm/devices/virtio/virtiofs/src/microvm/symlink_tests.rs
    index d22d58740..59ba4a947 100644
    --- a/vm/devices/virtio/virtiofs/src/microvm/symlink_tests.rs
    +++ b/vm/devices/virtio/virtiofs/src/microvm/symlink_tests.rs
    @@ -433,7 +433,7 @@ fn readdirplus_returns_usable_symlink_nodes() {
         let entries = fs
             .get_file(handle)
             .unwrap()
    -        .read_dir(&fs, 0, 4096, true)
    +        .read_dir(&fs, FUSE_ROOT_ID, 0, 4096, true)
             .unwrap();
         assert!(!entries.is_empty());
         let link = fs.lookup(&request(FUSE_ROOT_ID), name(b"link")).unwrap();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: openvmmInitial title-keyword triage suggestion

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions