Looking for a file-system overlay using LD_PRELOAD

I'm looking for a shared library that is to be loaded using LD_PRELOAD that would modify the view of the filesystem to the client program.

Ideally, I'd like to choose the filesystem root (or use / as root) and to overlay the filesystem by renaming filenames.

For example, I might want to tell my program to look for /usr/lib/* in /usr/lib32/* instead.

Do you know of such a program ?

Thanks.


There's AVFS which is a little bit like this, but I would certainly not recommend the technique for anything security conscious, since you would have to patch all present and future library things that frob files...

An alternate approach might be to make chroot / bind-mount farm. That also has the advantage that you can mount --bind things read-only, which is nice.


PlasticFS may help, although I think (from reading, I haven't tried it) it allows you to effectively create a synthetic filesystem at some mount-point (kind of like FUSE, but using LD_PRELOAD).

So you can e.g create a synthetic root at /tmp/myfs, but you would still need a chroot-like tool to present this constructed location as if it were the root of the filesystem. fakechroot is an obvious choice for not requiring root, but it also uses LD_PRELOAD so I'm not sure if the two tools would confuse each other.


Update: It's a little confusing, but I've actually tried it now - versions of plasticfs up to and including 1.11 use LD_PRELOAD (and in fact include a "chroot" filter, so you don't need to use fakechroot). So that may be what you want, but:

  • it didn't work very well in my tests (created files it shouldn't, missed files that should have been there)

  • newer releases (1.11 was released in 2007, it's up to 1.14 now) abandoned LD_PRELOAD entirely for FUSE and a pair of mount and umount stateful commands, which also removed the ability to use it as a chroot.