Fix overflow behavior and control flags
This commit is contained in:
parent
e082d4eaa6
commit
bdc1c79770
|
|
@ -3,7 +3,7 @@ inotify_events = IN_ACCESS | IN_MODIFY | IN_ATTRIB | IN_CLOSE_WRITE |
|
||||||
IN_DELETE_SELF | IN_CLOSE;
|
IN_DELETE_SELF | IN_CLOSE;
|
||||||
|
|
||||||
inotify_controls = IN_ONLYDIR | IN_DONT_FOLLOW | IN_MASK_CREATE |
|
inotify_controls = IN_ONLYDIR | IN_DONT_FOLLOW | IN_MASK_CREATE |
|
||||||
IN_MASK_ADD | IN_ISDIR | IN_ONESHOT;
|
IN_MASK_ADD | IN_ONESHOT;
|
||||||
|
|
||||||
// Add a watch to an initialized inotify instance
|
// Add a watch to an initialized inotify instance
|
||||||
inotify_add_watch(fd, pathname, mask = <inotify_events> | <inotify_controls>);
|
inotify_add_watch(fd, pathname, mask = <inotify_events> | <inotify_controls>);
|
||||||
|
|
|
||||||
|
|
@ -239,8 +239,12 @@ impl InotifyFile {
|
||||||
}
|
}
|
||||||
|
|
||||||
// If the queue is full, drop the event.
|
// If the queue is full, drop the event.
|
||||||
// We do not return an error to the caller.
|
// Try to queue an overflow event in advance to alert the user.
|
||||||
if event_queue.len() >= self.queue_capacity {
|
if event_queue.len() == self.queue_capacity - 1 {
|
||||||
|
let overflow_event = InotifyEvent::new(u32::MAX, FsEvents::Q_OVERFLOW, 0, None);
|
||||||
|
event_queue.push_back(overflow_event);
|
||||||
|
return;
|
||||||
|
} else if event_queue.len() >= self.queue_capacity {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -672,7 +676,6 @@ bitflags! {
|
||||||
const EXCL_UNLINK = 1 << 26; // Exclude events on unlinked objects
|
const EXCL_UNLINK = 1 << 26; // Exclude events on unlinked objects
|
||||||
const MASK_CREATE = 1 << 28; // Only create watches
|
const MASK_CREATE = 1 << 28; // Only create watches
|
||||||
const MASK_ADD = 1 << 29; // Add to existing watch mask
|
const MASK_ADD = 1 << 29; // Add to existing watch mask
|
||||||
const ISDIR = 1 << 30; // Event occurred on a directory
|
|
||||||
const ONESHOT = 1 << 31; // Send event once
|
const ONESHOT = 1 << 31; // Send event once
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue