示例#1
0
        public void Format()
        {
            // Setup superblock
            Array.Clear(_tmpBuffer, 0, BlockSize);
            Encoding.ASCII.GetBytes(HeaderMagic).CopyTo(_tmpBuffer, 0);
            BitConverter.GetBytes((int)0).CopyTo(_tmpBuffer, HeaderMagic.Length);
            Source.WriteAll(0, _tmpBuffer, 0, BlockSize);
            _superBlock = Superblock.ReadFrom(_tmpBuffer);

            // Setup block bitmap
            byte[] tmpBuffer = new byte[BlockSize];
            Source.WriteAll(BlockSize * 1, tmpBuffer, 0, BlockSize);

            // Clear inode bitmap
            BitArray inodeBitmap = new BitArray(tmpBuffer);

            inodeBitmap[0] = true;
            inodeBitmap.CopyTo(tmpBuffer, 0);
            Source.WriteAll(BlockSize * 2, tmpBuffer, 0, BlockSize);

            // Create root directory
            BobFsNode root = new BobFsNode(this, 0);

            root.Type     = ENodeType.Directory;
            root.NumLinks = 1;
            root.Size     = 0;
            root.Commit();
        }
示例#2
0
        private BobFs(BlockSource source, bool caching = true)
        {
            Source   = source;
            _caching = caching;

            _tmpBuffer = new byte[BlockSize];
            Source.ReadAll(0, _tmpBuffer, 0, BlockSize);
            _superBlock = Superblock.ReadFrom(_tmpBuffer);
        }