fileio: make get_status_field() more generic

All users of get_status_field() expect the field pattern to occur in
the beginning of a line, and the delimiter is ':'.

Hardcode this into the function, and also skip any whitespace before ':'
to support fields in files like /proc/cpuinfo. Add support for returning
the full field value (currently stops on first whitespace).

Rename the function so it's easier to ensure all callers switch to new
semantics.
This commit is contained in:
Aaro Koskinen
2015-09-30 15:57:55 +03:00
parent 5e6ad75f25
commit c4cd1d4d93
6 changed files with 40 additions and 16 deletions
+1 -1
View File
@@ -215,7 +215,7 @@ int get_process_capeff(pid_t pid, char **capeff) {
p = procfs_file_alloca(pid, "status");
r = get_status_field(p, "\nCapEff:", capeff);
r = get_proc_field(p, "CapEff", WHITESPACE, capeff);
if (r == -ENOENT)
return -ESRCH;