Exemple #1
0
        /// <summary>

        /// 将编译好的启动文件boot.bin按规定写入磁盘
        /// </summary>
        public void WriteBootBlock()
        {
            int bootSize = MachinePara.Boot_Size * MachinePara.Block_Size;

            byte[] writeTo = new byte[bootSize];

            //读取boot.bin
            _bootFile.OpenFile();
            _bootFile.SeekFilePosition(0, System.IO.SeekOrigin.Begin);
            _bootFile.ReadFile(ref writeTo, 0, 512);
            _bootFile.CloseFile();

            //写入c.img
            _diskFile.OpenFile();
            _diskFile.SeekFilePosition(0, System.IO.SeekOrigin.Begin);
            _diskFile.WriteFile(ref writeTo, 0, bootSize);
            _diskFile.CloseFile();
        }
Exemple #2
0
        /// <summary>
        /// 写入文件项
        /// </summary>
        private void WriteFileItem()
        {
            int blockNum, i;

            byte[] readFrom = new byte[512];

            int fileLength = (int)_origFile.ReturnFileLength();

            blockNum = fileLength / 512 + ((fileLength % 512 == 0) ? 0 : 1);

            _origFile.SeekFilePosition(0, System.IO.SeekOrigin.Begin);
            for (i = 0; i < blockNum - 1; ++i)
            {
                _origFile.ReadFile(ref readFrom, 0, 512);
                WriteStream(readFrom, i * 512, 512, _fileInode);
            }
            _origFile.ReadFile(ref readFrom, 0, _fileInode._i_size % 512);
            WriteStream(readFrom, i * 512, _fileInode._i_size % 512, _fileInode);
        }
Exemple #3
0
        /// <summary>
        /// 将编译好的内核kernel.bin文件按规定写入磁盘
        /// </summary>
        public void WriteKernelBlock()
        {
            _kernelFile.OpenFile();
            int kernelFileLength = (int)_kernelFile.ReturnFileLength();

            byte[] writeTo;
            writeTo = new byte[kernelFileLength];

            //读出kernel.bin文件的内容
            _kernelFile.SeekFilePosition(0, System.IO.SeekOrigin.Begin);
            _kernelFile.ReadFile(ref writeTo, 0, kernelFileLength);
            _kernelFile.CloseFile();

            //将kernel.bin的内容写入c.img
            _diskFile.OpenFile();
            _diskFile.SeekFilePosition(1 * 512, System.IO.SeekOrigin.Begin);
            _diskFile.WriteFile(ref writeTo, 0, kernelFileLength);
            _diskFile.CloseFile();
        }