mirror of
https://codeberg.org/libreboot/lbmk.git
synced 2026-07-15 08:20:59 +02:00
util/nvmutil: tidy up prw()
Signed-off-by: Leah Rowe <leah@libreboot.org>
This commit is contained in:
@@ -1663,20 +1663,22 @@ prw(int fd, void *mem, size_t nrw,
|
|||||||
|| (unsigned int)prw_type > IO_WRITE)
|
|| (unsigned int)prw_type > IO_WRITE)
|
||||||
goto err_prw;
|
goto err_prw;
|
||||||
|
|
||||||
|
flags = fcntl(fd, F_GETFL);
|
||||||
|
if (flags == -1)
|
||||||
|
return -1;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* O_APPEND must not be used, because this
|
* O_APPEND must not be used, because this
|
||||||
* allows POSIX write() to ignore the
|
* allows POSIX write() to ignore the
|
||||||
* current write offset and write at EOF,
|
* current write offset and write at EOF,
|
||||||
* which would therefore break pread/pwrite
|
* which would therefore break pread/pwrite
|
||||||
*/
|
*/
|
||||||
flags = fcntl(fd, F_GETFL);
|
|
||||||
if (flags == -1)
|
|
||||||
return -1;
|
|
||||||
if (flags & O_APPEND)
|
if (flags & O_APPEND)
|
||||||
goto err_prw;
|
goto err_prw;
|
||||||
|
|
||||||
if ((off_orig = lseek_eintr(fd, (off_t)0, SEEK_CUR)) == (off_t)-1)
|
if ((off_orig = lseek_eintr(fd, (off_t)0, SEEK_CUR)) == (off_t)-1)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
if (lseek_eintr(fd, off, SEEK_SET) == (off_t)-1)
|
if (lseek_eintr(fd, off, SEEK_SET) == (off_t)-1)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
@@ -1688,6 +1690,7 @@ prw(int fd, void *mem, size_t nrw,
|
|||||||
if (lseek_eintr(fd, off_orig, SEEK_SET) == (off_t)-1) {
|
if (lseek_eintr(fd, off_orig, SEEK_SET) == (off_t)-1) {
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
errno = saved_errno;
|
errno = saved_errno;
|
||||||
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
errno = saved_errno;
|
errno = saved_errno;
|
||||||
|
|||||||
Reference in New Issue
Block a user