I've been playing with a technique to transparently do data conversion on memory mapped data. The idea is basically to memory map a desired file, and create a second anonymous region that read/write protected. When the user goes to access to the anonymous region, the resulting segfault is caught, the data is converted and permissions are changed to allow the access to proceed.
It works great, but there's one little hitch. Passing the pointer without first touching the data to a system call like write() won't trigger the segfault handler, instead it just returns EFAULT as the handler isn't called to fix up permissions. Is there a way to cause system calls to use user-space handlers when there's a problem?