xref: /netbsd/bin/pax/cpio.1 (revision 56b14ee0)
1*56b14ee0Swiz.\" $NetBSD: cpio.1,v 1.15 2017/07/03 21:33:23 wiz Exp $
2b73dcc21Schristos.\"
3b73dcc21Schristos.\" Copyright (c) 1997 SigmaSoft, Th. Lockert
4b73dcc21Schristos.\" All rights reserved.
5b73dcc21Schristos.\"
6b73dcc21Schristos.\" Redistribution and use in source and binary forms, with or without
7b73dcc21Schristos.\" modification, are permitted provided that the following conditions
8b73dcc21Schristos.\" are met:
9b73dcc21Schristos.\" 1. Redistributions of source code must retain the above copyright
10b73dcc21Schristos.\"    notice, this list of conditions and the following disclaimer.
11b73dcc21Schristos.\" 2. Redistributions in binary form must reproduce the above copyright
12b73dcc21Schristos.\"    notice, this list of conditions and the following disclaimer in the
13b73dcc21Schristos.\"    documentation and/or other materials provided with the distribution.
14b73dcc21Schristos.\"
15b73dcc21Schristos.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
16b73dcc21Schristos.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
17b73dcc21Schristos.\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
18b73dcc21Schristos.\" IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
19b73dcc21Schristos.\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
20b73dcc21Schristos.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
21b73dcc21Schristos.\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
22b73dcc21Schristos.\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23b73dcc21Schristos.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
24b73dcc21Schristos.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25b73dcc21Schristos.\"
26b73dcc21Schristos.\"	OpenBSD: cpio.1,v 1.14 2000/11/10 17:52:02 aaron Exp
27b73dcc21Schristos.\"
284fa1515fSwiz.Dd June 18, 2011
29b73dcc21Schristos.Dt CPIO 1
30b73dcc21Schristos.Os
31b73dcc21Schristos.Sh NAME
32b73dcc21Schristos.Nm cpio
33b73dcc21Schristos.Nd copy file archives in and out
34b73dcc21Schristos.Sh SYNOPSIS
35b73dcc21Schristos.Nm cpio
36b73dcc21Schristos.Fl o
3773f0c105Swiz.Op Fl AaBcLvZz
38b73dcc21Schristos.Op Fl C Ar bytes
39b73dcc21Schristos.Op Fl F Ar archive
40b73dcc21Schristos.Op Fl H Ar format
41b73dcc21Schristos.Op Fl O Ar archive
42*56b14ee0Swiz.Ar "< name-list"
43*56b14ee0Swiz.Op Ar "> archive"
44b73dcc21Schristos.Nm cpio
45b73dcc21Schristos.Fl i
4673f0c105Swiz.Op Fl 6BbcdfmrSstuvZz
47b73dcc21Schristos.Op Fl C Ar bytes
48b73dcc21Schristos.Op Fl E Ar file
49b73dcc21Schristos.Op Fl F Ar archive
50b73dcc21Schristos.Op Fl H Ar format
51b73dcc21Schristos.Op Fl I Ar archive
52b73dcc21Schristos.Op Ar "pattern ..."
53*56b14ee0Swiz.Op Ar "< archive"
54b73dcc21Schristos.Nm cpio
55b73dcc21Schristos.Fl p
5673f0c105Swiz.Op Fl adLlmuv
57b73dcc21Schristos.Ar destination-directory
58*56b14ee0Swiz.Ar "< name-list"
59b73dcc21Schristos.Sh DESCRIPTION
60b73dcc21SchristosThe
61b73dcc21Schristos.Nm
62b73dcc21Schristoscommand copies files to and from a
63b73dcc21Schristos.Nm
6443c2fa4eSwizarchive.
6543c2fa4eSwizIf the archive is of the form:
6624dd1a7dSchristos.Ar [[user@]host:]file
6724dd1a7dSchristosthen the archive will be processed using
6824dd1a7dSchristos.Xr rmt 8 .
69b73dcc21Schristos.Pp
70b73dcc21SchristosThe options are as follows:
71b73dcc21Schristos.Bl -tag -width Ds
724fa1515fSwiz.It Fl o , Fl Fl create
73b73dcc21SchristosCreate an archive.
74b73dcc21SchristosReads the list of files to store in the
75b73dcc21Schristosarchive from standard input, and writes the archive on standard
76b73dcc21Schristosoutput.
77b73dcc21Schristos.Bl -tag -width Ds
784fa1515fSwiz.It Fl a , Fl Fl reset-access-time
79b73dcc21SchristosReset the access times on files that have been copied to the
80b73dcc21Schristosarchive.
814fa1515fSwiz.It Fl A , Fl Fl append
82b73dcc21SchristosAppend to the specified archive.
83b73dcc21Schristos.It Fl B
84b73dcc21SchristosSet block size of output to 5120 bytes.
85b73dcc21Schristos.It Fl c
86b73dcc21SchristosUse ASCII format for
87b73dcc21Schristos.Nm
88b73dcc21Schristosheader for portability.
89b73dcc21Schristos.It Fl C Ar bytes
90b73dcc21SchristosSet the block size of output to
91b73dcc21Schristos.Ar bytes .
92b73dcc21Schristos.It Fl F Ar archive
93b73dcc21Schristos.It Fl O Ar archive
94b73dcc21SchristosUse the specified file name as the archive to write to.
95b73dcc21Schristos.It Fl H Ar format
96b73dcc21SchristosWrite the archive in the specified format.
97b73dcc21SchristosRecognized formats are:
98b73dcc21Schristos.Pp
99b73dcc21Schristos.Bl -tag -width sv4cpio -compact
100b73dcc21Schristos.It Ar bcpio
101b73dcc21SchristosOld binary
102b73dcc21Schristos.Nm
103b73dcc21Schristosformat.
104b73dcc21Schristos.It Ar cpio
105b73dcc21SchristosOld octal character
106b73dcc21Schristos.Nm
107b73dcc21Schristosformat.
108b73dcc21Schristos.It Ar sv4cpio
109b73dcc21SchristosSVR4 hex
110b73dcc21Schristos.Nm
111b73dcc21Schristosformat.
112b73dcc21Schristos.It Ar tar
113b73dcc21SchristosOld tar format.
114b73dcc21Schristos.It Ar ustar
115b73dcc21SchristosPOSIX ustar format.
116b73dcc21Schristos.El
117b73dcc21Schristos.It Fl L
118b73dcc21SchristosFollow symbolic links.
119b73dcc21Schristos.It Fl v
120b73dcc21SchristosBe verbose about operations.
121b73dcc21SchristosList filenames as they are written to the archive.
1224fa1515fSwiz.It Fl Fl xz
12333d59250SchristosCompress/decompress archive using
12433d59250Schristos.Xr xz 1
12533d59250Schristosformat.
126b73dcc21Schristos.It Fl Z
127b73dcc21SchristosCompress archive using
128b73dcc21Schristos.Xr compress 1
129b73dcc21Schristosformat.
1304fa1515fSwiz.It Fl z
1314fa1515fSwizCompress/decompress archive using
1324fa1515fSwiz.Xr gzip 1
1334fa1515fSwizformat.
134b73dcc21Schristos.El
1354fa1515fSwiz.It Fl i , Fl Fl extract
136b73dcc21SchristosRestore files from an archive.
137b73dcc21SchristosReads the archive file from
138b73dcc21Schristosstandard input and extracts files matching the
139b73dcc21Schristos.Ar patterns
140b73dcc21Schristosthat were specified on the command line.
141b73dcc21Schristos.Bl -tag -width Ds
142b73dcc21Schristos.It Fl b
143b73dcc21SchristosDo byte and word swapping after reading in data from the
144b73dcc21Schristosarchive, for restoring archives created on systems with
145b73dcc21Schristosa different byte order.
146b73dcc21Schristos.It Fl B
147b73dcc21SchristosSet the block size of the archive being read to 5120 bytes.
148b73dcc21Schristos.It Fl c
149b73dcc21SchristosExpect the archive headers to be in ASCII format.
150b73dcc21Schristos.It Fl C Ar bytes
151b73dcc21SchristosRead archive written with a block size of
152b73dcc21Schristos.Ar bytes .
1534fa1515fSwiz.It Fl d , Fl Fl make-directories
154b73dcc21SchristosCreate any intermediate directories as needed during
155b73dcc21Schristosrestore.
1564fa1515fSwiz.It Fl E Ar file , Fl Fl pattern-file Ar file
157b73dcc21SchristosRead list of file name patterns to extract or list from
158b73dcc21Schristos.Ar file .
1594fa1515fSwiz.It Fl f , Fl Fl nonmatching
160b73dcc21SchristosRestore all files except those matching the
161b73dcc21Schristos.Ar patterns
162b73dcc21Schristosgiven on the command line.
1634fa1515fSwiz.It Fl F Ar archive , Fl Fl file Ar archive
164b73dcc21Schristos.It Fl I Ar archive
165b73dcc21SchristosUse the specified file as the input for the archive.
1664fa1515fSwiz.It Fl H Ar format , Fl Fl format Ar format
167b73dcc21SchristosRead an archive of the specified format.
168b73dcc21SchristosRecognized formats are:
169b73dcc21Schristos.Pp
170b73dcc21Schristos.Bl -tag -width sv4cpio -compact
171b73dcc21Schristos.It Ar bcpio
172b73dcc21SchristosOld binary
173b73dcc21Schristos.Nm
174b73dcc21Schristosformat.
175b73dcc21Schristos.It Ar cpio
176b73dcc21SchristosOld octal character
177b73dcc21Schristos.Nm
178b73dcc21Schristosformat.
179b73dcc21Schristos.It Ar sv4cpio
180b73dcc21SchristosSVR4 hex
181b73dcc21Schristos.Nm
182b73dcc21Schristosformat.
183b73dcc21Schristos.It Ar tar
184b73dcc21SchristosOld tar format.
185b73dcc21Schristos.It Ar ustar
186b73dcc21SchristosPOSIX ustar format.
187b73dcc21Schristos.El
188b73dcc21Schristos.It Fl m
189b73dcc21SchristosRestore modification times on files.
1904fa1515fSwiz.It Fl r , Fl Fl rename
191b73dcc21SchristosRename restored files interactively.
192b73dcc21Schristos.It Fl s
193b73dcc21SchristosSwap bytes after reading data from the archive.
1944fa1515fSwiz.It Fl S , Fl Fl swap-halfwords
195b73dcc21SchristosSwap words after reading data from the archive.
1964fa1515fSwiz.It Fl t , Fl Fl list
197b73dcc21SchristosOnly list the contents of the archive, no files or
198b73dcc21Schristosdirectories will be created.
1994fa1515fSwiz.It Fl u , Fl Fl unconditional
200b73dcc21SchristosOverwrite files even when the file in the archive is
201b73dcc21Schristosolder than the one that will be overwritten.
2024fa1515fSwiz.It Fl v , Fl Fl verbose
203b73dcc21SchristosBe verbose about operations.
204b73dcc21SchristosList filenames as they are copied in from the archive.
205b73dcc21Schristos.It Fl z
206b73dcc21SchristosUncompress archive using
207b73dcc21Schristos.Xr gzip 1
208b73dcc21Schristosformat.
209b73dcc21Schristos.It Fl Z
210b73dcc21SchristosUncompress archive using
211b73dcc21Schristos.Xr compress 1
212b73dcc21Schristosformat.
213b73dcc21Schristos.It Fl 6
214b73dcc21SchristosProcess old-style
215b73dcc21Schristos.Nm
216b73dcc21Schristosformat archives.
217b73dcc21Schristos.El
2184fa1515fSwiz.It Fl p , Fl Fl pass-through
219b73dcc21SchristosCopy files from one location to another in a single pass.
220b73dcc21SchristosThe list of files to copy are read from standard input and
221b73dcc21Schristoswritten out to a directory relative to the specified
222b73dcc21Schristos.Ar directory
223b73dcc21Schristosargument.
224b73dcc21Schristos.Bl -tag -width Ds
225b73dcc21Schristos.It Fl a
226b73dcc21SchristosReset the access times on files that have been copied.
227b73dcc21Schristos.It Fl d
228b73dcc21SchristosCreate any intermediate directories as needed to write
229b73dcc21Schristosthe files at the new location.
2304fa1515fSwiz.It Fl l , Fl Fl link
231b73dcc21SchristosWhen possible, link files rather than creating an
232b73dcc21Schristosextra copy.
2334fa1515fSwiz.It Fl L , Fl Fl dereference
234b73dcc21SchristosFollow symbolic links.
2354fa1515fSwiz.It Fl m , Fl Fl preserve-modification-time
236b73dcc21SchristosRestore modification times on files.
2374fa1515fSwiz.It Fl u , Fl Fl unconditional
238b73dcc21SchristosOverwrite files even when the original file being copied is
239b73dcc21Schristosolder than the one that will be overwritten.
2404fa1515fSwiz.It Fl v , Fl Fl verbose
241b73dcc21SchristosBe verbose about operations.
242b73dcc21SchristosList filenames as they are copied.
2434fa1515fSwiz.It Fl Fl force-local
244900b115eSgrantDo not interpret filenames that contain a
245900b115eSgrant.Sq \&:
246900b115eSgrantas remote files.
2474fa1515fSwiz.It Fl Fl insecure
24824dd1a7dSchristosNormally
24924dd1a7dSchristos.Nm
250900b115eSgrantignores filenames that contain
25173f0c105Swiz.Dq ..
25273f0c105Swizas a path component.
25373f0c105SwizWith this option, files that contain
25473f0c105Swiz.Dq ..
255900b115eSgrantcan be processed.
256b73dcc21Schristos.El
257b73dcc21Schristos.El
258553e3c84Swiz.Sh EXIT STATUS
259b73dcc21Schristos.Nm
260b73dcc21Schristoswill exit with one of the following values:
261b73dcc21Schristos.Bl -tag -width 2n
262b73dcc21Schristos.It 0
263b73dcc21SchristosAll files were processed successfully.
264b73dcc21Schristos.It 1
265b73dcc21SchristosAn error occurred.
266b73dcc21Schristos.El
267b73dcc21Schristos.Pp
268b73dcc21SchristosWhenever
269b73dcc21Schristos.Nm
270b73dcc21Schristoscannot create a file or a link when extracting an archive or cannot
271b73dcc21Schristosfind a file while writing an archive, or cannot preserve the user
272b73dcc21SchristosID, group ID, file mode, or access and modification times when the
273b73dcc21Schristos.Fl p
274b73dcc21Schristosoption is specified, a diagnostic message is written to standard
275b73dcc21Schristoserror and a non-zero exit value will be returned, but processing
276b73dcc21Schristoswill continue.
277b73dcc21SchristosIn the case where
278b73dcc21Schristos.Nm
279b73dcc21Schristoscannot create a link to a file,
280b73dcc21Schristos.Nm
281b73dcc21Schristoswill not create a second copy of the file.
282b73dcc21Schristos.Pp
283b73dcc21SchristosIf the extraction of a file from an archive is prematurely terminated
284b73dcc21Schristosby a signal or error,
285b73dcc21Schristos.Nm
286b73dcc21Schristosmay have only partially extracted the file the user wanted.
287b73dcc21SchristosAdditionally, the file modes of extracted files and directories may
288b73dcc21Schristoshave incorrect file bits, and the modification and access times may
289b73dcc21Schristosbe wrong.
290b73dcc21Schristos.Pp
291b73dcc21SchristosIf the creation of an archive is prematurely terminated by a signal
292b73dcc21Schristosor error,
293b73dcc21Schristos.Nm
294b73dcc21Schristosmay have only partially created the archive which may violate the
295b73dcc21Schristosspecific archive format specification.
296b73dcc21Schristos.Sh SEE ALSO
297b73dcc21Schristos.Xr pax 1 ,
298b73dcc21Schristos.Xr tar 1
299b73dcc21Schristos.Sh AUTHORS
300e1e4c2e5Swiz.An Keith Muller
301e1e4c2e5Swizat the University of California, San Diego.
302b73dcc21Schristos.Sh BUGS
303b73dcc21SchristosThe
304b73dcc21Schristos.Fl s
305b73dcc21Schristosand
306b73dcc21Schristos.Fl S
307b73dcc21Schristosoptions are currently not implemented.
308