From c634f3d2fc0f9f682af69e2d38b07847e5bd4f14 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Mon, 25 Sep 2017 19:25:50 +0200 Subject: [PATCH] =?utf8?q?mount:=20rename=20mount=5Fstate=5Factive()=20?= =?utf8?q?=E2=86=92=20MOUNT=5FSTATE=5FWITH=5FPROCESS()?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit The function returns true for all states that have a control process running, and each time we call it that's what we want to know, hence let's rename it accordingly. Moreover, the more generic unit states have an ACTIVE state, and it is defined quite differently from the set of states this function returns true for, hence let's avoid confusion and not reuse the word "ACTIVE" here in a different context. Finally, let's uppercase this, since in most ways it's pretty much identical to a macro --- src/core/mount.c | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/src/core/mount.c b/src/core/mount.c index 949d14e55c9..22b3608a2f7 100644 --- a/src/core/mount.c +++ b/src/core/mount.c @@ -68,6 +68,18 @@ static const UnitActiveState state_translation_table[_MOUNT_STATE_MAX] = { static int mount_dispatch_timer(sd_event_source *source, usec_t usec, void *userdata); static int mount_dispatch_io(sd_event_source *source, int fd, uint32_t revents, void *userdata); +static bool MOUNT_STATE_WITH_PROCESS(MountState state) { + return IN_SET(state, + MOUNT_MOUNTING, + MOUNT_MOUNTING_DONE, + MOUNT_REMOUNTING, + MOUNT_REMOUNTING_SIGTERM, + MOUNT_REMOUNTING_SIGKILL, + MOUNT_UNMOUNTING, + MOUNT_UNMOUNTING_SIGTERM, + MOUNT_UNMOUNTING_SIGKILL); +} + static bool mount_needs_network(const char *options, const char *fstype) { if (fstab_test_option(options, "_netdev\0")) return true; @@ -119,18 +131,6 @@ static bool mount_is_automount(const MountParameters *p) { "x-systemd.automount\0"); } -static bool mount_state_active(MountState state) { - return IN_SET(state, - MOUNT_MOUNTING, - MOUNT_MOUNTING_DONE, - MOUNT_REMOUNTING, - MOUNT_REMOUNTING_SIGTERM, - MOUNT_REMOUNTING_SIGKILL, - MOUNT_UNMOUNTING, - MOUNT_UNMOUNTING_SIGTERM, - MOUNT_UNMOUNTING_SIGKILL); -} - static bool mount_is_bound_to_device(const Mount *m) { const MountParameters *p; @@ -638,7 +638,7 @@ static void mount_set_state(Mount *m, MountState state) { old_state = m->state; m->state = state; - if (!mount_state_active(state)) { + if (!MOUNT_STATE_WITH_PROCESS(state)) { m->timer_event_source = sd_event_source_unref(m->timer_event_source); mount_unwatch_control_pid(m); m->control_command = NULL; @@ -669,7 +669,7 @@ static int mount_coldplug(Unit *u) { if (m->control_pid > 0 && pid_is_unwaited(m->control_pid) && - mount_state_active(new_state)) { + MOUNT_STATE_WITH_PROCESS(new_state)) { r = unit_watch_pid(UNIT(m), m->control_pid); if (r < 0) -- 2.39.2