]>
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, | |
41 | _SWAP_RESULT_MAX, | |
42 | _SWAP_RESULT_INVALID = -1 | |
43 | } SwapResult; | |
44 | ||
5bcb0f2b LP |
45 | typedef struct SwapParameters { |
46 | char *what; | |
47cb901e | 47 | char *options; |
5bcb0f2b | 48 | int priority; |
5bcb0f2b LP |
49 | } SwapParameters; |
50 | ||
07b0b134 | 51 | struct Swap { |
ac155bb8 | 52 | Unit meta; |
07b0b134 | 53 | |
e04aad61 LP |
54 | char *what; |
55 | ||
9670d583 LP |
56 | /* If the device has already shown up, this is the device |
57 | * node, which might be different from what, due to | |
58 | * symlinks */ | |
59 | char *devnode; | |
60 | ||
4e85aff4 LP |
61 | SwapParameters parameters_proc_swaps; |
62 | SwapParameters parameters_fragment; | |
07b0b134 | 63 | |
4e85aff4 LP |
64 | bool from_proc_swaps:1; |
65 | bool from_fragment:1; | |
e04aad61 | 66 | |
e04aad61 LP |
67 | /* Used while looking for swaps that vanished or got added |
68 | * from/to /proc/swaps */ | |
69 | bool is_active:1; | |
70 | bool just_activated:1; | |
71 | ||
5ad096b3 LP |
72 | bool reset_cpu_usage:1; |
73 | ||
e1770af8 LP |
74 | SwapResult result; |
75 | ||
e04aad61 LP |
76 | usec_t timeout_usec; |
77 | ||
78 | ExecCommand exec_command[_SWAP_EXEC_COMMAND_MAX]; | |
79 | ExecContext exec_context; | |
4819ff03 | 80 | KillContext kill_context; |
4ad49000 | 81 | CGroupContext cgroup_context; |
e04aad61 | 82 | |
613b411c LP |
83 | ExecRuntime *exec_runtime; |
84 | ||
e04aad61 LP |
85 | SwapState state, deserialized_state; |
86 | ||
87 | ExecCommand* control_command; | |
88 | SwapExecCommand control_command_id; | |
89 | pid_t control_pid; | |
90 | ||
718db961 | 91 | sd_event_source *timer_event_source; |
e04aad61 | 92 | |
35b8ca3a | 93 | /* In order to be able to distinguish dependencies on |
e04aad61 LP |
94 | different device nodes we might end up creating multiple |
95 | devices for the same swap. We chain them up here. */ | |
96 | ||
9670d583 | 97 | LIST_FIELDS(struct Swap, same_devnode); |
07b0b134 ML |
98 | }; |
99 | ||
100 | extern const UnitVTable swap_vtable; | |
101 | ||
628c89cc LP |
102 | int swap_process_device_new(Manager *m, struct udev_device *dev); |
103 | int swap_process_device_remove(Manager *m, struct udev_device *dev); | |
9670d583 | 104 | |
44a6b1b6 ZJS |
105 | const char* swap_exec_command_to_string(SwapExecCommand i) _const_; |
106 | SwapExecCommand swap_exec_command_from_string(const char *s) _pure_; | |
07b0b134 | 107 | |
44a6b1b6 ZJS |
108 | const char* swap_result_to_string(SwapResult i) _const_; |
109 | SwapResult swap_result_from_string(const char *s) _pure_; |