chiark
/
gitweb
/
~ianmdlvl
/
elogind.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Fix order and document user unit dirs
[elogind.git]
/
src
/
shared
/
dropin.c
diff --git
a/src/shared/dropin.c
b/src/shared/dropin.c
index 7774236f71dacc05d28a3fbfa2fdf56d7114c299..ac09be984a45d6d34e26bd21d8567bd2bf3b88ea 100644
(file)
--- a/
src/shared/dropin.c
+++ b/
src/shared/dropin.c
@@
-24,17
+24,21
@@
#include "mkdir.h"
#include "fileio-label.h"
#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;
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);
assert(unit);
assert(name);
assert(_p);
assert(_q);
+ sprintf(prefix, "%u", level);
+
b = xescape(name, "/.");
if (!b)
return -ENOMEM;
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;
if (!p)
return -ENOMEM;
- q = strjoin(p, "/
90
-", b, ".conf", NULL);
+ q = strjoin(p, "/
", prefix, "
-", b, ".conf", NULL);
if (!q) {
free(p);
return -ENOMEM;
if (!q) {
free(p);
return -ENOMEM;
@@
-57,7
+61,7
@@
int drop_in_file(const char *dir, const char *unit,
return 0;
}
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;
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);
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;
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);
}
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;
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;
if (r < 0)
return -ENOMEM;
- return write_drop_in(dir, unit, name, p);
+ return write_drop_in(dir, unit,
level,
name, p);
}
}