X-Git-Url: https://git.ucc.asn.au/?a=blobdiff_plain;f=KernelLand%2FModules%2FStorage%2FLVM%2Fvolumes.c;h=cf1a60d16307e9f1932440438d0f076fd71a241f;hb=015f48988e0ff398409d71dfc692005ab439490a;hp=fdac4fd578716a9a9490a7990091495cca5649f5;hpb=54f893f1c1091d5f0bef8458585300e44beb7e81;p=tpg%2Facess2.git diff --git a/KernelLand/Modules/Storage/LVM/volumes.c b/KernelLand/Modules/Storage/LVM/volumes.c index fdac4fd5..cf1a60d1 100644 --- a/KernelLand/Modules/Storage/LVM/volumes.c +++ b/KernelLand/Modules/Storage/LVM/volumes.c @@ -30,6 +30,12 @@ int LVM_AddVolume(const tLVM_VolType *Type, const char *Name, void *Ptr, size_t tLVM_Format *fmt; void *first_block; + if( BlockCount == 0 || BlockSize == 0 ) { + Log_Error("LVM", "BlockSize(0x%x)/BlockCount(0x%x) invalid in LVM_AddVolume", + BlockSize, BlockCount); + return 1; + } + dummy_vol.Type = Type; dummy_vol.Ptr = Ptr; dummy_vol.BlockCount = BlockCount; @@ -37,6 +43,10 @@ int LVM_AddVolume(const tLVM_VolType *Type, const char *Name, void *Ptr, size_t // Read the first block of the volume first_block = malloc(BlockSize); + if( !first_block ) { + Log_Error("VLM", "LVM_AddVolume - malloc error on %i bytes", BlockSize); + return -1; + } Type->Read(Ptr, 0, 1, first_block); // Determine Format @@ -49,11 +59,14 @@ int LVM_AddVolume(const tLVM_VolType *Type, const char *Name, void *Ptr, size_t // Create real volume descriptor // TODO: If this needs to be rescanned later, having the subvolume list separate might be an idea real_vol = malloc( sizeof(tLVM_Vol) + strlen(Name) + 1 + sizeof(tLVM_SubVolume*) * dummy_vol.nSubVolumes ); + real_vol->Next = NULL; real_vol->Type = Type; real_vol->Ptr = Ptr; + real_vol->BlockSize = BlockSize; real_vol->BlockCount = BlockCount; real_vol->nSubVolumes = dummy_vol.nSubVolumes; real_vol->SubVolumes = (void*)( real_vol->Name + strlen(Name) + 1 ); + real_vol->BlockSize = BlockSize; strcpy(real_vol->Name, Name); memset(real_vol->SubVolumes, 0, sizeof(tLVM_SubVolume*) * real_vol->nSubVolumes); // - VFS Nodes