Subject: Re: NetBSD+=TCFS, how to use generic FS layer system?
To: VaX#n8 <vax@carolina.rr.com>
From: Bill Studenmund <wrstuden@netbsd.org>
List: tech-kern
Date: 05/25/2004 18:13:51
--JbKQpFqZXJ2T76Sg
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

On Tue, May 25, 2004 at 03:48:55PM -0400, VaX#n8 wrote:
> TCFS is the Transparent Crypting File System.  It is a file system layer
> that does encryption and sits above something like FFS.  It does not need
> any special support from the underlying layer except for some file system
> flags (see chflags).  For docs and more info, see: http://www.tcfs.it/
>=20
> It is working pretty well but I'd like to make it even better by
> eliminating any redundant code (further suggestions appreciated).
>=20
> So to this end I'd like to know is how to use the layerfs code.
> I know how to put layer_bypass and other vnodeops into the table,
> but I'm a little confused when it comes to using a compatible
> mount and vnode structure.  I tried it without and it started generating
> all kinds of debugging information.  Can anyone help me understand
> what I need to do?

As nullfs/null.h and umap/umap.h indicate, you start your fs-specific node=
=20
and mount structures with the layer structures. So struct tcfs_node needs=
=20
to start with struct layer_args, and struct tcfs_mount starts with struct=
=20
layer_mount. Then MOUNTTOLAYERMOUNT() and VTOLAYER() work right. Also,=20
your mount call arguements (struct tcfs_args) should start with=20
layer_args.

While the internal structure of struct tcfs_node matches layer_node,=20
neither tcfs_mount nor tcfs_args match. Among other things, you do not=20
allocate enough storage for the layer hash table pointer, so who knows=20
what happens as layer nodes get created and destroyed.

I'd suggest you just start the three structures with the layer ones. Even=
=20
though tcfs_node is the same, by using lauer_node for those elements, you=
=20
remove the potential for future issues. Like say if we ever change=20
layer_node, your code will pick up the change.

> I've basically integrated it into NetBSD-1.6.2, and you can see my work h=
ere:
> http://vaxn8.tripod.com/tcfs/NetBSD162/index.html
>=20
> It can be compiled in statically or as a module.
> Currently you must get the userland from the TCFS package
> (however, its LKM should *not* be used as its DES implementation is broke=
n).
> Since the package mount_tcfs gets installed in /usr/pkg/sbin and not /sbi=
n,
> you can't "mount -t tcfs" yet, but you can call mount_tcfs directly.

Take care,

Bill

--JbKQpFqZXJ2T76Sg
Content-Type: application/pgp-signature
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.3 (NetBSD)

iD8DBQFAs+9PWz+3JHUci9cRAvYqAJ4hP3H48RDuVcrUvwYg36/0KkjJfwCeM8Gt
FWKPz+cwCv039LAfrmx34zA=
=IoFb
-----END PGP SIGNATURE-----

--JbKQpFqZXJ2T76Sg--