Example #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);
        }
Example #2
0
        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());
        }
Example #3
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);
        }
Example #4
0
        private MetablockReader[] LoadIndirectReaders(long pos, int count, int recordSize)
        {
            _context.RawStream.Position = pos;
            int numBlocks = (int)Utilities.Ceil(count * recordSize, MetadataBufferSize);

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

            return(result);
        }
Example #5
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);
        }