]> git.ipfire.org Git - thirdparty/systemd.git/blame - src/swap.h
dbus: more efficient implementation of properties
[thirdparty/systemd.git] / src / swap.h
CommitLineData
03467c88 1/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
07b0b134
ML
2
3#ifndef fooswaphfoo
4#define fooswaphfoo
5
6/***
7 This file is part of systemd.
8
9 Copyright 2010 Lennart Poettering
10 Copyright 2010 Maarten Lankhorst
11
12 systemd is free software; you can redistribute it and/or modify it
13 under the terms of the GNU General Public License as published by
14 the Free Software Foundation; either version 2 of the License, or
15 (at your option) any later version.
16
17 systemd is distributed in the hope that it will be useful, but
18 WITHOUT ANY WARRANTY; without even the implied warranty of
19 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 General Public License for more details.
21
22 You should have received a copy of the GNU General Public License
23 along with systemd; If not, see <http://www.gnu.org/licenses/>.
24***/
25
26typedef struct Swap Swap;
27
28#include "unit.h"
29
30typedef enum SwapState {
31 SWAP_DEAD,
e04aad61 32 SWAP_ACTIVATING,
07b0b134 33 SWAP_ACTIVE,
e04aad61
LP
34 SWAP_DEACTIVATING,
35 SWAP_ACTIVATING_SIGTERM,
36 SWAP_ACTIVATING_SIGKILL,
37 SWAP_DEACTIVATING_SIGTERM,
38 SWAP_DEACTIVATING_SIGKILL,
fdf20a31 39 SWAP_FAILED,
07b0b134
ML
40 _SWAP_STATE_MAX,
41 _SWAP_STATE_INVALID = -1
42} SwapState;
43
e04aad61
LP
44typedef enum SwapExecCommand {
45 SWAP_EXEC_ACTIVATE,
46 SWAP_EXEC_DEACTIVATE,
47 _SWAP_EXEC_COMMAND_MAX,
48 _SWAP_EXEC_COMMAND_INVALID = -1
49} SwapExecCommand;
50
4e85aff4
LP
51typedef struct SwapParameters {
52 char *what;
53 int priority;
54 bool noauto:1;
173a8d04 55 bool nofail:1;
4e85aff4
LP
56 bool handle:1;
57} SwapParameters;
58
07b0b134 59struct Swap {
ac155bb8 60 Unit meta;
07b0b134 61
e04aad61
LP
62 char *what;
63
4e85aff4
LP
64 SwapParameters parameters_etc_fstab;
65 SwapParameters parameters_proc_swaps;
66 SwapParameters parameters_fragment;
07b0b134 67
4e85aff4
LP
68 bool from_etc_fstab:1;
69 bool from_proc_swaps:1;
70 bool from_fragment:1;
e04aad61
LP
71
72 bool failure:1;
73
74 /* Used while looking for swaps that vanished or got added
75 * from/to /proc/swaps */
76 bool is_active:1;
77 bool just_activated:1;
78
79 usec_t timeout_usec;
80
81 ExecCommand exec_command[_SWAP_EXEC_COMMAND_MAX];
82 ExecContext exec_context;
83
84 SwapState state, deserialized_state;
85
86 ExecCommand* control_command;
87 SwapExecCommand control_command_id;
88 pid_t control_pid;
89
90 Watch timer_watch;
91
35b8ca3a 92 /* In order to be able to distinguish dependencies on
e04aad61
LP
93 different device nodes we might end up creating multiple
94 devices for the same swap. We chain them up here. */
95
96 LIST_FIELDS(struct Swap, same_proc_swaps);
07b0b134
ML
97};
98
99extern const UnitVTable swap_vtable;
100
e04aad61 101int swap_add_one(Manager *m, const char *what, const char *what_proc_swaps, int prio, bool no_auto, bool no_fail, bool handle, bool set_flags);
6e2ef85b
LP
102
103int swap_add_one_mount_link(Swap *s, Mount *m);
104
e04aad61 105int swap_dispatch_reload(Manager *m);
4e434314 106int swap_fd_event(Manager *m, int events);
e04aad61 107
07b0b134
ML
108const char* swap_state_to_string(SwapState i);
109SwapState swap_state_from_string(const char *s);
110
e04aad61
LP
111const char* swap_exec_command_to_string(SwapExecCommand i);
112SwapExecCommand swap_exec_command_from_string(const char *s);
07b0b134
ML
113
114#endif