svn commit: r224563 - in stable/8/usr.bin/tar: . test

Martin Matuska mm at FreeBSD.org
Mon Aug 1 08:00:47 UTC 2011


Author: mm
Date: Mon Aug  1 08:00:46 2011
New Revision: 224563
URL: http://svn.freebsd.org/changeset/base/224563

Log:
  Sync bsdtar with 9-CURRENT:
  
  MFC on usr.bin/bsdtar:
  203569,203571,203586-203590,203593-203594,204329,205076,206463-206466,
  206484-206485,206487,207786,207790-207791,208028,209152,210720,213469,
  223541,223573,224153,224158
  
  MFC 203569 (kientzle):
  bsdtar doesn't actually know what compression is supported by libarchive
  and it should not pretend that it does.  It should just pass along the
  user's request and handle an error if it's not supported.
  
  MFC 203571 (kientzle):
  Fill in some missing error handling, be a little more careful about
  error reporting, prefer int64_t to off_t.
  
  MFC 203586 (kientzle):
  Trim out some unused configuration variables, remove
  some unused headers, etc.
  
  MFC 203587 (kientzle):
  Minor code rework.
  
  MFC 203588 (kientzle):
  Restructure the logic that determines when we're crossing a mount
  point.  In particular, this carves out a place for detecting and
  excluding synthetic or network filesystems.
  
  MFC 203589 (kientzle):
  Various portability workarounds for non-FreeBSD platforms.
  
  MFC 203590 (kientzle):
  Style & Portability:  Use archive_entry methods to examine
  file information, change some functions to static, remove
  some unused headers.
  
  MFC 203593 (kientzle):
  Merge a bunch of refactoring from Joerg Sonnenberger to
  isolate common code used by tar and cpio (and useful to other
  libarchive clients).  The functions here are prefixed with
  "lafe" (libarchive front-end) to indicate their use.
  
  MFC 203594 (kientzle):
  Simplify, remove unnecessary code.
  
  MFC 204329 (ru)
  Fixed dependencies (make checkdpadd).
  
  MFC 205076 (uqs):
  Fix several typos in macros or macro misusage.
  
  Found by:	make manlint
  
  MFC 206463 (kientzle):
  Correct the markup for the -s option,
  document the iso9660:rockridge and mtree:indent options
  
  MFC 206464 (kientzle):
  Remove an unnecessary include and conditionalize some code.
  
  MFC 206465 (kientzle):
  Consistently specify O_BINARY when opening files.
  
  MFC 206466 (kientzle):
  Fix -X.
  
  MFC 206484 (kientzle):
  Diff reduction against bsdtar 2.8.3
  
  MFC 206485 (kientzle):
  Diff reduction against bsdtar 2.8.3
  
  MFC 206487 (kientzle):
  If a file is specifically both included and excluded, then:
   * It is not extracted (because it is excluded)
   * If it's not present in the archive, then an error is
     reported (because the file was requested and not found)
   * If it is present in the archive, no error is reported.
  Previously, this would always report an error because the
  exclusion prevented the entry from matching the inclusion.
  
  Also, tar is now more reluctant to report unmatched inclusions.
  Previously, "tar x file1 'file*'" against an archive that contained a
  single entry "file1" would match file1 and then report an error for
  the second pattern because it wasn't matched.  It now considers both
  inclusions to be matched and reports no error.
  
  MFC 207786 (kientzle):
  Various manpage updates, including many long-option synonyms that were previously
  undocumented.
  
  MFC 207790 (kientzle):
  Config updates.
  
  MFC 207791 (kientzle)
  FreeBSD is now using bsdtar 2.8.3.
  
  MFC 208028 (uqs):
  mdoc: move remaining sections into consistent order
  
  This pertains mostly to FILES, HISTORY, EXIT STATUS and AUTHORS sections.
  
  Found by:	mdocml lint run
  
  MFC 209152 (kientzle):
  If the compressed data is larger than the uncompressed,
  report the compression ratio as 0% instead of displaying
  nonsense triggered by numeric overflow.  This is common
  when dealing with uncompressed files when the I/O blocking
  causes there to be small transient differences in the
  accounting.
  
  Thanks to:	Boris Samorodov
  
  MFC 210720 (joel):
  Fix typos.
  
  MFC 213469 (kientzle):
  Recognize both ! and ^ as markers for negated character classes.
  
  Submitted by:	Mykola Dzham
  
  MFC 223541 (kientzle):
  If there is a read error reading Y/N confirmation from the keyboard,
  exit immediately with an error.
  
  If there is an error opening or reading a file to put into the archive,
  set the return value for a deferred error exit.
  
  MFC 223573 (kientzle):
  The --newer-than test should descend into old
  directories to look for new files.
  
  MFC 224153 (mm):
  Update bsdtar to 2.8.4
  Use common code from lib/libarchive/libarchive_fe
  
  MFC 224158 (mm):
  Fix accidential commit part:
  Include "bsdtar_platform.h" instead of "lafe_platform.h"

Added:
  stable/8/usr.bin/tar/test/test_empty_mtree.c
     - copied unchanged from r224153, head/usr.bin/tar/test/test_empty_mtree.c
  stable/8/usr.bin/tar/test/test_option_T_upper.c
     - copied unchanged from r224153, head/usr.bin/tar/test/test_option_T_upper.c
  stable/8/usr.bin/tar/test/test_option_r.c
     - copied unchanged from r224153, head/usr.bin/tar/test/test_option_r.c
Deleted:
  stable/8/usr.bin/tar/err.c
  stable/8/usr.bin/tar/err.h
  stable/8/usr.bin/tar/matching.c
  stable/8/usr.bin/tar/test/test_option_T.c
Modified:
  stable/8/usr.bin/tar/Makefile
  stable/8/usr.bin/tar/bsdtar.1
  stable/8/usr.bin/tar/bsdtar.c
  stable/8/usr.bin/tar/bsdtar.h
  stable/8/usr.bin/tar/bsdtar_platform.h
  stable/8/usr.bin/tar/cmdline.c
  stable/8/usr.bin/tar/config_freebsd.h
  stable/8/usr.bin/tar/getdate.c
  stable/8/usr.bin/tar/read.c
  stable/8/usr.bin/tar/subst.c
  stable/8/usr.bin/tar/test/Makefile
  stable/8/usr.bin/tar/test/main.c
  stable/8/usr.bin/tar/test/test.h
  stable/8/usr.bin/tar/test/test_0.c
  stable/8/usr.bin/tar/test/test_basic.c
  stable/8/usr.bin/tar/test/test_copy.c
  stable/8/usr.bin/tar/test/test_help.c
  stable/8/usr.bin/tar/test/test_option_q.c
  stable/8/usr.bin/tar/test/test_option_s.c
  stable/8/usr.bin/tar/test/test_patterns.c
  stable/8/usr.bin/tar/test/test_patterns_2.tar.uu
  stable/8/usr.bin/tar/test/test_patterns_3.tar.uu
  stable/8/usr.bin/tar/test/test_patterns_4.tar.uu
  stable/8/usr.bin/tar/test/test_stdio.c
  stable/8/usr.bin/tar/test/test_strip_components.c
  stable/8/usr.bin/tar/test/test_symlink_dir.c
  stable/8/usr.bin/tar/test/test_version.c
  stable/8/usr.bin/tar/tree.h
  stable/8/usr.bin/tar/util.c
  stable/8/usr.bin/tar/write.c
Directory Properties:
  stable/8/usr.bin/tar/   (props changed)

Modified: stable/8/usr.bin/tar/Makefile
==============================================================================
--- stable/8/usr.bin/tar/Makefile	Mon Aug  1 07:59:54 2011	(r224562)
+++ stable/8/usr.bin/tar/Makefile	Mon Aug  1 08:00:46 2011	(r224563)
@@ -2,25 +2,33 @@
 .include <bsd.own.mk>
 
 PROG=	bsdtar
-BSDTAR_VERSION_STRING=2.7.0
+BSDTAR_VERSION_STRING=2.8.4
 SRCS=	bsdtar.c	\
 	cmdline.c	\
-	err.c		\
 	getdate.c	\
-	matching.c	\
 	read.c		\
 	subst.c		\
 	tree.c		\
 	util.c		\
 	write.c
-DPADD=	${LIBARCHIVE} ${LIBBZ2} ${LIBZ} ${LIBLZMA}
-LDADD=	-larchive -lbz2 -lz -lmd -llzma
+
+.PATH: ${.CURDIR}/../../lib/libarchive/libarchive_fe
+SRCS+=	err.c		\
+	line_reader.c	\
+	matching.c	\
+	pathmatch.c
+
+WARNS?=	6
+DPADD=	${LIBARCHIVE} ${LIBBZ2} ${LIBZ} ${LIBMD} ${LIBLZMA} ${LIBBSDXML}
+LDADD=	-larchive -lbz2 -lz -lmd -llzma -lbsdxml
 .if ${MK_OPENSSL} != "no"
+DPADD+=	${LIBCRYPTO}
 LDADD+= -lcrypto
 .endif
 CFLAGS+=	-DBSDTAR_VERSION_STRING=\"${BSDTAR_VERSION_STRING}\"
 CFLAGS+=	-DPLATFORM_CONFIG_H=\"config_freebsd.h\"
 CFLAGS+=	-I${.CURDIR} -I${.CURDIR}/../../lib/libarchive
+CFLAGS+=	-I${.CURDIR}/../../lib/libarchive/libarchive_fe
 SYMLINKS=	bsdtar ${BINDIR}/tar
 MLINKS=	bsdtar.1 tar.1
 DEBUG_FLAGS=-g

Modified: stable/8/usr.bin/tar/bsdtar.1
==============================================================================
--- stable/8/usr.bin/tar/bsdtar.1	Mon Aug  1 07:59:54 2011	(r224562)
+++ stable/8/usr.bin/tar/bsdtar.1	Mon Aug  1 08:00:46 2011	(r224563)
@@ -24,7 +24,7 @@
 .\"
 .\" $FreeBSD$
 .\"
-.Dd March 25, 2009
+.Dd Oct 12, 2009
 .Dt BSDTAR 1
 .Os
 .Sh NAME
@@ -50,8 +50,8 @@
 .Sh DESCRIPTION
 .Nm
 creates and manipulates streaming archive files.
-This implementation can extract from tar, pax, cpio, zip, jar, ar,
-and ISO 9660 cdrom images and can create tar, pax, cpio, ar,
+This implementation can extract from tar, pax, cpio, zip, jar, ar, xar,
+rpm and ISO 9660 cdrom images and can create tar, pax, cpio, ar, zip,
 and shar archives.
 .Pp
 The first synopsis form shows a
@@ -67,6 +67,8 @@ is a mode indicator from the following l
 .Bl -tag -compact -width indent
 .It Fl c
 Create a new archive containing the specified items.
+The long option form is
+.Fl Fl create .
 .It Fl r
 Like
 .Fl c ,
@@ -75,8 +77,12 @@ Note that this only works on uncompresse
 The
 .Fl f
 option is required.
+The long option form is
+.Fl Fl append .
 .It Fl t
 List archive contents to stdout.
+The long option form is
+.Fl Fl list .
 .It Fl u
 Like
 .Fl r ,
@@ -86,11 +92,15 @@ Note that this only works on uncompresse
 The
 .Fl f
 option is required.
+The long form is
+.Fl Fl update .
 .It Fl x
 Extract to disk from the archive.
 If a file with the same name appears more than once in the archive,
 each copy will be extracted, with later copies overwriting (replacing)
 earlier copies.
+The long option form is
+.Fl Fl extract .
 .El
 .Pp
 In
@@ -127,14 +137,18 @@ In contrast,
 .Dl Nm Fl c Fl f Pa - Pa newfile Pa original.tar
 creates a new archive with only two entries.
 Similarly,
-.Dl Nm Fl czf Pa - Fl -format Cm pax Cm @ Ns Pa -
+.Dl Nm Fl czf Pa - Fl Fl format Cm pax Cm @ Ns Pa -
 reads an archive from standard input (whose format will be determined
 automatically) and converts it into a gzip-compressed
 pax-format archive on stdout.
 In this way,
 .Nm
 can be used to convert archives from one format to another.
-.It Fl b Ar blocksize
+.It Fl B , Fl Fl read-full-blocks
+Ignored for compatibility with other
+.Xr tar 1
+implementations.
+.It Fl b Ar blocksize , Fl Fl block-size Ar blocksize
 Specify the block size, in 512-byte records, for tape drive I/O.
 As a rule, this argument is only needed when reading from or writing
 to tape drives, and usually not even then as the default block size of
@@ -144,21 +158,22 @@ In c and r mode, this changes the direct
 the following files.
 In x mode, change directories after opening the archive
 but before extracting entries from the archive.
-.It Fl -check-links
-(c and r modes only)
-Issue a warning message unless all links to each file are archived.
-.It Fl -chroot
+.It Fl Fl chroot
 (x mode only)
 .Fn chroot
 to the current directory after processing any
 .Fl C
 options and before extracting any files.
-.It Fl -exclude Ar pattern
+.It Fl Fl disable-copyfile
+Mac OS X specific.
+Disable the use of
+.Xr copyfile 3 .
+.It Fl Fl exclude Ar pattern
 Do not process files or directories that match the
 specified pattern.
 Note that exclusions take precedence over patterns or filenames
 specified on the command line.
-.It Fl -format Ar format
+.It Fl Fl format Ar format
 (c, r, u mode only)
 Use the specified format for the created archive.
 Supported formats include
@@ -172,16 +187,39 @@ Other formats may also be supported; see
 for more information about currently-supported formats.
 In r and u modes, when extending an existing archive, the format specified
 here must be compatible with the format of the existing archive on disk.
-.It Fl f Ar file
+.It Fl f Ar file , Fl Fl file Ar file
 Read the archive from or write the archive to the specified file.
 The filename can be
 .Pa -
 for standard input or standard output.
-If not specified, the default tape device will be used.
-(On
+The default varies by system;
+on
 .Fx ,
-the default tape device is
-.Pa /dev/sa0 . )
+the default is
+.Pa /dev/sa0 ;
+on Linux, the default is
+.Pa /dev/st0 .
+.It Fl Fl gid Ar id
+Use the provided group id number.
+On extract, this overrides the group id in the archive;
+the group name in the archive will be ignored.
+On create, this overrides the group id read from disk;
+if
+.Fl Fl gname
+is not also specified, the group name will be set to
+match the group id.
+.It Fl Fl gname Ar name
+Use the provided group name.
+On extract, this overrides the group name in the archive;
+if the provided group name does not exist on the system,
+the group id
+(from the archive or from the
+.Fl Fl gid
+option)
+will be used instead.
+On create, this sets the group name that will be stored
+in the archive;
+the name will not be verified against the system group database.
 .It Fl H
 (c and r mode only)
 Symbolic links named on the command line will be followed; the
@@ -193,25 +231,36 @@ Synonym for
 .It Fl I
 Synonym for
 .Fl T .
-.It Fl -include Ar pattern
+.It Fl Fl help
+Show usage.
+.It Fl Fl include Ar pattern
 Process only files or directories that match the specified pattern.
 Note that exclusions specified with
-.Fl -exclude
+.Fl Fl exclude
 take precedence over inclusions.
 If no inclusions are explicitly specified, all entries are processed by
 default.
 The
-.Fl -include
+.Fl Fl include
 option is especially useful when filtering archives.
 For example, the command
-.Dl Nm Fl c Fl f Pa new.tar Fl -include='*foo*' Cm @ Ns Pa old.tgz
+.Dl Nm Fl c Fl f Pa new.tar Fl Fl include='*foo*' Cm @ Ns Pa old.tgz
 creates a new archive
 .Pa new.tar
 containing only the entries from
 .Pa old.tgz
 containing the string
 .Sq foo .
-.It Fl j
+.It Fl J , Fl Fl xz
+(c mode only)
+Compress the resulting archive with
+.Xr xz 1 .
+In extract or list modes, this option is ignored.
+Note that, unlike other
+.Nm tar
+implementations, this implementation recognizes XZ compression
+automatically when reading archives.
+.It Fl j , Fl Fl bzip , Fl Fl bzip2 , Fl Fl bunzip2
 (c mode only)
 Compress the resulting archive with
 .Xr bzip2 1 .
@@ -220,69 +269,99 @@ Note that, unlike other
 .Nm tar
 implementations, this implementation recognizes bzip2 compression
 automatically when reading archives.
-.It Fl k
+.It Fl k , Fl Fl keep-old-files
 (x mode only)
 Do not overwrite existing files.
 In particular, if a file appears more than once in an archive,
 later copies will not overwrite earlier copies.
-.It Fl -keep-newer-files
+.It Fl Fl keep-newer-files
 (x mode only)
 Do not overwrite existing files that are newer than the
 versions appearing in the archive being extracted.
-.It Fl L
+.It Fl L , Fl Fl dereference
 (c and r mode only)
 All symbolic links will be followed.
 Normally, symbolic links are archived as such.
 With this option, the target of the link will be archived instead.
-.It Fl l
-This is a synonym for the
-.Fl -check-links
-option.
-.It Fl m
+.It Fl l , Fl Fl check-links
+(c and r modes only)
+Issue a warning message unless all links to each file are archived.
+.It Fl Fl lzma
+(c mode only) Compress the resulting archive with the original LZMA algorithm.
+Use of this option is discouraged and new archives should be created with
+.Fl Fl xz
+instead.
+Note that, unlike other
+.Nm tar
+implementations, this implementation recognizes LZMA compression
+automatically when reading archives.
+.It Fl m , Fl Fl modification-time
 (x mode only)
 Do not extract modification time.
 By default, the modification time is set to the time stored in the archive.
-.It Fl n
+.It Fl n , Fl Fl norecurse , Fl Fl no-recursion
 (c, r, u modes only)
 Do not recursively archive the contents of directories.
-.It Fl -newer Ar date
+.It Fl Fl newer Ar date
 (c, r, u modes only)
 Only include files and directories newer than the specified date.
 This compares ctime entries.
-.It Fl -newer-mtime Ar date
+.It Fl Fl newer-mtime Ar date
 (c, r, u modes only)
 Like
-.Fl -newer ,
+.Fl Fl newer ,
 except it compares mtime entries instead of ctime entries.
-.It Fl -newer-than Pa file
+.It Fl Fl newer-than Pa file
 (c, r, u modes only)
 Only include files and directories newer than the specified file.
 This compares ctime entries.
-.It Fl -newer-mtime-than Pa file
+.It Fl Fl newer-mtime-than Pa file
 (c, r, u modes only)
 Like
-.Fl -newer-than ,
+.Fl Fl newer-than ,
 except it compares mtime entries instead of ctime entries.
-.It Fl -nodump
+.It Fl Fl nodump
 (c and r modes only)
 Honor the nodump file flag by skipping this file.
-.It Fl -null
+.It Fl Fl null
 (use with
-.Fl I ,
-.Fl T ,
+.Fl I
 or
-.Fl X )
+.Fl T )
 Filenames or patterns are separated by null characters,
 not by newlines.
 This is often used to read filenames output by the
 .Fl print0
 option to
 .Xr find 1 .
-.It Fl -numeric-owner
+.It Fl Fl no-same-owner
+(x mode only)
+Do not extract owner and group IDs.
+This is the reverse of
+.Fl Fl same-owner
+and the default behavior if
+.Nm
+is run as non-root.
+.It Fl Fl no-same-permissions
 (x mode only)
-Ignore symbolic user and group names when restoring archives to disk,
-only numeric uid and gid values will be obeyed.
-.It Fl O
+Do not extract full permissions (SGID, SUID, sticky bit, ACLs,
+extended attributes or extended file flags).
+This is the reverse of
+.Fl p
+and the default behavior if
+.Nm
+is run as non-root.
+.It Fl Fl numeric-owner
+This is equivalent to
+.Fl Fl uname
+.Qq
+.Fl Fl gname
+.Qq .
+On extract, it causes user and group names in the archive
+to be ignored in favor of the numeric user and group ids.
+On create, it causes user and group names to not be stored
+in the archive.
+.It Fl O , Fl Fl to-stdout
 (x, t modes only)
 In extract (-x) mode, files will be written to standard out rather than
 being extracted to disk.
@@ -301,11 +380,11 @@ the archive will be discarded.
 .It Fl o
 (c, r, u mode)
 A synonym for
-.Fl -format Ar ustar
-.It Fl -one-file-system
+.Fl Fl format Ar ustar
+.It Fl Fl one-file-system
 (c, r, and u modes)
 Do not cross mount points.
-.It Fl -options Ar options
+.It Fl Fl options Ar options
 Select optional behaviors for particular modules.
 The argument is a text string containing comma-separated
 keywords and values.
@@ -336,6 +415,13 @@ This is enabled by default, use
 or
 .Cm iso9660:!joliet
 to disable.
+.It Cm iso9660:rockridge
+Support Rock Ridge extensions.
+This is enabled by default, use
+.Cm !rockridge
+or
+.Cm iso9660:!rockridge
+to disable.
 .It Cm gzip:compression-level
 A decimal integer from 0 to 9 specifying the gzip compression level.
 .It Cm xz:compression-level
@@ -359,11 +445,17 @@ Enable generation of
 .Cm /set
 lines in the output.
 .It Cm mtree:indent
-XXX need explanation XXX
+Produce human-readable output by indenting options and splitting lines
+to fit into 80 columns.
+.It Cm zip:compression Ns = Ns Ar type
+Use
+.Ar type
+as compression method.
+Supported values are store (uncompressed) and deflate (gzip algorithm).
 .El
 If a provided option is not supported by any module, that
 is a fatal error.
-.It Fl P
+.It Fl P , Fl Fl absolute-paths
 Preserve pathnames.
 By default, absolute pathnames (those that begin with a /
 character) have the leading slash removed both when creating archives
@@ -374,21 +466,22 @@ will refuse to extract archive entries w
 .Pa ..
 or whose target directory would be altered by a symlink.
 This option suppresses these behaviors.
-.It Fl p
+.It Fl p , Fl Fl insecure , Fl Fl preserve-permissions
 (x mode only)
 Preserve file permissions.
 Attempt to restore the full permissions, including owner, file modes, file
 flags and ACLs, if available, for each item extracted from the archive.
-By default, newly-created files are owned by the user running
-.Nm ,
-the file mode is restored for newly-created regular files, and
-all other types of entries receive default permissions.
-If
+This is the default, if
 .Nm
-is being run by root, the default is to restore the owner unless the
-.Fl o
-option is also specified.
-.It Fl q ( Fl -fast-read )
+is being run by root and can be overriden by also specifying
+.Fl Fl no-same-owner
+and
+.Fl Fl no-same-permissions .
+.It Fl Fl posix
+(c, r, u mode only)
+Synonym for
+.Fl Fl format Ar pax
+.It Fl q , Fl Fl fast-read
 (x and t mode only)
 Extract or list only the first archive entry that matches each pattern
 or filename operand.
@@ -402,8 +495,16 @@ This option is provided as a performance
 Extract files as sparse files.
 For every block on disk, check first if it contains only NULL bytes and seek
 over it otherwise.
-This works similiar to the conv=sparse option of dd.
-.It Fl -strip-components Ar count
+This works similar to the conv=sparse option of dd.
+.It Fl Fl same-owner
+(x mode only)
+Extract owner and group IDs.
+This is the reverse of
+.Fl Fl no-same-owner
+and the default behavior if
+.Nm
+is run as root.
+.It Fl Fl strip-components Ar count
 (x mode only)
 Remove the specified number of leading path elements.
 Pathnames with fewer elements will be silently skipped.
@@ -412,11 +513,21 @@ but before security checks.
 .It Fl s Ar pattern
 Modify file or archive member names according to
 .Pa pattern .
-The pattern has the format /old/new/[gps].
-old is a basic regular expression.
-If it doesn't apply, the pattern is skipped.
-new is the replacement string of the matched part.
-~ is substituted with the match, \1 to \9 with the content of
+The pattern has the format
+.Ar /old/new/ Ns Op gps
+where
+.Ar old
+is a basic regular expression,
+.Ar new
+is the replacement string of the matched part,
+and the optional trailing letters modify
+how the replacement is handled.
+If
+.Ar old
+is not matched, the pattern is skipped.
+Within
+.Ar new ,
+~ is substituted with the match, \e1 to \e9 with the content of
 the corresponding captured group.
 The optional trailing g specifies that matching should continue
 after the matched part and stopped on the first unmatched pattern.
@@ -425,7 +536,7 @@ of symbolic links.
 The optional trailing p specifies that after a successful substitution
 the original path name and the new path name should be printed to
 standard error.
-.It Fl T Ar filename
+.It Fl T Ar filename , Fl Fl files-from Ar filename
 In x or t mode,
 .Nm
 will read the list of names to be extracted from
@@ -439,25 +550,50 @@ The special name
 on a line by itself will cause the current directory to be changed to
 the directory specified on the following line.
 Names are terminated by newlines unless
-.Fl -null
+.Fl Fl null
 is specified.
 Note that
-.Fl -null
+.Fl Fl null
 also disables the special handling of lines containing
 .Dq -C .
-.It Fl U
+.It Fl Fl totals
+(c, r, u mode only)
+After archiving all files, print a summary to stderr.
+.It Fl U , Fl Fl unlink , Fl Fl unlink-first
 (x mode only)
 Unlink files before creating them.
-Without this option,
-.Nm
-overwrites existing files, which preserves existing hardlinks.
-With this option, existing hardlinks will be broken, as will any
-symlink that would affect the location of an extracted file.
-.It Fl -use-compress-program Ar program
+This can be a minor performance optimization if most files
+already exist, but can make things slower if most files
+do not already exist.
+This flag also causes
+.Nm
+to remove intervening directory symlinks instead of
+reporting an error.
+See the SECURITY section below for more details.
+.It Fl Fl uid Ar id
+Use the provided user id number and ignore the user
+name from the archive.
+On create, if
+.Fl Fl uname
+is not also specified, the user name will be set to
+match the user id.
+.It Fl Fl uname Ar name
+Use the provided user name.
+On extract, this overrides the user name in the archive;
+if the provided user name does not exist on the system,
+it will be ignored and the user id
+(from the archive or from the
+.Fl Fl uid
+option)
+will be used instead.
+On create, this sets the user name that will be stored
+in the archive;
+the name is not verified against the system user database.
+.It Fl Fl use-compress-program Ar program
 Pipe the input (in x or t mode) or the output (in c mode) through
 .Pa program
 instead of using the builtin compression support.
-.It Fl v
+.It Fl v , Fl Fl verbose
 Produce verbose output.
 In create and extract modes,
 .Nm
@@ -470,18 +606,18 @@ will produce output similar to that of
 Additional
 .Fl v
 options will provide additional detail.
-.It Fl -version
+.It Fl Fl version
 Print version of
 .Nm
 and
 .Nm libarchive ,
 and exit.
-.It Fl w
+.It Fl w , Fl Fl confirmation , Fl Fl interactive
 Ask for confirmation for every action.
-.It Fl X Ar filename
+.It Fl X Ar filename , Fl Fl exclude-from Ar filename
 Read a list of exclusion patterns from the specified file.
 See
-.Fl -exclude
+.Fl Fl exclude
 for more information about the handling of exclusions.
 .It Fl y
 (c mode only)
@@ -492,23 +628,23 @@ Note that, unlike other
 .Nm tar
 implementations, this implementation recognizes bzip2 compression
 automatically when reading archives.
-.It Fl z
+.It Fl Z , Fl Fl compress , Fl Fl uncompress
 (c mode only)
 Compress the resulting archive with
-.Xr gzip 1 .
+.Xr compress 1 .
 In extract or list modes, this option is ignored.
 Note that, unlike other
 .Nm tar
-implementations, this implementation recognizes gzip compression
+implementations, this implementation recognizes compress compression
 automatically when reading archives.
-.It Fl Z
+.It Fl z , Fl Fl gunzip , Fl Fl gzip
 (c mode only)
 Compress the resulting archive with
-.Xr compress 1 .
+.Xr gzip 1 .
 In extract or list modes, this option is ignored.
 Note that, unlike other
 .Nm tar
-implementations, this implementation recognizes compress compression
+implementations, this implementation recognizes gzip compression
 automatically when reading archives.
 .El
 .Sh ENVIRONMENT
@@ -521,25 +657,19 @@ See
 .Xr environ 7
 for more information.
 .It Ev TAPE
-The default tape device.
+The default device.
 The
 .Fl f
 option overrides this.
+Please see the description of the
+.Fl f
+option above for more details.
 .It Ev TZ
 The timezone to use when displaying dates.
 See
 .Xr environ 7
 for more information.
 .El
-.Sh FILES
-.Bl -tag -width ".Ev BLOCKSIZE"
-.It Pa /dev/sa0
-The default tape device, if not overridden by the
-.Ev TAPE
-environment variable or the
-.Fl f
-option.
-.El
 .Sh EXIT STATUS
 .Ex -std
 .Sh EXAMPLES
@@ -604,9 +734,9 @@ permissions, or names that differ from e
 .Dl $ tar -cvf output.tar @input.mtree
 .Pp
 The
-.Fl -newer
+.Fl Fl newer
 and
-.Fl -newer-mtime
+.Fl Fl newer-mtime
 switches accept a variety of common date and time specifications, including
 .Dq 12 Mar 2005 7:14:29pm ,
 .Dq 2005-03-12 19:14 ,
@@ -615,7 +745,7 @@ and
 .Dq 19:14 PST May 1 .
 .Pp
 The
-.Fl -options
+.Fl Fl options
 argument can be used to control various details of archive generation
 or reading.
 For example, you can generate mtree output which only contains
@@ -623,9 +753,9 @@ For example, you can generate mtree outp
 and
 .Cm uid
 keywords:
-.Dl Nm Fl cf Pa file.tar Fl -format=mtree Fl -options='!all,type,time,uid' Pa dir
+.Dl Nm Fl cf Pa file.tar Fl Fl format=mtree Fl Fl options='!all,type,time,uid' Pa dir
 or you can set the compression level used by gzip or xz compression:
-.Dl Nm Fl czf Pa file.tar Fl -options='compression-level=9' .
+.Dl Nm Fl czf Pa file.tar Fl Fl options='compression-level=9' .
 For more details, see the explanation of the
 .Fn archive_read_set_options
 and
@@ -771,6 +901,7 @@ components, or symlinks to other directo
 .Xr mt 1 ,
 .Xr pax 1 ,
 .Xr shar 1 ,
+.Xr xz 1 ,
 .Xr libarchive 3 ,
 .Xr libarchive-formats 5 ,
 .Xr tar 5
@@ -780,7 +911,7 @@ in
 .St -p1003.1-96
 but was dropped from
 .St -p1003.1-2001 .
-The options used by this implementation were developed by surveying a
+The options supported by this implementation were developed by surveying a
 number of existing tar implementations as well as the old POSIX specification
 for tar and the current POSIX specification for pax.
 .Pp
@@ -806,6 +937,9 @@ beginning with
 This is a complete re-implementation based on the
 .Xr libarchive 3
 library.
+It was first released with
+.Fx 5.4
+in May, 2005.
 .Sh BUGS
 This program follows
 .St -p1003.1-96
@@ -815,7 +949,7 @@ option.
 Note that GNU tar prior to version 1.15 treated
 .Fl l
 as a synonym for the
-.Fl -one-file-system
+.Fl Fl one-file-system
 option.
 .Pp
 The
@@ -893,6 +1027,3 @@ Converting between dissimilar archive fo
 convention can cause hard link information to be lost.
 (This is a consequence of the incompatible ways that different archive
 formats store hardlink information.)
-.Pp
-There are alternative long options for many of the short options that
-are deliberately not documented.

Modified: stable/8/usr.bin/tar/bsdtar.c
==============================================================================
--- stable/8/usr.bin/tar/bsdtar.c	Mon Aug  1 07:59:54 2011	(r224562)
+++ stable/8/usr.bin/tar/bsdtar.c	Mon Aug  1 08:00:46 2011	(r224563)
@@ -85,6 +85,12 @@ __FBSDID("$FreeBSD$");
 #define	_PATH_DEFTAPE "/dev/tape"
 #endif
 
+#ifdef __MINGW32__
+int _CRT_glob = 0; /* Disable broken CRT globbing. */
+#endif
+
+static struct bsdtar *_bsdtar;
+
 #if defined(HAVE_SIGACTION) && (defined(SIGINFO) || defined(SIGUSR1))
 static volatile int siginfo_occurred;
 
@@ -138,7 +144,7 @@ main(int argc, char **argv)
 	 * Use a pointer for consistency, but stack-allocated storage
 	 * for ease of cleanup.
 	 */
-	bsdtar = &bsdtar_storage;
+	_bsdtar = bsdtar = &bsdtar_storage;
 	memset(bsdtar, 0, sizeof(*bsdtar));
 	bsdtar->fd = -1; /* Mark as "unused" */
 	option_o = 0;
@@ -151,35 +157,37 @@ main(int argc, char **argv)
 		sa.sa_flags = 0;
 #ifdef SIGINFO
 		if (sigaction(SIGINFO, &sa, NULL))
-			bsdtar_errc(1, errno, "sigaction(SIGINFO) failed");
+			lafe_errc(1, errno, "sigaction(SIGINFO) failed");
 #endif
 #ifdef SIGUSR1
 		/* ... and treat SIGUSR1 the same way as SIGINFO. */
 		if (sigaction(SIGUSR1, &sa, NULL))
-			bsdtar_errc(1, errno, "sigaction(SIGUSR1) failed");
+			lafe_errc(1, errno, "sigaction(SIGUSR1) failed");
 #endif
 	}
 #endif
 
-	/* Need bsdtar_progname before calling bsdtar_warnc. */
+	/* Need lafe_progname before calling lafe_warnc. */
 	if (*argv == NULL)
-		bsdtar_progname = "bsdtar";
+		lafe_progname = "bsdtar";
 	else {
 #if defined(_WIN32) && !defined(__CYGWIN__)
-		bsdtar_progname = strrchr(*argv, '\\');
+		lafe_progname = strrchr(*argv, '\\');
 #else
-		bsdtar_progname = strrchr(*argv, '/');
+		lafe_progname = strrchr(*argv, '/');
 #endif
-		if (bsdtar_progname != NULL)
-			bsdtar_progname++;
+		if (lafe_progname != NULL)
+			lafe_progname++;
 		else
-			bsdtar_progname = *argv;
+			lafe_progname = *argv;
 	}
 
 	time(&now);
 
+#if HAVE_SETLOCALE
 	if (setlocale(LC_ALL, "") == NULL)
-		bsdtar_warnc(0, "Failed to set default locale");
+		lafe_warnc(0, "Failed to set default locale");
+#endif
 #if defined(HAVE_NL_LANGINFO) && defined(HAVE_D_MD_ORDER)
 	bsdtar->day_first = (*nl_langinfo(D_MD_ORDER) == 'd');
 #endif
@@ -230,7 +238,7 @@ main(int argc, char **argv)
 		case 'b': /* SUSv2 */
 			t = atoi(bsdtar->optarg);
 			if (t <= 0 || t > 8192)
-				bsdtar_errc(1, 0,
+				lafe_errc(1, 0,
 				    "Argument to -b is out of range (1..8192)");
 			bsdtar->bytes_per_block = 512 * t;
 			break;
@@ -247,8 +255,8 @@ main(int argc, char **argv)
 			bsdtar->option_chroot = 1;
 			break;
 		case OPTION_EXCLUDE: /* GNU tar */
-			if (exclude(bsdtar, bsdtar->optarg))
-				bsdtar_errc(1, 0,
+			if (lafe_exclude(&bsdtar->matching, bsdtar->optarg))
+				lafe_errc(1, 0,
 				    "Couldn't exclude %s\n", bsdtar->optarg);
 			break;
 		case OPTION_FORMAT: /* GNU tar, others */
@@ -293,36 +301,24 @@ main(int argc, char **argv)
 			 * noone else needs this to filter entries
 			 * when transforming archives.
 			 */
-			if (include(bsdtar, bsdtar->optarg))
-				bsdtar_errc(1, 0,
+			if (lafe_include(&bsdtar->matching, bsdtar->optarg))
+				lafe_errc(1, 0,
 				    "Failed to add %s to inclusion list",
 				    bsdtar->optarg);
 			break;
 		case 'j': /* GNU tar */
-#if HAVE_LIBBZ2
 			if (bsdtar->create_compression != '\0')
-				bsdtar_errc(1, 0,
+				lafe_errc(1, 0,
 				    "Can't specify both -%c and -%c", opt,
 				    bsdtar->create_compression);
 			bsdtar->create_compression = opt;
-#else
-			bsdtar_warnc(0,
-			    "bzip2 compression not supported by this version of bsdtar");
-			usage();
-#endif
 			break;
 		case 'J': /* GNU tar 1.21 and later */
-#if HAVE_LIBLZMA
 			if (bsdtar->create_compression != '\0')
-				bsdtar_errc(1, 0,
+				lafe_errc(1, 0,
 				    "Can't specify both -%c and -%c", opt,
 				    bsdtar->create_compression);
 			bsdtar->create_compression = opt;
-#else
-			bsdtar_warnc(0,
-			    "xz compression not supported by this version of bsdtar");
-			usage();
-#endif
 			break;
 		case 'k': /* GNU tar */
 			bsdtar->extract_flags |= ARCHIVE_EXTRACT_NO_OVERWRITE;
@@ -338,17 +334,11 @@ main(int argc, char **argv)
 			bsdtar->option_warn_links = 1;
 			break;
 		case OPTION_LZMA:
-#if HAVE_LIBLZMA
 			if (bsdtar->create_compression != '\0')
-				bsdtar_errc(1, 0,
+				lafe_errc(1, 0,
 				    "Can't specify both -%c and -%c", opt,
 				    bsdtar->create_compression);
 			bsdtar->create_compression = opt;
-#else
-			bsdtar_warnc(0,
-			    "lzma compression not supported by this version of bsdtar");
-			usage();
-#endif
 			break;
 		case 'm': /* SUSv2 */
 			bsdtar->extract_flags &= ~ARCHIVE_EXTRACT_TIME;
@@ -370,7 +360,7 @@ main(int argc, char **argv)
 			{
 				struct stat st;
 				if (stat(bsdtar->optarg, &st) != 0)
-					bsdtar_errc(1, 0,
+					lafe_errc(1, 0,
 					    "Can't open file %s", bsdtar->optarg);
 				bsdtar->newer_ctime_sec = st.st_ctime;
 				bsdtar->newer_ctime_nsec =
@@ -384,7 +374,7 @@ main(int argc, char **argv)
 			{
 				struct stat st;
 				if (stat(bsdtar->optarg, &st) != 0)
-					bsdtar_errc(1, 0,
+					lafe_errc(1, 0,
 					    "Can't open file %s", bsdtar->optarg);
 				bsdtar->newer_mtime_sec = st.st_mtime;
 				bsdtar->newer_mtime_nsec =
@@ -455,7 +445,7 @@ main(int argc, char **argv)
 #if HAVE_REGEX_H
 			add_substitution(bsdtar, bsdtar->optarg);
 #else
-			bsdtar_warnc(0,
+			lafe_warnc(0,
 			    "-s is not supported by this version of bsdtar");
 			usage();
 #endif
@@ -501,8 +491,8 @@ main(int argc, char **argv)
 			bsdtar->option_interactive = 1;
 			break;
 		case 'X': /* GNU tar */
-			if (exclude_from_file(bsdtar, bsdtar->optarg))
-				bsdtar_errc(1, 0,
+			if (lafe_exclude_from_file(&bsdtar->matching, bsdtar->optarg))
+				lafe_errc(1, 0,
 				    "failed to process exclusions from file %s",
 				    bsdtar->optarg);
 			break;
@@ -510,37 +500,25 @@ main(int argc, char **argv)
 			set_mode(bsdtar, opt);
 			break;
 		case 'y': /* FreeBSD version of GNU tar */
-#if HAVE_LIBBZ2
 			if (bsdtar->create_compression != '\0')
-				bsdtar_errc(1, 0,
+				lafe_errc(1, 0,
 				    "Can't specify both -%c and -%c", opt,
 				    bsdtar->create_compression);
 			bsdtar->create_compression = opt;
-#else
-			bsdtar_warnc(0,
-			    "bzip2 compression not supported by this version of bsdtar");
-			usage();
-#endif
 			break;
 		case 'Z': /* GNU tar */
 			if (bsdtar->create_compression != '\0')
-				bsdtar_errc(1, 0,
+				lafe_errc(1, 0,
 				    "Can't specify both -%c and -%c", opt,
 				    bsdtar->create_compression);
 			bsdtar->create_compression = opt;
 			break;
 		case 'z': /* GNU tar, star, many others */
-#if HAVE_LIBZ
 			if (bsdtar->create_compression != '\0')
-				bsdtar_errc(1, 0,
+				lafe_errc(1, 0,
 				    "Can't specify both -%c and -%c", opt,
 				    bsdtar->create_compression);
 			bsdtar->create_compression = opt;
-#else
-			bsdtar_warnc(0,
-			    "gzip compression not supported by this version of bsdtar");
-			usage();
-#endif
 			break;
 		case OPTION_USE_COMPRESS_PROGRAM:
 			bsdtar->compress_program = bsdtar->optarg;
@@ -562,7 +540,7 @@ main(int argc, char **argv)
 
 	/* Otherwise, a mode is required. */
 	if (bsdtar->mode == '\0')
-		bsdtar_errc(1, 0,
+		lafe_errc(1, 0,
 		    "Must specify one of -c, -r, -t, -u, -x");
 
 	/* Check boolean options only permitted in certain modes. */
@@ -636,13 +614,13 @@ main(int argc, char **argv)
 		break;
 	}
 
-	cleanup_exclusions(bsdtar);
+	lafe_cleanup_exclusions(&bsdtar->matching);
 #if HAVE_REGEX_H
 	cleanup_substitution(bsdtar);
 #endif
 
 	if (bsdtar->return_value != 0)
-		bsdtar_warnc(0,
+		lafe_warnc(0,
 		    "Error exit delayed from previous errors.");
 	return (bsdtar->return_value);
 }
@@ -651,7 +629,7 @@ static void
 set_mode(struct bsdtar *bsdtar, char opt)
 {
 	if (bsdtar->mode != '\0' && bsdtar->mode != opt)
-		bsdtar_errc(1, 0,
+		lafe_errc(1, 0,
 		    "Can't specify both -%c and -%c", opt, bsdtar->mode);
 	bsdtar->mode = opt;
 }
@@ -663,7 +641,7 @@ static void
 only_mode(struct bsdtar *bsdtar, const char *opt, const char *valid_modes)
 {
 	if (strchr(valid_modes, bsdtar->mode) == NULL)
-		bsdtar_errc(1, 0,
+		lafe_errc(1, 0,
 		    "Option %s is not permitted in mode -%c",
 		    opt, bsdtar->mode);
 }
@@ -674,7 +652,7 @@ usage(void)
 {
 	const char	*p;
 
-	p = bsdtar_progname;
+	p = lafe_progname;
 

*** DIFF OUTPUT TRUNCATED AT 1000 LINES ***


More information about the svn-src-stable-8 mailing list