1 /*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
7 This file is part of systemd.
9 Copyright 2010 Lennart Poettering
10 Copyright 2010 Maarten Lankhorst
12 systemd is free software; you can redistribute it and/or modify it
13 under the terms of the GNU Lesser General Public License as published by
14 the Free Software Foundation; either version 2.1 of the License, or
15 (at your option) any later version.
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 Lesser General Public License for more details.
22 You should have received a copy of the GNU Lesser General Public License
23 along with systemd; If not, see <http://www.gnu.org/licenses/>.
26 typedef struct Swap Swap;
30 typedef enum SwapState {
35 SWAP_ACTIVATING_SIGTERM,
36 SWAP_ACTIVATING_SIGKILL,
37 SWAP_DEACTIVATING_SIGTERM,
38 SWAP_DEACTIVATING_SIGKILL,
41 _SWAP_STATE_INVALID = -1
44 typedef enum SwapExecCommand {
47 _SWAP_EXEC_COMMAND_MAX,
48 _SWAP_EXEC_COMMAND_INVALID = -1
51 typedef struct SwapParameters {
59 typedef enum SwapResult {
61 SWAP_FAILURE_RESOURCES,
63 SWAP_FAILURE_EXIT_CODE,
65 SWAP_FAILURE_CORE_DUMP,
67 _SWAP_RESULT_INVALID = -1
75 SwapParameters parameters_etc_fstab;
76 SwapParameters parameters_proc_swaps;
77 SwapParameters parameters_fragment;
79 bool from_etc_fstab:1;
80 bool from_proc_swaps:1;
83 /* Used while looking for swaps that vanished or got added
84 * from/to /proc/swaps */
86 bool just_activated:1;
92 ExecCommand exec_command[_SWAP_EXEC_COMMAND_MAX];
93 ExecContext exec_context;
95 SwapState state, deserialized_state;
97 ExecCommand* control_command;
98 SwapExecCommand control_command_id;
103 /* In order to be able to distinguish dependencies on
104 different device nodes we might end up creating multiple
105 devices for the same swap. We chain them up here. */
107 LIST_FIELDS(struct Swap, same_proc_swaps);
110 extern const UnitVTable swap_vtable;
112 int 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);
114 int swap_add_one_mount_link(Swap *s, Mount *m);
116 int swap_dispatch_reload(Manager *m);
117 int swap_fd_event(Manager *m, int events);
119 const char* swap_state_to_string(SwapState i);
120 SwapState swap_state_from_string(const char *s);
122 const char* swap_exec_command_to_string(SwapExecCommand i);
123 SwapExecCommand swap_exec_command_from_string(const char *s);
125 const char* swap_result_to_string(SwapResult i);
126 SwapResult swap_result_from_string(const char *s);