public async Task <IActionResult> Edit(int id, [Bind("ID,BarCode,Bank,Tag,CreateDate")] HardDisk hardDisk)
        {
            if (id != hardDisk.ID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(hardDisk);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!HardDiskExists(hardDisk.ID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(hardDisk));
        }
예제 #2
0
        public override void OnSave(ConfigNode node)
        {
            try
            {
                node.AddValue("activated", ProcessorMode != ProcessorModes.OFF);

                if (HardDisk != null)
                {
                    ConfigNode hdNode = HardDisk.ToConfigNode("harddisk");
                    node.AddNode(hdNode);
                }

                if (shared != null && shared.Cpu != null)
                {
                    SafeHouse.Config.SaveConfig();
                }

                base.OnSave(node);
            }
            catch (Exception ex) //Intentional Pokemon, if exceptions get out of here it can kill the craft
            {
                SafeHouse.Logger.Log("ONSAVE Exception: " + ex.TargetSite);
                SafeHouse.Logger.LogException(ex);
            }
        }
예제 #3
0
 public static void SetArrayBlock(int index, byte value)
 {
     arrayBlock[index] = value;
     HardDisk.Write(new byte[1] {
         value
     }, SuperBlock.FSMStart + index);
 }
예제 #4
0
 public static byte GetArrayInodeDirTable(int index)
 {
     byte[] buffer = new byte[1];
     HardDisk.Read(ref buffer, SuperBlock.InodeDirTableStart + index);
     arrayInodeDirTable[index] = buffer[0];
     return(arrayInodeDirTable[index]);
 }
예제 #5
0
        public GptHardDrive(HardDisk hdd)
        {
            //check for MBR protective partition
            if (!MbrHardDisk.IsMbr(hdd))
            {
                throw new Exception("Not MBR.");
            }
            if (MbrHardDisk.GetType(hdd, 0) != MbrPartitionType.GptProtective)
            {
                throw new Exception("Not GPT.");
            }

            mHeader = LoadHeader(hdd, SectorSize);
            var backup = LoadHeader(hdd, hdd.Length - SectorSize);

            List <PartitionEntry> parts = new List <PartitionEntry>();

            for (int i = 0; i < mHeader.NumberOfPartitions; i++)
            {
                var partEnt = GetLba <PartitionEntry>(hdd, mHeader.StartingLbaOfPartitionEntries, i * mHeader.SizeOfPartitionEntry);
                if (partEnt.Type == Guid.Empty)
                {
                    continue;
                }
                parts.Add(partEnt);
            }

            mPartition = parts.Where(p => sZfsPartitionTypes.Contains(p.Type)).Single();

            Init(hdd, SectorSize * mPartition.FirstLba, SectorSize * (mPartition.LastLba - mPartition.FirstLba));
        }
예제 #6
0
 public static void SetArrayInodeDirTable(int index, byte value)
 {
     arrayInodeDirTable[index] = value;
     HardDisk.Write(new byte[1] {
         value
     }, SuperBlock.InodeDirTableStart + index);
 }
예제 #7
0
            //public PartitionHardDisk[] Partition;

            public HardDisk[] GetDevice()
            {
                List <HardDisk>          arrayHardDisk = new List <HardDisk>();
                ManagementObjectSearcher searcher      = new ManagementObjectSearcher("root\\CIMV2", "SELECT * FROM Win32_DiskDrive");

                foreach (ManagementObject queryObj in searcher.Get())
                {
                    HardDisk tempHardDisk = new HardDisk();
                    tempHardDisk.SerialNumber   = queryObj["SerialNumber"] != null ? queryObj["SerialNumber"].ToString() : "Nodata";
                    tempHardDisk.Caption        = queryObj["Caption"] != null ? queryObj["Caption"].ToString() : "Nodata";
                    tempHardDisk.Size           = queryObj["Size"] != null ? (Convert.ToDouble(queryObj["Size"]) / 1073741824).ToString() : "Nodata";
                    tempHardDisk.PartitionValue = queryObj["Partitions"] != null ? queryObj["Partitions"].ToString() : "Nodata";

                    /*
                     * try
                     * {
                     *  ManagementObjectSearcher searcher = new ManagementObjectSearcher("root\\CIMV2", "SELECT * FROM Win32_DiskPartition");
                     *
                     *  foreach (ManagementObject queryObj in searcher.Get())
                     *  {
                     *      Console.WriteLine("Caption: {0}", queryObj["Caption"]);
                     *      Console.WriteLine("Size     : {0}", (long.Parse(queryObj["Size"].ToString()) / 1073741824).ToString());
                     *      Console.WriteLine("Type: {0}", queryObj["Type"]);
                     *  }
                     * }
                     * catch (ManagementException e)
                     * {
                     *  ;
                     * }
                     */

                    arrayHardDisk.Add(tempHardDisk);
                }
                return(arrayHardDisk.ToArray());
            }
예제 #8
0
        public async Task <IActionResult> Edit(int id, [Bind("Naziv,Proizvodjac,Cijena,Kapacitet,Brzina,Id")] HardDisk hardDisk)
        {
            if (id != hardDisk.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(hardDisk);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!HardDiskExists(hardDisk.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(hardDisk));
        }
예제 #9
0
 private void PlayMovie()
 {
     HardDisk.ProvideMovieData();
     Cpu.Handle();
     SoundCard.Show();
     GraphicsCard.Play();
 }
예제 #10
0
        public async Task <IHttpActionResult> PostHardDisk(HardDisk HardDisk)
        {
            if (HardDisk == null)
            {
                return(BadRequest("Отсутствует тело элемента"));
            }
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            _db.HardDisks.Add(HardDisk);

            try
            {
                await _db.SaveChangesAsync();
            }
            catch (DbUpdateException)
            {
                if (HardDiskExists(HardDisk.Id))
                {
                    return(Conflict());
                }
                else
                {
                    throw;
                }
            }
            return(CreatedAtRoute("DefaultApi", new { id = HardDisk.Id }, HardDisk));
        }
예제 #11
0
        public unsafe VdiHardDisk(HardDisk hdd)
            : base(hdd)
        {
            var headBytes = hdd.ReadBytes(0, sizeof(VdiHeader));
            VdiHeader head = Program.ToStruct<VdiHeader>(headBytes);

            if (head.ImageSig != VdiMagic)
                throw new Exception("Wrong magic.");
            if (head.Version != VdiVersion)
                throw new Exception("Wrong version.");
            if (head.SizeOfHeader != VdiHeadSize)
                throw new Exception("Wrong size.");

            if (head.ImageType != ImageType.Dynamic)
                throw new NotImplementedException("Only dynamic is supported.");

            var dataOffset = head.OffsetData;
            mBlockOffsets = new long[head.BlocksInHdd];
            mBlockSize = (int)head.BlockSize;

            for (long i = 0; i < head.BlocksInHdd; i++)
            {
                uint blockLoc;
                hdd.Get<uint>(head.OffsetBlocks + i * 4, out blockLoc);
                if (blockLoc == ~0u)
                    mBlockOffsets[i] = -1;
                else
                    mBlockOffsets[i] = dataOffset + blockLoc * mBlockSize;
            }
        }
예제 #12
0
        private GptHeader LoadHeader(HardDisk hdd, long offset)
        {
            GptHeader ret;

            hdd.Get(offset, out ret); //LBA 1
            if (ret.Signature != EfiMagic)
            {
                throw new Exception("Not a GPT.");
            }
            if (ret.Revision != CurrentRevision)
            {
                throw new Exception("Wrong rev.");
            }
            if (ret.HeaderSize < CurrentHeaderSize)
            {
                throw new Exception("Wrong header size.");
            }
            //TODO: check crc
            if (ret.SizeOfPartitionEntry != ParitionEntrySize)
            {
                throw new Exception("Wrong ParitionEntrySize.");
            }
            //TODO: check partition entry CRC

            if (ret.NumberOfPartitions == 0)
            {
                throw new Exception("No partitions!");
            }

            return(ret);
        }
예제 #13
0
        public static HardDisk Create(HardDisk hdd)
        {
            byte[]    headBytes = hdd.ReadBytes(hdd.Length - 512, 512);
            VhdHeader head      = Program.ToStructFromBigEndian <VhdHeader>(headBytes);

            if (head.CookieStr != "conectix")
            {
                throw new Exception("missing magic string");
            }
            if (head.FileFormatVersion != 0x00010000)
            {
                throw new Exception("upsupported version");
            }
            //TODO: validate checksum

            if (head.DiskType == DiskType.Fixed)
            {
                return(new FixedVhd(hdd, in head));
            }
            else if (head.DiskType == DiskType.Dynamic)
            {
                return(new DynamicVhd(hdd, in head));
            }
            else
            {
                throw new Exception("Only fixed size VHDs are supported.");
            }
        }
예제 #14
0
        public static void SetInodeID(string name, int ID)
        {
            byte[] buffer = System.Text.Encoding.ASCII.GetBytes(name);
            HardDisk.Write(buffer, SuperBlock.InodeNameAndIDTableStart + ID * SuperBlock.InodeNameLength);

            nameInode[ID] = name;
        }
예제 #15
0
        public object Add(HardDisk hardDisk)
        {
            _context.HardDiskSizes.Add(hardDisk);
            _context.SaveChanges();

            return(new SuccessResponse());
        }
예제 #16
0
        public static MbrPartitionType GetType(HardDisk hdd, int index)
        {
            MbrHeader h;

            hdd.Get(0, out h);
            return(h.GetPartition(index).Type);
        }
예제 #17
0
        public static bool IsMbr(HardDisk hdd)
        {
            MbrHeader h;

            hdd.Get(0, out h);
            return(h.BootSig == MbrHeader.MbrMagic);
        }
예제 #18
0
        public ATA()
        {
            foreach (DiskElement drive in SystemConfig.Machine.Disks)
            {
                ATADrive newDrive;

                if (drive.Type == DriveType.HardDisk)
                {
                    newDrive = new HardDisk();
                }
                else if (drive.Type == DriveType.CDROM)
                {
                    newDrive = new CDROM();
                }
                else
                {
                    break;
                }

                newDrive.LoadImage(drive.Image);

                diskDrives.Add(newDrive);
            }

            primarySelected = true;
        }
예제 #19
0
        private static T GetLba <T>(HardDisk hdd, long absoluteLba, long extraOffset) where T : struct
        {
            long byteOffset = absoluteLba * SectorSize + extraOffset;
            T    ret;

            hdd.Get <T>(byteOffset, out ret);
            return(ret);
        }
예제 #20
0
        public void SetArrayFile(int index, int number)
        {
            byte[] buffer = new byte[4];
            buffer = BitConverter.GetBytes(SuperBlock.InodeStart + SuperBlock.InodeSize * number);
            HardDisk.Write(buffer, SuperBlock.InodeDirStart + dirID * SuperBlock.InodeDirSize + 4 * index);

            arrayFile[index] = SuperBlock.InodeStart + SuperBlock.InodeSize * number;
        }
예제 #21
0
        public int GetArrayBlock(int index)
        {
            byte[] buffer = new byte[4];
            HardDisk.Read(ref buffer, SuperBlock.InodeStart + fileID * SuperBlock.InodeSize + 4 * index);
            arrayBlocks[index] = BitConverter.ToInt32(buffer, 0);

            return(arrayBlocks[index]);
        }
예제 #22
0
 protected OffsetTableHardDisk(HardDisk hdd)
 {
     if (hdd == null)
         throw new ArgumentNullException(nameof(hdd));
     mHdd = hdd;
     mReadBlock = readBlock;
     mGetBlockKey = getBlockKey;
 }
예제 #23
0
        public static byte GetArrayBlock(int index)
        {
            byte[] buffer = new byte[1];
            HardDisk.Read(ref buffer, SuperBlock.FSMStart + index);

            arrayBlock[index] = buffer[0];
            return(arrayBlock[index]);
        }
예제 #24
0
        public void SetArrayBlock(int index, int number)
        {
            byte[] buffer = new byte[4];
            buffer = BitConverter.GetBytes(number * SuperBlock.BlockSize + SuperBlock.BlockStart);

            HardDisk.Write(buffer, SuperBlock.InodeStart + fileID * SuperBlock.InodeSize + 4 * index);

            arrayBlocks[index] = number * SuperBlock.BlockSize + SuperBlock.BlockStart;
        }
예제 #25
0
        public int GetArrayDir(int index)
        {
            byte[] buffer = new byte[4];
            HardDisk.Read(ref buffer, SuperBlock.InodeDirStart + dirID * SuperBlock.InodeDirSize + 4 * SuperBlock.InodeMaxCountInDir + 4 * index);

            arrayDir[index] = BitConverter.ToInt32(buffer, 0);

            return(arrayDir[index]);
        }
예제 #26
0
 /// <summary>
 /// The method convert from EntityModel to model of hardDisk
 /// </summary>
 /// <param name="hardDisk">HardDisk hardDisk</param>
 /// <returns>Models.HardDisk</returns>
 public Models.HardDisk NewHardDisk(HardDisk hardDisk)
 {
     return(new Models.HardDisk
     {
         Id = hardDisk.Id,
         HDD = hardDisk.HDD,
         SSD = hardDisk.SSD
     });
 }
예제 #27
0
 public static HardDisk Create(HardDisk hdd, long offset, long size)
 {
     while (hdd is OffsetHardDisk)
     {
         var off = (OffsetHardDisk)hdd;
         offset += off.mOffset;
         hdd = off.mHdd;
     }
     return new OffsetHardDisk(hdd, offset, size);
 }
예제 #28
0
 public static HardDisk Create(HardDisk hdd, long offset, long size)
 {
     while (hdd is OffsetHardDisk)
     {
         var off = (OffsetHardDisk)hdd;
         offset += off.mOffset;
         hdd     = off.mHdd;
     }
     return(new OffsetHardDisk(hdd, offset, size));
 }
예제 #29
0
        public async Task <IActionResult> Create([Bind("Naziv,Proizvodjac,Cijena,Kapacitet,Brzina")] HardDisk hardDisk)
        {
            if (ModelState.IsValid)
            {
                _context.Add(hardDisk);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(hardDisk));
        }
예제 #30
0
        protected void Init(HardDisk hdd, long offset, long size)
        {
            if (offset < 0)
                throw new ArgumentOutOfRangeException();
            if (offset + size > hdd.Length)
                throw new ArgumentOutOfRangeException();

            mHdd = hdd;
            mOffset = offset;
            mSize = size;
        }
예제 #31
0
        public LeafVdevInfo(HardDisk hdd)
        {
            this.HDD = hdd;

            var rentedBytes = Program.RentBytes(VDEV_PHYS_SIZE);

            try
            {
                if (!hdd.ReadLabelBytes(rentedBytes, VDEV_SKIP_SIZE))
                    throw new Exception("Invalid checksum on lable config data!");
                Config = new NvList(rentedBytes);
            }
            finally
            {
                Program.ReturnBytes(rentedBytes);
                rentedBytes = default(ArraySegment<byte>);
            }

            //figure out how big the uber blocks are
            var vdevTree = Config.Get<NvList>("vdev_tree");
            var ubShift = (int)vdevTree.Get<ulong>("ashift");
            ubShift = Math.Max(ubShift, UBERBLOCK_SHIFT);
            ubShift = Math.Min(ubShift, MAX_UBERBLOCK_SHIFT);
            var ubSize = 1 << ubShift;
            var ubCount = VDEV_UBERBLOCK_RING >> ubShift;

            List<uberblock_t> blocks = new List<uberblock_t>();
            var ubBytes = Program.RentBytes(ubSize);
            try
            {
                for (long i = 0; i < ubCount; i++)
                {
                    var offset = VDEV_SKIP_SIZE + VDEV_PHYS_SIZE + ubSize * i;
                    if (!hdd.ReadLabelBytes(ubBytes, offset))
                        continue;
                    uberblock_t b = Program.ToStruct<uberblock_t>(ubBytes.Array, ubBytes.Offset);
                    if (b.Magic == uberblock_t.UbMagic)
                    {
                        blocks.Add(b);
                    }
                }
            }
            finally
            {
                Program.ReturnBytes(ubBytes);
                ubBytes = default(ArraySegment<byte>);
            }
            this.Uberblock = blocks.OrderByDescending(u => u.Txg).ThenByDescending(u => u.TimeStamp).First();

            const int VDevLableSizeStart = 4 << 20;
            const int VDevLableSizeEnd = 512 << 10;
            hdd = OffsetHardDisk.Create(hdd, VDevLableSizeStart, hdd.Length - VDevLableSizeStart - VDevLableSizeEnd);
            this.HDD = hdd;
        }
        public async Task <IActionResult> Create([Bind("ID,BarCode,Bank,Tag,CreateDate")] HardDisk hardDisk)
        {
            if (ModelState.IsValid)
            {
                _context.Add(hardDisk);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(hardDisk));
        }
예제 #33
0
        public async Task <bool> CreateHardDiskPart(HardDiskServiceModel hardDiskServiceModel)
        {
            HardDisk hardDiskEntity = hardDiskServiceModel.To <HardDisk>();

            hardDiskEntity.Id = Guid.NewGuid().ToString();

            bool result = await this.pCCDbContext.AddAsync(hardDiskEntity) != null;

            await this.pCCDbContext.SaveChangesAsync();

            return(result);
        }
예제 #34
0
 /// <summary>
 /// Constructor, initialize all attributes except id, state and date
 /// </summary>
 /// <param name="clientName">ClientName to initialize</param>
 /// <param name="os">Operative system to initialize</param>
 /// <param name="type">Computer type to initialize</param>
 /// <param name="processor">Processor to initialize</param>
 /// <param name="hardDisk">Hard disk to initialize</param>
 /// <param name="ram">RAM to initialize</param>
 /// <param name="desc">Description to initialize</param>
 /// <param name="graphicCard">Graphic card to initialize</param>
 public Computer(string clientName, OS os, ComType type, Processor processor, HardDisk hardDisk, RAM ram, string desc, GraphicCard graphicCard)
 {
     this.clientName      = clientName;
     this.operativeSystem = os;
     this.type            = type;
     this.processor       = processor;
     this.hardDisk        = hardDisk;
     this.ram             = ram;
     this.desc            = desc;
     this.date            = DateTime.Now;
     this.state           = State.Recibida;
     this.graphicCard     = graphicCard;
 }
예제 #35
0
 public Laptop(string model, string manufacturer, Processor processor, int ramMemory,
               string graphicsCard, HardDisk hardDisk, Screen screen, Battery battery, double price)
 {
     this.Model        = model;
     this.Manufacturer = manufacturer;
     this.Processor    = processor;
     this.RamMemory    = ramMemory;
     this.GraphicsCard = graphicsCard;
     this.HardDisk     = hardDisk;
     this.Screen       = screen;
     this.Battery      = battery;
     this.Price        = price;
 }
예제 #36
0
        public static HardDisk Create(HardDisk hdd)
        {
            VhdHeader head = GetHeader(hdd);
            if (head.CookieStr != "conectix")
                throw new Exception("missing magic string");
            if (head.FileFormatVersion != 0x00010000)
                throw new Exception("upsupported version");

            if (head.DiskType == DiskType.Fixed)
            {
                return new FixedVhd(hdd);
            }
            else if (head.DiskType == DiskType.Dynamic)
            {
                return new DynamicVhd(hdd);
            }
            else
            {
                throw new Exception("Only fixed size VHDs are supported.");
            }
        }
예제 #37
0
            public DynamicVhd(HardDisk hdd)
                : base(hdd)
            {
                VhdHeader head = GetHeader(hdd);
                int dySize = Program.SizeOf<DynamicHeader>();
                DynamicHeader dyhead = Program.ToStructByteSwap<DynamicHeader>(hdd.ReadBytes(head.DataOffset, dySize));
                if (dyhead.CookieStr != "cxsparse")
                    throw new Exception("missing magic string");
                if (dyhead.HeaderVersion != 0x00010000)
                    throw new NotSupportedException("wrong version");
                if (dyhead.ParentUniqueID != Guid.Empty)
                    throw new NotSupportedException("Differencing disks not supported.");

                mSize = head.CurrentSize;
                mBlockSize = dyhead.BlockSize;
                int sectorBitmapSize = (mBlockSize / SECTOR_SIZE) / 8;

                int numberOfBlocks = (int)(mSize / mBlockSize);
                if (numberOfBlocks > dyhead.MaxTableEntries)
                    throw new Exception();
                mBlockOffsets = new long[numberOfBlocks];

                var bat = hdd.ReadBytes(dyhead.TableOffset, numberOfBlocks * 4);

                for (int i = 0; i < numberOfBlocks; i++)
                {
                    Program.ByteSwap(typeof(int), bat, i * 4);
                    long batEntry = Program.ToStruct<int>(bat, i * 4);
                    if (batEntry != -1)
                    {
                        batEntry *= SECTOR_SIZE;
                        //skip the sector bitmap, since we don't support differencing disks
                        batEntry += sectorBitmapSize;
                    }
                    mBlockOffsets[i] = batEntry;
                }
            }
예제 #38
0
            public FixedVhd(HardDisk hdd)
            {
                long size = hdd.Length - 512;
                var head = GetHeader(hdd);

                if (head.CurrentSize != size)
                    throw new Exception();

                Init(hdd, 0, size);
            }
예제 #39
0
 static VhdHeader GetHeader(HardDisk hdd)
 {
     return Program.ToStructByteSwap<VhdHeader>(hdd.ReadBytes(hdd.Length - 512, 512));
 }
예제 #40
0
 private OffsetHardDisk(HardDisk hdd, long offset, long size)
 {
     Init(hdd, offset, size);
 }
예제 #41
0
        public VhdxHardDisk(HardDisk hdd)
            : base(hdd)
        {
            VHDX_REGION_TABLE_ENTRY batRegion, metadataRegion;
            GetRegions(out batRegion, out metadataRegion);

            VHDX_FILE_PARAMETERS fileParams;
            uint logicalSectorSize;
            ReadMetadata(metadataRegion, out fileParams, out mVirtualDiskSize, out logicalSectorSize);

            if (fileParams.HasParent)
                throw new NotImplementedException("Differencing disk are not supported.");

            //check all these calculations to make sure our assumptions about data sizes are correct
            checked
            {
                mBlockSize = (int)fileParams.BlockSize;

                int chunkRatio = (int)((1L << 23) * logicalSectorSize / mBlockSize);
                int dataBlockCount = (int)Math.Ceiling((decimal)mVirtualDiskSize / mBlockSize);
                int sectorBitmapCount = (int)Math.Ceiling((decimal)dataBlockCount / chunkRatio);
                int totalBatEntries = dataBlockCount + (int)Math.Floor((dataBlockCount - 1) / (decimal)chunkRatio);

                if (batRegion.Length < Program.SizeOf<VHDX_BAT_ENTRY>() * totalBatEntries)
                    throw new Exception("Bat region is not big enough to contain all the bat entries!");

                var batBytes = mHdd.ReadBytes((long)batRegion.FileOffset, (int)batRegion.Length);

                mBlockOffsets = new long[dataBlockCount];
                int fileOffsetsNdx = 0;
                for (int i = 0; i < totalBatEntries; i++)
                {
                    var isSectorBitmap = i % (chunkRatio + 1) == chunkRatio;
                    var entry = Program.ToStruct<VHDX_BAT_ENTRY>(batBytes, i * Program.SizeOf<VHDX_BAT_ENTRY>());
                    if (isSectorBitmap)
                    {
                        if (entry.SectorBitmapState != SectorBitmapState.NotPresent)
                            throw new Exception("Present bat entry!");
                    }
                    else
                    {
                        long offset;
                        switch (entry.PayloadState)
                        {
                            case PayloadBlockState.NotPresent:
                            case PayloadBlockState.Undefined:
                            case PayloadBlockState.BlockZero:
                            case PayloadBlockState.Unmapped:
                                offset = 0;
                                break;
                            case PayloadBlockState.FullyPresent:
                                offset = entry.FileOffsetMB << 20;
                                break;
                            case PayloadBlockState.PartiallyPresent:
                                throw new NotSupportedException("Partially present blocks are not supported.");
                            default:
                                throw new Exception($"Unknown BAT entry state: {entry.PayloadState}");
                        }
                        if (offset == 0)
                            offset = -1;
                        mBlockOffsets[fileOffsetsNdx++] = offset;
                    }
                }
            }
        }
예제 #42
0
 public static bool IsMbr(HardDisk hdd)
 {
     MbrHeader h;
     hdd.Get(0, out h);
     return h.BootSig == MbrHeader.MbrMagic;
 }
예제 #43
0
        public MbrHardDisk(HardDisk hdd, int partition)
        {
            hdd.Get(0, out mHeader);

            //for now, always assume a GPT partition
            if (!MbrHardDisk.IsMbr(hdd))
                throw new Exception("Expected a MBR hdd.");
            if (MbrHardDisk.GetType(hdd, 0) != MbrPartitionType.GptProtective)
                throw new Exception("Expected a GPT protective MBR entry.");

            mPartition = mHeader.GetPartition(partition);
            Init(hdd, (long)mPartition.FirstSectorLba * MbrHeader.SectorSize, (long)mPartition.NumberOfSectors * MbrHeader.SectorSize);
        }
예제 #44
0
 public HddVdev(NvList config, LeafVdevInfo hdd)
     : base(config)
 {
     this.mHdd = hdd.HDD;
 }
예제 #45
0
 public static MbrPartitionType GetType(HardDisk hdd, int index)
 {
     MbrHeader h;
     hdd.Get(0, out h);
     return h.GetPartition(index).Type;
 }