git: 14acbf6159c3 - main - kboot: Add option to parse 32-bit quantity
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Thu, 17 Apr 2025 21:59:09 UTC
The branch main has been updated by imp:
URL: https://cgit.FreeBSD.org/src/commit/?id=14acbf6159c3efa8ce3965bb1211d4232af3fb4f
commit 14acbf6159c3efa8ce3965bb1211d4232af3fb4f
Author: Warner Losh <imp@FreeBSD.org>
AuthorDate: 2025-04-17 04:03:34 +0000
Commit: Warner Losh <imp@FreeBSD.org>
CommitDate: 2025-04-17 21:56:45 +0000
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
---
stand/kboot/include/util.h | 1 +
stand/kboot/libkboot/util.c | 13 +++++++++++++
2 files changed, 14 insertions(+)
diff --git a/stand/kboot/include/util.h b/stand/kboot/include/util.h
index ca71277bc66a..682ab8830bfa 100644
--- a/stand/kboot/include/util.h
+++ b/stand/kboot/include/util.h
@@ -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);
diff --git a/stand/kboot/libkboot/util.c b/stand/kboot/libkboot/util.c
index 0100a7cc5d8a..c7fe8b542643 100644
--- a/stand/kboot/libkboot/util.c
+++ b/stand/kboot/libkboot/util.c
@@ -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;
+}