public VfsXfsFileSystem(Stream stream, FileSystemParameters parameters) : base(new XfsFileSystemOptions(parameters)) { stream.Position = 0; byte[] superblockData = Utilities.ReadFully(stream, 264); SuperBlock superblock = new SuperBlock(); superblock.ReadFrom(superblockData, 0); if (superblock.Magic != SuperBlock.XfsMagic) { throw new IOException("Invalid superblock magic - probably not an xfs file system"); } Context = new Context { RawStream = stream, SuperBlock = superblock, Options = (XfsFileSystemOptions)Options }; var allocationGroups = new AllocationGroup[superblock.AgCount]; long offset = 0; for (int i = 0; i < allocationGroups.Length; i++) { var ag = new AllocationGroup(Context, offset); allocationGroups[ag.InodeBtreeInfo.SequenceNumber] = ag; offset += ag.FreeBlockInfo.Length * superblock.Blocksize; } Context.AllocationGroups = allocationGroups; RootDirectory = new Directory(Context, Context.GetInode(superblock.RootInode)); }
public Inode GetInode(ulong number) { var inode = new Inode(number, this); AllocationGroup group = AllocationGroups[inode.AllocationGroup]; group.LoadInode(inode); if (inode.Magic != Inode.InodeMagic) { throw new IOException("invalid inode magic"); } return(inode); }
public override void LoadBtree(AllocationGroup ag) { Children = new Dictionary <uint, BtreeHeader>(NumberOfRecords); for (int i = 0; i < NumberOfRecords; i++) { BtreeHeader child; if (Level == 1) { child = new BTreeInodeLeave(); } else { child = new BTreeInodeNode(); } var data = ag.Context.RawStream; data.Position = (Pointer[i] * ag.Context.SuperBlock.Blocksize) + ag.Offset; var buffer = Utilities.ReadFully(data, (int)ag.Context.SuperBlock.Blocksize); child.ReadFrom(buffer, 0); child.LoadBtree(ag); Children.Add(Keys[i], child); } }
public abstract void LoadBtree(AllocationGroup ag);
public override void LoadBtree(AllocationGroup ag) { }