From: John Hodge Date: Sat, 19 May 2012 13:49:07 +0000 (+0800) Subject: Modules/{ATA,LVM} - Slight API change because SCSI devices don't have a fixed block... X-Git-Tag: rel0.15~611^2~93 X-Git-Url: https://git.ucc.asn.au/?a=commitdiff_plain;h=54f893f1c1091d5f0bef8458585300e44beb7e81;p=tpg%2Facess2.git Modules/{ATA,LVM} - Slight API change because SCSI devices don't have a fixed block size --- diff --git a/KernelLand/Modules/Storage/ATA/main.c b/KernelLand/Modules/Storage/ATA/main.c index 6737e447..7c1b3a86 100644 --- a/KernelLand/Modules/Storage/ATA/main.c +++ b/KernelLand/Modules/Storage/ATA/main.c @@ -32,8 +32,7 @@ MODULE_DEFINE(0, VERSION, i386ATA, ATA_Install, NULL, "PCI", "LVM", NULL); tLVM_VolType gATA_VolType = { .Name = "ATA", .Read = ATA_ReadRaw, - .Write = ATA_WriteRaw, - .BlockSize = 512, + .Write = ATA_WriteRaw }; // === CODE === @@ -106,7 +105,7 @@ int ATA_ScanDisk(int Disk) char name[] = "ata0"; sprintf(name, "ata%i", Disk); - LVM_AddVolume(&gATA_VolType, name, (void*)(Uint*)Disk, sector_count); + LVM_AddVolume(&gATA_VolType, name, (void*)(Uint*)Disk, 512, sector_count); #if DEBUG >= 2 { diff --git a/KernelLand/Modules/Storage/LVM/include/lvm.h b/KernelLand/Modules/Storage/LVM/include/lvm.h index 3a9ef1b1..5576e8ee 100644 --- a/KernelLand/Modules/Storage/LVM/include/lvm.h +++ b/KernelLand/Modules/Storage/LVM/include/lvm.h @@ -16,14 +16,12 @@ struct sLVM_VolType { const char *Name; - size_t BlockSize; - int (*Read)(void *, Uint64, size_t, void *); int (*Write)(void *, Uint64, size_t, const void *); }; -extern int LVM_AddVolume(const tLVM_VolType *Type, const char *Name, void *Ptr, size_t BlockCount); +extern int LVM_AddVolume(const tLVM_VolType *Type, const char *Name, void *Ptr, size_t BlockSize, size_t BlockCount); #endif diff --git a/KernelLand/Modules/Storage/LVM/lvm_int.h b/KernelLand/Modules/Storage/LVM/lvm_int.h index bd077019..5ef812d6 100644 --- a/KernelLand/Modules/Storage/LVM/lvm_int.h +++ b/KernelLand/Modules/Storage/LVM/lvm_int.h @@ -30,6 +30,7 @@ struct sLVM_Vol void *Ptr; const tLVM_VolType *Type; + size_t BlockSize; Uint64 BlockCount; int nSubVolumes; diff --git a/KernelLand/Modules/Storage/LVM/main.c b/KernelLand/Modules/Storage/LVM/main.c index d89604a7..d6845e19 100644 --- a/KernelLand/Modules/Storage/LVM/main.c +++ b/KernelLand/Modules/Storage/LVM/main.c @@ -127,7 +127,7 @@ tVFS_Node *LVM_Vol_FindDir(tVFS_Node *Node, const char *Name) size_t LVM_Vol_Read(tVFS_Node *Node, off_t Offset, size_t Length, void *Buffer) { tLVM_Vol *vol = Node->ImplPtr; - Uint64 byte_size = vol->BlockCount * vol->Type->BlockSize; + Uint64 byte_size = vol->BlockCount * vol->BlockSize; if( Offset > byte_size ) return 0; @@ -138,7 +138,7 @@ size_t LVM_Vol_Read(tVFS_Node *Node, off_t Offset, size_t Length, void *Buffer) return DrvUtil_ReadBlock( Offset, Length, Buffer, - LVM_int_DrvUtil_ReadBlock, vol->Type->BlockSize, vol + LVM_int_DrvUtil_ReadBlock, vol->BlockSize, vol ); } @@ -150,7 +150,7 @@ size_t LVM_Vol_Write(tVFS_Node *Node, off_t Offset, size_t Length, const void *B size_t LVM_SubVol_Read(tVFS_Node *Node, off_t Offset, size_t Length, void *Buffer) { tLVM_SubVolume *sv = Node->ImplPtr; - Uint64 byte_size = sv->BlockCount * sv->Vol->Type->BlockSize; + Uint64 byte_size = sv->BlockCount * sv->Vol->BlockSize; if( Offset > byte_size ) return 0; @@ -160,21 +160,21 @@ size_t LVM_SubVol_Read(tVFS_Node *Node, off_t Offset, size_t Length, void *Buffe Length = byte_size - Offset; LOG("Reading (0x%llx+0x%llx)+0x%x to %p", - (Uint64)(sv->FirstBlock * sv->Vol->Type->BlockSize), Offset, + (Uint64)(sv->FirstBlock * sv->Vol->BlockSize), Offset, Length, Buffer ); - Offset += sv->FirstBlock * sv->Vol->Type->BlockSize; + Offset += sv->FirstBlock * sv->Vol->BlockSize; return DrvUtil_ReadBlock( Offset, Length, Buffer, - LVM_int_DrvUtil_ReadBlock, sv->Vol->Type->BlockSize, sv->Vol + LVM_int_DrvUtil_ReadBlock, sv->Vol->BlockSize, sv->Vol ); } size_t LVM_SubVol_Write(tVFS_Node *Node, off_t Offset, size_t Length, const void *Buffer) { tLVM_SubVolume *sv = Node->ImplPtr; - Uint64 byte_size = sv->BlockCount * sv->Vol->Type->BlockSize; + Uint64 byte_size = sv->BlockCount * sv->Vol->BlockSize; if( Offset > byte_size ) return 0; @@ -183,12 +183,12 @@ size_t LVM_SubVol_Write(tVFS_Node *Node, off_t Offset, size_t Length, const void if( Offset + Length > byte_size ) Length = byte_size - Offset; - Offset += sv->FirstBlock * sv->Vol->Type->BlockSize; + Offset += sv->FirstBlock * sv->Vol->BlockSize; return DrvUtil_WriteBlock( Offset, Length, Buffer, LVM_int_DrvUtil_ReadBlock, LVM_int_DrvUtil_WriteBlock, - sv->Vol->Type->BlockSize, sv->Vol + sv->Vol->BlockSize, sv->Vol ); } diff --git a/KernelLand/Modules/Storage/LVM/volumes.c b/KernelLand/Modules/Storage/LVM/volumes.c index 35054987..fdac4fd5 100644 --- a/KernelLand/Modules/Storage/LVM/volumes.c +++ b/KernelLand/Modules/Storage/LVM/volumes.c @@ -23,7 +23,7 @@ int LVM_AddVolumeVFS(const char *Name, int FD) return 0; } -int LVM_AddVolume(const tLVM_VolType *Type, const char *Name, void *Ptr, size_t BlockCount) +int LVM_AddVolume(const tLVM_VolType *Type, const char *Name, void *Ptr, size_t BlockSize, size_t BlockCount) { tLVM_Vol dummy_vol; tLVM_Vol *real_vol; @@ -33,13 +33,11 @@ int LVM_AddVolume(const tLVM_VolType *Type, const char *Name, void *Ptr, size_t dummy_vol.Type = Type; dummy_vol.Ptr = Ptr; dummy_vol.BlockCount = BlockCount; + dummy_vol.BlockSize = BlockSize; // Read the first block of the volume - LOG("Type->BlockSize = %i", Type->BlockSize); - first_block = malloc(Type->BlockSize); - LOG("first_block = %p", first_block); + first_block = malloc(BlockSize); Type->Read(Ptr, 0, 1, first_block); - LOG("first block read"); // Determine Format // TODO: Determine format @@ -67,7 +65,7 @@ int LVM_AddVolume(const tLVM_VolType *Type, const char *Name, void *Ptr, size_t memset(&real_vol->VolNode, 0, sizeof(tVFS_Node)); real_vol->VolNode.Type = &gLVM_VolNodeType; real_vol->VolNode.ImplPtr = real_vol; - real_vol->VolNode.Size = BlockCount * Type->BlockSize; + real_vol->VolNode.Size = BlockCount * BlockSize; // Type->PopulateSubvolumes fmt->PopulateSubvolumes(real_vol, first_block); @@ -113,7 +111,7 @@ void LVM_int_SetSubvolume_Anon(tLVM_Vol *Volume, int Index, Uint64 FirstBlock, U sv->Node.ImplPtr = sv; sv->Node.Type = &gLVM_SubVolNodeType; - sv->Node.Size = BlockCount * Volume->Type->BlockSize; + sv->Node.Size = BlockCount * Volume->BlockSize; Log_Log("LVM", "Partition %s/%s - 0x%llx+0x%llx blocks", Volume->Name, sv->Name, FirstBlock, BlockCount);