I was recently accepted for a Google Summer of Code’08 project. I will be adding subfile support to FFS for NetBSD.
Things to work on:
- Changes that need to be made to the file system
-
- Add a flag to the file system superblock to show if subfiles are supported
- Add two new inode types ( IFSFDIR and IFSFREG )
An IFSFDIR:
* is referenced by exactly one base inode, add a back pointer to the inode struct
* contents are same as normal directory, struct direct.
* contains a “.” entry that references the IFSFDIR.
* contains a “..” entry that references the base inode
* entries may only reference IFSFREG there may be no subdirectories or device nodes
* is instantiated on demand
* is removed when the base inode is removed
* does not have independent access control (uid, gid, mode), refer the the base inode
An IFSFREG:
* is just like an IFREG
* could (should?) contain a back pointer to the IFSFDIR
* can only have a link count of 1
* can be deleted explicitly (see subfile_remove(), below)
* is deleted when the base inode is deleted
* does not have independent access control (uid, gid, mode), refer the the base inode
When a base inode is deleted, the subfile tree has to be deleted also. Changes to remove() would be needed.
- OS Level – System Calls
-
- int subfile_open (char * basefilename, char * subfilename, int open_flags);
- int subfile_fopen (int basefilefd, char * subfilename, int open_flags);
- subfile_fopen acts much like regular fopen(2) except it is passed a basefile fd to open then opens the subfile of the basefile.
Both of these open functions would return a normal file descriptor to the subfile upon a successful open, a fd that can be used with normal read, write, close, etc.
-
- opendir -modified to open the subfolder of a file if the file’s inode contains a subfolder reference
- int subfile_stat (char * basefilename, char * subfilename, struct stat * sb);
- int subfile_fdstat (int basefilefd, char * subfilename, struct stat * sb);
- int subfile_remove (char * basefilename, char * subfilename);
- int subfile_fdremove (int basefilefd, char * subfilename);
If you would like to research a bit on subfiles, I suggest these links:

