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