fileio: modernize get_proc_field()
- Drop effectively unused "terminator" param, imply whitespace
- Make ret param optional
- Return ENODATA if the requested key is not found, rather than
ENOENT
- Turn ENOENT -> ENOSYS if /proc/ is not mounted
- Don't skip whitespaces before ':', nothing needs this handling
anyways
- Remove the special treatment for all "0"s. We don't actually
use this for capabilities given pidref_get_capability() exists
- Switch away from read_full_virtual_file() - files using "field"
scheme under /proc/ seem all to be "seq_file"s (refer to
da65941c3e for details on file types)
This commit is contained in:
+3
-3
@@ -432,8 +432,8 @@ static Virtualization detect_vm_zvm(void) {
|
||||
_cleanup_free_ char *t = NULL;
|
||||
int r;
|
||||
|
||||
r = get_proc_field("/proc/sysinfo", "VM00 Control Program", WHITESPACE, &t);
|
||||
if (r == -ENOENT)
|
||||
r = get_proc_field("/proc/sysinfo", "VM00 Control Program", &t);
|
||||
if (IN_SET(r, -ENOENT, -ENODATA))
|
||||
return VIRTUALIZATION_NONE;
|
||||
if (r < 0)
|
||||
return r;
|
||||
@@ -655,7 +655,7 @@ Virtualization detect_container(void) {
|
||||
/* proot doesn't use PID namespacing, so we can just check if we have a matching tracer for this
|
||||
* invocation without worrying about it being elsewhere.
|
||||
*/
|
||||
r = get_proc_field("/proc/self/status", "TracerPid", WHITESPACE, &p);
|
||||
r = get_proc_field("/proc/self/status", "TracerPid", &p);
|
||||
if (r < 0)
|
||||
log_debug_errno(r, "Failed to read our own trace PID, ignoring: %m");
|
||||
else if (!streq(p, "0")) {
|
||||
|
||||
Reference in New Issue
Block a user