chiark / gitweb /
use #pragma once instead of foo*foo #define guards
[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
28 typedef enum MountState {
29         MOUNT_DEAD,
30         MOUNT_MOUNTING,               /* /bin/mount is running, but the mount is not done yet. */
31         MOUNT_MOUNTING_DONE,          /* /bin/mount is running, and the mount is done. */
32         MOUNT_MOUNTED,
33         MOUNT_REMOUNTING,
34         MOUNT_UNMOUNTING,
35         MOUNT_MOUNTING_SIGTERM,
36         MOUNT_MOUNTING_SIGKILL,
37         MOUNT_REMOUNTING_SIGTERM,
38         MOUNT_REMOUNTING_SIGKILL,
39         MOUNT_UNMOUNTING_SIGTERM,
40         MOUNT_UNMOUNTING_SIGKILL,
41         MOUNT_FAILED,
42         _MOUNT_STATE_MAX,
43         _MOUNT_STATE_INVALID = -1
44 } MountState;
45
46 typedef enum MountExecCommand {
47         MOUNT_EXEC_MOUNT,
48         MOUNT_EXEC_UNMOUNT,
49         MOUNT_EXEC_REMOUNT,
50         _MOUNT_EXEC_COMMAND_MAX,
51         _MOUNT_EXEC_COMMAND_INVALID = -1
52 } MountExecCommand;
53
54 typedef struct MountParameters {
55         char *what;
56         char *options;
57         char *fstype;
58         int passno;
59 } MountParameters;
60
61 typedef enum MountResult {
62         MOUNT_SUCCESS,
63         MOUNT_FAILURE_RESOURCES,
64         MOUNT_FAILURE_TIMEOUT,
65         MOUNT_FAILURE_EXIT_CODE,
66         MOUNT_FAILURE_SIGNAL,
67         MOUNT_FAILURE_CORE_DUMP,
68         _MOUNT_RESULT_MAX,
69         _MOUNT_RESULT_INVALID = -1
70 } MountResult;
71
72 struct Mount {
73         Unit meta;
74
75         char *where;
76
77         MountParameters parameters_proc_self_mountinfo;
78         MountParameters parameters_fragment;
79
80         bool from_proc_self_mountinfo:1;
81         bool from_fragment:1;
82
83         /* Used while looking for mount points that vanished or got
84          * added from/to /proc/self/mountinfo */
85         bool is_mounted:1;
86         bool just_mounted:1;
87         bool just_changed:1;
88
89         MountResult result;
90         MountResult reload_result;
91
92         mode_t directory_mode;
93
94         usec_t timeout_usec;
95
96         ExecCommand exec_command[_MOUNT_EXEC_COMMAND_MAX];
97         ExecContext exec_context;
98
99         MountState state, deserialized_state;
100
101         ExecCommand* control_command;
102         MountExecCommand control_command_id;
103         pid_t control_pid;
104
105         Watch timer_watch;
106 };
107
108 extern const UnitVTable mount_vtable;
109
110 void mount_fd_event(Manager *m, int events);
111
112 const char* mount_state_to_string(MountState i);
113 MountState mount_state_from_string(const char *s);
114
115 const char* mount_exec_command_to_string(MountExecCommand i);
116 MountExecCommand mount_exec_command_from_string(const char *s);
117
118 const char* mount_result_to_string(MountResult i);
119 MountResult mount_result_from_string(const char *s);