cgls: add --machine/-M
cg_get_machine_path is modified to include the escaped machine name + ".nspawn" if the machine argument is nonnull.
This commit is contained in:
@@ -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;
|
||||
|
||||
|
||||
@@ -87,7 +87,7 @@ int cg_is_empty_recursive(const char *controller, const char *path, bool ignore_
|
||||
int cg_get_root_path(char **path);
|
||||
int cg_get_system_path(char **path);
|
||||
int cg_get_user_path(char **path);
|
||||
int cg_get_machine_path(char **path);
|
||||
int cg_get_machine_path(const char *machine, char **path);
|
||||
|
||||
int cg_path_get_session(const char *path, char **session);
|
||||
int cg_path_get_owner_uid(const char *path, uid_t *uid);
|
||||
|
||||
Reference in New Issue
Block a user