3f8fb63c0c
option, which is used in print/teTeX3-texmf. The only difference from the pax in src is that tar does not support the --chroot option if fchroot(2) is not available. Major changes and bug fixes since 20040802: PR/18759: FUKAUMI Naoki: pax/tar dot-dot handling broken PR/18840: Frederick Bruckman: Fix for PR/18663 incomplete pax symlink handling This patch makes ``--insecure'' do something. Now if ``--insecure'' is not set (the default) we do a realpath(3) in all the pathnames that we are trying to create and if either realpath fails, or the path is outside our working directory, we print a warning and die. This maybe too strict and might fail on valid archives that create symlinks and directories in the wrong order. PR/31923: Sergey Svishchev: pax-as-tar ignores -k, overwrites existing files Fix from Onno van der Linden PR/30132: Juan RP: tar --chroot refuses to extract files. fchroot() changes the effective path, so we need to call updatepath(). Apply user supplied patterns first before applying actions for -A. This way pax behavior WRT to patterns lines up with the example in the documentation and how other implementations do it as well since -A is a non-standard option/behavior. Fixes items noted in PR#23776 Add an option --chroot to tar. Causes it to chroot(".") before doing an extract. With -h this will cause existing absolute symlinks to be treated as relative to the current directory. Helps sysinst handle existing symlinks in the target system. Remove 'L' from the usage (got spilt into 'h' and 'H' many moons ago) Add 'S' to usage, and put into correct place in options list. PR/27213: Greg A. Woods: pax doesn't honour SIGPIPE when listing But always exit, not just on SIGPIPE. Properly handle "cpio" archives where the last hardlink includes the data of a file. This fixes PR bin/26514. PR/20228: Simon Burge: pax has problems reading a particular cpio archive The problem here is that the archive is too short (< 512 bytes). The buffer routines, try to read at least 512 bytes, even when we try to determine what format file we have, which is wrong. Don't leave arcn->org_name pointing to ftent->fts_path, if we being cpio then ftent is freed just below. Take a copy of the name and point org_name at the copy. Should fix PR/30627 (the fix in the PR will break pax and tar!) PR/30167: J.T. Conklin: NetBSD tar does not support GNU tar --no-recursion flag Fix from PR#29290. Properly terminate the cpio_longopts struct so an unknown option doesn't run off the end and core dump Fix broken cpio(1) option handling: - "cpio -i -t" should list the contents of a file, not extract it. - Don't extract a file when only option "-d" is given. Patch supplied by Paul Ripke in PR bin/26513. PR/27212: Greg A. Woods: Accept "-C <dirname>" inside filelists in addition to "-C\n<dirname>". But we are not making it the default output option as the patch suggests. PR/19490: Julio Merino: Teach tar about --sparse, -S option. Do it for cpio too. PR/27208: Greg A. Woods: pax must call options() before using syswarn() or tty_warn() PR/20071: Perry Metzger: --extract handling is broken. This patch fixes Perry's example.
329 lines
9.7 KiB
Groff
329 lines
9.7 KiB
Groff
.\" $NetBSD: tar.1,v 1.5 2005/12/01 03:00:01 minskim Exp $
|
|
.\"
|
|
.\" Copyright (c) 1996 SigmaSoft, Th. Lockert
|
|
.\" All rights reserved.
|
|
.\"
|
|
.\" Redistribution and use in source and binary forms, with or without
|
|
.\" modification, are permitted provided that the following conditions
|
|
.\" are met:
|
|
.\" 1. Redistributions of source code must retain the above copyright
|
|
.\" notice, this list of conditions and the following disclaimer.
|
|
.\" 2. Redistributions in binary form must reproduce the above copyright
|
|
.\" notice, this list of conditions and the following disclaimer in the
|
|
.\" documentation and/or other materials provided with the distribution.
|
|
.\"
|
|
.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
|
.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
|
.\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
|
.\" IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
.\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
|
.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
.\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
.\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
|
.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
.\"
|
|
.\" OpenBSD: tar.1,v 1.28 2000/11/09 23:58:56 aaron Exp
|
|
.\"
|
|
.Dd May 7, 2005
|
|
.Dt TAR 1
|
|
.Os
|
|
.Sh NAME
|
|
.Nm tar
|
|
.Nd tape archiver
|
|
.Sh SYNOPSIS
|
|
.Nm tar
|
|
.Sm off
|
|
.Oo \&- Oc {crtux} Op Fl befhjklmopqvwzHOPSXZ014578
|
|
.Sm on
|
|
.Op Ar archive
|
|
.Op Ar blocksize
|
|
.\" XXX how to do this right?
|
|
.Op Fl C Ar directory
|
|
.Op Fl T Ar file
|
|
.Op Fl s Ar replstr
|
|
.Op Ar file ...
|
|
.Sh DESCRIPTION
|
|
The
|
|
.Nm
|
|
command creates, adds files to, or extracts files from an
|
|
archive file in
|
|
.Dq tar
|
|
format.
|
|
A tar archive is often stored on a magnetic tape, but can be
|
|
stored equally well on a floppy, CD-ROM, or in a regular disk file.
|
|
.Pp
|
|
One of the following flags must be present:
|
|
.Bl -tag -width Ar
|
|
.It Fl c , -create
|
|
Create new archive, or overwrite an existing archive,
|
|
adding the specified files to it.
|
|
.It Fl r , -append
|
|
Append the named new files to existing archive.
|
|
Note that this will only work on media on which an end-of-file mark
|
|
can be overwritten.
|
|
.It Fl t , -list
|
|
List contents of archive.
|
|
If any files are named on the
|
|
command line, only those files will be listed.
|
|
.It Fl u , -update
|
|
Alias for
|
|
.Fl r .
|
|
.It Fl x , -extract , -get
|
|
Extract files from archive.
|
|
If any files are named on the
|
|
command line, only those files will be extracted from the
|
|
archive.
|
|
If more than one copy of a file exists in the
|
|
archive, later copies will overwrite earlier copies during
|
|
extraction.
|
|
The file mode and modification time are preserved
|
|
if possible.
|
|
The file mode is subject to modification by the
|
|
.Xr umask 2 .
|
|
.El
|
|
.Pp
|
|
In addition to the flags mentioned above, any of the following
|
|
flags may be used:
|
|
.Bl -tag -width Ar
|
|
.It Fl b Ar "blocking factor" , Fl -block-size Ar "blocking factor"
|
|
Set blocking factor to use for the archive.
|
|
.Nm
|
|
uses 512 byte blocks.
|
|
The default is 20, the maximum is 126.
|
|
Archives with a blocking factor larger 63 violate the
|
|
.Tn POSIX
|
|
standard and will not be portable to all systems.
|
|
.It Fl e
|
|
Stop after first error.
|
|
.It Fl f Ar archive , Fl -file Ar archive
|
|
Filename where the archive is stored.
|
|
Defaults to
|
|
.Pa /dev/rst0 .
|
|
If the archive is of the form:
|
|
.Ar [[user@]host:]file
|
|
then the archive will be processed using
|
|
.Xr rmt 8 .
|
|
.It Fl h , -dereference
|
|
Follow symbolic links as if they were normal files
|
|
or directories.
|
|
.It Fl j, -bzip2, -bunzip2
|
|
Use
|
|
.Xr bzip2 1
|
|
for compression of the archive.
|
|
This option is a GNU extension.
|
|
.It Fl k , -keep-old-files
|
|
Keep existing files; don't overwrite them from archive.
|
|
.It Fl l , -one-file-system
|
|
Do not cross filesystems.
|
|
.It Fl m , -modification-time
|
|
Do not preserve modification time.
|
|
.It Fl O
|
|
When creating and appending to an archive, write old-style (non-POSIX) archives.
|
|
When extracting from an archive, extract to standard output.
|
|
.It Fl o , -portability , -old-archive
|
|
Don't write directory information that the older (V7) style
|
|
.Nm
|
|
is unable to decode.
|
|
This implies the
|
|
.Fl O
|
|
flag.
|
|
.It Fl p , -preserve-permissions , -preserve
|
|
Preserve user and group ID as well as file mode regardless of
|
|
the current
|
|
.Xr umask 2 .
|
|
The setuid and setgid bits are only preserved if the user is
|
|
the superuser.
|
|
Only meaningful in conjunction with the
|
|
.Fl x
|
|
flag.
|
|
.It Fl q , -fast-read
|
|
Select the first archive member that matches each
|
|
.Ar pattern
|
|
operand.
|
|
No more than one archive member is matched for each
|
|
.Ar pattern .
|
|
When members of type directory are matched, the file hierarchy rooted at that
|
|
directory is also matched.
|
|
.It Fl S , -sparse
|
|
This flag has no effect as
|
|
.Nm
|
|
always generates sparse files.
|
|
.It Fl s Ar replstr
|
|
Modify the file or archive member names specified by the
|
|
.Ar pattern
|
|
or
|
|
.Ar file
|
|
operands according to the substitution expression
|
|
.Ar replstr ,
|
|
using the syntax of the
|
|
.Xr ed 1
|
|
utility regular expressions.
|
|
The format of these regular expressions are:
|
|
.Dl /old/new/[gp]
|
|
As in
|
|
.Xr ed 1 ,
|
|
.Cm old
|
|
is a basic regular expression and
|
|
.Cm new
|
|
can contain an ampersand (\*[Am]), \\n (where n is a digit) back-references,
|
|
or subexpression matching.
|
|
The
|
|
.Cm old
|
|
string may also contain
|
|
.Aq Dv newline
|
|
characters.
|
|
Any non-null character can be used as a delimiter (/ is shown here).
|
|
Multiple
|
|
.Fl s
|
|
expressions can be specified.
|
|
The expressions are applied in the order they are specified on the
|
|
command line, terminating with the first successful substitution.
|
|
The optional trailing
|
|
.Cm g
|
|
continues to apply the substitution expression to the pathname substring
|
|
which starts with the first character following the end of the last successful
|
|
substitution.
|
|
The first unsuccessful substitution stops the operation of the
|
|
.Cm g
|
|
option.
|
|
The optional trailing
|
|
.Cm p
|
|
will cause the final result of a successful substitution to be written to
|
|
.Dv standard error
|
|
in the following format:
|
|
.Dl \*[Lt]original pathname\*[Gt] \*[Gt]\*[Gt] \*[Lt]new pathname\*[Gt]
|
|
File or archive member names that substitute to the empty string
|
|
are not selected and will be skipped.
|
|
.It Fl v
|
|
Verbose operation mode.
|
|
.It Fl w , -interactive , -confirmation
|
|
Interactively rename files.
|
|
This option causes
|
|
.Nm
|
|
to prompt the user for the filename to use when storing or
|
|
extracting files in an archive.
|
|
.It Fl z , -gzip , -gunzip
|
|
Compress archive using gzip.
|
|
.It Fl B , -read-full-blocks
|
|
Reassemble small reads into full blocks (For reading from 4.2BSD pipes).
|
|
.It Fl C Ar directory , Fl -directory Ar directory
|
|
This is a positional argument which sets the working directory for the
|
|
following files.
|
|
When extracting, files will be extracted into
|
|
the specified directory; when creating, the specified files will be matched
|
|
from the directory.
|
|
This argument and its parameter may also appear in a file list specified by
|
|
.Fl T .
|
|
.It Fl H
|
|
Follow symlinks given on command line only.
|
|
.It Fl P , -absolute-paths
|
|
Do not strip leading slashes
|
|
.Pq Sq /
|
|
from pathnames.
|
|
The default is to strip leading slashes.
|
|
.It Fl T Ar file , Fl -files-from Ar file
|
|
Read the names of files to archive or extract from the given file, one
|
|
per line.
|
|
A line may also specify the positional argument
|
|
.Dq Fl C Ar directory .
|
|
.It Fl X Ar file , Fl -exclude-from Ar file
|
|
Exclude files listed in the given file.
|
|
.It Fl Z , -compress , -uncompress
|
|
Compress archive using compress.
|
|
.It Fl -strict
|
|
Do not enable GNU tar extensions such as long filenames and long link names.
|
|
.It Fl -atime-preserve
|
|
Preserve file access times.
|
|
.It Fl -chroot
|
|
.Fn chroot
|
|
to the current directory before extracting files.
|
|
Use with
|
|
.Fl x
|
|
and
|
|
.Fl h
|
|
to make absolute symlinks relative to the current directory.
|
|
.It Fl -unlink
|
|
Ignored, only accepted for compatibility with other
|
|
.Nm
|
|
implementations.
|
|
.Nm
|
|
always unlinks files before creating them.
|
|
.It Fl -use-compress-program Ar program
|
|
Use the named program as the program to decompress the input.
|
|
.It Fl -force-local
|
|
Do not interpret filenames that contain a
|
|
.Sq \&:
|
|
as remote files.
|
|
.It Fl -insecure
|
|
Normally
|
|
.Nm
|
|
ignores filenames that contain
|
|
.Sq ..
|
|
as a path component.
|
|
With this option, files that contain
|
|
.Sq ..
|
|
can be processed.
|
|
.It Fl -no-recursion
|
|
Cause files of type directory being copied or archived, or archive members of
|
|
type directory being extracted, to match only the directory file or archive
|
|
member and not the file hierarchy rooted at the directory.
|
|
.El
|
|
.Pp
|
|
The options
|
|
.Op Fl 014578
|
|
can be used to select one of the compiled-in backup devices,
|
|
.Pa /dev/rstN .
|
|
.Sh FILES
|
|
.Bl -tag -width "/dev/rst0"
|
|
.It Pa /dev/rst0
|
|
default archive name
|
|
.El
|
|
.Sh DIAGNOSTICS
|
|
.Nm
|
|
will exit with one of the following values:
|
|
.Bl -tag -width 2n
|
|
.It 0
|
|
All files were processed successfully.
|
|
.It 1
|
|
An error occurred.
|
|
.El
|
|
.Pp
|
|
Whenever
|
|
.Nm
|
|
cannot create a file or a link when extracting an archive or cannot
|
|
find a file while writing an archive, or cannot preserve the user
|
|
ID, group ID, file mode, or access and modification times when the
|
|
.Fl p
|
|
option is specified, a diagnostic message is written to standard
|
|
error and a non-zero exit value will be returned, but processing
|
|
will continue.
|
|
In the case where
|
|
.Nm
|
|
cannot create a link to a file,
|
|
.Nm
|
|
will not create a second copy of the file.
|
|
.Pp
|
|
If the extraction of a file from an archive is prematurely terminated
|
|
by a signal or error,
|
|
.Nm
|
|
may have only partially extracted the file the user wanted.
|
|
Additionally, the file modes of extracted files and directories may
|
|
have incorrect file bits, and the modification and access times may
|
|
be wrong.
|
|
.Pp
|
|
If the creation of an archive is prematurely terminated by a signal
|
|
or error,
|
|
.Nm
|
|
may have only partially created the archive which may violate the
|
|
specific archive format specification.
|
|
.Sh SEE ALSO
|
|
.Xr cpio 1 ,
|
|
.Xr pax 1
|
|
.Sh HISTORY
|
|
A
|
|
.Nm
|
|
command first appeared in
|
|
.At v7 .
|
|
.Sh AUTHORS
|
|
Keith Muller at the University of California, San Diego.
|