| 1 |
/* SPDX-License-Identifier: LGPL-2.1-or-later */ |
| 2 |
#pragma once |
| 3 |
|
| 4 |
#include "cgroup.h" |
| 5 |
#include "core-forward.h" |
| 6 |
#include "execute.h" |
| 7 |
#include "kill.h" |
| 8 |
#include "pidref.h" |
| 9 |
#include "unit.h" |
| 10 |
|
| 11 |
typedef enum MountExecCommand { |
| 12 |
MOUNT_EXEC_MOUNT, |
| 13 |
MOUNT_EXEC_UNMOUNT, |
| 14 |
MOUNT_EXEC_REMOUNT, |
| 15 |
_MOUNT_EXEC_COMMAND_MAX, |
| 16 |
_MOUNT_EXEC_COMMAND_INVALID = -EINVAL, |
| 17 |
} MountExecCommand; |
| 18 |
|
| 19 |
typedef enum MountResult { |
| 20 |
MOUNT_SUCCESS, |
| 21 |
MOUNT_FAILURE_RESOURCES, /* a bit of a misnomer, just our catch-all error for errnos we didn't expect */ |
| 22 |
MOUNT_FAILURE_TIMEOUT, |
| 23 |
MOUNT_FAILURE_EXIT_CODE, |
| 24 |
MOUNT_FAILURE_SIGNAL, |
| 25 |
MOUNT_FAILURE_CORE_DUMP, |
| 26 |
MOUNT_FAILURE_START_LIMIT_HIT, |
| 27 |
MOUNT_FAILURE_PROTOCOL, |
| 28 |
_MOUNT_RESULT_MAX, |
| 29 |
_MOUNT_RESULT_INVALID = -EINVAL, |
| 30 |
} MountResult; |
| 31 |
|
| 32 |
typedef struct MountParameters { |
| 33 |
char *what; |
| 34 |
char *options; |
| 35 |
char *fstype; |
| 36 |
} MountParameters; |
| 37 |
|
| 38 |
/* Used while looking for mount points that vanished or got added from/to /proc/self/mountinfo */ |
| 39 |
typedef enum MountProcFlags { |
| 40 |
MOUNT_PROC_IS_MOUNTED = 1 << 0, |
| 41 |
MOUNT_PROC_JUST_MOUNTED = 1 << 1, |
| 42 |
MOUNT_PROC_JUST_CHANGED = 1 << 2, |
| 43 |
} MountProcFlags; |
| 44 |
|
| 45 |
typedef struct Mount { |
| 46 |
Unit meta; |
| 47 |
|
| 48 |
char *where; |
| 49 |
|
| 50 |
MountParameters parameters_proc_self_mountinfo; |
| 51 |
MountParameters parameters_fragment; |
| 52 |
|
| 53 |
bool from_proc_self_mountinfo:1; |
| 54 |
bool from_fragment:1; |
| 55 |
|
| 56 |
MountProcFlags proc_flags; |
| 57 |
|
| 58 |
bool sloppy_options; |
| 59 |
|
| 60 |
bool lazy_unmount; |
| 61 |
bool force_unmount; |
| 62 |
|
| 63 |
bool read_write_only; |
| 64 |
|
| 65 |
MountResult result; |
| 66 |
MountResult reload_result; |
| 67 |
MountResult clean_result; |
| 68 |
|
| 69 |
mode_t directory_mode; |
| 70 |
|
| 71 |
usec_t timeout_usec; |
| 72 |
|
| 73 |
ExecCommand exec_command[_MOUNT_EXEC_COMMAND_MAX]; |
| 74 |
|
| 75 |
ExecContext exec_context; |
| 76 |
KillContext kill_context; |
| 77 |
CGroupContext cgroup_context; |
| 78 |
|
| 79 |
ExecRuntime *exec_runtime; |
| 80 |
CGroupRuntime *cgroup_runtime; |
| 81 |
|
| 82 |
MountState state, deserialized_state; |
| 83 |
|
| 84 |
ExecCommand *control_command; |
| 85 |
MountExecCommand control_command_id; |
| 86 |
PidRef control_pid; |
| 87 |
|
| 88 |
sd_event_source *timer_event_source; |
| 89 |
|
| 90 |
unsigned n_retry_umount; |
| 91 |
} Mount; |
| 92 |
|
| 93 |
extern const UnitVTable mount_vtable; |
| 94 |
|
| 95 |
void mount_fd_event(Manager *m, int events); |
| 96 |
|
| 97 |
char* mount_get_where_escaped(const Mount *m); |
| 98 |
char* mount_get_what_escaped(const Mount *m); |
| 99 |
char* mount_get_options_escaped(const Mount *m); |
| 100 |
const char* mount_get_fstype(const Mount *m); |
| 101 |
|
| 102 |
DECLARE_STRING_TABLE_LOOKUP(mount_exec_command, MountExecCommand); |
| 103 |
|
| 104 |
DECLARE_STRING_TABLE_LOOKUP(mount_result, MountResult); |
| 105 |
|
| 106 |
DEFINE_CAST(MOUNT, Mount); |