]>
Commit | Line | Data |
---|---|---|
c2f1db8f | 1 | #pragma once |
07b0b134 ML |
2 | |
3 | /*** | |
4 | This file is part of systemd. | |
5 | ||
6 | Copyright 2010 Lennart Poettering | |
7 | Copyright 2010 Maarten Lankhorst | |
8 | ||
9 | systemd is free software; you can redistribute it and/or modify it | |
5430f7f2 LP |
10 | under the terms of the GNU Lesser General Public License as published by |
11 | the Free Software Foundation; either version 2.1 of the License, or | |
07b0b134 ML |
12 | (at your option) any later version. |
13 | ||
14 | systemd is distributed in the hope that it will be useful, but | |
15 | WITHOUT ANY WARRANTY; without even the implied warranty of | |
16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
5430f7f2 | 17 | Lesser General Public License for more details. |
07b0b134 | 18 | |
5430f7f2 | 19 | You should have received a copy of the GNU Lesser General Public License |
07b0b134 ML |
20 | along with systemd; If not, see <http://www.gnu.org/licenses/>. |
21 | ***/ | |
22 | ||
07630cea | 23 | #include "libudev.h" |
9670d583 | 24 | |
07b0b134 ML |
25 | typedef struct Swap Swap; |
26 | ||
e04aad61 LP |
27 | typedef enum SwapExecCommand { |
28 | SWAP_EXEC_ACTIVATE, | |
29 | SWAP_EXEC_DEACTIVATE, | |
30 | _SWAP_EXEC_COMMAND_MAX, | |
31 | _SWAP_EXEC_COMMAND_INVALID = -1 | |
32 | } SwapExecCommand; | |
33 | ||
e1770af8 LP |
34 | typedef enum SwapResult { |
35 | SWAP_SUCCESS, | |
36 | SWAP_FAILURE_RESOURCES, | |
37 | SWAP_FAILURE_TIMEOUT, | |
38 | SWAP_FAILURE_EXIT_CODE, | |
39 | SWAP_FAILURE_SIGNAL, | |
40 | SWAP_FAILURE_CORE_DUMP, | |
07299350 | 41 | SWAP_FAILURE_START_LIMIT_HIT, |
e1770af8 LP |
42 | _SWAP_RESULT_MAX, |
43 | _SWAP_RESULT_INVALID = -1 | |
44 | } SwapResult; | |
45 | ||
5bcb0f2b LP |
46 | typedef struct SwapParameters { |
47 | char *what; | |
47cb901e | 48 | char *options; |
5bcb0f2b | 49 | int priority; |
5bcb0f2b LP |
50 | } SwapParameters; |
51 | ||
07b0b134 | 52 | struct Swap { |
ac155bb8 | 53 | Unit meta; |
07b0b134 | 54 | |
e04aad61 LP |
55 | char *what; |
56 | ||
9670d583 LP |
57 | /* If the device has already shown up, this is the device |
58 | * node, which might be different from what, due to | |
59 | * symlinks */ | |
60 | char *devnode; | |
61 | ||
4e85aff4 LP |
62 | SwapParameters parameters_proc_swaps; |
63 | SwapParameters parameters_fragment; | |
07b0b134 | 64 | |
4e85aff4 LP |
65 | bool from_proc_swaps:1; |
66 | bool from_fragment:1; | |
e04aad61 | 67 | |
e04aad61 LP |
68 | /* Used while looking for swaps that vanished or got added |
69 | * from/to /proc/swaps */ | |
70 | bool is_active:1; | |
71 | bool just_activated:1; | |
72 | ||
906c06f6 | 73 | bool reset_accounting:1; |
5ad096b3 | 74 | |
e1770af8 LP |
75 | SwapResult result; |
76 | ||
e04aad61 LP |
77 | usec_t timeout_usec; |
78 | ||
79 | ExecCommand exec_command[_SWAP_EXEC_COMMAND_MAX]; | |
80 | ExecContext exec_context; | |
4819ff03 | 81 | KillContext kill_context; |
4ad49000 | 82 | CGroupContext cgroup_context; |
e04aad61 | 83 | |
613b411c | 84 | ExecRuntime *exec_runtime; |
29206d46 | 85 | DynamicCreds dynamic_creds; |
613b411c | 86 | |
e04aad61 LP |
87 | SwapState state, deserialized_state; |
88 | ||
89 | ExecCommand* control_command; | |
90 | SwapExecCommand control_command_id; | |
91 | pid_t control_pid; | |
92 | ||
718db961 | 93 | sd_event_source *timer_event_source; |
e04aad61 | 94 | |
35b8ca3a | 95 | /* In order to be able to distinguish dependencies on |
e04aad61 LP |
96 | different device nodes we might end up creating multiple |
97 | devices for the same swap. We chain them up here. */ | |
98 | ||
9670d583 | 99 | LIST_FIELDS(struct Swap, same_devnode); |
07b0b134 ML |
100 | }; |
101 | ||
102 | extern const UnitVTable swap_vtable; | |
103 | ||
628c89cc LP |
104 | int swap_process_device_new(Manager *m, struct udev_device *dev); |
105 | int swap_process_device_remove(Manager *m, struct udev_device *dev); | |
9670d583 | 106 | |
44a6b1b6 ZJS |
107 | const char* swap_exec_command_to_string(SwapExecCommand i) _const_; |
108 | SwapExecCommand swap_exec_command_from_string(const char *s) _pure_; | |
07b0b134 | 109 | |
44a6b1b6 ZJS |
110 | const char* swap_result_to_string(SwapResult i) _const_; |
111 | SwapResult swap_result_from_string(const char *s) _pure_; |