Пример #1
0
        //*****************************************************************************************
        //* Construncting a new'SipperPartitionSector' representing an emtpty drive.              *
        //*****************************************************************************************
        public SipperPartitionSector(PartitionTableEntry sipperPartition)
        {
            int x = 0;

            int sipperIdLen = Math.Min(Constants.SIPPER_PARTITION_ID_SIZE, Constants.SIPPER_PARITION_ID.Length);

            sipperId = new char[Constants.SIPPER_PARTITION_ID_SIZE];
            for (x = 0; x < sipperIdLen; x++)
            {
                sipperId[x] = Constants.SIPPER_PARITION_ID[x];
            }


            // Used code from  'Sipper3DLL.c'  function 'InitializeSIPPERPartition' as a model for
            // filling in the following fields.
            totalSectors   = sipperPartition.TotalSectors;
            fileDataSector = sipperPartition.RelativeSector + (uint)Constants.MAX_SIPPER_FILES + (uint)1;

            endSector = sipperPartition.RelativeSector + sipperPartition.TotalSectors;   // I worry about this line, seems that we should be subtracting '1' from it.

            nextFcbSector  = sipperPartition.RelativeSector + 1;
            nextFileHandle = 0;

            int sizeOfUnUsedSpace = Constants.LOGICAL_BLOCK_SIZE - (sipperId.Length + 5 * sizeof(UInt32));

            unUsedSpace = new byte[sizeOfUnUsedSpace];
            for (x = 0; x < sizeOfUnUsedSpace; x++)
            {
                unUsedSpace[x] = 0;
            }
        }
Пример #2
0
 /**
  * @brief Constructs a Partition Table by reading in each of the 4 partition table entries from a supplied buffer.
  * @param[in]      buff       Buffer to read data from.
  * @param[in,out]  nextIndex  Next byte from the buffer to be read.  Upon retun the caller can use this as the starting point
  *                            for the next data structure.
  */
 public PartitionTable(byte[] buffer,
                       ref int nextIndex
                       )
 {
     partitions = new PartitionTableEntry[4];
     for (int x = 0; x < 4; x++)
     {
         partitions[x] = new PartitionTableEntry(buffer, ref nextIndex);
     }
 }
Пример #3
0
 static public int  BuffSpaceNeeded()
 {
     return(4 * PartitionTableEntry.BuffSpaceNeeded());
 }
Пример #4
0
        } /* BlockEnd */

        public void  ResetSipperDirectory()
        {
            // 1) Open SipperDisk for update
            //
            // 2) Read in current 'SippePartitonSector'
            //
            // 3) set SipperDiskPartiton.FileDataSector <= PartitionTableEntry.RelativeSector + MAX_SIPPER_FILES  + 1
            //                                             This is the 1st sector after the SIPPER Dierctry Structure.
            //
            // 4) reWrite  'SipperDiskPartiton'
            //
            // 5) sipperDirectorySector <= PartitionTableEntry.RelativeSector * LOGICAL_BLOCK_SIZE + sizeof(SipperPartitionSector);
            //    Disk Set File pointer to sipperDirectorySector
            //
            // 6) Initialize a FileControlBlock (FCB)
            //    a. memset  (&FCB, 0, sizeof (FCB)
            //    b. FCB.Allocatd    <= 0x0  (Indicates Sipper File Free)
            //    c. FCB.Status      <= 0    (Indicates Sipper File is Closed)
            //    d. FCB.FileName    <= "NO FILE"
            //    e. FCB.Description <= "NO DESCRIPTION"
            //
            //
            // 7) Write out Blank FCB to all Directory Entries
            //    for  (x <= 0; x < MAX_SIPPER_FILES;  x++)
            //     |Write out FCB to Disk
            //
            // 8) Update fields in SipperPartitionSector to reflect a empty drive.
            //    nextFcbSector  <= PartitionTableEntry.RelativeSector + 1;
            //    nextFileHandle <= 0;
            //    fileDataSector <= PartitionTableEntry.RelativeSector + MAX_SIPPER_FILES + 1
            //
            // 9) RwWrite SipperPartitionSector
            //
            // 10) Close Sipper Disk
            //
            //

            ReOpen(true);                // Mmaking sure the Siper disk is opened for update.
            ReadSipperPartitionSector(); // Make sure it is the latest on the drive.

            PartitionTableEntry sipperPartitionTableEntry = mbr.GetSipperPartitionTableEntry();

            sipperPartitionSector.FileDataSector = sipperPartitionTableEntry.RelativeSector + Constants.MAX_SIPPER_FILES + 1;

            WriteSipperPartitionSector(sipperPartitionSector);


            Int64 sipperDirectorySectorByteOffset = mbr.GetSipperDirectoryByteOffset();

            fs.Seek(sipperDirectorySectorByteOffset, SeekOrigin.Begin);

            SipperFileControlBlock fcb = new SipperFileControlBlock();

            fcb.Allocated = SipperFileControlBlock.SIPPER_FILE_FREE;
            fcb.Status    = SipperFileControlBlock.SIPPER_FILE_CLOSED;

            for (int fileCount = 0; fileCount < Constants.MAX_SIPPER_FILES; fileCount++)
            {
                fcb.FcbIndex = fileCount;
                fcb.Write(fs);
            }


            sipperPartitionSector.NextFcbSector  = sipperPartitionTableEntry.RelativeSector + 1;
            sipperPartitionSector.NextFileHandle = 0;
            sipperPartitionSector.FileDataSector = sipperPartitionTableEntry.RelativeSector + Constants.MAX_SIPPER_FILES + 1;

            WriteSipperPartitionSector(sipperPartitionSector);

            CloseHandleToPhysicalDisk();
        } /* ResetSipperDirectory */