goto failed;
}
- /* rc: 1 event accepted; 0 ignored; <0 error */
+ /* rc: <0 error; 0 accepted; 1 nothing */
rc = me->opers->op_process_event(mn, me);
if (rc < 0)
goto failed;
- if (rc == 1)
+ if (rc == 0)
break;
/* TODO" recalculate timeout */
} while (1);
return rc;
}
+/* Returns: <0 error; 0 success; 1 nothing */
static int kernel_process_event(struct libmnt_monitor *mn,
struct monitor_entry *me)
{
- int status = 1;
-
if (!mn || !me || me->fd < 0)
- return 0;
+ return -EINVAL;
if (mn->kernel_veiled && access(MNT_PATH_UTAB ".act", F_OK) == 0) {
- status = 0;
DBG(MONITOR, ul_debugobj(mn, "kernel event veiled"));
+ return 1;
}
- return status;
+ return 0;
}
/*
DBG(MONITOR, ul_debug(" added inotify watch for %s [fd=%d]", filename, wd));
rc = 0;
if (final)
- *final = 1;
+ *final = 0; /* success */
if (fd)
*fd = wd;
goto done;
/*
* verify and drain inotify buffer
+ *
+ * Returns: <0 error; 0 success; 1 nothing
*/
static int userspace_process_event(struct libmnt_monitor *mn,
struct monitor_entry *me)
{
char buf[sizeof(struct inotify_event) + NAME_MAX + 1];
- int status = 0;
+ int status = 1; /* nothing by default */
if (!me || me->fd < 0)
- return 0;
+ return -EINVAL;
DBG(MONITOR, ul_debugobj(mn, "process utab event"));
DBG(MONITOR, ul_debugobj(mn, " inotify event 0x%x [%s]\n", e->mask, e->len ? e->name : ""));
if (e->mask & IN_CLOSE_WRITE)
- status = 1;
+ status = 0;
else {
/* add watch for the event file */
userspace_add_watch(me, &status, &fd);
}
} while (1);
- DBG(MONITOR, ul_debugobj(mn, "%s", status == 1 ? " success" : " nothing"));
+ DBG(MONITOR, ul_debugobj(mn, "%s", status < 0 ? " failed" :
+ status == 0 ? " success" : " nothing"));
return status;
}