From 93c0d60794839c00afe9418939e0a15a3bece0b3 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Thomas=20Wei=C3=9Fschuh?= Date: Fri, 23 Dec 2022 21:05:02 +0000 Subject: [PATCH] lib: procfs: clarify name of procfs_process_get_data_for() The previous name "procfs_process_get_line_for()" indicates that only a single line would be read from the file. In fact the function always returns the full file contents. This behavior is necessary are various procfs files can contain legitimate newlines. Rename the function to match its behavior. --- lib/procfs.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/procfs.c b/lib/procfs.c index 1072a9a2ce..16583721a6 100644 --- a/lib/procfs.c +++ b/lib/procfs.c @@ -141,7 +141,7 @@ static ssize_t read_procfs_file(int fd, char *buf, size_t bufsz) return sz; } -static ssize_t procfs_process_get_line_for(struct path_cxt *pc, char *buf, size_t bufsz, +static ssize_t procfs_process_get_data_for(struct path_cxt *pc, char *buf, size_t bufsz, const char *fname) { int fd = ul_path_open(pc, O_RDONLY|O_CLOEXEC, fname); @@ -156,17 +156,17 @@ static ssize_t procfs_process_get_line_for(struct path_cxt *pc, char *buf, size_ ssize_t procfs_process_get_cmdline(struct path_cxt *pc, char *buf, size_t bufsz) { - return procfs_process_get_line_for(pc, buf, bufsz, "cmdline"); + return procfs_process_get_data_for(pc, buf, bufsz, "cmdline"); } ssize_t procfs_process_get_cmdname(struct path_cxt *pc, char *buf, size_t bufsz) { - return procfs_process_get_line_for(pc, buf, bufsz, "comm"); + return procfs_process_get_data_for(pc, buf, bufsz, "comm"); } ssize_t procfs_process_get_stat(struct path_cxt *pc, char *buf, size_t bufsz) { - return procfs_process_get_line_for(pc, buf, bufsz, "stat"); + return procfs_process_get_data_for(pc, buf, bufsz, "stat"); } int procfs_process_get_stat_nth(struct path_cxt *pc, int n, uintmax_t *re) @@ -179,7 +179,7 @@ int procfs_process_get_stat_nth(struct path_cxt *pc, int n, uintmax_t *re) if (n == 2 || n == 3) /* process name and status (strings) */ return -EINVAL; - rc = procfs_process_get_line_for(pc, buf, sizeof(buf), "stat"); + rc = procfs_process_get_data_for(pc, buf, sizeof(buf), "stat"); if (rc < 0) return rc; -- 2.47.3