DæmonNews: News and views for the BSD community

Daemon News Ezine BSD News BSD Mall BSD Support Forum BSD Advocacy BSD Updates

Ext2fs rev 1 changes in NetBSD

Hubert Feyrer, Manuel Bouyer; April 2000

Manuel Bouyer has made changes to the NetBSD ext2fs to include changes for revision 1 of the Linux Extended2 filesystem. Here's an introduction to what ext2fs is, and an overview of the first revision's changes.

Why so many filesystems?

Running on a broad range of hardware platforms not only means being able to talk to the hardware. Often it's necessary to access programs and files installed on machines prior to the transition to another operating system, or even after. While changing to (or even playing with) another operating system, copying all data over to the new filesystem format is often not an option. And even if so, some method of accessing data is required.

Given that systems may have their own filesystem format to store data in their "native" format, accessability via an appropriate filesystem is required to get to the data. It is the filesystem's responsibility to understand the layout of the data on the disk, and to make it accessible for reading and writing.

Besides native filesystems like FFS and LFS, NetBSD comes with a wide range of file systems, which ensure it can read and/or write disks containing data in the following filesystems:

  • Commodore Amiga AmigaDOS

  • Acorn Filecore

  • MS-DOS FAT, also with Win95 long filenames

  • Windows NT NTFS

  • ISO 9660 as found on CDROMs and DVDs, with both Rockridge and Joliet extensions for "long" names.

  • Berkeley-based Fast File-System used by Sun's SunOS and Solaris as well as SGI's Irix

  • Linux ext2fs

The filesystem used natively in NetBSD is the Berkeley FFS. The name was changed from Unix File System (UFS) to avoid the trademarked term "Unix". See [1] for more information on the Berkeley FFS.

There are some changes to the ext2fs code used in NetBSD, and we'll talk about that here. After a general overview of ext2fs, we'll outline the changes made in ext2fs revision 1.

What is ext2fs?

The Second Extended Filesystem (ext2fs) is used as the Linux operating system's native filesystem format today. Ext2fs is based on the Minix filesystem, and several improvements were made to make it fit today's data storage requirements, using semantics and concepts found then (and today) in the traditional Berkeley based Fast Filesystem (FFS).

Besides implementing standard FFS features like symbolic links, long filenames and variable blocksize, extfs also includes other changes like bitfields for extensions in new revisions and a filesystem "clean" flag to avoid the filesystem check on reboot.

Please refer to [2] for more details on ext2fs.

Changes in ext2fs rev. 1

Ext2fs rev 1 has bitfields in the superblock indicating which features the ext2fs has. They are categorized in three classes: 'compat' are features which can be ignored by kernels which don't support it; 'rocompat' are features which can be ignored by kernels which don't support them if the filesystem is mounted read-only; and 'incompat' are features which prevent the filesystem from being mounted at all if the kernel doesn't support one of them.

As of linux-2.2.14 the only 'compat' feature defined so far is 'prealloc', which affects the way blocks are pre-alloctated on write; No support for this optimisation is present in NetBSD so far.

Three 'rocompat' features are defined:

  • 'sparse_super': don't copy superblocks in each cylinders groups (save some space)

  • 'largefile': supports files > 2G on 64bit systems (32bit systems like i386 are still limited to 2G files)

  • 'btreedir': suspectedly use btree format for directories (instead of a flat list)

Linux-2.2.14 supports sparse_super and largefile; NetBSD only supports 'sparse_super' (lacking access to 64bit linux systems, it's not known if linux-2.2.14 completely supports largefile, and mke2fs 1.18 doesn't support it either, at least it's not documented in the man page).

Two 'incompat' features are defined:

  • 'compression': A compressing filesystem

  • 'filetype': store file types in directory entries; really, really close to what FFS does since at least 4.4BSD, maybe even 4.3 did (you'll have to check that).

As of linux-2.2.14/e2fsprogs 1.18 only 'filetype' is supported; NetBSD supports it as well.

A bit of history

The NetBSD ext2fs started with a 'cp -r ffs ext2fs' and then (after renaming all functions/defines) adapting this to ext2fs: no fragments, different block allocation policy, minor changes in inodes and directory formats (ext2fs is really close to ffs), byte swapping on big-endian systems. At this time the 'file type in directory entries' code was deleted. Three years later it was added back.

By using this approach, it was possible to get a completely GPL-free ext2fs implementation which fits the NetBSD requirement to keep GPL'ed code out of the kernel.

References

[1]

M. McKusick, K. Bostic, M. Karels, J. Quarterman: The Design and Implementation of the 4.4BSD Operating System; Addison-Wesley Publishing Company, Reading, MA. April 1996, ISBN 0-201-54979-4.

[2]

R. Card, T. Ts'o, S. Tweedie: Design and Implementation of the Second Extended Filesystem; http://web.mit.edu/tytso/www/linux/ext2intro.html.

Google
Web daemonnews.org

More Articles
  • Interview with Jan Schaumann
  • Interview with Theo de Raadt
  • Book Review: Virtualization with VMware ESX Server
  • Editorial: Not Quite Dead Yet
  • The Design of OpenBGPd
  • Interview with der Mouse
  • Letter to Steve Jobs
  • Interview with Manuel Bouyer on Xen
  • Apple and Open Source
  • BSDCan 2006
  • BSD Certification Survey Results
  • Lab in a Box
  • Ike Notes on BSDCan 2005
  • BSDCan 2005 Photos
  • FreeBSD Developer Summit Pictures

  • Advertisements




    Author maintains all copyrights on this article.
    Images and layout Copyright © 1998-2006 Dæmon News. All Rights Reserved.