You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

54 lines
2.3 KiB

  1. How Fuse-1.3 Works
  2. [Written by Terje Oseberg]
  3. 1. The fuse library.
  4. When your user mode program calls fuse_main() (lib/helper.c),
  5. fuse_main() parses the arguments passed to your user mode program,
  6. then calls fuse_mount() (lib/mount.c).
  7. fuse_mount() creates a UNIX domain socket pair, then forks and execs
  8. fusermount (util/fusermount.c) passing it one end of the socket in the
  9. FUSE_COMMFD_ENV environment variable.
  10. fusermount (util/fusermount.c) makes sure that the fuse module is
  11. loaded. fusermount then open /dev/fuse and send the file handle over a
  12. UNIX domain socket back to fuse_mount().
  13. fuse_mount() returns the filehandle for /dev/fuse to fuse_main().
  14. fuse_main() calls fuse_new() (lib/fuse.c) which allocates the struct
  15. fuse datastructure that stores and maintains a cached image of the
  16. filesystem data.
  17. Lastly, fuse_main() calls either fuse_loop() (lib/fuse.c) or
  18. fuse_loop_mt() (lib/fuse_mt.c) which both start to read the filesystem
  19. system calls from the /dev/fuse, call the usermode functions
  20. stored in struct fuse_operations datastructure before calling
  21. fuse_main(). The results of those calls are then written back to the
  22. /dev/fuse file where they can be forwarded back to the system
  23. calls.
  24. 2. The kernel module.
  25. The kernel module consists of two parts. First the proc filesystem
  26. component in kernel/dev.c -and second the filesystem system calls
  27. kernel/file.c, kernel/inode.c, and kernel/dir.c
  28. All the system calls in kernel/file.c, kernel/inode.c, and
  29. kernel/dir.c make calls to either request_send(),
  30. request_send_noreply(), or request_send_nonblock(). Most of the calls
  31. (all but 2) are to request_send(). request_send() adds the request to,
  32. "list of requests" structure (fc->pending), then waits for a response.
  33. request_send_noreply() and request_send_nonblock() are both similar in
  34. function to request_send() except that one is non-blocking, and the
  35. other does not respond with a reply.
  36. The proc filesystem component in kernel/dev.c responds to file io
  37. requests to the file /dev/fuse. fuse_dev_read() handles the
  38. file reads and returns commands from the "list of requests" structure
  39. to the calling program. fuse_dev_write() handles file writes and takes
  40. the data written and places them into the req->out datastructure where
  41. they can be returned to the system call through the "list of requests"
  42. structure and request_send().