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

Function Ext2ReadDisk

Ext4Fsd/block.c:538–585  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

536
537
538NTSTATUS
539Ext2ReadDisk(
540 IN PEXT2_VCB Vcb,
541 IN ULONGLONG Offset,
542 IN ULONG Size,
543 IN PVOID Buffer,
544 IN BOOLEAN bVerify )
545{
546 NTSTATUS Status;
547 PUCHAR Buf;
548 ULONG Length;
549 ULONGLONG Lba;
550
551 Lba = Offset & (~((ULONGLONG)SECTOR_SIZE - 1));
552 Length = (ULONG)(Size + Offset + SECTOR_SIZE - 1 - Lba) &
553 (~((ULONG)SECTOR_SIZE - 1));
554
555 Buf = Ext2AllocatePool(PagedPool, Length, EXT2_DATA_MAGIC);
556 if (!Buf) {
557 DEBUG(DL_ERR, ( "Ext2ReadDisk: failed to allocate Buffer.\n"));
558 Status = STATUS_INSUFFICIENT_RESOURCES;
559
560 goto errorout;
561 }
562 INC_MEM_COUNT(PS_DISK_BUFFER, Buf, Length);
563
564 Status = Ext2ReadSync( Vcb,
565 Lba,
566 Length,
567 Buf,
568 FALSE );
569
570 if (!NT_SUCCESS(Status)) {
571 DEBUG(DL_ERR, ("Ext2ReadDisk: disk i/o error: %xh.\n", Status));
572 goto errorout;
573 }
574
575 RtlCopyMemory(Buffer, &Buf[Offset - Lba], Size);
576
577errorout:
578
579 if (Buf) {
580 Ext2FreePool(Buf, EXT2_DATA_MAGIC);
581 DEC_MEM_COUNT(PS_DISK_BUFFER, Buf, Length);
582 }
583
584 return Status;
585}
586
587
588NTSTATUS

Callers 1

Ext2LoadSuperFunction · 0.85

Calls 3

Ext2AllocatePoolFunction · 0.85
Ext2ReadSyncFunction · 0.85
Ext2FreePoolFunction · 0.85

Tested by

no test coverage detected