chiark / gitweb /
core: rework how transient unit files and property drop-ins work
authorLennart Poettering <lennart@poettering.net>
Thu, 7 Apr 2016 13:43:59 +0000 (15:43 +0200)
committerSven Eden <yamakuzure@gmx.net>
Fri, 16 Jun 2017 08:12:57 +0000 (10:12 +0200)
With this change the logic for placing transient unit files and drop-ins
generated via "systemctl set-property" is reworked.

The latter are now placed in the newly introduced "control" unit file
directory. The fomer are now placed in the "transient" unit file directory.

Note that the properties originally set when a transient unit was created will
be written to and stay in the transient unit file directory, while later
changes are done via drop-ins.

This is preparation for a later "systemctl revert" addition, where existing
drop-ins are flushed out, but the original transient definition is restored.

src/basic/strv.c

index 3a021003fae8b2e22c4e25a0a94411d8b819156b..7757a444346725fa448bee8b8525eb443099aecd 100644 (file)
@@ -566,6 +566,42 @@ int strv_extend(char ***l, const char *value) {
         return strv_consume(l, v);
 }
 
+int strv_extend_front(char ***l, const char *value) {
+        size_t n, m;
+        char *v, **c;
+
+        assert(l);
+
+        /* Like strv_extend(), but prepends rather than appends the new entry */
+
+        if (!value)
+                return 0;
+
+        n = strv_length(*l);
+
+        /* Increase and overflow check. */
+        m = n + 2;
+        if (m < n)
+                return -ENOMEM;
+
+        v = strdup(value);
+        if (!v)
+                return -ENOMEM;
+
+        c = realloc_multiply(*l, sizeof(char*), m);
+        if (!c) {
+                free(v);
+                return -ENOMEM;
+        }
+
+        memmove(c+1, c, n * sizeof(char*));
+        c[0] = v;
+        c[n+1] = NULL;
+
+        *l = c;
+        return 0;
+}
+
 char **strv_uniq(char **l) {
         char **i;