Header files that are only useful to one subsystem (a kernel module, or driver, for example) should, IMO, only be located in the subsystem for which they are used. For example, do we really need to ship a header file in /usr/include/sys/ that has all the register definitions for the DEC tulip ethernet (dnet.h)? Wouldn't it be sufficient to have those definitions just where they belong, alongside the source for the dnet driver itself?
Locating the files for such subsystems in their own directory instead of a common directory (e.g. common/io/dnet/dnet.h instead of common/sys/dnet.h) has several positive ramifications:
- It makes it readily apparent that the header file has no content needed outside of the kernel or subsystem. So changes can be more freely made (no userland dependencies, for example.)
- The header file is not delivered to customers (except as part of the entire source code), shrinking the amount of disk space consumed on development workstations.
- No exceptions entry is required to suppress the file from delivery - so the file is referenced in fewer places. (Fewer places to change if the file needs to move, be removed, etc.)
- The header file is easier for humans to locate with the source.
- The header file is faster for the compiler to locate -- it will be in the first directory searched - slightly faster build times. (If enough subsystems do this, it might start to make a noticeable improvement.)
- The common include directory becomes slightly more manageable with each such change. (Big directories with hundreds of files are awkward.)
- The file can't be used/abused by other subsystems (at least not without making such abuse obvious), because it really is in a private directory.
The upshot of all this is that a bunch of driver-private header files have been slowly moving out of uts/common/sys/ and into better locations. Hopefully other driver developers will consider doing the same.