Take down condition subsystem at shutdown/reboot

Leave the system as it was when we found it.  Also, we'll build things
on top of cond_is_available() to handle pre bootstrap and pre shutdown
tasks.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
This commit is contained in:
Joachim Wiberg committed 2022-11-07 06:44:21 +01:00
1 parent 585ac51f45
commit 5f74adad06
3 files changed
+20

No files matched your search

+14
View File
@@ -410,6 +410,15 @@ void cond_deassert(const char *pat)
nftw(cond_path(pat), deassert, 20, FTW_DEPTH);
}
/*
* Check if we have bootstrapped enough of the system to use conditions.
* Will answer 'No' before bootstrap done *and* at shutdown/reboot.
*/
int cond_is_available(void)
{
return fisdir(_PATH_COND);
}
void cond_init(void)
{
char path[MAX_ARG_LEN];
@@ -423,6 +432,11 @@ void cond_init(void)
cond_boot_strap();
}
void cond_exit(void)
{
cond_delpath(_PATH_COND);
}
/**
* Local Variables:
* indent-tabs-mode: t
+3
View File
@@ -46,7 +46,10 @@ int cond_clear_noupdate(const char *name);
void cond_reassert (const char *pat);
void cond_deassert (const char *pat);
int cond_is_available(void);
void cond_init (void);
void cond_exit (void);
#endif /* FINIT_COND_H_ */
+3
View File
@@ -322,6 +322,9 @@ void do_shutdown(shutop_t op)
plugin_exit();
api_exit();
/* We can no longer act on conditions, activate script runner */
cond_exit();
/* Reap 'em */
while (waitpid(-1, NULL, WNOHANG) > 0)
;