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_fragment(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 p = get_mount_parameters(m);
386 if (path_equal(m->where, "/") ||
387 path_equal(m->where, "/usr"))
390 if (mount_is_network(p)) {
391 after = SPECIAL_REMOTE_FS_PRE_TARGET;
392 after2 = SPECIAL_NETWORK_TARGET;
393 online = SPECIAL_NETWORK_ONLINE_TARGET;
395 after = SPECIAL_LOCAL_FS_PRE_TARGET;
400 r = unit_add_dependency_by_name(UNIT(m), UNIT_AFTER, after, NULL, true);
405 r = unit_add_dependency_by_name(UNIT(m), UNIT_AFTER, after2, NULL, true);
411 r = unit_add_two_dependencies_by_name(UNIT(m), UNIT_WANTS, UNIT_AFTER, online, NULL, true);
416 if (should_umount(m)) {
417 r = unit_add_two_dependencies_by_name(UNIT(m), UNIT_BEFORE, UNIT_CONFLICTS, SPECIAL_UMOUNT_TARGET, NULL, true);
425 static int mount_verify(Mount *m) {
426 _cleanup_free_ char *e = NULL;
431 if (UNIT(m)->load_state != UNIT_LOADED)
434 if (!m->from_fragment && !m->from_proc_self_mountinfo)
437 e = unit_name_from_path(m->where, ".mount");
441 b = unit_has_name(UNIT(m), e);
443 log_unit_error(UNIT(m)->id, "%s's Where= setting doesn't match unit name. Refusing.", UNIT(m)->id);
447 if (mount_point_is_api(m->where) || mount_point_ignore(m->where)) {
448 log_unit_error(UNIT(m)->id, "Cannot create mount unit for API file system %s. Refusing.", m->where);
452 if (UNIT(m)->fragment_path && !m->parameters_fragment.what) {
453 log_unit_error(UNIT(m)->id, "%s's What setting is missing. Refusing.", UNIT(m)->id);
457 if (m->exec_context.pam_name && m->kill_context.kill_mode != KILL_CONTROL_GROUP) {
458 log_unit_error(UNIT(m)->id, "%s has PAM enabled. Kill mode must be set to control-group'. Refusing.",UNIT(m)->id);
465 static int mount_add_extras(Mount *m) {
471 if (u->fragment_path)
472 m->from_fragment = true;
475 m->where = unit_name_to_path(u->id);
480 path_kill_slashes(m->where);
482 if (!u->description) {
483 r = unit_set_description(u, m->where);
488 r = mount_add_device_links(m);
492 r = mount_add_mount_links(m);
496 r = mount_add_quota_links(m);
500 r = unit_patch_contexts(u);
504 r = unit_add_exec_dependencies(u, &m->exec_context);
508 r = unit_add_default_slice(u, &m->cgroup_context);
512 if (u->default_dependencies) {
513 r = mount_add_default_dependencies(m);
521 static int mount_load(Unit *u) {
526 assert(u->load_state == UNIT_STUB);
528 if (m->from_proc_self_mountinfo)
529 r = unit_load_fragment_and_dropin_optional(u);
531 r = unit_load_fragment_and_dropin(u);
536 /* This is a new unit? Then let's add in some extras */
537 if (u->load_state == UNIT_LOADED) {
538 r = mount_add_extras(m);
543 return mount_verify(m);
546 static int mount_notify_automount(Mount *m, int status) {
553 SET_FOREACH(p, UNIT(m)->dependencies[UNIT_TRIGGERED_BY], i)
554 if (p->type == UNIT_AUTOMOUNT) {
555 r = automount_send_ready(AUTOMOUNT(p), status);
563 static void mount_set_state(Mount *m, MountState state) {
564 MountState old_state;
567 old_state = m->state;
570 if (state != MOUNT_MOUNTING &&
571 state != MOUNT_MOUNTING_DONE &&
572 state != MOUNT_REMOUNTING &&
573 state != MOUNT_UNMOUNTING &&
574 state != MOUNT_MOUNTING_SIGTERM &&
575 state != MOUNT_MOUNTING_SIGKILL &&
576 state != MOUNT_UNMOUNTING_SIGTERM &&
577 state != MOUNT_UNMOUNTING_SIGKILL &&
578 state != MOUNT_REMOUNTING_SIGTERM &&
579 state != MOUNT_REMOUNTING_SIGKILL) {
580 m->timer_event_source = sd_event_source_unref(m->timer_event_source);
581 mount_unwatch_control_pid(m);
582 m->control_command = NULL;
583 m->control_command_id = _MOUNT_EXEC_COMMAND_INVALID;
586 if (state == MOUNT_MOUNTED ||
587 state == MOUNT_REMOUNTING)
588 mount_notify_automount(m, 0);
589 else if (state == MOUNT_DEAD ||
590 state == MOUNT_UNMOUNTING ||
591 state == MOUNT_MOUNTING_SIGTERM ||
592 state == MOUNT_MOUNTING_SIGKILL ||
593 state == MOUNT_REMOUNTING_SIGTERM ||
594 state == MOUNT_REMOUNTING_SIGKILL ||
595 state == MOUNT_UNMOUNTING_SIGTERM ||
596 state == MOUNT_UNMOUNTING_SIGKILL ||
597 state == MOUNT_FAILED) {
598 if (state != old_state)
599 mount_notify_automount(m, -ENODEV);
602 if (state != old_state)
603 log_unit_debug(UNIT(m)->id,
604 "%s changed %s -> %s",
606 mount_state_to_string(old_state),
607 mount_state_to_string(state));
609 unit_notify(UNIT(m), state_translation_table[old_state], state_translation_table[state], m->reload_result == MOUNT_SUCCESS);
610 m->reload_result = MOUNT_SUCCESS;
613 static int mount_coldplug(Unit *u) {
615 MountState new_state = MOUNT_DEAD;
619 assert(m->state == MOUNT_DEAD);
621 if (m->deserialized_state != m->state)
622 new_state = m->deserialized_state;
623 else if (m->from_proc_self_mountinfo)
624 new_state = MOUNT_MOUNTED;
626 if (new_state == m->state)
629 if (new_state == MOUNT_MOUNTING ||
630 new_state == MOUNT_MOUNTING_DONE ||
631 new_state == MOUNT_REMOUNTING ||
632 new_state == MOUNT_UNMOUNTING ||
633 new_state == MOUNT_MOUNTING_SIGTERM ||
634 new_state == MOUNT_MOUNTING_SIGKILL ||
635 new_state == MOUNT_UNMOUNTING_SIGTERM ||
636 new_state == MOUNT_UNMOUNTING_SIGKILL ||
637 new_state == MOUNT_REMOUNTING_SIGTERM ||
638 new_state == MOUNT_REMOUNTING_SIGKILL) {
640 if (m->control_pid <= 0)
643 r = unit_watch_pid(UNIT(m), m->control_pid);
647 r = mount_arm_timer(m);
652 mount_set_state(m, new_state);
656 static void mount_dump(Unit *u, FILE *f, const char *prefix) {
663 p = get_mount_parameters(m);
666 "%sMount State: %s\n"
670 "%sFile System Type: %s\n"
672 "%sFrom /proc/self/mountinfo: %s\n"
673 "%sFrom fragment: %s\n"
674 "%sDirectoryMode: %04o\n",
675 prefix, mount_state_to_string(m->state),
676 prefix, mount_result_to_string(m->result),
678 prefix, p ? strna(p->what) : "n/a",
679 prefix, p ? strna(p->fstype) : "n/a",
680 prefix, p ? strna(p->options) : "n/a",
681 prefix, yes_no(m->from_proc_self_mountinfo),
682 prefix, yes_no(m->from_fragment),
683 prefix, m->directory_mode);
685 if (m->control_pid > 0)
687 "%sControl PID: "PID_FMT"\n",
688 prefix, m->control_pid);
690 exec_context_dump(&m->exec_context, f, prefix);
691 kill_context_dump(&m->kill_context, f, prefix);
694 static int mount_spawn(Mount *m, ExecCommand *c, pid_t *_pid) {
697 ExecParameters exec_params = {
698 .apply_permissions = true,
699 .apply_chroot = true,
700 .apply_tty_stdin = true,
707 unit_realize_cgroup(UNIT(m));
709 r = unit_setup_exec_runtime(UNIT(m));
713 r = mount_arm_timer(m);
717 exec_params.environment = UNIT(m)->manager->environment;
718 exec_params.confirm_spawn = UNIT(m)->manager->confirm_spawn;
719 exec_params.cgroup_supported = UNIT(m)->manager->cgroup_supported;
720 exec_params.cgroup_path = UNIT(m)->cgroup_path;
721 exec_params.cgroup_delegate = m->cgroup_context.delegate;
722 exec_params.runtime_prefix = manager_get_runtime_prefix(UNIT(m)->manager);
723 exec_params.unit_id = UNIT(m)->id;
733 r = unit_watch_pid(UNIT(m), pid);
735 /* FIXME: we need to do something here */
743 m->timer_event_source = sd_event_source_unref(m->timer_event_source);
748 static void mount_enter_dead(Mount *m, MountResult f) {
751 if (f != MOUNT_SUCCESS)
754 exec_runtime_destroy(m->exec_runtime);
755 m->exec_runtime = exec_runtime_unref(m->exec_runtime);
757 exec_context_destroy_runtime_directory(&m->exec_context, manager_get_runtime_prefix(UNIT(m)->manager));
759 mount_set_state(m, m->result != MOUNT_SUCCESS ? MOUNT_FAILED : MOUNT_DEAD);
762 static void mount_enter_mounted(Mount *m, MountResult f) {
765 if (f != MOUNT_SUCCESS)
768 mount_set_state(m, MOUNT_MOUNTED);
771 static void mount_enter_signal(Mount *m, MountState state, MountResult f) {
776 if (f != MOUNT_SUCCESS)
779 r = unit_kill_context(
782 (state != MOUNT_MOUNTING_SIGTERM && state != MOUNT_UNMOUNTING_SIGTERM && state != MOUNT_REMOUNTING_SIGTERM) ?
783 KILL_KILL : KILL_TERMINATE,
791 r = mount_arm_timer(m);
795 mount_set_state(m, state);
796 } else if (state == MOUNT_REMOUNTING_SIGTERM)
797 mount_enter_signal(m, MOUNT_REMOUNTING_SIGKILL, MOUNT_SUCCESS);
798 else if (state == MOUNT_REMOUNTING_SIGKILL)
799 mount_enter_mounted(m, MOUNT_SUCCESS);
800 else if (state == MOUNT_MOUNTING_SIGTERM)
801 mount_enter_signal(m, MOUNT_MOUNTING_SIGKILL, MOUNT_SUCCESS);
802 else if (state == MOUNT_UNMOUNTING_SIGTERM)
803 mount_enter_signal(m, MOUNT_UNMOUNTING_SIGKILL, MOUNT_SUCCESS);
805 mount_enter_dead(m, MOUNT_SUCCESS);
810 log_unit_warning(UNIT(m)->id,
811 "%s failed to kill processes: %s", UNIT(m)->id, strerror(-r));
813 if (state == MOUNT_REMOUNTING_SIGTERM || state == MOUNT_REMOUNTING_SIGKILL)
814 mount_enter_mounted(m, MOUNT_FAILURE_RESOURCES);
816 mount_enter_dead(m, MOUNT_FAILURE_RESOURCES);
819 void warn_if_dir_nonempty(const char *unit, const char* where) {
825 r = dir_is_empty(where);
829 log_unit_struct(unit,
831 LOG_MESSAGE_ID(SD_MESSAGE_OVERMOUNTING),
832 LOG_MESSAGE("%s: Directory %s to mount over is not empty, mounting anyway.",
837 log_unit_warning(unit,
838 "MESSAGE=Failed to check directory %s: %s",
839 where, strerror(-r));
842 static int fail_if_symlink(const char *unit, const char* where) {
845 if (is_symlink(where) > 0) {
846 log_unit_struct(unit,
848 LOG_MESSAGE_ID(SD_MESSAGE_OVERMOUNTING),
849 LOG_MESSAGE("%s: Mount on symlink %s not allowed.",
859 static void mount_enter_unmounting(Mount *m) {
864 /* Start counting our attempts */
865 if (!IN_SET(m->state,
867 MOUNT_UNMOUNTING_SIGTERM,
868 MOUNT_UNMOUNTING_SIGKILL))
869 m->n_retry_umount = 0;
871 m->control_command_id = MOUNT_EXEC_UNMOUNT;
872 m->control_command = m->exec_command + MOUNT_EXEC_UNMOUNT;
874 r = exec_command_set(m->control_command, "/bin/umount", m->where, NULL);
875 if (r >= 0 && UNIT(m)->manager->running_as == SYSTEMD_SYSTEM)
876 r = exec_command_append(m->control_command, "-n", NULL);
880 mount_unwatch_control_pid(m);
882 r = mount_spawn(m, m->control_command, &m->control_pid);
886 mount_set_state(m, MOUNT_UNMOUNTING);
891 log_unit_warning(UNIT(m)->id,
892 "%s failed to run 'umount' task: %s",
893 UNIT(m)->id, strerror(-r));
894 mount_enter_mounted(m, MOUNT_FAILURE_RESOURCES);
897 static void mount_enter_mounting(Mount *m) {
903 m->control_command_id = MOUNT_EXEC_MOUNT;
904 m->control_command = m->exec_command + MOUNT_EXEC_MOUNT;
906 mkdir_p_label(m->where, m->directory_mode);
908 warn_if_dir_nonempty(m->meta.id, m->where);
910 /* Create the source directory for bind-mounts if needed */
911 p = get_mount_parameters_fragment(m);
912 if (p && mount_is_bind(p))
913 mkdir_p_label(p->what, m->directory_mode);
915 r = fail_if_symlink(m->meta.id, m->where);
919 if (m->from_fragment) {
920 _cleanup_free_ char *opts = NULL;
922 r = fstab_filter_options(m->parameters_fragment.options,
923 "nofail\0" "noauto\0" "auto\0", NULL, NULL, &opts);
927 r = exec_command_set(m->control_command, "/bin/mount",
928 m->parameters_fragment.what, m->where, NULL);
929 if (r >= 0 && UNIT(m)->manager->running_as == SYSTEMD_SYSTEM)
930 r = exec_command_append(m->control_command, "-n", NULL);
931 if (r >= 0 && m->sloppy_options)
932 r = exec_command_append(m->control_command, "-s", NULL);
933 if (r >= 0 && m->parameters_fragment.fstype)
934 r = exec_command_append(m->control_command, "-t", m->parameters_fragment.fstype, NULL);
935 if (r >= 0 && !isempty(opts))
936 r = exec_command_append(m->control_command, "-o", opts, NULL);
943 mount_unwatch_control_pid(m);
945 r = mount_spawn(m, m->control_command, &m->control_pid);
949 mount_set_state(m, MOUNT_MOUNTING);
954 log_unit_warning(UNIT(m)->id,
955 "%s failed to run 'mount' task: %s",
956 UNIT(m)->id, strerror(-r));
957 mount_enter_dead(m, MOUNT_FAILURE_RESOURCES);
960 static void mount_enter_remounting(Mount *m) {
965 m->control_command_id = MOUNT_EXEC_REMOUNT;
966 m->control_command = m->exec_command + MOUNT_EXEC_REMOUNT;
968 if (m->from_fragment) {
971 if (m->parameters_fragment.options)
972 o = strappenda("remount,", m->parameters_fragment.options);
976 r = exec_command_set(m->control_command, "/bin/mount",
977 m->parameters_fragment.what, m->where,
979 if (r >= 0 && UNIT(m)->manager->running_as == SYSTEMD_SYSTEM)
980 r = exec_command_append(m->control_command, "-n", NULL);
981 if (r >= 0 && m->sloppy_options)
982 r = exec_command_append(m->control_command, "-s", NULL);
983 if (r >= 0 && m->parameters_fragment.fstype)
984 r = exec_command_append(m->control_command, "-t", m->parameters_fragment.fstype, NULL);
991 mount_unwatch_control_pid(m);
993 r = mount_spawn(m, m->control_command, &m->control_pid);
997 mount_set_state(m, MOUNT_REMOUNTING);
1002 log_unit_warning(UNIT(m)->id,
1003 "%s failed to run 'remount' task: %s",
1004 UNIT(m)->id, strerror(-r));
1005 m->reload_result = MOUNT_FAILURE_RESOURCES;
1006 mount_enter_mounted(m, MOUNT_SUCCESS);
1009 static int mount_start(Unit *u) {
1010 Mount *m = MOUNT(u);
1014 /* We cannot fulfill this request right now, try again later
1016 if (m->state == MOUNT_UNMOUNTING ||
1017 m->state == MOUNT_UNMOUNTING_SIGTERM ||
1018 m->state == MOUNT_UNMOUNTING_SIGKILL ||
1019 m->state == MOUNT_MOUNTING_SIGTERM ||
1020 m->state == MOUNT_MOUNTING_SIGKILL)
1023 /* Already on it! */
1024 if (m->state == MOUNT_MOUNTING)
1027 assert(m->state == MOUNT_DEAD || m->state == MOUNT_FAILED);
1029 m->result = MOUNT_SUCCESS;
1030 m->reload_result = MOUNT_SUCCESS;
1032 mount_enter_mounting(m);
1036 static int mount_stop(Unit *u) {
1037 Mount *m = MOUNT(u);
1042 if (m->state == MOUNT_UNMOUNTING ||
1043 m->state == MOUNT_UNMOUNTING_SIGKILL ||
1044 m->state == MOUNT_UNMOUNTING_SIGTERM ||
1045 m->state == MOUNT_MOUNTING_SIGTERM ||
1046 m->state == MOUNT_MOUNTING_SIGKILL)
1049 assert(m->state == MOUNT_MOUNTING ||
1050 m->state == MOUNT_MOUNTING_DONE ||
1051 m->state == MOUNT_MOUNTED ||
1052 m->state == MOUNT_REMOUNTING ||
1053 m->state == MOUNT_REMOUNTING_SIGTERM ||
1054 m->state == MOUNT_REMOUNTING_SIGKILL);
1056 mount_enter_unmounting(m);
1060 static int mount_reload(Unit *u) {
1061 Mount *m = MOUNT(u);
1065 if (m->state == MOUNT_MOUNTING_DONE)
1068 assert(m->state == MOUNT_MOUNTED);
1070 mount_enter_remounting(m);
1074 static int mount_serialize(Unit *u, FILE *f, FDSet *fds) {
1075 Mount *m = MOUNT(u);
1081 unit_serialize_item(u, f, "state", mount_state_to_string(m->state));
1082 unit_serialize_item(u, f, "result", mount_result_to_string(m->result));
1083 unit_serialize_item(u, f, "reload-result", mount_result_to_string(m->reload_result));
1085 if (m->control_pid > 0)
1086 unit_serialize_item_format(u, f, "control-pid", PID_FMT, m->control_pid);
1088 if (m->control_command_id >= 0)
1089 unit_serialize_item(u, f, "control-command", mount_exec_command_to_string(m->control_command_id));
1094 static int mount_deserialize_item(Unit *u, const char *key, const char *value, FDSet *fds) {
1095 Mount *m = MOUNT(u);
1102 if (streq(key, "state")) {
1105 if ((state = mount_state_from_string(value)) < 0)
1106 log_unit_debug(u->id, "Failed to parse state value %s", value);
1108 m->deserialized_state = state;
1109 } else if (streq(key, "result")) {
1112 f = mount_result_from_string(value);
1114 log_unit_debug(UNIT(m)->id,
1115 "Failed to parse result value %s", value);
1116 else if (f != MOUNT_SUCCESS)
1119 } else if (streq(key, "reload-result")) {
1122 f = mount_result_from_string(value);
1124 log_unit_debug(UNIT(m)->id,
1125 "Failed to parse reload result value %s", value);
1126 else if (f != MOUNT_SUCCESS)
1127 m->reload_result = f;
1129 } else if (streq(key, "control-pid")) {
1132 if (parse_pid(value, &pid) < 0)
1133 log_unit_debug(UNIT(m)->id,
1134 "Failed to parse control-pid value %s", value);
1136 m->control_pid = pid;
1137 } else if (streq(key, "control-command")) {
1138 MountExecCommand id;
1140 if ((id = mount_exec_command_from_string(value)) < 0)
1141 log_unit_debug(UNIT(m)->id,
1142 "Failed to parse exec-command value %s", value);
1144 m->control_command_id = id;
1145 m->control_command = m->exec_command + id;
1148 log_unit_debug(UNIT(m)->id,
1149 "Unknown serialization key '%s'", key);
1154 _pure_ static UnitActiveState mount_active_state(Unit *u) {
1157 return state_translation_table[MOUNT(u)->state];
1160 _pure_ static const char *mount_sub_state_to_string(Unit *u) {
1163 return mount_state_to_string(MOUNT(u)->state);
1166 _pure_ static bool mount_check_gc(Unit *u) {
1167 Mount *m = MOUNT(u);
1171 return m->from_proc_self_mountinfo;
1174 static void mount_sigchld_event(Unit *u, pid_t pid, int code, int status) {
1175 Mount *m = MOUNT(u);
1181 if (pid != m->control_pid)
1186 if (is_clean_exit(code, status, NULL))
1188 else if (code == CLD_EXITED)
1189 f = MOUNT_FAILURE_EXIT_CODE;
1190 else if (code == CLD_KILLED)
1191 f = MOUNT_FAILURE_SIGNAL;
1192 else if (code == CLD_DUMPED)
1193 f = MOUNT_FAILURE_CORE_DUMP;
1195 assert_not_reached("Unknown code");
1197 if (f != MOUNT_SUCCESS)
1200 if (m->control_command) {
1201 exec_status_exit(&m->control_command->exec_status, &m->exec_context, pid, code, status);
1203 m->control_command = NULL;
1204 m->control_command_id = _MOUNT_EXEC_COMMAND_INVALID;
1207 log_unit_full(u->id,
1208 f == MOUNT_SUCCESS ? LOG_DEBUG : LOG_NOTICE,
1209 "%s mount process exited, code=%s status=%i",
1210 u->id, sigchld_code_to_string(code), status);
1212 /* Note that mount(8) returning and the kernel sending us a
1213 * mount table change event might happen out-of-order. If an
1214 * operation succeed we assume the kernel will follow soon too
1215 * and already change into the resulting state. If it fails
1216 * we check if the kernel still knows about the mount. and
1217 * change state accordingly. */
1221 case MOUNT_MOUNTING:
1222 case MOUNT_MOUNTING_DONE:
1223 case MOUNT_MOUNTING_SIGKILL:
1224 case MOUNT_MOUNTING_SIGTERM:
1226 if (f == MOUNT_SUCCESS)
1227 mount_enter_mounted(m, f);
1228 else if (m->from_proc_self_mountinfo)
1229 mount_enter_mounted(m, f);
1231 mount_enter_dead(m, f);
1234 case MOUNT_REMOUNTING:
1235 case MOUNT_REMOUNTING_SIGKILL:
1236 case MOUNT_REMOUNTING_SIGTERM:
1238 m->reload_result = f;
1239 if (m->from_proc_self_mountinfo)
1240 mount_enter_mounted(m, MOUNT_SUCCESS);
1242 mount_enter_dead(m, MOUNT_SUCCESS);
1246 case MOUNT_UNMOUNTING:
1247 case MOUNT_UNMOUNTING_SIGKILL:
1248 case MOUNT_UNMOUNTING_SIGTERM:
1250 if (f == MOUNT_SUCCESS) {
1252 if (m->from_proc_self_mountinfo) {
1254 /* Still a mount point? If so, let's
1255 * try again. Most likely there were
1256 * multiple mount points stacked on
1257 * top of each other. Note that due to
1258 * the io event priority logic we can
1259 * be sure the new mountinfo is loaded
1260 * before we process the SIGCHLD for
1261 * the mount command. */
1263 if (m->n_retry_umount < RETRY_UMOUNT_MAX) {
1264 log_unit_debug(u->id, "%s: mount still present, trying again.", u->id);
1265 m->n_retry_umount++;
1266 mount_enter_unmounting(m);
1268 log_unit_debug(u->id, "%s: mount still present after %u attempts to unmount, giving up.", u->id, m->n_retry_umount);
1269 mount_enter_mounted(m, f);
1272 mount_enter_dead(m, f);
1274 } else if (m->from_proc_self_mountinfo)
1275 mount_enter_mounted(m, f);
1277 mount_enter_dead(m, f);
1281 assert_not_reached("Uh, control process died at wrong time.");
1284 /* Notify clients about changed exit status */
1285 unit_add_to_dbus_queue(u);
1288 static int mount_dispatch_timer(sd_event_source *source, usec_t usec, void *userdata) {
1289 Mount *m = MOUNT(userdata);
1292 assert(m->timer_event_source == source);
1296 case MOUNT_MOUNTING:
1297 case MOUNT_MOUNTING_DONE:
1298 log_unit_warning(UNIT(m)->id,
1299 "%s mounting timed out. Stopping.", UNIT(m)->id);
1300 mount_enter_signal(m, MOUNT_MOUNTING_SIGTERM, MOUNT_FAILURE_TIMEOUT);
1303 case MOUNT_REMOUNTING:
1304 log_unit_warning(UNIT(m)->id,
1305 "%s remounting timed out. Stopping.", UNIT(m)->id);
1306 m->reload_result = MOUNT_FAILURE_TIMEOUT;
1307 mount_enter_mounted(m, MOUNT_SUCCESS);
1310 case MOUNT_UNMOUNTING:
1311 log_unit_warning(UNIT(m)->id,
1312 "%s unmounting timed out. Stopping.", UNIT(m)->id);
1313 mount_enter_signal(m, MOUNT_UNMOUNTING_SIGTERM, MOUNT_FAILURE_TIMEOUT);
1316 case MOUNT_MOUNTING_SIGTERM:
1317 if (m->kill_context.send_sigkill) {
1318 log_unit_warning(UNIT(m)->id,
1319 "%s mounting timed out. Killing.", UNIT(m)->id);
1320 mount_enter_signal(m, MOUNT_MOUNTING_SIGKILL, MOUNT_FAILURE_TIMEOUT);
1322 log_unit_warning(UNIT(m)->id,
1323 "%s mounting timed out. Skipping SIGKILL. Ignoring.",
1326 if (m->from_proc_self_mountinfo)
1327 mount_enter_mounted(m, MOUNT_FAILURE_TIMEOUT);
1329 mount_enter_dead(m, MOUNT_FAILURE_TIMEOUT);
1333 case MOUNT_REMOUNTING_SIGTERM:
1334 if (m->kill_context.send_sigkill) {
1335 log_unit_warning(UNIT(m)->id,
1336 "%s remounting timed out. Killing.", UNIT(m)->id);
1337 mount_enter_signal(m, MOUNT_REMOUNTING_SIGKILL, MOUNT_FAILURE_TIMEOUT);
1339 log_unit_warning(UNIT(m)->id,
1340 "%s remounting timed out. Skipping SIGKILL. Ignoring.",
1343 if (m->from_proc_self_mountinfo)
1344 mount_enter_mounted(m, MOUNT_FAILURE_TIMEOUT);
1346 mount_enter_dead(m, MOUNT_FAILURE_TIMEOUT);
1350 case MOUNT_UNMOUNTING_SIGTERM:
1351 if (m->kill_context.send_sigkill) {
1352 log_unit_warning(UNIT(m)->id,
1353 "%s unmounting timed out. Killing.", UNIT(m)->id);
1354 mount_enter_signal(m, MOUNT_UNMOUNTING_SIGKILL, MOUNT_FAILURE_TIMEOUT);
1356 log_unit_warning(UNIT(m)->id,
1357 "%s unmounting timed out. Skipping SIGKILL. Ignoring.",
1360 if (m->from_proc_self_mountinfo)
1361 mount_enter_mounted(m, MOUNT_FAILURE_TIMEOUT);
1363 mount_enter_dead(m, MOUNT_FAILURE_TIMEOUT);
1367 case MOUNT_MOUNTING_SIGKILL:
1368 case MOUNT_REMOUNTING_SIGKILL:
1369 case MOUNT_UNMOUNTING_SIGKILL:
1370 log_unit_warning(UNIT(m)->id,
1371 "%s mount process still around after SIGKILL. Ignoring.",
1374 if (m->from_proc_self_mountinfo)
1375 mount_enter_mounted(m, MOUNT_FAILURE_TIMEOUT);
1377 mount_enter_dead(m, MOUNT_FAILURE_TIMEOUT);
1381 assert_not_reached("Timeout at wrong time.");
1387 static int mount_add_one(
1391 const char *options,
1395 _cleanup_free_ char *e = NULL, *w = NULL, *o = NULL, *f = NULL;
1396 bool load_extras = false;
1398 bool delete, changed = false;
1408 /* Ignore API mount points. They should never be referenced in
1409 * dependencies ever. */
1410 if (mount_point_is_api(where) || mount_point_ignore(where))
1413 if (streq(fstype, "autofs"))
1416 /* probably some kind of swap, ignore */
1417 if (!is_path(where))
1420 e = unit_name_from_path(where, ".mount");
1424 u = manager_get_unit(m, e);
1428 u = unit_new(m, sizeof(Mount));
1432 r = unit_add_name(u, e);
1436 MOUNT(u)->where = strdup(where);
1437 if (!MOUNT(u)->where) {
1442 u->source_path = strdup("/proc/self/mountinfo");
1443 if (!u->source_path) {
1448 if (m->running_as == SYSTEMD_SYSTEM) {
1451 target = mount_needs_network(options, fstype) ? SPECIAL_REMOTE_FS_TARGET : SPECIAL_LOCAL_FS_TARGET;
1452 r = unit_add_dependency_by_name(u, UNIT_BEFORE, target, NULL, true);
1456 if (should_umount(MOUNT(u))) {
1457 r = unit_add_dependency_by_name(u, UNIT_CONFLICTS, SPECIAL_UMOUNT_TARGET, NULL, true);
1463 unit_add_to_load_queue(u);
1468 if (!MOUNT(u)->where) {
1469 MOUNT(u)->where = strdup(where);
1470 if (!MOUNT(u)->where) {
1476 if (m->running_as == SYSTEMD_SYSTEM &&
1477 mount_needs_network(options, fstype)) {
1478 /* _netdev option may have shown up late, or on a
1479 * remount. Add remote-fs dependencies, even though
1480 * local-fs ones may already be there. */
1481 unit_add_dependency_by_name(u, UNIT_BEFORE, SPECIAL_REMOTE_FS_TARGET, NULL, true);
1485 if (u->load_state == UNIT_NOT_FOUND) {
1486 u->load_state = UNIT_LOADED;
1489 /* Load in the extras later on, after we
1490 * finished initialization of the unit */
1497 o = strdup(options);
1499 if (!w || !o || !f) {
1504 p = &MOUNT(u)->parameters_proc_self_mountinfo;
1506 changed = changed ||
1507 !streq_ptr(p->options, options) ||
1508 !streq_ptr(p->what, what) ||
1509 !streq_ptr(p->fstype, fstype);
1512 MOUNT(u)->is_mounted = true;
1513 MOUNT(u)->just_mounted = !MOUNT(u)->from_proc_self_mountinfo;
1514 MOUNT(u)->just_changed = changed;
1517 MOUNT(u)->from_proc_self_mountinfo = true;
1532 r = mount_add_extras(MOUNT(u));
1538 unit_add_to_dbus_queue(u);
1549 static int mount_load_proc_self_mountinfo(Manager *m, bool set_flags) {
1550 _cleanup_(mnt_free_tablep) struct libmnt_table *tb = NULL;
1551 _cleanup_(mnt_free_iterp) struct libmnt_iter *itr = NULL;
1552 struct libmnt_fs *fs;
1557 tb = mnt_new_table();
1558 itr = mnt_new_iter(MNT_ITER_FORWARD);
1562 r = mnt_table_parse_mtab(tb, NULL);
1568 const char *device, *path, *options, *fstype;
1569 _cleanup_free_ const char *d = NULL, *p = NULL;
1572 k = mnt_table_next_fs(tb, itr, &fs);
1576 return log_error_errno(k, "Failed to get next entry from /etc/fstab: %m");
1578 device = mnt_fs_get_source(fs);
1579 path = mnt_fs_get_target(fs);
1580 options = mnt_fs_get_options(fs);
1581 fstype = mnt_fs_get_fstype(fs);
1583 d = cunescape(device);
1584 p = cunescape(path);
1588 k = mount_add_one(m, d, p, options, fstype, set_flags);
1589 if (r == 0 && k < 0)
1596 static void mount_shutdown(Manager *m) {
1599 m->mount_event_source = sd_event_source_unref(m->mount_event_source);
1600 m->mount_utab_event_source = sd_event_source_unref(m->mount_utab_event_source);
1602 if (m->proc_self_mountinfo) {
1603 fclose(m->proc_self_mountinfo);
1604 m->proc_self_mountinfo = NULL;
1606 m->utab_inotify_fd = safe_close(m->utab_inotify_fd);
1609 static int mount_get_timeout(Unit *u, uint64_t *timeout) {
1610 Mount *m = MOUNT(u);
1613 if (!m->timer_event_source)
1616 r = sd_event_source_get_time(m->timer_event_source, timeout);
1623 static int mount_enumerate(Manager *m) {
1629 if (!m->proc_self_mountinfo) {
1630 m->proc_self_mountinfo = fopen("/proc/self/mountinfo", "re");
1631 if (!m->proc_self_mountinfo)
1634 r = sd_event_add_io(m->event, &m->mount_event_source, fileno(m->proc_self_mountinfo), EPOLLPRI, mount_dispatch_io, m);
1638 /* Dispatch this before we dispatch SIGCHLD, so that
1639 * we always get the events from /proc/self/mountinfo
1640 * before the SIGCHLD of /bin/mount. */
1641 r = sd_event_source_set_priority(m->mount_event_source, -10);
1646 if (m->utab_inotify_fd < 0) {
1647 m->utab_inotify_fd = inotify_init1(IN_NONBLOCK|IN_CLOEXEC);
1648 if (m->utab_inotify_fd < 0) {
1653 (void) mkdir_p_label("/run/mount", 0755);
1655 r = inotify_add_watch(m->utab_inotify_fd, "/run/mount", IN_MOVED_TO);
1661 r = sd_event_add_io(m->event, &m->mount_utab_event_source, m->utab_inotify_fd, EPOLLIN, mount_dispatch_io, m);
1665 r = sd_event_source_set_priority(m->mount_utab_event_source, -10);
1670 r = mount_load_proc_self_mountinfo(m, false);
1681 static int mount_dispatch_io(sd_event_source *source, int fd, uint32_t revents, void *userdata) {
1682 Manager *m = userdata;
1687 assert(revents & (EPOLLPRI | EPOLLIN));
1689 /* The manager calls this for every fd event happening on the
1690 * /proc/self/mountinfo file, which informs us about mounting
1691 * table changes, and for /run/mount events which we watch
1692 * for mount options. */
1694 if (fd == m->utab_inotify_fd) {
1695 bool rescan = false;
1697 /* FIXME: We *really* need to replace this with
1698 * libmount's own API for this, we should not hardcode
1699 * internal behaviour of libmount here. */
1702 union inotify_event_buffer buffer;
1703 struct inotify_event *e;
1706 l = read(fd, &buffer, sizeof(buffer));
1708 if (errno == EAGAIN || errno == EINTR)
1711 log_error_errno(errno, "Failed to read utab inotify: %m");
1715 FOREACH_INOTIFY_EVENT(e, buffer, l) {
1716 /* Only care about changes to utab,
1717 * but we have to monitor the
1718 * directory to reliably get
1719 * notifications about when utab is
1720 * replaced using rename(2) */
1721 if ((e->mask & IN_Q_OVERFLOW) || streq(e->name, "utab"))
1730 r = mount_load_proc_self_mountinfo(m, true);
1732 log_error_errno(r, "Failed to reread /proc/self/mountinfo: %m");
1734 /* Reset flags, just in case, for later calls */
1735 LIST_FOREACH(units_by_type, u, m->units_by_type[UNIT_MOUNT]) {
1736 Mount *mount = MOUNT(u);
1738 mount->is_mounted = mount->just_mounted = mount->just_changed = false;
1744 manager_dispatch_load_queue(m);
1746 LIST_FOREACH(units_by_type, u, m->units_by_type[UNIT_MOUNT]) {
1747 Mount *mount = MOUNT(u);
1749 if (!mount->is_mounted) {
1751 mount->from_proc_self_mountinfo = false;
1753 switch (mount->state) {
1756 /* This has just been unmounted by
1757 * somebody else, follow the state
1759 mount_enter_dead(mount, MOUNT_SUCCESS);
1766 } else if (mount->just_mounted || mount->just_changed) {
1768 /* New or changed mount entry */
1770 switch (mount->state) {
1774 /* This has just been mounted by
1775 * somebody else, follow the state
1777 mount_enter_mounted(mount, MOUNT_SUCCESS);
1780 case MOUNT_MOUNTING:
1781 mount_set_state(mount, MOUNT_MOUNTING_DONE);
1785 /* Nothing really changed, but let's
1786 * issue an notification call
1787 * nonetheless, in case somebody is
1788 * waiting for this. (e.g. file system
1789 * ro/rw remounts.) */
1790 mount_set_state(mount, mount->state);
1795 /* Reset the flags for later calls */
1796 mount->is_mounted = mount->just_mounted = mount->just_changed = false;
1802 static void mount_reset_failed(Unit *u) {
1803 Mount *m = MOUNT(u);
1807 if (m->state == MOUNT_FAILED)
1808 mount_set_state(m, MOUNT_DEAD);
1810 m->result = MOUNT_SUCCESS;
1811 m->reload_result = MOUNT_SUCCESS;
1814 static int mount_kill(Unit *u, KillWho who, int signo, sd_bus_error *error) {
1815 return unit_kill_common(u, who, signo, -1, MOUNT(u)->control_pid, error);
1818 static const char* const mount_state_table[_MOUNT_STATE_MAX] = {
1819 [MOUNT_DEAD] = "dead",
1820 [MOUNT_MOUNTING] = "mounting",
1821 [MOUNT_MOUNTING_DONE] = "mounting-done",
1822 [MOUNT_MOUNTED] = "mounted",
1823 [MOUNT_REMOUNTING] = "remounting",
1824 [MOUNT_UNMOUNTING] = "unmounting",
1825 [MOUNT_MOUNTING_SIGTERM] = "mounting-sigterm",
1826 [MOUNT_MOUNTING_SIGKILL] = "mounting-sigkill",
1827 [MOUNT_REMOUNTING_SIGTERM] = "remounting-sigterm",
1828 [MOUNT_REMOUNTING_SIGKILL] = "remounting-sigkill",
1829 [MOUNT_UNMOUNTING_SIGTERM] = "unmounting-sigterm",
1830 [MOUNT_UNMOUNTING_SIGKILL] = "unmounting-sigkill",
1831 [MOUNT_FAILED] = "failed"
1834 DEFINE_STRING_TABLE_LOOKUP(mount_state, MountState);
1836 static const char* const mount_exec_command_table[_MOUNT_EXEC_COMMAND_MAX] = {
1837 [MOUNT_EXEC_MOUNT] = "ExecMount",
1838 [MOUNT_EXEC_UNMOUNT] = "ExecUnmount",
1839 [MOUNT_EXEC_REMOUNT] = "ExecRemount",
1842 DEFINE_STRING_TABLE_LOOKUP(mount_exec_command, MountExecCommand);
1844 static const char* const mount_result_table[_MOUNT_RESULT_MAX] = {
1845 [MOUNT_SUCCESS] = "success",
1846 [MOUNT_FAILURE_RESOURCES] = "resources",
1847 [MOUNT_FAILURE_TIMEOUT] = "timeout",
1848 [MOUNT_FAILURE_EXIT_CODE] = "exit-code",
1849 [MOUNT_FAILURE_SIGNAL] = "signal",
1850 [MOUNT_FAILURE_CORE_DUMP] = "core-dump"
1853 DEFINE_STRING_TABLE_LOOKUP(mount_result, MountResult);
1855 const UnitVTable mount_vtable = {
1856 .object_size = sizeof(Mount),
1857 .exec_context_offset = offsetof(Mount, exec_context),
1858 .cgroup_context_offset = offsetof(Mount, cgroup_context),
1859 .kill_context_offset = offsetof(Mount, kill_context),
1860 .exec_runtime_offset = offsetof(Mount, exec_runtime),
1866 .private_section = "Mount",
1869 .no_instances = true,
1875 .coldplug = mount_coldplug,
1879 .start = mount_start,
1881 .reload = mount_reload,
1885 .serialize = mount_serialize,
1886 .deserialize_item = mount_deserialize_item,
1888 .active_state = mount_active_state,
1889 .sub_state_to_string = mount_sub_state_to_string,
1891 .check_gc = mount_check_gc,
1893 .sigchld_event = mount_sigchld_event,
1895 .reset_failed = mount_reset_failed,
1897 .bus_interface = "org.freedesktop.systemd1.Mount",
1898 .bus_vtable = bus_mount_vtable,
1899 .bus_set_property = bus_mount_set_property,
1900 .bus_commit_properties = bus_mount_commit_properties,
1902 .get_timeout = mount_get_timeout,
1904 .can_transient = true,
1906 .enumerate = mount_enumerate,
1907 .shutdown = mount_shutdown,
1909 .status_message_formats = {
1910 .starting_stopping = {
1911 [0] = "Mounting %s...",
1912 [1] = "Unmounting %s...",
1914 .finished_start_job = {
1915 [JOB_DONE] = "Mounted %s.",
1916 [JOB_FAILED] = "Failed to mount %s.",
1917 [JOB_DEPENDENCY] = "Dependency failed for %s.",
1918 [JOB_TIMEOUT] = "Timed out mounting %s.",
1920 .finished_stop_job = {
1921 [JOB_DONE] = "Unmounted %s.",
1922 [JOB_FAILED] = "Failed unmounting %s.",
1923 [JOB_TIMEOUT] = "Timed out unmounting %s.",