mirror of
https://codeberg.org/libreboot/lbmk.git
synced 2026-07-17 08:40:14 +02:00
util/nvmutil: re-use do_rw() from prw()
using a special leah-only technique Signed-off-by: Leah Rowe <leah@libreboot.org>
This commit is contained in:
+5
-12
@@ -609,8 +609,8 @@ sanitize_command_index(size_t c)
|
|||||||
command[c].flags != O_RDWR)
|
command[c].flags != O_RDWR)
|
||||||
err(EINVAL, "invalid cmd.flags setting");
|
err(EINVAL, "invalid cmd.flags setting");
|
||||||
|
|
||||||
if (!((PLESEN > LESEN) && (SCHREIB > PLESEN) && (PSCHREIB > SCHREIB)))
|
if (!((!LESEN) && (PLESEN == 1) && (SCHREIB == 2) && (PSCHREIB == 3)))
|
||||||
err(EINVAL, "some rw type integers are the same");
|
err(EINVAL, "rw type integers are the wrong values");
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@@ -1440,10 +1440,10 @@ static ssize_t
|
|||||||
do_rw(int fd, uint8_t *mem,
|
do_rw(int fd, uint8_t *mem,
|
||||||
size_t len, off_t off, int rw_type)
|
size_t len, off_t off, int rw_type)
|
||||||
{
|
{
|
||||||
if (rw_type == LESEN)
|
if (rw_type == LESEN || rw_type == PLESEN << 2)
|
||||||
return read(fd, mem, len);
|
return read(fd, mem, len);
|
||||||
|
|
||||||
if (rw_type == SCHREIB)
|
if (rw_type == SCHREIB || rw_type == PSCHREIB << 2)
|
||||||
return write(fd, mem, len);
|
return write(fd, mem, len);
|
||||||
|
|
||||||
if (rw_type == PLESEN || rw_type == PSCHREIB)
|
if (rw_type == PLESEN || rw_type == PSCHREIB)
|
||||||
@@ -1476,14 +1476,7 @@ prw(int fd, void *mem, size_t nrw,
|
|||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
do {
|
do {
|
||||||
if (rw_type == PLESEN)
|
r = do_rw(fd, mem, nrw, off, rw_type << 2);
|
||||||
r = read(fd, mem, nrw);
|
|
||||||
else if (rw_type == PSCHREIB)
|
|
||||||
r = write(fd, mem, nrw);
|
|
||||||
else {
|
|
||||||
set_err_if_unset(EINVAL);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
} while (r < 0 && errno == EINTR);
|
} while (r < 0 && errno == EINTR);
|
||||||
|
|
||||||
saved_errno = errno;
|
saved_errno = errno;
|
||||||
|
|||||||
Reference in New Issue
Block a user