-
Notifications
You must be signed in to change notification settings - Fork 107
Porting UFS (using Spatch)
Harvey needs a file system, and after investigating various file systems, we decided to port the FreeBSD implementation of UFS2 to Harvey.
This is not an easy task - it involves transplanting a major system from one operating system to another. Once the port is complete, we want to ensure we can incorporate any improvements to the FreeBSD implementation with minimal effort.
To achieve this, it was suggested we use spatch to create semantic patches. These patches are describe patterns of code that can be found across a code base and then modified as described in the patch. Where spatches are not possible, we can use sed, or if necessary, modify the code by hand.
The process we intend to follow is:
- Fork FreeBSD. (Done)
- Copy the ufs code into a new library (libufs).
- Add an initially empty build file to allow us to build the library as a kernel library in Harvey.
- Develop simple spatches that can be applied to the code to slowly transform it into something that can be built.
- Implement a driver to integrate libufs with Harvey.
Spatch sometimes has problems parsing code with macros. An example is the use of the TAILQ_ENTRY() macro in the inode struct in ufs/inode.h. If spatch cannot parse this entry in the struct, it cannot transform any part of the struct. We can resolve this by adding the definition of the macro to a macro file, and pass this to spatch when applying the patches. We will build up this macro file as we go, from the actual macros in FreeBSD.
You can check that a file can be fully parsed by spatch as so: spatch --parse-c ../ufs/acl.h
. This will report whether spatch can fully parse the file or not.