summary refs log tree commit diff
path: root/devices/src/virtio/fs/filesystem.rs
diff options
context:
space:
mode:
authorChirantan Ekbote <chirantan@chromium.org>2020-04-13 17:14:16 +0900
committerCommit Bot <commit-bot@chromium.org>2020-04-16 06:32:41 +0000
commit80d61873eba0e40013bf6ffe1cba1276300e7dc5 (patch)
tree76cef4abedd1c56ce89da61a54ce4a00bb1a0f0b /devices/src/virtio/fs/filesystem.rs
parente17b2b9059e38ba2d76b542949d89b4d26d837f9 (diff)
downloadcrosvm-80d61873eba0e40013bf6ffe1cba1276300e7dc5.tar
crosvm-80d61873eba0e40013bf6ffe1cba1276300e7dc5.tar.gz
crosvm-80d61873eba0e40013bf6ffe1cba1276300e7dc5.tar.bz2
crosvm-80d61873eba0e40013bf6ffe1cba1276300e7dc5.tar.lz
crosvm-80d61873eba0e40013bf6ffe1cba1276300e7dc5.tar.xz
crosvm-80d61873eba0e40013bf6ffe1cba1276300e7dc5.tar.zst
crosvm-80d61873eba0e40013bf6ffe1cba1276300e7dc5.zip
devices: fs: Strip padding from directory entry names
When calling `getdents64`, the kernel will add additional nul bytes to
the name of the directory entry to make sure the whole thing is 8-byte
aligned.

Previously we would pass on this padded name to the kernel driver.
However, this seems to prevent the driver from detecting the "." and
".." entries, leading to the driver printing warnings like

  VFS: Lookup of '.' in virtiofs virtiofs would have caused loop

Strip out the padding so that the kernel detection of the "." and ".."
entries can work properly.

BUG=b:153677176
TEST=vm.Virtiofs and manually start a vm and check that the kernel
     doesn't print warnings about lookups causing loops

Change-Id: Id015182186cc3cb076e27556a1ab0a2de710aa59
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2145547
Auto-Submit: Chirantan Ekbote <chirantan@chromium.org>
Reviewed-by: Dylan Reid <dgreid@chromium.org>
Commit-Queue: Chirantan Ekbote <chirantan@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Diffstat (limited to 'devices/src/virtio/fs/filesystem.rs')
-rw-r--r--devices/src/virtio/fs/filesystem.rs2
1 files changed, 1 insertions, 1 deletions
diff --git a/devices/src/virtio/fs/filesystem.rs b/devices/src/virtio/fs/filesystem.rs
index eb9726c..3f9528f 100644
--- a/devices/src/virtio/fs/filesystem.rs
+++ b/devices/src/virtio/fs/filesystem.rs
@@ -77,7 +77,7 @@ pub struct DirEntry<'a> {
 
     /// The name of this directory entry. There are no requirements for the contents of this field
     /// and any sequence of bytes is considered valid.
-    pub name: &'a [u8],
+    pub name: &'a CStr,
 }
 
 /// A reply to a `getxattr` method call.