]> git.ipfire.org Git - thirdparty/systemd.git/blobdiff - src/shared/cgroup-show.c
util-lib: split out env file parsing code into env-file.c
[thirdparty/systemd.git] / src / shared / cgroup-show.c
index ea2db32510276fbb85d22f85b7549dd42c580ab1..988a354ae36d7408dbffbe2695938e8d2e5df629 100644 (file)
@@ -1,9 +1,4 @@
 /* SPDX-License-Identifier: LGPL-2.1+ */
-/***
-  This file is part of systemd.
-
-  Copyright 2010 Lennart Poettering
-***/
 
 #include <dirent.h>
 #include <errno.h>
@@ -17,8 +12,8 @@
 #include "bus-util.h"
 #include "cgroup-show.h"
 #include "cgroup-util.h"
+#include "env-file.h"
 #include "fd-util.h"
-#include "fileio.h"
 #include "format-util.h"
 #include "locale-util.h"
 #include "macro.h"
@@ -43,7 +38,7 @@ static void show_pid_array(
         if (n_pids == 0)
                 return;
 
-        qsort(pids, n_pids, sizeof(pid_t), pid_compare_func);
+        typesafe_qsort(pids, n_pids, pid_compare_func);
 
         /* Filter duplicates */
         for (j = 0, i = 1; i < n_pids; i++) {
@@ -282,26 +277,6 @@ int show_cgroup_and_extra(
         return show_extra_pids(controller, path, prefix, n_columns, extra_pids, n_extra_pids, flags);
 }
 
-int show_cgroup_and_extra_by_spec(
-                const char *spec,
-                const char *prefix,
-                unsigned n_columns,
-                const pid_t extra_pids[],
-                unsigned n_extra_pids,
-                OutputFlags flags) {
-
-        _cleanup_free_ char *controller = NULL, *path = NULL;
-        int r;
-
-        assert(spec);
-
-        r = cg_split_spec(spec, &controller, &path);
-        if (r < 0)
-                return r;
-
-        return show_cgroup_and_extra(controller, path, prefix, n_columns, extra_pids, n_extra_pids, flags);
-}
-
 int show_cgroup_get_unit_path_and_warn(
                 sd_bus *bus,
                 const char *unit,
@@ -344,7 +319,7 @@ int show_cgroup_get_path_and_warn(
                 const char *m;
 
                 m = strjoina("/run/systemd/machines/", machine);
-                r = parse_env_file(m, NEWLINE, "SCOPE", &unit, NULL);
+                r = parse_env_file(NULL, m, "SCOPE", &unit);
                 if (r < 0)
                         return log_error_errno(r, "Failed to load machine data: %m");