2 * Acess2 Logical Volume Manager
3 * - By John Hodge (thePowersGang)
13 // --------------------------------------------------------------------
14 // Managment / Initialisation
15 // --------------------------------------------------------------------
16 int LVM_AddVolume(const char *Name, int FD)
18 // Make dummy volume descriptor (for the read code)
22 // Type->CountSubvolumes
24 // Create real volume descriptor
26 // Type->PopulateSubvolumes
33 void LVM_int_SetSubvolume_Anon(tLVM_Vol *Volume, int Index, Uint64 FirstBlock, Uint64 BlockCount)
38 if( Index < 0 || Index >= Volume->nSubVolumes ) {
39 Log_Warning("LVM", "SV ID is out of range (0 < %i < %i)",
40 Index, Volume->nSubVolumes);
44 if( Volume->SubVolumes[Index] ) {
45 Log_Warning("LVM", "Attempt to set SV %i of %p twice", Index, Volume);
49 namelen = snprintf(NULL, 0, "%i", Index);
51 sv = malloc( sizeof(tLVM_SubVolume) + namelen + 1 );
56 Volume->SubVolumes[Index] = sv;
59 sprintf(sv->Name, "%i", Index);
60 sv->FirstBlock = FirstBlock;
61 sv->BlockCount = BlockCount;
62 memset(&sv->Node, 0, sizeof(tVFS_Node));
64 sv->Node.ImplPtr = sv;
65 sv->Node.Type = &gLVM_SubVolNodeType;
68 // --------------------------------------------------------------------
70 // --------------------------------------------------------------------
71 size_t LVM_int_ReadVolume(tLVM_Vol *Volume, Uint64 BlockNum, size_t BlockCount, void *Dest)
75 Volume->BackingDescriptor,
76 BlockNum * Volume->BlockSize,
77 BlockCount * Volume->BlockSize,
80 return rv / Volume->BlockSize;
83 size_t LVM_int_WriteVolume(tLVM_Vol *Volume, Uint64 BlockNum, size_t BlockCount, const void *Src)
87 Volume->BackingDescriptor,
88 BlockNum * Volume->BlockSize,
89 BlockCount * Volume->BlockSize,
92 return rv / Volume->BlockSize;