summaryrefslogtreecommitdiff
path: root/util/nvmutil/nvmutil.c
diff options
context:
space:
mode:
authorLeah Rowe <leah@libreboot.org>2026-03-14 00:40:00 +0000
committerLeah Rowe <leah@libreboot.org>2026-03-14 00:40:00 +0000
commitb89e965ed7ae731eda50cd1b035b540d6cdb4b45 (patch)
tree6f0c3f461733b41e1b2338fba03989fd08b36e6a /util/nvmutil/nvmutil.c
parent69ff774ad3a4823bc02fd4d34c97525a32fe7dd4 (diff)
util/nvmutil: tidy up prw()
Signed-off-by: Leah Rowe <leah@libreboot.org>
Diffstat (limited to 'util/nvmutil/nvmutil.c')
-rw-r--r--util/nvmutil/nvmutil.c19
1 files changed, 11 insertions, 8 deletions
diff --git a/util/nvmutil/nvmutil.c b/util/nvmutil/nvmutil.c
index 62c5ee2a..85b6d4ed 100644
--- a/util/nvmutil/nvmutil.c
+++ b/util/nvmutil/nvmutil.c
@@ -1681,7 +1681,7 @@ prw(int fd, void *mem, size_t nrw,
ssize_t r;
int saved_errno;
int flags;
- int positional_rw = 0;
+ int positional_rw;
if (mem == NULL)
goto err_prw;
@@ -1695,16 +1695,19 @@ prw(int fd, void *mem, size_t nrw,
r = -1;
-try_rw_again:
-
- if (rw_type == IO_WRITE)
- r = write(fd, mem, nrw);
- else if (rw_type == IO_READ)
- r = read(fd, mem, nrw);
+ if (rw_type >= IO_PREAD)
+ positional_rw = 1; /* pread/pwrite */
else
- positional_rw = 1;
+ positional_rw = 0; /* read/write */
+
+try_rw_again:
if (!positional_rw) {
+ if (rw_type == IO_WRITE)
+ r = write(fd, mem, nrw);
+ else if (rw_type == IO_READ)
+ r = read(fd, mem, nrw);
+
if (r == -1 && (errno == EINTR
|| errno == err_eagain(loop_eagain)))
goto try_rw_again;