[systemd-devel] [PATCH 3/4] fstab-generator: do not overwrite already generated units

harald at redhat.com harald at redhat.com
Mon Mar 4 22:28:43 PST 2013


From: Harald Hoyer <harald at redhat.com>

only checks for /run/systemd/generator/*.mount
---
 src/fstab-generator/fstab-generator.c | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/src/fstab-generator/fstab-generator.c b/src/fstab-generator/fstab-generator.c
index 3b8329b..502f64c 100644
--- a/src/fstab-generator/fstab-generator.c
+++ b/src/fstab-generator/fstab-generator.c
@@ -419,6 +419,21 @@ static int parse_fstab(const char *prefix, bool initrd) {
                 if (is_path(where))
                         path_kill_slashes(where);
 
+                if (initrd) {
+                        char _cleanup_free_ *mu = NULL, *name = NULL;
+                        /* Skip generation, if unit already exists */
+                        name = unit_name_from_path(where, ".mount");
+                        if (!name)
+                                return log_oom();
+                        mu = strjoin(arg_dest, "/", name, NULL);
+                        if (!mu)
+                                return log_oom();
+
+                        k = access(mu, R_OK);
+                        if (k == 0)
+                                continue;
+                }
+
                 log_debug("Found entry what=%s where=%s type=%s", what, where, me->mnt_type);
 
                 if (streq(me->mnt_type, "swap"))
-- 
1.8.1



More information about the systemd-devel mailing list