示例#1
0
 public static DirectoryHeader ReadFrom(MetablockReader reader)
 {
     DirectoryHeader result = new DirectoryHeader();
     result.Count = reader.ReadInt();
     result.StartBlock = reader.ReadInt();
     result.InodeNumber = reader.ReadInt();
     return result;
 }
示例#2
0
        public static DirectoryHeader ReadFrom(MetablockReader reader)
        {
            DirectoryHeader result = new DirectoryHeader();

            result.Count       = reader.ReadInt();
            result.StartBlock  = reader.ReadInt();
            result.InodeNumber = reader.ReadInt();
            return(result);
        }
        private int GetId(ushort idKey)
        {
            int recordsPerBlock = MetadataBufferSize / 4;
            int block = idKey / recordsPerBlock;
            int offset = idKey % recordsPerBlock;

            MetablockReader reader = _context.UidGidTableReaders[block];
            reader.SetPosition(0, offset * 4);
            return reader.ReadInt();
        }
示例#4
0
        public static DirectoryRecord ReadFrom(MetablockReader reader)
        {
            DirectoryRecord result = new DirectoryRecord();
            result.Offset = reader.ReadUShort();
            result.InodeNumber = reader.ReadShort();
            result.Type = (InodeType)reader.ReadUShort();
            ushort size = reader.ReadUShort();
            result.Name = reader.ReadString(size + 1);

            return result;
        }
示例#5
0
        public static DirectoryRecord ReadFrom(MetablockReader reader)
        {
            DirectoryRecord result = new DirectoryRecord();

            result.Offset      = reader.ReadUShort();
            result.InodeNumber = reader.ReadShort();
            result.Type        = (InodeType)reader.ReadUShort();
            ushort size = reader.ReadUShort();

            result.Name = reader.ReadString(size + 1);

            return(result);
        }
示例#6
0
        private MetablockReader[] LoadIndirectReaders(long pos, int count, int recordSize)
        {
            _context.RawStream.Position = pos;
            int numBlocks = MathUtilities.Ceil(count * recordSize, MetadataBufferSize);

            byte[]            tableBytes = StreamUtilities.ReadFully(_context.RawStream, numBlocks * 8);
            MetablockReader[] result     = new MetablockReader[numBlocks];
            for (int i = 0; i < numBlocks; ++i)
            {
                long block = EndianUtilities.ToInt64LittleEndian(tableBytes, i * 8);
                result[i] = new MetablockReader(_context, block);
            }

            return(result);
        }
示例#7
0
        public static Inode Read(MetablockReader inodeReader)
        {
            byte[] typeData = new byte[2];
            if (inodeReader.Read(typeData, 0, 2) != 2)
            {
                throw new IOException("Unable to read Inode type");
            }

            InodeType type  = (InodeType)Utilities.ToUInt16LittleEndian(typeData, 0);
            Inode     inode = InstantiateType(type);

            byte[] inodeData = new byte[inode.Size];
            inodeData[0] = typeData[0];
            inodeData[1] = typeData[1];

            if (inodeReader.Read(inodeData, 2, inode.Size - 2) != inode.Size - 2)
            {
                throw new IOException("Unable to read whole Inode");
            }

            inode.ReadFrom(inodeData, 0);

            return(inode);
        }
示例#8
0
        public static Inode Read(MetablockReader inodeReader)
        {
            byte[] typeData = new byte[2];
            if (inodeReader.Read(typeData, 0, 2) != 2)
            {
                throw new IOException("Unable to read Inode type");
            }

            InodeType type = (InodeType)Utilities.ToUInt16LittleEndian(typeData, 0);
            Inode inode = InstantiateType(type);

            byte[] inodeData = new byte[inode.Size];
            inodeData[0] = typeData[0];
            inodeData[1] = typeData[1];

            if (inodeReader.Read(inodeData, 2, inode.Size - 2) != inode.Size - 2)
            {
                throw new IOException("Unable to read whole Inode");
            }

            inode.ReadFrom(inodeData, 0);

            return inode;
        }