Modules/{ATA,LVM} - Slight API change because SCSI devices don't have a fixed block...
authorJohn Hodge <[email protected]>
Sat, 19 May 2012 13:49:07 +0000 (21:49 +0800)
committerJohn Hodge <[email protected]>
Sat, 19 May 2012 13:49:07 +0000 (21:49 +0800)
KernelLand/Modules/Storage/ATA/main.c
KernelLand/Modules/Storage/LVM/include/lvm.h
KernelLand/Modules/Storage/LVM/lvm_int.h
KernelLand/Modules/Storage/LVM/main.c
KernelLand/Modules/Storage/LVM/volumes.c

index 6737e44..7c1b3a8 100644 (file)
@@ -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
        {
index 3a9ef1b..5576e8e 100644 (file)
@@ -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
 
index bd07701..5ef812d 100644 (file)
@@ -30,6 +30,7 @@ struct sLVM_Vol
        void    *Ptr;
        const tLVM_VolType      *Type;
 
+       size_t  BlockSize;
        Uint64  BlockCount;
        
         int    nSubVolumes;
index d89604a..d6845e1 100644 (file)
@@ -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
                );
 }
 
index 3505498..fdac4fd 100644 (file)
@@ -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);

UCC git Repository :: git.ucc.asn.au