private void boot() { Stream stream = new FileStream("block.dat", FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.ReadWrite); if (0 == stream.Length) { superBlock superblock = new superBlock(1024, 4096); dataBlock block = new dataBlock(); block.data = superblock; datablock[0] = block; initBoot(); ((blockBitmap)datablock[2].data).findUnuse(1); } inode root = new inode(); List <int> b = new List <int>(); b.Add(4); root.init(0, b, "文件夹", DateTime.Now); ((inode[])datablock[3].data)[0] = root; dataBlock data = new dataBlock(); ((blockBitmap)datablock[2].data).findUnuse(4); List <int> nodes = ((inodeBitmap)datablock[1].data).findUnuse(1); datablock[4] = new dataBlock(); datablock[4].createInode("..", -1); datablock[4].createInode(".", nodes[0]); IOFormatter.getInstance().Serialize(IOStream.getInstance(), datablock); }
private void initBoot() { superBlock superblock = (superBlock)datablock[0].data; inode[] node = new inode[superblock.nodeNum]; blockBitmap blockMap = new blockBitmap(superblock.blockNum); inodeBitmap nodeMap = new inodeBitmap(superblock.nodeNum); datablock[1] = new dataBlock(); datablock[1].data = nodeMap; datablock[2] = new dataBlock(); datablock[2].data = blockMap; datablock[3] = new dataBlock(); datablock[3].data = node; }
private void initBoot() { Stream stream = new FileStream("super.dat", FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.ReadWrite); if (0 == stream.Length) { superBlock superblock = new superBlock(1024, 4096); dataBlock boot = new dataBlock(); boot.data = superblock; datablock = new dataBlock[4096]; node = new inode[1024]; blockMap.findUnuse(1); datablock[0] = boot; } inode root = new inode(); List <int> b = new List <int>(); b.Add(4); root.init(0, b, "文件夹", DateTime.Now); node[0] = root; dataBlock data = new dataBlock(); blockMap.findUnuse(4); List <int> nodes = nodeMap.findUnuse(1); datablock[1] = new dataBlock(); datablock[1].data = nodeMap; datablock[2] = new dataBlock(); datablock[2].data = blockMap; datablock[3] = new dataBlock(); datablock[3].data = node; datablock[4] = new dataBlock(); initDir(4, -1, nodes[0]); IOFormatter.getInstance().Serialize(IOStream.getInstance(), datablock); }