mirror of
https://github.com/troglobit/finit.git
synced 2026-11-09 16:21:24 +00:00
plugins: sys: watch uevent to prevent feedback loop
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
This commit is contained in:
1 parent
c27f3603e6
commit
2018c82ea1
1 file changed
+12
-3
+12
-3
@@ -50,10 +50,19 @@ static void sys_cond(int set)
|
|||||||
cond_clear(cond);
|
cond_clear(cond);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int check_online(char *path)
|
static int check_online(char *ac)
|
||||||
{
|
{
|
||||||
|
char path[strlen(ac) + 1];
|
||||||
|
char *ptr;
|
||||||
int val;
|
int val;
|
||||||
|
|
||||||
|
strlcpy(path, ac, sizeof(path));
|
||||||
|
ptr = strrchr(path, '/');
|
||||||
|
if (!ptr)
|
||||||
|
return 0;
|
||||||
|
ptr[1] = 0;
|
||||||
|
strlcat(path, "online", sizeof(path));
|
||||||
|
|
||||||
if (fngetint(path, &val))
|
if (fngetint(path, &val))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
@@ -172,11 +181,11 @@ static void sys_init(void *arg)
|
|||||||
if (is_ac(path, sizeof(path))) {
|
if (is_ac(path, sizeof(path))) {
|
||||||
num_ac++;
|
num_ac++;
|
||||||
|
|
||||||
snprintf(path, sizeof(path), "%s/%s/online", _PATH_SYSFS_PWR, nm);
|
snprintf(path, sizeof(path), "%s/%s/uevent", _PATH_SYSFS_PWR, nm);
|
||||||
if (check_online(path))
|
if (check_online(path))
|
||||||
num_ac_online++;
|
num_ac_online++;
|
||||||
|
|
||||||
if (iwatch_add(&iw_sys, path, 0))
|
if (iwatch_add(&iw_sys, path, IN_CLOSE_NOWRITE))
|
||||||
_pe("Failed setting up pwr monitor for %s", path);
|
_pe("Failed setting up pwr monitor for %s", path);
|
||||||
}
|
}
|
||||||
free(d[i]);
|
free(d[i]);
|
||||||
|
|||||||
Reference in new issue
Block a user