Skip to content

Commit

Permalink
Merge pull request #1113 from cagatay-y/main
Browse files Browse the repository at this point in the history
fuse: fix incorrect len field in command headers
  • Loading branch information
mkroening authored Mar 26, 2024
2 parents c2f023f + c4990a4 commit 4e9c13c
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 @@ -498,7 +500,10 @@ impl<O: ops::Op> Cmd<O> {
fn with_capacity(nodeid: u64, op_header: O::InStruct, len: usize) -> Box<UninitCmd<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 4e9c13c

Please sign in to comment.