kboot: Add option to parse 32-bit quantity

The type that's exposed from sysfs' memory map is 32-bit and so is the
data-type of memory description.

Sponsored by:		Netflix
Reviewed by:		kevans, andrew,	jhibbits
Differential Revision:	https://reviews.freebsd.org/D49856
This commit is contained in:
Warner Losh
2025-04-16 22:03:34 -06:00
parent 58c99df219
commit 14acbf6159
2 changed files with 14 additions and 0 deletions
+1
View File
@@ -7,4 +7,5 @@
#pragma once
bool file2str(const char *fn, char *buffer, size_t buflen);
bool file2u32(const char *fn, uint32_t *val);
bool file2u64(const char *fn, uint64_t *val);
+13
View File
@@ -44,3 +44,16 @@ file2u64(const char *fn, uint64_t *val)
*val = v;
return true;
}
bool
file2u32(const char *fn, uint32_t *val)
{
unsigned long v;
char buffer[80];
if (!file2str(fn, buffer, sizeof(buffer)))
return false;
v = strtoul(buffer, NULL, 0); /* XXX check return values? */
*val = v;
return true;
}