The k project

File system

Description

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

NAME
    open, read, seek, close - manipulate the filesystem
SYNOPSIS
    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);
DESCRIPTION
    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
    supported).

    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
       bytes.
       SEEK END: the cursor is set to the size of the file plus offset
       bytes.

    close() closes the file descriptor fd, so that it no longer refers to
    any file.
RETURN VALUE
    open() returns the new unique file descriptor, or -1 if an error
    occured.
    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.
NOTES
    There are no standard file descriptors like STDIN FILENO.
SEE ALSO
    Useful constants are defined in k/kstd.h