This isn’t supported out-of-the-box on any unix I know, but you can do pretty much anything with FUSE. There’s at least one implementation of nullfs¹, a filesystem where every file exists and behaves like
/dev/null (this isn’t the only implementation I’ve ever seen).
Not to be confused with the *BSD nullfs, which is analogous to bindfs.
Another approach would be a LD_PRELOAD wrapper; basically a small shared library which is loaded before libc.so, and intercepts calls to “open” with something that checks the prospective file path and substitutes “/dev/null” if it would be in the target directory.
This has the advantage of being
(a) entirely in user-space – no kernel hacking required; and
(b) only affecting the single errant application.
A simple example is at http://www.noah.org/wiki/LD_PRELOAD_notes, but in your case you will want to intercept the “open” & “creat” system calls.
i have created a kernel module based on the ramfs example in the linux kernel,
it is basically a blackhole filesystem called nullfsvfs. The FUSE system implementation needs to copy data from user to kernelspace and is quite slow, compared to a straight implementation as kernel module. See: