tLVM_VolType gATA_VolType = {
.Name = "ATA",
.Read = ATA_ReadRaw,
- .Write = ATA_WriteRaw,
- .BlockSize = 512,
+ .Write = ATA_WriteRaw
};
// === CODE ===
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
{
{
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
void *Ptr;
const tLVM_VolType *Type;
+ size_t BlockSize;
Uint64 BlockCount;
int nSubVolumes;
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;
return DrvUtil_ReadBlock(
Offset, Length, Buffer,
- LVM_int_DrvUtil_ReadBlock, vol->Type->BlockSize, vol
+ LVM_int_DrvUtil_ReadBlock, vol->BlockSize, vol
);
}
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;
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;
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
);
}
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;
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
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);
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);