diff options
| author | Karel Zak <kzak@redhat.com> | 2025-06-10 12:15:28 +0200 |
|---|---|---|
| committer | Karel Zak <kzak@redhat.com> | 2025-08-06 14:52:59 +0200 |
| commit | 89c310c9f4ce1f1d37eca489c0fb467cacbb01ff (patch) | |
| tree | 1d20345b2749864d66f55aa94425c93eb9b096ac /libmount/src | |
| parent | dbd9c5143f2a75cde1d8eb5ccb66412fb89ac64e (diff) | |
| download | util-linux-89c310c9f4ce1f1d37eca489c0fb467cacbb01ff.tar.gz | |
libmount: (monitor) cleanup op_process_event() return codes
Let's use usual concept (<0 error; 0 success; 1 nothing).
Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'libmount/src')
| -rw-r--r-- | libmount/src/monitor.c | 4 | ||||
| -rw-r--r-- | libmount/src/monitor_mountinfo.c | 9 | ||||
| -rw-r--r-- | libmount/src/monitor_utab.c | 13 |
3 files changed, 14 insertions, 12 deletions
diff --git a/libmount/src/monitor.c b/libmount/src/monitor.c index f625dafb6a..6bede6b58f 100644 --- a/libmount/src/monitor.c +++ b/libmount/src/monitor.c @@ -339,11 +339,11 @@ static int read_epoll_events(struct libmnt_monitor *mn, int timeout, struct moni 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); diff --git a/libmount/src/monitor_mountinfo.c b/libmount/src/monitor_mountinfo.c index 0c05051b06..44f0ea46ac 100644 --- a/libmount/src/monitor_mountinfo.c +++ b/libmount/src/monitor_mountinfo.c @@ -54,19 +54,18 @@ err: 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; } /* diff --git a/libmount/src/monitor_utab.c b/libmount/src/monitor_utab.c index 4cc1b3acb4..1b5815b4d6 100644 --- a/libmount/src/monitor_utab.c +++ b/libmount/src/monitor_utab.c @@ -56,7 +56,7 @@ static int userspace_add_watch(struct monitor_entry *me, int *final, int *fd) 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; @@ -123,15 +123,17 @@ err: /* * 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")); @@ -154,7 +156,7 @@ static int userspace_process_event(struct libmnt_monitor *mn, 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); @@ -167,7 +169,8 @@ static int userspace_process_event(struct libmnt_monitor *mn, } } 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; } |
