summaryrefslogtreecommitdiff
path: root/src/shared/cgroup-util.c
diff options
context:
space:
mode:
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2013-04-30 00:35:38 -0400
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2013-05-01 10:15:25 -0400
commit38158b920e772ea3a7cc9dfcf705666ce3aa5ce3 (patch)
tree4106a88cbf6f55cb41694c6e7d85dd08f3108089 /src/shared/cgroup-util.c
parent57277cbe40bc9a1421c810cee39c606f11d39008 (diff)
cgls: add --machine/-M
cg_get_machine_path is modified to include the escaped machine name + ".nspawn" if the machine argument is nonnull.
Diffstat (limited to 'src/shared/cgroup-util.c')
-rw-r--r--src/shared/cgroup-util.c17
1 files changed, 11 insertions, 6 deletions
diff --git a/src/shared/cgroup-util.c b/src/shared/cgroup-util.c
index 1366f5865f..8c2ef45530 100644
--- a/src/shared/cgroup-util.c
+++ b/src/shared/cgroup-util.c
@@ -1146,17 +1146,22 @@ int cg_get_user_path(char **path) {
return 0;
}
-int cg_get_machine_path(char **path) {
- _cleanup_free_ char *root = NULL;
+int cg_get_machine_path(const char *machine, char **path) {
+ _cleanup_free_ char *root = NULL, *escaped = NULL;
char *p;
assert(path);
- if (cg_get_root_path(&root) < 0 || streq(root, "/"))
- p = strdup("/machine");
- else
- p = strappend(root, "/machine");
+ if (machine) {
+ const char *name = strappenda(machine, ".nspawn");
+
+ escaped = cg_escape(name);
+ if (!escaped)
+ return -ENOMEM;
+ }
+ p = strjoin(cg_get_root_path(&root) >= 0 && !streq(root, "/") ? root : "",
+ "/machine", machine ? "/" : "", machine ? escaped : "", NULL);
if (!p)
return -ENOMEM;