MCPcopy Create free account
hub / github.com/bobranten/Ext4Fsd / Ext2CheckSetBlock

Function Ext2CheckSetBlock

Ext4Fsd/memory.c:1839–1888  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1837}
1838
1839BOOLEAN
1840Ext2CheckSetBlock(PEXT2_IRP_CONTEXT IrpContext, PEXT2_VCB Vcb, LONGLONG Block)
1841{
1842 PEXT2_GROUP_DESC gd;
1843 struct buffer_head *gb = NULL;
1844 struct buffer_head *bh = NULL;
1845 ULONG group, dwBlk, Length;
1846 RTL_BITMAP bitmap;
1847 BOOLEAN bModified = FALSE;
1848
1849 group = (ULONG)(Block - EXT2_FIRST_DATA_BLOCK) / BLOCKS_PER_GROUP;
1850 dwBlk = (ULONG)(Block - EXT2_FIRST_DATA_BLOCK) % BLOCKS_PER_GROUP;
1851
1852 gd = ext4_get_group_desc(&Vcb->sb, group, &gb);
1853 if (!gd) {
1854 return FALSE;
1855 }
1856 bh = sb_getblk(&Vcb->sb, ext4_block_bitmap(&Vcb->sb, gd));
1857
1858 if (group == Vcb->sbi.s_groups_count - 1) {
1859 Length = (ULONG)(TOTAL_BLOCKS % BLOCKS_PER_GROUP);
1860
1861 /* s_blocks_count is integer multiple of s_blocks_per_group */
1862 if (Length == 0)
1863 Length = BLOCKS_PER_GROUP;
1864 } else {
1865 Length = BLOCKS_PER_GROUP;
1866 }
1867
1868 if (dwBlk >= Length) {
1869 fini_bh(&gb);
1870 fini_bh(&bh);
1871 return FALSE;
1872 }
1873
1874
1875 RtlInitializeBitMap(&bitmap, (PULONG)bh->b_data, Length);
1876
1877 if (RtlCheckBit(&bitmap, dwBlk) == 0) {
1878 DbgBreak();
1879 RtlSetBits(&bitmap, dwBlk, 1);
1880 bModified = TRUE;
1881 mark_buffer_dirty(bh);
1882 }
1883
1884 fini_bh(&gb);
1885 fini_bh(&bh);
1886
1887 return (!bModified);
1888}
1889
1890BOOLEAN
1891Ext2CheckBitmapConsistency(PEXT2_IRP_CONTEXT IrpContext, PEXT2_VCB Vcb)

Callers 1

Calls 5

ext4_get_group_descFunction · 0.85
sb_getblkFunction · 0.85
ext4_block_bitmapFunction · 0.85
fini_bhFunction · 0.85
mark_buffer_dirtyFunction · 0.85

Tested by

no test coverage detected