mirror of
https://codeberg.org/libreboot/lbmk.git
synced 2026-07-11 05:52:36 +02:00
util/nvmutil: preserve errno during i/o
do not clobber errno yeah we're basically being libc now Signed-off-by: Leah Rowe <leah@libreboot.org>
This commit is contained in:
@@ -1372,6 +1372,7 @@ prw(int fd, void *mem, size_t count,
|
||||
{
|
||||
off_t old;
|
||||
ssize_t r;
|
||||
int saved_errno = 0;
|
||||
|
||||
if ((old = lseek_eintr(fd, (off_t)0, SEEK_CUR)) == (off_t)-1)
|
||||
return -1;
|
||||
@@ -1388,9 +1389,15 @@ prw(int fd, void *mem, size_t count,
|
||||
err(EIO, "%s: Invalid rw_type", path);
|
||||
} while (r < 0 && errno == EINTR);
|
||||
|
||||
if (r < 0)
|
||||
saved_errno = errno;
|
||||
|
||||
if (lseek_eintr(fd, old, SEEK_SET) == (off_t)-1)
|
||||
return -1;
|
||||
|
||||
if (r < 0)
|
||||
errno = saved_errno;
|
||||
|
||||
return r;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user