disk: Allow read hook callback to take read buffer to potentially modify it

It will be desirable in the future to allow having the read hook modify the
data passed back from a read function call on a disk or file. This adds that
infrastructure and has no impact on code flow for existing uses of the read
hook. Also changed is that now when the read hook callback is called it can
also indicate what error code should be sent back to the read caller.

Signed-off-by: Glenn Washburn <development@efficientek.com>
Reviewed-by: Patrick Steinhardt <ps@pks.im>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
This commit is contained in:
Glenn Washburn authored and Daniel Kiper committed 2022-07-04 14:43:25 +02:00
1 parent 190d79e135
commit f5a92e6040
9 files changed
+40 -31

No files matched your search

+6 -4
View File
@@ -53,9 +53,9 @@ print_blocklist (grub_disk_addr_t sector, unsigned num,
}
/* Helper for grub_cmd_blocklist. */
static void
static grub_err_t
read_blocklist (grub_disk_addr_t sector, unsigned offset, unsigned length,
void *data)
char *buf __attribute__ ((unused)), void *data)
{
struct blocklist_ctx *ctx = data;
@@ -70,7 +70,7 @@ read_blocklist (grub_disk_addr_t sector, unsigned offset, unsigned length,
}
if (!length)
return;
return GRUB_ERR_NONE;
print_blocklist (ctx->start_sector, ctx->num_sectors, 0, 0, ctx);
ctx->num_sectors = 0;
}
@@ -87,7 +87,7 @@ read_blocklist (grub_disk_addr_t sector, unsigned offset, unsigned length,
}
if (!length)
return;
return GRUB_ERR_NONE;
if (length & (GRUB_DISK_SECTOR_SIZE - 1))
{
@@ -103,6 +103,8 @@ read_blocklist (grub_disk_addr_t sector, unsigned offset, unsigned length,
ctx->start_sector = sector;
ctx->num_sectors = length >> GRUB_DISK_SECTOR_BITS;
}
return GRUB_ERR_NONE;
}
static grub_err_t