cond.c: Normalize COND_PATH, some systems have /run not /var/run

On most modern Linux systems /run is a tmpfs that replaces /var/run.
The latter is set up as a symlink to /run by the bootmisc.so plugin.

However, Finit conditions rely on the /var/run/finit/cond prefix, which
does not exist until bootmisc.so has run, which is *after* `mount -a`
has run.  Therefore, to have working conditions before we run `mount -a`
we must normalize the path constructed by cond_path() to use either the
/run or /var/run (default) prefix.

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
This commit is contained in:
Joachim Nilsson
2018-01-18 14:44:25 +01:00
parent a61551d15f
commit fd7a6c5020
+4 -2
View File
@@ -26,6 +26,7 @@
#include "finit.h"
#include "cond.h"
#include "pid.h"
#include "service.h"
@@ -42,11 +43,12 @@ const char *condstr(enum cond_state s)
const char *cond_path(const char *name)
{
char tmp[MAX_ARG_LEN];
static char file[MAX_ARG_LEN];
snprintf(file, sizeof(file), COND_PATH "/%s", name);
snprintf(tmp, sizeof(tmp), COND_PATH "/%s", name);
return file;
return pid_runpath(tmp, file, sizeof(file));
}
unsigned int cond_get_gen(const char *path)