mirror of
https://git.savannah.gnu.org/git/grub.git
synced 2026-10-21 06:49:35 +00:00
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:
1 parent
190d79e135
commit
f5a92e6040
9 files changed
+40
-31
No files matched your search
@@ -123,7 +123,7 @@ hfsplus_read_compressed_real (struct grub_hfsplus_file *node,
|
||||
{
|
||||
grub_memcpy (buf, node->cbuf + pos, len);
|
||||
if (grub_file_progress_hook && node->file)
|
||||
grub_file_progress_hook (0, 0, len, node->file);
|
||||
grub_file_progress_hook (0, 0, len, NULL, node->file);
|
||||
return len;
|
||||
}
|
||||
|
||||
@@ -170,7 +170,7 @@ hfsplus_read_compressed_real (struct grub_hfsplus_file *node,
|
||||
grub_memcpy (buf, node->cbuf + (pos % HFSPLUS_COMPRESS_BLOCK_SIZE),
|
||||
curlen);
|
||||
if (grub_file_progress_hook && node->file)
|
||||
grub_file_progress_hook (0, 0, curlen, node->file);
|
||||
grub_file_progress_hook (0, 0, curlen, NULL, node->file);
|
||||
buf += curlen;
|
||||
pos += curlen;
|
||||
len -= curlen;
|
||||
|
||||
@@ -227,7 +227,7 @@ read_block (struct grub_ntfs_rlst *ctx, grub_uint8_t *buf, grub_size_t num)
|
||||
grub_memset (buf, 0, nn * GRUB_NTFS_COM_LEN);
|
||||
buf += nn * GRUB_NTFS_COM_LEN;
|
||||
if (grub_file_progress_hook && ctx->file)
|
||||
grub_file_progress_hook (0, 0, nn * GRUB_NTFS_COM_LEN,
|
||||
grub_file_progress_hook (0, 0, nn * GRUB_NTFS_COM_LEN, NULL,
|
||||
ctx->file);
|
||||
}
|
||||
}
|
||||
@@ -240,7 +240,7 @@ read_block (struct grub_ntfs_rlst *ctx, grub_uint8_t *buf, grub_size_t num)
|
||||
if (buf)
|
||||
buf += GRUB_NTFS_COM_LEN;
|
||||
if (grub_file_progress_hook && ctx->file)
|
||||
grub_file_progress_hook (0, 0, GRUB_NTFS_COM_LEN,
|
||||
grub_file_progress_hook (0, 0, GRUB_NTFS_COM_LEN, NULL,
|
||||
ctx->file);
|
||||
nn--;
|
||||
}
|
||||
@@ -271,7 +271,7 @@ read_block (struct grub_ntfs_rlst *ctx, grub_uint8_t *buf, grub_size_t num)
|
||||
if (grub_file_progress_hook && ctx->file)
|
||||
grub_file_progress_hook (0, 0,
|
||||
tt << (ctx->comp.log_spc
|
||||
+ GRUB_NTFS_BLK_SHR),
|
||||
+ GRUB_NTFS_BLK_SHR), NULL,
|
||||
ctx->file);
|
||||
buf += tt << (ctx->comp.log_spc + GRUB_NTFS_BLK_SHR);
|
||||
}
|
||||
@@ -294,7 +294,7 @@ read_block (struct grub_ntfs_rlst *ctx, grub_uint8_t *buf, grub_size_t num)
|
||||
if (grub_file_progress_hook && ctx->file)
|
||||
grub_file_progress_hook (0, 0,
|
||||
nn << (ctx->comp.log_spc
|
||||
+ GRUB_NTFS_BLK_SHR),
|
||||
+ GRUB_NTFS_BLK_SHR), NULL,
|
||||
ctx->file);
|
||||
}
|
||||
ctx->target_vcn += nn;
|
||||
@@ -323,7 +323,7 @@ ntfscomp (grub_uint8_t *dest, grub_disk_addr_t ofs,
|
||||
|
||||
grub_memcpy (dest, ctx->attr->sbuf + ofs - ctx->attr->save_pos, n);
|
||||
if (grub_file_progress_hook && ctx->file)
|
||||
grub_file_progress_hook (0, 0, n, ctx->file);
|
||||
grub_file_progress_hook (0, 0, n, NULL, ctx->file);
|
||||
if (n == len)
|
||||
return 0;
|
||||
|
||||
@@ -390,7 +390,7 @@ ntfscomp (grub_uint8_t *dest, grub_disk_addr_t ofs,
|
||||
n = len;
|
||||
grub_memcpy (dest, &ctx->attr->sbuf[o], n);
|
||||
if (grub_file_progress_hook && ctx->file)
|
||||
grub_file_progress_hook (0, 0, n, ctx->file);
|
||||
grub_file_progress_hook (0, 0, n, NULL, ctx->file);
|
||||
if (n == len)
|
||||
goto quit;
|
||||
dest += n;
|
||||
@@ -422,7 +422,7 @@ ntfscomp (grub_uint8_t *dest, grub_disk_addr_t ofs,
|
||||
|
||||
grub_memcpy (dest, ctx->attr->sbuf, len);
|
||||
if (grub_file_progress_hook && file)
|
||||
grub_file_progress_hook (0, 0, len, file);
|
||||
grub_file_progress_hook (0, 0, len, NULL, file);
|
||||
}
|
||||
|
||||
quit:
|
||||
|
||||
Reference in new issue
Block a user