.nr g 2 .\" $MirOS: src/bin/pax/cpio.1,v 1.42 2020/09/04 22:37:02 tg Exp $ .\" $OpenBSD: cpio.1,v 1.35 2014/09/08 01:27:54 schwarze Exp $ .\" .\" Copyright (c) 2005, 2009, 2011, 2012, 2014, 2015, 2016, .\" 2017, 2018 .\" mirabilos .\" Copyright (c) 1997 SigmaSoft, Th. Lockert .\" All rights reserved. .\" .\" Redistribution and use in source and binary forms, with or without .\" modification, are permitted provided that the following conditions .\" are met: .\" 1. Redistributions of source code must retain the above copyright .\" notice, this list of conditions and the following disclaimer. .\" 2. Redistributions in binary form must reproduce the above copyright .\" notice, this list of conditions and the following disclaimer in the .\" documentation and/or other materials provided with the distribution. .\" .\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR .\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES .\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. .\" IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, .\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT .\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, .\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY .\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT .\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF .\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. .\"- .\" Try to make GNU groff and AT&T nroff more compatible .\" * ` generates ‘ in gnroff, so use \` .\" * ' generates ’ in gnroff, \' generates ´, so use \*(aq .\" * - generates ‐ in gnroff, \- generates −, so .tr it to - .\" thus use - for hyphens and \- for minus signs and option dashes .\" * ~ is size-reduced and placed atop in groff, so use \*(TI .\" * ^ is size-reduced and placed atop in groff, so use \*(ha .\" * \(en does not work in nroff, so use \*(en for a solo en dash .\" * and \*(EM for a correctly spaced em dash .\" * <>| are problematic, so redefine and use \*(Lt\*(Gt\*(Ba .\" Also make sure to use \& *before* a punctuation char that is to not .\" be interpreted as punctuation, and especially with two-letter words .\" but also (after) a period that does not end a sentence (“e.g.\&”). .\" The section after the "doc" macropackage has been loaded contains .\" additional code to convene between the UCB mdoc macropackage (and .\" its variant as BSD mdoc in groff) and the GNU mdoc macropackage. .\" .ie \n(.g \{\ . if \*[.T]ascii .tr \-\N'45' . if \*[.T]latin1 .tr \-\N'45' . if \*[.T]utf8 .tr \-\N'45' . ds <= \[<=] . ds >= \[>=] . ds Rq \[rq] . ds Lq \[lq] . ds sL \(aq . ds sR \(aq . if \*[.T]utf8 .ds sL ` . if \*[.T]ps .ds sL ` . if \*[.T]utf8 .ds sR ' . if \*[.T]ps .ds sR ' . ds aq \(aq . ds TI \(ti . ds ha \(ha . ds en \(en .\} .el \{\ . ds aq ' . ds TI ~ . ds ha ^ . ds en \(em .\} .ie n \{\ . ds EM \ \*(en\ \& .\} .el \{\ . ds EM \f(TR\^\(em\^\fP .\} .\" .\" Implement .Dd with the Mdocdate RCS keyword .\" .rn Dd xD .de Dd .ie \\$1$Mdocdate: \{\ . xD \\$2 \\$3, \\$4 .\} .el .xD \\$1 \\$2 \\$3 \\$4 \\$5 \\$6 \\$7 \\$8 .. .\" .\" .Dd must come before definition of .Mx, because when called .\" with -mandoc, it might implement .Mx itself, but we want to .\" use our own definition. And .Dd must come *first*, always. .\" .Dd $Mdocdate: September 4 2020 $ .\" .\" Check which macro package we use, and do other -mdoc setup. .\" .ie \n(.g \{\ . if \*[.T]utf8 .tr \[la]\*(Lt . if \*[.T]utf8 .tr \[ra]\*(Gt . ie d volume-ds-1 .ds tT gnu . el .ie d doc-volume-ds-1 .ds tT gnp . el .ds tT bsd .\} .el .ds tT ucb .\" .\" Implement .Mx (MirBSD) .\" .ie "\*(tT"gnu" \{\ . eo . de Mx . nr curr-font \n[.f] . nr curr-size \n[.ps] . ds str-Mx \f[\n[curr-font]]\s[\n[curr-size]u] . ds str-Mx1 \*[Tn-font-size]\%MirBSD\*[str-Mx] . if !\n[arg-limit] \ . if \n[.$] \{\ . ds macro-name Mx . parse-args \$@ . \} . if (\n[arg-limit] > \n[arg-ptr]) \{\ . nr arg-ptr +1 . ie (\n[type\n[arg-ptr]] == 2) \ . as str-Mx1 \~\*[arg\n[arg-ptr]] . el \ . nr arg-ptr -1 . \} . ds arg\n[arg-ptr] "\*[str-Mx1] . nr type\n[arg-ptr] 2 . ds space\n[arg-ptr] "\*[space] . nr num-args (\n[arg-limit] - \n[arg-ptr]) . nr arg-limit \n[arg-ptr] . if \n[num-args] \ . parse-space-vector . print-recursive .. . ec . ds sP \s0 . ds tN \*[Tn-font-size] .\} .el .ie "\*(tT"gnp" \{\ . eo . de Mx . nr doc-curr-font \n[.f] . nr doc-curr-size \n[.ps] . ds doc-str-Mx \f[\n[doc-curr-font]]\s[\n[doc-curr-size]u] . ds doc-str-Mx1 \*[doc-Tn-font-size]\%MirBSD\*[doc-str-Mx] . if !\n[doc-arg-limit] \ . if \n[.$] \{\ . ds doc-macro-name Mx . doc-parse-args \$@ . \} . if (\n[doc-arg-limit] > \n[doc-arg-ptr]) \{\ . nr doc-arg-ptr +1 . ie (\n[doc-type\n[doc-arg-ptr]] == 2) \ . as doc-str-Mx1 \~\*[doc-arg\n[doc-arg-ptr]] . el \ . nr doc-arg-ptr -1 . \} . ds doc-arg\n[doc-arg-ptr] "\*[doc-str-Mx1] . nr doc-type\n[doc-arg-ptr] 2 . ds doc-space\n[doc-arg-ptr] "\*[doc-space] . nr doc-num-args (\n[doc-arg-limit] - \n[doc-arg-ptr]) . nr doc-arg-limit \n[doc-arg-ptr] . if \n[doc-num-args] \ . doc-parse-space-vector . doc-print-recursive .. . ec . ds sP \s0 . ds tN \*[doc-Tn-font-size] .\} .el \{\ . de Mx . nr cF \\n(.f . nr cZ \\n(.s . ds aa \&\f\\n(cF\s\\n(cZ . if \\n(aC==0 \{\ . ie \\n(.$==0 \&MirBSD\\*(aa . el .aV \\$1 \\$2 \\$3 \\$4 \\$5 \\$6 \\$7 \\$8 \\$9 . \} . if \\n(aC>\\n(aP \{\ . nr aP \\n(aP+1 . ie \\n(C\\n(aP==2 \{\ . as b1 \&MirBSD\ #\&\\*(A\\n(aP\\*(aa . ie \\n(aC>\\n(aP \{\ . nr aP \\n(aP+1 . nR . \} . el .aZ . \} . el \{\ . as b1 \&MirBSD\\*(aa . nR . \} . \} .. .\} .\"- .ie \ng==1 \{\ . ds nc mircpio . ds np mirpax . ds nt mirtar . ds nm mircpio . Dt MIRCPIO 1 .\} .el .ie \ng==2 \{\ . ds nc paxcpio . ds np pax . ds nt paxtar . ds nm paxcpio . Dt PAXCPIO 1 .\} .el \{\ . ds nc cpio . ds np pax . ds nt tar . ds nm cpio . Dt CPIO 1 .\} .\"- .Os MirBSD .Sh NAME .ie \ng==1 \{\ .Nm mircpio .Nd copy file archives in and out .\} .el .ie \ng==2 \{\ .Nm paxcpio .Nd copy file archives in and out .\} .el \{\ .Nm cpio .Nd copy file archives in and out .\} .Sh SYNOPSIS .Bk -words .Nm \*(nm .Fl o .Op Fl 0AaBcJjLVvZz .Op Fl C Ar bytes .Op Fl F Ar archive .Op Fl H Ar format .Op Fl M Ar flag .Op Fl O Ar archive .No \*(Lt Ar name-list .Op \*(Gt Ar archive .Nm \*(nm .Fl i .Op Fl 06BbcdfJjmrSstuVvZz .Op Fl C Ar bytes .Op Fl E Ar file .Op Fl F Ar archive .Op Fl H Ar format .Op Fl I Ar archive .Op Fl M Ar flag .Op Ar pattern ... .Op \*(Lt Ar archive .Nm \*(nm .Fl p .Op Fl 0adLlmuVv .Ar destination-directory .No \*(Lt Ar name-list .Ek .Sh DESCRIPTION The .Nm command copies files to and from a .Nm cpio archive. .Pp The options are as follows: .Bl -tag -width Ds .It Fl 0 Use the NUL .Pq Ql \e0 character as a pathname terminator, instead of newline .Pq Ql \en . This applies only to the pathnames read from standard input in the write and copy modes, and to the pathnames written to standard output in list mode. This option is expected to be used in concert with the .Fl print0 function in .Xr find 1 , the .Fl d Ar \*(aq\*(aq option to the .Ic read built-in utility of .Xr mksh 1 or the .Fl 0 flag in .Xr xargs 1 . .It Fl o Create an archive. Reads the list of files to store in the archive from standard input, and writes the archive on standard output. .Bl -tag -width Ds .It Fl A Append to the specified archive. .It Fl a Reset the access times on files that have been copied to the archive. .It Fl B Set block size of output to 5120 bytes. .It Fl C Ar bytes Set the block size of output to .Ar bytes . .It Fl c Use ASCII format for .Nm cpio header for portability. .It Fl F Ar archive Use the specified file as the input for the archive. .It Fl H Ar format Write the archive in the specified format. Recognised formats are: .Pp .Bl -tag -width sv4cpio -compact .It Ar ar Unix Archiver. .It Ar bcpio Old binary .Nm cpio format. Selected by .Fl 6 . .It Ar cpio Old octal character .Nm cpio format. Selected by .Fl c . .It Ar sv4cpio SVR4 hex .Nm cpio format. .It Ar sv4crc SVR4 hex .Nm cpio format with checksums. This is the default format for creating new archives. .It Ar tar Old tar format. .It Ar ustar POSIX ustar format. .It "\ " .It Ar bin These four formats...\& .It Ar crc \&...are supported...\& .It Ar newc \&...for backwards...\& .It Ar odc \&...compatibility only. .El .It Fl J Use the xz utility to compress the archive. .It Fl j Use the bzip2 utility to compress the archive. .It Fl L Follow symbolic links. .It Fl M Ar flag Configure the archive normaliser. .Ar flag is either a numeric value compatible to .Xr strtonum 3 which is directly stored in the flags word, or one of the following values, optionally prefixed with .Dq no\- to turn them off: .Pp .Bl -tag -width xxxxxx -compact .It Ar inodes 0x0001: Serialise inodes, zero device info. .br (cpio, sv4cpio, sv4crc) .It Ar links 0x0002: Store content of hard links only once. .br (cpio, sv4cpio, sv4crc) .It Ar mtime 0x0004: Zero out the file modification time. .br (ar, cpio, sv4cpio, sv4crc, ustar) .It Ar uidgid 0x0008: Set owner to 0:0 .Pq Li root Ns : Ns Li wheel . .br (ar, cpio, sv4cpio, sv4crc, ustar) .It Ar verb 0x0010: Debug this option. .It Ar debug 0x0020: Debug file header storage. .It Ar lncp 0x0040: Extract hard links by copy if link fails. .It Ar numid 0x0080: Use only numeric uid and gid values. .br (ustar) .It Ar gslash 0x0100: Append a slash after directory names. .br (ustar) .It Ar set 0x0003: Keep ownership and mtime intact. .It Ar dist 0x008B: Clean everything except mtime. .It Ar norm 0x008F: Clean everything. .It Ar root 0x0089: Clean owner and device information. .El .Pp When creating an archive and verbosely listing output, these normalisation operations are not reflected in the output, because they are made only after the output has been shown. .Pp This option is only implemented for the ar, cpio, sv4cpio, sv4crc, and ustar file format writing routines. .It Fl O Ar archive Use the specified file name as the archive to write to. .It Fl V Print a dot .Pq Sq \&. for each file written to the archive. .It Fl v Be verbose about operations. List filenames as they are written to the archive. .It Fl Z Use the .Xr compress 1 utility to compress the archive. .It Fl z Use the .Xr gzip 1 utility to compress the archive. .El .It Fl i Restore files from an archive. Reads the archive file from standard input and extracts files matching the .Ar patterns that were specified on the command line. .Bl -tag -width Ds .It Fl 6 Process old-style .Nm cpio format archives. .It Fl B Set the block size of the archive being read to 5120 bytes. .It Fl b Do byte and word swapping after reading in data from the archive, for restoring archives created on systems with a different byte order. .It Fl C Ar bytes Read archive written with a block size of .Ar bytes . .It Fl c Expect the archive headers to be in ASCII format. .It Fl d Create any intermediate directories as needed during restore. .It Fl E Ar file Read list of file name patterns to extract or list from .Ar file . .It Fl F Ar archive , Fl I Ar archive Use the specified file as the input for the archive. .It Fl f Restore all files except those matching the .Ar patterns given on the command line. .It Fl H Ar format Read an archive of the specified format. Recognised formats are: .Pp .Bl -tag -width sv4cpio -compact .It Ar ar Unix Archiver. .It Ar bcpio Old binary .Nm cpio format. .It Ar cpio Old octal character .Nm cpio format. .It Ar sv4cpio SVR4 hex .Nm cpio format. .It Ar sv4crc SVR4 hex .Nm cpio format with checksums. .It Ar tar Old tar format. .It Ar ustar POSIX ustar format. .It "\ " .It Ar bin These four formats...\& .It Ar crc \&...are supported...\& .It Ar newc \&...for backwards...\& .It Ar odc \&...compatibility only. .El .It Fl J Use the xz utility to decompress the archive. .It Fl j Use the bzip2 utility to decompress the archive. .It Fl m Restore modification times on files. .It Fl r Rename restored files interactively. .It Fl S Swap words after reading data from the archive. .It Fl s Swap bytes after reading data from the archive. .It Fl t Only list the contents of the archive, no files or directories will be created. .It Fl u Overwrite files even when the file in the archive is older than the one that will be overwritten. .It Fl V Print a dot .Pq Sq \&. for each file read from the archive. .It Fl v Be verbose about operations. List filenames as they are copied in from the archive. .It Fl Z Use the .Xr compress 1 utility to decompress the archive. .It Fl z Use the .Xr gzip 1 utility to decompress the archive. .El .It Fl p Copy files from one location to another in a single pass. The list of files to copy are read from standard input and written out to a directory relative to the specified .Ar directory argument. .Bl -tag -width Ds .It Fl a Reset the access times on files that have been copied. .It Fl d Create any intermediate directories as needed to write the files at the new location. .It Fl L Follow symbolic links. .It Fl l When possible, link files rather than creating an extra copy. .It Fl m Restore modification times on files. .It Fl u Overwrite files even when the original file being copied is older than the one that will be overwritten. .It Fl V Print a dot .Pq Sq \&. for each file copied. .It Fl v Be verbose about operations. List filenames as they are copied. .El .El .Sh ENVIRONMENT .Bl -tag -width Fl .It Ev TMPDIR Path in which to store temporary files. .El .Sh EXIT STATUS The .Nm utility exits with one of the following values: .Pp .Bl -tag -width Ds -offset indent -compact .It 0 All files were processed successfully. .It 1 An error occurred. .El .Sh DIAGNOSTICS Whenever .Nm cannot create a file or a link when extracting an archive or cannot find a file while writing an archive, or cannot preserve the user ID, group ID, file mode, or access and modification times when the .Fl p option is specified, a diagnostic message is written to standard error and a non-zero exit value will be returned, but processing will continue. In the case where .Nm cannot create a link to a file, unless .Fl M Ar lncp is given, .Nm will not create a second copy of the file. .Pp If the extraction of a file from an archive is prematurely terminated by a signal or error, .Nm may have only partially extracted the file the user wanted. Additionally, the file modes of extracted files and directories may have incorrect file bits, and the modification and access times may be wrong. .Pp If the creation of an archive is prematurely terminated by a signal or error, .Nm may have only partially created the archive, which may violate the specific archive format specification. .Sh SEE ALSO .Xr ar 1 , .if \ng==1 \{\ .Xr cpio 1 , .Xr deb 5 , .Xr mirpax 1 , .Xr mirtar 1 , .\} .ie \ng==2 \{\ .Xr cpio 1 , .Xr deb 5 , .Xr pax 1 , .Xr paxtar 1 , .\} .el \{\ .Xr pax 1 , .\} .Xr tar 1 .Sh AUTHORS .An -nosplit .An Keith Muller at the University of California, San Diego. .Mx extensions by .An mirabilos Aq m@mirbsd.org . .Sh CAVEATS Different file formats have different maximum file sizes. It is recommended that a format such as cpio or ustar be used for larger files. .Bl -column "File format" "Maximum file size" -offset indent .It Sy "File format" Ta Sy "Maximum file size" .It ar Ta "10 Gigabytes \- 1 Byte" .It bcpio Ta "4 Gibibytes" .It sv4cpio Ta "4 Gibibytes" .It sv4crc Ta "4 Gibibytes" .It cpio Ta "8 Gibibytes" .It tar Ta "8 Gibibytes" .It ustar Ta "8 Gibibytes" .El .Pp The backwards-compatible format options are not available in the .Xr \*(np 1 front-end. .Pp The .Fl M option is a MirBSD extension, available starting with .Mx 8 . Archives written using these options are, however, compatible to the standard and should be readable on any other system. The only option whose behaviour is not explicitly allowed by the standard is hard link unification (write file contens only once) selected by .Fl M Ar 0x0002 . .Pp The .Fl V option is a GNU extension, available starting with .Mx 11 . .Pp The .Ar ar file format matches APT repositories and the BSD .Xr ar 1 specification, not GNU binutils (which can however read them) or SYSV systems. .Sh BUGS The .Fl s and .Fl S options are currently not implemented. .Pp The .Ar pax file format is not yet supported.