Following lots of "How to build your own Operating system" tutorials,
I m supposed to write custom loader to floppy disk boot sector via
#include <sys/types.h> /* unistd.h needs this */
#include <unistd.h> /* contains read/write */
#include <fcntl.h>
int main()
{
char boot_buf[512];
int floppy_desc, file_desc;
file_desc = open("./boot", O_RDONLY);
read(file_desc, boot_buf, 510);
close(file_desc);
boot_buf[510] = 0x55;
boot_buf[511] = 0xaa;
floppy_desc = open("/dev/fd0", O_RDWR);
lseek(floppy_desc, 0, SEEK_CUR);
write(floppy_desc, boot_buf, 512);
close(floppy_desc);
}
我没有带软盘的电脑, 我更喜欢尝试整个项目 在虚拟机器上通过虚拟Box。
So How to write custom boot sector to a virtual CD image that will be invoked by my virtual machine ? :)
If you have any alternative way please suggest it :)