mirror of
https://codeberg.org/libreboot/lbmk.git
synced 2026-07-17 08:40:14 +02:00
nvmutil: split pwrite handling from writeGbe
handle it in a separate function, for clarity. the main function just checks each part whether it changed, and then passes control to writeGbe_part. Signed-off-by: Leah Rowe <leah@libreboot.org>
This commit is contained in:
+12
-9
@@ -18,7 +18,7 @@ void cmd_setchecksum(void), cmd_brick(void), swap(int partnum), writeGbe(void),
|
|||||||
cmd_dump(void), cmd_setmac(void), nvmalloc(void), readGbe(void),
|
cmd_dump(void), cmd_setmac(void), nvmalloc(void), readGbe(void),
|
||||||
checkdir(const char *path), macf(int partnum), hexdump(int partnum),
|
checkdir(const char *path), macf(int partnum), hexdump(int partnum),
|
||||||
parseMacString(const char *strMac, uint16_t *mac), cmd_swap(void),
|
parseMacString(const char *strMac, uint16_t *mac), cmd_swap(void),
|
||||||
openFiles(const char *path), cmd_copy(void);
|
openFiles(const char *path), cmd_copy(void), writeGbe_part(int);
|
||||||
int goodChecksum(int partnum);
|
int goodChecksum(int partnum);
|
||||||
uint8_t hextonum(char chs), rhex(void);
|
uint8_t hextonum(char chs), rhex(void);
|
||||||
|
|
||||||
@@ -421,18 +421,21 @@ void
|
|||||||
writeGbe(void)
|
writeGbe(void)
|
||||||
{
|
{
|
||||||
for (int p = 0; p < 2; p++) {
|
for (int p = 0; p < 2; p++) {
|
||||||
if ((!nvmPartChanged[p]) || (flags == O_RDONLY))
|
if ((nvmPartChanged[p]) && (flags != O_RDONLY))
|
||||||
continue;
|
writeGbe_part(p);
|
||||||
|
|
||||||
swap(p); /* swap bytes on big-endian host CPUs */
|
|
||||||
if(pwrite(fd, (uint8_t *) gbe[p], nf, p * partsize) != nf)
|
|
||||||
err(ERR(), "Couldn't write %ld bytes to '%s' part '%d'",
|
|
||||||
nf, filename, p);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
err_if(close(fd) == -1);
|
err_if(close(fd) == -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
writeGbe_part(int p)
|
||||||
|
{
|
||||||
|
swap(p); /* swap bytes on big-endian host CPUs */
|
||||||
|
if(pwrite(fd, (uint8_t *) gbe[p], nf, p * partsize) != nf)
|
||||||
|
err(ERR(), "Can't write %ld b to '%s' p%d", nf, filename, p);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
swap(int partnum)
|
swap(int partnum)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user