cpio

cpio
Cpio
Developer(s) GNU Project
Stable release 2.11  (March 10, 2010; 19 months ago (2010-03-10))[1] [+/−]
Written in C
Operating system Unix-like
Type File archiver
License GPL
Website gnu.org/software/cpio/

cpio is a general file archiver utility and its associated file format. It is primarily installed on Unix-like computer operating systems. The software utility was originally intended as a tape archiving program as part of the Programmer's Workbench (PWB/UNIX), and has been a component of virtually every Unix operating system released thereafter. Its name is derived from the phrase copy in and out, in close description of the program's use of standard input and standard output in its operation.

All variants of Unix also support other backup and archiving programs, such as tar that has become more widely recognized.[2] The use of cpio by the RPM Package Manager, in the initramfs program of Linux kernel 2.6, and in Apple Computer's Installer (pax) make cpio an important archiving tool.

Since its original design, cpio and its archive file format have undergone several, sometimes incompatible, revisions. Most notable is the change, now an operational option, from the use of a binary format of archive file meta information to an ASCII-based representation.

Contents

Operation and archive format

Cpio was originally designed to store backup file archives on a tape device in a sequential, contiguous manner. Cpio does not compress any content, but resulting archives are often compressed using gzip or other external compressors.

Archive creation

When creating archives during the copy-out operation, initiated with the -o command line flag, cpio reads file and directory path names from its standard input channel and writes the resulting archive byte stream to its standard output. Cpio is therefore typically used with other utilities that generate the list of files to be archived, such as the find program.

The resulting cpio archive is a sequence of files and directories concatenated into a single archive, separated by header sections with file meta information, such as filename, inode number, ownership, permissions, and timestamps. The file name of an archive is conventionally usually chosen with a .cpio file extension.

Example using find to archive an entire directory tree:

$ find . -depth -print | cpio -o >archive.cpio

Extraction

During the copy-in operation, initiated by the -i command line flag, cpio reads an archive from its standard input and recreates the archived files in the operating system's file system.

$ cpio -id <archive.cpio

The -d flag tells cpio to construct directories as necessary. The -v flag can be used to have file names listed as files are extracted.

Any command line arguments (not option flags) are shell-like globbing-patterns; only files in the archive whose names match one or more of those patterns are copied from the archive. The following example extracts etc/fstab from the archive.

$ cpio -id etc/fstab <archive.cpio

List

The files contained in a cpio archive may be listed with this invocation:

$ cpio -it < archive.cpio

List may be useful since a cpio archive may contain absolute rather than relative paths (e.g., /bin/ls vs. bin/ls).

Copy

Cpio supports a third type of operation which copies files, initiated with the pass option (-p). This mode combines the copy-out and copy-in steps without actually storing any archive in a file. In this mode, cpio reads path names on standard input like the copy-out operation, but instead of creating an archive, it recreates the directories and files at a different location in the file system, as specified by path given as a command line argument.

$ find . -depth -print0 | cpio --null -pduv new-dir

POSIX standardization

The cpio utility was standardized in POSIX.1-1988. It was dropped from later revisions, starting with POSIX.1-2001 because of its 8 GB file size limit. The POSIX standardized pax utility can be used to read and write cpio archives instead.

Implementations

Most Linux distributions provide the GNU version of cpio.[3] FreeBSD and Mac OS X use the BSD-licensed cpio provided with libarchive[4]

See also

References

  1. ^ Poznyakoff, Sergey (2010-03-10). "cpio-2.11 released [stable]". info-gnu mailing list. http://lists.gnu.org/archive/html/info-gnu/2010-03/msg00009.html. Retrieved 2010-03-21. 
  2. ^ Peek, J; O'Reilly, T; Loukides, M. (1997). Unix Power Tools. p. 38.13. O'Reilly & Associates, Inc. ISBN 1-56592-260-3.
  3. ^ "Cpio". GNU.org.
  4. ^ "libarchive". Google Code.

External links


Wikimedia Foundation. 2010.

Игры ⚽ Нужно сделать НИР?

Look at other dictionaries:

  • cpio — ist ein Archivierungsprogramm und Dateiformat aus dem Unix Umfeld, welches in seiner grundlegenden Funktionsweise (nicht jedoch bei der Kommandozeilenschnittstelle) dem Kommando tar ähnelt. Die Abkürzung cpio steht für „copy in, copy out“. Mit… …   Deutsch Wikipedia

  • cpio — Тип Архиватор Разработчик Проект GNU Написана на C Операционная система Unix like Последняя версия 2.11 (10 марта 2010) Лицензия …   Википедия

  • Cpio — (сокр. от англ. Copy Input/Output)  двоичный архиватор и формат файла. Утилита cpio применялась как ленточный архиватор (tape archiver), первоначально являвшийся частью PWB/UNIX, а также частью UNIX System III и UNIX System V. Однако,… …   Википедия

  • Cpio — is a binary file archiver and a file format. The cpio software utility was meant as a tape archiver that was originally part of PWB/UNIX, and that was also part of UNIX System III and UNIX System V. However, the use of its Research Unix… …   Wikipedia

  • CPIO — ist ein Archivierungsprogramm und Dateiformat aus dem Unix Umfeld, welches in seiner Funktionsweise dem Kommando tar ähnelt. Die Abkürzung cpio steht für „copy in, copy out“. Mit cpio können Dateien sequentiell in eine Archivdatei oder auf… …   Deutsch Wikipedia

  • Cpio — ist ein Archivierungsprogramm und Dateiformat aus dem Unix Umfeld, welches in seiner Funktionsweise dem Kommando tar ähnelt. Die Abkürzung cpio steht für „copy in, copy out“. Mit cpio können Dateien sequentiell in eine Archivdatei oder auf… …   Deutsch Wikipedia

  • Cpio — est un utilitaire d archivage ainsi qu un format de fichier utilisé sur UNIX. Il était conçu à l origine comme un moyen de sauvegarder des données sur bande magnétique sur les premières versions d UNIX System III et UNIX System V. Il est… …   Wikipédia en Français

  • Cpio — Saltar a navegación, búsqueda cpio es el nombre de una utilidad binaria tanto como del formato asociado a ésta, .cpio . Este tipo de archivo fue inicialmente creado para el almacenamiento de copias de seguridad en cintas magnéticas de una forma… …   Wikipedia Español

  • cpio — En informatique, cpio est un utilitaire d archivage ainsi qu un format de fichier utilisé sur UNIX. Il était conçu à l origine comme un moyen de sauvegarder des données sur bande magnétique sur les premières versions d UNIX System III et UNIX… …   Wikipédia en Français

  • CPIO — Copy In/Out …   Acronyms

Share the article and excerpts

Direct link
Do a right-click on the link above
and select “Copy Link”