chiark / gitweb /
core: convert PID 1 to libsystemd-bus
[elogind.git] / src / core / mount.h
1 /*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
2
3 #pragma once
4
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
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.
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
18   Lesser General Public License for more details.
19
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/>.
22 ***/
23
24 typedef struct Mount Mount;
25
26 #include "unit.h"
27 #include "kill.h"
28 #include "execute.h"
29 #include "cgroup.h"
30
31 typedef enum MountState {
32         MOUNT_DEAD,
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. */
35         MOUNT_MOUNTED,
36         MOUNT_REMOUNTING,
37         MOUNT_UNMOUNTING,
38         MOUNT_MOUNTING_SIGTERM,
39         MOUNT_MOUNTING_SIGKILL,
40         MOUNT_REMOUNTING_SIGTERM,
41         MOUNT_REMOUNTING_SIGKILL,
42         MOUNT_UNMOUNTING_SIGTERM,
43         MOUNT_UNMOUNTING_SIGKILL,
44         MOUNT_FAILED,
45         _MOUNT_STATE_MAX,
46         _MOUNT_STATE_INVALID = -1
47 } MountState;
48
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
57 typedef struct MountParameters {
58         char *what;
59         char *options;
60         char *fstype;
61 } MountParameters;
62
63 typedef enum MountResult {
64         MOUNT_SUCCESS,
65         MOUNT_FAILURE_RESOURCES,
66         MOUNT_FAILURE_TIMEOUT,
67         MOUNT_FAILURE_EXIT_CODE,
68         MOUNT_FAILURE_SIGNAL,
69         MOUNT_FAILURE_CORE_DUMP,
70         _MOUNT_RESULT_MAX,
71         _MOUNT_RESULT_INVALID = -1
72 } MountResult;
73
74 struct Mount {
75         Unit meta;
76
77         char *where;
78
79         MountParameters parameters_proc_self_mountinfo;
80         MountParameters parameters_fragment;
81
82         bool from_proc_self_mountinfo:1;
83         bool from_fragment:1;
84
85         /* Used while looking for mount points that vanished or got
86          * added from/to /proc/self/mountinfo */
87         bool is_mounted:1;
88         bool just_mounted:1;
89         bool just_changed:1;
90
91         MountResult result;
92         MountResult reload_result;
93
94         mode_t directory_mode;
95
96         usec_t timeout_usec;
97
98         ExecCommand exec_command[_MOUNT_EXEC_COMMAND_MAX];
99
100         ExecContext exec_context;
101         KillContext kill_context;
102         CGroupContext cgroup_context;
103
104         MountState state, deserialized_state;
105
106         ExecCommand* control_command;
107         MountExecCommand control_command_id;
108         pid_t control_pid;
109
110         sd_event_source *timer_event_source;
111 };
112
113 extern const UnitVTable mount_vtable;
114
115 void mount_fd_event(Manager *m, int events);
116
117 const char* mount_state_to_string(MountState i) _const_;
118 MountState mount_state_from_string(const char *s) _pure_;
119
120 const char* mount_exec_command_to_string(MountExecCommand i) _const_;
121 MountExecCommand mount_exec_command_from_string(const char *s) _pure_;
122
123 const char* mount_result_to_string(MountResult i) _const_;
124 MountResult mount_result_from_string(const char *s) _pure_;
125
126 void warn_if_dir_nonempty(const char *unit, const char* where);