mirror of
https://codeberg.org/libreboot/lbmk.git
synced 2026-07-11 05:52:36 +02:00
util/nvmutil: added a "cat" command
with this, you can read 16KB and 128KB files, and output them to stdout, but it outputs 8KB for example: ./nvmutil gbe128.bin > gbe8.bin now you have a 8KB file i could probably easily add cat16 and cat128 too. nvmutil reads two 4KB parts regardless of GbE file size (one from the first 4KB of each half of the file), so this was easy to implement. Signed-off-by: Leah Rowe <leah@libreboot.org>
This commit is contained in:
+21
-3
@@ -120,6 +120,7 @@ static void write_mac_part(size_t partnum);
|
||||
static void cmd_helper_dump(void);
|
||||
static void print_mac_from_nvm(size_t partnum);
|
||||
static void hexdump(size_t partnum);
|
||||
static void cmd_helper_cat(void);
|
||||
static void write_gbe_file(void);
|
||||
static void override_part_modified(void);
|
||||
static void set_checksum(size_t part);
|
||||
@@ -236,6 +237,7 @@ enum {
|
||||
CMD_SETMAC,
|
||||
CMD_SWAP,
|
||||
CMD_COPY,
|
||||
CMD_CAT
|
||||
};
|
||||
|
||||
/*
|
||||
@@ -316,6 +318,12 @@ static const struct commands command[] = {
|
||||
ARG_PART,
|
||||
CHECKSUM_READ, SKIP_CHECKSUM_WRITE,
|
||||
GBE_PART_SIZE },
|
||||
|
||||
{ CMD_CAT, "cat", cmd_helper_cat, ARGC_3,
|
||||
NO_INVERT, SET_MOD_OFF,
|
||||
ARG_NOPART,
|
||||
SKIP_CHECKSUM_READ, SKIP_CHECKSUM_WRITE,
|
||||
GBE_PART_SIZE },
|
||||
};
|
||||
|
||||
#define MAX_CMD_LEN 50
|
||||
@@ -694,9 +702,6 @@ read_gbe_file_part(size_t p)
|
||||
|
||||
if (rc != (ssize_t)gbe_rw_size)
|
||||
err(ECANCELED, "%s: Partial read from p%zu", fname, p);
|
||||
|
||||
printf("%s: Read %zu bytes from p%zu\n",
|
||||
fname, gbe_rw_size, p);
|
||||
}
|
||||
|
||||
static ssize_t
|
||||
@@ -1083,6 +1088,19 @@ hexdump(size_t partnum)
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
cmd_helper_cat(void)
|
||||
{
|
||||
size_t wc = 0;
|
||||
ssize_t w;
|
||||
|
||||
fflush(NULL);
|
||||
|
||||
for (wc = 0; wc < sizeof(buf); wc += w)
|
||||
if ((w = write(STDOUT_FILENO, buf + wc, sizeof(buf) - wc)) < 1)
|
||||
err(EIO, "%s: stdout", fname);
|
||||
}
|
||||
|
||||
static void
|
||||
write_gbe_file(void)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user