]> git.proxmox.com Git - systemd.git/blob - src/login/logind-inhibit.h
Enable seccomp support on powerpc, ppc64el, and s390x
[systemd.git] / src / login / logind-inhibit.h
1 /*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
2
3 #pragma once
4
5 /***
6 This file is part of systemd.
7
8 Copyright 2012 Lennart Poettering
9
10 systemd is free software; you can redistribute it and/or modify it
11 under the terms of the GNU Lesser General Public License as published by
12 the Free Software Foundation; either version 2.1 of the License, or
13 (at your option) any later version.
14
15 systemd is distributed in the hope that it will be useful, but
16 WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 Lesser General Public License for more details.
19
20 You should have received a copy of the GNU Lesser General Public License
21 along with systemd; If not, see <http://www.gnu.org/licenses/>.
22 ***/
23
24 typedef struct Inhibitor Inhibitor;
25
26
27 typedef enum InhibitWhat {
28 INHIBIT_SHUTDOWN = 1,
29 INHIBIT_SLEEP = 2,
30 INHIBIT_IDLE = 4,
31 INHIBIT_HANDLE_POWER_KEY = 8,
32 INHIBIT_HANDLE_SUSPEND_KEY = 16,
33 INHIBIT_HANDLE_HIBERNATE_KEY = 32,
34 INHIBIT_HANDLE_LID_SWITCH = 64,
35 _INHIBIT_WHAT_MAX = 128,
36 _INHIBIT_WHAT_INVALID = -1
37 } InhibitWhat;
38
39 typedef enum InhibitMode {
40 INHIBIT_BLOCK,
41 INHIBIT_DELAY,
42 _INHIBIT_MODE_MAX,
43 _INHIBIT_MODE_INVALID = -1
44 } InhibitMode;
45
46 #include "logind.h"
47
48 struct Inhibitor {
49 Manager *manager;
50
51 sd_event_source *event_source;
52
53 char *id;
54 char *state_file;
55
56 bool started;
57
58 InhibitWhat what;
59 char *who;
60 char *why;
61 InhibitMode mode;
62
63 pid_t pid;
64 uid_t uid;
65
66 dual_timestamp since;
67
68 char *fifo_path;
69 int fifo_fd;
70 };
71
72 Inhibitor* inhibitor_new(Manager *m, const char *id);
73 void inhibitor_free(Inhibitor *i);
74
75 int inhibitor_save(Inhibitor *i);
76 int inhibitor_load(Inhibitor *i);
77
78 int inhibitor_start(Inhibitor *i);
79 int inhibitor_stop(Inhibitor *i);
80
81 int inhibitor_create_fifo(Inhibitor *i);
82 void inhibitor_remove_fifo(Inhibitor *i);
83
84 InhibitWhat manager_inhibit_what(Manager *m, InhibitMode mm);
85 bool manager_is_inhibited(Manager *m, InhibitWhat w, InhibitMode mm, dual_timestamp *since, bool ignore_inactive, bool ignore_uid, uid_t uid, Inhibitor **offending);
86
87 const char *inhibit_what_to_string(InhibitWhat k);
88 InhibitWhat inhibit_what_from_string(const char *s);
89
90 const char *inhibit_mode_to_string(InhibitMode k);
91 InhibitMode inhibit_mode_from_string(const char *s);