Fuse workflow official documentation

Source: Internet
Author: User
Tags unix domain socket

How fuse-1.3 works

[This document is a bit old, but it is enough for anyone who knows how fuse works.]
[Written by Terje Oseberg]
1. the fuse library.

When your user mode program CILSFuse_main ()(LIB/helper. c), fuse_main () parses the arguments passed to your user mode program, then CILSFuse_mount ()(LIB/mount. C ).

Fuse_mount () creates a Unix domain socket pair, then forks and execsFusermount(Util/fusermount. c) passing it one end of the socket inFuse_commfd_envEnvironment variable.

In fact, not all fuse_mount in the new fuse library will call socketpair () to create a socket. in the new fuse library, if the mount point is accessible to users, the FD used for communication with the fuse of the kernel is actually open ("/dev/fuse ",...) returned descriptor. if the mount point is located at/opt/fuse, socketpair is called to create a socket in the Unix domain.

Fusermount (util/fusermount. c) makes sure that the fuse module is loaded. fusermount then open/dev/fuse and send the file handle over a Unix domain socket back to fuse_mount ().

Fuse_mount () returns the filehandle for/dev/fuse to fuse_main (). fuse_main () CILSFuse_new ()(LIB/fuse. c) which allocates the struct fuse Datastructure that stores and maintains a cached image of the filesystem data.

Lastly, fuse_main () CILS eitherFuse_loop ()(LIB/fuse. c) orFuse_loop_mt ()(LIB/fuse_mt.c) which both start to read the filesystem system CILS from the/dev/fuse, call the usermode functions stored in struct fuse_operations Datastructure before calling fuse_main (). the results of those CILS are then written back to/Dev/FuseFile where they can be forwarded back to the system CILS.

2. the kernel module.

The kernel module consists of two parts. first the proc filesystem component in kernel/dev. c-and second the filesystem system callkernel/file. c, kernel/inode. c, and kernel/Dir. c All the system callin kernel/file. c, kernel/inode. c, and kernel/Dir. c make callto eitherRequest_send (),Request_send_noreply (), OrRequest_send_nonblock (). Most of the CILS (all but 2) are to request_send (). request_send () adds the request to, "list of requests" structure (FC-> pending), Then waits for a response. request_send_noreply () and request_send_nonblock () are both similar in function to request_send () blocks t that one is non-blocking, and the other does not respond with a reply.
The proc filesystem component in kernel/dev. c responds to file IO requests to the file/dev/fuse.Fuse_dev_read ()Handles the file reads and returns commands from the "List of requests" structure to the calling program.Fuse_dev_write ()Handles file writes and takes the data written and places them into the req-> out Datastructure where they can be returned to the system call through the "List of requests" structure and request_send ().

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.