The k project

File system


You will have to implement a basic file system in order to read data from the ROM.

The file system used in K is called KFS (for K File System) which is a read-only file system, no support for writing is asked.

The KFS superblock can be found on the first block of the module loaded by grub at boot. You do not need to write any disk driver to read the filesystem from the floppy or disk.

Syscall interface

    open, read, seek, close - manipulate the filesystem
    int open(const char *pathname, int flags);
    ssize_t read(int fd, void *buf, size_t count);
    off_t seek(int fd, off_t offset, int whence);
    int close(int fd);
    Given a pathname for a file, open() returns a file descriptor for use in
    subsequent system calls (read, seek, close). The parameter flags must be
    set to O RDONLY to open the file in read-only mode (the only one mode

    read() attempts to read up to count bytes from file descriptor fd into
    the buffer starting at buf.

    seek() repositions the reading cursor of the open file associated with
    the file descriptor filedes to the argument offset according to the
    directive whence as follow:
       SEEK SET: the cursor is set to offset bytes.
       SEEK CUR: the cursor is set to its current location plus offset
       SEEK END: the cursor is set to the size of the file plus offset

    close() closes the file descriptor fd, so that it no longer refers to
    any file.
    open() returns the new unique file descriptor, or -1 if an error
    read() returns the number of bytes read, or -1 if an error occured.
    seek() returns the new resulting offset location as measured in bytes
    from the beginning of the file. Otherwise, a value of (off t)-1 on
    error.  close() returns 0 on success, or -1 on error.
    There are no standard file descriptors like STDIN FILENO.
    Useful constants are defined in k/kstd.h