root/morphix/trunk/mini_fo/README.attach

Revision 2, 3.8 kB (checked in by nextime, 2 years ago)

Initial import, branching from morphix svn

Line 
1
2                 GENERAL INFORMATION ON NEW FIST ATTACH MODE
3
4 WARNING: this code is alpha quality at best!  Only the bare-bone features
5 are implemented: much is missing and no serious error checking is done.  It
6 is currently supported only on Linux 2.4 and tested only with Wrapfs.
7
8 * Problem
9
10 When you mount a stackable file system, you stack it on top of another
11 directory.  That mount can only be done by the root user, because the VFS
12 checks that before it calls your file system code.
13
14 There are cases where you'd like to stack a file system on top of multiple
15 directories.  For example, suppose you wanted to use Cryptfs to encrypt
16 several users' directories.  If you wanted to encrypt the entire set of home
17 directories, you could stack Cryptfs on top of /home.  But what if you do
18 not want to encrypt all of /home, but only portions of it, say
19 /home/ezk/priv and /home/ion/Mail/personal?  You would have to mount Cryptfs
20 twice, one for each of those directories.  Now imagine hundreds of users
21 wanting each to have a personal crypto directory, and you can see why
22 hundreds of mounts are impractical (and also impossible, as most kernels
23 have hard limits on the maximum allowed number of mounts).
24
25 Another, even more serious problem with Cryptfs is when trying to support
26 multiple user keys.  Current Cryptfs supports only one keys.  If you change
27 the code to support multiple keys (per UID, per GID, per UID+SID) as many
28 have done, you find serious name clashes.  For example two users with
29 group-access to the same directory can create the same file "foo", which
30 encrypts to different ciphertext names; so it's allowed on the lower-level
31 file system, but cannot be allowed inside Cryptfs.  Such and other odd
32 semantics are due to the fact that current Cryptfs has a shared name space.
33 The new attach mode will allow Cryptfs to  separate the name spaces, thus
34 improving security and avoiding name clashes and odd semantics.
35
36 * Solution
37
38 Our solution is called "attach-mode mount."  You enable it in your .fist
39 file with the declaration "mntstyle attach."  In this mode, you mount a very
40 thin stackable file system on top of a given mount point, and you do NOT
41 specify at mount-time which directory you're going to stack on.  Instead,
42 that specification comes later.
43
44 Once you mount a stackable file system in attach-mode, you get an empty
45 directory.  Now you can run fist_ioctl to execute the new "attach" ioctl
46 which will allow you to attach a new directory node right below the
47 stackable file system mount point, and have that new node point to your
48 personal directory.
49
50 (BTW, this attach-style mount is not new.  Matt Blaze did something similar
51 for CFS, only in a user-level file server.)
52
53 * Examples
54
55 root# mount -t mini_fo -o debug=18 none /mnt/mini_fo
56 ezk$ fist_ioctl +a /mnt/mini_fo zadok /home/ezk/priv
57 ion$ fist_ioctl +a /mnt/mini_fo badula /home/ion/Mail/personal
58         and so on...
59
60 The above sequence of commands will result in having two new directory
61 entries inside /mnt/mini_fo:
62
63 $ ls -a /mnt/mini_fo
64 . .. badula zadok
65
66 The actions of attach and detach are very similar to mount and unmount,
67 respectively -- only that the attach/detach ioctls do not require root
68 privileges.
69
70 You can use "fist_ioctl -a" to detach a node (may not be implemented yet).
71
72 * Implementation
73
74 The exact details of this code are in the Linux-2.4 FiST template.  Look for
75 sections of code delimited by #ifdef FIST_MNTSTYLE_ATTACH.  Briefly, when
76 you mount Wrapfs in attach mode, it uses a different set of VFS ops (iops,
77 dops, fops, etc.) than the normal stacking code.  There is no "hidden"
78 superblock, dentry, or inode at mount time.  The only real operation
79 possible at this point is the attach ioctl.  This one will create a new
80 virtual dentry as a child of the mount point, and set its hidden dentry to
81 the one that the user pointed to.  From that point on, we're using the
82 regular stacking code and VFS operations.
83
84 Happy attaching,
85 Erez.
Note: See TracBrowser for help on using the browser.