]> git.ipfire.org Git - thirdparty/man-pages.git/commit
fanotify.7: fanotify_read should use aligned buffer
authorHeinrich Schuchardt <xypron.glpk@gmx.de>
Wed, 21 May 2014 20:16:16 +0000 (22:16 +0200)
committerMichael Kerrisk <mtk.manpages@gmail.com>
Thu, 22 May 2014 06:49:30 +0000 (08:49 +0200)
commit864eccb90198a695d038c1be390de2a9e0c0f530
treeae0320d72c149776102d487f6064278cd1949e60
parentda9a495eaa2704282cada911d532c01c654b3f86
fanotify.7: fanotify_read should use aligned buffer

Michael Kerrisk pointed me to alignment issues which may
arise when reading misaligned integers.

On some systems integer values can only be read if they are
correctly aligned. Other system have a lower performance when
reading from or writing to misaligned memory positions.

Therefore, the buffer used to call read(2) for a fanotify
file descriptor should have the same alignment as
struct fanotify_event_metadata.

Due to the casting to char* inside the macros
FAN_EVENT_OK and FAN_EVENT_NEXT we can use any
data structure for the buffer.

With the patch an array of struct fanotify_event_metadata is
used as buffer which seems a natural choice to ensure proper
alignment.

It should be remembered that the offset between events is given
by field event_len and iterating over the array may not be
allowable in future. Instead the macros should be used.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
man7/fanotify.7