| 820 | } |
| 821 | |
| 822 | NTSTATUS |
| 823 | Ext2MapIndirect( |
| 824 | IN PEXT2_IRP_CONTEXT IrpContext, |
| 825 | IN PEXT2_VCB Vcb, |
| 826 | IN PEXT2_MCB Mcb, |
| 827 | IN ULONG Index, |
| 828 | IN BOOLEAN bAlloc, |
| 829 | OUT PULONG pBlock, |
| 830 | OUT PULONG Number |
| 831 | ) |
| 832 | { |
| 833 | ULONG Layer; |
| 834 | ULONG Slot; |
| 835 | |
| 836 | ULONG Base = Index; |
| 837 | |
| 838 | NTSTATUS Status = STATUS_SUCCESS; |
| 839 | |
| 840 | *pBlock = 0; |
| 841 | *Number = 0; |
| 842 | |
| 843 | for (Layer = 0; Layer < EXT2_BLOCK_TYPES; Layer++) { |
| 844 | |
| 845 | if (Index < Vcb->max_blocks_per_layer[Layer]) { |
| 846 | |
| 847 | ULONG dwRet = 0, dwBlk = 0, dwHint = 0, dwArray = 0; |
| 848 | |
| 849 | Slot = (Layer==0) ? (Index):(Layer + EXT2_NDIR_BLOCKS - 1); |
| 850 | dwBlk = Mcb->Inode.i_block[Slot]; |
| 851 | |
| 852 | if (dwBlk == 0) { |
| 853 | |
| 854 | if (!bAlloc) { |
| 855 | |
| 856 | *Number = 1; |
| 857 | goto errorout; |
| 858 | |
| 859 | } else { |
| 860 | |
| 861 | if (Slot) { |
| 862 | dwHint = Mcb->Inode.i_block[Slot - 1]; |
| 863 | } |
| 864 | |
| 865 | /* allocate and zero block if necessary */ |
| 866 | *Number = 1; |
| 867 | Status = Ext2ExpandLast( |
| 868 | IrpContext, |
| 869 | Vcb, |
| 870 | Mcb, |
| 871 | Base, |
| 872 | Layer, |
| 873 | NULL, |
| 874 | &dwHint, |
| 875 | &dwBlk, |
| 876 | Number |
| 877 | ); |
| 878 | |
| 879 | if (!NT_SUCCESS(Status)) { |
no test coverage detected