]> git.proxmox.com Git - systemd.git/blame - src/core/swap.h
Merge tag 'upstream/229'
[systemd.git] / src / core / swap.h
CommitLineData
663996b3
MS
1#pragma once
2
3/***
4 This file is part of systemd.
5
6 Copyright 2010 Lennart Poettering
7 Copyright 2010 Maarten Lankhorst
8
9 systemd is free software; you can redistribute it and/or modify it
10 under the terms of the GNU Lesser General Public License as published by
11 the Free Software Foundation; either version 2.1 of the License, or
12 (at your option) any later version.
13
14 systemd is distributed in the hope that it will be useful, but
15 WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 Lesser General Public License for more details.
18
19 You should have received a copy of the GNU Lesser General Public License
20 along with systemd; If not, see <http://www.gnu.org/licenses/>.
21***/
22
db2df898 23#include "libudev.h"
60f067b4 24
663996b3
MS
25typedef struct Swap Swap;
26
663996b3
MS
27typedef enum SwapExecCommand {
28 SWAP_EXEC_ACTIVATE,
29 SWAP_EXEC_DEACTIVATE,
30 _SWAP_EXEC_COMMAND_MAX,
31 _SWAP_EXEC_COMMAND_INVALID = -1
32} SwapExecCommand;
33
663996b3
MS
34typedef enum SwapResult {
35 SWAP_SUCCESS,
36 SWAP_FAILURE_RESOURCES,
37 SWAP_FAILURE_TIMEOUT,
38 SWAP_FAILURE_EXIT_CODE,
39 SWAP_FAILURE_SIGNAL,
40 SWAP_FAILURE_CORE_DUMP,
41 _SWAP_RESULT_MAX,
42 _SWAP_RESULT_INVALID = -1
43} SwapResult;
44
60f067b4
JS
45typedef struct SwapParameters {
46 char *what;
5eef597e 47 char *options;
60f067b4 48 int priority;
60f067b4
JS
49} SwapParameters;
50
663996b3
MS
51struct Swap {
52 Unit meta;
53
54 char *what;
55
60f067b4
JS
56 /* If the device has already shown up, this is the device
57 * node, which might be different from what, due to
58 * symlinks */
59 char *devnode;
60
663996b3
MS
61 SwapParameters parameters_proc_swaps;
62 SwapParameters parameters_fragment;
63
64 bool from_proc_swaps:1;
65 bool from_fragment:1;
66
67 /* Used while looking for swaps that vanished or got added
68 * from/to /proc/swaps */
69 bool is_active:1;
70 bool just_activated:1;
71
e3bff60a
MP
72 bool reset_cpu_usage:1;
73
663996b3
MS
74 SwapResult result;
75
76 usec_t timeout_usec;
77
78 ExecCommand exec_command[_SWAP_EXEC_COMMAND_MAX];
79 ExecContext exec_context;
80 KillContext kill_context;
14228c0d 81 CGroupContext cgroup_context;
663996b3 82
60f067b4
JS
83 ExecRuntime *exec_runtime;
84
663996b3
MS
85 SwapState state, deserialized_state;
86
87 ExecCommand* control_command;
88 SwapExecCommand control_command_id;
89 pid_t control_pid;
90
60f067b4 91 sd_event_source *timer_event_source;
663996b3
MS
92
93 /* In order to be able to distinguish dependencies on
94 different device nodes we might end up creating multiple
95 devices for the same swap. We chain them up here. */
96
60f067b4 97 LIST_FIELDS(struct Swap, same_devnode);
663996b3
MS
98};
99
100extern const UnitVTable swap_vtable;
101
e3bff60a
MP
102int swap_process_device_new(Manager *m, struct udev_device *dev);
103int swap_process_device_remove(Manager *m, struct udev_device *dev);
663996b3 104
663996b3
MS
105const char* swap_exec_command_to_string(SwapExecCommand i) _const_;
106SwapExecCommand swap_exec_command_from_string(const char *s) _pure_;
107
108const char* swap_result_to_string(SwapResult i) _const_;
109SwapResult swap_result_from_string(const char *s) _pure_;