]>
Commit | Line | Data |
---|---|---|
03467c88 | 1 | /*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/ |
5cb5a6ff | 2 | |
c2f1db8f | 3 | #pragma once |
5cb5a6ff | 4 | |
a7334b09 LP |
5 | /*** |
6 | This file is part of systemd. | |
7 | ||
8 | Copyright 2010 Lennart Poettering | |
9 | ||
10 | systemd is free software; you can redistribute it and/or modify it | |
5430f7f2 LP |
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 | |
a7334b09 LP |
13 | (at your option) any later version. |
14 | ||
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 | |
5430f7f2 | 18 | Lesser General Public License for more details. |
a7334b09 | 19 | |
5430f7f2 | 20 | You should have received a copy of the GNU Lesser General Public License |
a7334b09 LP |
21 | along with systemd; If not, see <http://www.gnu.org/licenses/>. |
22 | ***/ | |
23 | ||
5cb5a6ff LP |
24 | typedef struct Mount Mount; |
25 | ||
87f0e418 | 26 | #include "unit.h" |
4819ff03 | 27 | #include "kill.h" |
4ad49000 LP |
28 | #include "execute.h" |
29 | #include "cgroup.h" | |
5cb5a6ff LP |
30 | |
31 | typedef enum MountState { | |
32 | MOUNT_DEAD, | |
e537352b LP |
33 | MOUNT_MOUNTING, /* /bin/mount is running, but the mount is not done yet. */ |
34 | MOUNT_MOUNTING_DONE, /* /bin/mount is running, and the mount is done. */ | |
5cb5a6ff | 35 | MOUNT_MOUNTED, |
e537352b | 36 | MOUNT_REMOUNTING, |
5cb5a6ff | 37 | MOUNT_UNMOUNTING, |
e537352b LP |
38 | MOUNT_MOUNTING_SIGTERM, |
39 | MOUNT_MOUNTING_SIGKILL, | |
40 | MOUNT_REMOUNTING_SIGTERM, | |
41 | MOUNT_REMOUNTING_SIGKILL, | |
42 | MOUNT_UNMOUNTING_SIGTERM, | |
43 | MOUNT_UNMOUNTING_SIGKILL, | |
fdf20a31 | 44 | MOUNT_FAILED, |
e537352b LP |
45 | _MOUNT_STATE_MAX, |
46 | _MOUNT_STATE_INVALID = -1 | |
5cb5a6ff LP |
47 | } MountState; |
48 | ||
e537352b LP |
49 | typedef enum MountExecCommand { |
50 | MOUNT_EXEC_MOUNT, | |
51 | MOUNT_EXEC_UNMOUNT, | |
52 | MOUNT_EXEC_REMOUNT, | |
53 | _MOUNT_EXEC_COMMAND_MAX, | |
54 | _MOUNT_EXEC_COMMAND_INVALID = -1 | |
55 | } MountExecCommand; | |
56 | ||
9d2f5178 LP |
57 | typedef enum MountResult { |
58 | MOUNT_SUCCESS, | |
59 | MOUNT_FAILURE_RESOURCES, | |
60 | MOUNT_FAILURE_TIMEOUT, | |
61 | MOUNT_FAILURE_EXIT_CODE, | |
62 | MOUNT_FAILURE_SIGNAL, | |
63 | MOUNT_FAILURE_CORE_DUMP, | |
64 | _MOUNT_RESULT_MAX, | |
65 | _MOUNT_RESULT_INVALID = -1 | |
66 | } MountResult; | |
67 | ||
5bcb0f2b LP |
68 | typedef struct MountParameters { |
69 | char *what; | |
70 | char *options; | |
71 | char *fstype; | |
72 | } MountParameters; | |
73 | ||
5cb5a6ff | 74 | struct Mount { |
ac155bb8 | 75 | Unit meta; |
5cb5a6ff | 76 | |
e537352b | 77 | char *where; |
b08d03ff | 78 | |
e537352b LP |
79 | MountParameters parameters_proc_self_mountinfo; |
80 | MountParameters parameters_fragment; | |
f50e0a01 | 81 | |
f50e0a01 | 82 | bool from_proc_self_mountinfo:1; |
e537352b | 83 | bool from_fragment:1; |
ef734fd6 LP |
84 | |
85 | /* Used while looking for mount points that vanished or got | |
86 | * added from/to /proc/self/mountinfo */ | |
e537352b LP |
87 | bool is_mounted:1; |
88 | bool just_mounted:1; | |
89 | bool just_changed:1; | |
90 | ||
9d2f5178 LP |
91 | MountResult result; |
92 | MountResult reload_result; | |
e537352b | 93 | |
3e5235b0 LP |
94 | mode_t directory_mode; |
95 | ||
7fab9d01 LP |
96 | usec_t timeout_usec; |
97 | ||
e537352b | 98 | ExecCommand exec_command[_MOUNT_EXEC_COMMAND_MAX]; |
4ad49000 | 99 | |
e537352b | 100 | ExecContext exec_context; |
4819ff03 | 101 | KillContext kill_context; |
4ad49000 | 102 | CGroupContext cgroup_context; |
e537352b | 103 | |
613b411c LP |
104 | ExecRuntime *exec_runtime; |
105 | ||
a16e1123 | 106 | MountState state, deserialized_state; |
e537352b | 107 | |
e537352b | 108 | ExecCommand* control_command; |
a16e1123 | 109 | MountExecCommand control_command_id; |
e537352b LP |
110 | pid_t control_pid; |
111 | ||
718db961 | 112 | sd_event_source *timer_event_source; |
5cb5a6ff LP |
113 | }; |
114 | ||
87f0e418 | 115 | extern const UnitVTable mount_vtable; |
5cb5a6ff | 116 | |
ef734fd6 LP |
117 | void mount_fd_event(Manager *m, int events); |
118 | ||
44a6b1b6 ZJS |
119 | const char* mount_state_to_string(MountState i) _const_; |
120 | MountState mount_state_from_string(const char *s) _pure_; | |
a16e1123 | 121 | |
44a6b1b6 ZJS |
122 | const char* mount_exec_command_to_string(MountExecCommand i) _const_; |
123 | MountExecCommand mount_exec_command_from_string(const char *s) _pure_; | |
a16e1123 | 124 | |
44a6b1b6 ZJS |
125 | const char* mount_result_to_string(MountResult i) _const_; |
126 | MountResult mount_result_from_string(const char *s) _pure_; | |
20ad4cfd ZJS |
127 | |
128 | void warn_if_dir_nonempty(const char *unit, const char* where); |