Skip to content

Commit

Permalink
virtio/fs: Munge device number into inode number
Browse files Browse the repository at this point in the history
virtio-fs can expose multiple host mounts as a single mount. This means
that all st_dev numbers from the host get collapsed into a single
st_dev, breaking st_ino/st_dev comparisons for file identity.

Short of replicating the mount hierarchy with separate virtio-fs mounts,
there's no good way to fix this in all cases. So, do a best-effort hack
by XORing st_dev into the top bits of st_ino. This can still have
collisions, but it's a lot better than ignoring st_dev entirely (which
is very likely to have collisions with multiple mounted filesystems).

Fixes Wine in krun on Fedora systems with separate btrfs subvolumes for
/ and /home (which causes Wine to think / and /home are the same path,
breaking DOS device selection).

Signed-off-by: Asahi Lina <[email protected]>
  • Loading branch information
asahilina committed Jul 6, 2024
1 parent ddbd2fd commit 9d52648
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/devices/src/virtio/fs/fuse.rs
Original file line number Diff line number Diff line change
Expand Up @@ -546,7 +546,7 @@ unsafe impl ByteValued for Attr {}
impl From<bindings::stat64> for Attr {
fn from(st: bindings::stat64) -> Attr {
Attr {
ino: st.st_ino,
ino: st.st_ino ^ (st.st_dev << 32),
size: st.st_size as u64,
blocks: st.st_blocks as u64,
atime: st.st_atime as u64,
Expand Down

0 comments on commit 9d52648

Please sign in to comment.