mount: rename mount_state_active() → MOUNT_STATE_WITH_PROCESS()

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
This commit is contained in:
Lennart Poettering
2017-09-26 16:17:22 +02:00
parent 22af0e5873
commit c634f3d2fc
+14 -14
View File
@@ -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)