Skip to content

Commit

Permalink
review: fix fanotify_event_metadata alignment on Rust <1.15.0
Browse files Browse the repository at this point in the history
  • Loading branch information
cpu committed Apr 2, 2020
1 parent 4034008 commit 8b30245
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 11 deletions.
11 changes: 11 additions & 0 deletions src/unix/linux_like/linux/align.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,17 @@ macro_rules! expand_align {
#[doc(hidden)]
size: [u8; ::__SIZEOF_PTHREAD_CONDATTR_T],
}

#[repr(align(8))]
pub struct fanotify_event_metadata {
pub event_len: __u32,
pub vers: __u8,
pub reserved: __u8,
pub metadata_len: __u16,
pub mask: __u64,
pub fd: ::c_int,
pub pid: ::c_int,
}
}

s_no_extra_traits! {
Expand Down
11 changes: 0 additions & 11 deletions src/unix/linux_like/linux/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -477,17 +477,6 @@ s! {
pub len: u32
}

#[repr(align(8))]
pub struct fanotify_event_metadata {
pub event_len: __u32,
pub vers: __u8,
pub reserved: __u8,
pub metadata_len: __u16,
pub mask: __u64,
pub fd: ::c_int,
pub pid: ::c_int,
}

pub struct fanotify_response {
pub fd: ::c_int,
pub response: __u32,
Expand Down
11 changes: 11 additions & 0 deletions src/unix/linux_like/linux/no_align.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,17 @@ macro_rules! expand_align {
__align: [::c_int; 0],
size: [u8; ::__SIZEOF_PTHREAD_CONDATTR_T],
}

pub struct fanotify_event_metadata {
__align: [::c_long; 0],
pub event_len: __u32,
pub vers: __u8,
pub reserved: __u8,
pub metadata_len: __u16,
pub mask: __u64,
pub fd: ::c_int,
pub pid: ::c_int,
}
}

s_no_extra_traits! {
Expand Down

0 comments on commit 8b30245

Please sign in to comment.