public int ReadFrom(byte[] buffer, int offset) { this.Signature = EndianUtilities.ToUInt32BigEndian(buffer, offset + 0); this.Version = EndianUtilities.ToUInt32BigEndian(buffer, offset + 4); this.HeaderSize = EndianUtilities.ToUInt32BigEndian(buffer, offset + 8); this.Flags = EndianUtilities.ToUInt32BigEndian(buffer, offset + 12); this.RunningDataForkOffset = EndianUtilities.ToUInt64BigEndian(buffer, offset + 16); this.DataForkOffset = EndianUtilities.ToUInt64BigEndian(buffer, offset + 24); this.DataForkLength = EndianUtilities.ToUInt64BigEndian(buffer, offset + 32); this.RsrcForkOffset = EndianUtilities.ToUInt64BigEndian(buffer, offset + 40); this.RsrcForkLength = EndianUtilities.ToUInt64BigEndian(buffer, offset + 48); this.SegmentNumber = EndianUtilities.ToUInt32BigEndian(buffer, offset + 56); this.SegmentCount = EndianUtilities.ToUInt32BigEndian(buffer, offset + 60); this.SegmentGuid = EndianUtilities.ToGuidBigEndian(buffer, offset + 64); this.DataForkChecksum = EndianUtilities.ToStruct <UdifChecksum>(buffer, offset + 80); this.XmlOffset = EndianUtilities.ToUInt64BigEndian(buffer, offset + 216); this.XmlLength = EndianUtilities.ToUInt64BigEndian(buffer, offset + 224); this.MasterChecksum = EndianUtilities.ToStruct <UdifChecksum>(buffer, offset + 352); this.ImageVariant = EndianUtilities.ToUInt32BigEndian(buffer, offset + 488); this.SectorCount = EndianUtilities.ToInt64BigEndian(buffer, offset + 492); return(this.Size); }
public int ReadFrom(byte[] buffer, int offset) { Magic = EndianUtilities.ToUInt32BigEndian(buffer, offset); Version = EndianUtilities.ToUInt32BigEndian(buffer, offset + 0x4); SequenceNumber = EndianUtilities.ToUInt32BigEndian(buffer, offset + 0x8); Length = EndianUtilities.ToUInt32BigEndian(buffer, offset + 0xC); RootBlockNumbers = new uint[2]; RootBlockNumbers[0] = EndianUtilities.ToUInt32BigEndian(buffer, offset + 0x10); RootBlockNumbers[1] = EndianUtilities.ToUInt32BigEndian(buffer, offset + 0x14); Spare0 = EndianUtilities.ToUInt32BigEndian(buffer, offset + 0x18); Levels = new uint[2]; Levels[0] = EndianUtilities.ToUInt32BigEndian(buffer, offset + 0x1C); Levels[1] = EndianUtilities.ToUInt32BigEndian(buffer, offset + 0x20); Spare1 = EndianUtilities.ToUInt32BigEndian(buffer, offset + 0x24); FreeListFirst = EndianUtilities.ToUInt32BigEndian(buffer, offset + 0x28); FreeListLast = EndianUtilities.ToUInt32BigEndian(buffer, offset + 0x2C); FreeListCount = EndianUtilities.ToUInt32BigEndian(buffer, offset + 0x30); FreeBlocks = EndianUtilities.ToUInt32BigEndian(buffer, offset + 0x34); Longest = EndianUtilities.ToUInt32BigEndian(buffer, offset + 0x38); BTreeBlocks = EndianUtilities.ToUInt32BigEndian(buffer, offset + 0x3C); if (SbVersion >= 5) { UniqueId = EndianUtilities.ToGuidBigEndian(buffer, offset + 0x40); Lsn = EndianUtilities.ToUInt64BigEndian(buffer, offset + 0x50); Crc = EndianUtilities.ToUInt32BigEndian(buffer, offset + 0x58); } return(Size); }
public int ReadFrom(byte[] buffer, int offset) { Count4Bytes = buffer[offset]; Count8Bytes = buffer[offset + 0x1]; byte count = Count4Bytes; _useShortInode = Count8Bytes == 0; offset += 0x2; if (_useShortInode) { Parent = EndianUtilities.ToUInt32BigEndian(buffer, offset); offset += 0x4; } else { Parent = EndianUtilities.ToUInt64BigEndian(buffer, offset); offset += 0x8; } Entries = new ShortformDirectoryEntry[count]; for (int i = 0; i < count; i++) { var entry = new ShortformDirectoryEntry(_useShortInode, _context); entry.ReadFrom(buffer, offset); offset += entry.Size; Entries[i] = entry; } return(Size); }
public void Parse(byte[] headerData, int headerOffset, byte[] bodyData) { Header = new BasicHeaderSegment(); Header.ReadFrom(headerData, headerOffset); if (Header.OpCode != OpCode.ScsiDataIn) { throw new InvalidProtocolException("Invalid opcode in response, expected " + OpCode.ScsiDataIn + " was " + Header.OpCode); } UnpackFlags(headerData[headerOffset + 1]); if (StatusPresent) { Status = (ScsiStatus)headerData[headerOffset + 3]; } Lun = EndianUtilities.ToUInt64BigEndian(headerData, headerOffset + 8); TargetTransferTag = EndianUtilities.ToUInt32BigEndian(headerData, headerOffset + 20); StatusSequenceNumber = EndianUtilities.ToUInt32BigEndian(headerData, headerOffset + 24); ExpectedCommandSequenceNumber = EndianUtilities.ToUInt32BigEndian(headerData, headerOffset + 28); MaxCommandSequenceNumber = EndianUtilities.ToUInt32BigEndian(headerData, headerOffset + 32); DataSequenceNumber = EndianUtilities.ToUInt32BigEndian(headerData, headerOffset + 36); BufferOffset = EndianUtilities.ToUInt32BigEndian(headerData, headerOffset + 40); ResidualCount = EndianUtilities.ToUInt32BigEndian(headerData, headerOffset + 44); ReadData = bodyData; }
public int ReadFrom(byte[] buffer, int offset) { Magic = EndianUtilities.ToUInt32BigEndian(buffer, offset); Version = EndianUtilities.ToUInt32BigEndian(buffer, offset + 0x4); SequenceNumber = EndianUtilities.ToUInt32BigEndian(buffer, offset + 0x8); Length = EndianUtilities.ToUInt32BigEndian(buffer, offset + 0xc); Count = EndianUtilities.ToUInt32BigEndian(buffer, offset + 0x10); Root = EndianUtilities.ToUInt32BigEndian(buffer, offset + 0x14); Level = EndianUtilities.ToUInt32BigEndian(buffer, offset + 0x18); FreeCount = EndianUtilities.ToUInt32BigEndian(buffer, offset + 0x1c); NewInode = EndianUtilities.ToUInt32BigEndian(buffer, offset + 0x20); DirInode = EndianUtilities.ToInt32BigEndian(buffer, offset + 0x24); Unlinked = new int[64]; for (int i = 0; i < Unlinked.Length; i++) { Unlinked[i] = EndianUtilities.ToInt32BigEndian(buffer, offset + 0x28 + i * 0x4); } if (SbVersion >= 5) { UniqueId = EndianUtilities.ToGuidBigEndian(buffer, offset + 0x132); Lsn = EndianUtilities.ToUInt64BigEndian(buffer, offset + 0x142); Crc = EndianUtilities.ToUInt32BigEndian(buffer, offset + 0x14A); } return(Size); }
public override int ReadFrom(byte[] buffer, int offset) { offset += base.ReadFrom(buffer, offset); BlockNumber = EndianUtilities.ToUInt64BigEndian(buffer, offset); LogSequenceNumber = EndianUtilities.ToUInt64BigEndian(buffer, offset + 0x8); Uuid = EndianUtilities.ToGuidBigEndian(buffer, offset + 0x10); Owner = EndianUtilities.ToUInt64BigEndian(buffer, offset + 0x20); Crc = EndianUtilities.ToUInt32LittleEndian(buffer, offset + 0x28); return(base.Size + 48); }
protected override int ReadHeader(byte[] buffer, int offset) { Magic = EndianUtilities.ToUInt32BigEndian(buffer, offset); Crc = EndianUtilities.ToUInt32BigEndian(buffer, offset + 0x04); BlockNumber = EndianUtilities.ToUInt64BigEndian(buffer, offset + 0x08); LogSequenceNumber = EndianUtilities.ToUInt64BigEndian(buffer, offset + 0x10); Uuid = EndianUtilities.ToGuidBigEndian(buffer, offset + 0x18); Owner = EndianUtilities.ToUInt64BigEndian(buffer, 0x28); return(0x30); }
public override int ReadFrom(byte[] buffer, int offset) { Inode = EndianUtilities.ToUInt64BigEndian(buffer, offset); NameLength = buffer[offset + 0x8]; Name = EndianUtilities.ToByteArray(buffer, offset + 0x9, NameLength); var padding = 6 - ((NameLength + 1) % 8); offset += padding; Tag = EndianUtilities.ToUInt16BigEndian(buffer, offset + 0x9 + NameLength); return(Size); }
public int ReadFrom(byte[] buffer, int offset) { ulong lower = EndianUtilities.ToUInt64BigEndian(buffer, offset + 0x8); ulong middle = EndianUtilities.ToUInt64BigEndian(buffer, offset + 0x6); ulong upper = EndianUtilities.ToUInt64BigEndian(buffer, offset + 0); BlockCount = (uint)(lower & 0x001FFFFF); StartBlock = (middle >> 5) & 0x000FFFFFFFFFFFFF; StartOffset = (upper >> 9) & 0x003FFFFFFFFFFFFF; Flag = (ExtentFlag)((buffer[offset + 0x0] >> 6) & 0x3); return(Size); }
public int ReadFrom(byte[] buffer, int offset) { LogicalSize = EndianUtilities.ToUInt64BigEndian(buffer, offset + 0); ClumpSize = EndianUtilities.ToUInt32BigEndian(buffer, offset + 8); TotalBlocks = EndianUtilities.ToUInt32BigEndian(buffer, offset + 12); Extents = new ExtentDescriptor[8]; for (int i = 0; i < 8; ++i) { Extents[i] = EndianUtilities.ToStruct <ExtentDescriptor>(buffer, offset + 16 + i * 8); } return(StructSize); }
public int ReadFrom(byte[] buffer, int offset) { NameLength = buffer[offset]; Offset = EndianUtilities.ToUInt16BigEndian(buffer, offset + 0x1); Name = EndianUtilities.ToByteArray(buffer, offset + 0x3, NameLength); if (_useShortInode) { Inode = EndianUtilities.ToUInt32BigEndian(buffer, offset + 0x3 + NameLength); } else { Inode = EndianUtilities.ToUInt64BigEndian(buffer, offset + 0x3 + NameLength); } return(Size); }
public int ReadFrom(byte[] buffer, int offset) { Signature = EndianUtilities.ToUInt16BigEndian(buffer, offset + 0); if (!IsValid) { return(Size); } Version = EndianUtilities.ToUInt16BigEndian(buffer, offset + 2); Attributes = (VolumeAttributes)EndianUtilities.ToUInt32BigEndian(buffer, offset + 4); LastMountedVersion = EndianUtilities.ToUInt32BigEndian(buffer, offset + 8); JournalInfoBlock = EndianUtilities.ToUInt32BigEndian(buffer, offset + 12); CreateDate = HfsPlusUtilities.ReadHFSPlusDate(DateTimeKind.Local, buffer, offset + 16); ModifyDate = HfsPlusUtilities.ReadHFSPlusDate(DateTimeKind.Utc, buffer, offset + 20); BackupDate = HfsPlusUtilities.ReadHFSPlusDate(DateTimeKind.Utc, buffer, offset + 24); CheckedDate = HfsPlusUtilities.ReadHFSPlusDate(DateTimeKind.Utc, buffer, offset + 28); FileCount = EndianUtilities.ToUInt32BigEndian(buffer, offset + 32); FolderCount = EndianUtilities.ToUInt32BigEndian(buffer, offset + 36); BlockSize = EndianUtilities.ToUInt32BigEndian(buffer, offset + 40); TotalBlocks = EndianUtilities.ToUInt32BigEndian(buffer, offset + 44); FreeBlocks = EndianUtilities.ToUInt32BigEndian(buffer, offset + 48); NextAllocation = EndianUtilities.ToUInt32BigEndian(buffer, offset + 52); ResourceClumpSize = EndianUtilities.ToUInt32BigEndian(buffer, offset + 56); DataClumpSize = EndianUtilities.ToUInt32BigEndian(buffer, offset + 60); NextCatalogId = new CatalogNodeId(EndianUtilities.ToUInt32BigEndian(buffer, offset + 64)); WriteCount = EndianUtilities.ToUInt32BigEndian(buffer, offset + 68); EncodingsBitmap = EndianUtilities.ToUInt64BigEndian(buffer, offset + 72); FinderInfo = new uint[8]; for (int i = 0; i < 8; ++i) { FinderInfo[i] = EndianUtilities.ToUInt32BigEndian(buffer, offset + 80 + i * 4); } AllocationFile = EndianUtilities.ToStruct <ForkData>(buffer, offset + 112); ExtentsFile = EndianUtilities.ToStruct <ForkData>(buffer, offset + 192); CatalogFile = EndianUtilities.ToStruct <ForkData>(buffer, offset + 272); AttributesFile = EndianUtilities.ToStruct <ForkData>(buffer, offset + 352); StartupFile = EndianUtilities.ToStruct <ForkData>(buffer, offset + 432); return(512); }
public int ReadFrom(byte[] buffer, int offset) { Level = EndianUtilities.ToUInt16BigEndian(buffer, offset); NumberOfRecords = EndianUtilities.ToUInt16BigEndian(buffer, offset + 0x2); offset += 0x4; Keys = new ulong[NumberOfRecords]; Pointer = new ulong[NumberOfRecords]; for (int i = 0; i < NumberOfRecords; i++) { Keys[i] = EndianUtilities.ToUInt64BigEndian(buffer, offset + i * 0x8); } offset += ((buffer.Length - offset) / 16) * 8; for (int i = 0; i < NumberOfRecords; i++) { Pointer[i] = EndianUtilities.ToUInt64BigEndian(buffer, offset + i * 0x8); } return(Size); }
public override int ReadFrom(byte[] buffer, int offset) { offset += base.ReadFrom(buffer, offset); if (Level == 0) throw new IOException("invalid B+tree level - expected >= 1"); Keys = new ulong[NumberOfRecords]; Pointer = new ulong[NumberOfRecords]; for (int i = 0; i < NumberOfRecords; i++) { Keys[i] = EndianUtilities.ToUInt64BigEndian(buffer, offset + i * 0x8); } offset += ((buffer.Length - offset) / 16) * 8; for (int i = 0; i < NumberOfRecords; i++) { Pointer[i] = EndianUtilities.ToUInt64BigEndian(buffer, offset + i * 0x8); } return Size; }
public virtual int ReadFrom(byte[] buffer, int offset) { Magic = EndianUtilities.ToUInt32BigEndian(buffer, offset); Level = EndianUtilities.ToUInt16BigEndian(buffer, offset + 0x4); NumberOfRecords = EndianUtilities.ToUInt16BigEndian(buffer, offset + 0x6); LeftSibling = EndianUtilities.ToInt32BigEndian(buffer, offset + 0x8); RightSibling = EndianUtilities.ToInt32BigEndian(buffer, offset + 0xC); if (SbVersion >= 5) { Bno = EndianUtilities.ToUInt64BigEndian(buffer, offset + 0x10); Lsn = EndianUtilities.ToUInt64BigEndian(buffer, offset + 0x18); UniqueId = EndianUtilities.ToGuidBigEndian(buffer, offset + 0x20); Owner = EndianUtilities.ToUInt32BigEndian(buffer, offset + 0x30); Crc = EndianUtilities.ToUInt32BigEndian(buffer, offset + 0x34); } return(Size); }
public int ReadFrom(byte[] buffer, int offset) { Magic = EndianUtilities.ToUInt16BigEndian(buffer, offset); Mode = EndianUtilities.ToUInt16BigEndian(buffer, offset + 0x2); Version = buffer[offset + 0x4]; Format = (InodeFormat)buffer[offset + 0x5]; Onlink = EndianUtilities.ToUInt16BigEndian(buffer, offset + 0x6); UserId = EndianUtilities.ToUInt32BigEndian(buffer, offset + 0x8); GroupId = EndianUtilities.ToUInt32BigEndian(buffer, offset + 0xC); Nlink = EndianUtilities.ToUInt32BigEndian(buffer, offset + 0x10); ProjectId = EndianUtilities.ToUInt16BigEndian(buffer, offset + 0x14); Padding = EndianUtilities.ToByteArray(buffer, offset + 0x16, 8); FlushIterator = EndianUtilities.ToUInt16BigEndian(buffer, 0x1E); AccessTime = ReadTimestamp(buffer, offset + 0x20); ModificationTime = ReadTimestamp(buffer, offset + 0x28); CreationTime = ReadTimestamp(buffer, offset + 0x30); Length = EndianUtilities.ToUInt64BigEndian(buffer, offset + 0x38); BlockCount = EndianUtilities.ToUInt64BigEndian(buffer, offset + 0x40); ExtentSize = EndianUtilities.ToUInt32BigEndian(buffer, offset + 0x48); Extents = EndianUtilities.ToUInt32BigEndian(buffer, offset + 0x4C); AttributeExtents = EndianUtilities.ToUInt16BigEndian(buffer, offset + 0x50); Forkoff = buffer[offset + 0x52]; AttributeFormat = (sbyte)buffer[offset + 0x53]; DmApiEventMask = EndianUtilities.ToUInt32BigEndian(buffer, offset + 0x54); DmState = EndianUtilities.ToUInt16BigEndian(buffer, offset + 0x58); Flags = (InodeFlags)EndianUtilities.ToUInt16BigEndian(buffer, offset + 0x5A); Generation = EndianUtilities.ToUInt32BigEndian(buffer, offset + 0x5C); var dfOffset = Version < 3 ? 0x64 : 0xb0; int dfLength; if (Forkoff == 0) { dfLength = buffer.Length - offset - dfOffset; } else { dfLength = (Forkoff * 8); } DataFork = EndianUtilities.ToByteArray(buffer, offset + dfOffset, dfLength); return(Size); }
public void Parse(byte[] headerData, int headerOffset, byte[] bodyData) { BasicHeaderSegment _headerSegment = new BasicHeaderSegment(); _headerSegment.ReadFrom(headerData, headerOffset); if (_headerSegment.OpCode != OpCode.TextResponse) { throw new InvalidProtocolException("Invalid opcode in response, expected " + OpCode.TextResponse + " was " + _headerSegment.OpCode); } Continue = (headerData[headerOffset + 1] & 0x40) != 0; _lun = EndianUtilities.ToUInt64BigEndian(headerData, headerOffset + 8); _targetTransferTag = EndianUtilities.ToUInt32BigEndian(headerData, headerOffset + 20); StatusSequenceNumber = EndianUtilities.ToUInt32BigEndian(headerData, headerOffset + 24); ExpectedCommandSequenceNumber = EndianUtilities.ToUInt32BigEndian(headerData, headerOffset + 28); MaxCommandSequenceNumber = EndianUtilities.ToUInt32BigEndian(headerData, headerOffset + 32); TextData = bodyData; }
public int ReadFrom(byte[] buffer, int offset) { this.Signature = EndianUtilities.ToUInt32BigEndian(buffer, offset + 0); this.InfoVersion = EndianUtilities.ToUInt32BigEndian(buffer, offset + 4); this.FirstSector = EndianUtilities.ToInt64BigEndian(buffer, offset + 8); this.SectorCount = EndianUtilities.ToInt64BigEndian(buffer, offset + 16); this.DataStart = EndianUtilities.ToUInt64BigEndian(buffer, offset + 24); this.DecompressBufferRequested = EndianUtilities.ToUInt32BigEndian(buffer, offset + 32); this.BlocksDescriptor = EndianUtilities.ToUInt32BigEndian(buffer, offset + 36); this.CheckSum = EndianUtilities.ToStruct <UdifChecksum>(buffer, offset + 60); this.Runs = new List <CompressedRun>(); int numRuns = EndianUtilities.ToInt32BigEndian(buffer, offset + 200); for (int i = 0; i < numRuns; ++i) { this.Runs.Add(EndianUtilities.ToStruct <CompressedRun>(buffer, offset + 204 + (i * 40))); } return(0); }
public int ReadFrom(byte[] buffer, int offset) { Magic = EndianUtilities.ToUInt16BigEndian(buffer, offset); Mode = EndianUtilities.ToUInt16BigEndian(buffer, offset + 0x2); Version = buffer[offset + 0x4]; Format = (InodeFormat)buffer[offset + 0x5]; Onlink = EndianUtilities.ToUInt16BigEndian(buffer, offset + 0x6); UserId = EndianUtilities.ToUInt32BigEndian(buffer, offset + 0x8); GroupId = EndianUtilities.ToUInt32BigEndian(buffer, offset + 0xC); Nlink = EndianUtilities.ToUInt32BigEndian(buffer, offset + 0x10); ProjectId = EndianUtilities.ToUInt16BigEndian(buffer, offset + 0x14); Padding = EndianUtilities.ToByteArray(buffer, offset + 0x16, 8); FlushIterator = EndianUtilities.ToUInt16BigEndian(buffer, 0x1E); AccessTime = ReadTimestamp(buffer, offset + 0x20); ModificationTime = ReadTimestamp(buffer, offset + 0x28); CreationTime = ReadTimestamp(buffer, offset + 0x30); Length = EndianUtilities.ToUInt64BigEndian(buffer, offset + 0x38); BlockCount = EndianUtilities.ToUInt64BigEndian(buffer, offset + 0x40); ExtentSize = EndianUtilities.ToUInt32BigEndian(buffer, offset + 0x48); Extents = EndianUtilities.ToUInt32BigEndian(buffer, offset + 0x4C); AttributeExtents = EndianUtilities.ToUInt16BigEndian(buffer, offset + 0x50); Forkoff = buffer[offset + 0x52]; AttributeFormat = (sbyte)buffer[offset + 0x53]; DmApiEventMask = EndianUtilities.ToUInt32BigEndian(buffer, offset + 0x54); DmState = EndianUtilities.ToUInt16BigEndian(buffer, offset + 0x58); Flags = (InodeFlags)EndianUtilities.ToUInt16BigEndian(buffer, offset + 0x5A); Generation = EndianUtilities.ToUInt32BigEndian(buffer, offset + 0x5C); int DataForkStartOffset = 0x64; if (Version == 3) { DataForkStartOffset = 0xb0; } //var dfLength = (Forkoff*8) - DataForkStartOffset;//Extended atributes come in two versions: ¡°atr1¡± or ¡°atr2¡±, this just fit atr2 var dfLength = buffer.Length - offset - DataForkStartOffset;//read all data DataFork = EndianUtilities.ToByteArray(buffer, offset + DataForkStartOffset, dfLength); return(Size); }
public void Parse(byte[] headerData, int headerOffset) { StatusPresent = false; Header = new BasicHeaderSegment(); Header.ReadFrom(headerData, headerOffset); if (Header.OpCode != OpCode.ReadyToTransfer) { throw new InvalidProtocolException("Invalid opcode in response, expected " + OpCode.ReadyToTransfer + " was " + Header.OpCode); } Lun = EndianUtilities.ToUInt64BigEndian(headerData, headerOffset + 8); TargetTransferTag = EndianUtilities.ToUInt32BigEndian(headerData, headerOffset + 20); StatusSequenceNumber = EndianUtilities.ToUInt32BigEndian(headerData, headerOffset + 24); ExpectedCommandSequenceNumber = EndianUtilities.ToUInt32BigEndian(headerData, headerOffset + 28); MaxCommandSequenceNumber = EndianUtilities.ToUInt32BigEndian(headerData, headerOffset + 32); ReadyToTransferSequenceNumber = EndianUtilities.ToUInt32BigEndian(headerData, headerOffset + 36); BufferOffset = EndianUtilities.ToUInt32BigEndian(headerData, headerOffset + 40); DesiredTransferLength = EndianUtilities.ToUInt32BigEndian(headerData, headerOffset + 44); }
public override int ReadFrom(byte[] buffer, int offset) { Inode = EndianUtilities.ToUInt64BigEndian(buffer, offset); NameLength = buffer[offset + 0x8]; Name = EndianUtilities.ToByteArray(buffer, offset + 0x9, NameLength); offset += 0x9 + NameLength; if (_ftype) { FType = (DirectoryFType)buffer[offset]; offset++; } var padding = 6 - ((NameLength + (_ftype ? 2 : 1)) % 8); if (padding < 0) { padding += 8; } offset += padding; Tag = EndianUtilities.ToUInt16BigEndian(buffer, offset); return(Size); }
public override int ReadFrom(byte[] buffer, int offset) { if (sb_ok == false) { throw new IOException("not initial SuperBlock"); } Inode = EndianUtilities.ToUInt64BigEndian(buffer, offset); NameLength = buffer[offset + 0x8]; Name = EndianUtilities.ToByteArray(buffer, offset + 0x9, NameLength); /* according to linux kernel * static inline int xfs_sb_version_hasftype(struct xfs_sb *sbp) * { * return (XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_5 && * xfs_sb_has_incompat_feature(sbp, XFS_SB_FEAT_INCOMPAT_FTYPE)) || * (xfs_sb_version_hasmorebits(sbp) && * (sbp->sb_features2 & XFS_SB_VERSION2_FTYPE)); * } *******/ if (SuperBlock.SB_hasftype == true) //if( (((SuperBlock.SbVersion == 5) || ((SuperBlock.Version & 0x8000) != 0)) && ((SuperBlock.Features2 & 0x00000200) != 0)) || // ((SuperBlock.SbVersion == 5) && (SuperBlock.IncompatibleFeatures&0x0001)!=0)) { //has ftype in dir inode var padding = 6 - ((NameLength + 1 + 1) % 8); //skip ftype offset += padding; has_ftype = 1; } else { var padding = 6 - ((NameLength + 1) % 8); offset += padding; has_ftype = 0; } Tag = EndianUtilities.ToUInt16BigEndian(buffer, offset + 0x9 + NameLength);//length u16 return(Size); }
public override void ReadFrom(byte[] buffer, int offset, int count) { Luns = new List <ulong>(); if (count == 0) { return; } if (count < 8) { throw new InvalidProtocolException("Data truncated too far"); } _availableLuns = EndianUtilities.ToUInt32BigEndian(buffer, offset) / 8; int pos = 8; while (pos <= count - 8 && Luns.Count < _availableLuns) { Luns.Add(EndianUtilities.ToUInt64BigEndian(buffer, offset + pos)); pos += 8; } }
public int ReadFrom(byte[] buffer, int offset) { Magic = EndianUtilities.ToUInt32BigEndian(buffer, offset); if (Magic != XfsMagic) { return(Size); } Blocksize = EndianUtilities.ToUInt32BigEndian(buffer, offset + 0x4); DataBlocks = EndianUtilities.ToUInt64BigEndian(buffer, offset + 0x8); RealtimeBlocks = EndianUtilities.ToUInt64BigEndian(buffer, offset + 0x10); RealtimeExtents = EndianUtilities.ToUInt64BigEndian(buffer, offset + 0x18); UniqueId = EndianUtilities.ToGuidBigEndian(buffer, offset + 0x20); Logstart = EndianUtilities.ToUInt64BigEndian(buffer, offset + 0x30); RootInode = EndianUtilities.ToUInt64BigEndian(buffer, offset + 0x38); RealtimeBitmapInode = EndianUtilities.ToUInt64BigEndian(buffer, offset + 0x40); RealtimeSummaryInode = EndianUtilities.ToUInt64BigEndian(buffer, offset + 0x48); RealtimeExtentSize = EndianUtilities.ToUInt32BigEndian(buffer, offset + 0x50); AgBlocks = EndianUtilities.ToUInt32BigEndian(buffer, offset + 0x54); AgCount = EndianUtilities.ToUInt32BigEndian(buffer, offset + 0x58); RealtimeBitmapBlocks = EndianUtilities.ToUInt32BigEndian(buffer, offset + 0x5C); LogBlocks = EndianUtilities.ToUInt32BigEndian(buffer, offset + 0x60); Version = (VersionFlags)EndianUtilities.ToUInt16BigEndian(buffer, offset + 0x64); SectorSize = EndianUtilities.ToUInt16BigEndian(buffer, offset + 0x66); InodeSize = EndianUtilities.ToUInt16BigEndian(buffer, offset + 0x68); InodesPerBlock = EndianUtilities.ToUInt16BigEndian(buffer, offset + 0x6A); FilesystemName = EndianUtilities.BytesToZString(buffer, offset + 0x6C, 12); BlocksizeLog2 = buffer[offset + 0x78]; SectorSizeLog2 = buffer[offset + 0x79]; InodeSizeLog2 = buffer[offset + 0x7A]; InodesPerBlockLog2 = buffer[offset + 0x7B]; AgBlocksLog2 = buffer[offset + 0x7C]; RealtimeExtentsLog2 = buffer[offset + 0x7D]; InProgress = buffer[offset + 0x7E]; InodesMaxPercent = buffer[offset + 0x7F]; AllocatedInodes = EndianUtilities.ToUInt64BigEndian(buffer, offset + 0x80); FreeInodes = EndianUtilities.ToUInt64BigEndian(buffer, offset + 0x88); FreeDataBlocks = EndianUtilities.ToUInt64BigEndian(buffer, offset + 0x90); FreeRealtimeExtents = EndianUtilities.ToUInt64BigEndian(buffer, offset + 0x98); UserQuotaInode = EndianUtilities.ToUInt64BigEndian(buffer, offset + 0xA0); GroupQuotaInode = EndianUtilities.ToUInt64BigEndian(buffer, offset + 0xA8); QuotaFlags = EndianUtilities.ToUInt16BigEndian(buffer, offset + 0xB0); Flags = buffer[offset + 0xB2]; SharedVersionNumber = buffer[offset + 0xB3]; InodeChunkAlignment = EndianUtilities.ToUInt32BigEndian(buffer, offset + 0xB4); Unit = EndianUtilities.ToUInt32BigEndian(buffer, offset + 0xB8); Width = EndianUtilities.ToUInt32BigEndian(buffer, offset + 0xBC); DirBlockLog2 = buffer[offset + 0xC0]; LogSectorSizeLog2 = buffer[offset + 0xC1]; LogSectorSize = EndianUtilities.ToUInt16BigEndian(buffer, offset + 0xC2); LogUnitSize = EndianUtilities.ToUInt32BigEndian(buffer, offset + 0xC4); Features2 = (Version2Features)EndianUtilities.ToUInt32BigEndian(buffer, offset + 0xC8); BadFeatures2 = EndianUtilities.ToUInt32BigEndian(buffer, offset + 0xCC); if (SbVersion >= (ushort)VersionFlags.Version5) { CompatibleFeatures = EndianUtilities.ToUInt32BigEndian(buffer, offset + 0xD0); ReadOnlyCompatibleFeatures = (ReadOnlyCompatibleFeatures)EndianUtilities.ToUInt32BigEndian(buffer, offset + 0xD4); IncompatibleFeatures = (IncompatibleFeatures)EndianUtilities.ToUInt32BigEndian(buffer, offset + 0xD8); LogIncompatibleFeatures = EndianUtilities.ToUInt32BigEndian(buffer, offset + 0xDC); Crc = EndianUtilities.ToUInt32BigEndian(buffer, offset + 0xE0); SparseInodeAlignment = EndianUtilities.ToUInt32BigEndian(buffer, offset + 0xE4); ProjectQuotaInode = EndianUtilities.ToUInt64BigEndian(buffer, offset + 0xE8); Lsn = EndianUtilities.ToInt64BigEndian(buffer, offset + 0xF0); MetaUuid = EndianUtilities.ToGuidBigEndian(buffer, offset + 0xF8); if ((IncompatibleFeatures & IncompatibleFeatures.Supported) != IncompatibleFeatures.Supported) { throw new NotSupportedException("XFS Features not supported"); } } var agOffset = AgBlocksLog2 + InodesPerBlockLog2; RelativeInodeMask = 0xffffffff >> (32 - agOffset); AgInodeMask = ~RelativeInodeMask; DirBlockSize = Blocksize << DirBlockLog2; return(Size); }
protected static ulong ReadULong(byte[] buffer, ref int offset) { offset += 8; return(EndianUtilities.ToUInt64BigEndian(buffer, offset - 8)); }