return 0;
}
+static int mount_add_path_links(Mount *m) {
+ Meta *other;
+ int r;
+
+ assert(m);
+
+ LIST_FOREACH(units_per_type, other, m->meta.manager->units_per_type[UNIT_PATH])
+ if ((r = path_add_one_mount_link((Path*) other, m)) < 0)
+ return r;
+
+ return 0;
+}
+
static int mount_add_automount_links(Mount *m) {
Meta *other;
int r;
char *e;
assert(m);
- if (UNIT(m)->meta.load_state != UNIT_LOADED)
+ if (m->meta.load_state != UNIT_LOADED)
return 0;
+ if (!m->from_etc_fstab && !m->from_fragment && !m->from_proc_self_mountinfo)
+ return -ENOENT;
+
if (!(e = unit_name_from_path(m->where, ".mount")))
return -ENOMEM;
if ((r = mount_add_swap_links(m)) < 0)
return r;
+ if ((r = mount_add_path_links(m)) < 0)
+ return r;
+
if ((r = mount_add_automount_links(m)) < 0)
return r;
case MOUNT_REMOUNTING_SIGKILL:
case MOUNT_REMOUNTING_SIGTERM:
- if (success && m->from_proc_self_mountinfo)
+ if (success)
mount_enter_mounted(m, true);
else if (m->from_proc_self_mountinfo)
mount_enter_mounted(m, false);
static int mount_load_proc_self_mountinfo(Manager *m, bool set_flags) {
int r;
- char *device, *path, *options, *fstype, *d, *p;
+ char *device, *path, *options, *options2, *fstype, *d, *p, *o;
assert(m);
for (;;) {
int k;
- device = path = options = fstype = d = p = NULL;
+ device = path = options = options2 = fstype = d = p = o = NULL;
if ((k = fscanf(m->proc_self_mountinfo,
"%*s " /* (1) mount id */
"- " /* (8) seperator */
"%ms " /* (9) file system type */
"%ms" /* (10) mount source */
+ "%ms" /* (11) mount options 2 */
"%*[^\n]", /* some rubbish at the end */
&path,
&options,
&fstype,
- &device)) != 4) {
+ &device,
+ &options2)) != 5) {
if (k == EOF)
break;
goto finish;
}
+ if (asprintf(&o, "%s,%s", options, options2) < 0) {
+ r = -ENOMEM;
+ goto finish;
+ }
+
if (!(d = cunescape(device)) ||
!(p = cunescape(path))) {
r = -ENOMEM;
goto finish;
}
- if ((r = mount_add_one(m, d, p, options, fstype, true, set_flags)) < 0)
+ if ((r = mount_add_one(m, d, p, o, fstype, true, set_flags)) < 0)
goto finish;
free(device);
free(path);
free(options);
+ free(options2);
free(fstype);
free(d);
free(p);
+ free(o);
}
r = 0;
free(device);
free(path);
free(options);
+ free(options2);
free(fstype);
free(d);
free(p);
+ free(o);
return r;
}