-
Notifications
You must be signed in to change notification settings - Fork 268
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fs-watch: Use a properly sized buffer for inotify events (#195)
The buffer passed to `read(2)` to read inotify events from the inotify fd must be long enough to fit events with filenames of the maximum allowable length. The `inotify-rs` library previously always constructed such a buffer, but as of 1fe4e38, we are required to provide our own buffer. The buffer we were providing was insufficiently large for some filenames. See also the `man` page for `inotify`: > The behavior when the buffer given to read(2) is too small to return > information about the next event depends on the kernel version: in > kernels before 2.6.21, read(2) returns 0; since kernel 2.6.21, > read(2) fails with the error EINVAL. Specifying a buffer of size > > sizeof(struct inotify_event) + NAME_MAX + 1 > > will be sufficient to read at least one event. (http://man7.org/linux/man-pages/man7/inotify.7.html) This branch updates the `fs-watch` lib to calculate the necessary buffer length correctly, and use a properly-sized buffer. I've also added tests that fail when the buffer is too short. Fixes linkerd/linkerd2#2331 Signed-off-by: Eliza Weisman <eliza@buoyant.io>
- Loading branch information
Showing
3 changed files
with
39 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters