diff --git a/stand/kboot/include/util.h b/stand/kboot/include/util.h --- 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 --- a/stand/kboot/libkboot/util.c +++ b/stand/kboot/libkboot/util.c @@ -44,3 +44,16 @@ *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; +}