diff options
| author | Leah Rowe <leah@libreboot.org> | 2026-03-17 17:29:07 +0000 |
|---|---|---|
| committer | Leah Rowe <leah@libreboot.org> | 2026-03-17 17:29:07 +0000 |
| commit | 0db9cc321f11cb231ba609e53bcc790d3171e1d4 (patch) | |
| tree | 0a31ddaf253e365687119f73dedd34f8ac7af9f9 /util/nvmutil/nvmutil.c | |
| parent | 6e63106dae202471d66c5274979b3caf1cd09096 (diff) | |
util/nvmutil: split up copy_gbe
Signed-off-by: Leah Rowe <leah@libreboot.org>
Diffstat (limited to 'util/nvmutil/nvmutil.c')
| -rw-r--r-- | util/nvmutil/nvmutil.c | 42 |
1 files changed, 25 insertions, 17 deletions
diff --git a/util/nvmutil/nvmutil.c b/util/nvmutil/nvmutil.c index 002ec715..f6374a7a 100644 --- a/util/nvmutil/nvmutil.c +++ b/util/nvmutil/nvmutil.c @@ -561,6 +561,31 @@ xopen(int *fd_ptr, const char *path, int flags, struct stat *st) void copy_gbe(void) { + struct xfile *f = &nv->f; + + read_file(); + + /* + regular operations post-read operate only on the first + 8KB, because each GbE part is the first 4KB of each + half of the file. + + we no longer care about anything past 8KB, until we get + to writing, at which point we will flush the buffer + again + */ + + if (f->gbe_file_size == SIZE_8KB) + return; + + x_v_memcpy(f->buf + (unsigned long)GBE_PART_SIZE, + f->buf + (unsigned long)(f->gbe_file_size >> 1), + (unsigned long)GBE_PART_SIZE); +} + +void +read_file(void) +{ long _r; struct stat _st; @@ -614,23 +639,6 @@ copy_gbe(void) if (x_i_memcmp(f->buf, f->bufcmp, f->gbe_file_size) != 0) err(errno, "%s: %s: read contents differ (pre-test)", f->fname, f->tname); - - /* - regular operations post-read operate only on the first - 8KB, because each GbE part is the first 4KB of each - half of the file. - - we no longer care about anything past 8KB, until we get - to writing, at which point we will flush the buffer - again - */ - - if (f->gbe_file_size == SIZE_8KB) - return; - - x_v_memcpy(f->buf + (unsigned long)GBE_PART_SIZE, - f->buf + (unsigned long)(f->gbe_file_size >> 1), - (unsigned long)GBE_PART_SIZE); } void |
