Museum

Home

Lab Overview

Retrotechnology Articles

⇒ Online Manual

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

find(1)

ls(1)

scpio(1)

sh(1)

tar(1)

cat(1)

echo(1)

ar(4)

cpio(4)



  cpio(1)                             CLIX                             cpio(1)



  NAME

    cpio - Copies file archives in and out

  SYNOPSIS

    cpio -o[acBLvV] [-C bufsize] [[-O file] [-M message]]

    cpio -i[BcdmrtuvVfsSb6kL] [-C bufsize] [[-I file] [-M message]] [pattern
    ... ]

    cpio -p[adlLmuvV] directory

    The cpio command creates a cpio saveset.

  FLAGS

    -a           Resets access times of input files after they have been
                 copied.  Access times are not reset for linked files when
                 cpio -pla is specified.

    -b           Reverses the order of the bytes within each word.  Use -b
                 only with the -i flag.

    -B           Blocks input/output 5,120 bytes to the record.  The default
                 buffer size is 512 bytes when this flag and the -C flag are
                 not used.  (The -B flag does not apply to the -p flag; -B is
                 meaningful only with data directed to or from a character
                 special device, for example, /dev/rmt/0m.)

    -c           Writes header information in ASCII character form for
                 portability.  Always use this flag when origin and
                 destination machines are of different CPU types.

    -C bufsize   Blocks input/output bufsize bytes to the record, where
                 bufsize is replaced by a positive integer.  The default
                 buffer size is 512 bytes when this and -B flags are not used.
                 The -C flag does not apply to the pass flag; -C is meaningful
                 only with data directed to or from a character special device
                 (for example, /dev/rmt/0m.)

    -d           Creates directories as needed.

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

    -I file      Reads 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 flag.




  2/94 - Intergraph Corporation                                              1






  cpio(1)                             CLIX                             cpio(1)



    -k           Attempts to skip corrupted file headers and I/O errors that
                 may be encountered.  With this flag, only files with good
                 headers are read, allowing cpio to copy files from a medium
                 that is corrupted or out of sequence.  (For cpio archives
                 that contain other cpio archives, if an error is encountered,
                 cpio may terminate prematurely.  The cpio command will find
                 the next good header, which may be for a smaller archive, and
                 terminate when the smaller archive's trailer is encountered.)
                 Use only with the -i flag.

    -l           Links files rather than copying them when linking them is
                 possible.  This flag is used only with the -p flag.

    -L           Links and archives the file pointed to rather than the link.
                 By default, cpio saves and restores symbolic links exactly as
                 it finds them.  If this flag is turned on, cpio attempts to
                 follow the link and archive the file it points to rather than
                 the link.  If the -L flag is used with flag -i and the
                 archive was not made using the -L flag, a file will be
                 created which contains only the pathname pointed to by the
                 original symbolic link.

    -m           Retains previous file modification time.  This flag is
                 ineffective on directories and symbolic links that are being
                 copied.

    -M message   Defines a message for use when switching media.  When using
                 the -O or -I flags and specifying a character special device,
                 this flag can be used to define the message displayed when
                 reaching the end of the medium.  One %d can be placed in the
                 message to display the sequence number of the next medium
                 needed to continue.

    -O file      Directs 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 flag.

    -p directory Reads from stdin to obtain a list of pathnames of files that
                 are conditionally created and copied in the destination
                 directory tree based on other flags.

    -r           Interactively renames files.  If you type a null line, the
                 file is skipped.  If you type a ``.'' the original pathname
                 will be copied.  (Use only with the -i or -o flags.)

    -s           Swaps bytes within each halfword.  Use only with the -i flag.

    -S           Swaps halfwords within each word.  Use only with the -i flag.

    -t           Displays a table of contents for the input.  No files are



  2                                              Intergraph Corporation - 2/94






  cpio(1)                             CLIX                             cpio(1)



                 created.

    -u           Copies unconditionally.  Normally, an older file in the
                 archive will not replace a newer existing file with the same
                 name.

    -v           Displays a list of filenames.  When used with the -t flag,
                 the table of contents resembles the output of an ls -l
                 command (see ls(1)).

    -V           Displays a dot for each file seen.  This assures the user
                 that cpio is working without displaying all filenames.

    -6           Processes an old (that is, UNIX System Sixth Edition format)
                 file.  Use only with the -i flag.

  DESCRIPTION

    The cpio -o (copy out) command reads stdin to obtain a list of pathnames,
    and copies those files on stdout with pathname and status information.
    Output is padded to a 512-byte boundary by default.

    The cpio -i (copy in) command extracts files from stdin, which is assumed
    to be the product of a previous cpio -o.  Only files with names that match
    patterns are selected.  The patterns are regular expressions given in the
    filename generating notation of sh.  In patterns, metacharacters ?, *, and
    [...] match the slash (/) character, and backslash (\) is an escape
    character.  A ! metacharacter means NOT.  (For example, the !abc* pattern
    excludes all files that begin with abc.) Multiple patterns may be
    specified.  If no patterns are specified, all files are selected.  Each
    pattern must be enclosed in double quotes so that it is not interpreted by
    the shell; otherwise, the name of a file in the current directory is used.
    Extracted files are conditionally created and copied in the current
    directory tree based on the flags described above.  The permissions of the
    files will be those of the previous cpio -o.  The file owner and group
    will be the current user's unless the user is superuser, which causes cpio
    to retain the file owner and group of the previous cpio -o.

    If cpio -i tries to create a file that exists and the existing file is the
    same age or newer, cpio will output a warning message and not replace the
    file.  (The -u flag can be used to unconditionally overwrite the existing
    file.)

    The cpio -p (pass) command reads from stdin to obtain a list of pathnames
    of files that are conditionally created and copied in the destination
    directory tree based on the flags described above. If there is not enough
    space in the destination directory cpio copies what it can and terminates.
    No error message is displayed.

  EXAMPLES




  2/94 - Intergraph Corporation                                              3






  cpio(1)                             CLIX                             cpio(1)



    1.  To create a list of pathnames and status information, enter the
        following;

        ls | cpio -oc >../newfile

        In this example, cpio reads a list of filenames from stdin.  The cpio
        command then creates a cpio archive, which is redirected into the file
        ../newfile.  The -c flag ensures that the file can be ported to other
        machines.  Instead of using ls, find, echo, or cat could be used to
        pipe a list of names to cpio.  Output could be directed to a device
        instead of a file.

    2.  To extract files from the file created with the cpio -o command,
        enter:

        cat newfile | cpio -icd "memo/a1" "memo/b*

        The cpio -i command uses the output file of cpio -o (directed through
        a pipe with cat in the example), extracts the files that match the
        patterns (memo/a1, memo/b*), creates directories below the current
        directory as needed (-d flag), and places the files in the appropriate
        directories.  The -c flag 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.

    3.  To link a group of files to another directory, enter the following:

        find . -depth -print | cpio -pdlmv newdir

        The cpio -p command copies or links (-l flag) the filenames piped to
        it into another directory (newdir in the example).  The -d flag says
        to create directories as needed.  The -m flag says to retain the
        modification time.  (It is important to use the -depth flag of find to
        generate pathnames for cpio.  This eliminates problems cpio could have
        trying to create files under read-only directories.)  The -v flag
        causes each filename to be displayed to stderr.

  NOTES

    The cpio command assumes four-byte words.

    pathnames are restricted to 256 characters.

    Only the superuser can copy special files.

    Blocks are reported in 512-byte quantities.

    If a file has 000 permissions, contains more than 0 characters, and the
    user is not root, the file will not be copied.

  DIAGNOSTICS



  4                                              Intergraph Corporation - 2/94






  cpio(1)                             CLIX                             cpio(1)



    If cpio reaches the end of medium (such as end of a tape), when writing to
    (-o) or reading from (-i) a character special device and -O and -I are not
    used, cpio will display the message:

    If you want to go on, type device/file name when ready.

    To continue, the medium must be replaced and the character special device
    name (such as /dev/rmt/0m) and a carriage return typed.  The user may want
    to continue by directing cpio to use a different device.  For example, if
    two tape drives are available, it may be desirable to switch between them
    so cpio can proceed while tapes are being changed.  (A carriage return
    alone causes the cpio process to exit.)

    When using the -O flag, the following message may appear when the user is
    prompted for the next floppy:

    Floppy failed: flopp0.0 invalid block number at block 2880


    The message is a courtesy message from the kernel and is not an error.

  EXIT VALUES

    This command exits with a value of 0 if successful.  If unsuccessful, this
    command exits with a nonzero value.

  RELATED INFORMATION

    Commands:  find(1), ls(1), scpio(1) sh(1), tar(1), cat(1), echo(1)

    Files: ar(4), cpio(4)























  2/94 - Intergraph Corporation                                              5




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