cpio

from Wikipedia, the free encyclopedia

cpio is an archiving program and file format from the Unix environment, which in its basic functionality (but not in the command line interface) is similar to the tar command . The abbreviation cpio stands for "copy in, copy out". With cpio files can be written sequentially to an archive file or to magnetic tape. cpio files are often given the file extension .cpio . Like tar files, cpio archives are larger than the sum of the individual files contained in the archive, so that data compression may be useful. Compress , gzip or bzip2 is usually used for compression under Unix .

The SVR4 version of the cpio command can use tar archive formats as well as various cpio formats. GNU -cpio copied this behavior. One program that uses a format similar to the cpio file format is afio . Archives created by afio cannot always be read by cpio because of the differences in the archive format, which can usually only be found in the middle of these archives .

POSIX standard

cpio is included in the POSIX .1-1988 standard. From later versions, from POSIX.1-2001 , it was removed due to its maximum file size of 4 GB / 2 GB (with the non-standardized SVR4 format) or 8 GB (with the POSIX-cpio format). This decision was also influenced by the fact that the cpio archive format cannot be expanded without creating a completely new format from the cpio family. However, the new POSIX command pax supports both the tar and cpio formats. The name pax ( Latin for "peace") was chosen as a result of the so-called tar wars (which were waged around 1992) to create peace between the two rival programs cpio and tar.

Functionality and example calls

cpio has four basic functions, which have the options -o ("copy-out mode", creating an archive), -i ("copy-in mode", extracting from an archive), -p ("copy-pass -Modus ", copying of directory trees) and -t (" List mode ") can be specified. cpio basically works like other Unix filters ; that is, it expects its arguments from the input data stream and sends its results to the output data stream.

Generate a cpio file that contains the files of the current directory:

ls | cpio -o > verzeichnis.cpio

Generate a cpio file that contains the files and subdirectories of the current directory:

find . -depth -print | cpio -o > verzeichnis.cpio

Restoring files from a cpio archive:

cpio -i < archiv.cpio

List the files contained in the archive without extracting them:

cpio -it < archiv.cpio

Copy the current directory including all subdirectories to / tmp / directory (corresponds roughly to cp -r * / tmp / directory ):

find . -print -depth | cpio -pd /tmp/verzeichnis

Comparison between cpio and tar

Of the two Unix commands cpio and tar , tar is better known and more widespread and is not subject to the size limitation for archive files of 4 GB (2 GB for implementations with signed int for the file size) for the SVr4 format or 8 GB for the POSIX format. Format. The proponents of cpio claim that the cpio format does not generally have any compatibility problems between different Unix platforms. On closer inspection, however, this turns out to be a false assumption, because there are four completely incompatible cpio formats and additional problems with the byte order . Another comparison can be found in the GNU tar manual. There you will also find some information about the formats that are partially supported by GNU-cpio, but this information is only partially applicable to the GNU implementation, which is not fully compatible with UNIX-cpio.

The original cpio implementation has an undocumented property and behaves similarly to the install program. This means that cpio can extract files from the program files and libraries that are currently being used without causing the program to crash.

Since the cpio formats were defined in such a way that each extension leads to a completely new, incompatible archive format, the POSIX cpio format was designated in 2001 as POSIX.1-2001 as not future-oriented. The currently preferred POSIX archive format is called pax and is a variant of the tar format that can be expanded as required.

use

Nowadays, cpio is mainly used with an initramfs , the successor to initrd . Even rpm packages internally use the cpio format.

See also

Individual evidence

  1. http://www.opengroup.org/onlinepubs/9699919799/utilities/pax.html
  2. http://www.gnu.org/software/tar/manual/html_section/cpio.html#SEC144
  3. http://www.gnu.org/software/tar/manual/html_section/Formats.html
  4. http://www.gnu.org/software/cpio/manual/cpio.html

Web links