From 1f953359cb382e611ad22e139c753747895acb54 Mon Sep 17 00:00:00 2001 From: Leah Rowe Date: Tue, 10 Mar 2026 15:12:12 +0000 Subject: util/nvmutil: re-try /dev/[u]random on EAGAIN Signed-off-by: Leah Rowe --- util/nvmutil/nvmutil.c | 22 ++++++++++++++++++++-- 1 file 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 -- cgit v1.2.1