source: freewrt/tools/paxmirabilis/src/pax.1@ a569125

freewrt_1_0 freewrt_2_0
Last change on this file since a569125 was a569125, checked in by Thorsten Glaser <tg@…>, 14 years ago

even FreeWRT 1.0-stable deserves paxmirabilis-20120216 compiled with LTO ☺

git-svn-id: svn://www.freewrt.org/branches/freewrt_1_0@3981 afb5a338-a214-0410-bd46-81f09a774fd1

  • Property mode set to 100644
File size: 35.3 KB
Line 
1.\" $MirOS: src/bin/pax/pax.1,v 1.22 2012/02/12 02:49:41 tg Exp $
2.\" $OpenBSD: pax.1,v 1.61 2010/09/19 20:55:25 jmc Exp $
3.\" $NetBSD: pax.1,v 1.3 1995/03/21 09:07:37 cgd Exp $
4.\"
5.\" Copyright (c) 2005, 2009, 2011, 2012
6.\" Thorsten Glaser <tg@mirbsd.org>
7.\" Copyright (c) 1992 Keith Muller.
8.\" Copyright (c) 1992, 1993
9.\" The Regents of the University of California. All rights reserved.
10.\"
11.\" This code is derived from software contributed to Berkeley by
12.\" Keith Muller of the University of California, San Diego.
13.\"
14.\" Redistribution and use in source and binary forms, with or without
15.\" modification, are permitted provided that the following conditions
16.\" are met:
17.\" 1. Redistributions of source code must retain the above copyright
18.\" notice, this list of conditions and the following disclaimer.
19.\" 2. Redistributions in binary form must reproduce the above copyright
20.\" notice, this list of conditions and the following disclaimer in the
21.\" documentation and/or other materials provided with the distribution.
22.\" 3. Neither the name of the University nor the names of its contributors
23.\" may be used to endorse or promote products derived from this software
24.\" without specific prior written permission.
25.\"
26.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
27.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
28.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
29.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
30.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
31.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
32.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
33.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
34.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
35.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
36.\" SUCH DAMAGE.
37.\"
38.\" @(#)pax.1 8.4 (Berkeley) 4/18/94
39.\"
40.\"-
41.\" Try to make GNU groff and AT&T nroff more compatible
42.\" * ` generates ‘ in gnroff, so use \`
43.\" * ' generates ’ in gnroff, \' generates ´, so use \*(aq
44.\" * - generates ‐ in gnroff, \- generates −, so .tr it to -
45.\" thus use - for hyphens and \- for minus signs and option dashes
46.\" * ~ is size-reduced and placed atop in groff, so use \*(TI
47.\" * ^ is size-reduced and placed atop in groff, so use \*(ha
48.\" * \(en does not work in nroff, so use \*(en
49.\" The section after the "doc" macropackage has been loaded contains
50.\" additional code to convene between the UCB mdoc macropackage (and
51.\" its variant as BSD mdoc in groff) and the GNU mdoc macropackage.
52.\"
53.ie \n(.g \{\
54. if \*[.T]ascii .tr \-\N'45'
55. if \*[.T]latin1 .tr \-\N'45'
56. if \*[.T]utf8 .tr \-\N'45'
57. ds <= \[<=]
58. ds >= \[>=]
59. ds Rq \[rq]
60. ds Lq \[lq]
61. ds sL \(aq
62. ds sR \(aq
63. if \*[.T]utf8 .ds sL `
64. if \*[.T]ps .ds sL `
65. if \*[.T]utf8 .ds sR '
66. if \*[.T]ps .ds sR '
67. ds aq \(aq
68. ds TI \(ti
69. ds ha \(ha
70. ds en \(en
71.\}
72.el \{\
73. ds aq '
74. ds TI ~
75. ds ha ^
76. ds en \(em
77.\}
78.\"
79.\" Implement .Dd with the Mdocdate RCS keyword
80.\"
81.rn Dd xD
82.de Dd
83.ie \\$1$Mdocdate: \{\
84. xD \\$2 \\$3, \\$4
85.\}
86.el .xD \\$1 \\$2 \\$3 \\$4 \\$5 \\$6 \\$7 \\$8
87..
88.\"
89.\" .Dd must come before definition of .Mx, because when called
90.\" with -mandoc, it might implement .Mx itself, but we want to
91.\" use our own definition. And .Dd must come *first*, always.
92.\"
93.Dd $Mdocdate: February 12 2012 $
94.\"
95.\" Check which macro package we use
96.\"
97.ie \n(.g \{\
98. ie d volume-ds-1 .ds tT gnu
99. el .ds tT bsd
100.\}
101.el .ds tT ucb
102.\"
103.\" Implement .Mx (MirBSD)
104.\"
105.ie "\*(tT"gnu" \{\
106. eo
107. de Mx
108. nr curr-font \n[.f]
109. nr curr-size \n[.ps]
110. ds str-Mx \f[\n[curr-font]]\s[\n[curr-size]u]
111. ds str-Mx1 \*[Tn-font-size]\%MirOS\*[str-Mx]
112. if !\n[arg-limit] \
113. if \n[.$] \{\
114. ds macro-name Mx
115. parse-args \$@
116. \}
117. if (\n[arg-limit] > \n[arg-ptr]) \{\
118. nr arg-ptr +1
119. ie (\n[type\n[arg-ptr]] == 2) \
120. as str-Mx1 \~\*[arg\n[arg-ptr]]
121. el \
122. nr arg-ptr -1
123. \}
124. ds arg\n[arg-ptr] "\*[str-Mx1]
125. nr type\n[arg-ptr] 2
126. ds space\n[arg-ptr] "\*[space]
127. nr num-args (\n[arg-limit] - \n[arg-ptr])
128. nr arg-limit \n[arg-ptr]
129. if \n[num-args] \
130. parse-space-vector
131. print-recursive
132..
133. ec
134. ds sP \s0
135. ds tN \*[Tn-font-size]
136.\}
137.el \{\
138. de Mx
139. nr cF \\n(.f
140. nr cZ \\n(.s
141. ds aa \&\f\\n(cF\s\\n(cZ
142. if \\n(aC==0 \{\
143. ie \\n(.$==0 \&MirOS\\*(aa
144. el .aV \\$1 \\$2 \\$3 \\$4 \\$5 \\$6 \\$7 \\$8 \\$9
145. \}
146. if \\n(aC>\\n(aP \{\
147. nr aP \\n(aP+1
148. ie \\n(C\\n(aP==2 \{\
149. as b1 \&MirOS\ #\&\\*(A\\n(aP\\*(aa
150. ie \\n(aC>\\n(aP \{\
151. nr aP \\n(aP+1
152. nR
153. \}
154. el .aZ
155. \}
156. el \{\
157. as b1 \&MirOS\\*(aa
158. nR
159. \}
160. \}
161..
162.\}
163.\"-
164.ie \ng==1 \{\
165. ds nc mircpio
166. ds np mirpax
167. ds nt mirtar
168. ds nm mirpax
169. Dt MIRPAX 1
170.\}
171.el .ie \ng==2 \{\
172. ds nc paxcpio
173. ds np pax
174. ds nt paxtar
175. ds nm pax
176. Dt PAX 1
177.\}
178.el \{\
179. ds nc cpio
180. ds np pax
181. ds nt tar
182. ds nm pax
183. Dt PAX 1
184.\}
185.\"-
186.Os MirBSD
187.Sh NAME
188.ie \ng==1 \{\
189.Nm mirpax
190.Nd read and write file archives and copy directory hierarchies
191.\}
192.el \{\
193.Nm pax
194.Nd read and write file archives and copy directory hierarchies
195.\}
196.Sh SYNOPSIS
197.Bk -words
198.Nm \*(nm
199.Op Fl 0cdJjnOvz
200.Op Fl E Ar limit
201.Op Fl f Ar archive
202.Op Fl G Ar group
203.Op Fl s Ar replstr
204.Op Fl T Ar range
205.Op Fl U Ar user
206.Op Ar pattern ...
207.Nm \*(nm
208.Fl r
209.Op Fl 0cDdiJjknOuvYZz
210.Op Fl E Ar limit
211.Op Fl f Ar archive
212.Op Fl G Ar group
213.Op Fl M Ar flag
214.Op Fl o Ar options
215.Op Fl p Ar string
216.Op Fl s Ar replstr
217.Op Fl T Ar range
218.Op Fl U Ar user
219.Op Ar pattern ...
220.Nm \*(nm
221.Fl w
222.Op Fl 0adHiJjLOPtuvXz
223.Op Fl B Ar bytes
224.Op Fl b Ar blocksize
225.Op Fl f Ar archive
226.Op Fl G Ar group
227.Op Fl M Ar flag
228.Op Fl o Ar options
229.Op Fl s Ar replstr
230.Op Fl T Ar range
231.Op Fl U Ar user
232.Op Fl x Ar format
233.Op Ar
234.Nm \*(nm
235.Fl rw
236.Op Fl 0DdHiJjkLlnOPtuvXYZ
237.Op Fl G Ar group
238.Op Fl p Ar string
239.Op Fl s Ar replstr
240.Op Fl T Ar range
241.Op Fl U Ar user
242.Op Ar
243.Ar directory
244.Ek
245.Sh DESCRIPTION
246.Nm
247will read, write, and list the members of an archive file
248and will copy directory hierarchies.
249.Nm
250operation is independent of the specific archive format
251and supports a wide variety of different archive formats.
252A list of supported archive formats can be found under the description of the
253.Fl x
254option.
255.Pp
256The presence of the
257.Fl r
258and the
259.Fl w
260options specifies which of the following functional modes
261.Nm
262will operate under:
263.Em list , read , write ,
264and
265.Em copy .
266.Bl -tag -width 6n
267.It \*(Ltnone\*(Gt
268.Em List .
269.Nm
270will write to standard output
271a table of contents of the members of the archive file read from
272standard input, whose pathnames match the specified
273.Ar pattern
274arguments.
275The table of contents contains one filename per line
276and is written using single line buffering.
277.It Fl r
278.Em Read .
279.Nm
280extracts the members of the archive file read from the standard input,
281with pathnames matching the specified
282.Ar pattern
283arguments.
284The archive format and blocking is automatically determined on input.
285When an extracted file is a directory, the entire file hierarchy
286rooted at that directory is extracted.
287All extracted files are created relative to the current file hierarchy.
288The setting of ownership, access and modification times, and file mode of
289the extracted files are discussed in more detail under the
290.Fl p
291option.
292.It Fl w
293.Em Write .
294.Nm
295writes an archive containing the
296.Ar file
297operands to standard output
298using the specified archive format.
299When no
300.Ar file
301operands are specified, a list of files to copy with one per line is read from
302standard input.
303When a
304.Ar file
305operand is also a directory, the entire file hierarchy rooted
306at that directory will be included.
307.It Fl rw
308.Em Copy .
309.Nm
310copies the
311.Ar file
312operands to the destination
313.Ar directory .
314When no
315.Ar file
316operands are specified, a list of files to copy with one per line is read from
317the standard input.
318When a
319.Ar file
320operand is also a directory the entire file
321hierarchy rooted at that directory will be included.
322The effect of the
323.Em copy
324is as if the copied files were written to an archive file and then
325subsequently extracted, except that there may be hard links between
326the original and the copied files (see the
327.Fl l
328option below).
329.Pp
330.Sy Warning :
331The destination
332.Ar directory
333must not be one of the
334.Ar file
335operands or a member of a file hierarchy rooted at one of the
336.Ar file
337operands.
338The result of a
339.Em copy
340under these conditions is unpredictable.
341.El
342.Pp
343While processing a damaged archive during a
344.Em read
345or
346.Em list
347operation,
348.Nm
349will attempt to recover from media defects and will search through the archive
350to locate and process the largest number of archive members possible (see the
351.Fl E
352option for more details on error handling).
353.Pp
354The
355.Ar directory
356operand specifies a destination directory pathname.
357If the
358.Ar directory
359operand does not exist, or it is not writable by the user,
360or it is not of type directory,
361.Nm
362will exit with a non-zero exit status.
363.Pp
364The
365.Ar pattern
366operand is used to select one or more pathnames of archive members.
367Archive members are selected using the pattern matching notation described
368by
369.Xr glob 3 .
370When the
371.Ar pattern
372operand is not supplied, all members of the archive will be selected.
373When a
374.Ar pattern
375matches a directory, the entire file hierarchy rooted at that directory will
376be selected.
377When a
378.Ar pattern
379operand does not select at least one archive member,
380.Nm
381will write these
382.Ar pattern
383operands in a diagnostic message to standard error
384and then exit with a non-zero exit status.
385.Pp
386The
387.Ar file
388operand specifies the pathname of a file to be copied or archived.
389When a
390.Ar file
391operand does not select at least one archive member,
392.Nm
393will write these
394.Ar file
395operand pathnames in a diagnostic message to standard error
396and then exit with a non-zero exit status.
397.Pp
398The options are as follows:
399.Bl -tag -width Ds
400.It Fl 0
401Use the NUL
402.Pq Ql \e0
403character as a pathname terminator, instead of newline
404.Pq Ql \en .
405This applies only to the pathnames read from standard input in
406the write and copy modes,
407and to the pathnames written to standard output in list mode.
408This option is expected to be used in concert with the
409.Fl print0
410function in
411.Xr find 1
412or the
413.Fl 0
414flag in
415.Xr xargs 1 .
416.It Fl a
417Append the given
418.Ar file
419operands
420to the end of an archive that was previously written.
421If an archive format is not specified with a
422.Fl x
423option, the format currently being used in the archive will be selected.
424Any attempt to append to an archive in a format different from the
425format already used in the archive will cause
426.Nm
427to exit immediately
428with a non-zero exit status.
429The blocking size used in the archive volume where writing starts
430will continue to be used for the remainder of that archive volume.
431.Pp
432.Sy Warning :
433Many storage devices are not able to support the operations necessary
434to perform an append operation.
435Any attempt to append to an archive stored on such a device may damage the
436archive or have other unpredictable results.
437Tape drives in particular are more likely to not support an append operation.
438An archive stored in a regular file system file or on a disk device will
439usually support an append operation.
440.It Fl B Ar bytes
441Limit the number of bytes written to a single archive volume to
442.Ar bytes .
443The
444.Ar bytes
445limit can end with
446.Sq Li m ,
447.Sq Li k ,
448or
449.Sq Li b
450to specify multiplication by 1048576 (1M), 1024 (1K) or 512, respectively.
451A pair of
452.Ar bytes
453limits can be separated by
454.Sq Li x
455to indicate a product.
456.Pp
457.Em Warning :
458Only use this option when writing an archive to a device which supports
459an end of file read condition based on last (or largest) write offset
460(such as a regular file or a tape drive).
461The use of this option with a floppy or hard disk is not recommended.
462.It Fl b Ar blocksize
463When
464.Em writing
465an archive,
466block the output at a positive decimal integer number of
467bytes per write to the archive file.
468The
469.Ar blocksize
470must be a multiple of 512 bytes with a maximum of 64512 bytes.
471Archive block sizes larger than 32256 bytes violate the
472.Tn POSIX
473standard and will not be portable to all systems.
474A
475.Ar blocksize
476can end with
477.Sq Li k
478or
479.Sq Li b
480to specify multiplication by 1024 (1K) or 512, respectively.
481A pair of
482.Ar blocksizes
483can be separated by
484.Sq Li x
485to indicate a product.
486A specific archive device may impose additional restrictions on the size
487of blocking it will support.
488When blocking is not specified, the default
489.Ar blocksize
490is dependent on the specific archive format being used (see the
491.Fl x
492option).
493.It Fl c
494Match all file or archive members
495.Em except
496those specified by the
497.Ar pattern
498and
499.Ar file
500operands.
501.It Fl D
502This option is the same as the
503.Fl u
504option, except that the file inode change time is checked instead of the
505file modification time.
506The file inode change time can be used to select files whose inode information
507(e.g., UID, GID, etc.) is newer than a copy of the file in the destination
508.Ar directory .
509.It Fl d
510Cause files of type directory being copied or archived, or archive members of
511type directory being extracted, to match only the directory file or archive
512member and not the file hierarchy rooted at the directory.
513.It Fl E Ar limit
514Limit the number of consecutive read faults while trying to read a flawed
515archive to
516.Ar limit .
517With a positive
518.Ar limit ,
519.Nm
520will attempt to recover from an archive read error and will
521continue processing starting with the next file stored in the archive.
522A
523.Ar limit
524of 0 will cause
525.Nm
526to stop operation after the first read error is detected on an archive volume.
527A
528.Ar limit
529of
530.Li NONE
531will cause
532.Nm
533to attempt to recover from read errors forever.
534The default
535.Ar limit
536is a small positive number of retries.
537.Pp
538.Em Warning :
539Using this option with
540.Li NONE
541should be used with extreme caution as
542.Nm
543may get stuck in an infinite loop on a very badly flawed archive.
544.It Fl f Ar archive
545Specify
546.Ar archive
547as the pathname of the input or output archive, overriding the default
548standard input (for
549.Em list
550and
551.Em read )
552or standard output
553(for
554.Em write ) .
555A single archive may span multiple files and different archive devices.
556When required,
557.Nm
558will prompt for the pathname of the file or device of the next volume in the
559archive.
560.It Fl G Ar group
561Select a file based on its
562.Ar group
563name, or when starting with a
564.Cm # ,
565a numeric GID.
566A
567.Ql \e
568can be used to escape the
569.Cm # .
570Multiple
571.Fl G
572options may be supplied and checking stops with the first match.
573.It Fl H
574Follow only command-line symbolic links while performing a physical file
575system traversal.
576.It Fl i
577Interactively rename files or archive members.
578For each archive member matching a
579.Ar pattern
580operand or each file matching a
581.Ar file
582operand,
583.Nm
584will prompt to
585.Pa /dev/tty
586giving the name of the file, its file mode, and its modification time.
587.Nm
588will then read a line from
589.Pa /dev/tty .
590If this line is blank, the file or archive member is skipped.
591If this line consists of a single period, the
592file or archive member is processed with no modification to its name.
593Otherwise, its name is replaced with the contents of the line.
594.Nm
595will immediately exit with a non-zero exit status if
596.Dv EOF
597is encountered when reading a response or if
598.Pa /dev/tty
599cannot be opened for reading and writing.
600.It Fl J
601Use the xz utility to compress (decompress) the archive
602while writing (reading).
603Incompatible with
604.Fl a .
605.It Fl j
606Use the bzip2 utility to compress (decompress) the archive
607while writing (reading).
608Incompatible with
609.Fl a .
610.It Fl k
611Do not overwrite existing files.
612.It Fl L
613Follow all symbolic links to perform a logical file system traversal.
614.It Fl l
615(The lowercase letter
616.Dq ell . )
617Link files.
618In the
619.Em copy
620mode
621.Pq Fl r Fl w ,
622hard links are made between the source and destination file hierarchies
623whenever possible.
624.It Fl M Ar flag
625Configure the archive normaliser.
626.Ar flag
627is either a numeric value compatible to
628.Xr strtonum 3
629which is directly stored in the flags word, or
630one of the following values, optionally prefixed with
631.Dq no\-
632to turn them off:
633.Pp
634.Bl -tag -width xxxxxx -compact
635.It Ar inodes
6360x0001: Serialise inodes, zero device info.
637.br
638(cpio, sv4cpio, sv4crc)
639.It Ar links
6400x0002: Store content of hard links only once.
641.br
642(cpio, sv4cpio, sv4crc)
643.It Ar mtime
6440x0004: Zero out the file modification time.
645.br
646(ar, cpio, sv4cpio, sv4crc, ustar)
647.It Ar uidgid
6480x0008: Set owner to 0:0 (root:wheel).
649.br
650(ar, cpio, sv4cpio, sv4crc, ustar)
651.It Ar verb
6520x0010: Debug this option.
653.It Ar debug
6540x0020: Debug file header storage.
655.It Ar lncp
6560x0040: Extract hard links by copy if link fails.
657.It Ar numid
6580x0080: Use only numeric uid and gid values.
659.br
660(ustar)
661.It Ar gslash
6620x0100: Append a slash after directory names.
663.br
664(ustar)
665.It Ar set
6660x0003: Keep ownership and mtime intact.
667.It Ar dist
6680x008B: Clean everything except mtime.
669.It Ar norm
6700x008F: Clean everything.
671.It Ar root
6720x0089: Clean owner and device information.
673.El
674.Pp
675This option is only implemented for the ar, cpio, sv4cpio,
676sv4crc, and ustar file format writing routines.
677.Pp
678TODO: The
679.Nm \*(nm
680frontend should be using the
681.Fl o
682option for handling this feature instead.
683.It Fl n
684Select the first archive member that matches each
685.Ar pattern
686operand.
687No more than one archive member is matched for each
688.Ar pattern .
689When members of type directory are matched, the file hierarchy rooted at that
690directory is also matched (unless
691.Fl d
692is also specified).
693.It Fl O
694Force the archive to be one volume.
695If a volume ends prematurely,
696.Nm
697will not prompt for a new volume.
698This option can be useful for
699automated tasks where error recovery cannot be performed by a human.
700.It Fl o Ar options
701Information to modify the algorithm for extracting or writing archive files
702which is specific to the archive format specified by
703.Fl x .
704In general,
705.Ar options
706take the form:
707.Ar name Ns = Ns Ar value .
708.Pp
709The following options are available for the old
710.Bx
711.Em tar
712format:
713.Pp
714.Bl -tag -width Ds -compact
715.It Cm nodir
716.It Cm write_opt=nodir
717When writing archives, omit the storage of directories.
718.El
719.It Fl P
720Do not follow symbolic links, perform a physical file system traversal.
721This is the default mode.
722.It Fl p Ar string
723Specify one or more file characteristic options (privileges).
724The
725.Ar string
726option-argument is a string specifying file characteristics to be retained or
727discarded on extraction.
728The string consists of the specification characters
729.Cm a , e , m , o ,
730and
731.Cm p .
732Multiple characteristics can be concatenated within the same string
733and multiple
734.Fl p
735options can be specified.
736The meanings of the specification characters are as follows:
737.Bl -tag -width 2n
738.It Cm a
739Do not preserve file access times.
740By default, file access times are preserved whenever possible.
741.It Cm e
742.Dq Preserve everything ,
743the user ID, group ID, file mode bits,
744file access time, and file modification time.
745This is intended to be used by
746.Em root ,
747someone with all the appropriate privileges, in order to preserve all
748aspects of the files as they are recorded in the archive.
749The
750.Cm e
751flag is the sum of the
752.Cm o
753and
754.Cm p
755flags.
756.It Cm m
757Do not preserve file modification times.
758By default, file modification times are preserved whenever possible.
759.It Cm o
760Preserve the user ID and group ID.
761.It Cm p
762.Dq Preserve
763the file mode bits.
764This is intended to be used by a
765.Em user
766with regular privileges who wants to preserve all aspects of the file other
767than the ownership.
768The file times are preserved by default, but two other flags are offered to
769disable this and use the time of extraction instead.
770.El
771.Pp
772In the preceding list,
773.Sq preserve
774indicates that an attribute stored in the archive is given to the
775extracted file, subject to the permissions of the invoking
776process.
777Otherwise the attribute of the extracted file is determined as
778part of the normal file creation action.
779If neither the
780.Cm e
781nor the
782.Cm o
783specification character is specified, or the user ID and group ID are not
784preserved for any reason,
785.Nm
786will not set the
787.Dv S_ISUID
788.Em ( setuid )
789and
790.Dv S_ISGID
791.Em ( setgid )
792bits of the file mode.
793If the preservation of any of these items fails for any reason,
794.Nm
795will write a diagnostic message to standard error.
796Failure to preserve these items will affect the final exit status,
797but will not cause the extracted file to be deleted.
798If the file characteristic letters in any of the string option-arguments are
799duplicated or conflict with each other, the one(s) given last will take
800precedence.
801For example, if
802.Fl p Ar eme
803is specified, file modification times are still preserved.
804.It Fl r
805Read an archive file from standard input
806and extract the specified
807.Ar file
808operands.
809If any intermediate directories are needed in order to extract an archive
810member, these directories will be created as if
811.Xr mkdir 2
812was called with the bitwise inclusive
813.Tn OR
814of
815.Dv S_IRWXU , S_IRWXG ,
816and
817.Dv S_IRWXO
818as the mode argument.
819When the selected archive format supports the specification of linked
820files and these files cannot be linked while the archive is being extracted,
821.Nm
822will write a diagnostic message to standard error
823and exit with a non-zero exit status at the completion of operation.
824.It Fl s Ar replstr
825Modify the archive member names according to the substitution expression
826.Ar replstr ,
827using the syntax of the
828.Xr ed 1
829utility regular expressions.
830.Ar file
831or
832.Ar pattern
833arguments may be given to restrict the list of archive members to those
834specified.
835.Pp
836The format of these regular expressions is:
837.Pp
838.Dl /old/new/[gp]
839.Pp
840As in
841.Xr ed 1 ,
842.Ar old
843is a basic regular expression (see
844.Xr re_format 7 )
845and
846.Ar new
847can contain an ampersand
848.Pq Ql & ,
849.Ql \e Ns Em n
850(where
851.Em n
852is a digit) back-references,
853or subexpression matching.
854The
855.Ar old
856string may also contain newline characters.
857Any non-null character can be used as a delimiter
858.Po
859.Ql /
860is shown here
861.Pc .
862Multiple
863.Fl s
864expressions can be specified.
865The expressions are applied in the order they are specified on the
866command line, terminating with the first successful substitution.
867.Pp
868The optional trailing
869.Cm g
870continues to apply the substitution expression to the pathname substring,
871which starts with the first character following the end of the last successful
872substitution.
873The first unsuccessful substitution stops the operation of the
874.Cm g
875option.
876The optional trailing
877.Cm p
878will cause the final result of a successful substitution to be written to
879standard error in the following format:
880.Pp
881.D1 Em original-pathname No \*(Gt\*(Gt Em new-pathname
882.Pp
883File or archive member names that substitute to the empty string
884are not selected and will be skipped.
885.It Fl T Ar range
886Allow files to be selected based on a file modification or inode change
887time falling within the specified time range.
888The range has the format:
889.Sm off
890.Bd -filled -offset indent
891.Oo Ar from_date Oc Oo ,
892.Ar to_date Oc Oo /
893.Oo Cm c Oc Op Cm m Oc
894.Ed
895.Sm on
896.Pp
897The dates specified by
898.Ar from_date
899to
900.Ar to_date
901are inclusive.
902If only a
903.Ar from_date
904is supplied, all files with a modification or inode change time
905equal to or younger are selected.
906If only a
907.Ar to_date
908is supplied, all files with a modification or inode change time
909equal to or older will be selected.
910When the
911.Ar from_date
912is equal to the
913.Ar to_date ,
914only files with a modification or inode change time of exactly that
915time will be selected.
916.Pp
917When
918.Nm
919is in the
920.Em write
921or
922.Em copy
923mode, the optional trailing field
924.Oo Cm c Oc Ns Op Cm m
925can be used to determine which file time (inode change, file modification or
926both) are used in the comparison.
927If neither is specified, the default is to use file modification time only.
928The
929.Cm m
930specifies the comparison of file modification time (the time when
931the file was last written).
932The
933.Cm c
934specifies the comparison of inode change time (the time when the file
935inode was last changed; e.g., a change of owner, group, mode, etc).
936When
937.Cm c
938and
939.Cm m
940are both specified, then the modification and inode change times are
941both compared.
942.Pp
943The inode change time comparison is useful in selecting files whose
944attributes were recently changed or selecting files which were recently
945created and had their modification time reset to an older time (as what
946happens when a file is extracted from an archive and the modification time
947is preserved).
948Time comparisons using both file times is useful when
949.Nm
950is used to create a time based incremental archive (only files that were
951changed during a specified time range will be archived).
952.Pp
953A time range is made up of six different fields and each field must contain two
954digits.
955The format is:
956.Pp
957.Dl [[[[[cc]yy]mm]dd]HH]MM[.SS]
958.Pp
959Where
960.Ar cc
961is the first two digits of the year (the century),
962.Ar yy
963is the last two digits of the year,
964the first
965.Ar mm
966is the month (from 01 to 12),
967.Ar dd
968is the day of the month (from 01 to 31),
969.Ar HH
970is the hour of the day (from 00 to 23),
971.Ar MM
972is the minute (from 00 to 59),
973and
974.Ar SS
975is the seconds (from 00 to 59).
976The minute field
977.Ar MM
978is required, while the other fields are optional and must be added in the
979following order:
980.Ar HH , dd , mm ,
981.Ar yy , cc .
982.Pp
983The
984.Ar SS
985field may be added independently of the other fields.
986Time ranges are relative to the current time, so
987.Ic \-T 1234/cm
988would select all files with a modification or inode change time
989of 12:34 PM today or later.
990Multiple
991.Fl T
992time range can be supplied and checking stops with the first match.
993.It Fl t
994Reset the access times of any file or directory read or accessed by
995.Nm
996to be the same as they were before being read or accessed by
997.Nm \*(nm .
998.It Fl U Ar user
999Select a file based on its
1000.Ar user
1001name, or when starting with a
1002.Cm # ,
1003a numeric UID.
1004A
1005.Ql \e
1006can be used to escape the
1007.Cm # .
1008Multiple
1009.Fl U
1010options may be supplied and checking stops with the first match.
1011.It Fl u
1012Ignore files that are older (having a less recent file modification time)
1013than a pre-existing file or archive member with the same name.
1014During
1015.Em read ,
1016an archive member with the same name as a file in the file system will be
1017extracted if the archive member is newer than the file.
1018During
1019.Em write ,
1020a file system member with the same name as an archive member will be
1021written to the archive if it is newer than the archive member.
1022During
1023.Em copy ,
1024the file in the destination hierarchy is replaced by the file in the source
1025hierarchy or by a link to the file in the source hierarchy if the file in
1026the source hierarchy is newer.
1027.It Fl v
1028During a
1029.Em list
1030operation, produce a verbose table of contents using the format of the
1031.Xr ls 1
1032utility with the
1033.Fl l
1034option.
1035For pathnames representing a hard link to a previous member of the archive,
1036the output has the format:
1037.Pp
1038.Dl Em ls \-l listing Li == Em link-name
1039.Pp
1040For pathnames representing a symbolic link, the output has the format:
1041.Pp
1042.Dl Em ls \-l listing Li =\*(Gt Em link-name
1043.Pp
1044Where
1045.Em ls \-l listing
1046is the output format specified by the
1047.Xr ls 1
1048utility when used with the
1049.Fl l
1050option.
1051Otherwise for all the other operational modes
1052.Po Em read , write , No and Em copy
1053.Pc ,
1054pathnames are written and flushed to standard error
1055without a trailing newline
1056as soon as processing begins on that file or
1057archive member.
1058The trailing newline
1059is not buffered and is written only after the file has been read or written.
1060.It Fl w
1061Write files to the standard output
1062in the specified archive format.
1063When no
1064.Ar file
1065operands are specified, standard input
1066is read for a list of pathnames with one per line without any leading or
1067trailing
1068.Aq blanks .
1069.It Fl X
1070When traversing the file hierarchy specified by a pathname,
1071do not descend into directories that have a different device ID.
1072See the
1073.Li st_dev
1074field as described in
1075.Xr stat 2
1076for more information about device IDs.
1077.It Fl x Ar format
1078Specify the output archive format, with the default format being
1079.Cm ustar .
1080.Nm
1081currently supports the following formats:
1082.Bl -tag -width "sv4cpio"
1083.It Cm ar
1084The Unix Archiver library format.
1085This format matches APT repositories and the BSD
1086.Xr ar 1
1087specification, not GNU binutils (which can however read them) or SYSV systems.
1088See
1089.Xr ar 5
1090on some operating systems for more information.
1091.It Cm bcpio
1092The old binary cpio format.
1093The default blocksize for this format is 5120 bytes.
1094This format is not very portable and should not be used when other formats
1095are available.
1096Inode and device information about a file (used for detecting file hard links
1097by this format), which may be truncated by this format, is detected by
1098.Nm
1099and is repaired.
1100.It Cm cpio
1101The extended cpio interchange format specified in the
1102.St -p1003.2
1103standard.
1104The default blocksize for this format is 5120 bytes.
1105Inode and device information about a file (used for detecting file hard links
1106by this format), which may be truncated by this format, is detected by
1107.Nm
1108and is repaired.
1109.It Cm sv4cpio
1110The System V release 4 cpio.
1111The default blocksize for this format is 5120 bytes.
1112Inode and device information about a file (used for detecting file hard links
1113by this format), which may be truncated by this format, is detected by
1114.Nm
1115and is repaired.
1116.It Cm sv4crc
1117The System V release 4 cpio with file CRC checksums.
1118The default blocksize for this format is 5120 bytes.
1119Inode and device information about a file (used for detecting file hard links
1120by this format), which may be truncated by this format, is detected by
1121.Nm
1122and is repaired.
1123.It Cm tar
1124The old
1125.Bx
1126tar format as found in
1127.Bx 4.3 .
1128The default blocksize for this format is 10240 bytes.
1129Pathnames stored by this format must be 100 characters or less in length.
1130Only
1131.Em regular
1132files,
1133.Em hard links , soft links ,
1134and
1135.Em directories
1136will be archived (other file system types are not supported).
1137For backwards compatibility with even older tar formats, a
1138.Fl o
1139option can be used when writing an archive to omit the storage of directories.
1140This option takes the form:
1141.Pp
1142.Dl Fl o Cm write_opt=nodir
1143.It Cm ustar
1144The extended tar interchange format specified in the
1145.St -p1003.2
1146standard.
1147The default blocksize for this format is 10240 bytes.
1148Filenames stored by this format must be 100 characters or less in length;
1149the total pathname must be 256 characters or less.
1150.El
1151.Pp
1152.Nm
1153will detect and report any file that it is unable to store or extract
1154as the result of any specific archive format restrictions.
1155The individual archive formats may impose additional restrictions on use.
1156Typical archive format restrictions include (but are not limited to):
1157file pathname length, file size, link pathname length, and the type of the
1158file.
1159.It Fl Y
1160This option is the same as the
1161.Fl D
1162option, except that the inode change time is checked using the
1163pathname created after all the file name modifications have completed.
1164.It Fl Z
1165This option is the same as the
1166.Fl u
1167option, except that the modification time is checked using the
1168pathname created after all the file name modifications have completed.
1169.It Fl z
1170Use the
1171.Xr gzip 1
1172utility to compress (decompress) the archive while writing (reading).
1173Incompatible with
1174.Fl a .
1175.El
1176.Pp
1177The options that operate on the names of files or archive members
1178.Po Fl c ,
1179.Fl i ,
1180.Fl n ,
1181.Fl s ,
1182.Fl u ,
1183.Fl v ,
1184.Fl D ,
1185.Fl G ,
1186.Fl T ,
1187.Fl U ,
1188.Fl Y ,
1189and
1190.Fl Z
1191.Pc
1192interact as follows.
1193.Pp
1194When extracting files during a
1195.Em read
1196operation, archive members are
1197.Sq selected ,
1198based only on the user specified pattern operands as modified by the
1199.Fl c ,
1200.Fl n ,
1201.Fl u ,
1202.Fl D ,
1203.Fl G ,
1204.Fl T ,
1205.Fl U
1206options.
1207Then any
1208.Fl s
1209and
1210.Fl i
1211options will modify in that order, the names of these selected files.
1212Then the
1213.Fl Y
1214and
1215.Fl Z
1216options will be applied based on the final pathname.
1217Finally, the
1218.Fl v
1219option will write the names resulting from these modifications.
1220.Pp
1221When archiving files during a
1222.Em write
1223operation, or copying files during a
1224.Em copy
1225operation, archive members are
1226.Sq selected ,
1227based only on the user specified pathnames as modified by the
1228.Fl n ,
1229.Fl u ,
1230.Fl D ,
1231.Fl G ,
1232.Fl T ,
1233and
1234.Fl U
1235options (the
1236.Fl D
1237option only applies during a copy operation).
1238Then any
1239.Fl s
1240and
1241.Fl i
1242options will modify in that order, the names of these selected files.
1243Then during a
1244.Em copy
1245operation the
1246.Fl Y
1247and the
1248.Fl Z
1249options will be applied based on the final pathname.
1250Finally, the
1251.Fl v
1252option will write the names resulting from these modifications.
1253.Pp
1254When one or both of the
1255.Fl u
1256or
1257.Fl D
1258options are specified along with the
1259.Fl n
1260option, a file is not considered selected unless it is newer
1261than the file to which it is compared.
1262.Sh ENVIRONMENT
1263.Bl -tag -width Fl
1264.It Ev TMPDIR
1265Path in which to store temporary files.
1266.El
1267.Sh EXIT STATUS
1268The
1269.Nm
1270utility exits with one of the following values:
1271.Pp
1272.Bl -tag -width Ds -offset indent -compact
1273.It 0
1274All files were processed successfully.
1275.It 1
1276An error occurred.
1277.El
1278.Sh EXAMPLES
1279Copy the contents of the current directory to the device
1280.Pa /dev/rst0 :
1281.Pp
1282.Dl $ \*(nm \-w \-f /dev/rst0 \&.
1283.Pp
1284Give the verbose table of contents for an archive stored in
1285.Pa filename :
1286.Pp
1287.Dl $ \*(nm \-v \-f filename
1288.Pp
1289This sequence of commands will copy the entire
1290.Pa olddir
1291directory hierarchy to
1292.Pa newdir :
1293.Bd -literal -offset indent
1294$ mkdir newdir
1295$ cd olddir
1296$ \*(nm \-rw . ../newdir
1297.Ed
1298.Pp
1299Extract files from the archive
1300.Pa a.pax .
1301Files rooted in
1302.Pa /usr
1303are extracted relative to the current working directory;
1304all other files are extracted to their unmodified path.
1305.Pp
1306.Dl $ \*(nm \-r \-s \*(aq,\*(ha/usr/,,\*(aq \-f a.pax
1307.Pp
1308This can be used to interactively select the files to copy from the
1309current directory to
1310.Pa dest_dir :
1311.Pp
1312.Dl $ \*(nm \-rw \-i \&. dest_dir
1313.Pp
1314Extract all files from the archive
1315.Pa a.pax
1316which are owned by
1317.Em root
1318with group
1319.Em bin
1320and preserve all file permissions:
1321.Pp
1322.Dl "$ \*(nm \-r \-pe \-U root \-G bin \-f a.pax"
1323.Pp
1324Update (and list) only those files in the destination directory
1325.Pa /backup
1326which are older (less recent inode change or file modification times) than
1327files with the same name found in the source file tree
1328.Pa home :
1329.Pp
1330.Dl "$ \*(nm \-r \-w \-v \-Y \-Z home /backup"
1331.Sh DIAGNOSTICS
1332Whenever
1333.Nm
1334cannot create a file or a link when reading an archive or cannot
1335find a file when writing an archive, or cannot preserve the user ID,
1336group ID, or file mode when the
1337.Fl p
1338option is specified, a diagnostic message is written to standard error
1339and a non-zero exit status will be returned, but processing will continue.
1340In the case where
1341.Nm
1342cannot create a link to a file,
1343unless
1344.Fl M Ar lncp
1345is given,
1346.Nm
1347will not create a second copy of the file.
1348.Pp
1349If the extraction of a file from an archive is prematurely terminated by
1350a signal or error,
1351.Nm
1352may have only partially extracted a file the user wanted.
1353Additionally, the file modes of extracted files and directories
1354may have incorrect file bits, and the modification and access times may be
1355wrong.
1356.Pp
1357If the creation of an archive is prematurely terminated by a signal or error,
1358.Nm
1359may have only partially created the archive, which may violate the specific
1360archive format specification.
1361.Pp
1362If while doing a
1363.Em copy ,
1364.Nm
1365detects a file is about to overwrite itself, the file is not copied,
1366a diagnostic message is written to standard error
1367and when
1368.Nm
1369completes it will exit with a non-zero exit status.
1370.Sh SEE ALSO
1371.Xr ar 1 ,
1372.Xr cpio 1 ,
1373.if \ng==1 \{\
1374.Xr deb 5 ,
1375.Xr mircpio 1 ,
1376.Xr mirtar 1 ,
1377.Xr pax 1 ,
1378.\}
1379.if \ng==2 \{\
1380.Xr deb 5 ,
1381.Xr paxcpio 1 ,
1382.Xr paxtar 1 ,
1383.\}
1384.Xr tar 1
1385.Sh STANDARDS
1386The
1387.Nm
1388utility is compliant with the
1389IEEE Std 1003.1-2008
1390.Pq Dq Tn POSIX
1391specification.
1392.Pp
1393The flags
1394.Fl 0BDEGHJjLMOPTUYZz ,
1395the archive formats
1396.Em ar ,
1397.Em bcpio ,
1398.Em sv4cpio ,
1399.Em sv4crc ,
1400.Em tar ,
1401and the flawed archive handling during
1402.Em list
1403and
1404.Em read
1405operations
1406are extensions to that specification.
1407.Sh AUTHORS
1408Keith Muller at the University of California, San Diego.
1409.Pp
1410.Mx
1411extensions by
1412.An Thorsten Glaser Aq tg@mirbsd.org .
Note: See TracBrowser for help on using the repository browser.