- if (automount) {
- Unit *am;
-
- if ((r = unit_load_related_unit(UNIT(m), ".automount", &am)) < 0)
- return r;
-
- /* If auto is configured as well also pull in the
- * mount right-away, but don't rely on it. */
- if (!noauto) /* automount + auto */
- if ((r = unit_add_dependency(tu, UNIT_WANTS, UNIT(m), true)) < 0)
- return r;
-
- /* Install automount unit */
- if (!nofail) /* automount + fail */
- return unit_add_two_dependencies(tu, UNIT_AFTER, UNIT_REQUIRES, am, true);
- else /* automount + nofail */
- return unit_add_two_dependencies(tu, UNIT_AFTER, UNIT_WANTS, am, true);
-
- } else if (!noauto) {
-
- /* Automatically add mount points that aren't natively
- * configured to local-fs.target */
-
- if (!nofail) /* auto + fail */
- return unit_add_two_dependencies(tu, UNIT_AFTER, UNIT_REQUIRES, UNIT(m), true);
- else /* auto + nofail */
- return unit_add_dependency(tu, UNIT_WANTS, UNIT(m), true);
- }
-
- return 0;
-}
-
-static int mount_add_device_links(Mount *m) {
- MountParameters *p;
- int r;
-
- assert(m);
-
- if (!(p = get_mount_parameters_configured(m)))
- return 0;
-
- if (!p->what)
- return 0;
-
- if (!mount_is_bind(p) &&
- !path_equal(m->where, "/") &&
- p == &m->parameters_etc_fstab) {
- bool nofail, noauto;
-
- noauto = !!mount_test_option(p->options, "noauto");
- nofail = !!mount_test_option(p->options, "nofail");
-
- if ((r = unit_add_node_link(UNIT(m), p->what,
- !noauto && nofail &&
- UNIT(m)->manager->running_as == MANAGER_SYSTEM)) < 0)
- return r;
- }
-
- if (p->passno > 0 &&
- !mount_is_bind(p) &&
- UNIT(m)->manager->running_as == MANAGER_SYSTEM &&
- !path_equal(m->where, "/")) {
- char *name;
- Unit *fsck;
- /* Let's add in the fsck service */
-
- /* aka SPECIAL_FSCK_SERVICE */
- if (!(name = unit_name_from_path_instance("fsck", p->what, ".service")))
- return -ENOMEM;
-
- if ((r = manager_load_unit_prepare(UNIT(m)->manager, name, NULL, NULL, &fsck)) < 0) {
- log_warning("Failed to prepare unit %s: %s", name, strerror(-r));
- free(name);
- return r;
- }
-
- free(name);
-
- SERVICE(fsck)->fsck_passno = p->passno;
-
- if ((r = unit_add_two_dependencies(UNIT(m), UNIT_AFTER, UNIT_REQUIRES, fsck, true)) < 0)
- return r;
- }
-
- return 0;
-}
-
-static int mount_add_default_dependencies(Mount *m) {
- int r;
- MountParameters *p;
-
- assert(m);
-
- if (UNIT(m)->manager->running_as != MANAGER_SYSTEM)
- return 0;
-
- p = get_mount_parameters_configured(m);
- if (p && needs_quota(p)) {
- if ((r = unit_add_two_dependencies_by_name(UNIT(m), UNIT_BEFORE, UNIT_WANTS, SPECIAL_QUOTACHECK_SERVICE, NULL, true)) < 0 ||
- (r = unit_add_two_dependencies_by_name(UNIT(m), UNIT_BEFORE, UNIT_WANTS, SPECIAL_QUOTAON_SERVICE, NULL, true)) < 0)