collaborative-system / tea

Team Editing Advance Tools
0 stars 0 forks source link

Flush fuse operation #24

Open mati2251 opened 2 weeks ago

mati2251 commented 2 weeks ago

Documentation description

        /** Possibly flush cached data
     *
     * BIG NOTE: This is not equivalent to fsync().  It's not a
     * request to sync dirty data.
     *
     * Flush is called on each close() of a file descriptor, as opposed to
     * release which is called on the close of the last file descriptor for
     * a file.  Under Linux, errors returned by flush() will be passed to 
     * userspace as errors from close(), so flush() is a good place to write
     * back any cached dirty data. However, many applications ignore errors 
     * on close(), and on non-Linux systems, close() may succeed even if flush()
     * returns an error. For these reasons, filesystems should not assume
     * that errors returned by flush will ever be noticed or even
     * delivered.
     *
     * NOTE: The flush() method may be called more than once for each
     * open().  This happens if more than one file descriptor refers to an
     * open file handle, e.g. due to dup(), dup2() or fork() calls.  It is
     * not possible to determine if a flush is final, so each flush should
     * be treated equally.  Multiple write-flush sequences are relatively
     * rare, so this shouldn't be a problem.
     *
     * Filesystems shouldn't assume that flush will be called at any
     * particular point.  It may be called more times than expected, or not
     * at all.
     *
     * [close]: http://pubs.opengroup.org/onlinepubs/9699919799/functions/close.html
     */
    int (*flush) (const char *, struct fuse_file_info *);

General instructions on where to implement the fuse method

each point should contain two new types, request and response

  1. In the proto/messages.proto file
    • add two new types and two new messages to enum
  2. In common/io.h
    • Add new recv handlers:
  3. In common/io.cpp
    • Add new types to switch within recv_handler
  4. In server/fs.cpp
    • Add new request handler
    • Add new handlers to recv_handlers
  5. In filesystem/tcp.cpp
    • Add new handlers to recv_handlers
  6. In filesystem/fs.cpp
    • implement your fuse method
mati2251 commented 1 day ago

For the present purpose, flush is useless, so I implement an empty function.