]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
uclampset: use lib/procfs.c
authorKarel Zak <kzak@redhat.com>
Tue, 7 Sep 2021 15:39:33 +0000 (17:39 +0200)
committerKarel Zak <kzak@redhat.com>
Wed, 6 Oct 2021 09:01:54 +0000 (11:01 +0200)
schedutils/uclampset.c

index e09d6a7f9f0e2bca09c8d746f26331a7c19704a8..0de806abcfcf7914509963bf054b2764ab0195b1 100644 (file)
@@ -27,7 +27,7 @@
 #include "closestream.h"
 #include "path.h"
 #include "pathnames.h"
-#include "procutils.h"
+#include "procfs.h"
 #include "sched_attr.h"
 #include "strutils.h"
 
@@ -94,7 +94,7 @@ static void show_uclamp_pid_info(pid_t pid, char *cmd)
        if (cmd)
                comm = cmd;
        else
-               comm = proc_get_command_name(pid);
+               comm = pid_get_cmdname(pid);
 
        printf(_("%s (%d) util_clamp: min: %d max: %d\n"),
               comm ? : "unknown", pid, sa.sched_util_min, sa.sched_util_max);
@@ -134,16 +134,17 @@ static void show_uclamp_info(struct uclampset *ctl)
        if (ctl->system) {
                show_uclamp_system_info();
        } else if (ctl->all_tasks) {
+               DIR *sub = NULL;
                pid_t tid;
-               struct proc_tasks *ts = proc_open_tasks(ctl->pid);
+               struct path_cxt *pc = ul_new_procfs_path(ctl->pid, NULL);
 
-               if (!ts)
+               if (!pc)
                        err(EXIT_FAILURE, _("cannot obtain the list of tasks"));
 
-               while (!proc_next_tid(ts, &tid))
+               while (procfs_process_next_tid(pc, &sub, &tid) == 0)
                        show_uclamp_pid_info(tid, NULL);
 
-               proc_close_tasks(ts);
+               ul_unref_path(pc);
        } else {
                show_uclamp_pid_info(ctl->pid, ctl->cmd);
        }
@@ -175,17 +176,18 @@ static int set_uclamp_one(struct uclampset *ctl, pid_t pid)
 static void set_uclamp_pid(struct uclampset *ctl)
 {
        if (ctl->all_tasks) {
+               DIR *sub = NULL;
                pid_t tid;
-               struct proc_tasks *ts = proc_open_tasks(ctl->pid);
+               struct path_cxt *pc = ul_new_procfs_path(ctl->pid, NULL);
 
-               if (!ts)
+               if (!pc)
                        err(EXIT_FAILURE, _("cannot obtain the list of tasks"));
 
-               while (!proc_next_tid(ts, &tid))
+               while (procfs_process_next_tid(pc, &sub, &tid) == 0) {
                        if (set_uclamp_one(ctl, tid) == -1)
                                err(EXIT_FAILURE, _("failed to set tid %d's uclamp values"), tid);
-
-               proc_close_tasks(ts);
+               }
+               ul_unref_path(pc);
 
        } else if (set_uclamp_one(ctl, ctl->pid) == -1) {
                err(EXIT_FAILURE, _("failed to set pid %d's uclamp values"), ctl->pid);