]>
Commit | Line | Data |
---|---|---|
db9ecf05 | 1 | /* SPDX-License-Identifier: LGPL-2.1-or-later */ |
f8e2fb7b LP |
2 | |
3 | #include <errno.h> | |
4 | #include <fcntl.h> | |
ca78ad1d ZJS |
5 | #include <sys/stat.h> |
6 | #include <sys/types.h> | |
f8e2fb7b LP |
7 | #include <unistd.h> |
8 | ||
b5efdb8a | 9 | #include "alloc-util.h" |
686d13b9 | 10 | #include "env-file.h" |
46ed9f4c | 11 | #include "errno-list.h" |
7c248223 | 12 | #include "errno-util.h" |
4f5dd394 | 13 | #include "escape.h" |
3ffd4af2 | 14 | #include "fd-util.h" |
a5c32cff | 15 | #include "fileio.h" |
f97b34a6 | 16 | #include "format-util.h" |
11eae36d | 17 | #include "io-util.h" |
6ecda0fb | 18 | #include "logind-dbus.h" |
3ffd4af2 | 19 | #include "logind-inhibit.h" |
4f5dd394 | 20 | #include "mkdir.h" |
6bedfcbb | 21 | #include "parse-util.h" |
b910cc72 | 22 | #include "path-util.h" |
8b43440b | 23 | #include "string-table.h" |
07630cea | 24 | #include "string-util.h" |
e4de7287 | 25 | #include "tmpfile-util.h" |
b1d4f8e1 | 26 | #include "user-util.h" |
4f5dd394 | 27 | #include "util.h" |
f8e2fb7b | 28 | |
290320ef LP |
29 | static void inhibitor_remove_fifo(Inhibitor *i); |
30 | ||
81280b2a LP |
31 | int inhibitor_new(Inhibitor **ret, Manager *m, const char* id) { |
32 | _cleanup_(inhibitor_freep) Inhibitor *i = NULL; | |
33 | int r; | |
f8e2fb7b | 34 | |
81280b2a | 35 | assert(ret); |
f8e2fb7b | 36 | assert(m); |
81280b2a | 37 | assert(id); |
f8e2fb7b | 38 | |
81280b2a | 39 | i = new(Inhibitor, 1); |
f8e2fb7b | 40 | if (!i) |
81280b2a LP |
41 | return -ENOMEM; |
42 | ||
43 | *i = (Inhibitor) { | |
44 | .manager = m, | |
45 | .what = _INHIBIT_WHAT_INVALID, | |
46 | .mode = _INHIBIT_MODE_INVALID, | |
47 | .uid = UID_INVALID, | |
48 | .fifo_fd = -1, | |
49 | }; | |
f8e2fb7b | 50 | |
b910cc72 | 51 | i->state_file = path_join("/run/systemd/inhibit", id); |
6b430fdb | 52 | if (!i->state_file) |
81280b2a | 53 | return -ENOMEM; |
f8e2fb7b | 54 | |
2b6bf07d | 55 | i->id = basename(i->state_file); |
f8e2fb7b | 56 | |
81280b2a LP |
57 | r = hashmap_put(m->inhibitors, i->id, i); |
58 | if (r < 0) | |
59 | return r; | |
f8e2fb7b | 60 | |
81280b2a LP |
61 | *ret = TAKE_PTR(i); |
62 | return 0; | |
f8e2fb7b LP |
63 | } |
64 | ||
81280b2a | 65 | Inhibitor* inhibitor_free(Inhibitor *i) { |
cc377381 | 66 | |
81280b2a LP |
67 | if (!i) |
68 | return NULL; | |
f8e2fb7b | 69 | |
cc377381 LP |
70 | free(i->who); |
71 | free(i->why); | |
72 | ||
81280b2a LP |
73 | sd_event_source_unref(i->event_source); |
74 | safe_close(i->fifo_fd); | |
f8e2fb7b | 75 | |
09172930 YW |
76 | hashmap_remove(i->manager->inhibitors, i->id); |
77 | ||
81280b2a LP |
78 | /* Note that we don't remove neither the state file nor the fifo path here, since we want both to |
79 | * survive daemon restarts */ | |
80 | free(i->state_file); | |
81 | free(i->fifo_path); | |
82 | ||
81280b2a | 83 | return mfree(i); |
f8e2fb7b LP |
84 | } |
85 | ||
290320ef | 86 | static int inhibitor_save(Inhibitor *i) { |
cc377381 LP |
87 | _cleanup_free_ char *temp_path = NULL; |
88 | _cleanup_fclose_ FILE *f = NULL; | |
f8e2fb7b | 89 | int r; |
f8e2fb7b LP |
90 | |
91 | assert(i); | |
92 | ||
37c1d5e9 | 93 | r = mkdir_safe_label("/run/systemd/inhibit", 0755, 0, 0, MKDIR_WARN_MODE); |
f8e2fb7b | 94 | if (r < 0) |
dacd6cee | 95 | goto fail; |
f8e2fb7b LP |
96 | |
97 | r = fopen_temporary(i->state_file, &f, &temp_path); | |
98 | if (r < 0) | |
dacd6cee | 99 | goto fail; |
f8e2fb7b | 100 | |
07530d70 | 101 | (void) fchmod(fileno(f), 0644); |
f8e2fb7b LP |
102 | |
103 | fprintf(f, | |
104 | "# This is private data. Do not parse.\n" | |
105 | "WHAT=%s\n" | |
eecd1362 | 106 | "MODE=%s\n" |
90b2de37 ZJS |
107 | "UID="UID_FMT"\n" |
108 | "PID="PID_FMT"\n", | |
f8e2fb7b | 109 | inhibit_what_to_string(i->what), |
eecd1362 | 110 | inhibit_mode_to_string(i->mode), |
90b2de37 ZJS |
111 | i->uid, |
112 | i->pid); | |
f8e2fb7b LP |
113 | |
114 | if (i->who) { | |
cc377381 LP |
115 | _cleanup_free_ char *cc = NULL; |
116 | ||
f8e2fb7b | 117 | cc = cescape(i->who); |
88231eb6 | 118 | if (!cc) { |
f8e2fb7b | 119 | r = -ENOMEM; |
88231eb6 TA |
120 | goto fail; |
121 | } | |
122 | ||
123 | fprintf(f, "WHO=%s\n", cc); | |
f8e2fb7b LP |
124 | } |
125 | ||
126 | if (i->why) { | |
cc377381 LP |
127 | _cleanup_free_ char *cc = NULL; |
128 | ||
f8e2fb7b | 129 | cc = cescape(i->why); |
88231eb6 | 130 | if (!cc) { |
f8e2fb7b | 131 | r = -ENOMEM; |
88231eb6 TA |
132 | goto fail; |
133 | } | |
134 | ||
135 | fprintf(f, "WHY=%s\n", cc); | |
f8e2fb7b LP |
136 | } |
137 | ||
138 | if (i->fifo_path) | |
139 | fprintf(f, "FIFO=%s\n", i->fifo_path); | |
140 | ||
dacd6cee LP |
141 | r = fflush_and_check(f); |
142 | if (r < 0) | |
143 | goto fail; | |
f8e2fb7b | 144 | |
dacd6cee | 145 | if (rename(temp_path, i->state_file) < 0) { |
f8e2fb7b | 146 | r = -errno; |
dacd6cee | 147 | goto fail; |
f8e2fb7b LP |
148 | } |
149 | ||
dacd6cee LP |
150 | return 0; |
151 | ||
152 | fail: | |
153 | (void) unlink(i->state_file); | |
154 | ||
155 | if (temp_path) | |
156 | (void) unlink(temp_path); | |
f8e2fb7b | 157 | |
dacd6cee | 158 | return log_error_errno(r, "Failed to save inhibit data %s: %m", i->state_file); |
f8e2fb7b LP |
159 | } |
160 | ||
fa39c2de LP |
161 | static int bus_manager_send_inhibited_change(Inhibitor *i) { |
162 | const char *property; | |
163 | ||
164 | assert(i); | |
165 | ||
166 | property = i->mode == INHIBIT_BLOCK ? "BlockInhibited" : "DelayInhibited"; | |
167 | ||
168 | return manager_send_changed(i->manager, property, NULL); | |
169 | } | |
170 | ||
f8e2fb7b LP |
171 | int inhibitor_start(Inhibitor *i) { |
172 | assert(i); | |
173 | ||
174 | if (i->started) | |
175 | return 0; | |
176 | ||
c7b5eb98 LP |
177 | dual_timestamp_get(&i->since); |
178 | ||
de0671ee | 179 | log_debug("Inhibitor %s (%s) pid="PID_FMT" uid="UID_FMT" mode=%s started.", |
f8e2fb7b | 180 | strna(i->who), strna(i->why), |
de0671ee | 181 | i->pid, i->uid, |
eecd1362 | 182 | inhibit_mode_to_string(i->mode)); |
f8e2fb7b | 183 | |
f8e2fb7b LP |
184 | i->started = true; |
185 | ||
fa39c2de LP |
186 | inhibitor_save(i); |
187 | ||
188 | bus_manager_send_inhibited_change(i); | |
f8e2fb7b LP |
189 | |
190 | return 0; | |
191 | } | |
192 | ||
290320ef | 193 | void inhibitor_stop(Inhibitor *i) { |
f8e2fb7b LP |
194 | assert(i); |
195 | ||
196 | if (i->started) | |
de0671ee | 197 | log_debug("Inhibitor %s (%s) pid="PID_FMT" uid="UID_FMT" mode=%s stopped.", |
f8e2fb7b | 198 | strna(i->who), strna(i->why), |
de0671ee | 199 | i->pid, i->uid, |
eecd1362 | 200 | inhibit_mode_to_string(i->mode)); |
f8e2fb7b | 201 | |
81280b2a LP |
202 | inhibitor_remove_fifo(i); |
203 | ||
f8e2fb7b | 204 | if (i->state_file) |
6990fb6b | 205 | (void) unlink(i->state_file); |
f8e2fb7b LP |
206 | |
207 | i->started = false; | |
208 | ||
fa39c2de | 209 | bus_manager_send_inhibited_change(i); |
f8e2fb7b LP |
210 | } |
211 | ||
212 | int inhibitor_load(Inhibitor *i) { | |
e437538f | 213 | _cleanup_free_ char *what = NULL, *uid = NULL, *pid = NULL, *who = NULL, *why = NULL, *mode = NULL; |
cc377381 LP |
214 | InhibitWhat w; |
215 | InhibitMode mm; | |
216 | char *cc; | |
e437538f | 217 | ssize_t l; |
cc377381 LP |
218 | int r; |
219 | ||
aa8fbc74 | 220 | r = parse_env_file(NULL, i->state_file, |
f8e2fb7b LP |
221 | "WHAT", &what, |
222 | "UID", &uid, | |
223 | "PID", &pid, | |
224 | "WHO", &who, | |
225 | "WHY", &why, | |
eecd1362 | 226 | "MODE", &mode, |
13df9c39 | 227 | "FIFO", &i->fifo_path); |
f8e2fb7b | 228 | if (r < 0) |
11b0dd0e | 229 | return log_error_errno(r, "Failed to read %s: %m", i->state_file); |
f8e2fb7b | 230 | |
eecd1362 | 231 | w = what ? inhibit_what_from_string(what) : 0; |
f8e2fb7b LP |
232 | if (w >= 0) |
233 | i->what = w; | |
234 | ||
eecd1362 LP |
235 | mm = mode ? inhibit_mode_from_string(mode) : INHIBIT_BLOCK; |
236 | if (mm >= 0) | |
237 | i->mode = mm; | |
238 | ||
a34faf57 LN |
239 | if (uid) { |
240 | r = parse_uid(uid, &i->uid); | |
241 | if (r < 0) | |
11b0dd0e | 242 | log_debug_errno(r, "Failed to parse UID of inhibitor: %s", uid); |
a34faf57 | 243 | } |
eecd1362 | 244 | |
a34faf57 LN |
245 | if (pid) { |
246 | r = parse_pid(pid, &i->pid); | |
247 | if (r < 0) | |
11b0dd0e | 248 | log_debug_errno(r, "Failed to parse PID of inhibitor: %s", pid); |
a34faf57 | 249 | } |
f8e2fb7b LP |
250 | |
251 | if (who) { | |
e437538f ZJS |
252 | l = cunescape(who, 0, &cc); |
253 | if (l < 0) | |
254 | return log_debug_errno(l, "Failed to unescape \"who\" of inhibitor: %m"); | |
f8e2fb7b | 255 | |
09f300c4 | 256 | free_and_replace(i->who, cc); |
f8e2fb7b LP |
257 | } |
258 | ||
259 | if (why) { | |
e437538f ZJS |
260 | l = cunescape(why, 0, &cc); |
261 | if (l < 0) | |
262 | return log_debug_errno(l, "Failed to unescape \"why\" of inhibitor: %m"); | |
f8e2fb7b | 263 | |
09f300c4 | 264 | free_and_replace(i->why, cc); |
f8e2fb7b LP |
265 | } |
266 | ||
267 | if (i->fifo_path) { | |
11b0dd0e | 268 | _cleanup_close_ int fd = -1; |
f8e2fb7b | 269 | |
11b0dd0e | 270 | /* Let's re-open the FIFO on both sides, and close the writing side right away */ |
f8e2fb7b | 271 | fd = inhibitor_create_fifo(i); |
11b0dd0e LP |
272 | if (fd < 0) |
273 | return log_error_errno(fd, "Failed to reopen FIFO: %m"); | |
f8e2fb7b LP |
274 | } |
275 | ||
cc377381 LP |
276 | return 0; |
277 | } | |
f8e2fb7b | 278 | |
cc377381 LP |
279 | static int inhibitor_dispatch_fifo(sd_event_source *s, int fd, uint32_t revents, void *userdata) { |
280 | Inhibitor *i = userdata; | |
281 | ||
282 | assert(s); | |
283 | assert(fd == i->fifo_fd); | |
284 | assert(i); | |
285 | ||
286 | inhibitor_stop(i); | |
287 | inhibitor_free(i); | |
288 | ||
289 | return 0; | |
f8e2fb7b LP |
290 | } |
291 | ||
292 | int inhibitor_create_fifo(Inhibitor *i) { | |
293 | int r; | |
294 | ||
295 | assert(i); | |
296 | ||
297 | /* Create FIFO */ | |
298 | if (!i->fifo_path) { | |
37c1d5e9 | 299 | r = mkdir_safe_label("/run/systemd/inhibit", 0755, 0, 0, MKDIR_WARN_MODE); |
f8e2fb7b LP |
300 | if (r < 0) |
301 | return r; | |
302 | ||
605405c6 | 303 | i->fifo_path = strjoin("/run/systemd/inhibit/", i->id, ".ref"); |
cc377381 | 304 | if (!i->fifo_path) |
f8e2fb7b LP |
305 | return -ENOMEM; |
306 | ||
307 | if (mkfifo(i->fifo_path, 0600) < 0 && errno != EEXIST) | |
308 | return -errno; | |
309 | } | |
310 | ||
311 | /* Open reading side */ | |
312 | if (i->fifo_fd < 0) { | |
db4a47e9 | 313 | i->fifo_fd = open(i->fifo_path, O_RDONLY|O_CLOEXEC|O_NONBLOCK); |
f8e2fb7b LP |
314 | if (i->fifo_fd < 0) |
315 | return -errno; | |
cc377381 | 316 | } |
f8e2fb7b | 317 | |
cc377381 | 318 | if (!i->event_source) { |
151b9b96 | 319 | r = sd_event_add_io(i->manager->event, &i->event_source, i->fifo_fd, 0, inhibitor_dispatch_fifo, i); |
f8e2fb7b LP |
320 | if (r < 0) |
321 | return r; | |
322 | ||
e11544a8 | 323 | r = sd_event_source_set_priority(i->event_source, SD_EVENT_PRIORITY_IDLE-10); |
cc377381 LP |
324 | if (r < 0) |
325 | return r; | |
3884274b LP |
326 | |
327 | (void) sd_event_source_set_description(i->event_source, "inhibitor-ref"); | |
f8e2fb7b LP |
328 | } |
329 | ||
330 | /* Open writing side */ | |
7c248223 | 331 | return RET_NERRNO(open(i->fifo_path, O_WRONLY|O_CLOEXEC|O_NONBLOCK)); |
f8e2fb7b LP |
332 | } |
333 | ||
290320ef | 334 | static void inhibitor_remove_fifo(Inhibitor *i) { |
f8e2fb7b LP |
335 | assert(i); |
336 | ||
03e334a1 LP |
337 | i->event_source = sd_event_source_unref(i->event_source); |
338 | i->fifo_fd = safe_close(i->fifo_fd); | |
f8e2fb7b LP |
339 | |
340 | if (i->fifo_path) { | |
6990fb6b | 341 | (void) unlink(i->fifo_path); |
a1e58e8e | 342 | i->fifo_path = mfree(i->fifo_path); |
f8e2fb7b LP |
343 | } |
344 | } | |
345 | ||
11eae36d LP |
346 | bool inhibitor_is_orphan(Inhibitor *i) { |
347 | assert(i); | |
348 | ||
349 | if (!i->started) | |
350 | return true; | |
351 | ||
352 | if (!i->fifo_path) | |
353 | return true; | |
354 | ||
355 | if (i->fifo_fd < 0) | |
356 | return true; | |
357 | ||
358 | if (pipe_eof(i->fifo_fd) != 0) | |
359 | return true; | |
360 | ||
361 | return false; | |
362 | } | |
363 | ||
eecd1362 | 364 | InhibitWhat manager_inhibit_what(Manager *m, InhibitMode mm) { |
f8e2fb7b | 365 | Inhibitor *i; |
f8e2fb7b LP |
366 | InhibitWhat what = 0; |
367 | ||
368 | assert(m); | |
369 | ||
90e74a66 | 370 | HASHMAP_FOREACH(i, m->inhibitors) |
5e8273ac | 371 | if (i->mode == mm && i->started) |
eecd1362 | 372 | what |= i->what; |
f8e2fb7b LP |
373 | |
374 | return what; | |
375 | } | |
376 | ||
beaafb2e LP |
377 | static int pid_is_active(Manager *m, pid_t pid) { |
378 | Session *s; | |
379 | int r; | |
380 | ||
7b33c622 AJ |
381 | /* Get client session. This is not what you are looking for these days. |
382 | * FIXME #6852 */ | |
beaafb2e | 383 | r = manager_get_session_by_pid(m, pid, &s); |
2c4f86c1 | 384 | if (r < 0) |
beaafb2e LP |
385 | return r; |
386 | ||
2c4f86c1 LP |
387 | /* If there's no session assigned to it, then it's globally |
388 | * active on all ttys */ | |
389 | if (r == 0) | |
390 | return 1; | |
391 | ||
beaafb2e LP |
392 | return session_is_active(s); |
393 | } | |
394 | ||
395 | bool manager_is_inhibited( | |
396 | Manager *m, | |
397 | InhibitWhat w, | |
398 | InhibitMode mm, | |
399 | dual_timestamp *since, | |
409133be LP |
400 | bool ignore_inactive, |
401 | bool ignore_uid, | |
85a428c6 LP |
402 | uid_t uid, |
403 | Inhibitor **offending) { | |
beaafb2e | 404 | |
c7b5eb98 | 405 | Inhibitor *i; |
5cb14b37 | 406 | struct dual_timestamp ts = DUAL_TIMESTAMP_NULL; |
c7b5eb98 LP |
407 | bool inhibited = false; |
408 | ||
409 | assert(m); | |
410 | assert(w > 0 && w < _INHIBIT_WHAT_MAX); | |
411 | ||
90e74a66 | 412 | HASHMAP_FOREACH(i, m->inhibitors) { |
5e8273ac AF |
413 | if (!i->started) |
414 | continue; | |
415 | ||
c7b5eb98 LP |
416 | if (!(i->what & w)) |
417 | continue; | |
418 | ||
eecd1362 LP |
419 | if (i->mode != mm) |
420 | continue; | |
421 | ||
409133be LP |
422 | if (ignore_inactive && pid_is_active(m, i->pid) <= 0) |
423 | continue; | |
424 | ||
425 | if (ignore_uid && i->uid == uid) | |
beaafb2e LP |
426 | continue; |
427 | ||
c7b5eb98 LP |
428 | if (!inhibited || |
429 | i->since.monotonic < ts.monotonic) | |
430 | ts = i->since; | |
431 | ||
432 | inhibited = true; | |
85a428c6 LP |
433 | |
434 | if (offending) | |
435 | *offending = i; | |
c7b5eb98 LP |
436 | } |
437 | ||
438 | if (since) | |
439 | *since = ts; | |
440 | ||
441 | return inhibited; | |
442 | } | |
443 | ||
f8e2fb7b | 444 | const char *inhibit_what_to_string(InhibitWhat w) { |
adbb2b6a RM |
445 | static thread_local char buffer[STRLEN( |
446 | "shutdown:" | |
447 | "sleep:" | |
448 | "idle:" | |
449 | "handle-power-key:" | |
450 | "handle-suspend-key:" | |
451 | "handle-hibernate-key:" | |
452 | "handle-lid-switch:" | |
453 | "handle-reboot-key")+1]; | |
beaafb2e | 454 | char *p; |
f8e2fb7b LP |
455 | |
456 | if (w < 0 || w >= _INHIBIT_WHAT_MAX) | |
457 | return NULL; | |
458 | ||
beaafb2e LP |
459 | p = buffer; |
460 | if (w & INHIBIT_SHUTDOWN) | |
461 | p = stpcpy(p, "shutdown:"); | |
462 | if (w & INHIBIT_SLEEP) | |
463 | p = stpcpy(p, "sleep:"); | |
464 | if (w & INHIBIT_IDLE) | |
465 | p = stpcpy(p, "idle:"); | |
466 | if (w & INHIBIT_HANDLE_POWER_KEY) | |
467 | p = stpcpy(p, "handle-power-key:"); | |
8e7fd6ad LP |
468 | if (w & INHIBIT_HANDLE_SUSPEND_KEY) |
469 | p = stpcpy(p, "handle-suspend-key:"); | |
470 | if (w & INHIBIT_HANDLE_HIBERNATE_KEY) | |
471 | p = stpcpy(p, "handle-hibernate-key:"); | |
beaafb2e LP |
472 | if (w & INHIBIT_HANDLE_LID_SWITCH) |
473 | p = stpcpy(p, "handle-lid-switch:"); | |
adbb2b6a RM |
474 | if (w & INHIBIT_HANDLE_REBOOT_KEY) |
475 | p = stpcpy(p, "handle-reboot-key:"); | |
beaafb2e LP |
476 | |
477 | if (p > buffer) | |
478 | *(p-1) = 0; | |
479 | else | |
480 | *p = 0; | |
481 | ||
482 | return buffer; | |
f8e2fb7b LP |
483 | } |
484 | ||
46ed9f4c | 485 | int inhibit_what_from_string(const char *s) { |
f8e2fb7b | 486 | InhibitWhat what = 0; |
f8e2fb7b | 487 | |
46ed9f4c ZJS |
488 | for (const char *p = s;;) { |
489 | _cleanup_free_ char *word = NULL; | |
490 | int r; | |
491 | ||
492 | /* A sanity check that our return values fit in an int */ | |
493 | assert_cc((int) _INHIBIT_WHAT_MAX == _INHIBIT_WHAT_MAX); | |
494 | ||
495 | r = extract_first_word(&p, &word, ":", EXTRACT_DONT_COALESCE_SEPARATORS); | |
496 | if (r < 0) | |
497 | return r; | |
498 | if (r == 0) | |
499 | return what; | |
500 | ||
501 | if (streq(word, "shutdown")) | |
f8e2fb7b | 502 | what |= INHIBIT_SHUTDOWN; |
46ed9f4c | 503 | else if (streq(word, "sleep")) |
4943c1c9 | 504 | what |= INHIBIT_SLEEP; |
46ed9f4c | 505 | else if (streq(word, "idle")) |
f8e2fb7b | 506 | what |= INHIBIT_IDLE; |
46ed9f4c | 507 | else if (streq(word, "handle-power-key")) |
beaafb2e | 508 | what |= INHIBIT_HANDLE_POWER_KEY; |
46ed9f4c | 509 | else if (streq(word, "handle-suspend-key")) |
8e7fd6ad | 510 | what |= INHIBIT_HANDLE_SUSPEND_KEY; |
46ed9f4c | 511 | else if (streq(word, "handle-hibernate-key")) |
8e7fd6ad | 512 | what |= INHIBIT_HANDLE_HIBERNATE_KEY; |
46ed9f4c | 513 | else if (streq(word, "handle-lid-switch")) |
beaafb2e | 514 | what |= INHIBIT_HANDLE_LID_SWITCH; |
197db625 | 515 | else if (streq(word, "handle-reboot-key")) |
adbb2b6a | 516 | what |= INHIBIT_HANDLE_REBOOT_KEY; |
f8e2fb7b LP |
517 | else |
518 | return _INHIBIT_WHAT_INVALID; | |
519 | } | |
f8e2fb7b | 520 | } |
eecd1362 LP |
521 | |
522 | static const char* const inhibit_mode_table[_INHIBIT_MODE_MAX] = { | |
523 | [INHIBIT_BLOCK] = "block", | |
524 | [INHIBIT_DELAY] = "delay" | |
525 | }; | |
526 | ||
527 | DEFINE_STRING_TABLE_LOOKUP(inhibit_mode, InhibitMode); |