| 747 | } |
| 748 | |
| 749 | BOOLEAN |
| 750 | Ext2LoadBuffer( IN PEXT2_IRP_CONTEXT IrpContext, |
| 751 | IN PEXT2_VCB Vcb, |
| 752 | IN LONGLONG offset, |
| 753 | IN ULONG size, |
| 754 | IN PVOID buf ) |
| 755 | { |
| 756 | struct buffer_head *bh = NULL; |
| 757 | BOOLEAN rc; |
| 758 | |
| 759 | __try { |
| 760 | |
| 761 | while (size) { |
| 762 | |
| 763 | sector_t block; |
| 764 | ULONG len = 0, delta = 0; |
| 765 | |
| 766 | block = (sector_t) (offset >> BLOCK_BITS); |
| 767 | delta = (ULONG)offset & (BLOCK_SIZE - 1); |
| 768 | len = BLOCK_SIZE - delta; |
| 769 | if (size < len) |
| 770 | len = size; |
| 771 | |
| 772 | bh = sb_getblk(&Vcb->sb, block); |
| 773 | if (!bh) { |
| 774 | DEBUG(DL_ERR, ("Ext2SaveBuffer: can't load block %I64u\n", block)); |
| 775 | DbgBreak(); |
| 776 | __leave; |
| 777 | } |
| 778 | |
| 779 | if (!buffer_uptodate(bh)) { |
| 780 | int err = bh_submit_read(bh); |
| 781 | if (err < 0) { |
| 782 | DEBUG(DL_ERR, ("Ext2SaveBuffer: bh_submit_read failed: %d\n", err)); |
| 783 | __leave; |
| 784 | } |
| 785 | } |
| 786 | |
| 787 | __try { |
| 788 | RtlCopyMemory(buf, bh->b_data + delta, len); |
| 789 | } __finally { |
| 790 | fini_bh(&bh); |
| 791 | } |
| 792 | |
| 793 | buf = (PUCHAR)buf + len; |
| 794 | offset = offset + len; |
| 795 | size = size - len; |
| 796 | } |
| 797 | |
| 798 | rc = TRUE; |
| 799 | |
| 800 | } __finally { |
| 801 | |
| 802 | if (bh) |
| 803 | fini_bh(&bh); |
| 804 | |
| 805 | } |
| 806 |
no test coverage detected