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"
48 #define RETRY_UMOUNT_MAX 32
50 DEFINE_TRIVIAL_CLEANUP_FUNC(struct libmnt_table*, mnt_free_table);
51 DEFINE_TRIVIAL_CLEANUP_FUNC(struct libmnt_iter*, mnt_free_iter);
53 static const UnitActiveState state_translation_table[_MOUNT_STATE_MAX] = {
54 [MOUNT_DEAD] = UNIT_INACTIVE,
55 [MOUNT_MOUNTING] = UNIT_ACTIVATING,
56 [MOUNT_MOUNTING_DONE] = UNIT_ACTIVE,
57 [MOUNT_MOUNTED] = UNIT_ACTIVE,
58 [MOUNT_REMOUNTING] = UNIT_RELOADING,
59 [MOUNT_UNMOUNTING] = UNIT_DEACTIVATING,
60 [MOUNT_MOUNTING_SIGTERM] = UNIT_DEACTIVATING,
61 [MOUNT_MOUNTING_SIGKILL] = UNIT_DEACTIVATING,
62 [MOUNT_REMOUNTING_SIGTERM] = UNIT_RELOADING,
63 [MOUNT_REMOUNTING_SIGKILL] = UNIT_RELOADING,
64 [MOUNT_UNMOUNTING_SIGTERM] = UNIT_DEACTIVATING,
65 [MOUNT_UNMOUNTING_SIGKILL] = UNIT_DEACTIVATING,
66 [MOUNT_FAILED] = UNIT_FAILED
69 static int mount_dispatch_timer(sd_event_source *source, usec_t usec, void *userdata);
70 static int mount_dispatch_io(sd_event_source *source, int fd, uint32_t revents, void *userdata);
72 static bool mount_needs_network(const char *options, const char *fstype) {
73 if (mount_test_option(options, "_netdev"))
76 if (fstype && fstype_is_network(fstype))
82 static bool mount_is_network(const MountParameters *p) {
85 return mount_needs_network(p->options, p->fstype);
88 static bool mount_is_bind(const MountParameters *p) {
91 if (mount_test_option(p->options, "bind"))
94 if (p->fstype && streq(p->fstype, "bind"))
97 if (mount_test_option(p->options, "rbind"))
100 if (p->fstype && streq(p->fstype, "rbind"))
106 static bool mount_is_auto(const MountParameters *p) {
109 return !mount_test_option(p->options, "noauto");
112 static bool needs_quota(const MountParameters *p) {
115 if (mount_is_network(p))
118 if (mount_is_bind(p))
121 return mount_test_option(p->options, "usrquota") ||
122 mount_test_option(p->options, "grpquota") ||
123 mount_test_option(p->options, "quota") ||
124 mount_test_option(p->options, "usrjquota") ||
125 mount_test_option(p->options, "grpjquota");
128 static void mount_init(Unit *u) {
132 assert(u->load_state == UNIT_STUB);
134 m->timeout_usec = u->manager->default_timeout_start_usec;
135 m->directory_mode = 0755;
137 if (unit_has_name(u, "-.mount")) {
138 /* Don't allow start/stop for root directory */
139 u->refuse_manual_start = true;
140 u->refuse_manual_stop = true;
142 /* The stdio/kmsg bridge socket is on /, in order to avoid a
143 * dep loop, don't use kmsg logging for -.mount */
144 m->exec_context.std_output = u->manager->default_std_output;
145 m->exec_context.std_error = u->manager->default_std_error;
148 /* We need to make sure that /bin/mount is always called in
149 * the same process group as us, so that the autofs kernel
150 * side doesn't send us another mount request while we are
151 * already trying to comply its last one. */
152 m->exec_context.same_pgrp = true;
154 m->control_command_id = _MOUNT_EXEC_COMMAND_INVALID;
156 u->ignore_on_isolate = true;
159 static int mount_arm_timer(Mount *m) {
164 if (m->timeout_usec <= 0) {
165 m->timer_event_source = sd_event_source_unref(m->timer_event_source);
169 if (m->timer_event_source) {
170 r = sd_event_source_set_time(m->timer_event_source, now(CLOCK_MONOTONIC) + m->timeout_usec);
174 return sd_event_source_set_enabled(m->timer_event_source, SD_EVENT_ONESHOT);
177 return sd_event_add_time(
178 UNIT(m)->manager->event,
179 &m->timer_event_source,
181 now(CLOCK_MONOTONIC) + m->timeout_usec, 0,
182 mount_dispatch_timer, m);
185 static void mount_unwatch_control_pid(Mount *m) {
188 if (m->control_pid <= 0)
191 unit_unwatch_pid(UNIT(m), m->control_pid);
195 static void mount_parameters_done(MountParameters *p) {
202 p->what = p->options = p->fstype = NULL;
205 static void mount_done(Unit *u) {
213 mount_parameters_done(&m->parameters_proc_self_mountinfo);
214 mount_parameters_done(&m->parameters_fragment);
216 m->exec_runtime = exec_runtime_unref(m->exec_runtime);
217 exec_command_done_array(m->exec_command, _MOUNT_EXEC_COMMAND_MAX);
218 m->control_command = NULL;
220 mount_unwatch_control_pid(m);
222 m->timer_event_source = sd_event_source_unref(m->timer_event_source);
225 _pure_ static MountParameters* get_mount_parameters_fragment(Mount *m) {
228 if (m->from_fragment)
229 return &m->parameters_fragment;
234 _pure_ static MountParameters* get_mount_parameters(Mount *m) {
237 if (m->from_proc_self_mountinfo)
238 return &m->parameters_proc_self_mountinfo;
240 return get_mount_parameters_fragment(m);
243 static int mount_add_mount_links(Mount *m) {
244 _cleanup_free_ char *parent = NULL;
253 if (!path_equal(m->where, "/")) {
254 /* Adds in links to other mount points that might lie further
255 * up in the hierarchy */
256 r = path_get_parent(m->where, &parent);
260 r = unit_require_mounts_for(UNIT(m), parent);
265 /* Adds in links to other mount points that might be needed
266 * for the source path (if this is a bind mount) to be
268 pm = get_mount_parameters_fragment(m);
269 if (pm && pm->what &&
270 path_is_absolute(pm->what) &&
271 !mount_is_network(pm)) {
273 r = unit_require_mounts_for(UNIT(m), pm->what);
278 /* Adds in links to other units that use this path or paths
279 * further down in the hierarchy */
280 s = manager_get_units_requiring_mounts_for(UNIT(m)->manager, m->where);
281 SET_FOREACH(other, s, i) {
283 if (other->load_state != UNIT_LOADED)
286 if (other == UNIT(m))
289 r = unit_add_dependency(other, UNIT_AFTER, UNIT(m), true);
293 if (UNIT(m)->fragment_path) {
294 /* If we have fragment configuration, then make this dependency required */
295 r = unit_add_dependency(other, UNIT_REQUIRES, UNIT(m), true);
304 static int mount_add_device_links(Mount *m) {
306 bool device_wants_mount = false;
311 p = get_mount_parameters_fragment(m);
318 if (mount_is_bind(p))
321 if (!is_device_path(p->what))
324 if (path_equal(m->where, "/"))
327 if (mount_is_auto(p) && UNIT(m)->manager->running_as == SYSTEMD_SYSTEM)
328 device_wants_mount = true;
330 r = unit_add_node_link(UNIT(m), p->what, device_wants_mount);
337 static int mount_add_quota_links(Mount *m) {
343 if (UNIT(m)->manager->running_as != SYSTEMD_SYSTEM)
346 p = get_mount_parameters_fragment(m);
353 r = unit_add_two_dependencies_by_name(UNIT(m), UNIT_BEFORE, UNIT_WANTS, SPECIAL_QUOTACHECK_SERVICE, NULL, true);
357 r = unit_add_two_dependencies_by_name(UNIT(m), UNIT_BEFORE, UNIT_WANTS, SPECIAL_QUOTAON_SERVICE, NULL, true);
364 static bool should_umount(Mount *m) {
367 if (path_equal(m->where, "/") ||
368 path_equal(m->where, "/usr"))
371 p = get_mount_parameters(m);
372 if (p && mount_test_option(p->options, "x-initrd.mount") &&
379 static int mount_add_default_dependencies(Mount *m) {
380 const char *after, *after2, *online;
386 if (UNIT(m)->manager->running_as != SYSTEMD_SYSTEM)
389 p = get_mount_parameters(m);
394 if (path_equal(m->where, "/") ||
395 path_equal(m->where, "/usr"))
398 if (mount_is_network(p)) {
399 after = SPECIAL_REMOTE_FS_PRE_TARGET;
400 after2 = SPECIAL_NETWORK_TARGET;
401 online = SPECIAL_NETWORK_ONLINE_TARGET;
403 after = SPECIAL_LOCAL_FS_PRE_TARGET;
408 r = unit_add_dependency_by_name(UNIT(m), UNIT_AFTER, after, NULL, true);
413 r = unit_add_dependency_by_name(UNIT(m), UNIT_AFTER, after2, NULL, true);
419 r = unit_add_two_dependencies_by_name(UNIT(m), UNIT_WANTS, UNIT_AFTER, online, NULL, true);
424 if (should_umount(m)) {
425 r = unit_add_two_dependencies_by_name(UNIT(m), UNIT_BEFORE, UNIT_CONFLICTS, SPECIAL_UMOUNT_TARGET, NULL, true);
433 static int mount_verify(Mount *m) {
434 _cleanup_free_ char *e = NULL;
439 if (UNIT(m)->load_state != UNIT_LOADED)
442 if (!m->from_fragment && !m->from_proc_self_mountinfo)
445 e = unit_name_from_path(m->where, ".mount");
449 b = unit_has_name(UNIT(m), e);
451 log_unit_error(UNIT(m)->id, "%s's Where= setting doesn't match unit name. Refusing.", UNIT(m)->id);
455 if (mount_point_is_api(m->where) || mount_point_ignore(m->where)) {
456 log_unit_error(UNIT(m)->id, "Cannot create mount unit for API file system %s. Refusing.", m->where);
460 if (UNIT(m)->fragment_path && !m->parameters_fragment.what) {
461 log_unit_error(UNIT(m)->id, "%s's What setting is missing. Refusing.", UNIT(m)->id);
465 if (m->exec_context.pam_name && m->kill_context.kill_mode != KILL_CONTROL_GROUP) {
466 log_unit_error(UNIT(m)->id, "%s has PAM enabled. Kill mode must be set to control-group'. Refusing.",UNIT(m)->id);
473 static int mount_add_extras(Mount *m) {
479 if (u->fragment_path)
480 m->from_fragment = true;
483 m->where = unit_name_to_path(u->id);
488 path_kill_slashes(m->where);
490 if (!u->description) {
491 r = unit_set_description(u, m->where);
496 r = mount_add_device_links(m);
500 r = mount_add_mount_links(m);
504 r = mount_add_quota_links(m);
508 r = unit_patch_contexts(u);
512 r = unit_add_exec_dependencies(u, &m->exec_context);
516 r = unit_add_default_slice(u, &m->cgroup_context);
520 if (u->default_dependencies) {
521 r = mount_add_default_dependencies(m);
529 static int mount_load(Unit *u) {
534 assert(u->load_state == UNIT_STUB);
536 if (m->from_proc_self_mountinfo)
537 r = unit_load_fragment_and_dropin_optional(u);
539 r = unit_load_fragment_and_dropin(u);
544 /* This is a new unit? Then let's add in some extras */
545 if (u->load_state == UNIT_LOADED) {
546 r = mount_add_extras(m);
551 return mount_verify(m);
554 static int mount_notify_automount(Mount *m, int status) {
561 SET_FOREACH(p, UNIT(m)->dependencies[UNIT_TRIGGERED_BY], i)
562 if (p->type == UNIT_AUTOMOUNT) {
563 r = automount_send_ready(AUTOMOUNT(p), status);
571 static void mount_set_state(Mount *m, MountState state) {
572 MountState old_state;
575 old_state = m->state;
578 if (state != MOUNT_MOUNTING &&
579 state != MOUNT_MOUNTING_DONE &&
580 state != MOUNT_REMOUNTING &&
581 state != MOUNT_UNMOUNTING &&
582 state != MOUNT_MOUNTING_SIGTERM &&
583 state != MOUNT_MOUNTING_SIGKILL &&
584 state != MOUNT_UNMOUNTING_SIGTERM &&
585 state != MOUNT_UNMOUNTING_SIGKILL &&
586 state != MOUNT_REMOUNTING_SIGTERM &&
587 state != MOUNT_REMOUNTING_SIGKILL) {
588 m->timer_event_source = sd_event_source_unref(m->timer_event_source);
589 mount_unwatch_control_pid(m);
590 m->control_command = NULL;
591 m->control_command_id = _MOUNT_EXEC_COMMAND_INVALID;
594 if (state == MOUNT_MOUNTED ||
595 state == MOUNT_REMOUNTING)
596 mount_notify_automount(m, 0);
597 else if (state == MOUNT_DEAD ||
598 state == MOUNT_UNMOUNTING ||
599 state == MOUNT_MOUNTING_SIGTERM ||
600 state == MOUNT_MOUNTING_SIGKILL ||
601 state == MOUNT_REMOUNTING_SIGTERM ||
602 state == MOUNT_REMOUNTING_SIGKILL ||
603 state == MOUNT_UNMOUNTING_SIGTERM ||
604 state == MOUNT_UNMOUNTING_SIGKILL ||
605 state == MOUNT_FAILED) {
606 if (state != old_state)
607 mount_notify_automount(m, -ENODEV);
610 if (state != old_state)
611 log_unit_debug(UNIT(m)->id,
612 "%s changed %s -> %s",
614 mount_state_to_string(old_state),
615 mount_state_to_string(state));
617 unit_notify(UNIT(m), state_translation_table[old_state], state_translation_table[state], m->reload_result == MOUNT_SUCCESS);
618 m->reload_result = MOUNT_SUCCESS;
621 static int mount_coldplug(Unit *u) {
623 MountState new_state = MOUNT_DEAD;
627 assert(m->state == MOUNT_DEAD);
629 if (m->deserialized_state != m->state)
630 new_state = m->deserialized_state;
631 else if (m->from_proc_self_mountinfo)
632 new_state = MOUNT_MOUNTED;
634 if (new_state == m->state)
637 if (new_state == MOUNT_MOUNTING ||
638 new_state == MOUNT_MOUNTING_DONE ||
639 new_state == MOUNT_REMOUNTING ||
640 new_state == MOUNT_UNMOUNTING ||
641 new_state == MOUNT_MOUNTING_SIGTERM ||
642 new_state == MOUNT_MOUNTING_SIGKILL ||
643 new_state == MOUNT_UNMOUNTING_SIGTERM ||
644 new_state == MOUNT_UNMOUNTING_SIGKILL ||
645 new_state == MOUNT_REMOUNTING_SIGTERM ||
646 new_state == MOUNT_REMOUNTING_SIGKILL) {
648 if (m->control_pid <= 0)
651 r = unit_watch_pid(UNIT(m), m->control_pid);
655 r = mount_arm_timer(m);
660 mount_set_state(m, new_state);
664 static void mount_dump(Unit *u, FILE *f, const char *prefix) {
671 p = get_mount_parameters(m);
674 "%sMount State: %s\n"
678 "%sFile System Type: %s\n"
680 "%sFrom /proc/self/mountinfo: %s\n"
681 "%sFrom fragment: %s\n"
682 "%sDirectoryMode: %04o\n",
683 prefix, mount_state_to_string(m->state),
684 prefix, mount_result_to_string(m->result),
686 prefix, p ? strna(p->what) : "n/a",
687 prefix, p ? strna(p->fstype) : "n/a",
688 prefix, p ? strna(p->options) : "n/a",
689 prefix, yes_no(m->from_proc_self_mountinfo),
690 prefix, yes_no(m->from_fragment),
691 prefix, m->directory_mode);
693 if (m->control_pid > 0)
695 "%sControl PID: "PID_FMT"\n",
696 prefix, m->control_pid);
698 exec_context_dump(&m->exec_context, f, prefix);
699 kill_context_dump(&m->kill_context, f, prefix);
702 static int mount_spawn(Mount *m, ExecCommand *c, pid_t *_pid) {
705 ExecParameters exec_params = {
706 .apply_permissions = true,
707 .apply_chroot = true,
708 .apply_tty_stdin = true,
715 unit_realize_cgroup(UNIT(m));
717 r = unit_setup_exec_runtime(UNIT(m));
721 r = mount_arm_timer(m);
725 exec_params.environment = UNIT(m)->manager->environment;
726 exec_params.confirm_spawn = UNIT(m)->manager->confirm_spawn;
727 exec_params.cgroup_supported = UNIT(m)->manager->cgroup_supported;
728 exec_params.cgroup_path = UNIT(m)->cgroup_path;
729 exec_params.cgroup_delegate = m->cgroup_context.delegate;
730 exec_params.runtime_prefix = manager_get_runtime_prefix(UNIT(m)->manager);
731 exec_params.unit_id = UNIT(m)->id;
741 r = unit_watch_pid(UNIT(m), pid);
743 /* FIXME: we need to do something here */
751 m->timer_event_source = sd_event_source_unref(m->timer_event_source);
756 static void mount_enter_dead(Mount *m, MountResult f) {
759 if (f != MOUNT_SUCCESS)
762 exec_runtime_destroy(m->exec_runtime);
763 m->exec_runtime = exec_runtime_unref(m->exec_runtime);
765 exec_context_destroy_runtime_directory(&m->exec_context, manager_get_runtime_prefix(UNIT(m)->manager));
767 mount_set_state(m, m->result != MOUNT_SUCCESS ? MOUNT_FAILED : MOUNT_DEAD);
770 static void mount_enter_mounted(Mount *m, MountResult f) {
773 if (f != MOUNT_SUCCESS)
776 mount_set_state(m, MOUNT_MOUNTED);
779 static void mount_enter_signal(Mount *m, MountState state, MountResult f) {
784 if (f != MOUNT_SUCCESS)
787 r = unit_kill_context(
790 (state != MOUNT_MOUNTING_SIGTERM && state != MOUNT_UNMOUNTING_SIGTERM && state != MOUNT_REMOUNTING_SIGTERM) ?
791 KILL_KILL : KILL_TERMINATE,
799 r = mount_arm_timer(m);
803 mount_set_state(m, state);
804 } else if (state == MOUNT_REMOUNTING_SIGTERM)
805 mount_enter_signal(m, MOUNT_REMOUNTING_SIGKILL, MOUNT_SUCCESS);
806 else if (state == MOUNT_REMOUNTING_SIGKILL)
807 mount_enter_mounted(m, MOUNT_SUCCESS);
808 else if (state == MOUNT_MOUNTING_SIGTERM)
809 mount_enter_signal(m, MOUNT_MOUNTING_SIGKILL, MOUNT_SUCCESS);
810 else if (state == MOUNT_UNMOUNTING_SIGTERM)
811 mount_enter_signal(m, MOUNT_UNMOUNTING_SIGKILL, MOUNT_SUCCESS);
813 mount_enter_dead(m, MOUNT_SUCCESS);
818 log_unit_warning(UNIT(m)->id,
819 "%s failed to kill processes: %s", UNIT(m)->id, strerror(-r));
821 if (state == MOUNT_REMOUNTING_SIGTERM || state == MOUNT_REMOUNTING_SIGKILL)
822 mount_enter_mounted(m, MOUNT_FAILURE_RESOURCES);
824 mount_enter_dead(m, MOUNT_FAILURE_RESOURCES);
827 void warn_if_dir_nonempty(const char *unit, const char* where) {
833 r = dir_is_empty(where);
837 log_unit_struct(unit,
839 LOG_MESSAGE_ID(SD_MESSAGE_OVERMOUNTING),
840 LOG_MESSAGE("%s: Directory %s to mount over is not empty, mounting anyway.",
845 log_unit_warning(unit,
846 "MESSAGE=Failed to check directory %s: %s",
847 where, strerror(-r));
850 static int fail_if_symlink(const char *unit, const char* where) {
853 if (is_symlink(where) > 0) {
854 log_unit_struct(unit,
856 LOG_MESSAGE_ID(SD_MESSAGE_OVERMOUNTING),
857 LOG_MESSAGE("%s: Mount on symlink %s not allowed.",
867 static void mount_enter_unmounting(Mount *m) {
872 /* Start counting our attempts */
873 if (!IN_SET(m->state,
875 MOUNT_UNMOUNTING_SIGTERM,
876 MOUNT_UNMOUNTING_SIGKILL))
877 m->n_retry_umount = 0;
879 m->control_command_id = MOUNT_EXEC_UNMOUNT;
880 m->control_command = m->exec_command + MOUNT_EXEC_UNMOUNT;
882 r = exec_command_set(m->control_command, "/bin/umount", m->where, NULL);
883 if (r >= 0 && UNIT(m)->manager->running_as == SYSTEMD_SYSTEM)
884 r = exec_command_append(m->control_command, "-n", NULL);
888 mount_unwatch_control_pid(m);
890 r = mount_spawn(m, m->control_command, &m->control_pid);
894 mount_set_state(m, MOUNT_UNMOUNTING);
899 log_unit_warning(UNIT(m)->id,
900 "%s failed to run 'umount' task: %s",
901 UNIT(m)->id, strerror(-r));
902 mount_enter_mounted(m, MOUNT_FAILURE_RESOURCES);
905 static void mount_enter_mounting(Mount *m) {
911 m->control_command_id = MOUNT_EXEC_MOUNT;
912 m->control_command = m->exec_command + MOUNT_EXEC_MOUNT;
914 mkdir_p_label(m->where, m->directory_mode);
916 warn_if_dir_nonempty(m->meta.id, m->where);
918 /* Create the source directory for bind-mounts if needed */
919 p = get_mount_parameters_fragment(m);
920 if (p && mount_is_bind(p))
921 mkdir_p_label(p->what, m->directory_mode);
923 r = fail_if_symlink(m->meta.id, m->where);
927 if (m->from_fragment) {
928 r = exec_command_set(m->control_command, "/bin/mount",
929 m->parameters_fragment.what, m->where, NULL);
930 if (r >= 0 && UNIT(m)->manager->running_as == SYSTEMD_SYSTEM)
931 r = exec_command_append(m->control_command, "-n", NULL);
932 if (r >= 0 && m->sloppy_options)
933 r = exec_command_append(m->control_command, "-s", NULL);
934 if (r >= 0 && m->parameters_fragment.fstype)
935 r = exec_command_append(m->control_command, "-t", m->parameters_fragment.fstype, NULL);
936 if (r >= 0 && m->parameters_fragment.options)
937 r = exec_command_append(m->control_command, "-o", m->parameters_fragment.options, NULL);
944 mount_unwatch_control_pid(m);
946 r = mount_spawn(m, m->control_command, &m->control_pid);
950 mount_set_state(m, MOUNT_MOUNTING);
955 log_unit_warning(UNIT(m)->id,
956 "%s failed to run 'mount' task: %s",
957 UNIT(m)->id, strerror(-r));
958 mount_enter_dead(m, MOUNT_FAILURE_RESOURCES);
961 static void mount_enter_remounting(Mount *m) {
966 m->control_command_id = MOUNT_EXEC_REMOUNT;
967 m->control_command = m->exec_command + MOUNT_EXEC_REMOUNT;
969 if (m->from_fragment) {
972 if (m->parameters_fragment.options)
973 o = strappenda("remount,", m->parameters_fragment.options);
977 r = exec_command_set(m->control_command, "/bin/mount",
978 m->parameters_fragment.what, m->where,
980 if (r >= 0 && UNIT(m)->manager->running_as == SYSTEMD_SYSTEM)
981 r = exec_command_append(m->control_command, "-n", NULL);
982 if (r >= 0 && m->sloppy_options)
983 r = exec_command_append(m->control_command, "-s", NULL);
984 if (r >= 0 && m->parameters_fragment.fstype)
985 r = exec_command_append(m->control_command, "-t", m->parameters_fragment.fstype, NULL);
992 mount_unwatch_control_pid(m);
994 r = mount_spawn(m, m->control_command, &m->control_pid);
998 mount_set_state(m, MOUNT_REMOUNTING);
1003 log_unit_warning(UNIT(m)->id,
1004 "%s failed to run 'remount' task: %s",
1005 UNIT(m)->id, strerror(-r));
1006 m->reload_result = MOUNT_FAILURE_RESOURCES;
1007 mount_enter_mounted(m, MOUNT_SUCCESS);
1010 static int mount_start(Unit *u) {
1011 Mount *m = MOUNT(u);
1015 /* We cannot fulfill this request right now, try again later
1017 if (m->state == MOUNT_UNMOUNTING ||
1018 m->state == MOUNT_UNMOUNTING_SIGTERM ||
1019 m->state == MOUNT_UNMOUNTING_SIGKILL ||
1020 m->state == MOUNT_MOUNTING_SIGTERM ||
1021 m->state == MOUNT_MOUNTING_SIGKILL)
1024 /* Already on it! */
1025 if (m->state == MOUNT_MOUNTING)
1028 assert(m->state == MOUNT_DEAD || m->state == MOUNT_FAILED);
1030 m->result = MOUNT_SUCCESS;
1031 m->reload_result = MOUNT_SUCCESS;
1033 mount_enter_mounting(m);
1037 static int mount_stop(Unit *u) {
1038 Mount *m = MOUNT(u);
1043 if (m->state == MOUNT_UNMOUNTING ||
1044 m->state == MOUNT_UNMOUNTING_SIGKILL ||
1045 m->state == MOUNT_UNMOUNTING_SIGTERM ||
1046 m->state == MOUNT_MOUNTING_SIGTERM ||
1047 m->state == MOUNT_MOUNTING_SIGKILL)
1050 assert(m->state == MOUNT_MOUNTING ||
1051 m->state == MOUNT_MOUNTING_DONE ||
1052 m->state == MOUNT_MOUNTED ||
1053 m->state == MOUNT_REMOUNTING ||
1054 m->state == MOUNT_REMOUNTING_SIGTERM ||
1055 m->state == MOUNT_REMOUNTING_SIGKILL);
1057 mount_enter_unmounting(m);
1061 static int mount_reload(Unit *u) {
1062 Mount *m = MOUNT(u);
1066 if (m->state == MOUNT_MOUNTING_DONE)
1069 assert(m->state == MOUNT_MOUNTED);
1071 mount_enter_remounting(m);
1075 static int mount_serialize(Unit *u, FILE *f, FDSet *fds) {
1076 Mount *m = MOUNT(u);
1082 unit_serialize_item(u, f, "state", mount_state_to_string(m->state));
1083 unit_serialize_item(u, f, "result", mount_result_to_string(m->result));
1084 unit_serialize_item(u, f, "reload-result", mount_result_to_string(m->reload_result));
1086 if (m->control_pid > 0)
1087 unit_serialize_item_format(u, f, "control-pid", PID_FMT, m->control_pid);
1089 if (m->control_command_id >= 0)
1090 unit_serialize_item(u, f, "control-command", mount_exec_command_to_string(m->control_command_id));
1095 static int mount_deserialize_item(Unit *u, const char *key, const char *value, FDSet *fds) {
1096 Mount *m = MOUNT(u);
1103 if (streq(key, "state")) {
1106 if ((state = mount_state_from_string(value)) < 0)
1107 log_unit_debug(u->id, "Failed to parse state value %s", value);
1109 m->deserialized_state = state;
1110 } else if (streq(key, "result")) {
1113 f = mount_result_from_string(value);
1115 log_unit_debug(UNIT(m)->id,
1116 "Failed to parse result value %s", value);
1117 else if (f != MOUNT_SUCCESS)
1120 } else if (streq(key, "reload-result")) {
1123 f = mount_result_from_string(value);
1125 log_unit_debug(UNIT(m)->id,
1126 "Failed to parse reload result value %s", value);
1127 else if (f != MOUNT_SUCCESS)
1128 m->reload_result = f;
1130 } else if (streq(key, "control-pid")) {
1133 if (parse_pid(value, &pid) < 0)
1134 log_unit_debug(UNIT(m)->id,
1135 "Failed to parse control-pid value %s", value);
1137 m->control_pid = pid;
1138 } else if (streq(key, "control-command")) {
1139 MountExecCommand id;
1141 if ((id = mount_exec_command_from_string(value)) < 0)
1142 log_unit_debug(UNIT(m)->id,
1143 "Failed to parse exec-command value %s", value);
1145 m->control_command_id = id;
1146 m->control_command = m->exec_command + id;
1149 log_unit_debug(UNIT(m)->id,
1150 "Unknown serialization key '%s'", key);
1155 _pure_ static UnitActiveState mount_active_state(Unit *u) {
1158 return state_translation_table[MOUNT(u)->state];
1161 _pure_ static const char *mount_sub_state_to_string(Unit *u) {
1164 return mount_state_to_string(MOUNT(u)->state);
1167 _pure_ static bool mount_check_gc(Unit *u) {
1168 Mount *m = MOUNT(u);
1172 return m->from_proc_self_mountinfo;
1175 static void mount_sigchld_event(Unit *u, pid_t pid, int code, int status) {
1176 Mount *m = MOUNT(u);
1182 if (pid != m->control_pid)
1187 if (is_clean_exit(code, status, NULL))
1189 else if (code == CLD_EXITED)
1190 f = MOUNT_FAILURE_EXIT_CODE;
1191 else if (code == CLD_KILLED)
1192 f = MOUNT_FAILURE_SIGNAL;
1193 else if (code == CLD_DUMPED)
1194 f = MOUNT_FAILURE_CORE_DUMP;
1196 assert_not_reached("Unknown code");
1198 if (f != MOUNT_SUCCESS)
1201 if (m->control_command) {
1202 exec_status_exit(&m->control_command->exec_status, &m->exec_context, pid, code, status);
1204 m->control_command = NULL;
1205 m->control_command_id = _MOUNT_EXEC_COMMAND_INVALID;
1208 log_unit_full(u->id,
1209 f == MOUNT_SUCCESS ? LOG_DEBUG : LOG_NOTICE,
1210 "%s mount process exited, code=%s status=%i",
1211 u->id, sigchld_code_to_string(code), status);
1213 /* Note that mount(8) returning and the kernel sending us a
1214 * mount table change event might happen out-of-order. If an
1215 * operation succeed we assume the kernel will follow soon too
1216 * and already change into the resulting state. If it fails
1217 * we check if the kernel still knows about the mount. and
1218 * change state accordingly. */
1222 case MOUNT_MOUNTING:
1223 case MOUNT_MOUNTING_DONE:
1224 case MOUNT_MOUNTING_SIGKILL:
1225 case MOUNT_MOUNTING_SIGTERM:
1227 if (f == MOUNT_SUCCESS)
1228 mount_enter_mounted(m, f);
1229 else if (m->from_proc_self_mountinfo)
1230 mount_enter_mounted(m, f);
1232 mount_enter_dead(m, f);
1235 case MOUNT_REMOUNTING:
1236 case MOUNT_REMOUNTING_SIGKILL:
1237 case MOUNT_REMOUNTING_SIGTERM:
1239 m->reload_result = f;
1240 if (m->from_proc_self_mountinfo)
1241 mount_enter_mounted(m, MOUNT_SUCCESS);
1243 mount_enter_dead(m, MOUNT_SUCCESS);
1247 case MOUNT_UNMOUNTING:
1248 case MOUNT_UNMOUNTING_SIGKILL:
1249 case MOUNT_UNMOUNTING_SIGTERM:
1251 if (f == MOUNT_SUCCESS) {
1253 if (m->from_proc_self_mountinfo) {
1255 /* Still a mount point? If so, let's
1256 * try again. Most likely there were
1257 * multiple mount points stacked on
1258 * top of each other. Note that due to
1259 * the io event priority logic we can
1260 * be sure the new mountinfo is loaded
1261 * before we process the SIGCHLD for
1262 * the mount command. */
1264 if (m->n_retry_umount < RETRY_UMOUNT_MAX) {
1265 log_unit_debug(u->id, "%s: mount still present, trying again.", u->id);
1266 m->n_retry_umount++;
1267 mount_enter_unmounting(m);
1269 log_unit_debug(u->id, "%s: mount still present after %u attempts to unmount, giving up.", u->id, m->n_retry_umount);
1270 mount_enter_mounted(m, f);
1273 mount_enter_dead(m, f);
1275 } else if (m->from_proc_self_mountinfo)
1276 mount_enter_mounted(m, f);
1278 mount_enter_dead(m, f);
1282 assert_not_reached("Uh, control process died at wrong time.");
1285 /* Notify clients about changed exit status */
1286 unit_add_to_dbus_queue(u);
1289 static int mount_dispatch_timer(sd_event_source *source, usec_t usec, void *userdata) {
1290 Mount *m = MOUNT(userdata);
1293 assert(m->timer_event_source == source);
1297 case MOUNT_MOUNTING:
1298 case MOUNT_MOUNTING_DONE:
1299 log_unit_warning(UNIT(m)->id,
1300 "%s mounting timed out. Stopping.", UNIT(m)->id);
1301 mount_enter_signal(m, MOUNT_MOUNTING_SIGTERM, MOUNT_FAILURE_TIMEOUT);
1304 case MOUNT_REMOUNTING:
1305 log_unit_warning(UNIT(m)->id,
1306 "%s remounting timed out. Stopping.", UNIT(m)->id);
1307 m->reload_result = MOUNT_FAILURE_TIMEOUT;
1308 mount_enter_mounted(m, MOUNT_SUCCESS);
1311 case MOUNT_UNMOUNTING:
1312 log_unit_warning(UNIT(m)->id,
1313 "%s unmounting timed out. Stopping.", UNIT(m)->id);
1314 mount_enter_signal(m, MOUNT_UNMOUNTING_SIGTERM, MOUNT_FAILURE_TIMEOUT);
1317 case MOUNT_MOUNTING_SIGTERM:
1318 if (m->kill_context.send_sigkill) {
1319 log_unit_warning(UNIT(m)->id,
1320 "%s mounting timed out. Killing.", UNIT(m)->id);
1321 mount_enter_signal(m, MOUNT_MOUNTING_SIGKILL, MOUNT_FAILURE_TIMEOUT);
1323 log_unit_warning(UNIT(m)->id,
1324 "%s mounting timed out. Skipping SIGKILL. Ignoring.",
1327 if (m->from_proc_self_mountinfo)
1328 mount_enter_mounted(m, MOUNT_FAILURE_TIMEOUT);
1330 mount_enter_dead(m, MOUNT_FAILURE_TIMEOUT);
1334 case MOUNT_REMOUNTING_SIGTERM:
1335 if (m->kill_context.send_sigkill) {
1336 log_unit_warning(UNIT(m)->id,
1337 "%s remounting timed out. Killing.", UNIT(m)->id);
1338 mount_enter_signal(m, MOUNT_REMOUNTING_SIGKILL, MOUNT_FAILURE_TIMEOUT);
1340 log_unit_warning(UNIT(m)->id,
1341 "%s remounting timed out. Skipping SIGKILL. Ignoring.",
1344 if (m->from_proc_self_mountinfo)
1345 mount_enter_mounted(m, MOUNT_FAILURE_TIMEOUT);
1347 mount_enter_dead(m, MOUNT_FAILURE_TIMEOUT);
1351 case MOUNT_UNMOUNTING_SIGTERM:
1352 if (m->kill_context.send_sigkill) {
1353 log_unit_warning(UNIT(m)->id,
1354 "%s unmounting timed out. Killing.", UNIT(m)->id);
1355 mount_enter_signal(m, MOUNT_UNMOUNTING_SIGKILL, MOUNT_FAILURE_TIMEOUT);
1357 log_unit_warning(UNIT(m)->id,
1358 "%s unmounting timed out. Skipping SIGKILL. Ignoring.",
1361 if (m->from_proc_self_mountinfo)
1362 mount_enter_mounted(m, MOUNT_FAILURE_TIMEOUT);
1364 mount_enter_dead(m, MOUNT_FAILURE_TIMEOUT);
1368 case MOUNT_MOUNTING_SIGKILL:
1369 case MOUNT_REMOUNTING_SIGKILL:
1370 case MOUNT_UNMOUNTING_SIGKILL:
1371 log_unit_warning(UNIT(m)->id,
1372 "%s mount process still around after SIGKILL. Ignoring.",
1375 if (m->from_proc_self_mountinfo)
1376 mount_enter_mounted(m, MOUNT_FAILURE_TIMEOUT);
1378 mount_enter_dead(m, MOUNT_FAILURE_TIMEOUT);
1382 assert_not_reached("Timeout at wrong time.");
1388 static int mount_add_one(
1392 const char *options,
1396 _cleanup_free_ char *e = NULL, *w = NULL, *o = NULL, *f = NULL;
1397 bool load_extras = false;
1399 bool delete, changed = false;
1409 /* Ignore API mount points. They should never be referenced in
1410 * dependencies ever. */
1411 if (mount_point_is_api(where) || mount_point_ignore(where))
1414 if (streq(fstype, "autofs"))
1417 /* probably some kind of swap, ignore */
1418 if (!is_path(where))
1421 e = unit_name_from_path(where, ".mount");
1425 u = manager_get_unit(m, e);
1429 u = unit_new(m, sizeof(Mount));
1433 r = unit_add_name(u, e);
1437 MOUNT(u)->where = strdup(where);
1438 if (!MOUNT(u)->where) {
1443 u->source_path = strdup("/proc/self/mountinfo");
1444 if (!u->source_path) {
1449 if (m->running_as == SYSTEMD_SYSTEM) {
1452 target = mount_needs_network(options, fstype) ? SPECIAL_REMOTE_FS_TARGET : SPECIAL_LOCAL_FS_TARGET;
1453 r = unit_add_dependency_by_name(u, UNIT_BEFORE, target, NULL, true);
1457 if (should_umount(MOUNT(u))) {
1458 r = unit_add_dependency_by_name(u, UNIT_CONFLICTS, SPECIAL_UMOUNT_TARGET, NULL, true);
1464 unit_add_to_load_queue(u);
1469 if (!MOUNT(u)->where) {
1470 MOUNT(u)->where = strdup(where);
1471 if (!MOUNT(u)->where) {
1477 if (m->running_as == SYSTEMD_SYSTEM &&
1478 mount_needs_network(options, fstype)) {
1479 /* _netdev option may have shown up late, or on a
1480 * remount. Add remote-fs dependencies, even though
1481 * local-fs ones may already be there. */
1482 unit_add_dependency_by_name(u, UNIT_BEFORE, SPECIAL_REMOTE_FS_TARGET, NULL, true);
1486 if (u->load_state == UNIT_NOT_FOUND) {
1487 u->load_state = UNIT_LOADED;
1490 /* Load in the extras later on, after we
1491 * finished initialization of the unit */
1498 o = strdup(options);
1500 if (!w || !o || !f) {
1505 p = &MOUNT(u)->parameters_proc_self_mountinfo;
1507 changed = changed ||
1508 !streq_ptr(p->options, options) ||
1509 !streq_ptr(p->what, what) ||
1510 !streq_ptr(p->fstype, fstype);
1513 MOUNT(u)->is_mounted = true;
1514 MOUNT(u)->just_mounted = !MOUNT(u)->from_proc_self_mountinfo;
1515 MOUNT(u)->just_changed = changed;
1518 MOUNT(u)->from_proc_self_mountinfo = true;
1533 r = mount_add_extras(MOUNT(u));
1539 unit_add_to_dbus_queue(u);
1550 static int mount_load_proc_self_mountinfo(Manager *m, bool set_flags) {
1551 _cleanup_(mnt_free_tablep) struct libmnt_table *tb = NULL;
1552 _cleanup_(mnt_free_iterp) struct libmnt_iter *itr = NULL;
1553 struct libmnt_fs *fs;
1558 tb = mnt_new_table();
1559 itr = mnt_new_iter(MNT_ITER_FORWARD);
1563 r = mnt_table_parse_mtab(tb, NULL);
1569 const char *device, *path, *options, *fstype;
1570 _cleanup_free_ const char *d = NULL, *p = NULL;
1573 k = mnt_table_next_fs(tb, itr, &fs);
1577 return log_error_errno(k, "Failed to get next entry from /etc/fstab: %m");
1579 device = mnt_fs_get_source(fs);
1580 path = mnt_fs_get_target(fs);
1581 options = mnt_fs_get_options(fs);
1582 fstype = mnt_fs_get_fstype(fs);
1584 d = cunescape(device);
1585 p = cunescape(path);
1589 k = mount_add_one(m, d, p, options, fstype, set_flags);
1590 if (r == 0 && k < 0)
1597 static void mount_shutdown(Manager *m) {
1600 m->mount_event_source = sd_event_source_unref(m->mount_event_source);
1601 m->mount_utab_event_source = sd_event_source_unref(m->mount_utab_event_source);
1603 if (m->proc_self_mountinfo) {
1604 fclose(m->proc_self_mountinfo);
1605 m->proc_self_mountinfo = NULL;
1607 m->utab_inotify_fd = safe_close(m->utab_inotify_fd);
1610 static int mount_get_timeout(Unit *u, uint64_t *timeout) {
1611 Mount *m = MOUNT(u);
1614 if (!m->timer_event_source)
1617 r = sd_event_source_get_time(m->timer_event_source, timeout);
1624 static int mount_enumerate(Manager *m) {
1630 if (!m->proc_self_mountinfo) {
1631 m->proc_self_mountinfo = fopen("/proc/self/mountinfo", "re");
1632 if (!m->proc_self_mountinfo)
1635 r = sd_event_add_io(m->event, &m->mount_event_source, fileno(m->proc_self_mountinfo), EPOLLPRI, mount_dispatch_io, m);
1639 /* Dispatch this before we dispatch SIGCHLD, so that
1640 * we always get the events from /proc/self/mountinfo
1641 * before the SIGCHLD of /bin/mount. */
1642 r = sd_event_source_set_priority(m->mount_event_source, -10);
1647 if (m->utab_inotify_fd < 0) {
1648 m->utab_inotify_fd = inotify_init1(IN_NONBLOCK|IN_CLOEXEC);
1649 if (m->utab_inotify_fd < 0) {
1654 (void) mkdir_p_label("/run/mount", 0755);
1656 r = inotify_add_watch(m->utab_inotify_fd, "/run/mount", IN_MOVED_TO);
1662 r = sd_event_add_io(m->event, &m->mount_utab_event_source, m->utab_inotify_fd, EPOLLIN, mount_dispatch_io, m);
1666 r = sd_event_source_set_priority(m->mount_utab_event_source, -10);
1671 r = mount_load_proc_self_mountinfo(m, false);
1682 static int mount_dispatch_io(sd_event_source *source, int fd, uint32_t revents, void *userdata) {
1683 Manager *m = userdata;
1688 assert(revents & (EPOLLPRI | EPOLLIN));
1690 /* The manager calls this for every fd event happening on the
1691 * /proc/self/mountinfo file, which informs us about mounting
1692 * table changes, and for /run/mount events which we watch
1693 * for mount options. */
1695 if (fd == m->utab_inotify_fd) {
1696 bool rescan = false;
1698 /* FIXME: We *really* need to replace this with
1699 * libmount's own API for this, we should not hardcode
1700 * internal behaviour of libmount here. */
1703 union inotify_event_buffer buffer;
1704 struct inotify_event *e;
1707 l = read(fd, &buffer, sizeof(buffer));
1709 if (errno == EAGAIN || errno == EINTR)
1712 log_error_errno(errno, "Failed to read utab inotify: %m");
1716 FOREACH_INOTIFY_EVENT(e, buffer, l) {
1717 /* Only care about changes to utab,
1718 * but we have to monitor the
1719 * directory to reliably get
1720 * notifications about when utab is
1721 * replaced using rename(2) */
1722 if ((e->mask & IN_Q_OVERFLOW) || streq(e->name, "utab"))
1731 r = mount_load_proc_self_mountinfo(m, true);
1733 log_error_errno(r, "Failed to reread /proc/self/mountinfo: %m");
1735 /* Reset flags, just in case, for later calls */
1736 LIST_FOREACH(units_by_type, u, m->units_by_type[UNIT_MOUNT]) {
1737 Mount *mount = MOUNT(u);
1739 mount->is_mounted = mount->just_mounted = mount->just_changed = false;
1745 manager_dispatch_load_queue(m);
1747 LIST_FOREACH(units_by_type, u, m->units_by_type[UNIT_MOUNT]) {
1748 Mount *mount = MOUNT(u);
1750 if (!mount->is_mounted) {
1752 mount->from_proc_self_mountinfo = false;
1754 switch (mount->state) {
1757 /* This has just been unmounted by
1758 * somebody else, follow the state
1760 mount_enter_dead(mount, MOUNT_SUCCESS);
1767 } else if (mount->just_mounted || mount->just_changed) {
1769 /* New or changed mount entry */
1771 switch (mount->state) {
1775 /* This has just been mounted by
1776 * somebody else, follow the state
1778 mount_enter_mounted(mount, MOUNT_SUCCESS);
1781 case MOUNT_MOUNTING:
1782 mount_set_state(mount, MOUNT_MOUNTING_DONE);
1786 /* Nothing really changed, but let's
1787 * issue an notification call
1788 * nonetheless, in case somebody is
1789 * waiting for this. (e.g. file system
1790 * ro/rw remounts.) */
1791 mount_set_state(mount, mount->state);
1796 /* Reset the flags for later calls */
1797 mount->is_mounted = mount->just_mounted = mount->just_changed = false;
1803 static void mount_reset_failed(Unit *u) {
1804 Mount *m = MOUNT(u);
1808 if (m->state == MOUNT_FAILED)
1809 mount_set_state(m, MOUNT_DEAD);
1811 m->result = MOUNT_SUCCESS;
1812 m->reload_result = MOUNT_SUCCESS;
1815 static int mount_kill(Unit *u, KillWho who, int signo, sd_bus_error *error) {
1816 return unit_kill_common(u, who, signo, -1, MOUNT(u)->control_pid, error);
1819 static const char* const mount_state_table[_MOUNT_STATE_MAX] = {
1820 [MOUNT_DEAD] = "dead",
1821 [MOUNT_MOUNTING] = "mounting",
1822 [MOUNT_MOUNTING_DONE] = "mounting-done",
1823 [MOUNT_MOUNTED] = "mounted",
1824 [MOUNT_REMOUNTING] = "remounting",
1825 [MOUNT_UNMOUNTING] = "unmounting",
1826 [MOUNT_MOUNTING_SIGTERM] = "mounting-sigterm",
1827 [MOUNT_MOUNTING_SIGKILL] = "mounting-sigkill",
1828 [MOUNT_REMOUNTING_SIGTERM] = "remounting-sigterm",
1829 [MOUNT_REMOUNTING_SIGKILL] = "remounting-sigkill",
1830 [MOUNT_UNMOUNTING_SIGTERM] = "unmounting-sigterm",
1831 [MOUNT_UNMOUNTING_SIGKILL] = "unmounting-sigkill",
1832 [MOUNT_FAILED] = "failed"
1835 DEFINE_STRING_TABLE_LOOKUP(mount_state, MountState);
1837 static const char* const mount_exec_command_table[_MOUNT_EXEC_COMMAND_MAX] = {
1838 [MOUNT_EXEC_MOUNT] = "ExecMount",
1839 [MOUNT_EXEC_UNMOUNT] = "ExecUnmount",
1840 [MOUNT_EXEC_REMOUNT] = "ExecRemount",
1843 DEFINE_STRING_TABLE_LOOKUP(mount_exec_command, MountExecCommand);
1845 static const char* const mount_result_table[_MOUNT_RESULT_MAX] = {
1846 [MOUNT_SUCCESS] = "success",
1847 [MOUNT_FAILURE_RESOURCES] = "resources",
1848 [MOUNT_FAILURE_TIMEOUT] = "timeout",
1849 [MOUNT_FAILURE_EXIT_CODE] = "exit-code",
1850 [MOUNT_FAILURE_SIGNAL] = "signal",
1851 [MOUNT_FAILURE_CORE_DUMP] = "core-dump"
1854 DEFINE_STRING_TABLE_LOOKUP(mount_result, MountResult);
1856 const UnitVTable mount_vtable = {
1857 .object_size = sizeof(Mount),
1858 .exec_context_offset = offsetof(Mount, exec_context),
1859 .cgroup_context_offset = offsetof(Mount, cgroup_context),
1860 .kill_context_offset = offsetof(Mount, kill_context),
1861 .exec_runtime_offset = offsetof(Mount, exec_runtime),
1867 .private_section = "Mount",
1870 .no_instances = true,
1876 .coldplug = mount_coldplug,
1880 .start = mount_start,
1882 .reload = mount_reload,
1886 .serialize = mount_serialize,
1887 .deserialize_item = mount_deserialize_item,
1889 .active_state = mount_active_state,
1890 .sub_state_to_string = mount_sub_state_to_string,
1892 .check_gc = mount_check_gc,
1894 .sigchld_event = mount_sigchld_event,
1896 .reset_failed = mount_reset_failed,
1898 .bus_interface = "org.freedesktop.systemd1.Mount",
1899 .bus_vtable = bus_mount_vtable,
1900 .bus_set_property = bus_mount_set_property,
1901 .bus_commit_properties = bus_mount_commit_properties,
1903 .get_timeout = mount_get_timeout,
1905 .can_transient = true,
1907 .enumerate = mount_enumerate,
1908 .shutdown = mount_shutdown,
1910 .status_message_formats = {
1911 .starting_stopping = {
1912 [0] = "Mounting %s...",
1913 [1] = "Unmounting %s...",
1915 .finished_start_job = {
1916 [JOB_DONE] = "Mounted %s.",
1917 [JOB_FAILED] = "Failed to mount %s.",
1918 [JOB_DEPENDENCY] = "Dependency failed for %s.",
1919 [JOB_TIMEOUT] = "Timed out mounting %s.",
1921 .finished_stop_job = {
1922 [JOB_DONE] = "Unmounted %s.",
1923 [JOB_FAILED] = "Failed unmounting %s.",
1924 [JOB_TIMEOUT] = "Timed out unmounting %s.",