Museum

Home

Lab Overview

Retrotechnology Articles

⇒ Online Manual

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

ar(1)

cat(1)

echo(1)

find(1)

ls(1)

tar(1)

umask(1)

cpio(4)

cpio(1)

NAME

cpio − copy file archives in and out

SYNOPSIS

cpio −o[aBcDhLRv] [−C bufsize] [[−O file] [ −M message]]

cpio −i [bBcdDfHkmrsStuvW26] [−C bufsize] [[−I file] [−M message]] [ pattern ...]

cpio −p [adDhLlmruv] directory

cpio −V [BcDhRv] [ rename-list]

DESCRIPTION

Cpio −o (copy out) reads the standard input to obtain a list of path names and copies those files onto the standard output together with path name and status information.  Output is padded to a 512-byte boundary by default. 

Cpio −i (copy in) extracts files from the standard input, which is assumed to be the product of a previous cpio −o.  Only files with names that match patterns are selected.  patterns are regular expressions given in the filename-generating notation of sh(1).  In patterns, meta-characters ?, ∗, and [...] match the slash (/) character, and backslash (\) is an escape character.  A ! metacharacter means not.  (For example, the !abc∗ pattern would exclude all files that begin with abc.)  Multiple patterns may be specified and if no patterns are specified, the default for patterns is ∗ (i.e., select all files).  Each pattern must be enclosed in double quotes otherwise the name of a file in the current directory is used.  Extracted files are conditionally created and copied into the current directory tree based upon the options described below.  Cpio will only archive directory, regular, symbolic link, linked, character special, block special, and FIFO type files.  It will extract the above mentioned types of files as well as other types, but will create these other types only as regular files.  The permissions of all extracted files will be those of the previous cpio −o if the user is super-user.  If the user is not super-user, the permissions of all extracted files will be modified appropriately by the user’s current umask value (see umask(1)).  The owner and group of the files will be that of the current user unless the user is super-user, which causes cpio to retain the owner and group of the files of the previous cpio −o.  NOTE: If cpio −i tries to create a file that already exists and the existing file is the same age or newer, cpio will output a warning message and not replace the file.  (The −u option can be used to unconditionally overwrite the existing file.) 

Cpio −p (pass) reads the standard input to obtain a list of path names of files that are conditionally created and copied into the destination directory tree based upon the options described below. 

Cpio −V (verify) compares files from the standard input, which is assumed to be the product of a previous cpio −o, with corresponding files on disk. This option may be used to ensure that a cpio archive was properly created with no I/O errors.  cpio will exit with a non-zero status if any errors are detected during the verify. 

The meanings of the available options are:

−a Reset access times of input files after they have been copied.  Access times are not reset for linked files when cpio −pla is specified.  This option is ineffective on symbolic links that are being copied. 

−b Reverse the order of the bytes within each word.  Use only with the −i option. 

−B Input/output is to be blocked 5,120 bytes to the record.  The default buffer size is 512 bytes when this and the −C options are not used.  (−B does not apply to the pass option; −B is meaningful only with data directed to or from a character special device, e.g.  /dev/rmt/0mf.) 

−c Write header information in ASCII character form for portability.  Always use this option when origin and destination machines are different types.  All POSIX applications must use this option to conform with the POSIX 1003.1 extended cpio format.  When conforming to POSIX 1003.1, only directories, FIFO special files, and regular files should be archived.  This option should also be used by X/Open conforming applications. 

−C bufsize
Input/output is to be blocked bufsize bytes to the record, where bufsize is replaced by a positive integer.  The default buffer size is 512 bytes when this and the −B options are not used.  (−C does not apply to the pass option; −C is meaningful only with data directed to or from a character special device, e.g.  /dev/rmt/0mf.) 

−d directories are to be created as needed. 

−D Print a dot for each file seen.  Useful to assure the user that cpio is working without printing out all file names. 

−f Copy in all files except those in patterns. (See the paragraph on cpio −i for a description of patterns.) 

−h Force cpio to follow symbolic links as if they were normal files or directories.  Normally, cpio does not follow symbolic links. 

−L Force cpio to follow symbolic links as if they were normal files or directories.  Normally, cpio does not follow symbolic links. 

−H Swap bytes within header.  This option should be used when reading tapes generated on a VAX or other machines which have a reverse byte orientation from the CX-series. 

−I file
Read the contents of file as input.  If file is a character special device, when the first medium is full replace the medium and type a carriage return to continue to the next medium.  Use only with the −i option. 

−k Attempt to skip corrupted file headers and I/O errors that may be encountered.  If you want to copy files from a medium that is corrupted or out of sequence, this option lets you read only those files with good headers.  (For cpio archives that contain other cpio archives, if an error is encountered cpio may terminate prematurely.  cpio will find the next good header, which may be one for a smaller archive, and terminate when the smaller archive’s trailer is encountered.)  Use only with the −i option. 

−l Whenever possible, link files rather than copying them.  Use only with the −p option. 

−m Retain previous file modification time.  This option is ineffective on directories and symbolic links that are being copied. 

−M message
Define a message to use when switching media. When you use the −O or −I options and specify a character special device, you can use this option to define the message that is printed when you reach the end of the medium.  One %d can be placed in the message to print the sequence number of the next medium needed to continue. 

−O file
Direct the output of cpio to file.  If file is a character special device, when the first medium is full replace the medium and type a carriage return to continue to the next medium.  Use only with the −o option. 

−r Interactively rename files.  If the user types a null line, the file is skipped.  If the user types a "." the original pathname will be copied.  (Not available with cpio −p.) 

−R Automatically rename files.  The −R option causes cpio to accept a list of filename pairs. This filename pair is read from standard input for the cpio −o (copy out) function and from the rename-list for the cpio −V (verify) function.  The first filename of the filename pair is the name of the file on disk.  The second filename of the filename pair is the name of the file as it appears on the cpio archive. 

−s swap bytes within each half word.  This option is provided as an aid in reading cpio format tapes generated on different type machines.  Use only with the −i option. 

−S Swap halfwords within each word.  This option is provided as an aid in reading cpio format tapes generated on different type machines.  Use only with the −i option. 

−t Print a table of contents of the input.  No files are created. 

−u Copy unconditionally (normally, an older file will not replace a newer file with the same name). 

−v verbose: causes a list of file names to be printed. When used with the −t option, the table of contents looks like the output of an ls −l command (see ls(1)). 

−W Swap words within longwords within header.  This option should be used when reading tapes generated on a VAX or other machines which have a reverse byte orientation from the CX-series. 

−2 Read tapes written with a two byte inode field in the header. By default, CX/UX cpio uses a 4 byte inode field in the header (see cpio(4)).  This option should not be used with the −c option. (The −c option always uses a 2 byte inode field.)  This option should be used when reading tapes generated on a VAX, a Harris Station (HS) or MCX, or other machines which use a two-byte inode field. 

−6 Process an old (i.e., UNIX System Sixth Edition format) file.  Use only with the −i option. 

NOTE: cpio assumes four-byte words. 

If cpio reaches end of medium (end of a tape for example), when writing to (−o) or reading from (−i) a character special device, and −O and −I aren’t used, cpio will print the message: If you want to go on, type device/file name when ready. To continue, you must replace the medium and type the character special device name (/dev/rmt/0mf for example) and carriage return.  You may want to continue by directing cpio to use a different device.  For example, if you have two tape drives you may want to switch between them so cpio can proceed while the first tape is being rewound.  (A carriage return alone causes the cpio process to exit.) 

EXAMPLES

The following examples show three uses of cpio. 

When standard input is directed through a pipe to cpio −o, it groups the files so they can be directed (>) to a single file (../newfile).  The −c option insures that the file will be portable to other machines.  Instead of ls(1), you could use find(1), echo(1), cat(1), etc. to pipe a list of names to cpio.  You could direct the output to a device instead of a file. 

ls │ cpio −oc >../newfile

cpio −i uses the output file of cpio −o (directed through a pipe with cat in the example), extracts those files that match the patterns (memo/a1, memo/b∗), creates directories below the current directory as needed (−d option), and places the files in the appropriate directories.  The −c option is used when the file is created with a portable header.  If no patterns were given, all files from newfile would be placed in the directory. 

cat newfile │ cpio −icd "memo/a1" "memo/b∗"

cpio −p takes the file names piped to it and copies or links (−l option) those files to another directory on your machine (newdir in the example).  The −d option says to create directories as needed.  The −m option says retain the modification time.  (It is important to use the −depth option of find(1) to generate path names for cpio.  This eliminates problems cpio could have trying to create files under read-only directories.) 

find . −depth −print │ cpio −pdlmv newdir

NOTE: For multi-tape archives, dismount the old volume, mount the new one, and continue to the next tape by typing the name of the next device (probably the same as for the first tape).  To stop, simply type a carriage return, and cpio will end. 

SEE ALSO

ar(1), cat(1), echo(1), find(1), ls(1), tar(1), umask(1). 
cpio(4) in the CX/UX Programmer’s Reference Manual. 

NOTES

1) Path names are restricted to 256 characters.
2) Only the super-user can copy special files.
3) Blocks are reported in 512-byte quantities.
4) If a file has 000 permissions, contains more than 0 characters of data,
   and the user is not root, the file will not be saved or restored.
5) If there are too many unique linked files, the program runs out of memory
   to keep track of them and, thereafter, linking information is lost.
6) The −B option does not work with certain magnetic tape drives.
7) Certain attributes (owner, group, last modified and accessed times) of
   symbolic links cannot be restored when using the −i option.
8) This release of cpio complies with the POSIX 1003.1 and X/Open
   standards.

CX/UX User’s Reference Manual

Typewritten Software • bear@typewritten.org • Edmonds, WA 98026