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

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

wbx@ asked me a few seconds too late to use an src/ subdirectory

git-svn-id: svn://www.freewrt.org/trunk/freewrt@204 afb5a338-a214-0410-bd46-81f09a774fd1

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