Movatterモバイル変換


[0]ホーム

URL:


Jump to content
WikipediaThe Free Encyclopedia
Search

cpio

From Wikipedia, the free encyclopedia
Archive file format
cpio
Original author(s)Dick Haight
Developer(s)AT&T Bell Laboratories
Initial release1977; 48 years ago (1977)
Operating systemUnix andUnix-like
TypeCommand
LicenseGNU cpio:GPLv3
libarchive bsdcpio:New BSD License
cpio
Filename extension
.cpio
Internet media type
application/x-cpio
Uniform Type Identifier (UTI)public.cpio-archive
Type of formatFile archiver

cpio is a generalfile archiver utility and its associatedfile format. It is primarily installed onUnix-like computer operating systems. Thesoftware 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 phrasecopy in and out, in close description of the program's use ofstandard input andstandard output in its operation.

All variants of Unix also support other backup and archiving programs, such astar, which has become more widely recognized.[1] The use of cpio by theRPM Package Manager, in theinitramfs of theLinux kernel since version 2.6, and in Apple'sInstaller (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 anASCII-based representation.

cpio was removed fromPOSIX.1-2001 in favor ofpax,[2] a similar utility which had been introduced in the previous version of the standard.

History

[edit]

cpio appeared inVersion 7 Unix as part of theProgrammer's Workbench project.[3]

Operation and archive format

[edit]

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

Archive creation

[edit]

When creating archives during thecopy-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 thefind 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. By convention, the file name of an archive is usually given the file extensioncpio.

This example uses thefind utility to generate a list of path names starting in the current directory to create an archive of the directory tree:

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

Extraction

[edit]

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

$cpio-i-vd<archive.cpio

Command line flagd tells cpio to construct directories as necessary. Flagv (verbose) lists file names as they are extracted.

Any remaining command line arguments other than the option flags are shell-likeglobbing-patterns; only files in the archive with matching names are copied from the archive. The following example extracts the file/etc/fstab from the archive:

$cpio-i-d/etc/fstab<archive.cpio

List

[edit]

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

$cpio-t<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

[edit]

Cpio supports a third type of operation whichcopies files. It is initiated with thepass-through option flag (p). This mode combines the copy-out and copy-in steps without actually creating any file archive. In this mode, cpio reads path names on standard input like thecopy-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 the path given as a command line argument.

This example copies the directory tree starting at the current directory to another pathnew-path in the file system, preserving files modification times (flagm), creating directories as needed (d), replacing any existing files unconditionally (u), while producing a progress listing on standard output (v):

$find.-depth-print|cpio-p-dumvnew-path

POSIX standardization

[edit]

Thecpio utility is standardized inPOSIX.1-1988, but was omitted fromPOSIX.1-2001 because of its file size and other limitations. For example, the GNU version offers various output format options, such as "bin" (default, and obsolete) and "ustar" (POSIX tar), having a file size limitations of 2,147,483,647 bytes (2 GB) and 8,589,934,591 bytes (8 GB), respectively.[4]

The cpio, ustar, and pax file formats are defined byPOSIX.1-2001 for thepax utility, which is currentlyPOSIX 1003.1-2008 compliant, and so it can read and write cpio and ustar formatted archives.

Implementations

[edit]

MostLinux distributions provide the GNU version ofcpio.[5]FreeBSD andmacOS use the BSD-licensedbsdcpio provided withlibarchive.[6]

See also

[edit]

References

[edit]
  1. ^Peek, J; O'Reilly, T; Loukides, M (1997).Unix Power Tools. O'Reilly & Associates, Inc. p. 38.13.ISBN 1-565-92260-3.
  2. ^"Rationale".pubs.opengroup.org. Retrieved2024-07-18.
  3. ^McIlroy, M. D. (1987).A Research Unix reader: annotated excerpts from the Programmer's Manual, 1971–1986(PDF) (Technical report). CSTR. Bell Labs. 139.
  4. ^cpioinfo document, in theOptions node, bsdcpio manual page
  5. ^"Cpio". GNU.org.
  6. ^"libarchive".

External links

[edit]
Archiving only
Compression only
Archiving and compression
Software packaging and distribution
Document packaging and distribution
Retrieved from "https://en.wikipedia.org/w/index.php?title=Cpio&oldid=1235369577"
Categories:
Hidden categories:

[8]ページ先頭

©2009-2025 Movatter.jp