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 r = exec_command_set(m->control_command, "/bin/mount",
921 m->parameters_fragment.what, m->where, NULL);
922 if (r >= 0 && UNIT(m)->manager->running_as == SYSTEMD_SYSTEM)
923 r = exec_command_append(m->control_command, "-n", NULL);
924 if (r >= 0 && m->sloppy_options)
925 r = exec_command_append(m->control_command, "-s", NULL);
926 if (r >= 0 && m->parameters_fragment.fstype)
927 r = exec_command_append(m->control_command, "-t", m->parameters_fragment.fstype, NULL);
928 if (r >= 0 && m->parameters_fragment.options)
929 r = exec_command_append(m->control_command, "-o", m->parameters_fragment.options, NULL);
936 mount_unwatch_control_pid(m);
938 r = mount_spawn(m, m->control_command, &m->control_pid);
942 mount_set_state(m, MOUNT_MOUNTING);
947 log_unit_warning(UNIT(m)->id,
948 "%s failed to run 'mount' task: %s",
949 UNIT(m)->id, strerror(-r));
950 mount_enter_dead(m, MOUNT_FAILURE_RESOURCES);
953 static void mount_enter_remounting(Mount *m) {
958 m->control_command_id = MOUNT_EXEC_REMOUNT;
959 m->control_command = m->exec_command + MOUNT_EXEC_REMOUNT;
961 if (m->from_fragment) {
964 if (m->parameters_fragment.options)
965 o = strappenda("remount,", m->parameters_fragment.options);
969 r = exec_command_set(m->control_command, "/bin/mount",
970 m->parameters_fragment.what, m->where,
972 if (r >= 0 && UNIT(m)->manager->running_as == SYSTEMD_SYSTEM)
973 r = exec_command_append(m->control_command, "-n", NULL);
974 if (r >= 0 && m->sloppy_options)
975 r = exec_command_append(m->control_command, "-s", NULL);
976 if (r >= 0 && m->parameters_fragment.fstype)
977 r = exec_command_append(m->control_command, "-t", m->parameters_fragment.fstype, NULL);
984 mount_unwatch_control_pid(m);
986 r = mount_spawn(m, m->control_command, &m->control_pid);
990 mount_set_state(m, MOUNT_REMOUNTING);
995 log_unit_warning(UNIT(m)->id,
996 "%s failed to run 'remount' task: %s",
997 UNIT(m)->id, strerror(-r));
998 m->reload_result = MOUNT_FAILURE_RESOURCES;
999 mount_enter_mounted(m, MOUNT_SUCCESS);
1002 static int mount_start(Unit *u) {
1003 Mount *m = MOUNT(u);
1007 /* We cannot fulfill this request right now, try again later
1009 if (m->state == MOUNT_UNMOUNTING ||
1010 m->state == MOUNT_UNMOUNTING_SIGTERM ||
1011 m->state == MOUNT_UNMOUNTING_SIGKILL ||
1012 m->state == MOUNT_MOUNTING_SIGTERM ||
1013 m->state == MOUNT_MOUNTING_SIGKILL)
1016 /* Already on it! */
1017 if (m->state == MOUNT_MOUNTING)
1020 assert(m->state == MOUNT_DEAD || m->state == MOUNT_FAILED);
1022 m->result = MOUNT_SUCCESS;
1023 m->reload_result = MOUNT_SUCCESS;
1025 mount_enter_mounting(m);
1029 static int mount_stop(Unit *u) {
1030 Mount *m = MOUNT(u);
1035 if (m->state == MOUNT_UNMOUNTING ||
1036 m->state == MOUNT_UNMOUNTING_SIGKILL ||
1037 m->state == MOUNT_UNMOUNTING_SIGTERM ||
1038 m->state == MOUNT_MOUNTING_SIGTERM ||
1039 m->state == MOUNT_MOUNTING_SIGKILL)
1042 assert(m->state == MOUNT_MOUNTING ||
1043 m->state == MOUNT_MOUNTING_DONE ||
1044 m->state == MOUNT_MOUNTED ||
1045 m->state == MOUNT_REMOUNTING ||
1046 m->state == MOUNT_REMOUNTING_SIGTERM ||
1047 m->state == MOUNT_REMOUNTING_SIGKILL);
1049 mount_enter_unmounting(m);
1053 static int mount_reload(Unit *u) {
1054 Mount *m = MOUNT(u);
1058 if (m->state == MOUNT_MOUNTING_DONE)
1061 assert(m->state == MOUNT_MOUNTED);
1063 mount_enter_remounting(m);
1067 static int mount_serialize(Unit *u, FILE *f, FDSet *fds) {
1068 Mount *m = MOUNT(u);
1074 unit_serialize_item(u, f, "state", mount_state_to_string(m->state));
1075 unit_serialize_item(u, f, "result", mount_result_to_string(m->result));
1076 unit_serialize_item(u, f, "reload-result", mount_result_to_string(m->reload_result));
1078 if (m->control_pid > 0)
1079 unit_serialize_item_format(u, f, "control-pid", PID_FMT, m->control_pid);
1081 if (m->control_command_id >= 0)
1082 unit_serialize_item(u, f, "control-command", mount_exec_command_to_string(m->control_command_id));
1087 static int mount_deserialize_item(Unit *u, const char *key, const char *value, FDSet *fds) {
1088 Mount *m = MOUNT(u);
1095 if (streq(key, "state")) {
1098 if ((state = mount_state_from_string(value)) < 0)
1099 log_unit_debug(u->id, "Failed to parse state value %s", value);
1101 m->deserialized_state = state;
1102 } else if (streq(key, "result")) {
1105 f = mount_result_from_string(value);
1107 log_unit_debug(UNIT(m)->id,
1108 "Failed to parse result value %s", value);
1109 else if (f != MOUNT_SUCCESS)
1112 } else if (streq(key, "reload-result")) {
1115 f = mount_result_from_string(value);
1117 log_unit_debug(UNIT(m)->id,
1118 "Failed to parse reload result value %s", value);
1119 else if (f != MOUNT_SUCCESS)
1120 m->reload_result = f;
1122 } else if (streq(key, "control-pid")) {
1125 if (parse_pid(value, &pid) < 0)
1126 log_unit_debug(UNIT(m)->id,
1127 "Failed to parse control-pid value %s", value);
1129 m->control_pid = pid;
1130 } else if (streq(key, "control-command")) {
1131 MountExecCommand id;
1133 if ((id = mount_exec_command_from_string(value)) < 0)
1134 log_unit_debug(UNIT(m)->id,
1135 "Failed to parse exec-command value %s", value);
1137 m->control_command_id = id;
1138 m->control_command = m->exec_command + id;
1141 log_unit_debug(UNIT(m)->id,
1142 "Unknown serialization key '%s'", key);
1147 _pure_ static UnitActiveState mount_active_state(Unit *u) {
1150 return state_translation_table[MOUNT(u)->state];
1153 _pure_ static const char *mount_sub_state_to_string(Unit *u) {
1156 return mount_state_to_string(MOUNT(u)->state);
1159 _pure_ static bool mount_check_gc(Unit *u) {
1160 Mount *m = MOUNT(u);
1164 return m->from_proc_self_mountinfo;
1167 static void mount_sigchld_event(Unit *u, pid_t pid, int code, int status) {
1168 Mount *m = MOUNT(u);
1174 if (pid != m->control_pid)
1179 if (is_clean_exit(code, status, NULL))
1181 else if (code == CLD_EXITED)
1182 f = MOUNT_FAILURE_EXIT_CODE;
1183 else if (code == CLD_KILLED)
1184 f = MOUNT_FAILURE_SIGNAL;
1185 else if (code == CLD_DUMPED)
1186 f = MOUNT_FAILURE_CORE_DUMP;
1188 assert_not_reached("Unknown code");
1190 if (f != MOUNT_SUCCESS)
1193 if (m->control_command) {
1194 exec_status_exit(&m->control_command->exec_status, &m->exec_context, pid, code, status);
1196 m->control_command = NULL;
1197 m->control_command_id = _MOUNT_EXEC_COMMAND_INVALID;
1200 log_unit_full(u->id,
1201 f == MOUNT_SUCCESS ? LOG_DEBUG : LOG_NOTICE,
1202 "%s mount process exited, code=%s status=%i",
1203 u->id, sigchld_code_to_string(code), status);
1205 /* Note that mount(8) returning and the kernel sending us a
1206 * mount table change event might happen out-of-order. If an
1207 * operation succeed we assume the kernel will follow soon too
1208 * and already change into the resulting state. If it fails
1209 * we check if the kernel still knows about the mount. and
1210 * change state accordingly. */
1214 case MOUNT_MOUNTING:
1215 case MOUNT_MOUNTING_DONE:
1216 case MOUNT_MOUNTING_SIGKILL:
1217 case MOUNT_MOUNTING_SIGTERM:
1219 if (f == MOUNT_SUCCESS)
1220 mount_enter_mounted(m, f);
1221 else if (m->from_proc_self_mountinfo)
1222 mount_enter_mounted(m, f);
1224 mount_enter_dead(m, f);
1227 case MOUNT_REMOUNTING:
1228 case MOUNT_REMOUNTING_SIGKILL:
1229 case MOUNT_REMOUNTING_SIGTERM:
1231 m->reload_result = f;
1232 if (m->from_proc_self_mountinfo)
1233 mount_enter_mounted(m, MOUNT_SUCCESS);
1235 mount_enter_dead(m, MOUNT_SUCCESS);
1239 case MOUNT_UNMOUNTING:
1240 case MOUNT_UNMOUNTING_SIGKILL:
1241 case MOUNT_UNMOUNTING_SIGTERM:
1243 if (f == MOUNT_SUCCESS) {
1245 if (m->from_proc_self_mountinfo) {
1247 /* Still a mount point? If so, let's
1248 * try again. Most likely there were
1249 * multiple mount points stacked on
1250 * top of each other. Note that due to
1251 * the io event priority logic we can
1252 * be sure the new mountinfo is loaded
1253 * before we process the SIGCHLD for
1254 * the mount command. */
1256 if (m->n_retry_umount < RETRY_UMOUNT_MAX) {
1257 log_unit_debug(u->id, "%s: mount still present, trying again.", u->id);
1258 m->n_retry_umount++;
1259 mount_enter_unmounting(m);
1261 log_unit_debug(u->id, "%s: mount still present after %u attempts to unmount, giving up.", u->id, m->n_retry_umount);
1262 mount_enter_mounted(m, f);
1265 mount_enter_dead(m, f);
1267 } else if (m->from_proc_self_mountinfo)
1268 mount_enter_mounted(m, f);
1270 mount_enter_dead(m, f);
1274 assert_not_reached("Uh, control process died at wrong time.");
1277 /* Notify clients about changed exit status */
1278 unit_add_to_dbus_queue(u);
1281 static int mount_dispatch_timer(sd_event_source *source, usec_t usec, void *userdata) {
1282 Mount *m = MOUNT(userdata);
1285 assert(m->timer_event_source == source);
1289 case MOUNT_MOUNTING:
1290 case MOUNT_MOUNTING_DONE:
1291 log_unit_warning(UNIT(m)->id,
1292 "%s mounting timed out. Stopping.", UNIT(m)->id);
1293 mount_enter_signal(m, MOUNT_MOUNTING_SIGTERM, MOUNT_FAILURE_TIMEOUT);
1296 case MOUNT_REMOUNTING:
1297 log_unit_warning(UNIT(m)->id,
1298 "%s remounting timed out. Stopping.", UNIT(m)->id);
1299 m->reload_result = MOUNT_FAILURE_TIMEOUT;
1300 mount_enter_mounted(m, MOUNT_SUCCESS);
1303 case MOUNT_UNMOUNTING:
1304 log_unit_warning(UNIT(m)->id,
1305 "%s unmounting timed out. Stopping.", UNIT(m)->id);
1306 mount_enter_signal(m, MOUNT_UNMOUNTING_SIGTERM, MOUNT_FAILURE_TIMEOUT);
1309 case MOUNT_MOUNTING_SIGTERM:
1310 if (m->kill_context.send_sigkill) {
1311 log_unit_warning(UNIT(m)->id,
1312 "%s mounting timed out. Killing.", UNIT(m)->id);
1313 mount_enter_signal(m, MOUNT_MOUNTING_SIGKILL, MOUNT_FAILURE_TIMEOUT);
1315 log_unit_warning(UNIT(m)->id,
1316 "%s mounting timed out. Skipping SIGKILL. Ignoring.",
1319 if (m->from_proc_self_mountinfo)
1320 mount_enter_mounted(m, MOUNT_FAILURE_TIMEOUT);
1322 mount_enter_dead(m, MOUNT_FAILURE_TIMEOUT);
1326 case MOUNT_REMOUNTING_SIGTERM:
1327 if (m->kill_context.send_sigkill) {
1328 log_unit_warning(UNIT(m)->id,
1329 "%s remounting timed out. Killing.", UNIT(m)->id);
1330 mount_enter_signal(m, MOUNT_REMOUNTING_SIGKILL, MOUNT_FAILURE_TIMEOUT);
1332 log_unit_warning(UNIT(m)->id,
1333 "%s remounting timed out. Skipping SIGKILL. Ignoring.",
1336 if (m->from_proc_self_mountinfo)
1337 mount_enter_mounted(m, MOUNT_FAILURE_TIMEOUT);
1339 mount_enter_dead(m, MOUNT_FAILURE_TIMEOUT);
1343 case MOUNT_UNMOUNTING_SIGTERM:
1344 if (m->kill_context.send_sigkill) {
1345 log_unit_warning(UNIT(m)->id,
1346 "%s unmounting timed out. Killing.", UNIT(m)->id);
1347 mount_enter_signal(m, MOUNT_UNMOUNTING_SIGKILL, MOUNT_FAILURE_TIMEOUT);
1349 log_unit_warning(UNIT(m)->id,
1350 "%s unmounting timed out. Skipping SIGKILL. Ignoring.",
1353 if (m->from_proc_self_mountinfo)
1354 mount_enter_mounted(m, MOUNT_FAILURE_TIMEOUT);
1356 mount_enter_dead(m, MOUNT_FAILURE_TIMEOUT);
1360 case MOUNT_MOUNTING_SIGKILL:
1361 case MOUNT_REMOUNTING_SIGKILL:
1362 case MOUNT_UNMOUNTING_SIGKILL:
1363 log_unit_warning(UNIT(m)->id,
1364 "%s mount process still around after 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 assert_not_reached("Timeout at wrong time.");
1380 static int mount_add_one(
1384 const char *options,
1388 _cleanup_free_ char *e = NULL, *w = NULL, *o = NULL, *f = NULL;
1389 bool load_extras = false;
1391 bool delete, changed = false;
1401 /* Ignore API mount points. They should never be referenced in
1402 * dependencies ever. */
1403 if (mount_point_is_api(where) || mount_point_ignore(where))
1406 if (streq(fstype, "autofs"))
1409 /* probably some kind of swap, ignore */
1410 if (!is_path(where))
1413 e = unit_name_from_path(where, ".mount");
1417 u = manager_get_unit(m, e);
1421 u = unit_new(m, sizeof(Mount));
1425 r = unit_add_name(u, e);
1429 MOUNT(u)->where = strdup(where);
1430 if (!MOUNT(u)->where) {
1435 u->source_path = strdup("/proc/self/mountinfo");
1436 if (!u->source_path) {
1441 if (m->running_as == SYSTEMD_SYSTEM) {
1444 target = mount_needs_network(options, fstype) ? SPECIAL_REMOTE_FS_TARGET : SPECIAL_LOCAL_FS_TARGET;
1445 r = unit_add_dependency_by_name(u, UNIT_BEFORE, target, NULL, true);
1449 if (should_umount(MOUNT(u))) {
1450 r = unit_add_dependency_by_name(u, UNIT_CONFLICTS, SPECIAL_UMOUNT_TARGET, NULL, true);
1456 unit_add_to_load_queue(u);
1461 if (!MOUNT(u)->where) {
1462 MOUNT(u)->where = strdup(where);
1463 if (!MOUNT(u)->where) {
1469 if (m->running_as == SYSTEMD_SYSTEM &&
1470 mount_needs_network(options, fstype)) {
1471 /* _netdev option may have shown up late, or on a
1472 * remount. Add remote-fs dependencies, even though
1473 * local-fs ones may already be there. */
1474 unit_add_dependency_by_name(u, UNIT_BEFORE, SPECIAL_REMOTE_FS_TARGET, NULL, true);
1478 if (u->load_state == UNIT_NOT_FOUND) {
1479 u->load_state = UNIT_LOADED;
1482 /* Load in the extras later on, after we
1483 * finished initialization of the unit */
1490 o = strdup(options);
1492 if (!w || !o || !f) {
1497 p = &MOUNT(u)->parameters_proc_self_mountinfo;
1499 changed = changed ||
1500 !streq_ptr(p->options, options) ||
1501 !streq_ptr(p->what, what) ||
1502 !streq_ptr(p->fstype, fstype);
1505 MOUNT(u)->is_mounted = true;
1506 MOUNT(u)->just_mounted = !MOUNT(u)->from_proc_self_mountinfo;
1507 MOUNT(u)->just_changed = changed;
1510 MOUNT(u)->from_proc_self_mountinfo = true;
1525 r = mount_add_extras(MOUNT(u));
1531 unit_add_to_dbus_queue(u);
1542 static int mount_load_proc_self_mountinfo(Manager *m, bool set_flags) {
1543 _cleanup_(mnt_free_tablep) struct libmnt_table *tb = NULL;
1544 _cleanup_(mnt_free_iterp) struct libmnt_iter *itr = NULL;
1545 struct libmnt_fs *fs;
1550 tb = mnt_new_table();
1551 itr = mnt_new_iter(MNT_ITER_FORWARD);
1555 r = mnt_table_parse_mtab(tb, NULL);
1561 const char *device, *path, *options, *fstype;
1562 _cleanup_free_ const char *d = NULL, *p = NULL;
1565 k = mnt_table_next_fs(tb, itr, &fs);
1569 return log_error_errno(k, "Failed to get next entry from /etc/fstab: %m");
1571 device = mnt_fs_get_source(fs);
1572 path = mnt_fs_get_target(fs);
1573 options = mnt_fs_get_options(fs);
1574 fstype = mnt_fs_get_fstype(fs);
1576 d = cunescape(device);
1577 p = cunescape(path);
1581 k = mount_add_one(m, d, p, options, fstype, set_flags);
1582 if (r == 0 && k < 0)
1589 static void mount_shutdown(Manager *m) {
1592 m->mount_event_source = sd_event_source_unref(m->mount_event_source);
1593 m->mount_utab_event_source = sd_event_source_unref(m->mount_utab_event_source);
1595 if (m->proc_self_mountinfo) {
1596 fclose(m->proc_self_mountinfo);
1597 m->proc_self_mountinfo = NULL;
1599 m->utab_inotify_fd = safe_close(m->utab_inotify_fd);
1602 static int mount_get_timeout(Unit *u, uint64_t *timeout) {
1603 Mount *m = MOUNT(u);
1606 if (!m->timer_event_source)
1609 r = sd_event_source_get_time(m->timer_event_source, timeout);
1616 static int mount_enumerate(Manager *m) {
1622 if (!m->proc_self_mountinfo) {
1623 m->proc_self_mountinfo = fopen("/proc/self/mountinfo", "re");
1624 if (!m->proc_self_mountinfo)
1627 r = sd_event_add_io(m->event, &m->mount_event_source, fileno(m->proc_self_mountinfo), EPOLLPRI, mount_dispatch_io, m);
1631 /* Dispatch this before we dispatch SIGCHLD, so that
1632 * we always get the events from /proc/self/mountinfo
1633 * before the SIGCHLD of /bin/mount. */
1634 r = sd_event_source_set_priority(m->mount_event_source, -10);
1639 if (m->utab_inotify_fd < 0) {
1640 m->utab_inotify_fd = inotify_init1(IN_NONBLOCK|IN_CLOEXEC);
1641 if (m->utab_inotify_fd < 0) {
1646 (void) mkdir_p_label("/run/mount", 0755);
1648 r = inotify_add_watch(m->utab_inotify_fd, "/run/mount", IN_MOVED_TO);
1654 r = sd_event_add_io(m->event, &m->mount_utab_event_source, m->utab_inotify_fd, EPOLLIN, mount_dispatch_io, m);
1658 r = sd_event_source_set_priority(m->mount_utab_event_source, -10);
1663 r = mount_load_proc_self_mountinfo(m, false);
1674 static int mount_dispatch_io(sd_event_source *source, int fd, uint32_t revents, void *userdata) {
1675 Manager *m = userdata;
1680 assert(revents & (EPOLLPRI | EPOLLIN));
1682 /* The manager calls this for every fd event happening on the
1683 * /proc/self/mountinfo file, which informs us about mounting
1684 * table changes, and for /run/mount events which we watch
1685 * for mount options. */
1687 if (fd == m->utab_inotify_fd) {
1688 bool rescan = false;
1690 /* FIXME: We *really* need to replace this with
1691 * libmount's own API for this, we should not hardcode
1692 * internal behaviour of libmount here. */
1695 union inotify_event_buffer buffer;
1696 struct inotify_event *e;
1699 l = read(fd, &buffer, sizeof(buffer));
1701 if (errno == EAGAIN || errno == EINTR)
1704 log_error_errno(errno, "Failed to read utab inotify: %m");
1708 FOREACH_INOTIFY_EVENT(e, buffer, l) {
1709 /* Only care about changes to utab,
1710 * but we have to monitor the
1711 * directory to reliably get
1712 * notifications about when utab is
1713 * replaced using rename(2) */
1714 if ((e->mask & IN_Q_OVERFLOW) || streq(e->name, "utab"))
1723 r = mount_load_proc_self_mountinfo(m, true);
1725 log_error_errno(r, "Failed to reread /proc/self/mountinfo: %m");
1727 /* Reset flags, just in case, for later calls */
1728 LIST_FOREACH(units_by_type, u, m->units_by_type[UNIT_MOUNT]) {
1729 Mount *mount = MOUNT(u);
1731 mount->is_mounted = mount->just_mounted = mount->just_changed = false;
1737 manager_dispatch_load_queue(m);
1739 LIST_FOREACH(units_by_type, u, m->units_by_type[UNIT_MOUNT]) {
1740 Mount *mount = MOUNT(u);
1742 if (!mount->is_mounted) {
1744 mount->from_proc_self_mountinfo = false;
1746 switch (mount->state) {
1749 /* This has just been unmounted by
1750 * somebody else, follow the state
1752 mount_enter_dead(mount, MOUNT_SUCCESS);
1759 } else if (mount->just_mounted || mount->just_changed) {
1761 /* New or changed mount entry */
1763 switch (mount->state) {
1767 /* This has just been mounted by
1768 * somebody else, follow the state
1770 mount_enter_mounted(mount, MOUNT_SUCCESS);
1773 case MOUNT_MOUNTING:
1774 mount_set_state(mount, MOUNT_MOUNTING_DONE);
1778 /* Nothing really changed, but let's
1779 * issue an notification call
1780 * nonetheless, in case somebody is
1781 * waiting for this. (e.g. file system
1782 * ro/rw remounts.) */
1783 mount_set_state(mount, mount->state);
1788 /* Reset the flags for later calls */
1789 mount->is_mounted = mount->just_mounted = mount->just_changed = false;
1795 static void mount_reset_failed(Unit *u) {
1796 Mount *m = MOUNT(u);
1800 if (m->state == MOUNT_FAILED)
1801 mount_set_state(m, MOUNT_DEAD);
1803 m->result = MOUNT_SUCCESS;
1804 m->reload_result = MOUNT_SUCCESS;
1807 static int mount_kill(Unit *u, KillWho who, int signo, sd_bus_error *error) {
1808 return unit_kill_common(u, who, signo, -1, MOUNT(u)->control_pid, error);
1811 static const char* const mount_state_table[_MOUNT_STATE_MAX] = {
1812 [MOUNT_DEAD] = "dead",
1813 [MOUNT_MOUNTING] = "mounting",
1814 [MOUNT_MOUNTING_DONE] = "mounting-done",
1815 [MOUNT_MOUNTED] = "mounted",
1816 [MOUNT_REMOUNTING] = "remounting",
1817 [MOUNT_UNMOUNTING] = "unmounting",
1818 [MOUNT_MOUNTING_SIGTERM] = "mounting-sigterm",
1819 [MOUNT_MOUNTING_SIGKILL] = "mounting-sigkill",
1820 [MOUNT_REMOUNTING_SIGTERM] = "remounting-sigterm",
1821 [MOUNT_REMOUNTING_SIGKILL] = "remounting-sigkill",
1822 [MOUNT_UNMOUNTING_SIGTERM] = "unmounting-sigterm",
1823 [MOUNT_UNMOUNTING_SIGKILL] = "unmounting-sigkill",
1824 [MOUNT_FAILED] = "failed"
1827 DEFINE_STRING_TABLE_LOOKUP(mount_state, MountState);
1829 static const char* const mount_exec_command_table[_MOUNT_EXEC_COMMAND_MAX] = {
1830 [MOUNT_EXEC_MOUNT] = "ExecMount",
1831 [MOUNT_EXEC_UNMOUNT] = "ExecUnmount",
1832 [MOUNT_EXEC_REMOUNT] = "ExecRemount",
1835 DEFINE_STRING_TABLE_LOOKUP(mount_exec_command, MountExecCommand);
1837 static const char* const mount_result_table[_MOUNT_RESULT_MAX] = {
1838 [MOUNT_SUCCESS] = "success",
1839 [MOUNT_FAILURE_RESOURCES] = "resources",
1840 [MOUNT_FAILURE_TIMEOUT] = "timeout",
1841 [MOUNT_FAILURE_EXIT_CODE] = "exit-code",
1842 [MOUNT_FAILURE_SIGNAL] = "signal",
1843 [MOUNT_FAILURE_CORE_DUMP] = "core-dump"
1846 DEFINE_STRING_TABLE_LOOKUP(mount_result, MountResult);
1848 const UnitVTable mount_vtable = {
1849 .object_size = sizeof(Mount),
1850 .exec_context_offset = offsetof(Mount, exec_context),
1851 .cgroup_context_offset = offsetof(Mount, cgroup_context),
1852 .kill_context_offset = offsetof(Mount, kill_context),
1853 .exec_runtime_offset = offsetof(Mount, exec_runtime),
1859 .private_section = "Mount",
1862 .no_instances = true,
1868 .coldplug = mount_coldplug,
1872 .start = mount_start,
1874 .reload = mount_reload,
1878 .serialize = mount_serialize,
1879 .deserialize_item = mount_deserialize_item,
1881 .active_state = mount_active_state,
1882 .sub_state_to_string = mount_sub_state_to_string,
1884 .check_gc = mount_check_gc,
1886 .sigchld_event = mount_sigchld_event,
1888 .reset_failed = mount_reset_failed,
1890 .bus_interface = "org.freedesktop.systemd1.Mount",
1891 .bus_vtable = bus_mount_vtable,
1892 .bus_set_property = bus_mount_set_property,
1893 .bus_commit_properties = bus_mount_commit_properties,
1895 .get_timeout = mount_get_timeout,
1897 .can_transient = true,
1899 .enumerate = mount_enumerate,
1900 .shutdown = mount_shutdown,
1902 .status_message_formats = {
1903 .starting_stopping = {
1904 [0] = "Mounting %s...",
1905 [1] = "Unmounting %s...",
1907 .finished_start_job = {
1908 [JOB_DONE] = "Mounted %s.",
1909 [JOB_FAILED] = "Failed to mount %s.",
1910 [JOB_DEPENDENCY] = "Dependency failed for %s.",
1911 [JOB_TIMEOUT] = "Timed out mounting %s.",
1913 .finished_stop_job = {
1914 [JOB_DONE] = "Unmounted %s.",
1915 [JOB_FAILED] = "Failed unmounting %s.",
1916 [JOB_TIMEOUT] = "Timed out unmounting %s.",