mirror of
https://github.com/AuxXxilium/eudev.git
synced 2024-12-26 05:35:21 +07:00
unit-name: rework unit_name_replace_instance function()
https://bugzilla.redhat.com/show_bug.cgi?id=855863
This commit is contained in:
parent
49a32d43de
commit
8556879e0d
12
TODO
12
TODO
@ -49,6 +49,18 @@ Bugfixes:
|
|||||||
|
|
||||||
Features:
|
Features:
|
||||||
|
|
||||||
|
* perfomance messages for selinux are gone from debug log?
|
||||||
|
|
||||||
|
* http://lists.freedesktop.org/archives/systemd-devel/2012-September/006502.html
|
||||||
|
|
||||||
|
* don't use writev() in tmpfiles for sake of compat with sysfs?
|
||||||
|
|
||||||
|
* come up with a nice way to write queue/read_ahead_kb for a block device without interfering with readahead
|
||||||
|
|
||||||
|
* journald: add kernel cmdline option to disable ratelimiting for debug purposes
|
||||||
|
|
||||||
|
* Add a way to reference the machine/boot ID from ExecStart= and similar command lines
|
||||||
|
|
||||||
* move PID 1 segfaults to /var/lib/systemd/coredump?
|
* move PID 1 segfaults to /var/lib/systemd/coredump?
|
||||||
|
|
||||||
* Document word splitting syntax for ExecStart= and friends
|
* Document word splitting syntax for ExecStart= and friends
|
||||||
|
@ -357,36 +357,29 @@ bool unit_name_is_instance(const char *n) {
|
|||||||
char *unit_name_replace_instance(const char *f, const char *i) {
|
char *unit_name_replace_instance(const char *f, const char *i) {
|
||||||
const char *p, *e;
|
const char *p, *e;
|
||||||
char *r, *k;
|
char *r, *k;
|
||||||
size_t a;
|
size_t a, b;
|
||||||
|
|
||||||
assert(f);
|
assert(f);
|
||||||
|
|
||||||
p = strchr(f, '@');
|
p = strchr(f, '@');
|
||||||
assert_se(e = strrchr(f, '.'));
|
if (!p)
|
||||||
|
return strdup(f);
|
||||||
|
|
||||||
|
e = strrchr(f, '.');
|
||||||
|
if (!e)
|
||||||
|
assert_se(e = strchr(f, 0));
|
||||||
|
|
||||||
a = p - f;
|
a = p - f;
|
||||||
|
b = strlen(i);
|
||||||
|
|
||||||
if (p) {
|
r = new(char, a + 1 + b + strlen(e) + 1);
|
||||||
size_t b;
|
if (!r)
|
||||||
|
return NULL;
|
||||||
b = strlen(i);
|
|
||||||
|
|
||||||
r = new(char, a + 1 + b + strlen(e) + 1);
|
|
||||||
if (!r)
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
k = mempcpy(r, f, a + 1);
|
|
||||||
k = mempcpy(k, i, b);
|
|
||||||
} else {
|
|
||||||
|
|
||||||
r = new(char, a + strlen(e) + 1);
|
|
||||||
if (!r)
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
k = mempcpy(r, f, a);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
k = mempcpy(r, f, a + 1);
|
||||||
|
k = mempcpy(k, i, b);
|
||||||
strcpy(k, e);
|
strcpy(k, e);
|
||||||
|
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -29,6 +29,30 @@
|
|||||||
int main(int argc, char* argv[]) {
|
int main(int argc, char* argv[]) {
|
||||||
char *t, *k;
|
char *t, *k;
|
||||||
|
|
||||||
|
t = unit_name_replace_instance("foo@.service", "waldo");
|
||||||
|
puts(t);
|
||||||
|
free(t);
|
||||||
|
|
||||||
|
t = unit_name_replace_instance("foo@xyz.service", "waldo");
|
||||||
|
puts(t);
|
||||||
|
free(t);
|
||||||
|
|
||||||
|
t = unit_name_replace_instance("xyz", "waldo");
|
||||||
|
puts(t);
|
||||||
|
free(t);
|
||||||
|
|
||||||
|
t = unit_name_replace_instance("", "waldo");
|
||||||
|
puts(t);
|
||||||
|
free(t);
|
||||||
|
|
||||||
|
t = unit_name_replace_instance("", "");
|
||||||
|
puts(t);
|
||||||
|
free(t);
|
||||||
|
|
||||||
|
t = unit_name_replace_instance("foo.service", "waldo");
|
||||||
|
puts(t);
|
||||||
|
free(t);
|
||||||
|
|
||||||
t = unit_name_from_path("/waldo", ".mount");
|
t = unit_name_from_path("/waldo", ".mount");
|
||||||
puts(t);
|
puts(t);
|
||||||
k = unit_name_to_path(t);
|
k = unit_name_to_path(t);
|
||||||
|
Loading…
Reference in New Issue
Block a user