]> CyberLeo.Net >> Repos - FreeBSD/releng/8.0.git/blob - contrib/cpio/doc/cpio.texi
Adjust to reflect 8.0-RELEASE.
[FreeBSD/releng/8.0.git] / contrib / cpio / doc / cpio.texi
1 \input texinfo   @c -*-texinfo-*-
2 @c %**start of header
3 @setfilename cpio.info
4 @settitle cpio
5 @setchapternewpage off
6 @c %**end of header
7
8 @dircategory Archiving
9 @direntry
10 * Cpio: (cpio).                 Copy-in-copy-out archiver to tape or disk.
11 @end direntry
12
13 @include version.texi
14
15 @copying
16 This manual documents GNU cpio (version @value{VERSION}, @value{UPDATED}).
17
18 Copyright @copyright{} 1995, 2001, 2002, 2004 Free Software Foundation, Inc.
19 @sp 1
20 @quotation
21 Permission is granted to copy, distribute and/or modify this document
22 under the terms of the GNU Free Documentation License, Version 1.2 or
23 any later version published by the Free Software Foundation; with no
24 Invariant Sections, with the Front-Cover texts being ``A GNU Manual'',
25 and with the Back-Cover Texts as in (a) below.  A copy of the license
26 is included in the section entitled ``GNU Free Documentation License''.
27
28 (a) The FSF's Back-Cover Text is: ``You have freedom to copy and modify
29 this GNU Manual, like GNU software.  Copies published by the Free
30 Software Foundation raise funds for GNU development.''
31 @end quotation
32 @end copying
33
34 @titlepage
35 @title GNU CPIO
36 @subtitle @value{VERSION} @value{UPDATED}
37 @author by Robert Carleton
38 @c copyright page
39 @page
40 @vskip 0pt plus 1filll
41 @insertcopying
42 @sp 2
43 Published by the Free Software Foundation @*
44 51 Franklin Street, Fifth Floor, @*
45 Boston, MA 02110-1301, USA @*
46 @end titlepage
47
48 @node Top, Introduction, (dir), (dir)
49 @comment  node-name,  next,  previous,  up
50
51 @ifinfo
52 @top
53
54 GNU cpio is a tool for creating and extracting archives, or copying
55 files from one place to another.  It handles a number of cpio formats as
56 well as reading and writing tar files.  This is the first edition of the 
57 GNU cpio documentation and is consistent with @value{VERSION}.
58
59 @end ifinfo
60
61 @menu
62 * Introduction::                
63 * Tutorial::                    Getting started.
64 * Invoking cpio::               How to invoke @command{cpio}.
65 * Media::                       Using tapes and other archive media.
66 * Reports::                     Reporting bugs or suggestions
67 * Concept Index::               Concept index.
68
69 @detailmenu
70  --- The Detailed Node Listing ---
71
72 Invoking cpio
73
74 * Copy-out mode::               
75 * Copy-in mode::                
76 * Copy-pass mode::              
77 * Options::                     
78
79 @end detailmenu
80 @end menu
81
82 @node Introduction, Tutorial, Top, Top
83 @comment  node-name,  next,  previous,  up
84 @chapter Introduction
85
86 GNU cpio copies files into or out of a cpio or tar archive, The archive
87 can be another file on the disk, a magnetic tape, or a pipe.
88
89 GNU cpio supports the following archive formats: binary, old ASCII, new
90 ASCII, crc, HPUX binary, HPUX old ASCII, old tar, and POSIX.1 tar.  The
91 tar format is provided for compatibility with the tar program. By
92 default, cpio creates binary format archives, for compatibility with
93 older cpio programs.  When extracting from archives, cpio automatically
94 recognizes which kind of archive it is reading and can read archives
95 created on machines with a different byte-order.
96
97 @node Tutorial, Invoking cpio, Introduction, Top
98 @comment  node-name,  next,  previous,  up
99 @chapter Tutorial
100 @cindex creating a cpio archive
101 @cindex extracting a cpio archive
102 @cindex copying directory structures
103 @cindex passing directory structures
104
105
106 GNU cpio performs three primary functions.  Copying files to an
107 archive, Extracting files from an archive, and passing files to another
108 directory tree.  An archive can be a file on disk, one or more floppy
109 disks, or one or more tapes.
110
111 When creating an archive, cpio takes the list of files to be processed
112 from the standard input, and then sends the archive to the standard
113 output, or to the device defined by the @option{-F} option.
114 @xref{Copy-out mode}.  Usually find or ls is used to provide this list
115 to the standard input.  In the following example you can see the
116 possibilities for archiving the contents of a single directory.
117
118
119 @example
120 @cartouche
121 % ls | cpio -ov > directory.cpio
122 @end cartouche
123 @end example
124
125 The @option{-o} option creates the archive, and the @option{-v} option
126 prints the names of the files archived as they are added.  Notice that
127 the options can be put together after a single @option{-} or can be placed
128 separately on the command line.  The @samp{>} redirects the cpio output
129 to the file @samp{directory.cpio}.
130
131
132 If you wanted to archive an entire directory tree, the find command can
133 provide the file list to cpio:
134
135
136 @example
137 @cartouche
138 % find . -print -depth | cpio -ov > tree.cpio
139 @end cartouche
140 @end example
141
142
143 This will take all the files in the current directory, the directories
144 below and place them in the archive tree.cpio.  Again the @option{-o}
145 creates an archive, and the @option{-v} option shows you the name of the
146 files as they are archived.  @xref{Copy-out mode}.  Using the @samp{.} in the
147 find statement will give you more flexibility when doing restores, as it
148 will save file names with a relative path vice a hard wired, absolute
149 path.  The @option{-depth} option forces @samp{find} to print of the
150 entries in a directory before printing the directory itself.  This
151 limits the effects of restrictive directory permissions by printing the
152 directory entries in a directory before the directory name itself.
153
154
155
156
157 Extracting an archive requires a bit more thought because cpio will not
158 create directories by default.  Another characteristic, is it will not
159 overwrite existing files unless you tell it to.
160
161
162 @example
163 @cartouche
164 % cpio -iv < directory.cpio
165 @end cartouche
166 @end example
167
168 This will retrieve the files archived in the file directory.cpio and
169 place them in the present directory.  The @option{-i} option extracts the
170 archive and the @option{-v} shows the file names as they are extracted.
171 If you are dealing with an archived directory tree, you need to use the
172 @option{-d} option to create directories as necessary, something like:
173
174 @example
175 @cartouche
176 % cpio -idv < tree.cpio
177 @end cartouche
178 @end example
179
180 This will take the contents of the archive tree.cpio and extract it to
181 the current directory.  If you try to extract the files on top of files
182 of the same name that already exist (and have the same or later
183 modification time) cpio will not extract the file unless told to do so
184 by the -u option.  @xref{Copy-in mode}.
185
186
187 In copy-pass mode, cpio copies files from one directory tree to another,
188 combining the copy-out and copy-in steps without actually using an
189 archive.  It reads the list of files to copy from the standard input;
190 the directory into which it will copy them is given as a non-option
191 argument.  @xref{Copy-pass mode}.
192
193 @example
194 @cartouche
195 % find . -depth -print0 | cpio --null -pvd new-dir
196 @end cartouche
197 @end example
198
199
200 The example shows copying the files of the present directory, and
201 sub-directories to a new directory called new-dir.  Some new options are
202 the @option{-print0} available with GNU find, combined with the
203 @option{--null} option of cpio.  These two options act together to send
204 file names between find and cpio, even if special characters are
205 embedded in the file names.  Another is @option{-p}, which tells cpio to
206 pass the files it finds to the directory @samp{new-dir}.
207
208 @node Invoking cpio, Media, Tutorial, Top
209 @comment  node-name,  next,  previous,  up
210 @chapter Invoking cpio
211 @cindex invoking cpio
212 @cindex command line options
213
214 @menu
215 * Copy-out mode::               
216 * Copy-in mode::                
217 * Copy-pass mode::              
218 * Options::                     
219 @end menu
220
221 @node Copy-out mode, Copy-in mode, Invoking cpio, Invoking cpio
222 @comment  node-name,  next,  previous,  up
223 @section Copy-out mode
224
225 In copy-out mode, cpio copies files into an archive.  It reads a list
226 of filenames, one per line, on the standard input, and writes the
227 archive onto the standard output.  A typical way to generate the list
228 of filenames is with the find command; you should give find the -depth
229 option to minimize problems with permissions on directories that are
230 unreadable.
231 @xref{Options}.
232
233 @example
234 cpio @{-o|--create@} [-0acvABLV] [-C bytes] [-H format]
235 [-M message] [-O [[user@@]host:]archive] [-F [[user@@]host:]archive]
236 [--file=[[user@@]host:]archive] [--format=format]
237 [--message=message][--null] [--reset-access-time] [--verbose]
238 [--dot] [--append] [--block-size=blocks] [--dereference]
239 [--io-size=bytes] [--rsh-command=command] [--help] [--version]
240 < name-list [> archive]
241 @end example
242
243 @node Copy-in mode, Copy-pass mode, Copy-out mode, Invoking cpio
244 @comment  node-name,  next,  previous,  up
245 @section Copy-in mode
246
247 In copy-in mode, cpio copies files out of an archive or lists the
248 archive contents.  It reads the archive from the standard input.  Any
249 non-option command line arguments are shell globbing patterns; only
250 files in the archive whose names match one or more of those patterns are
251 copied from the archive.  Unlike in the shell, an initial @samp{.} in a
252 filename does match a wildcard at the start of a pattern, and a @samp{/} in a
253 filename can match wildcards.  If no patterns are given, all files are
254 extracted.  @xref{Options}.
255
256 @example
257 cpio @{-i|--extract@} [-bcdfmnrtsuvBSV] [-C bytes] [-E file]
258 [-H format] [-M message] [-R [user][:.][group]]
259 [-I [[user@@]host:]archive] [-F [[user@@]host:]archive]
260 [--file=[[user@@]host:]archive] [--make-directories]
261 [--nonmatching] [--preserve-modification-time]
262 [--numeric-uid-gid] [--rename] [--list] [--swap-bytes] [--swap]
263 [--dot] [--unconditional] [--verbose] [--block-size=blocks]
264 [--swap-halfwords] [--io-size=bytes] [--pattern-file=file]
265 [--format=format] [--owner=[user][:.][group]]
266 [--no-preserve-owner] [--message=message] [--help] [--version]
267 [--absolute-filenames] [--sparse] [-only-verify-crc] [-quiet]
268 [--rsh-command=command] [pattern...] [< archive]
269 @end example
270
271 @node Copy-pass mode, Options, Copy-in mode, Invoking cpio
272 @comment  node-name,  next,  previous,  up
273 @section Copy-pass mode
274
275 In copy-pass mode, cpio copies files from one directory tree to
276 another, combining the copy-out and copy-in steps without actually
277 using an archive.  It reads the list of files to copy from the
278 standard input; the directory into which it will copy them is given as
279 a non-option argument.
280 @xref{Options}.
281
282 @example
283 cpio @{-p|--pass-through@} [-0adlmuvLV] [-R [user][:.][group]]
284 [--null] [--reset-access-time] [--make-directories] [--link]
285 [--preserve-modification-time] [--unconditional] [--verbose]
286 [--dot] [--dereference] [--owner=[user][:.][group]] [--sparse]
287 [--no-preserve-owner] [--help] [--version] destination-directory
288 < name-list
289 @end example
290
291
292
293 @node Options,  , Copy-pass mode, Invoking cpio
294 @comment  node-name,  next,  previous,  up
295 @section Options
296
297
298 @table @code
299
300
301 @item -0
302 @itemx --null
303 Read a list of filenames terminated by a null character, instead of a
304 newline, so that files whose names contain newlines can be archived.
305 GNU find is one way to produce a list of null-terminated filenames.
306 This option may be used in copy-out and copy-pass modes.
307
308 @item -a
309 @itemx --reset-access-time
310 Reset the access times of files after reading them, so
311 that it does not look like they have just been read.
312
313 @item -A
314 @itemx --append
315 Append to an existing archive.  Only works in copy-out
316 mode.  The archive must be a disk file specified with
317 the @option{-O} or @option{-F} (@option{--file}) option.
318
319 @item -b
320 @itemx --swap
321 Swap both halfwords of words and bytes of halfwords in the data.
322 Equivalent to -sS.  This option may be used in copy-in mode.  Use this
323 option to convert 32-bit integers between big-endian and little-endian
324 machines.
325
326 @item -B   
327 Set the I/O block size to 5120 bytes.  Initially the
328 block size is 512 bytes.
329
330 @item --block-size=@var{block-size}
331 Set the I/O block size to @var{block-size} * 512 bytes.
332
333 @item -c
334 Use the old portable (ASCII) archive format.
335
336 @item -C @var{io-size}
337 @itemx --io-size=@var{io-size}
338 Set the I/O block size to @var{io-size} bytes.
339
340 @item -d
341 @itemx --make-directories
342 Create leading directories where needed.
343
344 @item -E @var{file}
345 @itemx --pattern-file=@var{file}
346 Read additional patterns specifying filenames to extract or list from
347 @var{file}.  The lines of @var{file} are treated as if they had been non-option
348 arguments to cpio.  This option is used in copy-in mode,
349
350 @item -f
351 @itemx --nonmatching
352 Only copy files that do not match any of the given
353 patterns.
354
355 @item -F @var{archive}
356 @itemx --file=@var{archive}
357 Archive filename to use instead of standard input or output.  To use a
358 tape drive on another machine as the archive, use a filename that starts
359 with @samp{@var{hostname}:}, where @var{hostname} is the name or IP
360 address of the machine.  The hostname can be preceded by a username and an
361 @samp{@@} to access the remote tape drive as that user, if you have
362 permission to do so (typically an entry in that user's @file{~/.rhosts}
363 file).
364
365 @item --force-local
366 With @option{-F}, @option{-I}, or @option{-O}, take the archive file name to be a
367 local file even if it contains a colon, which would
368 ordinarily indicate a remote host name.
369
370 @item -H @var{format}
371 @itemx --format=@var{format}
372 Use archive format @var{format}.  The valid formats are listed below; the same
373 names are also recognized in all-caps.  The default in copy-in mode is
374 to automatically detect the archive format, and in copy-out mode is
375 @samp{bin}.
376
377 @table @samp
378 @item bin  
379 The obsolete binary format.
380
381 @item odc
382 The old (POSIX.1) portable format.
383
384 @item newc
385 The new (SVR4) portable format, which supports file systems having more
386 than 65536 i-nodes.
387
388 @item crc
389 The new (SVR4) portable format with a checksum added.
390
391 @item tar
392 The old tar format.
393
394 @item ustar
395 The POSIX.1 tar format.  Also recognizes GNU tar archives, which are
396 similar but not identical.
397
398 @item hpbin
399 The obsolete binary format used by HPUX's cpio (which stores device
400 files differently).
401
402 @item hpodc
403 The portable format used by HPUX's cpio (which stores device files
404 differently).
405 @end table
406
407 @item -i
408 @itemx --extract
409 Run in copy-in mode.
410 @xref{Copy-in mode}.
411
412 @item -I @var{archive}
413 Archive filename to use instead of standard input.  To use a tape drive
414 on another machine as the archive, use a filename that starts with
415 @samp{@var{hostname}:}, where @var{hostname} is the name or IP address
416 of the remote host.  The hostname can be preceded by a username and an @samp{@@} to
417 access the remote tape drive as that user, if you have permission to do
418 so (typically an entry in that user's @file{~/.rhosts} file).
419
420 @item -k
421 Ignored; for compatibility with other versions of cpio.
422
423 @item -l
424 @itemx --link
425 Link files instead of copying them, when possible.
426
427 @item -L
428 @itemx --dereference
429 Copy the file that a symbolic link points to, rather than the symbolic
430 link itself.
431
432 @item -m
433 @itemx --preserve-modification-time
434 Retain previous file modification times when creating files.
435
436 @item -M @var{message}
437 @itemx --message=@var{message}
438 Print @var{message} when the end of a volume of the backup media (such as a
439 tape or a floppy disk) is reached, to prompt the user to insert a new
440 volume.  If @var{message} contains the string @samp{%d}, it is replaced by the
441 current volume number (starting at 1).
442
443 @item -n
444 @itemx --numeric-uid-gid
445 Show numeric UID and GID instead of translating them into names when using the
446 @option{--verbose} option.
447
448 @item --absolute-filenames
449 Do not strip leading file name components that contain ".." and
450 leading slashes from file names in copy-in mode
451
452 @item --no-preserve-owner
453 Do not change the ownership of the files; leave them owned by the user
454 extracting them.  This is the default for non-root users, so that users
455 on System V don't inadvertantly give away files.  This option can be
456 used in copy-in mode and copy-pass mode
457
458 @item -o
459 @itemx --create
460 Run in copy-out mode.
461 @xref{Copy-out mode}.
462
463 @item -O @var{archive}
464 Archive filename to use instead of standard output.  To use a tape drive
465 on another machine as the archive, use a filename that starts with
466 @samp{@var{hostname}:}, where @var{hostname} is the name or IP address
467 of the machine.  The hostname can be preceded by a username and an @samp{@@} to
468 access the remote tape drive as that user, if you have permission to do
469 so (typically an entry in that user's @file{~/.rhosts} file).
470
471 @item --only-verify-crc
472 Verify the CRC's of each file in the archive, when reading a CRC format
473 archive. Don't actually extract the files.
474
475 @item -p
476 @itemx --pass-through
477 Run in copy-pass mode.
478 @xref{Copy-pass mode}.
479
480 @item --quiet
481 Do not print the number of blocks copied.
482
483 @item -r
484 @itemx --rename
485 Interactively rename files.
486
487 @item -R @var{owner}
488 @itemx --owner @var{owner}
489
490 In copy-in and copy-pass mode, set the ownership of all files created
491 to the specified @var{owner} (this operation is allowed only for the
492 super-user). In copy-out mode, store the supplied owner information in
493 the archive. 
494
495 The argument can be either the user name or the user name
496 and group name, separated by a dot or a colon, or the group name,
497 preceeded by a dot or a colon, as shown in the examples below:
498
499 @smallexample
500 @group
501 cpio --owner smith
502 cpio --owner smith:
503 cpio --owner smith:users
504 cpio --owner :users
505 @end group
506 @end smallexample
507
508 @noindent
509 If the group is omitted but the @samp{:} or @samp{.} separator is
510 given, as in the second example. the given user's login group will be
511 used.  
512
513 @item --rsh-command=@var{command}
514 Notifies cpio that is should use @var{command} to communicate with remote
515 devices.
516
517 @item -s
518 @itemx --swap-bytes
519 Swap the bytes of each halfword (pair of bytes) in the files. This option
520 can be used in copy-in mode.
521
522 @item -S
523 @itemx --swap-halfwords
524 Swap the halfwords of each word (4 bytes) in the files.  This option may
525 be used in copy-in mode.
526
527 @item --sparse
528 Write files with large blocks of zeros as sparse files.  This option is
529 used in copy-in and copy-pass modes.
530
531 @item -t
532 @itemx --list
533 Print a table of contents of the input.
534
535 @item -u
536 @itemx --unconditional
537 Replace all files, without asking whether to replace
538 existing newer files with older files.
539
540 @item -v
541 @itemx --verbose
542 List the files processed, or with @option{-t}, give an @samp{ls -l} style
543 table of contents listing.  In a verbose table of contents of a ustar
544 archive, user and group names in the archive that do not exist on the
545 local system are replaced by the names that correspond locally to the
546 numeric UID and GID stored in the archive.
547
548 @item -V
549 @itemx --dot
550 Print a @samp{.} for each file processed.
551
552 @item --version
553 Print the cpio program version number and exit.
554 @end table
555
556
557 @node Media, Reports, Invoking cpio, Top
558 @comment  node-name,  next,  previous,  up
559 @chapter Magnetic Media
560 @cindex magnetic media
561
562 Archives are usually written on removable media--tape cartridges, mag
563 tapes, or floppy disks.
564
565 The amount of data a tape or disk holds depends not only on its size,
566 but also on how it is formatted.  A 2400 foot long reel of mag tape
567 holds 40 megabytes of data when formated at 1600 bits per inch.  The
568 physically smaller EXABYTE tape cartridge holds 2.3 gigabytes.
569
570 Magnetic media are re-usable--once the archive on a tape is no longer
571 needed, the archive can be erased and the tape or disk used over. Media
572 quality does deteriorate with use, however.  Most tapes or disks should
573 be disgarded when they begin to produce data errors.
574
575 Magnetic media are written and erased using magnetic fields, and should
576 be protected from such fields to avoid damage to stored data.  Sticking
577 a floppy disk to a filing cabinet using a magnet is probably not a good
578 idea.
579
580 @node Reports, Concept Index, Media, Top
581 @chapter Reporting bugs or suggestions
582
583 It is possible you will encounter a bug in @command{cpio}.
584 If this happens, we would like to hear about it. As the purpose of bug
585 reporting is to improve software, please be sure to include maximum
586 information when reporting a bug. The information needed is:
587
588 @itemize @bullet
589 @item Version of the package you are using.
590 @item Compilation options used when configuring the package.
591 @item Conditions under which the bug appears.
592 @end itemize 
593
594 Send your report to <bug-cpio@@gnu.org>. Allow us a couple of
595 days to answer.
596
597 @node Concept Index, , Reports, Top
598 @comment  node-name,  next,  previous,  up
599 @unnumbered Concept Index
600 @printindex cp
601 @contents
602 @bye