On Fri, 2010-08-20 at 15:27 +0200, Andreas Schwab wrote:
Andreas suggested (I accidentally dropped the list when I ask him) I use
natural alignment and explicit padding rather than ((packed))
I'm open to the idea but I want to make it idiot proof (aka I won't
screw it up later) My best offhand idea would be to do something like
so:
Expose this to userspace:
struct fanotify_event_metadata {
__u32 event_len;
__u32 vers;
__s32 fd;
__u64 mask;
__s64 pid;
};
Wrap this in #ifdef KERNEL
struct fanotify_event_metadata_packed {
__u32 event_len;
__u32 vers;
__s32 fd;
__u64 mask;
__s64 pid;
} __attribute__ ((packed));
Then add:
BUILD_BUG_ON(sizeof(struct fanotify_event_metadata) !=
sizeof(struct fanotify_event_metadata_packed);
Is that a good way to make the actual object non-packed but keep myself
from ever letting it fail alignment and padding requirements?
-Eric
--