コード例 #1
0
ファイル: PartitionDevice.cs プロジェクト: sharpos/SharpOS
		public PartitionDevice (GenericPartition partition, IDiskDevice diskDevice, bool readOnly)
		{
			this.diskDevice = diskDevice;
			this.start = partition.StartLBA;
			this.blockCount = partition.TotalBlocks;
			this.readOnly = readOnly;

            base.parent = diskDevice as Device;
            base.name = base.parent.Name + "/Partition" + (partition.Index + 1).ToString();	// need to give it a unique name
			base.deviceStatus = DeviceStatus.Online;

			DeviceManager.Add (this);
		}
コード例 #2
0
ファイル: MasterBootBlock.cs プロジェクト: willvin313/SharpOS
        public void Dump()
        {
            for (uint index = 0; index < MaxMBRPartitions; index++)
            {
                GenericPartition partition = partitions[index];

                if (partition.PartitionType != PartitionTypes.Empty)
                {
                    TextMode.Write("partition #", (int)index);
                    TextMode.Write(" found, lba=", (int)partition.StartLBA);
                    TextMode.Write(", count=", (int)partition.TotalBlocks);
                    TextMode.Write(", type=", (int)partition.PartitionType);

                    // for testing
                    //if (FAT.FileSystem.IsFat (partition.BlockDevice))
                    //    TextMode.Write (" (fat)");
                    //else
                    TextMode.Write(" (unknown)");
                    TextMode.WriteLine();
                }
            }
        }
コード例 #3
0
ファイル: MasterBootBlock.cs プロジェクト: sharpos/SharpOS
		private bool ReadMasterBootBlock ()
		{
			valid = false;

			if (diskDevice.BlockSize != 512)	// only going to work with 512 sector sizes
				return false;

			BinaryFormat masterboot = new BinaryFormat (diskDevice.ReadBlock (0, 1));

			ushort mbrsignature = masterboot.GetUShort (MasterBootRecord.MBRSignature);
			diskSignature = masterboot.GetUInt (MasterBootRecord.DiskSignature);

			valid = (mbrsignature == MasterBootConstants.MBRSignature);

			if (valid) {
				for (uint index = 0; index < MaxMBRPartitions; index++) {

					uint offset = MasterBootRecord.PrimaryPartitions + (index * 16);

					GenericPartition partition = new GenericPartition (index);

					partition.Bootable = masterboot.GetByte (offset + PartitionRecord.Status) == 0x80;
					partition.PartitionType = masterboot.GetByte (offset + PartitionRecord.PartitionType);
					partition.StartLBA = masterboot.GetUInt (offset + PartitionRecord.LBA);
					partition.TotalBlocks = masterboot.GetUInt (offset + PartitionRecord.Sectors);

					partitions[index] = partition;
				}

				//TODO: Extended Partitions
			}

			code = new byte[MasterBootConstants.CodeAreaSize];
			for (uint index = 0; index < MasterBootConstants.CodeAreaSize; index++)
				code[index] = masterboot.GetByte (index);

			return valid;
		}