}
static int mount_add_target_links(Mount *m) {
- const char *target;
+ const char *target, *after = NULL;
MountParameters *p;
Unit *tu;
int r;
automount = !!mount_test_option(p->options, "comment=systemd.automount");
if (mount_test_option(p->options, "_netdev") ||
- fstype_is_network(p->fstype))
+ (p->fstype && fstype_is_network(p->fstype))) {
target = SPECIAL_REMOTE_FS_TARGET;
- else
+
+ if (m->meta.manager->running_as == MANAGER_SYSTEM)
+ after = SPECIAL_NETWORK_TARGET;
+ } else
target = SPECIAL_LOCAL_FS_TARGET;
if ((r = manager_load_unit(m->meta.manager, target, NULL, NULL, &tu)) < 0)
return r;
+ if (after)
+ if ((r = unit_add_dependency_by_name(tu, UNIT_AFTER, after, NULL, true)) < 0)
+ return r;
+
if (automount && m->meta.manager->running_as == MANAGER_SYSTEM) {
Unit *am;
"/bin/mount",
m->parameters_fragment.what,
m->where,
- "-t", m->parameters_fragment.fstype,
+ "-t", m->parameters_fragment.fstype ? m->parameters_fragment.fstype : "auto",
m->parameters_fragment.options ? "-o" : NULL, m->parameters_fragment.options,
NULL);
else if (m->from_etc_fstab)
"/bin/mount",
m->parameters_fragment.what,
m->where,
- "-t", m->parameters_fragment.fstype,
+ "-t", m->parameters_fragment.fstype ? m->parameters_fragment.fstype : "auto",
"-o", o,
NULL);
static int mount_load_proc_self_mountinfo(Manager *m, bool set_flags) {
int r;
+ unsigned i;
char *device, *path, *options, *options2, *fstype, *d, *p, *o;
assert(m);
rewind(m->proc_self_mountinfo);
- for (;;) {
+ for (i = 1;; i++) {
int k;
device = path = options = options2 = fstype = d = p = o = NULL;
"%ms " /* (5) mount point */
"%ms" /* (6) mount options */
"%*[^-]" /* (7) optional fields */
- "- " /* (8) seperator */
+ "- " /* (8) separator */
"%ms " /* (9) file system type */
"%ms" /* (10) mount source */
"%ms" /* (11) mount options 2 */
if (k == EOF)
break;
- r = -EBADMSG;
- goto finish;
+ log_warning("Failed to parse /proc/self/mountinfo:%u.", i);
+ goto clean_up;
}
if (asprintf(&o, "%s,%s", options, options2) < 0) {
if ((r = mount_add_one(m, d, p, o, fstype, true, set_flags)) < 0)
goto finish;
+clean_up:
free(device);
free(path);
free(options);