]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
lib: procfs: clarify name of procfs_process_get_data_for()
authorThomas Weißschuh <thomas@t-8ch.de>
Fri, 23 Dec 2022 21:05:02 +0000 (21:05 +0000)
committerThomas Weißschuh <thomas@t-8ch.de>
Fri, 23 Dec 2022 21:08:35 +0000 (21:08 +0000)
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

index 1072a9a2ce90cdd20b1b0107f3457aa8d1266a5f..16583721a68ea920897f29fe7712c50f03c3c957 100644 (file)
@@ -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;