From: Karel Zak Date: Tue, 10 Jun 2025 12:06:53 +0000 (+0200) Subject: libmount: (monitor) check for utab delete X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=d92f1366c838fd8e4f7508a4431138384dbff259;p=thirdparty%2Futil-linux.git libmount: (monitor) check for utab delete Also, monitor for "rm -rf /run/mount" to reinitialize the monitor. Signed-off-by: Karel Zak --- diff --git a/libmount/src/monitor_utab.c b/libmount/src/monitor_utab.c index f0e90c204..24b7b5450 100644 --- a/libmount/src/monitor_utab.c +++ b/libmount/src/monitor_utab.c @@ -94,7 +94,7 @@ static int userspace_add_watch(struct monitor_entry *me, int *final, int *fd) /* try event file if already exists */ errno = 0; - wd = inotify_add_watch(me->fd, filename, IN_CLOSE_WRITE); + wd = inotify_add_watch(me->fd, filename, IN_CLOSE_WRITE | IN_DELETE_SELF); if (wd >= 0) { DBG(MONITOR, ul_debug(" added inotify watch for %s [fd=%d]", filename, wd)); rc = 0; @@ -126,7 +126,7 @@ static int userspace_add_watch(struct monitor_entry *me, int *final, int *fd) break; /* already exist */ } errno = 0; - wd = inotify_add_watch(me->fd, filename, IN_CREATE|IN_ISDIR); + wd = inotify_add_watch(me->fd, filename, IN_CREATE|IN_ISDIR|IN_DELETE_SELF); if (wd >= 0) { DBG(MONITOR, ul_debug(" added inotify watch for %s [fd=%d]", filename, wd)); rc = 0; @@ -216,6 +216,11 @@ static int userspace_process_event(struct libmnt_monitor *mn, if (e->mask & IN_CLOSE_WRITE) status = 0; else { + if (e->mask & IN_DELETE_SELF) { + DBG(MONITOR, ul_debugobj(mn, " reseting watch")); + userspace_free_data(me); + } + /* add watch for the event file */ userspace_add_watch(me, &status, &fd);