Esempio n. 1
0
File: EBR.cs Progetto: radtek/BackO
 internal EBRPartition(IBMPartitionInformation info, EBR ebr)
 {
     Ebr    = ebr;
     Start  = info.StartLBA;
     Length = info.LengthLBA;
     //Identifier = info.PartitionType;
     blockDev = ebr.blockdevice;
 }
Esempio n. 2
0
        internal static List <Partition> GetExtendedPartitions(Partition element, ulong offset, int iterNb)
        {
            List <Partition> extParts = new List <Partition>();

            byte[] ebrData = new byte[512];
            //Console.WriteLine ("     GetExtendedPartitions(iter="+iterNb+") 1: will try to read EBR from "+element.Path+" at offset" +(element.Offset*512));
            ulong currentDiskOffset;

            /*if(firstStart)
             *      currentDiskOffset =( (element.Offset) + offset);
             * else
             *      currentDiskOffset = offset - element.Offset;*/
            //element.BlockStream.Seek((long)offset*512, SeekOrigin.Begin);
            element.BlockStream.Seek((long)element.Offset * 512, SeekOrigin.Begin);
            element.BlockStream.Read(ebrData, 0, 512);
            //Console.WriteLine ("     GetExtendedPartitions() 2: Read done");

            EBR ebr = new EBR(ebrData);
            //Console.WriteLine ("     GetExtendedPartitions() : found extended part EBR ");

            Partition extPart = new Partition();

            //extPart.Offset = ebr.Partitions[0].StartLBA+currentDiskOffset;
            extPart.Offset = ebr.Partitions[0].StartLBA;

            //if(iterNb==0){
            extPart.Offset += element.Offset;

            //}
            //if(iterNb == 1)
            //extPart.Offset += element.Offset;
            // note offset for relative EBRs
            //offset = extPart.Offset;
            extPart.Size        = ebr.Partitions[0].LengthLBA;
            extPart.Type        = ebr.Partitions[0].PartitionType;
            extPart.Schema      = PartitionSchemes.Extended;
            extPart.BlockStream = element.BlockStream;
            extParts.Add(extPart);
            Console.WriteLine(" ########## raw extpart = " + extPart.ToString());

            Partition truc = new Partition();

            truc.Offset = ebr.Partitions[1].StartLBA /*-element.Offset*/;
            if (iterNb == 0)
            {
                truc.Offset += element.Offset;
            }

            else if (iterNb >= 1)
            {
                truc.Offset += offset;
            }

            truc.Size        = ebr.Partitions[1].LengthLBA;
            truc.BlockStream = element.BlockStream;
            Console.WriteLine(" ########## raw nextEbr = " + truc.ToString());


            if (ebr.Partitions[1].StartLBA > 0 && truc.Offset > extPart.Offset)
            {
                //Console.WriteLine ("    *     GetExtendedPartitions()² 3:pointer to next EBR : "+ebr.Partitions[1].StartLBA*512);
                //Console.WriteLine ("    *     GetExtendedPartitions()² 4: found extended part EBR for ext part "+extPart.Offset);
                //extParts.AddRange(GetExtendedPartitions(truc, currentDiskOffset, false));
                extParts.AddRange(GetExtendedPartitions(truc, offset, iterNb + 1));
            }
            return(extParts);
        }