Next Previous Contents

1. A program

#include <unistd.h>
#include <fcntl.h>
int main(){
        int fd;
        char buf[512];

        fd = open("/dev/hda", O_RDONLY);
        if (fd >= 0)
                read(fd, buf, sizeof(buf));
        return 0;
}

This little program opens the block special device referring to the first IDE disk, and if the open succeeded reads the first sector. What happens in the kernel? Let us read 2.4.0 source.


Next Previous Contents