- Contact: tech-kern
- Mentors: Julio Merino
- Duration estimate: 2-3 months
kernfs is a virtual file system that provides the user several information about the current system and, in some cases, allows him to configure some aspects of the kernel through those virtual files. procfs is another virtual file system that provides information about the currently running processes.
These two file systems are written in a non-extensible way. For example, kernfs is built on a hardcoded table that always exposes the same set of files; there is no way for other system areas to add or remove entries from the kernfs contents. procfs has similar issues as someone might think of a subsystem that could benefit from attaching information of its own to each running process. The current code is not modular, not well-designed and, as time has shown, there probably remain serious security bugs in them.
Linux exposes some APIs that abstract procfs' contents and allow external code to manage its entries by adding or removing files and/ or directories. This is a very interesting feature when writing loadable kernel modules as they can use this virtual file system to provide a way of interaction with the end user.
NetBSD could benefit of similar APIs for both kernfs and procfs. This project would consist on adding these APIs, which most likely requires (or suggests) a full rewrite of these file systems. The developer should keep in mind the distinction between the two to avoid having a procfs similar to the one in Linux, which mixes system configuration and process management.
In order to keep the new implementations simple, the developer should investigate the possibility of using tmpfs as a backend for kernfs and procfs. With some changes, one could create a kernel "library" that allowed the creation of virtual file systems with few code. For example, it's unlikely that the directory management routines will change among the three file systems, so the code from tmpfs should be reused. Similarly other features should be reusable, making procfs's and kernfs's code a lot simpler than currently is.
Alternatively, investigate FreeBSD's pseudofs and see if this could be a useful for this project and base for all the file systems mentioned above.
When working in this project, it is very important to write a complete regression test suite for procfs and kernfs beforehand to ensure that the rewrites do not add incompatibilities.
![[NetBSD Logo]](http://www.NetBSD.org/images/NetBSD-smaller.png)