Example #1
0
        /// <summary>
        /// 设置普通文件的inode
        /// </summary>
        protected override void SetCommonFileInode()
        {
            base.SetCommonFileInode();
            _fileInode._i_mode = (uint)(File.IALLOC | IREAD | IWRITE | IEXEC | (IREAD >> 3) | (IWRITE >> 3) | (IEXEC >> 3) | (IREAD >> 6) | (IWRITE >> 6) | (IEXEC >> 6));

            if (_origFile.FileName.Length != 0)
            {
                if (!_origFile.OpenFile())
                {
                    Error.ErrorType = Error.ORIGFILEERROR;
                    return;
                }
                _fileInode._i_size = (int)(_origFile.ReturnFileLength());
                //写文件
                WriteFileItem();
                _origFile.CloseFile();
            }
        }
Example #2
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();
        }
Example #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();
        }