* (as returned by mnt_monitor_next_change()). If the event does not provide
* details, it returns -ENOTSUP.
*
+ * If the fanotify event queue has overflowed (events were lost due to
+ * sustained mount churn), this function returns -EOVERFLOW. In this case,
+ * the remaining buffered events are discarded and the caller should
+ * perform a full rescan to recover a consistent mount state.
+ *
* <informalexample>
* <programlisting>
* while (mnt_monitor_next_change(mn, NULL, &type) == 0) {
* if (type == MNT_MONITOR_TYPE_FANOTIFY) {
- * while (mnt_monitor_event_next_fs(mn, fs) == 0) {
+ * int rc;
+ * while ((rc = mnt_monitor_event_next_fs(mn, fs)) == 0) {
* printf("ID=%ju\n", mnt_fs_get_uniq_id(fs));
* }
+ * if (rc == -EOVERFLOW)
+ * full_rescan();
* }
* }
* </programlisting>
* </informalexample>
*
- * Returns: 0 on success, 1 no more data, <0 on error
+ * Returns: 0 on success, 1 no more data, -EOVERFLOW on queue overflow, <0 on error
*
* Since: 2.42
*/
meta->vers != FANOTIFY_METADATA_VERSION)
goto nothing;
+ if (meta->mask & FAN_Q_OVERFLOW) {
+ DBG_OBJ(MONITOR, mn, ul_debug("fanotify queue overflow"));
+ data->remaining = 0;
+ return -EOVERFLOW;
+ }
+
thislen = meta->event_len - sizeof(*meta);
mnt = (struct fanotify_event_info_mnt *)