diff --git a/src/fs/fuse.rs b/src/fs/fuse.rs index 01830a94ef..d23fb6365f 100644 --- a/src/fs/fuse.rs +++ b/src/fs/fuse.rs @@ -482,7 +482,9 @@ where fn new(nodeid: u64, op_header: O::InStruct) -> Box { Box::new(Cmd { in_header: fuse_abi::InHeader { - len: Layout::new::().size() as u32, + // The length we need the provide in the header is not the same as the size of the struct because of padding, so we need to calculate it manually. + len: (core::mem::size_of::() + + core::mem::size_of::()) as u32, opcode: O::OP_CODE as u32, nodeid, unique: 1, @@ -498,7 +500,10 @@ impl Cmd { fn with_capacity(nodeid: u64, op_header: O::InStruct, len: usize) -> Box> { let mut cmd = unsafe { Self::new_uninit(len) }; cmd.in_header = MaybeUninit::new(fuse_abi::InHeader { - len: core::mem::size_of_val(cmd.as_ref()) + // The length we need the provide in the header is not the same as the size of the struct because of padding, so we need to calculate it manually. + len: (core::mem::size_of::() + + core::mem::size_of::() + + len) .try_into() .expect("The command is too large"), opcode: O::OP_CODE as u32,