ext2fs and msdosfs support in Lites

This file briefly describes how support for these two file systems in Lites was implemented at Utah. It also provides some hints for users and developers. If you have any comments or questions, please send mail to the developer, gback@cs.utah.edu, or lites-bugs@cs.utah.edu We sincerely appreciate any feedback.


ext2fs has had moderate testing and worked reliably, it is cleanly supported, and performance is more or less comparable to FFS under Lites. The e2fsprog utilities have been ported as well. msdosfs works okay for us, but the original author of the code reports problems in write mode.

EXT2FS Support


The ext2fs support is embedded in the ufs framework, and it is based on the ffs implementation. The rationale for this is that ffs and ext2fs are very similar filesystems - both use groups, multilevel indexing, a similar on-disk inode format and almost identical directory formats.

The main differences are that ext2fs uses smaller blocksizes and doesn't support fragments. There are minor differences in the directory format. Furthermore, the allocation policies differ. Ext2fs's policy is mainly extent-based, aiming for contiguous allocation, whereas ffs' policy takes various disk parameters into account to aid its strategy.

A first approach to use the Linux code base and provide it with glue code so that it could use Lites' buffer cache and could be used by Lites' VFS layer failed. The reasons are threefold: first, the buffer cache interfaces are different, second, the amount of glue code for the vfs layer would have been rather large, and finally it would have been necessary to guarantee all the implicit assumptions the ext2fs code makes about the Linux kernel.

Therefore, we decided to start with the ffs code. The translation was then straightforward.

The differences in the directory format required a customized readdir routine, plus customized routines to enter or remove directory entries. Since those routines are not part of the VFS abstract interface, the ufs code dynamically checks the type of the vnode and calls the appropriate function. A second difference is that ext2fs and ffs have different notions of a basic unit in a directory (DIRBLKSIZ). These two changes were the only changes the ufs code suffered; the alternative would have been to clone large parts of the code.

Linux's allocation policies are enforced. This includes preferences of where to allocate blocks and inodes as well as the preallocation of up to eight contiguous blocks that help lay out ext2fs files contiguously under contention. The allocation code was the only code that came from the Linux source. At this point, it includes some i386 specific asm macros which were also taken from Linux.

Porting ext2fs to Other *BSD Flavours

From what was said above it should be clear that it should be sufficient to trace the changes the ufs and ffs code experienced and apply them to the ufs/ext2fs code. Anyone who wants to do that is requested to ``#ifdef LITES'' the changes he/she makes, and provide us with the changed version. (This is the author's personal effort to reunite the BSDs - where it makes sense. Unfortunately it's doomed to fail).

ext2fs Utility Programs

We aided Ted Ts'o in porting his e2fsprog package to *BSD. The next release 0.5c will run on NetBSD and FreeBSD systems. A prelease (as of 8/17/95) is available for FTP. Binaries for these utilities, as well as for a BSD-style mount program, are also available via FTP. See the FTP information section in the release page for details.

The mount program can be installed in /usr/sbin and will work with the standard BSD mount utility. Specifying a type of ``ext2fs'' in /etc/fstab will cause mount_ext2fs to be invoked. Unfortunately, fsck does not have a similar ``escape'' mechanism to allow non-FFS filesystems to be checked automatically. You will have to run the ext2fs checker by hand.

Unimplemented Features:


The msdosfs support was taken almost as is from the FreeBSD 2.0.5-snapshot 7/26/95. FreeBSD extensions not present in Lites had to be commented out (such as NFS cookies in readdir). Only other minor changes were needed, and these could be incorporated in a single header file.

Jordan K. Hubbard cautioned that it doesn't run reliably in read-write mode in FreeBSD. He mentioned that "dd if=/dev/zero of=" would reproduce the failure. (The disklabel supposedly gets overwritten, causing what he referred to as "partition pizza.") He uses a big DOS partition (>700 MB).

Even though we were not able to reproduce this failure on our small DOS partition, please be aware that you're using this software at your risk. Since the changes to the msdosfs code are really minor, the problem is likely to occur in Lites as well, unless it lies in another area of FreeBSD's code.

Godmar Back <gback@cs.utah.edu>
University of Utah, Computer Systems Laboratory
August 29, 1995