summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRafał Miłecki <rafal@milecki.pl>2018-12-09 17:52:10 +0100
committerRafał Miłecki <rafal@milecki.pl>2018-12-12 14:02:38 +0100
commitc8c7ca567a4c14755ffc9014ee8e527af996a0ce (patch)
tree42aef47415112018440f8a2988f4a955d99d32ef
parentf1bb762f0245fcbfa6555fd90e71de61480c301c (diff)
downloadfstools-c8c7ca567a4c14755ffc9014ee8e527af996a0ce.tar.gz
block: cleanup handling "start" action of the "autofs" command
When blockd starts it uses "start" action for getting current state of block devices. The way main_autofs() was implemented was a bit hacky though: 1) It was calling mount_device() with TYPE_HOTPLUG First of all that made code harder to understand. Faking TYPE_HOTPLUG for a TYPE_AUTOFS made following mount_device() logic more complex. Secondly the only reason for that seems to be to trigger "swap" and extroot checks in the mount_device(). Other than that it was only about calling blockd_notify() anyway. 2) It wasn't consistent Consider a "swap" or extroot without an "autofs" set (a pretty expected case). a) During original TYPE_HOTPLUG event mount_device() would detect both cases early and return without calling blockd_notify(). b) With previous main_autofs() implementation blockd_notify() was called for both cases. With this change main_autofs() doesn't fake TYPE_HOTPLUG and it follows mount_device() logic which should result in an expected & consistent state of devices in blockd. Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
-rw-r--r--block.c14
1 files changed, 9 insertions, 5 deletions
diff --git a/block.c b/block.c
index 3d06185..091375f 100644
--- a/block.c
+++ b/block.c
@@ -1186,12 +1186,16 @@ static int main_autofs(int argc, char **argv)
cache_load(0);
list_for_each_entry(pr, &devices, list) {
- struct mount *m = find_block(pr->uuid, pr->label, NULL, NULL);
+ struct mount *m;
- if (m && m->autofs)
- mount_device(pr, TYPE_HOTPLUG);
- else
- blockd_notify(pr->dev, m, pr);
+ if (!strcmp(pr->type, "swap"))
+ continue;
+
+ m = find_block(pr->uuid, pr->label, NULL, NULL);
+ if (m && m->extroot)
+ continue;
+
+ blockd_notify(pr->dev, m, pr);
}
return 0;
}