Rootdir = ~/Courses/c4029/lectures/Filesystems/Fuse/fuse-tutorial/fuse-2.9.3

1. Show Rootdir/include/fuse.h -
   file_operations - describes functions that are ops on files
   for 'struct stat' see /usr/include/bits/stat.h
   for mode_t and dev_t see /usr/include/sys/stat.h
   documents the 'main' function

2. Show Rootdir/lib/fuse.c -
   Note 
    static struct fuse_lowlevel_ops fuse_path_ops = {
       .init = fuse_lib_init,
       .destroy = fuse_lib_destroy,
       .lookup = fuse_lib_lookup,
       .forget = fuse_lib_forget,
       .forget_multi = fuse_lib_forget_multi,
       .getattr = fuse_lib_getattr,
       .setattr = fuse_lib_setattr,
       .access = fuse_lib_access,
       .readlink = fuse_lib_readlink,
       .mknod = fuse_lib_mknod,
       ...
    }
   and
    static void fuse_lib_init(void *data, struct fuse_conn_info *conn) { }
   calls
    void fuse_fs_init(struct fuse_fs *fs, struct fuse_conn_info *conn)
   where  'data' is cast to 'struct fuse *' and 
    struct fuse {  /* defined in Rootdir/lib/fuse.c */
       struct fuse_session *se;
       struct node_table name_table;
       struct node_table id_table;
       struct list_head lru_table;
       fuse_ino_t ctr;
       unsigned int generation;
       unsigned int hidectr;
       pthread_mutex_t lock;
       struct fuse_config conf;
       int intr_installed;
       struct fuse_fs *fs;
       int nullpath_ok;
       int utime_omit_ok;
       struct lock_queue_element *lockq;
       int pagesize;
       struct list_head partial_slabs;
       struct list_head full_slabs;
       pthread_t prune_thread;
    };
   and
    struct fuse_conn_info {  /* defined in Rootdir/include/fuse_common.h */
       unsigned proto_major;
       unsigned proto_minor;
       unsigned async_read;
       unsigned max_write;
       unsigned max_readahead;
       unsigned capable;
       unsigned want;
       unsigned max_background;
       unsigned congestion_threshold;
       unsigned reserved[23];
    };
   and
    struct fuse_fs {   /* defined in Rootdir/lib/fuse.c  */
       struct fuse_operations op;
       struct fuse_module *m;
       void *user_data;
       int compat;
       int debug;
    };


3. Compiling: pkg-config fuse --cflags --libs produces compiler args 
   from /usr/lib/pkgconfig/fuse.pc

4. Cd to Rootdir/example
   Note: 'ls mountdir' returns nothing
         'ls rootdir' returns bogus.txt with contents: 'a bogus file'
   Run from 'Rootdir/example': ../src/bbfs rootdir mountdir
   operations are logged in bbfs.log
   bogus.txt appears in both rootdir and mountdir
   Run: mount
   bbfs on /home/franco/Courses/c4029/lectures/FileSystem/Fuse/fuse-tutorial/example/mountdir type fuse.bbfs (rw,nosuid,nodev,relatime,user_id=500,group_id=500)
   Run anything on the file - watch the logs.
   Run: fusermount -u mountdir
   to unmount - fusermount is supplied with fuse
   Do the above from any root directory that does not include the
   mount directory

5. Consider bb_open:
   uses 'struct fuse_file_info' /* defined in fuse_common.h */
    struct fuse_file_info {
       int flags; // Available in open() and release() 
       unsigned long fh_old; // Old file handle, don't use
       int writepage;  // Is this caused by a write operation?
       unsigned int direct_io : 1;  // open may change this 
       unsigned int keep_cache : 1; // open may change this
       unsigned int flush : 1;
       unsigned int nonseekable : 1;  // open may change this
       unsigned int flock_release : 1;  // release may use this
       unsigned int padding : 27;  // do not change
       uint64_t fh;   // file handle - open sets this, can be used elsewhere
       uint64_t lock_owner; // lock owner - used in locking and flush ops
    };
   and 
   bb_read

6. look at main (which calls fuse_main)

7. look at log.c -
   look at struct fuse_context in Rootdir/fuse-9.2.2/include/fuse.h

     struct fuse_context {
        struct fuse *fuse;    /** Pointer to the fuse object */
        uid_t uid;            /** User ID of the calling process */
        gid_t gid;            /** Group ID of the calling process */
        pid_t pid;            /** Thread ID of the calling process */
        void *private_data;   /** Private filesystem data */
        mode_t umask;         /** Umask of the calling process */
     };

8. look at readdir in bbfs.c - notice the filler function

9. look at flags article in tutorial (unclear.html)