📄 zlibc.texi
字号:
\input texinfo @c -*-texinfo-*-@c %**start of header@setfilename zlibc.info@settitle Zlibc@c UPDATE THIS DATE WHENEVER YOU MAKE CHANGES!@c For double-sided printing, uncomment:@c @setchapternewpage odd@setchapternewpage off@c %**end of header@c MANskip@set EDITION 0.9j@set VERSION 0.9j@set UPDATED July 2000@iftex@finalout@end iftex@ifinfo@formatSTART-INFO-DIR-ENTRY* Zlibc: (zlibc). Zlibc: transparently access compressed files.END-INFO-DIR-ENTRY@end format@end ifinfo@ifinfoZlibc Copyright (C) 1993-1999 Alain KnaffPermission is granted to make and distribute verbatim copies ofthis manual provided the copyright notice and this permission noticeare preserved on all copies.@ignorePermission is granted to process this file through TeX and print theresults, provided the printed document carries copying permissionnotice identical to this one except for the removal of this paragraph(this paragraph not being relevant to the printed manual).@end ignorePermission is granted to copy and distribute modified versions of thismanual under the conditions for verbatim copying, provided that theentire resulting derived work is distributed under the terms of apermission notice identical to this one, and provided that the privacyof any reader of the resulting derived work is respected. In particularis it strictly forbidden to make this documentation available on a WorldWide Web server which deals cookies. However, keeping access statisticsis allowed.Permission is granted to copy and distribute translations of this manualinto another language, under the above conditions for modified versions,except that this permission notice may be stated in a translation approvedby the Free Software Foundation.@end ifinfo@titlepage@title Zlibc@subtitle Transparently access compressed files.@subtitle Edition @value{EDITION}, for Zlibc version @value{VERSION}@subtitle @value{UPDATED}@author by Alain Knaff@page@vskip 0pt plus 1filllCopyright @copyright{} 1993-1999 Alain KnaffPermission is granted to make and distribute verbatim copies ofthis manual provided the copyright notice and this permission noticeare preserved on all copies.Permission is granted to copy and distribute modified versions of thismanual under the conditions for verbatim copying, provided that theentire resulting derived work is distributed under the terms of apermission notice identical to this one and provided that the privacy ofany reader of the resulting derived work is respected. In particular isit strictly forbidden to make this documentation available on a WorldWide Web server which deals cookies. However, keeping access statisticsis allowed.Permission is granted to copy and distribute translations of this manualinto another language, under the above conditions for modified versions,except that this permission notice may be stated in a translation approvedby the Free Software Foundation.@end titlepage@ifinfo@node Top, Location, (dir), (dir)@end ifinfo@c MANend-skip@c zlibc-conf.5skip@ignore@unnumbered Namezlibc - transparently access compressed files.@end ignore@unnumbered IntroductionThe zlibc package allows transparent on the fly uncompression of gzippedfiles. Your programs will be able to access any compressed file, justas if they were uncompressed. Zlibc will transparently uncompresses thedata from these files as soon as they are read, just as a compressedfilesystem would do. No kernel patch, no recompilation of theseexecutables and no recompilation of the libraries is needed.It is not (yet) possible execute compressed files with zlibc. However,there is another package, called @code{tcx}, which is able to uncompressexecutables on the fly. On the other hand @code{tcx} isn't able touncompress data files on the fly. Fortunately, the both zlibc and tcxmay coexist on the same machine without problems.@menu* Location:: Where to get zlibc and early bug fixes* Installing zlibc:: How to install zlibc* Using zlibc:: How to configure your system to use zlibc* How it works:: The general principles behind zlibc* Customization:: How to customize zlibc to your needs* Porting zlibc:: How to port zlibc to new architectures* Variable Index:: Variable Index* Concept Index:: Concept Index@end menu@c MANskipThis documentation looks most pretty when printed or as html. Indeed,in the info version certain examples are difficult to read due to theconfusing quoting conventions of info.@c MANend-skip@include man-warning.texi@cindex bugs@cindex ALPHA patches@cindex patches@cindex diffs@cindex mailing list@node Location, Installing zlibc, Top, Top@chapter Where to get zlibcZlibc can be found at the following places (and their mirrors):@exampleftp://zlibc.linux.lu/zlibc-0.9j.tar.gzftp://www.tux.org/pub/knaff/zlibc/zlibc-0.9j.tar.gzftp://ibiblio.unc.edu/pub/Linux/libc/zlibc-0.9j.tar.gz@end exampleBefore reporting a bug, make sure that it has not yet been fixed in theAlpha patches which can be found at:@examplehttp://zlibc.linux.lu/http://www.tux.org/pub/knaff/zlibc@end exampleThese patches are named@code{zlibc-}@var{version}@code{-}@var{ddmm}@code{.taz}, where versionstands for the base version, @var{dd} for the day and @var{mm} for themonth. Due to a lack of space, I usually leave only the most recentpatch.There is an zlibc mailing list at zlibc @@ www.tux.org . Pleasesend all bug reports to this list. You may subscribe to the list bysending a message with 'subscribe zlibc @@ www.tux.org' in itsbody to majordomo @@ www.tux.org . (N.B. Please remove the spacesaround the "@@" both times. I left them there in order to foolspambots.) Announcements of new zlibc versions will also be sent tothe list, in addition to the linux announce newsgroups. The mailinglist is archived at http://www.tux.org/hypermail/zlibc/latest@node Installing zlibc, Using zlibc, Location, Top@chapter Installing zlibc@vindex LD_PRELOAD@cindex Installation@cindex Set-uid programs@cindex Boot problems@enumerate@item If you install zlibc on Linux, make sure that your shared loader(ld-linux.so.1/ld.so) understands @code{LD_PRELOAD}. (Best ifld.so-1.8.5 or more recent)@itemType @code{./configure}. This runs the GNU autoconfigure script whichconfigures the @file{Makefile} and the @file{config.h} file. You maycompile time configuration options to @code{./configure}, see fordetails.@itemType @code{make} to compile zlibc.@itemType @code{make install} to install zlibc and associated programs to itsfinal target.@itemTo use this module, set the environment variable @code{LD_PRELOAD} topoint to the object. Example (sh syntax):@example LD_PRELOAD=/usr/local/lib/uncompress.o export LD_PRELOAD@end exampleor (csh syntax):@example setenv LD_PRELOAD /usr/local/lib/uncompress.o@end exampleOn linux, use /lib/uncompress.o instead of /usr/local/lib/uncompress.o .You might want to put these lines in your @file{.profile} or@file{.cshrc} in order to have the uncompressing functions available allthe time.@itemCompress your files using gzip and enjoy@end enumerateFor security reasons, the dynamic loader disregards environmentalvariables such as @code{LD_PRELOAD} when executing set uid programs.However, on Linux, you can use zlibc with set uid programs too, by usingone of the two methods described below:@enumerate@itemYou may ing the path to @file{uncompress.o} into@file{/etc/ld.so.preload} instead of using @code{LD_PRELOAD}.@strong{WARNING}: If you use @file{/etc/ld.so.preload}, be sure toinstall @file{uncompress.o} on your root filesystem, for instance in@code{/lib}, as is done by the default configuration. Using a directorywhich is not available at boot time, such as /usr/local/lib will causetrouble at the next reboot!It is also careful to remove zlibc from @file{/etc/ld.so.preload} wheninstalling a new version. First test it out using @code{LD_PRELOAD},and only if everything is ok, put it back into@file{/etc/ld.so.preload}. The zlibc package also supplies fourstatically linked programs @code{srm}, @code{smv}, @code{sln} and@code{ssln}, which are equivalen to @code{rm}, @code{mv}, @code{ln} and@code{ln -s}. These can be used in case anything goes wrong with theinstallation.@itemIf you have a version of @code{ld.so} which is more recent than@code{1.9.0}, you can set @code{LD_PRELOAD} to just contain the basenameof @file{uncompress.o} without the directory. In that case, the file isfound as long as it is in the shared library path (which usuallycontains @file{/lib} and @file{/usr/lib})). Because the search isrestricted to the library search path, this also works for set-uidprograms.Example (sh syntax):@example LD_PRELOAD=uncompress.o export LD_PRELOAD@end exampleor (csh syntax):@example setenv LD_PRELOAD uncompress.o@end exampleThe advantage of this approach over @file{ld.so.preload} is that zlibccan more easily be switched off in case something goes wrong.@end enumerate@node Using zlibc, How it works, Installing zlibc, Top@chapter Using zlibc@cindex Symbolic linksOnce zlibc is installed, simply compress your biggest datafilesusing gzip. Your programs are now able to uncompress these files on thefly whenever they need them.@section Zlibc and links@subsection Symbolic linksAfter compressing your datafiles, you also need to change any potentialsymbolic links pointing to them. Let's suppose that @file{x} is asymlink to @file{tstfil}:@example> echo 'this is a test' >tstfil> ln -s tstfil x> ls -ltotal 1-rw-r--r-- 1 alknaff sirac 15 Feb 25 19:40 tstfillrwxrwxrwx 1 alknaff sirac 8 Feb 25 19:40 x -> tstfil@end exampleAfter compressing it, you'll see the following listing:@example> gzip tstfil> ls -ltotal 1pr--r--r-- 1 alknaff sirac 15 Feb 25 19:40 tstfillrwxrwxrwx 1 alknaff sirac 8 Feb 25 19:40 x -> tstfil@end example@file{Tstfil} is now shown as a pipe by zlibc in order to warn programsthat they cannot seek in it. Zlibc still shows it with its old name,and you can directly look at its contents:@example> cat tstfilthis is a test@end exampleHowever, @file{tstfil} is not yet accessible using the symbolic link:@example> cat xcat: x: No such file or directory@end exampleIn order to make @file{tstfil} accessible using the link, you have todestroy the link, and remake it:@example> rm x/bin/rm: remove `x'? y> ln -s tstfil x> ls -ltotal 1pr--r--r-- 1 alknaff sirac 15 Feb 25 19:40 tstfillrwxrwxrwx 1 alknaff sirac 8 Feb 25 19:44 x -> tstfil> cat xthis is a test@end example@subsection Hard linksIf you compress datafiles with hard links pointing to them, gzip refusesto compress them. @example> echo 'this is a test' >tstfil> ln tstfil x> ls -litotal 2 166 -rw-r--r-- 2 alknaff sirac 15 Feb 25 19:46 tstfil 166 -rw-r--r-- 2 alknaff sirac 15 Feb 25 19:46 x> gzip tstfilgzip: tstfil has 1 other link -- unchanged@end exampleThus you need to remove these hard links first, and remake them aftercompressing the file.@example> rm x/bin/rm: remove `x'? y> gzip tstfil> ln tstfil x> ls -litotal 2 167 pr--r--r-- 2 alknaff sirac 15 Feb 25 19:46 tstfil 167 pr--r--r-- 2 alknaff sirac 15 Feb 25 19:46 x> cat xthis is a test@end example@node How it works, Customization, Using zlibc, Top@chapter How it worksUsually, programs don't make system calls directly, but instead call alibrary function which performs the actual system calls. For instance,to open a file, the program first calls the @code{open} libraryfunction, and then this function makes the actual syscall. Zlibcoverrides the @code{open} function and other related functions in orderto do the uncompression on the fly.If the @code{open} system call fails because the file doesn't exist,zlibc constructs the filename of a compressed file by appending@code{.gz} to the filename supplied by the user program. If thiscompressed file exists, it is opened and piped trough @code{gunzip}, andthe descriptor of the read end of this pipe is returned to the caller.In some cases, the compressed file is first uncompressed into atemporary file, and a read descriptor for this file is passed to thecaller. This is necessary if the caller wants to call @code{lseek} onthe file or @code{mmap} it. A description of data files for which usingtemporary is necessary can be given in the configuration files@file{/usr/local/etc/zlibc.conf} (@file{/etc/zlibc.conf} onLinux)@footnote{Actually the location of the system-wide include filedepends on the settings of @code{sysconfdir} and @code{prefix} during@code{./configure} (@pxref{Compile-time configuration}).} and@file{~/.zlibrc}. @xref{Configuration files}, for a detailed descriptionof their syntax.Many user programs try to check the existence of a given file by othersystem calls before actually opening it. That's why zlibc alsooverrides these system calls. If for example the user program tries tostat 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 onlysimulated by zlibc is called 'the virtual file'.@node Customization, Porting zlibc, How it works, Top@chapter Customization@cindex CustomizationThe behavior of zlibc can be tailored using configuration files orenvironment variables. This customization should normally not be needed,
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -