cgls.c revision 324496eb25b51395a00430b28fac639502df9e3e
5828e9d7f59d4682a58585195d67153abdabacfcvboxsync/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
5828e9d7f59d4682a58585195d67153abdabacfcvboxsync This file is part of systemd.
5828e9d7f59d4682a58585195d67153abdabacfcvboxsync Copyright 2010 Lennart Poettering
5828e9d7f59d4682a58585195d67153abdabacfcvboxsync systemd is free software; you can redistribute it and/or modify it
5828e9d7f59d4682a58585195d67153abdabacfcvboxsync under the terms of the GNU Lesser General Public License as published by
5828e9d7f59d4682a58585195d67153abdabacfcvboxsync the Free Software Foundation; either version 2.1 of the License, or
5828e9d7f59d4682a58585195d67153abdabacfcvboxsync (at your option) any later version.
5828e9d7f59d4682a58585195d67153abdabacfcvboxsync systemd is distributed in the hope that it will be useful, but
5828e9d7f59d4682a58585195d67153abdabacfcvboxsync WITHOUT ANY WARRANTY; without even the implied warranty of
5828e9d7f59d4682a58585195d67153abdabacfcvboxsync MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
5828e9d7f59d4682a58585195d67153abdabacfcvboxsync Lesser General Public License for more details.
5828e9d7f59d4682a58585195d67153abdabacfcvboxsync You should have received a copy of the GNU Lesser General Public License
5828e9d7f59d4682a58585195d67153abdabacfcvboxsync along with systemd; If not, see <http://www.gnu.org/licenses/>.
5828e9d7f59d4682a58585195d67153abdabacfcvboxsyncstatic bool arg_no_pager = false;
5828e9d7f59d4682a58585195d67153abdabacfcvboxsyncstatic bool arg_kernel_threads = false;
5828e9d7f59d4682a58585195d67153abdabacfcvboxsyncstatic bool arg_all = false;
5828e9d7f59d4682a58585195d67153abdabacfcvboxsyncstatic void help(void) {
5828e9d7f59d4682a58585195d67153abdabacfcvboxsync "Recursively show control group contents.\n\n"
5828e9d7f59d4682a58585195d67153abdabacfcvboxsync " -h --help Show this help\n"
5828e9d7f59d4682a58585195d67153abdabacfcvboxsync " --version Show package version\n"
5828e9d7f59d4682a58585195d67153abdabacfcvboxsync " --no-pager Do not pipe output into a pager\n"
5828e9d7f59d4682a58585195d67153abdabacfcvboxsync " -a --all Show all groups, including empty\n"
5828e9d7f59d4682a58585195d67153abdabacfcvboxsync " -l --full Do not ellipsize output\n"
5828e9d7f59d4682a58585195d67153abdabacfcvboxsync " -k Include kernel threads in output\n"
5828e9d7f59d4682a58585195d67153abdabacfcvboxsync " -M --machine= Show container\n"
5828e9d7f59d4682a58585195d67153abdabacfcvboxsync while ((c = getopt_long(argc, argv, "hkalM:", options, NULL)) >= 0)
5828e9d7f59d4682a58585195d67153abdabacfcvboxsync switch (c) {
5828e9d7f59d4682a58585195d67153abdabacfcvboxsync _cleanup_bus_error_free_ sd_bus_error error = SD_BUS_ERROR_NULL;
5828e9d7f59d4682a58585195d67153abdabacfcvboxsync _cleanup_bus_flush_close_unref_ sd_bus *bus = NULL;
5828e9d7f59d4682a58585195d67153abdabacfcvboxsync const char *m;
5828e9d7f59d4682a58585195d67153abdabacfcvboxsync return log_error_errno(r, "Failed to get root control group path: %m");
5828e9d7f59d4682a58585195d67153abdabacfcvboxsync m = strjoina("/run/systemd/machines/", arg_machine);
5828e9d7f59d4682a58585195d67153abdabacfcvboxsync r = parse_env_file(m, NEWLINE, "SCOPE", &unit, NULL);
5828e9d7f59d4682a58585195d67153abdabacfcvboxsync return log_error_errno(r, "Failed to load machine data: %m");
5828e9d7f59d4682a58585195d67153abdabacfcvboxsync r = bus_open_transport(BUS_TRANSPORT_LOCAL, NULL, false, &bus);
5828e9d7f59d4682a58585195d67153abdabacfcvboxsync return log_error_errno(r, "Failed to create bus connection: %m");
5828e9d7f59d4682a58585195d67153abdabacfcvboxsync "ControlGroup",
5828e9d7f59d4682a58585195d67153abdabacfcvboxsync return log_error_errno(r, "Failed to query unit control group path: %s", bus_error_message(&error, r));
5828e9d7f59d4682a58585195d67153abdabacfcvboxsync if (r <= 0)
5828e9d7f59d4682a58585195d67153abdabacfcvboxsync if (r > 0 && arg_full < 0)
goto finish;
goto finish;
r = log_oom();
goto finish;
path = j;
bool done = false;
if (!arg_machine) {
if (!cwd) {
goto finish;
done = true;
if (!done) {
goto finish;
pager_close();