mirror of
https://codeberg.org/libreboot/lbmk.git
synced 2026-07-11 05:52:36 +02:00
util/nvmutil: split up copy_gbe
Signed-off-by: Leah Rowe <leah@libreboot.org>
This commit is contained in:
+25
-17
@@ -560,6 +560,31 @@ xopen(int *fd_ptr, const char *path, int flags, struct stat *st)
|
|||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
copy_gbe(void)
|
copy_gbe(void)
|
||||||
|
{
|
||||||
|
struct xfile *f = &nv->f;
|
||||||
|
|
||||||
|
read_file();
|
||||||
|
|
||||||
|
/*
|
||||||
|
regular operations post-read operate only on the first
|
||||||
|
8KB, because each GbE part is the first 4KB of each
|
||||||
|
half of the file.
|
||||||
|
|
||||||
|
we no longer care about anything past 8KB, until we get
|
||||||
|
to writing, at which point we will flush the buffer
|
||||||
|
again
|
||||||
|
*/
|
||||||
|
|
||||||
|
if (f->gbe_file_size == SIZE_8KB)
|
||||||
|
return;
|
||||||
|
|
||||||
|
x_v_memcpy(f->buf + (unsigned long)GBE_PART_SIZE,
|
||||||
|
f->buf + (unsigned long)(f->gbe_file_size >> 1),
|
||||||
|
(unsigned long)GBE_PART_SIZE);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
read_file(void)
|
||||||
{
|
{
|
||||||
long _r;
|
long _r;
|
||||||
struct stat _st;
|
struct stat _st;
|
||||||
@@ -614,23 +639,6 @@ copy_gbe(void)
|
|||||||
if (x_i_memcmp(f->buf, f->bufcmp, f->gbe_file_size) != 0)
|
if (x_i_memcmp(f->buf, f->bufcmp, f->gbe_file_size) != 0)
|
||||||
err(errno, "%s: %s: read contents differ (pre-test)",
|
err(errno, "%s: %s: read contents differ (pre-test)",
|
||||||
f->fname, f->tname);
|
f->fname, f->tname);
|
||||||
|
|
||||||
/*
|
|
||||||
regular operations post-read operate only on the first
|
|
||||||
8KB, because each GbE part is the first 4KB of each
|
|
||||||
half of the file.
|
|
||||||
|
|
||||||
we no longer care about anything past 8KB, until we get
|
|
||||||
to writing, at which point we will flush the buffer
|
|
||||||
again
|
|
||||||
*/
|
|
||||||
|
|
||||||
if (f->gbe_file_size == SIZE_8KB)
|
|
||||||
return;
|
|
||||||
|
|
||||||
x_v_memcpy(f->buf + (unsigned long)GBE_PART_SIZE,
|
|
||||||
f->buf + (unsigned long)(f->gbe_file_size >> 1),
|
|
||||||
(unsigned long)GBE_PART_SIZE);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|||||||
@@ -321,6 +321,7 @@ void xopen(int *fd, const char *path, int flags, struct stat *st);
|
|||||||
* After this, we can run commands.
|
* After this, we can run commands.
|
||||||
*/
|
*/
|
||||||
void copy_gbe(void);
|
void copy_gbe(void);
|
||||||
|
void read_file(void);
|
||||||
void read_checksums(void);
|
void read_checksums(void);
|
||||||
int good_checksum(unsigned long partnum);
|
int good_checksum(unsigned long partnum);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user