Tuesday, October 25, 2005

Attributes

There was once a great operating system called BeOS which sported an excellent filesystem called BFS (the Be File System). In addition to being efficient, journalled, large (64-bit) and multithreaded, the most compelling feature of the operating system (i.e., the feature not found in most conventional operating systems) was attributes. Attributes are metadata associated with files on a BFS volume.

For example, MP3 files contain ID3 data identifying fields such as Artist and Title. JPEG files can contain IPTC data containing information such as the date of a photograph, the photographer, the shutter speed, the aperture, etc. Using attributes, these fields would be refactored into the filesystem, not stored in the file itself. That is, an MP3 file would not have an ID3 tag, but would instead be attributed with Artist and Title attributes.

Another example of attribute usage is storing the preferred application to view a file. For example, in Windows, I may designate that JPEG files should open in the Gimp. However, when I download my vacation photos (which are JPEGs) from my camera, I'd like the default double click action to be to open them in the Picture Viewer (so I can get an easy slide show). I do not recall if Windows currently has the ability to selectively open some files of a type in one viewer and other files of the same type in a different editor. If it does indeed have this feature, that information would have to be stored in the registry (which brings a lot of woes including loss of information on OS reinstall). Using attributes, each file could have a PreferredApp attribute that specifies which application to use. This attribute could be an OS specified attribute (so that "power users" do not accidently delete this attribute).

SpoonFS will support arbitrary attributes on files. There will be a concept of system attributes (e.g., Date, Permission) and user attributes (Width, Height for JPEGs, Author for MP3 files). As well, attributes will be type safe. For example, a Date attribute will expect a date to be entered according to the format provided by the OS locale.

Attributes present a very powerful paradigm; they are a first step for turning a filesystem into a database. Attributes are indexed and queryable, so it is possible to quickly find files. As well, attributes allow the creation of metadata-only files. For example, consider the concept of a Contact in an e-mail program or IM application. In a traditional filesystem, a Contact may be implemented as a small text file that has fields listed one per line (e.g., Name, E-mail address, Birthday, etc.). In an attribute-based filesystem, each field could be stored as an attribute on a zero byte file. In actuality, no inode needs to be allocated for the file itself; only metadata is stored. The name SpoonFS comes from this observation on the lack of existance of an data actual file. Quoting from the Matrix:

There is no spoon

Similarly, there is no file (only metadata).

No comments: