]> git.ipfire.org Git - thirdparty/systemd.git/blame - src/core/swap.h
man: add an additional note about journalctl -u
[thirdparty/systemd.git] / src / core / swap.h
CommitLineData
53e1b683 1/* SPDX-License-Identifier: LGPL-2.1+ */
c2f1db8f 2#pragma once
07b0b134
ML
3
4/***
5 This file is part of systemd.
6
7 Copyright 2010 Lennart Poettering
8 Copyright 2010 Maarten Lankhorst
9
10 systemd is free software; you can redistribute it and/or modify it
5430f7f2
LP
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
07b0b134
ML
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
5430f7f2 18 Lesser General Public License for more details.
07b0b134 19
5430f7f2 20 You should have received a copy of the GNU Lesser General Public License
07b0b134
ML
21 along with systemd; If not, see <http://www.gnu.org/licenses/>.
22***/
23
07630cea 24#include "libudev.h"
9670d583 25
07b0b134
ML
26typedef struct Swap Swap;
27
e04aad61
LP
28typedef enum SwapExecCommand {
29 SWAP_EXEC_ACTIVATE,
30 SWAP_EXEC_DEACTIVATE,
31 _SWAP_EXEC_COMMAND_MAX,
32 _SWAP_EXEC_COMMAND_INVALID = -1
33} SwapExecCommand;
34
e1770af8
LP
35typedef enum SwapResult {
36 SWAP_SUCCESS,
37 SWAP_FAILURE_RESOURCES,
38 SWAP_FAILURE_TIMEOUT,
39 SWAP_FAILURE_EXIT_CODE,
40 SWAP_FAILURE_SIGNAL,
41 SWAP_FAILURE_CORE_DUMP,
07299350 42 SWAP_FAILURE_START_LIMIT_HIT,
e1770af8
LP
43 _SWAP_RESULT_MAX,
44 _SWAP_RESULT_INVALID = -1
45} SwapResult;
46
5bcb0f2b
LP
47typedef struct SwapParameters {
48 char *what;
47cb901e 49 char *options;
5bcb0f2b 50 int priority;
5bcb0f2b
LP
51} SwapParameters;
52
07b0b134 53struct Swap {
ac155bb8 54 Unit meta;
07b0b134 55
e04aad61
LP
56 char *what;
57
9670d583
LP
58 /* If the device has already shown up, this is the device
59 * node, which might be different from what, due to
60 * symlinks */
61 char *devnode;
62
4e85aff4
LP
63 SwapParameters parameters_proc_swaps;
64 SwapParameters parameters_fragment;
07b0b134 65
4e85aff4
LP
66 bool from_proc_swaps:1;
67 bool from_fragment:1;
e04aad61 68
e04aad61
LP
69 /* Used while looking for swaps that vanished or got added
70 * from/to /proc/swaps */
71 bool is_active:1;
72 bool just_activated:1;
73
e1770af8
LP
74 SwapResult result;
75
e04aad61
LP
76 usec_t timeout_usec;
77
78 ExecCommand exec_command[_SWAP_EXEC_COMMAND_MAX];
79 ExecContext exec_context;
4819ff03 80 KillContext kill_context;
4ad49000 81 CGroupContext cgroup_context;
e04aad61 82
613b411c 83 ExecRuntime *exec_runtime;
29206d46 84 DynamicCreds dynamic_creds;
613b411c 85
e04aad61
LP
86 SwapState state, deserialized_state;
87
88 ExecCommand* control_command;
89 SwapExecCommand control_command_id;
90 pid_t control_pid;
91
718db961 92 sd_event_source *timer_event_source;
e04aad61 93
35b8ca3a 94 /* In order to be able to distinguish dependencies on
e04aad61
LP
95 different device nodes we might end up creating multiple
96 devices for the same swap. We chain them up here. */
97
9670d583 98 LIST_FIELDS(struct Swap, same_devnode);
07b0b134
ML
99};
100
101extern const UnitVTable swap_vtable;
102
628c89cc
LP
103int swap_process_device_new(Manager *m, struct udev_device *dev);
104int swap_process_device_remove(Manager *m, struct udev_device *dev);
9670d583 105
44a6b1b6
ZJS
106const char* swap_exec_command_to_string(SwapExecCommand i) _const_;
107SwapExecCommand swap_exec_command_from_string(const char *s) _pure_;
07b0b134 108
44a6b1b6
ZJS
109const char* swap_result_to_string(SwapResult i) _const_;
110SwapResult swap_result_from_string(const char *s) _pure_;