diff options
| author | Leah Rowe <leah@libreboot.org> | 2026-03-10 15:12:12 +0000 |
|---|---|---|
| committer | Leah Rowe <leah@libreboot.org> | 2026-03-10 15:12:12 +0000 |
| commit | 1f953359cb382e611ad22e139c753747895acb54 (patch) | |
| tree | 89edb2e710cf58808213e7e91070d5403899e59b /util/nvmutil/nvmutil.c | |
| parent | b291bbf2e51623add6f4d325985d626f115fe737 (diff) | |
util/nvmutil: re-try /dev/[u]random on EAGAIN
Signed-off-by: Leah Rowe <leah@libreboot.org>
Diffstat (limited to 'util/nvmutil/nvmutil.c')
| -rw-r--r-- | util/nvmutil/nvmutil.c | 22 |
1 files changed, 20 insertions, 2 deletions
diff --git a/util/nvmutil/nvmutil.c b/util/nvmutil/nvmutil.c index d04280d2..a0c990b5 100644 --- a/util/nvmutil/nvmutil.c +++ b/util/nvmutil/nvmutil.c @@ -1121,8 +1121,26 @@ cmd_helper_cat(void) static void gbe_cat_buf(uint8_t *b) { - if (rw_file_exact(STDOUT_FILENO, b, GBE_PART_SIZE, 0, SCHREIB) == -1) - err(errno, "cat"); + ssize_t rval; + + while (1) { + rval = rw_file_exact(STDOUT_FILENO, b, + GBE_PART_SIZE, 0, SCHREIB); + + if (rval == -1) { + if (errno == EAGAIN) { + errno = 0; + continue; + } + + err(errno, "%s: cat", rname); + } + + if ((size_t)rval != GBE_PART_SIZE) + err(errno, "%s: Partial read", rname); + + break; + } } static void |
