writing the kernel to the second sector of the floppy
Posted: Tue Jul 22, 2008 1:00 pm
i don't know why my kernel doesn't want to start and i think i m not writing the kernel file to the second sector correctly.
here is the code...
can anyone tell me if there is a problem with this code, or suggest me a program...
thanks
here is the code...
Code: Select all
#include <sys/types.h>
#include <unistd.h>
#include <fcntl.h>
#include <stdio.h>
int main(){
char file_name[20];
char kernel_buf[512];
int floppy_desc, file_desc;
printf("input file: ");
scanf("%20s", file_name);
file_desc = open(file_name, O_RDONLY);
read(file_desc, boot_buf, 512);
close(file_desc);
floppy_desc = open("/dev/fd0", O_RDWR);
lseek(floppy_desc, 512, SEEK_SET);
write(floppy_desc, boot_buf, 512);
if(floppy_desc == -1)
perror("write");
close(floppy_desc);
}
thanks