1 /* SPDX-License-Identifier: LGPL-2.1+ */
5 This file is part of systemd.
7 Copyright 2010 Lennart Poettering
8 Copyright 2010 Maarten Lankhorst
10 systemd is free software; you can redistribute it and/or modify it
11 under the terms of the GNU Lesser General Public License as published by
12 the Free Software Foundation; either version 2.1 of the License, or
13 (at your option) any later version.
15 systemd is distributed in the hope that it will be useful, but
16 WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 Lesser General Public License for more details.
20 You should have received a copy of the GNU Lesser General Public License
21 along with systemd; If not, see <http://www.gnu.org/licenses/>.
26 typedef struct Swap Swap
;
28 typedef enum SwapExecCommand
{
31 _SWAP_EXEC_COMMAND_MAX
,
32 _SWAP_EXEC_COMMAND_INVALID
= -1
35 typedef enum SwapResult
{
37 SWAP_FAILURE_RESOURCES
,
39 SWAP_FAILURE_EXIT_CODE
,
41 SWAP_FAILURE_CORE_DUMP
,
42 SWAP_FAILURE_START_LIMIT_HIT
,
44 _SWAP_RESULT_INVALID
= -1
47 typedef struct SwapParameters
{
58 /* If the device has already shown up, this is the device
59 * node, which might be different from what, due to
63 SwapParameters parameters_proc_swaps
;
64 SwapParameters parameters_fragment
;
66 bool from_proc_swaps
:1;
69 /* Used while looking for swaps that vanished or got added
70 * from/to /proc/swaps */
72 bool just_activated
:1;
74 bool reset_accounting
:1;
80 ExecCommand exec_command
[_SWAP_EXEC_COMMAND_MAX
];
81 ExecContext exec_context
;
82 KillContext kill_context
;
83 CGroupContext cgroup_context
;
85 ExecRuntime
*exec_runtime
;
86 DynamicCreds dynamic_creds
;
88 SwapState state
, deserialized_state
;
90 ExecCommand
* control_command
;
91 SwapExecCommand control_command_id
;
94 sd_event_source
*timer_event_source
;
96 /* In order to be able to distinguish dependencies on
97 different device nodes we might end up creating multiple
98 devices for the same swap. We chain them up here. */
100 LIST_FIELDS(struct Swap
, same_devnode
);
103 extern const UnitVTable swap_vtable
;
105 int swap_process_device_new(Manager
*m
, struct udev_device
*dev
);
106 int swap_process_device_remove(Manager
*m
, struct udev_device
*dev
);
108 const char* swap_exec_command_to_string(SwapExecCommand i
) _const_
;
109 SwapExecCommand
swap_exec_command_from_string(const char *s
) _pure_
;
111 const char* swap_result_to_string(SwapResult i
) _const_
;
112 SwapResult
swap_result_from_string(const char *s
) _pure_
;