1 /*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
4 This file is part of systemd.
6 Copyright 2010 Lennart Poettering
8 systemd is free software; you can redistribute it and/or modify it
9 under the terms of the GNU Lesser General Public License as published by
10 the Free Software Foundation; either version 2.1 of the License, or
11 (at your option) any later version.
13 systemd is distributed in the hope that it will be useful, but
14 WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 Lesser General Public License for more details.
18 You should have received a copy of the GNU Lesser General Public License
19 along with systemd; If not, see <http://www.gnu.org/licenses/>.
25 #include <sys/epoll.h>
28 #include <sys/inotify.h>
33 #include "load-fragment.h"
34 #include "load-dropin.h"
36 #include "sd-messages.h"
39 #include "path-util.h"
40 #include "mount-setup.h"
41 #include "unit-name.h"
42 #include "dbus-mount.h"
44 #include "bus-common-errors.h"
45 #include "exit-status.h"
47 #include "fstab-util.h"
49 #define RETRY_UMOUNT_MAX 32
51 DEFINE_TRIVIAL_CLEANUP_FUNC(struct libmnt_table*, mnt_free_table);
52 DEFINE_TRIVIAL_CLEANUP_FUNC(struct libmnt_iter*, mnt_free_iter);
54 static const UnitActiveState state_translation_table[_MOUNT_STATE_MAX] = {
55 [MOUNT_DEAD] = UNIT_INACTIVE,
56 [MOUNT_MOUNTING] = UNIT_ACTIVATING,
57 [MOUNT_MOUNTING_DONE] = UNIT_ACTIVE,
58 [MOUNT_MOUNTED] = UNIT_ACTIVE,
59 [MOUNT_REMOUNTING] = UNIT_RELOADING,
60 [MOUNT_UNMOUNTING] = UNIT_DEACTIVATING,
61 [MOUNT_MOUNTING_SIGTERM] = UNIT_DEACTIVATING,
62 [MOUNT_MOUNTING_SIGKILL] = UNIT_DEACTIVATING,
63 [MOUNT_REMOUNTING_SIGTERM] = UNIT_RELOADING,
64 [MOUNT_REMOUNTING_SIGKILL] = UNIT_RELOADING,
65 [MOUNT_UNMOUNTING_SIGTERM] = UNIT_DEACTIVATING,
66 [MOUNT_UNMOUNTING_SIGKILL] = UNIT_DEACTIVATING,
67 [MOUNT_FAILED] = UNIT_FAILED
70 static int mount_dispatch_timer(sd_event_source *source, usec_t usec, void *userdata);
71 static int mount_dispatch_io(sd_event_source *source, int fd, uint32_t revents, void *userdata);
73 static bool mount_needs_network(const char *options, const char *fstype) {
74 if (fstab_test_option(options, "_netdev\0"))
77 if (fstype && fstype_is_network(fstype))
83 static bool mount_is_network(const MountParameters *p) {
86 return mount_needs_network(p->options, p->fstype);
89 static bool mount_is_bind(const MountParameters *p) {
92 if (fstab_test_option(p->options, "bind\0" "rbind\0"))
95 if (p->fstype && STR_IN_SET(p->fstype, "bind", "rbind"))
101 static bool mount_is_auto(const MountParameters *p) {
104 return !fstab_test_option(p->options, "noauto\0");
107 static bool needs_quota(const MountParameters *p) {
110 if (mount_is_network(p))
113 if (mount_is_bind(p))
116 return fstab_test_option(p->options,
117 "usrquota\0" "grpquota\0" "quota\0" "usrjquota\0" "grpjquota\0");
120 static void mount_init(Unit *u) {
124 assert(u->load_state == UNIT_STUB);
126 m->timeout_usec = u->manager->default_timeout_start_usec;
127 m->directory_mode = 0755;
129 if (unit_has_name(u, "-.mount")) {
130 /* Don't allow start/stop for root directory */
131 u->refuse_manual_start = true;
132 u->refuse_manual_stop = true;
134 /* The stdio/kmsg bridge socket is on /, in order to avoid a
135 * dep loop, don't use kmsg logging for -.mount */
136 m->exec_context.std_output = u->manager->default_std_output;
137 m->exec_context.std_error = u->manager->default_std_error;
140 /* We need to make sure that /bin/mount is always called in
141 * the same process group as us, so that the autofs kernel
142 * side doesn't send us another mount request while we are
143 * already trying to comply its last one. */
144 m->exec_context.same_pgrp = true;
146 m->control_command_id = _MOUNT_EXEC_COMMAND_INVALID;
148 u->ignore_on_isolate = true;
151 static int mount_arm_timer(Mount *m) {
156 if (m->timeout_usec <= 0) {
157 m->timer_event_source = sd_event_source_unref(m->timer_event_source);
161 if (m->timer_event_source) {
162 r = sd_event_source_set_time(m->timer_event_source, now(CLOCK_MONOTONIC) + m->timeout_usec);
166 return sd_event_source_set_enabled(m->timer_event_source, SD_EVENT_ONESHOT);
169 return sd_event_add_time(
170 UNIT(m)->manager->event,
171 &m->timer_event_source,
173 now(CLOCK_MONOTONIC) + m->timeout_usec, 0,
174 mount_dispatch_timer, m);
177 static void mount_unwatch_control_pid(Mount *m) {
180 if (m->control_pid <= 0)
183 unit_unwatch_pid(UNIT(m), m->control_pid);
187 static void mount_parameters_done(MountParameters *p) {
194 p->what = p->options = p->fstype = NULL;
197 static void mount_done(Unit *u) {
205 mount_parameters_done(&m->parameters_proc_self_mountinfo);
206 mount_parameters_done(&m->parameters_fragment);
208 m->exec_runtime = exec_runtime_unref(m->exec_runtime);
209 exec_command_done_array(m->exec_command, _MOUNT_EXEC_COMMAND_MAX);
210 m->control_command = NULL;
212 mount_unwatch_control_pid(m);
214 m->timer_event_source = sd_event_source_unref(m->timer_event_source);
217 _pure_ static MountParameters* get_mount_parameters_fragment(Mount *m) {
220 if (m->from_fragment)
221 return &m->parameters_fragment;
226 _pure_ static MountParameters* get_mount_parameters(Mount *m) {
229 if (m->from_proc_self_mountinfo)
230 return &m->parameters_proc_self_mountinfo;
232 return get_mount_parameters_fragment(m);
235 static int mount_add_mount_links(Mount *m) {
236 _cleanup_free_ char *parent = NULL;
245 if (!path_equal(m->where, "/")) {
246 /* Adds in links to other mount points that might lie further
247 * up in the hierarchy */
248 r = path_get_parent(m->where, &parent);
252 r = unit_require_mounts_for(UNIT(m), parent);
257 /* Adds in links to other mount points that might be needed
258 * for the source path (if this is a bind mount) to be
260 pm = get_mount_parameters_fragment(m);
261 if (pm && pm->what &&
262 path_is_absolute(pm->what) &&
263 !mount_is_network(pm)) {
265 r = unit_require_mounts_for(UNIT(m), pm->what);
270 /* Adds in links to other units that use this path or paths
271 * further down in the hierarchy */
272 s = manager_get_units_requiring_mounts_for(UNIT(m)->manager, m->where);
273 SET_FOREACH(other, s, i) {
275 if (other->load_state != UNIT_LOADED)
278 if (other == UNIT(m))
281 r = unit_add_dependency(other, UNIT_AFTER, UNIT(m), true);
285 if (UNIT(m)->fragment_path) {
286 /* If we have fragment configuration, then make this dependency required */
287 r = unit_add_dependency(other, UNIT_REQUIRES, UNIT(m), true);
296 static int mount_add_device_links(Mount *m) {
298 bool device_wants_mount = false;
303 p = get_mount_parameters(m);
310 if (mount_is_bind(p))
313 if (!is_device_path(p->what))
316 if (path_equal(m->where, "/"))
319 if (mount_is_auto(p) && UNIT(m)->manager->running_as == SYSTEMD_SYSTEM)
320 device_wants_mount = true;
322 r = unit_add_node_link(UNIT(m), p->what, device_wants_mount);
329 static int mount_add_quota_links(Mount *m) {
335 if (UNIT(m)->manager->running_as != SYSTEMD_SYSTEM)
338 p = get_mount_parameters_fragment(m);
345 r = unit_add_two_dependencies_by_name(UNIT(m), UNIT_BEFORE, UNIT_WANTS, SPECIAL_QUOTACHECK_SERVICE, NULL, true);
349 r = unit_add_two_dependencies_by_name(UNIT(m), UNIT_BEFORE, UNIT_WANTS, SPECIAL_QUOTAON_SERVICE, NULL, true);
356 static bool should_umount(Mount *m) {
359 if (path_equal(m->where, "/") ||
360 path_equal(m->where, "/usr"))
363 p = get_mount_parameters(m);
364 if (p && fstab_test_option(p->options, "x-initrd.mount\0") &&
371 static int mount_add_default_dependencies(Mount *m) {
372 const char *after, *after2, *online;
378 if (UNIT(m)->manager->running_as != SYSTEMD_SYSTEM)
381 /* We do not add any default dependencies to / and /usr, since
382 * they are guaranteed to stay mounted the whole time, since
383 * our system is on it. Also, don't bother with anything
384 * mounted below virtual file systems, it's also going to be
385 * virtual, and hence not worth the effort. */
386 if (path_equal(m->where, "/") ||
387 path_equal(m->where, "/usr") ||
388 path_startswith(m->where, "/proc") ||
389 path_startswith(m->where, "/sys") ||
390 path_startswith(m->where, "/dev"))
393 p = get_mount_parameters(m);
397 if (mount_is_network(p)) {
398 after = SPECIAL_REMOTE_FS_PRE_TARGET;
399 after2 = SPECIAL_NETWORK_TARGET;
400 online = SPECIAL_NETWORK_ONLINE_TARGET;
402 after = SPECIAL_LOCAL_FS_PRE_TARGET;
407 r = unit_add_dependency_by_name(UNIT(m), UNIT_AFTER, after, NULL, true);
412 r = unit_add_dependency_by_name(UNIT(m), UNIT_AFTER, after2, NULL, true);
418 r = unit_add_two_dependencies_by_name(UNIT(m), UNIT_WANTS, UNIT_AFTER, online, NULL, true);
423 if (should_umount(m)) {
424 r = unit_add_two_dependencies_by_name(UNIT(m), UNIT_BEFORE, UNIT_CONFLICTS, SPECIAL_UMOUNT_TARGET, NULL, true);
432 static int mount_verify(Mount *m) {
433 _cleanup_free_ char *e = NULL;
438 if (UNIT(m)->load_state != UNIT_LOADED)
441 if (!m->from_fragment && !m->from_proc_self_mountinfo)
444 e = unit_name_from_path(m->where, ".mount");
448 b = unit_has_name(UNIT(m), e);
450 log_unit_error(UNIT(m)->id, "%s's Where= setting doesn't match unit name. Refusing.", UNIT(m)->id);
454 if (mount_point_is_api(m->where) || mount_point_ignore(m->where)) {
455 log_unit_error(UNIT(m)->id, "Cannot create mount unit for API file system %s. Refusing.", m->where);
459 if (UNIT(m)->fragment_path && !m->parameters_fragment.what) {
460 log_unit_error(UNIT(m)->id, "%s's What setting is missing. Refusing.", UNIT(m)->id);
464 if (m->exec_context.pam_name && m->kill_context.kill_mode != KILL_CONTROL_GROUP) {
465 log_unit_error(UNIT(m)->id, "%s has PAM enabled. Kill mode must be set to control-group'. Refusing.",UNIT(m)->id);
472 static int mount_add_extras(Mount *m) {
478 if (u->fragment_path)
479 m->from_fragment = true;
482 m->where = unit_name_to_path(u->id);
487 path_kill_slashes(m->where);
489 if (!u->description) {
490 r = unit_set_description(u, m->where);
495 r = mount_add_device_links(m);
499 r = mount_add_mount_links(m);
503 r = mount_add_quota_links(m);
507 r = unit_patch_contexts(u);
511 r = unit_add_exec_dependencies(u, &m->exec_context);
515 r = unit_add_default_slice(u, &m->cgroup_context);
519 if (u->default_dependencies) {
520 r = mount_add_default_dependencies(m);
528 static int mount_load(Unit *u) {
533 assert(u->load_state == UNIT_STUB);
535 if (m->from_proc_self_mountinfo)
536 r = unit_load_fragment_and_dropin_optional(u);
538 r = unit_load_fragment_and_dropin(u);
543 /* This is a new unit? Then let's add in some extras */
544 if (u->load_state == UNIT_LOADED) {
545 r = mount_add_extras(m);
550 return mount_verify(m);
553 static int mount_notify_automount(Mount *m, int status) {
560 SET_FOREACH(p, UNIT(m)->dependencies[UNIT_TRIGGERED_BY], i)
561 if (p->type == UNIT_AUTOMOUNT) {
562 r = automount_send_ready(AUTOMOUNT(p), status);
570 static void mount_set_state(Mount *m, MountState state) {
571 MountState old_state;
574 old_state = m->state;
577 if (state != MOUNT_MOUNTING &&
578 state != MOUNT_MOUNTING_DONE &&
579 state != MOUNT_REMOUNTING &&
580 state != MOUNT_UNMOUNTING &&
581 state != MOUNT_MOUNTING_SIGTERM &&
582 state != MOUNT_MOUNTING_SIGKILL &&
583 state != MOUNT_UNMOUNTING_SIGTERM &&
584 state != MOUNT_UNMOUNTING_SIGKILL &&
585 state != MOUNT_REMOUNTING_SIGTERM &&
586 state != MOUNT_REMOUNTING_SIGKILL) {
587 m->timer_event_source = sd_event_source_unref(m->timer_event_source);
588 mount_unwatch_control_pid(m);
589 m->control_command = NULL;
590 m->control_command_id = _MOUNT_EXEC_COMMAND_INVALID;
593 if (state == MOUNT_MOUNTED ||
594 state == MOUNT_REMOUNTING)
595 mount_notify_automount(m, 0);
596 else if (state == MOUNT_DEAD ||
597 state == MOUNT_UNMOUNTING ||
598 state == MOUNT_MOUNTING_SIGTERM ||
599 state == MOUNT_MOUNTING_SIGKILL ||
600 state == MOUNT_REMOUNTING_SIGTERM ||
601 state == MOUNT_REMOUNTING_SIGKILL ||
602 state == MOUNT_UNMOUNTING_SIGTERM ||
603 state == MOUNT_UNMOUNTING_SIGKILL ||
604 state == MOUNT_FAILED) {
605 if (state != old_state)
606 mount_notify_automount(m, -ENODEV);
609 if (state != old_state)
610 log_unit_debug(UNIT(m)->id,
611 "%s changed %s -> %s",
613 mount_state_to_string(old_state),
614 mount_state_to_string(state));
616 unit_notify(UNIT(m), state_translation_table[old_state], state_translation_table[state], m->reload_result == MOUNT_SUCCESS);
617 m->reload_result = MOUNT_SUCCESS;
620 static int mount_coldplug(Unit *u) {
622 MountState new_state = MOUNT_DEAD;
626 assert(m->state == MOUNT_DEAD);
628 if (m->deserialized_state != m->state)
629 new_state = m->deserialized_state;
630 else if (m->from_proc_self_mountinfo)
631 new_state = MOUNT_MOUNTED;
633 if (new_state == m->state)
636 if (new_state == MOUNT_MOUNTING ||
637 new_state == MOUNT_MOUNTING_DONE ||
638 new_state == MOUNT_REMOUNTING ||
639 new_state == MOUNT_UNMOUNTING ||
640 new_state == MOUNT_MOUNTING_SIGTERM ||
641 new_state == MOUNT_MOUNTING_SIGKILL ||
642 new_state == MOUNT_UNMOUNTING_SIGTERM ||
643 new_state == MOUNT_UNMOUNTING_SIGKILL ||
644 new_state == MOUNT_REMOUNTING_SIGTERM ||
645 new_state == MOUNT_REMOUNTING_SIGKILL) {
647 if (m->control_pid <= 0)
650 r = unit_watch_pid(UNIT(m), m->control_pid);
654 r = mount_arm_timer(m);
659 mount_set_state(m, new_state);
663 static void mount_dump(Unit *u, FILE *f, const char *prefix) {
670 p = get_mount_parameters(m);
673 "%sMount State: %s\n"
677 "%sFile System Type: %s\n"
679 "%sFrom /proc/self/mountinfo: %s\n"
680 "%sFrom fragment: %s\n"
681 "%sDirectoryMode: %04o\n",
682 prefix, mount_state_to_string(m->state),
683 prefix, mount_result_to_string(m->result),
685 prefix, p ? strna(p->what) : "n/a",
686 prefix, p ? strna(p->fstype) : "n/a",
687 prefix, p ? strna(p->options) : "n/a",
688 prefix, yes_no(m->from_proc_self_mountinfo),
689 prefix, yes_no(m->from_fragment),
690 prefix, m->directory_mode);
692 if (m->control_pid > 0)
694 "%sControl PID: "PID_FMT"\n",
695 prefix, m->control_pid);
697 exec_context_dump(&m->exec_context, f, prefix);
698 kill_context_dump(&m->kill_context, f, prefix);
701 static int mount_spawn(Mount *m, ExecCommand *c, pid_t *_pid) {
704 ExecParameters exec_params = {
705 .apply_permissions = true,
706 .apply_chroot = true,
707 .apply_tty_stdin = true,
714 unit_realize_cgroup(UNIT(m));
716 r = unit_setup_exec_runtime(UNIT(m));
720 r = mount_arm_timer(m);
724 exec_params.environment = UNIT(m)->manager->environment;
725 exec_params.confirm_spawn = UNIT(m)->manager->confirm_spawn;
726 exec_params.cgroup_supported = UNIT(m)->manager->cgroup_supported;
727 exec_params.cgroup_path = UNIT(m)->cgroup_path;
728 exec_params.cgroup_delegate = m->cgroup_context.delegate;
729 exec_params.runtime_prefix = manager_get_runtime_prefix(UNIT(m)->manager);
730 exec_params.unit_id = UNIT(m)->id;
740 r = unit_watch_pid(UNIT(m), pid);
742 /* FIXME: we need to do something here */
750 m->timer_event_source = sd_event_source_unref(m->timer_event_source);
755 static void mount_enter_dead(Mount *m, MountResult f) {
758 if (f != MOUNT_SUCCESS)
761 exec_runtime_destroy(m->exec_runtime);
762 m->exec_runtime = exec_runtime_unref(m->exec_runtime);
764 exec_context_destroy_runtime_directory(&m->exec_context, manager_get_runtime_prefix(UNIT(m)->manager));
766 mount_set_state(m, m->result != MOUNT_SUCCESS ? MOUNT_FAILED : MOUNT_DEAD);
769 static void mount_enter_mounted(Mount *m, MountResult f) {
772 if (f != MOUNT_SUCCESS)
775 mount_set_state(m, MOUNT_MOUNTED);
778 static void mount_enter_signal(Mount *m, MountState state, MountResult f) {
783 if (f != MOUNT_SUCCESS)
786 r = unit_kill_context(
789 (state != MOUNT_MOUNTING_SIGTERM && state != MOUNT_UNMOUNTING_SIGTERM && state != MOUNT_REMOUNTING_SIGTERM) ?
790 KILL_KILL : KILL_TERMINATE,
798 r = mount_arm_timer(m);
802 mount_set_state(m, state);
803 } else if (state == MOUNT_REMOUNTING_SIGTERM)
804 mount_enter_signal(m, MOUNT_REMOUNTING_SIGKILL, MOUNT_SUCCESS);
805 else if (state == MOUNT_REMOUNTING_SIGKILL)
806 mount_enter_mounted(m, MOUNT_SUCCESS);
807 else if (state == MOUNT_MOUNTING_SIGTERM)
808 mount_enter_signal(m, MOUNT_MOUNTING_SIGKILL, MOUNT_SUCCESS);
809 else if (state == MOUNT_UNMOUNTING_SIGTERM)
810 mount_enter_signal(m, MOUNT_UNMOUNTING_SIGKILL, MOUNT_SUCCESS);
812 mount_enter_dead(m, MOUNT_SUCCESS);
817 log_unit_warning(UNIT(m)->id,
818 "%s failed to kill processes: %s", UNIT(m)->id, strerror(-r));
820 if (state == MOUNT_REMOUNTING_SIGTERM || state == MOUNT_REMOUNTING_SIGKILL)
821 mount_enter_mounted(m, MOUNT_FAILURE_RESOURCES);
823 mount_enter_dead(m, MOUNT_FAILURE_RESOURCES);
826 void warn_if_dir_nonempty(const char *unit, const char* where) {
832 r = dir_is_empty(where);
836 log_unit_struct(unit,
838 LOG_MESSAGE_ID(SD_MESSAGE_OVERMOUNTING),
839 LOG_MESSAGE("%s: Directory %s to mount over is not empty, mounting anyway.",
844 log_unit_warning(unit,
845 "MESSAGE=Failed to check directory %s: %s",
846 where, strerror(-r));
849 static int fail_if_symlink(const char *unit, const char* where) {
852 if (is_symlink(where) > 0) {
853 log_unit_struct(unit,
855 LOG_MESSAGE_ID(SD_MESSAGE_OVERMOUNTING),
856 LOG_MESSAGE("%s: Mount on symlink %s not allowed.",
866 static void mount_enter_unmounting(Mount *m) {
871 /* Start counting our attempts */
872 if (!IN_SET(m->state,
874 MOUNT_UNMOUNTING_SIGTERM,
875 MOUNT_UNMOUNTING_SIGKILL))
876 m->n_retry_umount = 0;
878 m->control_command_id = MOUNT_EXEC_UNMOUNT;
879 m->control_command = m->exec_command + MOUNT_EXEC_UNMOUNT;
881 r = exec_command_set(m->control_command, "/bin/umount", m->where, NULL);
882 if (r >= 0 && UNIT(m)->manager->running_as == SYSTEMD_SYSTEM)
883 r = exec_command_append(m->control_command, "-n", NULL);
887 mount_unwatch_control_pid(m);
889 r = mount_spawn(m, m->control_command, &m->control_pid);
893 mount_set_state(m, MOUNT_UNMOUNTING);
898 log_unit_warning(UNIT(m)->id,
899 "%s failed to run 'umount' task: %s",
900 UNIT(m)->id, strerror(-r));
901 mount_enter_mounted(m, MOUNT_FAILURE_RESOURCES);
904 static void mount_enter_mounting(Mount *m) {
910 m->control_command_id = MOUNT_EXEC_MOUNT;
911 m->control_command = m->exec_command + MOUNT_EXEC_MOUNT;
913 mkdir_p_label(m->where, m->directory_mode);
915 warn_if_dir_nonempty(m->meta.id, m->where);
917 /* Create the source directory for bind-mounts if needed */
918 p = get_mount_parameters_fragment(m);
919 if (p && mount_is_bind(p))
920 mkdir_p_label(p->what, m->directory_mode);
922 r = fail_if_symlink(m->meta.id, m->where);
926 if (m->from_fragment) {
927 _cleanup_free_ char *opts = NULL;
929 r = fstab_filter_options(m->parameters_fragment.options,
930 "nofail\0" "noauto\0" "auto\0", NULL, NULL, &opts);
934 r = exec_command_set(m->control_command, "/bin/mount",
935 m->parameters_fragment.what, m->where, NULL);
936 if (r >= 0 && UNIT(m)->manager->running_as == SYSTEMD_SYSTEM)
937 r = exec_command_append(m->control_command, "-n", NULL);
938 if (r >= 0 && m->sloppy_options)
939 r = exec_command_append(m->control_command, "-s", NULL);
940 if (r >= 0 && m->parameters_fragment.fstype)
941 r = exec_command_append(m->control_command, "-t", m->parameters_fragment.fstype, NULL);
942 if (r >= 0 && !isempty(opts))
943 r = exec_command_append(m->control_command, "-o", opts, NULL);
950 mount_unwatch_control_pid(m);
952 r = mount_spawn(m, m->control_command, &m->control_pid);
956 mount_set_state(m, MOUNT_MOUNTING);
961 log_unit_warning(UNIT(m)->id,
962 "%s failed to run 'mount' task: %s",
963 UNIT(m)->id, strerror(-r));
964 mount_enter_dead(m, MOUNT_FAILURE_RESOURCES);
967 static void mount_enter_remounting(Mount *m) {
972 m->control_command_id = MOUNT_EXEC_REMOUNT;
973 m->control_command = m->exec_command + MOUNT_EXEC_REMOUNT;
975 if (m->from_fragment) {
978 if (m->parameters_fragment.options)
979 o = strjoina("remount,", m->parameters_fragment.options);
983 r = exec_command_set(m->control_command, "/bin/mount",
984 m->parameters_fragment.what, m->where,
986 if (r >= 0 && UNIT(m)->manager->running_as == SYSTEMD_SYSTEM)
987 r = exec_command_append(m->control_command, "-n", NULL);
988 if (r >= 0 && m->sloppy_options)
989 r = exec_command_append(m->control_command, "-s", NULL);
990 if (r >= 0 && m->parameters_fragment.fstype)
991 r = exec_command_append(m->control_command, "-t", m->parameters_fragment.fstype, NULL);
998 mount_unwatch_control_pid(m);
1000 r = mount_spawn(m, m->control_command, &m->control_pid);
1004 mount_set_state(m, MOUNT_REMOUNTING);
1009 log_unit_warning(UNIT(m)->id,
1010 "%s failed to run 'remount' task: %s",
1011 UNIT(m)->id, strerror(-r));
1012 m->reload_result = MOUNT_FAILURE_RESOURCES;
1013 mount_enter_mounted(m, MOUNT_SUCCESS);
1016 static int mount_start(Unit *u) {
1017 Mount *m = MOUNT(u);
1021 /* We cannot fulfill this request right now, try again later
1023 if (m->state == MOUNT_UNMOUNTING ||
1024 m->state == MOUNT_UNMOUNTING_SIGTERM ||
1025 m->state == MOUNT_UNMOUNTING_SIGKILL ||
1026 m->state == MOUNT_MOUNTING_SIGTERM ||
1027 m->state == MOUNT_MOUNTING_SIGKILL)
1030 /* Already on it! */
1031 if (m->state == MOUNT_MOUNTING)
1034 assert(m->state == MOUNT_DEAD || m->state == MOUNT_FAILED);
1036 m->result = MOUNT_SUCCESS;
1037 m->reload_result = MOUNT_SUCCESS;
1039 mount_enter_mounting(m);
1043 static int mount_stop(Unit *u) {
1044 Mount *m = MOUNT(u);
1049 if (m->state == MOUNT_UNMOUNTING ||
1050 m->state == MOUNT_UNMOUNTING_SIGKILL ||
1051 m->state == MOUNT_UNMOUNTING_SIGTERM ||
1052 m->state == MOUNT_MOUNTING_SIGTERM ||
1053 m->state == MOUNT_MOUNTING_SIGKILL)
1056 assert(m->state == MOUNT_MOUNTING ||
1057 m->state == MOUNT_MOUNTING_DONE ||
1058 m->state == MOUNT_MOUNTED ||
1059 m->state == MOUNT_REMOUNTING ||
1060 m->state == MOUNT_REMOUNTING_SIGTERM ||
1061 m->state == MOUNT_REMOUNTING_SIGKILL);
1063 mount_enter_unmounting(m);
1067 static int mount_reload(Unit *u) {
1068 Mount *m = MOUNT(u);
1072 if (m->state == MOUNT_MOUNTING_DONE)
1075 assert(m->state == MOUNT_MOUNTED);
1077 mount_enter_remounting(m);
1081 static int mount_serialize(Unit *u, FILE *f, FDSet *fds) {
1082 Mount *m = MOUNT(u);
1088 unit_serialize_item(u, f, "state", mount_state_to_string(m->state));
1089 unit_serialize_item(u, f, "result", mount_result_to_string(m->result));
1090 unit_serialize_item(u, f, "reload-result", mount_result_to_string(m->reload_result));
1092 if (m->control_pid > 0)
1093 unit_serialize_item_format(u, f, "control-pid", PID_FMT, m->control_pid);
1095 if (m->control_command_id >= 0)
1096 unit_serialize_item(u, f, "control-command", mount_exec_command_to_string(m->control_command_id));
1101 static int mount_deserialize_item(Unit *u, const char *key, const char *value, FDSet *fds) {
1102 Mount *m = MOUNT(u);
1109 if (streq(key, "state")) {
1112 if ((state = mount_state_from_string(value)) < 0)
1113 log_unit_debug(u->id, "Failed to parse state value %s", value);
1115 m->deserialized_state = state;
1116 } else if (streq(key, "result")) {
1119 f = mount_result_from_string(value);
1121 log_unit_debug(UNIT(m)->id,
1122 "Failed to parse result value %s", value);
1123 else if (f != MOUNT_SUCCESS)
1126 } else if (streq(key, "reload-result")) {
1129 f = mount_result_from_string(value);
1131 log_unit_debug(UNIT(m)->id,
1132 "Failed to parse reload result value %s", value);
1133 else if (f != MOUNT_SUCCESS)
1134 m->reload_result = f;
1136 } else if (streq(key, "control-pid")) {
1139 if (parse_pid(value, &pid) < 0)
1140 log_unit_debug(UNIT(m)->id,
1141 "Failed to parse control-pid value %s", value);
1143 m->control_pid = pid;
1144 } else if (streq(key, "control-command")) {
1145 MountExecCommand id;
1147 if ((id = mount_exec_command_from_string(value)) < 0)
1148 log_unit_debug(UNIT(m)->id,
1149 "Failed to parse exec-command value %s", value);
1151 m->control_command_id = id;
1152 m->control_command = m->exec_command + id;
1155 log_unit_debug(UNIT(m)->id,
1156 "Unknown serialization key '%s'", key);
1161 _pure_ static UnitActiveState mount_active_state(Unit *u) {
1164 return state_translation_table[MOUNT(u)->state];
1167 _pure_ static const char *mount_sub_state_to_string(Unit *u) {
1170 return mount_state_to_string(MOUNT(u)->state);
1173 _pure_ static bool mount_check_gc(Unit *u) {
1174 Mount *m = MOUNT(u);
1178 return m->from_proc_self_mountinfo;
1181 static void mount_sigchld_event(Unit *u, pid_t pid, int code, int status) {
1182 Mount *m = MOUNT(u);
1188 if (pid != m->control_pid)
1193 if (is_clean_exit(code, status, NULL))
1195 else if (code == CLD_EXITED)
1196 f = MOUNT_FAILURE_EXIT_CODE;
1197 else if (code == CLD_KILLED)
1198 f = MOUNT_FAILURE_SIGNAL;
1199 else if (code == CLD_DUMPED)
1200 f = MOUNT_FAILURE_CORE_DUMP;
1202 assert_not_reached("Unknown code");
1204 if (f != MOUNT_SUCCESS)
1207 if (m->control_command) {
1208 exec_status_exit(&m->control_command->exec_status, &m->exec_context, pid, code, status);
1210 m->control_command = NULL;
1211 m->control_command_id = _MOUNT_EXEC_COMMAND_INVALID;
1214 log_unit_full(u->id,
1215 f == MOUNT_SUCCESS ? LOG_DEBUG : LOG_NOTICE,
1216 "%s mount process exited, code=%s status=%i",
1217 u->id, sigchld_code_to_string(code), status);
1219 /* Note that mount(8) returning and the kernel sending us a
1220 * mount table change event might happen out-of-order. If an
1221 * operation succeed we assume the kernel will follow soon too
1222 * and already change into the resulting state. If it fails
1223 * we check if the kernel still knows about the mount. and
1224 * change state accordingly. */
1228 case MOUNT_MOUNTING:
1229 case MOUNT_MOUNTING_DONE:
1230 case MOUNT_MOUNTING_SIGKILL:
1231 case MOUNT_MOUNTING_SIGTERM:
1233 if (f == MOUNT_SUCCESS)
1234 mount_enter_mounted(m, f);
1235 else if (m->from_proc_self_mountinfo)
1236 mount_enter_mounted(m, f);
1238 mount_enter_dead(m, f);
1241 case MOUNT_REMOUNTING:
1242 case MOUNT_REMOUNTING_SIGKILL:
1243 case MOUNT_REMOUNTING_SIGTERM:
1245 m->reload_result = f;
1246 if (m->from_proc_self_mountinfo)
1247 mount_enter_mounted(m, MOUNT_SUCCESS);
1249 mount_enter_dead(m, MOUNT_SUCCESS);
1253 case MOUNT_UNMOUNTING:
1254 case MOUNT_UNMOUNTING_SIGKILL:
1255 case MOUNT_UNMOUNTING_SIGTERM:
1257 if (f == MOUNT_SUCCESS) {
1259 if (m->from_proc_self_mountinfo) {
1261 /* Still a mount point? If so, let's
1262 * try again. Most likely there were
1263 * multiple mount points stacked on
1264 * top of each other. Note that due to
1265 * the io event priority logic we can
1266 * be sure the new mountinfo is loaded
1267 * before we process the SIGCHLD for
1268 * the mount command. */
1270 if (m->n_retry_umount < RETRY_UMOUNT_MAX) {
1271 log_unit_debug(u->id, "%s: mount still present, trying again.", u->id);
1272 m->n_retry_umount++;
1273 mount_enter_unmounting(m);
1275 log_unit_debug(u->id, "%s: mount still present after %u attempts to unmount, giving up.", u->id, m->n_retry_umount);
1276 mount_enter_mounted(m, f);
1279 mount_enter_dead(m, f);
1281 } else if (m->from_proc_self_mountinfo)
1282 mount_enter_mounted(m, f);
1284 mount_enter_dead(m, f);
1288 assert_not_reached("Uh, control process died at wrong time.");
1291 /* Notify clients about changed exit status */
1292 unit_add_to_dbus_queue(u);
1295 static int mount_dispatch_timer(sd_event_source *source, usec_t usec, void *userdata) {
1296 Mount *m = MOUNT(userdata);
1299 assert(m->timer_event_source == source);
1303 case MOUNT_MOUNTING:
1304 case MOUNT_MOUNTING_DONE:
1305 log_unit_warning(UNIT(m)->id,
1306 "%s mounting timed out. Stopping.", UNIT(m)->id);
1307 mount_enter_signal(m, MOUNT_MOUNTING_SIGTERM, MOUNT_FAILURE_TIMEOUT);
1310 case MOUNT_REMOUNTING:
1311 log_unit_warning(UNIT(m)->id,
1312 "%s remounting timed out. Stopping.", UNIT(m)->id);
1313 m->reload_result = MOUNT_FAILURE_TIMEOUT;
1314 mount_enter_mounted(m, MOUNT_SUCCESS);
1317 case MOUNT_UNMOUNTING:
1318 log_unit_warning(UNIT(m)->id,
1319 "%s unmounting timed out. Stopping.", UNIT(m)->id);
1320 mount_enter_signal(m, MOUNT_UNMOUNTING_SIGTERM, MOUNT_FAILURE_TIMEOUT);
1323 case MOUNT_MOUNTING_SIGTERM:
1324 if (m->kill_context.send_sigkill) {
1325 log_unit_warning(UNIT(m)->id,
1326 "%s mounting timed out. Killing.", UNIT(m)->id);
1327 mount_enter_signal(m, MOUNT_MOUNTING_SIGKILL, MOUNT_FAILURE_TIMEOUT);
1329 log_unit_warning(UNIT(m)->id,
1330 "%s mounting timed out. Skipping SIGKILL. Ignoring.",
1333 if (m->from_proc_self_mountinfo)
1334 mount_enter_mounted(m, MOUNT_FAILURE_TIMEOUT);
1336 mount_enter_dead(m, MOUNT_FAILURE_TIMEOUT);
1340 case MOUNT_REMOUNTING_SIGTERM:
1341 if (m->kill_context.send_sigkill) {
1342 log_unit_warning(UNIT(m)->id,
1343 "%s remounting timed out. Killing.", UNIT(m)->id);
1344 mount_enter_signal(m, MOUNT_REMOUNTING_SIGKILL, MOUNT_FAILURE_TIMEOUT);
1346 log_unit_warning(UNIT(m)->id,
1347 "%s remounting timed out. Skipping SIGKILL. Ignoring.",
1350 if (m->from_proc_self_mountinfo)
1351 mount_enter_mounted(m, MOUNT_FAILURE_TIMEOUT);
1353 mount_enter_dead(m, MOUNT_FAILURE_TIMEOUT);
1357 case MOUNT_UNMOUNTING_SIGTERM:
1358 if (m->kill_context.send_sigkill) {
1359 log_unit_warning(UNIT(m)->id,
1360 "%s unmounting timed out. Killing.", UNIT(m)->id);
1361 mount_enter_signal(m, MOUNT_UNMOUNTING_SIGKILL, MOUNT_FAILURE_TIMEOUT);
1363 log_unit_warning(UNIT(m)->id,
1364 "%s unmounting timed out. Skipping SIGKILL. Ignoring.",
1367 if (m->from_proc_self_mountinfo)
1368 mount_enter_mounted(m, MOUNT_FAILURE_TIMEOUT);
1370 mount_enter_dead(m, MOUNT_FAILURE_TIMEOUT);
1374 case MOUNT_MOUNTING_SIGKILL:
1375 case MOUNT_REMOUNTING_SIGKILL:
1376 case MOUNT_UNMOUNTING_SIGKILL:
1377 log_unit_warning(UNIT(m)->id,
1378 "%s mount process still around after SIGKILL. Ignoring.",
1381 if (m->from_proc_self_mountinfo)
1382 mount_enter_mounted(m, MOUNT_FAILURE_TIMEOUT);
1384 mount_enter_dead(m, MOUNT_FAILURE_TIMEOUT);
1388 assert_not_reached("Timeout at wrong time.");
1394 static int mount_add_one(
1398 const char *options,
1402 _cleanup_free_ char *e = NULL, *w = NULL, *o = NULL, *f = NULL;
1403 bool load_extras = false;
1405 bool delete, changed = false;
1415 /* Ignore API mount points. They should never be referenced in
1416 * dependencies ever. */
1417 if (mount_point_is_api(where) || mount_point_ignore(where))
1420 if (streq(fstype, "autofs"))
1423 /* probably some kind of swap, ignore */
1424 if (!is_path(where))
1427 e = unit_name_from_path(where, ".mount");
1431 u = manager_get_unit(m, e);
1435 u = unit_new(m, sizeof(Mount));
1439 r = unit_add_name(u, e);
1443 MOUNT(u)->where = strdup(where);
1444 if (!MOUNT(u)->where) {
1449 u->source_path = strdup("/proc/self/mountinfo");
1450 if (!u->source_path) {
1455 if (m->running_as == SYSTEMD_SYSTEM) {
1458 target = mount_needs_network(options, fstype) ? SPECIAL_REMOTE_FS_TARGET : SPECIAL_LOCAL_FS_TARGET;
1459 r = unit_add_dependency_by_name(u, UNIT_BEFORE, target, NULL, true);
1463 if (should_umount(MOUNT(u))) {
1464 r = unit_add_dependency_by_name(u, UNIT_CONFLICTS, SPECIAL_UMOUNT_TARGET, NULL, true);
1470 unit_add_to_load_queue(u);
1475 if (!MOUNT(u)->where) {
1476 MOUNT(u)->where = strdup(where);
1477 if (!MOUNT(u)->where) {
1483 if (m->running_as == SYSTEMD_SYSTEM &&
1484 mount_needs_network(options, fstype)) {
1485 /* _netdev option may have shown up late, or on a
1486 * remount. Add remote-fs dependencies, even though
1487 * local-fs ones may already be there. */
1488 unit_add_dependency_by_name(u, UNIT_BEFORE, SPECIAL_REMOTE_FS_TARGET, NULL, true);
1492 if (u->load_state == UNIT_NOT_FOUND) {
1493 u->load_state = UNIT_LOADED;
1496 /* Load in the extras later on, after we
1497 * finished initialization of the unit */
1504 o = strdup(options);
1506 if (!w || !o || !f) {
1511 p = &MOUNT(u)->parameters_proc_self_mountinfo;
1513 changed = changed ||
1514 !streq_ptr(p->options, options) ||
1515 !streq_ptr(p->what, what) ||
1516 !streq_ptr(p->fstype, fstype);
1519 MOUNT(u)->is_mounted = true;
1520 MOUNT(u)->just_mounted = !MOUNT(u)->from_proc_self_mountinfo;
1521 MOUNT(u)->just_changed = changed;
1524 MOUNT(u)->from_proc_self_mountinfo = true;
1539 r = mount_add_extras(MOUNT(u));
1545 unit_add_to_dbus_queue(u);
1556 static int mount_load_proc_self_mountinfo(Manager *m, bool set_flags) {
1557 _cleanup_(mnt_free_tablep) struct libmnt_table *tb = NULL;
1558 _cleanup_(mnt_free_iterp) struct libmnt_iter *itr = NULL;
1559 struct libmnt_fs *fs;
1564 tb = mnt_new_table();
1565 itr = mnt_new_iter(MNT_ITER_FORWARD);
1569 r = mnt_table_parse_mtab(tb, NULL);
1575 const char *device, *path, *options, *fstype;
1576 _cleanup_free_ const char *d = NULL, *p = NULL;
1579 k = mnt_table_next_fs(tb, itr, &fs);
1583 return log_error_errno(k, "Failed to get next entry from /etc/fstab: %m");
1585 device = mnt_fs_get_source(fs);
1586 path = mnt_fs_get_target(fs);
1587 options = mnt_fs_get_options(fs);
1588 fstype = mnt_fs_get_fstype(fs);
1590 d = cunescape(device);
1591 p = cunescape(path);
1595 k = mount_add_one(m, d, p, options, fstype, set_flags);
1596 if (r == 0 && k < 0)
1603 static void mount_shutdown(Manager *m) {
1606 m->mount_event_source = sd_event_source_unref(m->mount_event_source);
1607 m->mount_utab_event_source = sd_event_source_unref(m->mount_utab_event_source);
1609 if (m->proc_self_mountinfo) {
1610 fclose(m->proc_self_mountinfo);
1611 m->proc_self_mountinfo = NULL;
1613 m->utab_inotify_fd = safe_close(m->utab_inotify_fd);
1616 static int mount_get_timeout(Unit *u, uint64_t *timeout) {
1617 Mount *m = MOUNT(u);
1620 if (!m->timer_event_source)
1623 r = sd_event_source_get_time(m->timer_event_source, timeout);
1630 static int mount_enumerate(Manager *m) {
1636 if (!m->proc_self_mountinfo) {
1637 m->proc_self_mountinfo = fopen("/proc/self/mountinfo", "re");
1638 if (!m->proc_self_mountinfo)
1641 r = sd_event_add_io(m->event, &m->mount_event_source, fileno(m->proc_self_mountinfo), EPOLLPRI, mount_dispatch_io, m);
1645 /* Dispatch this before we dispatch SIGCHLD, so that
1646 * we always get the events from /proc/self/mountinfo
1647 * before the SIGCHLD of /bin/mount. */
1648 r = sd_event_source_set_priority(m->mount_event_source, -10);
1653 if (m->utab_inotify_fd < 0) {
1654 m->utab_inotify_fd = inotify_init1(IN_NONBLOCK|IN_CLOEXEC);
1655 if (m->utab_inotify_fd < 0) {
1660 (void) mkdir_p_label("/run/mount", 0755);
1662 r = inotify_add_watch(m->utab_inotify_fd, "/run/mount", IN_MOVED_TO);
1668 r = sd_event_add_io(m->event, &m->mount_utab_event_source, m->utab_inotify_fd, EPOLLIN, mount_dispatch_io, m);
1672 r = sd_event_source_set_priority(m->mount_utab_event_source, -10);
1677 r = mount_load_proc_self_mountinfo(m, false);
1688 static int mount_dispatch_io(sd_event_source *source, int fd, uint32_t revents, void *userdata) {
1689 Manager *m = userdata;
1694 assert(revents & (EPOLLPRI | EPOLLIN));
1696 /* The manager calls this for every fd event happening on the
1697 * /proc/self/mountinfo file, which informs us about mounting
1698 * table changes, and for /run/mount events which we watch
1699 * for mount options. */
1701 if (fd == m->utab_inotify_fd) {
1702 bool rescan = false;
1704 /* FIXME: We *really* need to replace this with
1705 * libmount's own API for this, we should not hardcode
1706 * internal behaviour of libmount here. */
1709 union inotify_event_buffer buffer;
1710 struct inotify_event *e;
1713 l = read(fd, &buffer, sizeof(buffer));
1715 if (errno == EAGAIN || errno == EINTR)
1718 log_error_errno(errno, "Failed to read utab inotify: %m");
1722 FOREACH_INOTIFY_EVENT(e, buffer, l) {
1723 /* Only care about changes to utab,
1724 * but we have to monitor the
1725 * directory to reliably get
1726 * notifications about when utab is
1727 * replaced using rename(2) */
1728 if ((e->mask & IN_Q_OVERFLOW) || streq(e->name, "utab"))
1737 r = mount_load_proc_self_mountinfo(m, true);
1739 log_error_errno(r, "Failed to reread /proc/self/mountinfo: %m");
1741 /* Reset flags, just in case, for later calls */
1742 LIST_FOREACH(units_by_type, u, m->units_by_type[UNIT_MOUNT]) {
1743 Mount *mount = MOUNT(u);
1745 mount->is_mounted = mount->just_mounted = mount->just_changed = false;
1751 manager_dispatch_load_queue(m);
1753 LIST_FOREACH(units_by_type, u, m->units_by_type[UNIT_MOUNT]) {
1754 Mount *mount = MOUNT(u);
1756 if (!mount->is_mounted) {
1758 mount->from_proc_self_mountinfo = false;
1760 switch (mount->state) {
1763 /* This has just been unmounted by
1764 * somebody else, follow the state
1766 mount_enter_dead(mount, MOUNT_SUCCESS);
1773 } else if (mount->just_mounted || mount->just_changed) {
1775 /* New or changed mount entry */
1777 switch (mount->state) {
1781 /* This has just been mounted by
1782 * somebody else, follow the state
1784 mount_enter_mounted(mount, MOUNT_SUCCESS);
1787 case MOUNT_MOUNTING:
1788 mount_set_state(mount, MOUNT_MOUNTING_DONE);
1792 /* Nothing really changed, but let's
1793 * issue an notification call
1794 * nonetheless, in case somebody is
1795 * waiting for this. (e.g. file system
1796 * ro/rw remounts.) */
1797 mount_set_state(mount, mount->state);
1802 /* Reset the flags for later calls */
1803 mount->is_mounted = mount->just_mounted = mount->just_changed = false;
1809 static void mount_reset_failed(Unit *u) {
1810 Mount *m = MOUNT(u);
1814 if (m->state == MOUNT_FAILED)
1815 mount_set_state(m, MOUNT_DEAD);
1817 m->result = MOUNT_SUCCESS;
1818 m->reload_result = MOUNT_SUCCESS;
1821 static int mount_kill(Unit *u, KillWho who, int signo, sd_bus_error *error) {
1822 return unit_kill_common(u, who, signo, -1, MOUNT(u)->control_pid, error);
1825 static const char* const mount_state_table[_MOUNT_STATE_MAX] = {
1826 [MOUNT_DEAD] = "dead",
1827 [MOUNT_MOUNTING] = "mounting",
1828 [MOUNT_MOUNTING_DONE] = "mounting-done",
1829 [MOUNT_MOUNTED] = "mounted",
1830 [MOUNT_REMOUNTING] = "remounting",
1831 [MOUNT_UNMOUNTING] = "unmounting",
1832 [MOUNT_MOUNTING_SIGTERM] = "mounting-sigterm",
1833 [MOUNT_MOUNTING_SIGKILL] = "mounting-sigkill",
1834 [MOUNT_REMOUNTING_SIGTERM] = "remounting-sigterm",
1835 [MOUNT_REMOUNTING_SIGKILL] = "remounting-sigkill",
1836 [MOUNT_UNMOUNTING_SIGTERM] = "unmounting-sigterm",
1837 [MOUNT_UNMOUNTING_SIGKILL] = "unmounting-sigkill",
1838 [MOUNT_FAILED] = "failed"
1841 DEFINE_STRING_TABLE_LOOKUP(mount_state, MountState);
1843 static const char* const mount_exec_command_table[_MOUNT_EXEC_COMMAND_MAX] = {
1844 [MOUNT_EXEC_MOUNT] = "ExecMount",
1845 [MOUNT_EXEC_UNMOUNT] = "ExecUnmount",
1846 [MOUNT_EXEC_REMOUNT] = "ExecRemount",
1849 DEFINE_STRING_TABLE_LOOKUP(mount_exec_command, MountExecCommand);
1851 static const char* const mount_result_table[_MOUNT_RESULT_MAX] = {
1852 [MOUNT_SUCCESS] = "success",
1853 [MOUNT_FAILURE_RESOURCES] = "resources",
1854 [MOUNT_FAILURE_TIMEOUT] = "timeout",
1855 [MOUNT_FAILURE_EXIT_CODE] = "exit-code",
1856 [MOUNT_FAILURE_SIGNAL] = "signal",
1857 [MOUNT_FAILURE_CORE_DUMP] = "core-dump"
1860 DEFINE_STRING_TABLE_LOOKUP(mount_result, MountResult);
1862 const UnitVTable mount_vtable = {
1863 .object_size = sizeof(Mount),
1864 .exec_context_offset = offsetof(Mount, exec_context),
1865 .cgroup_context_offset = offsetof(Mount, cgroup_context),
1866 .kill_context_offset = offsetof(Mount, kill_context),
1867 .exec_runtime_offset = offsetof(Mount, exec_runtime),
1873 .private_section = "Mount",
1876 .no_instances = true,
1882 .coldplug = mount_coldplug,
1886 .start = mount_start,
1888 .reload = mount_reload,
1892 .serialize = mount_serialize,
1893 .deserialize_item = mount_deserialize_item,
1895 .active_state = mount_active_state,
1896 .sub_state_to_string = mount_sub_state_to_string,
1898 .check_gc = mount_check_gc,
1900 .sigchld_event = mount_sigchld_event,
1902 .reset_failed = mount_reset_failed,
1904 .bus_interface = "org.freedesktop.systemd1.Mount",
1905 .bus_vtable = bus_mount_vtable,
1906 .bus_set_property = bus_mount_set_property,
1907 .bus_commit_properties = bus_mount_commit_properties,
1909 .get_timeout = mount_get_timeout,
1911 .can_transient = true,
1913 .enumerate = mount_enumerate,
1914 .shutdown = mount_shutdown,
1916 .status_message_formats = {
1917 .starting_stopping = {
1918 [0] = "Mounting %s...",
1919 [1] = "Unmounting %s...",
1921 .finished_start_job = {
1922 [JOB_DONE] = "Mounted %s.",
1923 [JOB_FAILED] = "Failed to mount %s.",
1924 [JOB_DEPENDENCY] = "Dependency failed for %s.",
1925 [JOB_TIMEOUT] = "Timed out mounting %s.",
1927 .finished_stop_job = {
1928 [JOB_DONE] = "Unmounted %s.",
1929 [JOB_FAILED] = "Failed unmounting %s.",
1930 [JOB_TIMEOUT] = "Timed out unmounting %s.",