Skip to content

Commit

Permalink
fuse: fix length calculation for header
Browse files Browse the repository at this point in the history
  • Loading branch information
cagatay-y committed Mar 26, 2024
1 parent ff2af8d commit d30602e
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/fs/fuse.rs
Original file line number Diff line number Diff line change
Expand Up @@ -482,7 +482,9 @@ where
fn new(nodeid: u64, op_header: O::InStruct) -> Box<Self> {
Box::new(Cmd {
in_header: fuse_abi::InHeader {
len: Layout::new::<Self>().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::<fuse_abi::InHeader>()
+ core::mem::size_of::<O::InStruct>()) as u32,
opcode: O::OP_CODE as u32,
nodeid,
unique: 1,
Expand All @@ -501,7 +503,10 @@ impl<O: ops::Op> Cmd<O> {
{
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::<fuse_abi::InHeader>()
+ core::mem::size_of::<O::InStruct>()
+ len)
.try_into()
.expect("The command is too large"),
opcode: O::OP_CODE as u32,
Expand Down

0 comments on commit d30602e

Please sign in to comment.