* grub-core/fs/hfspluscomp.c (hfsplus_read_compressed_real): Call

file_progress_read_hook.
	* grub-core/fs/ntfscomp.c (hfsplus_read_compressed_real): Likewise.
This commit is contained in:
Vladimir Serbinenko 2013-11-02 16:30:53 +01:00
parent 2855a0fcce
commit f169f65e75
7 changed files with 47 additions and 0 deletions

View file

@ -1,3 +1,9 @@
2013-11-02 Vladimir Serbinenko <phcoder@gmail.com>
* 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 <phcoder@gmail.com> 2013-11-02 Vladimir Serbinenko <phcoder@gmail.com>
* conf/Makefile.common (CFLAGS_PLATFORM): Remove poisoning of float * conf/Makefile.common (CFLAGS_PLATFORM): Remove poisoning of float

View file

@ -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 *data =
(struct grub_hfsplus_data *) file->data; (struct grub_hfsplus_data *) file->data;
data->opened_file.file = file;
if (grub_hfsplus_read_compressed && data->opened_file.compressed) if (grub_hfsplus_read_compressed && data->opened_file.compressed)
return grub_hfsplus_read_compressed (&data->opened_file, return grub_hfsplus_read_compressed (&data->opened_file,
file->offset, len, buf); file->offset, len, buf);

View file

@ -23,6 +23,7 @@
#include <grub/misc.h> #include <grub/misc.h>
#include <grub/mm.h> #include <grub/mm.h>
#include <grub/deflate.h> #include <grub/deflate.h>
#include <grub/file.h>
GRUB_MOD_LICENSE ("GPLv3+"); GRUB_MOD_LICENSE ("GPLv3+");
@ -121,6 +122,8 @@ hfsplus_read_compressed_real (struct grub_hfsplus_file *node,
if (node->compressed == 1) if (node->compressed == 1)
{ {
grub_memcpy (buf, node->cbuf + pos, len); 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; 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), grub_memcpy (buf, node->cbuf + (pos % HFSPLUS_COMPRESS_BLOCK_SIZE),
curlen); curlen);
if (grub_file_progress_hook && node->file)
grub_file_progress_hook (0, 0, curlen, node->file);
buf += curlen; buf += curlen;
pos += curlen; pos += curlen;
len -= curlen; len -= curlen;

View file

@ -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.log_spc = at->mft->data->log_spc;
ctx->comp.disk = at->mft->data->disk; ctx->comp.disk = at->mft->data->disk;
if (read_hook == grub_file_progress_hook)
ctx->file = read_hook_data;
if (pa[8] == 0) if (pa[8] == 0)
{ {
if (ofs + len > u32at (pa, 0x10)) if (ofs + len > u32at (pa, 0x10))

View file

@ -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); grub_memset (buf, 0, nn * GRUB_NTFS_COM_LEN);
buf += 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 else
@ -236,6 +239,9 @@ read_block (struct grub_ntfs_rlst *ctx, grub_uint8_t *buf, grub_size_t num)
return grub_errno; return grub_errno;
if (buf) if (buf)
buf += GRUB_NTFS_COM_LEN; 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--; 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, ctx->target_vcn)) << ctx->comp.log_spc, 0,
tt << (ctx->comp.log_spc + GRUB_NTFS_BLK_SHR), buf)) tt << (ctx->comp.log_spc + GRUB_NTFS_BLK_SHR), buf))
return grub_errno; 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); buf += tt << (ctx->comp.log_spc + GRUB_NTFS_BLK_SHR);
} }
nn -= tt; 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)) nn << (ctx->comp.log_spc + GRUB_NTFS_BLK_SHR), buf))
return grub_errno; return grub_errno;
buf += nn << (ctx->comp.log_spc + GRUB_NTFS_BLK_SHR); 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; ctx->target_vcn += nn;
} }
@ -306,6 +322,8 @@ ntfscomp (grub_uint8_t *dest, grub_disk_addr_t ofs,
n = len; n = len;
grub_memcpy (dest, ctx->attr->sbuf + ofs - ctx->attr->save_pos, n); 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) if (n == len)
return 0; return 0;
@ -351,6 +369,9 @@ ntfscomp (grub_uint8_t *dest, grub_disk_addr_t ofs,
if (ofs % GRUB_NTFS_COM_LEN) if (ofs % GRUB_NTFS_COM_LEN)
{ {
grub_uint32_t t, n, o; 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); t = ctx->target_vcn << (ctx->comp.log_spc + GRUB_NTFS_BLK_SHR);
if (read_block (ctx, ctx->attr->sbuf, 1)) if (read_block (ctx, ctx->attr->sbuf, 1))
@ -359,6 +380,8 @@ ntfscomp (grub_uint8_t *dest, grub_disk_addr_t ofs,
goto quit; goto quit;
} }
ctx->file = file;
ctx->attr->save_pos = t; ctx->attr->save_pos = t;
o = ofs % GRUB_NTFS_COM_LEN; o = ofs % GRUB_NTFS_COM_LEN;
@ -366,6 +389,8 @@ ntfscomp (grub_uint8_t *dest, grub_disk_addr_t ofs,
if (n > len) if (n > len)
n = len; n = len;
grub_memcpy (dest, &ctx->attr->sbuf[o], n); 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) if (n == len)
goto quit; goto quit;
dest += n; dest += n;
@ -383,7 +408,9 @@ ntfscomp (grub_uint8_t *dest, grub_disk_addr_t ofs,
if (len) if (len)
{ {
grub_uint32_t t; grub_uint32_t t;
void *file = ctx->file;
ctx->file = 0;
t = ctx->target_vcn << (ctx->comp.log_spc + GRUB_NTFS_BLK_SHR); t = ctx->target_vcn << (ctx->comp.log_spc + GRUB_NTFS_BLK_SHR);
if (read_block (ctx, ctx->attr->sbuf, 1)) 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; ctx->attr->save_pos = t;
grub_memcpy (dest, ctx->attr->sbuf, len); grub_memcpy (dest, ctx->attr->sbuf, len);
if (grub_file_progress_hook && file)
grub_file_progress_hook (0, 0, len, file);
} }
quit: quit:

View file

@ -56,6 +56,7 @@ struct grub_hfsplus_file
grub_int32_t mtime; grub_int32_t mtime;
int compressed; int compressed;
char *cbuf; char *cbuf;
void *file;
struct grub_hfsplus_compress_index *compress_index; struct grub_hfsplus_compress_index *compress_index;
grub_uint32_t cbuf_block; grub_uint32_t cbuf_block;
grub_uint32_t compress_index_size; grub_uint32_t compress_index_size;

View file

@ -183,6 +183,7 @@ struct grub_ntfs_rlst
grub_uint8_t *cur_run; grub_uint8_t *cur_run;
struct grub_ntfs_attr *attr; struct grub_ntfs_attr *attr;
struct grub_ntfs_comp comp; struct grub_ntfs_comp comp;
void *file;
}; };
typedef grub_err_t (*grub_ntfscomp_func_t) (grub_uint8_t *dest, typedef grub_err_t (*grub_ntfscomp_func_t) (grub_uint8_t *dest,