1 /*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
6 This file is part of systemd.
8 Copyright 2010 Lennart Poettering
9 Copyright 2010 Maarten Lankhorst
11 systemd is free software; you can redistribute it and/or modify it
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
14 (at your option) any later version.
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
19 Lesser General Public License for more details.
21 You should have received a copy of the GNU Lesser General Public License
22 along with systemd; If not, see <http://www.gnu.org/licenses/>.
25 typedef struct Swap Swap;
29 typedef enum SwapState {
34 SWAP_ACTIVATING_SIGTERM,
35 SWAP_ACTIVATING_SIGKILL,
36 SWAP_DEACTIVATING_SIGTERM,
37 SWAP_DEACTIVATING_SIGKILL,
40 _SWAP_STATE_INVALID = -1
43 typedef enum SwapExecCommand {
46 _SWAP_EXEC_COMMAND_MAX,
47 _SWAP_EXEC_COMMAND_INVALID = -1
50 typedef struct SwapParameters {
57 typedef enum SwapResult {
59 SWAP_FAILURE_RESOURCES,
61 SWAP_FAILURE_EXIT_CODE,
63 SWAP_FAILURE_CORE_DUMP,
65 _SWAP_RESULT_INVALID = -1
73 SwapParameters parameters_proc_swaps;
74 SwapParameters parameters_fragment;
76 bool from_proc_swaps:1;
79 /* Used while looking for swaps that vanished or got added
80 * from/to /proc/swaps */
82 bool just_activated:1;
88 ExecCommand exec_command[_SWAP_EXEC_COMMAND_MAX];
89 ExecContext exec_context;
90 KillContext kill_context;
92 SwapState state, deserialized_state;
94 ExecCommand* control_command;
95 SwapExecCommand control_command_id;
100 /* In order to be able to distinguish dependencies on
101 different device nodes we might end up creating multiple
102 devices for the same swap. We chain them up here. */
104 LIST_FIELDS(struct Swap, same_proc_swaps);
107 extern const UnitVTable swap_vtable;
109 int swap_add_one_mount_link(Swap *s, Mount *m);
111 int swap_dispatch_reload(Manager *m);
112 int swap_fd_event(Manager *m, int events);
114 const char* swap_state_to_string(SwapState i);
115 SwapState swap_state_from_string(const char *s);
117 const char* swap_exec_command_to_string(SwapExecCommand i);
118 SwapExecCommand swap_exec_command_from_string(const char *s);
120 const char* swap_result_to_string(SwapResult i);
121 SwapResult swap_result_from_string(const char *s);