writing the kernel to the second sector of the floppy

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
rutix
Posts: 8
Joined: Fri Jul 04, 2008 8:24 pm

writing the kernel to the second sector of the floppy

Post by rutix »

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...

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);

}
can anyone tell me if there is a problem with this code, or suggest me a program...

thanks
User avatar
milyges
Member
Member
Posts: 40
Joined: Fri Nov 03, 2006 1:48 pm
Location: Poland
Contact:

Re: writing the kernel to the second sector of the floppy

Post by milyges »

Use dd

Code: Select all

dd if=kernel.bin of=/dev/fd0 bs=512 skip=1
(or something like this, read man dd)
Post Reply