diff options
| author | Leah Rowe <leah@libreboot.org> | 2026-03-06 22:34:15 +0000 |
|---|---|---|
| committer | Leah Rowe <leah@libreboot.org> | 2026-03-06 22:36:08 +0000 |
| commit | a7d7f68a5c06ada9c7fb090a8679a723e1253f2f (patch) | |
| tree | 586dcaabfe2bebeb8b74ce0b5088da18278e410f /util | |
| parent | e27339179241937b728a38c701d969dc0b4a84d3 (diff) | |
util/nvmutil: be clearer about GbE file sizes
the partsize variable is also misleading, because it
refers to the full half of a file, which might be
bigger than 4KB. this variable name is a hangover
from when nvmutil only supported 8KB files.
Signed-off-by: Leah Rowe <leah@libreboot.org>
Diffstat (limited to 'util')
| -rw-r--r-- | util/nvmutil/nvmutil.c | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/util/nvmutil/nvmutil.c b/util/nvmutil/nvmutil.c index 81812b0a..c4fe6259 100644 --- a/util/nvmutil/nvmutil.c +++ b/util/nvmutil/nvmutil.c @@ -121,14 +121,13 @@ static const char *rname = NULL; static uint8_t buf[GBE_FILE_SIZE]; /* 8KB */ static uint16_t mac_buf[3]; -static off_t partsize; +static off_t gbe_file_size; static int gbe_flags; #ifndef HAVE_ARC4RANDOM static int rfd = -1; #endif static int gbe_fd = -1; -static struct stat gbe_st; static size_t part; static unsigned char invert; static unsigned char part_modified[2]; @@ -342,13 +341,16 @@ open_dev_urandom(void) static void open_gbe_file(void) { + static struct stat gbe_st; + xopen(&gbe_fd, fname, gbe_flags, &gbe_st); - switch(gbe_st.st_size) { + gbe_file_size = gbe_st.st_size; + + switch (gbe_file_size) { case SIZE_8KB: case SIZE_16KB: case SIZE_128KB: - partsize = gbe_st.st_size >> 1; break; default: err(ECANCELED, "File size must be 8KB, 16KB or 128KB"); @@ -841,7 +843,7 @@ static off_t gbe_file_offset(size_t p, const char *f_op) { return gbe_x_offset(p, f_op, "file", - partsize, gbe_st.st_size); + gbe_file_size >> 1, gbe_file_size); } /* |
