Usually, programs don't make system calls directly, but instead call a
library function which performs the actual system calls. For instance,
to open a file, the program first calls the open
library
function, and then this function makes the actual syscall. Zlibc
overrides the open
function and other related functions in order
to do the uncompression on the fly.
If the open
system call fails because the file doesn't exist,
zlibc constructs the filename of a compressed file by appending
.gz
to the filename supplied by the user program. If this
compressed file exists, it is opened and piped trough gunzip
, and
the descriptor of the read end of this pipe is returned to the caller.
In some cases, the compressed file is first uncompressed into a
temporary file, and a read descriptor for this file is passed to the
caller. This is necessary if the caller wants to call lseek
on
the file or mmap
it. A description of data files for which using
temporary is necessary can be given in the configuration files
`/usr/local/etc/zlibc.conf' (`/etc/zlibc.conf' on
Linux)(1) and
`~/.zlibrc'. See section Configuration files for a detailed description
of their syntax.
Many user programs try to check the existence of a given file by other system calls before actually opening it. That's why zlibc also overrides these system calls. If for example the user program tries to stat a file, this call is also intercepted.
The compressed file, which exists physically on the disk, is also called 'the real file', and the uncompressed file, whose existence is only simulated by zlibc is called 'the virtual file'.
Go to the first, previous, next, last section, table of contents.