mirror of
https://codeberg.org/libreboot/lbmk.git
synced 2026-03-25 13:29:03 +02:00
Compare commits
6 Commits
e4b8be5b0c
...
fbe2986a6e
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
fbe2986a6e | ||
|
|
847f63be87 | ||
|
|
62131ec093 | ||
|
|
ebac61df5e | ||
|
|
cbf409d6e1 | ||
|
|
2ecee50da8 |
@@ -1456,7 +1456,11 @@ rw_gbe_file_part(size_t p, int rw_type,
|
||||
|
||||
uint8_t *mem_offset;
|
||||
|
||||
if (rw_type == IO_WRITE || rw_type == IO_PWRITE)
|
||||
if (rw_type < IO_PREAD || rw_type > IO_PWRITE)
|
||||
err(errno, "%s: %s: part %lu: invalid rw_type, %d",
|
||||
fname, rw_type_str, (unsigned long)p, rw_type);
|
||||
|
||||
if (rw_type == IO_PWRITE)
|
||||
invert = 0;
|
||||
|
||||
/*
|
||||
@@ -1564,9 +1568,11 @@ rw_file_exact(int fd, uint8_t *mem, size_t len,
|
||||
return -1;
|
||||
}
|
||||
|
||||
for (rc = 0, rv = 0; rc < len; rc += (size_t)rv) {
|
||||
if ((rv = rw_file_once(fd, mem, len, off, rw_type, rc)) == -1)
|
||||
for (rc = 0, rv = 0; rc < len; ) {
|
||||
if ((rv = rw_file_once(fd, mem, len, off, rw_type, rc)) <= 0)
|
||||
return -1;
|
||||
|
||||
rc += (size_t)rv;
|
||||
}
|
||||
|
||||
return rc;
|
||||
@@ -1615,9 +1621,6 @@ static ssize_t
|
||||
do_rw(int fd, uint8_t *mem,
|
||||
size_t len, off_t off, int rw_type)
|
||||
{
|
||||
if ((unsigned int)rw_type > IO_PWRITE)
|
||||
goto err_do_rw;
|
||||
|
||||
if (rw_type == IO_READ)
|
||||
return read(fd, mem, len);
|
||||
|
||||
@@ -1627,7 +1630,6 @@ do_rw(int fd, uint8_t *mem,
|
||||
if (rw_type == IO_PREAD || rw_type == IO_PWRITE)
|
||||
return prw(fd, mem, len, off, rw_type);
|
||||
|
||||
err_do_rw:
|
||||
errno = EIO;
|
||||
return -1;
|
||||
}
|
||||
@@ -1648,8 +1650,11 @@ prw(int fd, void *mem, size_t nrw,
|
||||
off_t off_orig;
|
||||
ssize_t r;
|
||||
int saved_errno;
|
||||
int prw_type;
|
||||
|
||||
if ((unsigned int)(rw_type ^ IO_PREAD) > IO_WRITE) {
|
||||
prw_type = rw_type ^ IO_PREAD;
|
||||
|
||||
if ((unsigned int)prw_type > IO_WRITE) {
|
||||
errno = EIO;
|
||||
return -1;
|
||||
}
|
||||
@@ -1660,7 +1665,7 @@ prw(int fd, void *mem, size_t nrw,
|
||||
return -1;
|
||||
|
||||
do {
|
||||
r = do_rw(fd, mem, nrw, off, rw_type ^ IO_PREAD);
|
||||
r = do_rw(fd, mem, nrw, off, prw_type);
|
||||
} while (r < 0 && errno == EINTR);
|
||||
|
||||
saved_errno = errno;
|
||||
|
||||
Reference in New Issue
Block a user