diff options
Diffstat (limited to 'src/shared')
-rw-r--r-- | src/shared/dropin.c | 16 | ||||
-rw-r--r-- | src/shared/dropin.h | 6 | ||||
-rw-r--r-- | src/shared/generator.c | 9 |
3 files changed, 19 insertions, 12 deletions
diff --git a/src/shared/dropin.c b/src/shared/dropin.c index 7774236f71..ac09be984a 100644 --- a/src/shared/dropin.c +++ b/src/shared/dropin.c @@ -24,17 +24,21 @@ #include "mkdir.h" #include "fileio-label.h" -int drop_in_file(const char *dir, const char *unit, +int drop_in_file(const char *dir, const char *unit, unsigned level, const char *name, char **_p, char **_q) { _cleanup_free_ char *b = NULL; char *p, *q; + char prefix[DECIMAL_STR_MAX(unsigned)]; + assert(unit); assert(name); assert(_p); assert(_q); + sprintf(prefix, "%u", level); + b = xescape(name, "/."); if (!b) return -ENOMEM; @@ -46,7 +50,7 @@ int drop_in_file(const char *dir, const char *unit, if (!p) return -ENOMEM; - q = strjoin(p, "/90-", b, ".conf", NULL); + q = strjoin(p, "/", prefix, "-", b, ".conf", NULL); if (!q) { free(p); return -ENOMEM; @@ -57,7 +61,7 @@ int drop_in_file(const char *dir, const char *unit, return 0; } -int write_drop_in(const char *dir, const char *unit, +int write_drop_in(const char *dir, const char *unit, unsigned level, const char *name, const char *data) { _cleanup_free_ char *p = NULL, *q = NULL; @@ -68,7 +72,7 @@ int write_drop_in(const char *dir, const char *unit, assert(name); assert(data); - r = drop_in_file(dir, unit, name, &p, &q); + r = drop_in_file(dir, unit, level, name, &p, &q); if (r < 0) return r; @@ -76,7 +80,7 @@ int write_drop_in(const char *dir, const char *unit, return write_string_file_atomic_label(q, data); } -int write_drop_in_format(const char *dir, const char *unit, +int write_drop_in_format(const char *dir, const char *unit, unsigned level, const char *name, const char *format, ...) { _cleanup_free_ char *p = NULL; va_list ap; @@ -94,5 +98,5 @@ int write_drop_in_format(const char *dir, const char *unit, if (r < 0) return -ENOMEM; - return write_drop_in(dir, unit, name, p); + return write_drop_in(dir, unit, level, name, p); } diff --git a/src/shared/dropin.h b/src/shared/dropin.h index 2958632963..27a2b2953f 100644 --- a/src/shared/dropin.h +++ b/src/shared/dropin.h @@ -21,11 +21,11 @@ along with systemd; If not, see <http://www.gnu.org/licenses/>. ***/ -int drop_in_file(const char *dir, const char *unit, +int drop_in_file(const char *dir, const char *unit, unsigned level, const char *name, char **_p, char **_q); -int write_drop_in(const char *dir, const char *unit, +int write_drop_in(const char *dir, const char *unit, unsigned level, const char *name, const char *data); -int write_drop_in_format(const char *dir, const char *unit, +int write_drop_in_format(const char *dir, const char *unit, unsigned level, const char *name, const char *format, ...); diff --git a/src/shared/generator.c b/src/shared/generator.c index 1db5f8fb62..5d5b6a0a61 100644 --- a/src/shared/generator.c +++ b/src/shared/generator.c @@ -108,7 +108,7 @@ int generator_write_timeouts(const char *dir, const char *what, const char *wher timeout = start + 25; else { if (filtered) { - *filtered = strdup(opts); + *filtered = strdup(opts ?: ""); if (!*filtered) return log_oom(); } @@ -146,6 +146,9 @@ int generator_write_timeouts(const char *dir, const char *what, const char *wher if (!unit) return -ENOMEM; - return write_drop_in_format(dir, unit, "device-timeout", - "[Unit]\nJobTimeoutSec=%u", u / USEC_PER_SEC); + return write_drop_in_format(dir, unit, 50, "device-timeout", + "# Automatically generated by %s\n\n" + "[Unit]\nJobTimeoutSec=%u", + program_invocation_short_name, + u / USEC_PER_SEC); } |