Lecture 20

File Operations

The following file operations are defined in three places by Ext3. In file.c:

struct file_operations ext3_file_operations = {
        llseek:         generic_file_llseek,    /* BKL held */
        read:           generic_file_read,      /* BKL not held.  Don't need */
        write:          ext3_file_write,        /* BKL not held.  Don't need */
        ioctl:          ext3_ioctl,             /* BKL held */
        mmap:           generic_file_mmap,
        open:           ext3_open_file,         /* BKL not held.  Don't need */
        release:        ext3_release_file,      /* BKL not held.  Don't need */
        fsync:          ext3_sync_file,         /* BKL held */
};
And in dir.c:
struct file_operations ext3_dir_operations = {
        read:           generic_read_dir,
        readdir:        ext3_readdir,           /* BKL held */
        ioctl:          ext3_ioctl,             /* BKL held */
        fsync:          ext3_sync_file,         /* BKL held */
};
And finally in bad_inode.c:
static struct file_operations bad_file_ops =
{
        llseek:         EIO_ERROR,
        read:           EIO_ERROR,
        write:          EIO_ERROR,
        readdir:        EIO_ERROR,
        poll:           EIO_ERROR,
        ioctl:          EIO_ERROR,
        mmap:           EIO_ERROR,
        open:           EIO_ERROR,
        flush:          EIO_ERROR,
        release:        EIO_ERROR,
        fsync:          EIO_ERROR,
        fasync:         EIO_ERROR,
        lock:           EIO_ERROR,
};
The following are the elements of the file_operations structure: