[systemd-devel] [PATCH 2/2] core: do not overwrite existing units source
Umut Tezduyar
umut at tezduyar.com
Mon Feb 4 06:01:23 PST 2013
Only set source for freshly created .mounts coming from
mountinfo file.
---
src/core/mount.c | 12 +++++++-----
1 files changed, 7 insertions(+), 5 deletions(-)
diff --git a/src/core/mount.c b/src/core/mount.c
index 29ce440..8231059 100644
--- a/src/core/mount.c
+++ b/src/core/mount.c
@@ -1440,7 +1440,7 @@ static int mount_add_one(
int r;
Unit *u;
bool delete;
- char *e, *w = NULL, *o = NULL, *s = NULL, *f = NULL;
+ char *e, *w = NULL, *o = NULL, *f = NULL;
MountParameters *p;
bool load_extras = false;
@@ -1488,6 +1488,12 @@ static int mount_add_one(
goto fail;
}
+ u->source_path = strdup("/proc/self/mountinfo");
+ if (!u->source_path) {
+ r = -ENOMEM;
+ goto fail;
+ }
+
r = unit_add_two_dependencies_by_name(u, UNIT_BEFORE, UNIT_REQUIRED_BY, SPECIAL_LOCAL_FS_TARGET, NULL, true);
if (r < 0)
goto fail;
@@ -1517,7 +1523,6 @@ static int mount_add_one(
if (!(w = strdup(what)) ||
!(o = strdup(options)) ||
- !(s = strdup("/proc/self/mountinfo")) ||
!(f = strdup(fstype))) {
r = -ENOMEM;
goto fail;
@@ -1531,8 +1536,6 @@ static int mount_add_one(
}
MOUNT(u)->from_proc_self_mountinfo = true;
- free(u->source_path);
- u->source_path = s;
free(p->what);
p->what = w;
@@ -1558,7 +1561,6 @@ static int mount_add_one(
fail:
free(w);
free(o);
- free(s);
free(f);
if (delete && u)
--
1.7.2.5
More information about the systemd-devel
mailing list