1 /*-*- Mode: C; c-basic-offset: 8 -*-*/
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 General Public License as published by
10 the Free Software Foundation; either version 2 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 General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with systemd; If not, see <http://www.gnu.org/licenses/>.
25 #include <sys/epoll.h>
30 #include "load-fragment.h"
31 #include "load-dropin.h"
34 #include "mount-setup.h"
36 static const UnitActiveState state_translation_table[_MOUNT_STATE_MAX] = {
37 [MOUNT_DEAD] = UNIT_INACTIVE,
38 [MOUNT_MOUNTING] = UNIT_ACTIVATING,
39 [MOUNT_MOUNTING_DONE] = UNIT_ACTIVE,
40 [MOUNT_MOUNTED] = UNIT_ACTIVE,
41 [MOUNT_REMOUNTING] = UNIT_ACTIVE_RELOADING,
42 [MOUNT_UNMOUNTING] = UNIT_DEACTIVATING,
43 [MOUNT_MOUNTING_SIGTERM] = UNIT_DEACTIVATING,
44 [MOUNT_MOUNTING_SIGKILL] = UNIT_DEACTIVATING,
45 [MOUNT_REMOUNTING_SIGTERM] = UNIT_ACTIVE_RELOADING,
46 [MOUNT_REMOUNTING_SIGKILL] = UNIT_ACTIVE_RELOADING,
47 [MOUNT_UNMOUNTING_SIGTERM] = UNIT_DEACTIVATING,
48 [MOUNT_UNMOUNTING_SIGKILL] = UNIT_DEACTIVATING,
49 [MOUNT_MAINTAINANCE] = UNIT_INACTIVE,
52 static const char* const state_string_table[_MOUNT_STATE_MAX] = {
53 [MOUNT_DEAD] = "dead",
54 [MOUNT_MOUNTING] = "mounting",
55 [MOUNT_MOUNTING_DONE] = "mounting-done",
56 [MOUNT_MOUNTED] = "mounted",
57 [MOUNT_REMOUNTING] = "remounting",
58 [MOUNT_UNMOUNTING] = "unmounting",
59 [MOUNT_MOUNTING_SIGTERM] = "mounting-sigterm",
60 [MOUNT_MOUNTING_SIGKILL] = "mounting-sigkill",
61 [MOUNT_REMOUNTING_SIGTERM] = "remounting-sigterm",
62 [MOUNT_REMOUNTING_SIGKILL] = "remounting-sigkill",
63 [MOUNT_UNMOUNTING_SIGTERM] = "unmounting-sigterm",
64 [MOUNT_UNMOUNTING_SIGKILL] = "unmounting-sigkill",
65 [MOUNT_MAINTAINANCE] = "maintainance"
68 static void mount_parameters_done(MountParameters *p) {
75 p->what = p->options = p->fstype = NULL;
78 static void mount_done(Unit *u) {
86 mount_parameters_done(&m->parameters_etc_fstab);
87 mount_parameters_done(&m->parameters_proc_self_mountinfo);
88 mount_parameters_done(&m->parameters_fragment);
90 exec_context_done(&m->exec_context);
91 exec_command_done_array(m->exec_command, _MOUNT_EXEC_COMMAND_MAX);
92 m->control_command = NULL;
94 if (m->control_pid > 0) {
95 unit_unwatch_pid(u, m->control_pid);
99 unit_unwatch_timer(u, &m->timer_watch);
102 static void mount_init(Unit *u) {
106 assert(u->meta.load_state == UNIT_STUB);
109 m->from_etc_fstab = false;
110 m->from_proc_self_mountinfo = false;
111 m->from_fragment = false;
113 m->is_mounted = false;
114 m->just_mounted = false;
115 m->just_changed = false;
117 m->timeout_usec = DEFAULT_TIMEOUT_USEC;
119 zero(m->exec_command);
120 exec_context_init(&m->exec_context);
127 m->timer_watch.type = WATCH_INVALID;
130 static int mount_add_node_links(Mount *m) {
138 /* Adds in links to the device that this node is based on */
140 if (m->parameters_fragment.what)
141 what = m->parameters_fragment.what;
142 else if (m->parameters_etc_fstab.what)
143 what = m->parameters_etc_fstab.what;
145 /* We observe kernel mounts only while they are live,
146 * hence don't create any links for them */
149 if (!path_startswith(what, "/dev/"))
152 if (!(e = unit_name_escape_path(what+1, ".device")))
155 r = manager_load_unit(UNIT(m)->meta.manager, e, &device);
161 if ((r = unit_add_dependency(UNIT(m), UNIT_AFTER, device)) < 0)
164 if ((r = unit_add_dependency(UNIT(m), UNIT_REQUIRES, device)) < 0)
167 if (UNIT(m)->meta.manager->running_as == MANAGER_INIT ||
168 UNIT(m)->meta.manager->running_as == MANAGER_SYSTEM)
169 if ((r = unit_add_dependency(device, UNIT_WANTS, UNIT(m))) < 0)
175 static int mount_add_path_links(Mount *m) {
181 /* Adds in link to other mount points, that might lie below or
182 * above us in the hierarchy */
184 LIST_FOREACH(units_per_type, other, UNIT(m)->meta.manager->units_per_type[UNIT_MOUNT]) {
192 if (m->meta.load_state != UNIT_LOADED)
195 if (path_startswith(m->where, n->where)) {
197 if ((r = unit_add_dependency(UNIT(m), UNIT_AFTER, UNIT(other))) < 0)
200 if (n->from_etc_fstab || n->from_fragment)
201 if ((r = unit_add_dependency(UNIT(m), UNIT_REQUIRES, UNIT(other))) < 0)
204 } else if (path_startswith(n->where, m->where)) {
206 if ((r = unit_add_dependency(UNIT(m), UNIT_BEFORE, UNIT(other))) < 0)
209 if (m->from_etc_fstab || m->from_fragment)
210 if ((r = unit_add_dependency(UNIT(other), UNIT_REQUIRES, UNIT(m))) < 0)
218 static bool mount_test_option(const char *haystack, const char *needle) {
223 /* Like glibc's hasmntopt(), but works on a string, not a
230 me.mnt_opts = (char*) haystack;
232 return !!hasmntopt(&me, needle);
235 static int mount_add_target_links(Mount *m) {
243 if (m->from_fragment)
244 p = &m->parameters_fragment;
245 else if (m->from_etc_fstab)
246 p = &m->parameters_etc_fstab;
253 if (mount_test_option(p->options, MNTOPT_NOAUTO))
256 if (mount_test_option(p->options, "_netdev") ||
257 fstype_is_network(p->fstype))
258 target = SPECIAL_REMOTE_FS_TARGET;
260 target = SPECIAL_LOCAL_FS_TARGET;
262 if ((r = manager_load_unit(UNIT(m)->meta.manager, target, &u)) < 0)
265 if ((r = unit_add_dependency(u, UNIT_WANTS, UNIT(m))) < 0)
268 return unit_add_dependency(UNIT(m), UNIT_BEFORE, u);
271 static int mount_load(Unit *u) {
276 assert(u->meta.load_state == UNIT_STUB);
278 if ((r = unit_load_fragment_and_dropin_optional(u)) < 0)
281 /* This is a new unit? Then let's add in some extras */
282 if (u->meta.load_state == UNIT_LOADED) {
284 /* Minor validity checking */
285 if ((m->parameters_fragment.options || m->parameters_fragment.fstype) && !m->parameters_fragment.what)
288 if (m->parameters_fragment.what)
289 m->from_fragment = true;
291 if ((r = mount_add_node_links(MOUNT(u))) < 0)
294 if ((r = mount_add_path_links(MOUNT(u))) < 0)
297 if ((r = mount_add_target_links(MOUNT(u))) < 0)
300 if ((r = unit_add_default_cgroup(u)) < 0)
307 static void mount_set_state(Mount *m, MountState state) {
308 MountState old_state;
311 old_state = m->state;
314 if (state != MOUNT_MOUNTING &&
315 state != MOUNT_MOUNTING_DONE &&
316 state != MOUNT_REMOUNTING &&
317 state != MOUNT_UNMOUNTING &&
318 state != MOUNT_MOUNTING_SIGTERM &&
319 state != MOUNT_MOUNTING_SIGKILL &&
320 state != MOUNT_UNMOUNTING_SIGTERM &&
321 state != MOUNT_UNMOUNTING_SIGKILL &&
322 state != MOUNT_REMOUNTING_SIGTERM &&
323 state != MOUNT_REMOUNTING_SIGKILL) {
324 unit_unwatch_timer(UNIT(m), &m->timer_watch);
326 if (m->control_pid > 0) {
327 unit_unwatch_pid(UNIT(m), m->control_pid);
331 m->control_command = NULL;
334 if (state != old_state)
335 log_debug("%s changed %s → %s", unit_id(UNIT(m)), state_string_table[old_state], state_string_table[state]);
337 unit_notify(UNIT(m), state_translation_table[old_state], state_translation_table[state]);
340 static int mount_coldplug(Unit *u) {
344 assert(m->state == MOUNT_DEAD);
346 if (m->from_proc_self_mountinfo)
347 mount_set_state(m, MOUNT_MOUNTED);
352 static int mount_spawn(Mount *m, ExecCommand *c, pid_t *_pid) {
360 if ((r = unit_watch_timer(UNIT(m), m->timeout_usec, &m->timer_watch)) < 0)
363 if ((r = exec_spawn(c,
368 UNIT(m)->meta.cgroup_bondings,
372 if ((r = unit_watch_pid(UNIT(m), pid)) < 0)
373 /* FIXME: we need to do something here */
381 unit_unwatch_timer(UNIT(m), &m->timer_watch);
386 static void mount_dump(Unit *u, FILE *f, const char *prefix) {
393 if (m->from_proc_self_mountinfo)
394 p = &m->parameters_proc_self_mountinfo;
395 else if (m->from_fragment)
396 p = &m->parameters_fragment;
398 p = &m->parameters_etc_fstab;
401 "%sMount State: %s\n"
404 "%sFile System Type: %s\n"
406 "%sFrom /etc/fstab: %s\n"
407 "%sFrom /proc/self/mountinfo: %s\n"
408 "%sFrom fragment: %s\n"
410 prefix, state_string_table[m->state],
412 prefix, strna(p->what),
413 prefix, strna(p->fstype),
414 prefix, strna(p->options),
415 prefix, yes_no(m->from_etc_fstab),
416 prefix, yes_no(m->from_proc_self_mountinfo),
417 prefix, yes_no(m->from_fragment),
418 prefix, kill_mode_to_string(m->kill_mode));
420 if (m->control_pid > 0)
422 "%sControl PID: %llu\n",
423 prefix, (unsigned long long) m->control_pid);
425 exec_context_dump(&m->exec_context, f, prefix);
428 static void mount_enter_dead(Mount *m, bool success) {
434 mount_set_state(m, m->failure ? MOUNT_MAINTAINANCE : MOUNT_DEAD);
437 static void mount_enter_signal(Mount *m, MountState state, bool success) {
445 if (m->control_pid > 0) {
449 sig = (state == MOUNT_MOUNTING_SIGTERM ||
450 state == MOUNT_UNMOUNTING_SIGTERM ||
451 state == MOUNT_REMOUNTING_SIGTERM) ? SIGTERM : SIGKILL;
453 if (m->kill_mode == KILL_CONTROL_GROUP) {
455 if ((r = cgroup_bonding_kill_list(UNIT(m)->meta.cgroup_bondings, sig)) < 0) {
456 if (r != -EAGAIN && r != -ESRCH)
463 if (kill(m->kill_mode == KILL_PROCESS ? m->control_pid : -m->control_pid, sig) < 0 && errno != ESRCH) {
469 mount_set_state(m, state);
471 if (m->control_pid <= 0)
472 mount_enter_dead(m, true);
477 log_warning("%s failed to kill processes: %s", unit_id(UNIT(m)), strerror(-r));
478 mount_enter_dead(m, false);
481 static void mount_enter_mounted(Mount *m, bool success) {
487 mount_set_state(m, MOUNT_MOUNTED);
490 static void mount_enter_unmounting(Mount *m, bool success) {
499 m->control_command = c = m->exec_command + MOUNT_EXEC_UNMOUNT;
501 if ((r = exec_command_set(
508 if ((r = mount_spawn(m, c, &m->control_pid)) < 0)
511 mount_set_state(m, MOUNT_UNMOUNTING);
516 log_warning("%s failed to run umount exectuable: %s", unit_id(UNIT(m)), strerror(-r));
517 mount_enter_mounted(m, false);
520 static void mount_enter_mounting(Mount *m, bool success) {
529 m->control_command = c = m->exec_command + MOUNT_EXEC_MOUNT;
531 if (m->from_fragment)
532 r = exec_command_set(
535 m->parameters_fragment.what,
537 "-t", m->parameters_fragment.fstype,
538 "-o", m->parameters_fragment.options,
540 else if (m->from_etc_fstab)
541 r = exec_command_set(
552 if ((r = mount_spawn(m, c, &m->control_pid)) < 0)
555 mount_set_state(m, MOUNT_MOUNTING);
560 log_warning("%s failed to run mount exectuable: %s", unit_id(UNIT(m)), strerror(-r));
561 mount_enter_dead(m, false);
564 static void mount_enter_mounting_done(Mount *m, bool success) {
570 mount_set_state(m, MOUNT_MOUNTING_DONE);
573 static void mount_enter_remounting(Mount *m, bool success) {
582 m->control_command = c = m->exec_command + MOUNT_EXEC_REMOUNT;
584 if (m->from_fragment) {
588 if (m->parameters_fragment.options) {
589 if (!(buf = strappend("remount,", m->parameters_fragment.options))) {
598 r = exec_command_set(
601 m->parameters_fragment.what,
603 "-t", m->parameters_fragment.fstype,
608 } else if (m->from_etc_fstab)
609 r = exec_command_set(
623 if ((r = mount_spawn(m, c, &m->control_pid)) < 0)
626 mount_set_state(m, MOUNT_REMOUNTING);
631 mount_enter_mounted(m, false);
634 static int mount_start(Unit *u) {
639 /* We cannot fulfill this request right now, try again later
641 if (m->state == MOUNT_UNMOUNTING ||
642 m->state == MOUNT_UNMOUNTING_SIGTERM ||
643 m->state == MOUNT_UNMOUNTING_SIGKILL)
647 if (m->state == MOUNT_MOUNTING ||
648 m->state == MOUNT_MOUNTING_SIGTERM ||
649 m->state == MOUNT_MOUNTING_SIGKILL)
652 assert(m->state == MOUNT_DEAD || m->state == MOUNT_MAINTAINANCE);
656 mount_enter_mounting(m, true);
660 static int mount_stop(Unit *u) {
665 /* Cann't do this right now. */
666 if (m->state == MOUNT_MOUNTING ||
667 m->state == MOUNT_MOUNTING_DONE ||
668 m->state == MOUNT_MOUNTING_SIGTERM ||
669 m->state == MOUNT_MOUNTING_SIGKILL ||
670 m->state == MOUNT_REMOUNTING ||
671 m->state == MOUNT_REMOUNTING_SIGTERM ||
672 m->state == MOUNT_REMOUNTING_SIGKILL)
676 if (m->state == MOUNT_UNMOUNTING ||
677 m->state == MOUNT_UNMOUNTING_SIGKILL ||
678 m->state == MOUNT_UNMOUNTING_SIGTERM)
681 assert(m->state == MOUNT_MOUNTED);
683 mount_enter_unmounting(m, true);
687 static int mount_reload(Unit *u) {
692 if (m->state == MOUNT_MOUNTING_DONE)
695 assert(m->state == MOUNT_MOUNTED);
697 mount_enter_remounting(m, true);
701 static UnitActiveState mount_active_state(Unit *u) {
704 return state_translation_table[MOUNT(u)->state];
707 static void mount_sigchld_event(Unit *u, pid_t pid, int code, int status) {
714 success = code == CLD_EXITED && status == 0;
715 m->failure = m->failure || !success;
717 assert(m->control_pid == pid);
718 assert(m->control_command);
720 exec_status_fill(&m->control_command->exec_status, pid, code, status);
723 log_debug("%s control process exited, code=%s status=%i", unit_id(u), sigchld_code_to_string(code), status);
725 /* Note that mount(8) returning and the kernel sending us a
726 * mount table change event might happen out-of-order. If an
727 * operation succeed we assume the kernel will follow soon too
728 * and already change into the resulting state. If it fails
729 * we check if the kernel still knows about the mount. and
730 * change state accordingly. */
735 case MOUNT_MOUNTING_DONE:
736 case MOUNT_MOUNTING_SIGKILL:
737 case MOUNT_MOUNTING_SIGTERM:
738 case MOUNT_REMOUNTING:
739 case MOUNT_REMOUNTING_SIGKILL:
740 case MOUNT_REMOUNTING_SIGTERM:
742 if (success && m->from_proc_self_mountinfo)
743 mount_enter_mounted(m, true);
744 else if (m->from_proc_self_mountinfo)
745 mount_enter_mounted(m, false);
747 mount_enter_dead(m, false);
750 case MOUNT_UNMOUNTING:
751 case MOUNT_UNMOUNTING_SIGKILL:
752 case MOUNT_UNMOUNTING_SIGTERM:
755 mount_enter_dead(m, true);
756 else if (m->from_proc_self_mountinfo)
757 mount_enter_mounted(m, false);
759 mount_enter_dead(m, false);
763 assert_not_reached("Uh, control process died at wrong time.");
767 static void mount_timer_event(Unit *u, uint64_t elapsed, Watch *w) {
771 assert(elapsed == 1);
772 assert(w == &m->timer_watch);
777 case MOUNT_MOUNTING_DONE:
778 log_warning("%s mounting timed out. Stopping.", unit_id(u));
779 mount_enter_signal(m, MOUNT_MOUNTING_SIGTERM, false);
782 case MOUNT_REMOUNTING:
783 log_warning("%s remounting timed out. Stopping.", unit_id(u));
784 mount_enter_signal(m, MOUNT_REMOUNTING_SIGTERM, false);
787 case MOUNT_UNMOUNTING:
788 log_warning("%s unmounting timed out. Stopping.", unit_id(u));
789 mount_enter_signal(m, MOUNT_UNMOUNTING_SIGTERM, false);
792 case MOUNT_MOUNTING_SIGTERM:
793 log_warning("%s mounting timed out. Killing.", unit_id(u));
794 mount_enter_signal(m, MOUNT_MOUNTING_SIGKILL, false);
797 case MOUNT_REMOUNTING_SIGTERM:
798 log_warning("%s remounting timed out. Killing.", unit_id(u));
799 mount_enter_signal(m, MOUNT_REMOUNTING_SIGKILL, false);
802 case MOUNT_UNMOUNTING_SIGTERM:
803 log_warning("%s unmounting timed out. Killing.", unit_id(u));
804 mount_enter_signal(m, MOUNT_UNMOUNTING_SIGKILL, false);
807 case MOUNT_MOUNTING_SIGKILL:
808 case MOUNT_REMOUNTING_SIGKILL:
809 case MOUNT_UNMOUNTING_SIGKILL:
810 log_warning("%s mount process still around after SIGKILL. Ignoring.", unit_id(u));
812 if (m->from_proc_self_mountinfo)
813 mount_enter_mounted(m, false);
815 mount_enter_dead(m, false);
819 assert_not_reached("Timeout at wrong time.");
823 static int mount_add_one(
829 bool from_proc_self_mountinfo,
834 char *e, *w = NULL, *o = NULL, *f = NULL;
843 assert(!set_flags || from_proc_self_mountinfo);
845 /* Ignore API mount points. They should never be referenced in
846 * dependencies ever. */
847 if (mount_point_is_api(where))
850 /* probably some kind of swap, which we don't cover for now */
854 if (streq(where, "/"))
855 e = strdup("-.mount");
857 e = unit_name_escape_path(where+1, ".mount");
862 if (!(u = manager_get_unit(m, e))) {
865 if (!(u = unit_new(m))) {
870 r = unit_add_name(u, e);
876 if (!(MOUNT(u)->where = strdup(where))) {
881 if ((r = unit_set_description(u, where)) < 0)
884 unit_add_to_load_queue(u);
890 if (!(w = strdup(what)) ||
891 !(o = strdup(options)) ||
892 !(f = strdup(fstype))) {
897 if (from_proc_self_mountinfo) {
898 mp = &MOUNT(u)->parameters_proc_self_mountinfo;
901 MOUNT(u)->is_mounted = true;
902 MOUNT(u)->just_mounted = !MOUNT(u)->from_proc_self_mountinfo;
903 MOUNT(u)->just_changed = !streq_ptr(MOUNT(u)->parameters_proc_self_mountinfo.options, o);
906 MOUNT(u)->from_proc_self_mountinfo = true;
909 mp = &MOUNT(u)->parameters_etc_fstab;
911 MOUNT(u)->from_etc_fstab = true;
923 unit_add_to_dbus_queue(u);
938 static char *fstab_node_to_udev_node(char *p) {
942 /* FIXME: to follow udev's logic 100% we need to leave valid
943 * UTF8 chars unescaped */
945 if (startswith(p, "LABEL=")) {
947 if (!(t = xescape(p+6, "/ ")))
950 r = asprintf(&dn, "/dev/disk/by-label/%s", t);
959 if (startswith(p, "UUID=")) {
961 if (!(t = xescape(p+5, "/ ")))
964 r = asprintf(&dn, "/dev/disk/by-uuid/%s", ascii_strlower(t));
976 static int mount_load_etc_fstab(Manager *m) {
984 if (!(f = setmntent("/etc/fstab", "r")))
987 while ((me = getmntent(f))) {
990 if (!(what = fstab_node_to_udev_node(me->mnt_fsname))) {
995 if (!(where = strdup(me->mnt_dir))) {
1002 path_kill_slashes(what);
1004 if (where[0] == '/')
1005 path_kill_slashes(where);
1007 r = mount_add_one(m, what, where, me->mnt_opts, me->mnt_type, false, false);
1022 static int mount_load_proc_self_mountinfo(Manager *m, bool set_flags) {
1024 char *device, *path, *options, *fstype, *d, *p;
1028 rewind(m->proc_self_mountinfo);
1033 device = path = options = fstype = d = p = NULL;
1035 if ((k = fscanf(m->proc_self_mountinfo,
1036 "%*s " /* (1) mount id */
1037 "%*s " /* (2) parent id */
1038 "%*s " /* (3) major:minor */
1039 "%*s " /* (4) root */
1040 "%ms " /* (5) mount point */
1041 "%ms" /* (6) mount options */
1042 "%*[^-]" /* (7) optional fields */
1043 "- " /* (8) seperator */
1044 "%ms " /* (9) file system type */
1045 "%ms" /* (10) mount source */
1046 "%*[^\n]", /* some rubbish at the end */
1059 if (!(d = cunescape(device)) ||
1060 !(p = cunescape(path))) {
1065 if ((r = mount_add_one(m, d, p, options, fstype, true, set_flags)) < 0)
1089 static void mount_shutdown(Manager *m) {
1092 if (m->proc_self_mountinfo)
1093 fclose(m->proc_self_mountinfo);
1096 static int mount_enumerate(Manager *m) {
1098 struct epoll_event ev;
1101 if (!(m->proc_self_mountinfo = fopen("/proc/self/mountinfo", "r")))
1104 m->mount_watch.type = WATCH_MOUNT;
1105 m->mount_watch.fd = fileno(m->proc_self_mountinfo);
1108 ev.events = EPOLLERR;
1109 ev.data.ptr = &m->mount_watch;
1111 if (epoll_ctl(m->epoll_fd, EPOLL_CTL_ADD, m->mount_watch.fd, &ev) < 0)
1114 if ((r = mount_load_etc_fstab(m)) < 0)
1117 if ((r = mount_load_proc_self_mountinfo(m, false)) < 0)
1127 void mount_fd_event(Manager *m, int events) {
1132 assert(events == EPOLLERR);
1134 /* The manager calls this for every fd event happening on the
1135 * /proc/self/mountinfo file, which informs us about mounting
1138 if ((r = mount_load_proc_self_mountinfo(m, true)) < 0) {
1139 log_error("Failed to reread /proc/self/mountinfo: %s", strerror(-errno));
1141 /* Reset flags, just in case, for later calls */
1142 LIST_FOREACH(units_per_type, meta, m->units_per_type[UNIT_MOUNT]) {
1143 Mount *mount = (Mount*) meta;
1145 mount->is_mounted = mount->just_mounted = mount->just_changed = false;
1151 manager_dispatch_load_queue(m);
1153 LIST_FOREACH(units_per_type, meta, m->units_per_type[UNIT_MOUNT]) {
1154 Mount *mount = (Mount*) meta;
1156 if (!mount->is_mounted) {
1157 /* This has just been unmounted. */
1159 mount->from_proc_self_mountinfo = false;
1161 switch (mount->state) {
1164 mount_enter_dead(mount, true);
1168 mount_set_state(mount, mount->state);
1173 } else if (mount->just_mounted || mount->just_changed) {
1175 /* New or changed entrymount */
1177 switch (mount->state) {
1180 case MOUNT_MAINTAINANCE:
1181 mount_enter_mounted(mount, true);
1184 case MOUNT_MOUNTING:
1185 mount_enter_mounting_done(mount, true);
1189 /* Nothing really changed, but let's
1190 * issue an notification call
1191 * nonetheless, in case somebody is
1192 * waiting for this. (e.g. file system
1193 * ro/rw remounts.) */
1194 mount_set_state(mount, mount->state);
1199 /* Reset the flags for later calls */
1200 mount->is_mounted = mount->just_mounted = mount->just_changed = false;
1204 int mount_path_is_mounted(Manager *m, const char* path) {
1214 if (!(t = strdup(path)))
1217 path_kill_slashes(t);
1223 if (!(e = unit_name_escape_path(t+1, ".mount"))) {
1228 u = manager_get_unit(m, e);
1232 (MOUNT(u)->from_etc_fstab || MOUNT(u)->from_fragment) &&
1233 MOUNT(u)->state != MOUNT_MOUNTED) {
1238 assert_se(slash = strrchr(t, '/'));
1255 const UnitVTable mount_vtable = {
1264 .coldplug = mount_coldplug,
1268 .start = mount_start,
1270 .reload = mount_reload,
1272 .active_state = mount_active_state,
1274 .sigchld_event = mount_sigchld_event,
1275 .timer_event = mount_timer_event,
1277 .enumerate = mount_enumerate,
1278 .shutdown = mount_shutdown