How to make a dumthe application reads gzip files (on-the-fly) without code changes

gzipread

I'm looking for a general tool/library that overrides the OS fopen function to read gz files seamlessly on-the-fly without modification to an application.

Details: I have a legacy application that reads large binary files. These binaries compress very well as gz. I was thinking of compressing these binary files and keep the original files extension (as required by the legacy application) and use a library or an application that intercepts and overrides the system calls to support reading compressed files without any changes to the application code, and without doing complete uncompress. Also, doing overall filesystem compression is not applicable, as it would kill the performance of other HPC applications. I only need to compress specific binary files which are read by legacy applications, and add support for those applications to read these compressed files without any alteration to the source code.

Is there something available to do such thing? I don't care about portability, as long as it works fine in my Linux distro (RHEL 6)

Best Answer

Another possibility might be to use some specialized file system. Perhaps a FUSE filesystem (e.g. FUSE-BGZIP) which is doing the compression could do the trick, and you could adapt it to only transparently compress the few files you want to (e.g. with some overlayfs).

See also this question (transparent compression for ext4).