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:
+1
-1
@@ -240,7 +240,7 @@ static int detect_vm_zvm(void) {
|
||||
_cleanup_free_ char *t = NULL;
|
||||
int r;
|
||||
|
||||
r = get_status_field("/proc/sysinfo", "VM00 Control Program:", &t);
|
||||
r = get_proc_field("/proc/sysinfo", "VM00 Control Program", WHITESPACE, &t);
|
||||
if (r == -ENOENT)
|
||||
return VIRTUALIZATION_NONE;
|
||||
if (r < 0)
|
||||
|
||||
Reference in New Issue
Block a user