diff --git a/ChangeLog b/ChangeLog index 7f879adac..f48ffefa4 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2013-11-02 Vladimir Serbinenko + + * grub-core/fs/hfspluscomp.c (hfsplus_read_compressed_real): Call + file_progress_read_hook. + * grub-core/fs/ntfscomp.c (hfsplus_read_compressed_real): Likewise. + 2013-11-02 Vladimir Serbinenko * conf/Makefile.common (CFLAGS_PLATFORM): Remove poisoning of float diff --git a/grub-core/fs/hfsplus.c b/grub-core/fs/hfsplus.c index 790562450..a119c7ace 100644 --- a/grub-core/fs/hfsplus.c +++ b/grub-core/fs/hfsplus.c @@ -888,6 +888,8 @@ grub_hfsplus_read (grub_file_t file, char *buf, grub_size_t len) struct grub_hfsplus_data *data = (struct grub_hfsplus_data *) file->data; + data->opened_file.file = file; + if (grub_hfsplus_read_compressed && data->opened_file.compressed) return grub_hfsplus_read_compressed (&data->opened_file, file->offset, len, buf); diff --git a/grub-core/fs/hfspluscomp.c b/grub-core/fs/hfspluscomp.c index 13e4671e6..59cb8cbc0 100644 --- a/grub-core/fs/hfspluscomp.c +++ b/grub-core/fs/hfspluscomp.c @@ -23,6 +23,7 @@ #include #include #include +#include GRUB_MOD_LICENSE ("GPLv3+"); @@ -121,6 +122,8 @@ hfsplus_read_compressed_real (struct grub_hfsplus_file *node, if (node->compressed == 1) { grub_memcpy (buf, node->cbuf + pos, len); + if (grub_file_progress_hook && node->file) + grub_file_progress_hook (0, 0, len, node->file); return len; } @@ -162,6 +165,8 @@ 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); buf += curlen; pos += curlen; len -= curlen; diff --git a/grub-core/fs/ntfs.c b/grub-core/fs/ntfs.c index a0ae44200..83ba5698c 100644 --- a/grub-core/fs/ntfs.c +++ b/grub-core/fs/ntfs.c @@ -378,6 +378,9 @@ read_data (struct grub_ntfs_attr *at, grub_uint8_t *pa, grub_uint8_t *dest, ctx->comp.log_spc = at->mft->data->log_spc; ctx->comp.disk = at->mft->data->disk; + if (read_hook == grub_file_progress_hook) + ctx->file = read_hook_data; + if (pa[8] == 0) { if (ofs + len > u32at (pa, 0x10)) diff --git a/grub-core/fs/ntfscomp.c b/grub-core/fs/ntfscomp.c index c1d2d30cb..2e1ce51a8 100644 --- a/grub-core/fs/ntfscomp.c +++ b/grub-core/fs/ntfscomp.c @@ -226,6 +226,9 @@ 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, + ctx->file); } } else @@ -236,6 +239,9 @@ read_block (struct grub_ntfs_rlst *ctx, grub_uint8_t *buf, grub_size_t num) return grub_errno; if (buf) buf += GRUB_NTFS_COM_LEN; + if (grub_file_progress_hook && ctx->file) + grub_file_progress_hook (0, 0, GRUB_NTFS_COM_LEN, + ctx->file); nn--; } } @@ -262,6 +268,11 @@ read_block (struct grub_ntfs_rlst *ctx, grub_uint8_t *buf, grub_size_t num) ctx->target_vcn)) << ctx->comp.log_spc, 0, tt << (ctx->comp.log_spc + GRUB_NTFS_BLK_SHR), buf)) return grub_errno; + if (grub_file_progress_hook && ctx->file) + grub_file_progress_hook (0, 0, + tt << (ctx->comp.log_spc + + GRUB_NTFS_BLK_SHR), + ctx->file); buf += tt << (ctx->comp.log_spc + GRUB_NTFS_BLK_SHR); } nn -= tt; @@ -280,6 +291,11 @@ read_block (struct grub_ntfs_rlst *ctx, grub_uint8_t *buf, grub_size_t num) nn << (ctx->comp.log_spc + GRUB_NTFS_BLK_SHR), buf)) return grub_errno; buf += nn << (ctx->comp.log_spc + GRUB_NTFS_BLK_SHR); + if (grub_file_progress_hook && ctx->file) + grub_file_progress_hook (0, 0, + nn << (ctx->comp.log_spc + + GRUB_NTFS_BLK_SHR), + ctx->file); } ctx->target_vcn += nn; } @@ -306,6 +322,8 @@ ntfscomp (grub_uint8_t *dest, grub_disk_addr_t ofs, n = len; 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); if (n == len) return 0; @@ -351,6 +369,9 @@ ntfscomp (grub_uint8_t *dest, grub_disk_addr_t ofs, if (ofs % GRUB_NTFS_COM_LEN) { grub_uint32_t t, n, o; + void *file = ctx->file; + + ctx->file = 0; t = ctx->target_vcn << (ctx->comp.log_spc + GRUB_NTFS_BLK_SHR); if (read_block (ctx, ctx->attr->sbuf, 1)) @@ -359,6 +380,8 @@ ntfscomp (grub_uint8_t *dest, grub_disk_addr_t ofs, goto quit; } + ctx->file = file; + ctx->attr->save_pos = t; o = ofs % GRUB_NTFS_COM_LEN; @@ -366,6 +389,8 @@ ntfscomp (grub_uint8_t *dest, grub_disk_addr_t ofs, if (n > len) 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); if (n == len) goto quit; dest += n; @@ -383,7 +408,9 @@ ntfscomp (grub_uint8_t *dest, grub_disk_addr_t ofs, if (len) { grub_uint32_t t; + void *file = ctx->file; + ctx->file = 0; t = ctx->target_vcn << (ctx->comp.log_spc + GRUB_NTFS_BLK_SHR); if (read_block (ctx, ctx->attr->sbuf, 1)) { @@ -394,6 +421,8 @@ ntfscomp (grub_uint8_t *dest, grub_disk_addr_t ofs, ctx->attr->save_pos = t; grub_memcpy (dest, ctx->attr->sbuf, len); + if (grub_file_progress_hook && file) + grub_file_progress_hook (0, 0, len, file); } quit: diff --git a/include/grub/hfsplus.h b/include/grub/hfsplus.h index 0defd35b3..842554e04 100644 --- a/include/grub/hfsplus.h +++ b/include/grub/hfsplus.h @@ -56,6 +56,7 @@ struct grub_hfsplus_file grub_int32_t mtime; int compressed; char *cbuf; + void *file; struct grub_hfsplus_compress_index *compress_index; grub_uint32_t cbuf_block; grub_uint32_t compress_index_size; diff --git a/include/grub/ntfs.h b/include/grub/ntfs.h index 0ae3defdf..af3f4b05d 100644 --- a/include/grub/ntfs.h +++ b/include/grub/ntfs.h @@ -183,6 +183,7 @@ struct grub_ntfs_rlst grub_uint8_t *cur_run; struct grub_ntfs_attr *attr; struct grub_ntfs_comp comp; + void *file; }; typedef grub_err_t (*grub_ntfscomp_func_t) (grub_uint8_t *dest,