+static bool mount_is_bind(MountParameters *p) {
+ assert(p);
+
+ if (p->fstype && streq(p->fstype, "bind"))
+ return true;
+
+ if (mount_test_option(p->options, "bind"))
+ return true;
+
+ return false;
+}
+
+static int mount_add_device_links(Mount *m) {
+ MountParameters *p;
+ int r;
+
+ assert(m);
+
+ if (m->from_fragment)
+ p = &m->parameters_fragment;
+ else if (m->from_etc_fstab)
+ p = &m->parameters_etc_fstab;
+ else
+ return 0;
+
+ if (!p->what)
+ return 0;
+
+ if (!mount_is_bind(p) && !path_equal(m->where, "/")) {
+ bool nofail, noauto;
+
+ noauto = !!mount_test_option(p->options, MNTOPT_NOAUTO);
+ nofail = !!mount_test_option(p->options, "nofail");
+
+ if ((r = unit_add_node_link(UNIT(m), p->what,
+ !noauto && nofail &&
+ UNIT(m)->meta.manager->running_as == MANAGER_SYSTEM)) < 0)
+ return r;
+ }
+
+ if (p->passno > 0 &&
+ UNIT(m)->meta.manager->running_as == MANAGER_SYSTEM) {
+ char *name;
+ Unit *fsck;
+ /* Let's add in the fsck service */
+
+ if (!(name = unit_name_from_path_instance("fsck", p->what, ".service")))
+ return -ENOMEM;
+
+ if ((r = manager_load_unit_prepare(m->meta.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_WANTS, fsck, true)) < 0)
+ return r;
+ }
+
+ return 0;
+}
+