⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 how-fuse-works

📁 linux下的用户文件系统fuse-2.5.2
💻
字号:
                           How Fuse-1.3 Works[Written by Terje Oseberg]1. The fuse library.When your user mode program calls fuse_main() (lib/helper.c),fuse_main() parses the arguments passed to your user mode program,then calls fuse_mount() (lib/mount.c).fuse_mount() creates a UNIX domain socket, then forks and execsfusermount (util/fusermount.c) passing it one end of the socket in theFUSE_COMMFD_ENV environment variable.fusermount (util/fusermount.c) makes sure that the fuse module isloaded. fusermount then open /proc/fs/fuse/dev and send the filehandle over a UNIX domain socket back to fuse_mount().fuse_mount() returns the filehandle for /proc/fs/fuse/dev to fuse_main().fuse_main() calls fuse_new() (lib/fuse.c) which allocates the structfuse datastructure that stores and maintains a cached image of thefilesystem data.Lastly, fuse_main() calls either fuse_loop() (lib/fuse.c) orfuse_loop_mt() (lib/fuse_mt.c) which both start to read the filesystemsystem calls from the /proc/fs/fuse/dev, call the usermode functionsstored in struct fuse_operations datastructure before callingfuse_main(). The results of those calls are then written back to the/proc/fs/fuse/dev file where they can be forwarded back to the systemcalls.2. The kernel module.The kernel module consists of two parts. First the proc filesystemcomponent in kernel/dev.c -and second the filesystem system callskernel/file.c, kernel/inode.c, and kernel/dir.cAll the system calls in kernel/file.c, kernel/inode.c, andkernel/dir.c make calls to either request_send(),request_send_noreply(), or request_send_nonblock(). Most of the calls(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 infunction to request_send() except that one is non-blocking, and theother does not respond with a reply.The proc filesystem component in kernel/dev.c responds to file iorequests to the file /proc/fs/fuse/dev. fuse_dev_read() handles thefile reads and returns commands from the "list of requests" structureto the calling program. fuse_dev_write() handles file writes and takesthe data written and places them into the req->out datastructure wherethey can be returned to the system call through the "list of requests"structure and request_send().

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -