#include "util.h"
#include "mkdir.h"
-
+#include "path-util.h"
#include "logind-inhibit.h"
Inhibitor* inhibitor_new(Manager *m, const char* id) {
return NULL;
}
- i->id = file_name_from_path(i->state_file);
+ i->id = path_get_file_name(i->state_file);
if (hashmap_put(m->inhibitors, i->id, i) < 0) {
free(i->state_file);
assert(i);
- r = safe_mkdir("/run/systemd/inhibit", 0755, 0, 0);
+ r = mkdir_safe_label("/run/systemd/inhibit", 0755, 0, 0);
if (r < 0)
goto finish;
i->started = true;
- manager_send_changed(i->manager, "Inhibited\0");
+ manager_send_changed(i->manager, i->mode == INHIBIT_BLOCK ? "BlockInhibited\0" : "DelayInhibited\0");
return 0;
}
i->started = false;
- manager_send_changed(i->manager, "Inhibited\0");
+ manager_send_changed(i->manager, i->mode == INHIBIT_BLOCK ? "BlockInhibited\0" : "DelayInhibited\0");
return 0;
}
/* Create FIFO */
if (!i->fifo_path) {
- r = safe_mkdir("/run/systemd/inhibit", 0755, 0, 0);
+ r = mkdir_safe_label("/run/systemd/inhibit", 0755, 0, 0);
if (r < 0)
return r;
zero(ev);
ev.events = 0;
- ev.data.u32 = FD_FIFO_BASE + i->fifo_fd;
+ ev.data.u32 = FD_OTHER_BASE + i->fifo_fd;
if (epoll_ctl(i->manager->epoll_fd, EPOLL_CTL_ADD, i->fifo_fd, &ev) < 0)
return -errno;
static const char* const table[_INHIBIT_WHAT_MAX] = {
[0] = "",
[INHIBIT_SHUTDOWN] = "shutdown",
- [INHIBIT_SUSPEND] = "suspend",
+ [INHIBIT_SLEEP] = "sleep",
[INHIBIT_IDLE] = "idle",
- [INHIBIT_SHUTDOWN|INHIBIT_SUSPEND] = "shutdown:suspend",
+ [INHIBIT_SHUTDOWN|INHIBIT_SLEEP] = "shutdown:sleep",
[INHIBIT_SHUTDOWN|INHIBIT_IDLE] = "shutdown:idle",
- [INHIBIT_SHUTDOWN|INHIBIT_SUSPEND|INHIBIT_IDLE] = "shutdown:suspend:idle",
- [INHIBIT_SUSPEND|INHIBIT_IDLE] = "suspend:idle"
+ [INHIBIT_SHUTDOWN|INHIBIT_SLEEP|INHIBIT_IDLE] = "shutdown:sleep:idle",
+ [INHIBIT_SLEEP|INHIBIT_IDLE] = "sleep:idle"
};
if (w < 0 || w >= _INHIBIT_WHAT_MAX)
FOREACH_WORD_SEPARATOR(w, l, s, ":", state) {
if (l == 8 && strncmp(w, "shutdown", l) == 0)
what |= INHIBIT_SHUTDOWN;
- else if (l == 7 && strncmp(w, "suspend", l) == 0)
- what |= INHIBIT_SUSPEND;
+ else if (l == 5 && strncmp(w, "sleep", l) == 0)
+ what |= INHIBIT_SLEEP;
else if (l == 4 && strncmp(w, "idle", l) == 0)
what |= INHIBIT_IDLE;
else