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:
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user