Lecture 16

Kernel Korner: The ``Virtual File System'' in Linux
struct super_operations {
        void (*read_inode) (struct inode *);
  
        /* reiserfs kludge.  reiserfs needs 64 bits of information to
        ** find an inode.  We are using the read_inode2 call to get
        ** that information.  We don't like this, and are waiting on some
        ** VFS changes for the real solution.
        ** iget4 calls read_inode2, iff it is defined
        */
        void (*read_inode2) (struct inode *, void *) ;
        void (*dirty_inode) (struct inode *);
        void (*write_inode) (struct inode *, int);
        void (*put_inode) (struct inode *);
        void (*delete_inode) (struct inode *);
        void (*put_super) (struct super_block *);
        void (*write_super) (struct super_block *);
        void (*write_super_lockfs) (struct super_block *);
        void (*unlockfs) (struct super_block *);
        int (*statfs) (struct super_block *, struct statfs *);
        int (*remount_fs) (struct super_block *, int *, char *);
        void (*clear_inode) (struct inode *);
        void (*umount_begin) (struct super_block *);

        /* Following are for knfsd to interact with "interesting" filesystems
         * Currently just reiserfs, but possibly FAT and others later
         *
         * fh_to_dentry is given a filehandle fragement with length, and a type flag
         *   and must return a dentry for the referenced object or, if "parent" is
         *   set, a dentry for the parent of the object.
         *   If a dentry cannot be found, a "root" dentry should be created and
         *   flaged as DCACHE_NFSD_DISCONNECTED. nfsd_iget is an example implementation.
         *
         * dentry_to_fh is given a dentry and must generate the filesys specific
         *   part of the file handle.  Available length is passed in *lenp and used
         *   length should be returned therein.
         *   If need_parent is set, then dentry_to_fh should encode sufficient information
         *   to find the (current) parent.
         *   dentry_to_fh should return a 1byte "type" which will be passed back in
         *   the fhtype arguement to fh_to_dentry.  Type of 0 is reserved.
         *   If filesystem was exportable before the introduction of fh_to_dentry,
         *   types 1 and 2 should be used is that same way as the generic code.
         *   Type 255 means error.
         *
         * Lengths are in units of 4bytes, not bytes.
         */
        struct dentry * (*fh_to_dentry)(struct super_block *sb, __u32 *fh, int len, int fhtype, int parent);
        int (*dentry_to_fh)(struct dentry *, __u32 *fh, int *lenp, int need_parent);
        int (*show_options)(struct seq_file *, struct vfsmount *);
};


struct inode_operations {
        int (*create) (struct inode *,struct dentry *,int);
        struct dentry * (*lookup) (struct inode *,struct dentry *);
        int (*link) (struct dentry *,struct inode *,struct dentry *);
        int (*unlink) (struct inode *,struct dentry *);
        int (*symlink) (struct inode *,struct dentry *,const char *);
        int (*mkdir) (struct inode *,struct dentry *,int);
        int (*rmdir) (struct inode *,struct dentry *);
        int (*mknod) (struct inode *,struct dentry *,int,int);
        int (*rename) (struct inode *, struct dentry *,
                        struct inode *, struct dentry *);
        int (*readlink) (struct dentry *, char *,int);
        int (*follow_link) (struct dentry *, struct nameidata *);
        void (*truncate) (struct inode *);
        int (*permission) (struct inode *, int);
        int (*revalidate) (struct dentry *);
        int (*setattr) (struct dentry *, struct iattr *);
        int (*getattr) (struct dentry *, struct iattr *);
};


from fs.h:



struct file_operations {
        struct module *owner;
        loff_t (*llseek) (struct file *, loff_t, int);
        ssize_t (*read) (struct file *, char *, size_t, loff_t *);
        ssize_t (*write) (struct file *, const char *, size_t, loff_t *);
        int (*readdir) (struct file *, void *, filldir_t);
        unsigned int (*poll) (struct file *, struct poll_table_struct *);
        int (*ioctl) (struct inode *, struct file *, unsigned int, unsigned long);
        int (*mmap) (struct file *, struct vm_area_struct *);
        int (*open) (struct inode *, struct file *);
        int (*flush) (struct file *);
        int (*release) (struct inode *, struct file *);
        int (*fsync) (struct file *, struct dentry *, int datasync);
        int (*fasync) (int, struct file *, int);
        int (*lock) (struct file *, int, struct file_lock *);
        ssize_t (*readv) (struct file *, const struct iovec *, unsigned long, loff_t *);
        ssize_t (*writev) (struct file *, const struct iovec *, unsigned long, loff_t *);
        ssize_t (*sendpage) (struct file *, struct page *, int, size_t, loff_t *, int);
        unsigned long (*get_unmapped_area)(struct file *, unsigned long, unsigned long, unsigned long, unsigned long);
};