The third example is a filesystem extension that allows applications to transparently access remote files. Requests corresponding to remote filesystems are redirected to a server running elsewhere. The extension should provide wrappers for filesystem services, analyze the arguments and then choose which underlying service should be invoked to complete the request.
Usually, dynamically-linked programs do not trap directly to the operating system for reading and writing. Traps are usually encapsulated in a system library (e.g. libc) and are exported as library functions. Therefore, DITOOLS can interpose the above routines to these functions to achieve the expected behavior, without the need of system-call redirection functionality.
int fs_write(int fd, char *b, int s)
{
if remote_fd(fd) {
a = marshal(b,s);
r = send_request(server, WRITE, a);
} else
r = base_fs_write(fd,b,s);
return r;
}