~james-w/+junk/fuse-debian-upstream

« back to all changes in this revision

Viewing changes to doc/how-fuse-works

  • Committer: James Westby
  • Date: 2008-05-16 12:57:40 UTC
  • Revision ID: jw+debian@jameswestby.net-20080516125740-fn2iqsxtfd3olmib
Tags: upstream-debian-2.2.1
Import upstream from fuse_2.2.1.orig.tar.gz

Show diffs side-by-side

added added

removed removed

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