Skip to main content

read_events

Function read_events 

Source
pub fn read_events(fd: &Fd) -> Result<Vec<InotifyEvent>, CoreError>
Expand description

Read all available inotify events from the descriptor.

This function drains the inotify file descriptor until no more events are available (EAGAIN). It is safe to use with edge-triggered reactors.

§Edge Cases

  • Zero-length read: If the descriptor is non-blocking and no data is ready, this returns Ok(Vec::new()) (via EAGAIN mapping).
  • Partial read: This function ensures that only complete event structures are decoded from the buffer.

§Errors

  • EBADF: The provided file descriptor is invalid.
  • EFAULT: The internal buffer points outside the process’s address space.
  • EINVAL: Internal buffer is too small for even one event (should not happen).
  • EIO: Low-level I/O error.