libarchive import
. clean and nbsd_ports managed import . also makes it shared
This commit is contained in:
parent
76092ddf33
commit
543adbed3a
367 changed files with 58691 additions and 1619 deletions
1
Makefile
1
Makefile
|
@ -52,6 +52,7 @@ includes: .PHONY .MAKE
|
|||
${MAKEDIRTARGET} include includes
|
||||
${MAKEDIRTARGET} lib includes
|
||||
${MAKEDIRTARGET} sys includes
|
||||
${MAKEDIRTARGET} external includes
|
||||
|
||||
.for dir in lib lib/csu lib/libc
|
||||
do-${dir:S/\//-/g}: .PHONY .MAKE
|
||||
|
|
|
@ -7,4 +7,4 @@ INCS+= elf64.h elf_common.h elf_generic.h \
|
|||
ioc_memory.h ioc_sound.h ioc_tty.h \
|
||||
kbdio.h mtio.h svrctl.h video.h vm.h procfs.h elf_core.h exec_elf.h \
|
||||
disk.h dkio.h ioccom.h mutex.h iostat.h disklabel.h disklabel_gpt.h \
|
||||
bootblock.h dkbad.h
|
||||
bootblock.h dkbad.h extattr.h
|
||||
|
|
5
external/bsd/libarchive/Makefile
vendored
Normal file
5
external/bsd/libarchive/Makefile
vendored
Normal file
|
@ -0,0 +1,5 @@
|
|||
# $NetBSD: Makefile,v 1.1 2008/09/19 22:01:25 joerg Exp $
|
||||
|
||||
SUBDIR= lib .WAIT bin
|
||||
|
||||
.include <bsd.subdir.mk>
|
15
external/bsd/libarchive/Makefile.inc
vendored
Normal file
15
external/bsd/libarchive/Makefile.inc
vendored
Normal file
|
@ -0,0 +1,15 @@
|
|||
# $NetBSD: Makefile.inc,v 1.2 2010/02/20 02:55:53 joerg Exp $
|
||||
|
||||
.include <bsd.own.mk>
|
||||
|
||||
USE_FORT?= yes # complex string handling
|
||||
|
||||
LIBARCHIVEDIR= ${NETBSDSRCDIR}/external/bsd/libarchive/dist
|
||||
|
||||
CPPFLAGS+= -I${NETBSDSRCDIR}/external/bsd/libarchive/include
|
||||
CPPFLAGS+= -DPLATFORM_CONFIG_H=\"config_netbsd.h\"
|
||||
|
||||
LIBARCHIVE_FE_DIR!= cd ${.PARSEDIR}/lib/libarchive_fe && ${PRINTOBJDIR}
|
||||
LIBARCHIVE_FE= ${LIBARCHIVE_FE_DIR}/libarchive_fe.a
|
||||
|
||||
WARNS?= 4
|
11
external/bsd/libarchive/bin/Makefile
vendored
Normal file
11
external/bsd/libarchive/bin/Makefile
vendored
Normal file
|
@ -0,0 +1,11 @@
|
|||
# $NetBSD: Makefile,v 1.2 2010/04/23 19:41:03 joerg Exp $
|
||||
|
||||
.include <bsd.own.mk>
|
||||
|
||||
SUBDIR=
|
||||
|
||||
.if ${MKBSDTAR} == "yes"
|
||||
SUBDIR+= cpio tar
|
||||
.endif
|
||||
|
||||
.include <bsd.subdir.mk>
|
13
external/bsd/libarchive/bin/Makefile.inc
vendored
Normal file
13
external/bsd/libarchive/bin/Makefile.inc
vendored
Normal file
|
@ -0,0 +1,13 @@
|
|||
# $NetBSD: Makefile.inc,v 1.3 2010/11/02 19:14:53 joerg Exp $
|
||||
|
||||
.include "../Makefile.inc"
|
||||
|
||||
BINDIR= /bin
|
||||
|
||||
.if (${MKDYNAMICROOT} == "no")
|
||||
LDSTATIC?= -static
|
||||
.endif
|
||||
|
||||
DPADD= ${LIBARCHIVE_FE} ${LIBARCHIVE} ${LIBBZ2} ${LIBLZMA} ${LIBZ}
|
||||
LDADD= -L${LIBARCHIVE_FE_DIR} -larchive_fe -larchive -lbz2 -llzma -lz
|
||||
CPPFLAGS+= -I${LIBARCHIVEDIR}/libarchive_fe
|
19
external/bsd/libarchive/bin/cpio/Makefile
vendored
Normal file
19
external/bsd/libarchive/bin/cpio/Makefile
vendored
Normal file
|
@ -0,0 +1,19 @@
|
|||
# $NetBSD: Makefile,v 1.6 2011/09/19 01:45:15 christos Exp $
|
||||
|
||||
PROG= cpio
|
||||
SRCS= cmdline.c cpio.c
|
||||
|
||||
.include <bsd.init.mk>
|
||||
|
||||
.PATH: ${LIBARCHIVEDIR}/cpio
|
||||
|
||||
CLEANFILES+= cpio.1
|
||||
|
||||
cpio.1: ${LIBARCHIVEDIR}/cpio/bsdcpio.1
|
||||
${TOOL_CAT} ${LIBARCHIVEDIR}/cpio/bsdcpio.1 > $@
|
||||
|
||||
SYMLINKS+=${BINDIR}/cpio /usr/bin/cpio
|
||||
|
||||
COPTS.cpio.c += -Wno-format-nonliteral
|
||||
|
||||
.include <bsd.prog.mk>
|
19
external/bsd/libarchive/bin/tar/Makefile
vendored
Normal file
19
external/bsd/libarchive/bin/tar/Makefile
vendored
Normal file
|
@ -0,0 +1,19 @@
|
|||
# $NetBSD: Makefile,v 1.4 2011/09/09 12:43:14 christos Exp $
|
||||
|
||||
PROG= tar
|
||||
SRCS= bsdtar.c cmdline.c getdate.c read.c subst.c tree.c util.c write.c
|
||||
|
||||
.include <bsd.init.mk>
|
||||
|
||||
.PATH: ${LIBARCHIVEDIR}/tar
|
||||
|
||||
CLEANFILES+= tar.1
|
||||
|
||||
tar.1: ${LIBARCHIVEDIR}/tar/bsdtar.1
|
||||
${TOOL_CAT} ${LIBARCHIVEDIR}/tar/bsdtar.1 > $@
|
||||
|
||||
SYMLINKS+=${BINDIR}/tar /usr/bin/tar
|
||||
|
||||
COPTS.read.c += -Wno-format-nonliteral
|
||||
|
||||
.include <bsd.prog.mk>
|
60
external/bsd/libarchive/dist/COPYING
vendored
Normal file
60
external/bsd/libarchive/dist/COPYING
vendored
Normal file
|
@ -0,0 +1,60 @@
|
|||
The libarchive distribution as a whole is Copyright by Tim Kientzle
|
||||
and is subject to the copyright notice reproduced at the bottom of
|
||||
this file.
|
||||
|
||||
Each individual file in this distribution should have a clear
|
||||
copyright/licensing statement at the beginning of the file. If any do
|
||||
not, please let me know and I will rectify it. The following is
|
||||
intended to summarize the copyright status of the individual files;
|
||||
the actual statements in the files are controlling.
|
||||
|
||||
* Except as listed below, all C sources (including .c and .h files)
|
||||
and documentation files are subject to the copyright notice reproduced
|
||||
at the bottom of this file.
|
||||
|
||||
* The following source files are also subject in whole or in part to
|
||||
a 3-clause UC Regents copyright; please read the individual source
|
||||
files for details:
|
||||
libarchive/archive_entry.c
|
||||
libarchive/archive_read_support_compression_compress.c
|
||||
libarchive/archive_write_set_compression_compress.c
|
||||
libarchive/mtree.5
|
||||
tar/matching.c
|
||||
|
||||
* The following source files are in the public domain:
|
||||
tar/getdate.c
|
||||
|
||||
* The build files---including Makefiles, configure scripts,
|
||||
and auxiliary scripts used as part of the compile process---have
|
||||
widely varying licensing terms. Please check individual files before
|
||||
distributing them to see if those restrictions apply to you.
|
||||
|
||||
I intend for all new source code to use the license below and hope over
|
||||
time to replace code with other licenses with new implementations that
|
||||
do use the license below. The varying licensing of the build scripts
|
||||
seems to be an unavoidable mess.
|
||||
|
||||
|
||||
Copyright (c) 2003-2009 <author(s)>
|
||||
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
|
||||
in this position and unchanged.
|
||||
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(S) ``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(S) 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.
|
545
external/bsd/libarchive/dist/NEWS
vendored
Normal file
545
external/bsd/libarchive/dist/NEWS
vendored
Normal file
|
@ -0,0 +1,545 @@
|
|||
Jun 30, 2010: libarchive 2.8.4 released
|
||||
Jun 30, 2010: Improved reliability of hash function detection
|
||||
Jun 30, 2010: Fix issues on ancient FreeBSD, QNX, ancient NetBSD and Minux
|
||||
|
||||
Mar 14, 2010: libarchive 2.8.3 released
|
||||
Mar 14, 2010: Symlink dereference fix for Linux broke the build there; corrected.
|
||||
|
||||
Mar 14, 2010: libarchive 2.8.2 released
|
||||
Mar 12, 2010: Fix NULL deference for short self-extracting zip archives.
|
||||
Mar 12, 2010: Don't dereference symlinks on Linux when reading ACLs.
|
||||
Mar 07, 2010: Better detection of SHA2 support for old OpenSSL versions.
|
||||
Mar 07, 2010: Fix parsing of input files for bsdtar -T.
|
||||
Mar 07, 2010: Do not leak setup_xattr into the global namespace.
|
||||
|
||||
Mar 06, 2010: libarchive 2.8.1 released
|
||||
Mar 06, 2010: Fix build when an older libarchive is already installed
|
||||
Mar 03, 2010: Use O_BINARY opening files in bsdtar
|
||||
Mar 02, 2010: Include missing archive_crc32.h
|
||||
Mar 01, 2010: Correctly include iconv.h required by libxml2.
|
||||
|
||||
Feb 04, 2010: libarchive 2.8.0 released
|
||||
Jan 17, 2010: Fix error handling for 'echo nonexistent | cpio -o'
|
||||
Jan 17, 2010: Don't use futimes() on Cygwin
|
||||
|
||||
Jan 02, 2010: libarchive 2.7.902a released (test release for 2.8)
|
||||
Jan 02, 2010: Fix tar/test/test_windows on MinGW
|
||||
Jan 02, 2010: Fix memory leaks in libarchive tests
|
||||
Jan 01, 2010: Fix memory leak when filter startup fails
|
||||
|
||||
Dec 27, 2009: libarchive 2.7.901a released (test release for 2.8)
|
||||
|
||||
Aug 04, 2009: libarchive 2.7.1 released
|
||||
Jul 20, 2009: Suppress bogus warning about unxz
|
||||
Jul 19, 2009: Support Cygwin 1.7
|
||||
Jun 11, 2009: Support lzma/xz files compressed with larger buffer sizes.
|
||||
May 24, 2009: Handle gzip files signed with OpenBSD "gzsig" program.
|
||||
May 07, 2009: Avoid false failures when reading from pipe.
|
||||
|
||||
Apr 16, 2009: libarchive 2.7.0 released
|
||||
|
||||
Apr 10, 2009: libarchive 2.6.992a released
|
||||
Apr 09, 2009: Fix SIGPIPE issue building with MSVC.
|
||||
Apr 09, 2009: Fix several minor memory leaks in libarchive and libarchive_test
|
||||
|
||||
Apr 08, 2009: libarchive 2.6.991a released
|
||||
Apr 07, 2009: Additional tests added to bsdcpio_test
|
||||
|
||||
Apr 01, 2009: libarchive 2.6.990a released
|
||||
Apr 01, 2009: Use command-line gunzip, bunzip2, unxz, unlzma for
|
||||
decompression if the library is built without suitable
|
||||
libraries. The setup functions return ARCHIVE_WARN
|
||||
in this case so clients can adapt if necessary.
|
||||
Apr 01, 2009: Use getpw*_r and getgr*_r functions for thread-safety.
|
||||
Mar 24, 2009: Add archive_read_next_header2(), which is up to 25%
|
||||
more efficient for some clients; from Brian Harring.
|
||||
Mar 22, 2009: PDF versions of manpages are now included in the distribution.
|
||||
Mar, 2009: Major work to improve Cygwin build by Charles Wilson.
|
||||
Feb/Mar, 2009: Major work on cmake build support, mostly by Michihiro NAKAJIMA.
|
||||
Feb/Mar, 2009: Major work on Visual Studio support by Michihiro NAKAJIMA.
|
||||
All tests now pass.
|
||||
Feb 25, 2009: Fix Debian Bug #516577
|
||||
Feb 21, 2009: Yacc is no longer needed to build; date parser rewritten in C.
|
||||
Jan/Feb, 2009: Mtree work by Michihiro.
|
||||
Feb, 2009: Joliet support by Andreas Henriksson.
|
||||
Jan/Feb, 2009: New options framework by Michihiro.
|
||||
Feb, 2009: High-res timestamps on Tru64, AIX, and GNU Hurd, by Björn Jacke.
|
||||
Jan 18, 2009: Extended attributes work on FreeBSD and Linux now with pax format.
|
||||
Jan 07, 2009: New archive_read_disk_entry_from_file() knows about ACLs,
|
||||
extended attributes, etc so that bsdtar and bsdcpio don't require
|
||||
such system-specific knowledge.
|
||||
Jan 03, 2009: Read filter system extensively refactored. In particular,
|
||||
read filter pipelines are now built out automatically and individual
|
||||
filters should be much easier to implement. Documentation on the
|
||||
Googlecode Wiki explains how to implement new filters.
|
||||
Dec 28, 2008: Many Windows/Visual Studio fixes from Michihiro NAKAJIMA.
|
||||
|
||||
Dec 28, 2008: Main libarchive development moved from FreeBSD Perforce
|
||||
server to Google Code. This should make it easier for more
|
||||
people to participate in libarchive development.
|
||||
|
||||
Dec 28, 2008: libarchive 2.6.0 released
|
||||
Dec 25, 2008: libarchive 2.5.905a released
|
||||
Dec 10, 2008: libarchive 2.5.904a released
|
||||
Dec 04, 2008: libarchive 2.5.903a released
|
||||
Nov 09, 2008: libarchive 2.5.902a released
|
||||
Nov 08, 2008: libarchive 2.5.901a released
|
||||
Nov 08, 2008: Start of pre-release testing for libarchive 2.6
|
||||
|
||||
Nov 07, 2008: Read filter refactor: The decompression routines just
|
||||
consume and produce arbitrarily-sized blocks. The reblocking
|
||||
from read_support_compression_none() has been pulled into the
|
||||
read core. Also, the decompression bid now makes multiple
|
||||
passes and stacks read filters.
|
||||
Oct 21, 2008: bsdcpio: New command-line parser.
|
||||
Oct 19, 2008: Internal read_ahead change: short reads are now an error
|
||||
Oct 06, 2008: bsdtar: option parser no longer uses getopt_long(),
|
||||
gives consistent option parsing on all platforms.
|
||||
Sep 19, 2008: Jaakko Heinonen: shar utility built on libarchive
|
||||
Sep 17, 2008: Pedro Giffuni: birthtime support
|
||||
Sep 17, 2008: Miklos Vajna: lzma reader and test. Note: I still have
|
||||
some concerns about the auto-detection (LZMA file format
|
||||
doesn't support auto-detection well), so this is not yet
|
||||
enabled under archive_read_support_compression_all(). For
|
||||
now, you must call archive_read_support_compression_lzma() if
|
||||
you want LZMA read support.
|
||||
Sep 11, 2008: Ivailo Petrov: Many fixes to Windows build, new solution files
|
||||
Jul 26, 2008: archive_entry now tracks which values have not been set.
|
||||
This helps zip extraction (file size is often "unknown") and
|
||||
time restores (tar usually doesn't know atime).
|
||||
Jul 26, 2008: Joerg Sonnenberger: Performance improvements to shar writer
|
||||
Jul 25, 2008: Joerg Sonnenberger: mtree write support
|
||||
|
||||
Jul 02, 2008: libarchive 2.5.5 released
|
||||
|
||||
Jul 02, 2008: libarchive 2.5.5b released
|
||||
Jul 01, 2008: bsdcpio is being used by enough people, we can call it 1.0.0 now
|
||||
Jun 20, 2008: bsdcpio: If a -l link fails with EXDEV, copy the file instead
|
||||
Jun 19, 2008: bsdcpio: additional long options for better GNU cpio compat
|
||||
Jun 15, 2008: Many small portability and bugfixes since 2.5.4b.
|
||||
|
||||
May 25, 2008: libarchive 2.5.4b released
|
||||
May 21, 2008: Joerg Sonnenberger: fix bsdtar hardlink handling for newc format
|
||||
|
||||
May 21, 2008: More progress on Windows building. Thanks to "Scott"
|
||||
for the Windows makefiles, thanks to Kees Zeelenberg for
|
||||
code contributions.
|
||||
|
||||
May 21, 2008: Fix a number of non-exploitable integer and buffer overflows,
|
||||
thanks to David Remahl at Apple for pointing these out.
|
||||
|
||||
May 21, 2008: Colin Percival: SIGINFO or SIGUSR1 to bsdtar prints progress info
|
||||
|
||||
May 16, 2008: bsdtar's test harness no longer depends on file ordering.
|
||||
This was causing spurious test failures on a lot of systems.
|
||||
Thanks to Bernhard R. Link for the diagnosis.
|
||||
|
||||
May 14, 2008: Joerg Sonnenberger: -s substitution support for bsdtar
|
||||
|
||||
May 13, 2008: Joerg Sonnenberger: Many mtree improvements
|
||||
|
||||
May 11, 2008: Joerg Sonnenberger: fix hardlink extraction when
|
||||
hardlinks have different permissions from original file
|
||||
|
||||
April 30, 2008: Primary libarchive work has been moved into the FreeBSD
|
||||
project's Perforce repository: http://perforce.freebsd.org/
|
||||
The libarchive project can be browsed at
|
||||
//depot/user/kientzle/libarchive-portable
|
||||
Direct link: http://preview.tinyurl.com/46mdgr
|
||||
|
||||
May 04, 2008: libarchive 2.5.3b released
|
||||
* libarchive: Several fixes to link resolver to address bsdcpio crashes
|
||||
* bsdcpio: -p hardlink handling fixes
|
||||
* tar/pax: Ensure ustar dirnames end in '/'; be more careful about
|
||||
measuring filenames when deciding what pathname fields to use
|
||||
* libarchive: Mark which entry strings are set; be accurate about
|
||||
distinguishing empty strings ("") from unset ones (NULL)
|
||||
* tar: Don't crash reading entries with empty filenames
|
||||
* libarchive_test, bsdtar_test, bsdcpio_test: Better detaults:
|
||||
run all tests, delete temp dirs, summarize repeated failures
|
||||
* -no-undefined to libtool for Cygwin
|
||||
* libarchive_test: Skip large file tests on systems with 32-bit off_t
|
||||
* iso9660: Don't bother trying to find the body of an empty file;
|
||||
this works around strange behavior from some ISO9660 writers
|
||||
* tar: allow -r -T to be used together
|
||||
* tar: allow --format with -r or -u
|
||||
* libarchive: Don't build archive.h
|
||||
|
||||
May 04, 2008: Simplified building: archive.h is no longer constructed
|
||||
This may require additional #if conditionals on some platforms.
|
||||
|
||||
Mar 30, 2008: libarchive 2.5.1b released
|
||||
|
||||
Mar 15, 2008: libarchive 2.5.0b released
|
||||
Mar 15, 2008: bsdcpio now seems to correctly write hardlinks into newc,
|
||||
ustar, and old cpio archives. Just a little more testing before
|
||||
bsdcpio 1.0 becomes a reality.
|
||||
Mar 15, 2008: I think the new linkify() interface is finally handling
|
||||
all known hardlink strategies.
|
||||
Mar 15, 2008: Mtree read fixes from Joerg Sonnenberger.
|
||||
Mar 15, 2008: Many new bsdtar and bsdcpio options from Joerg Sonnenberger.
|
||||
Mar 15, 2008: test harnesses no longer require uudecode; they
|
||||
now have built-in decoding logic that decodes the reference
|
||||
files as they are needed.
|
||||
|
||||
Mar 14, 2008: libarchive 2.4.14 released; identical to 2.4.13 except for
|
||||
a point fix for gname/uname mixup in pax format that was introduced
|
||||
with the UTF-8 fixes.
|
||||
|
||||
Feb 26, 2008: libarchive 2.4.13 released
|
||||
Feb 25, 2008: Handle path, linkname, gname, or uname that can't be converted
|
||||
to/from UTF-8. Implement "hdrcharset" attribute from SUS-2008.
|
||||
Feb 25, 2008: Fix name clash on NetBSD.
|
||||
Feb 18, 2008: Fix writing empty 'ar' archives, per Kai Wang
|
||||
Feb 18, 2008: [bsdtar] Permit appending on block devices.
|
||||
Feb 09, 2008: New "linkify" resolver to help with newc hardlink writing;
|
||||
bsdcpio still needs to be converted to use this.
|
||||
Feb 02, 2008: Windows compatibility fixes from Ivailo Petrov, Kees Zeelenberg
|
||||
Jan 30, 2008: Ignore hardlink size for non-POSIX tar archives.
|
||||
|
||||
Jan 22, 2008: libarchive 2.4.12 released
|
||||
Jan 22, 2008: Fix bad padding when writing symlinks to newc cpio archives.
|
||||
Jan 22, 2008: Verify bsdcpio_test by getting it to work against GNU cpio 2.9.
|
||||
bsdcpio_test complains about missing options (-y and -z), format
|
||||
of informational messages (--version, --help), and a minor formatting
|
||||
issue in odc format output. After this update, bsdcpio_test uncovered
|
||||
several more cosmetic issues in bsdcpio, all now fixed.
|
||||
Jan 22, 2008: Experimental support for self-extracting Zip archives.
|
||||
Jan 22, 2008: Extend hardlink restore strategy to work correctly with
|
||||
hardlinks extracted from newc cpio files. (Which store the body
|
||||
only with the last occurrence of a link.)
|
||||
|
||||
Dec 30, 2007: libarchive 2.4.11 released
|
||||
Dec 30, 2007: Fixed a compile error in bsdcpio on some systems.
|
||||
|
||||
Dec 29, 2007: libarchive 2.4.10 released
|
||||
Dec 29, 2007: bsdcpio 0.9.0 is ready for wider use.
|
||||
Dec 29, 2007: Completed initial test harness for bsdcpio.
|
||||
|
||||
Dec 22, 2007: libarchive 2.4.9 released
|
||||
Dec 22, 2007: Implement the remaining options for bsdcpio: -a, -q, -L, -f,
|
||||
pattern selection for -i and -it.
|
||||
|
||||
Dec 13, 2007: libarchive 2.4.8 released
|
||||
Dec 13, 2007: gzip and bzip2 compression now handle zero-byte writes correctly,
|
||||
Thanks to Damien Golding for bringing this to my attention.
|
||||
|
||||
Dec 12, 2007: libarchive 2.4.7 released
|
||||
|
||||
Dec 10, 2007: libarchive 2.4.6 released
|
||||
Dec 09, 2007: tar/test/test_copy.c verifies "tar -c | tar -x" copy pipeline
|
||||
Dec 07, 2007: Fix a couple of minor memory leaks.
|
||||
|
||||
Dec 04, 2007: libarchive 2.4.5 released
|
||||
Dec 04, 2007: Fix cpio/test/test_write_odc by setting the umask first.
|
||||
|
||||
Dec 03, 2007: libarchive 2.4.4 released
|
||||
Dec 03, 2007: New configure options --disable-xattr and --disable-acl,
|
||||
thanks to Samuli Suominen.
|
||||
|
||||
Dec 03, 2007: libarchive 2.4.3 released
|
||||
Dec 03, 2007: Thanks to Lapo Luchini for sending me a ZIP file that
|
||||
libarchive couldn't handle. Fixed a bug in handling of
|
||||
"length at end" flags in ZIP files.
|
||||
Dec 03, 2007: Fixed bsdcpio -help, bsdtar -help tests.
|
||||
Dec 02, 2007: First cut at real bsdtar test harness.
|
||||
|
||||
Dec 02, 2007: libarchive 2.4.2 released
|
||||
|
||||
Dec 02, 2007: libarchive 2.4.1 released
|
||||
Dec 02, 2007: Minor fixes, rough cut of mdoc-to-man conversion for
|
||||
man pages.
|
||||
|
||||
Oct 30, 2007: libarchive 2.4.0 released
|
||||
Oct 30, 2007: Minor compile fix thanks to Joerg Schilling.
|
||||
Oct 30, 2007: Only run the format auction once at the beginning of the
|
||||
archive. This is simpler and supports better error recovery.
|
||||
Oct 29, 2007: Test support for very large entries in tar archives:
|
||||
libarchive_test now exercises entries from 2GB up to 1TB.
|
||||
|
||||
Oct 27, 2007: libarchive 2.3.5 released
|
||||
Oct 27, 2007: Correct some unnecessary internal data copying in the
|
||||
"compression none" reader and writer; this reduces user time
|
||||
by up to 2/3 in some tests. (Thanks to Jan Psota for
|
||||
publishing his performance test results to GNU tar's bug-tar
|
||||
mailing list; those results pointed me towards this problem.)
|
||||
Oct 27, 2007: Fix for skipping archive entries that are exactly
|
||||
a multiple of 4G on 32-bit platforms.
|
||||
Oct 25, 2007: Fix for reading very large (>8G) tar archives; this was
|
||||
broken when I put in support for new GNU tar sparse formats.
|
||||
Oct 20, 2007: Initial work on new pattern-matching code for cpio; I
|
||||
hope this eventually replaces the code currently in bsdtar.
|
||||
|
||||
Oct 08, 2007: libarchive 2.3.4 released
|
||||
Oct 05, 2007: Continuing work on bsdcpio test suite.
|
||||
Oct 05, 2007: New cpio.5 manpage, updates to "History" of bsdcpio.1 and
|
||||
bsdtar.1 manpages.
|
||||
Oct 05, 2007: Fix zip reader to immediately return EOF if you try
|
||||
to read body of non-regular file. In particular, this fixes
|
||||
bsdtar extraction of zip archives.
|
||||
|
||||
Sep 30, 2007: libarchive 2.3.3 released
|
||||
Sep 26, 2007: Rework Makefile.am so that the enable/disable options
|
||||
actually do the right things.
|
||||
Sep 26, 2007: cpio-odc and cpio-newc archives no longer write bodies
|
||||
for non-regular files.
|
||||
Sep 26, 2007: Test harness for bsdcpio is in place, needs more tests written.
|
||||
This is much nicer than the ragtag collection of test scripts
|
||||
that bsdtar has.
|
||||
|
||||
Sep 20, 2007: libarchive 2.3.2 released
|
||||
Sep 20, 2007: libarchive 2.3.1 broke bsdtar because the archive_write_data()
|
||||
fix was implemented incorrectly.
|
||||
|
||||
Sep 16, 2007: libarchive 2.3.1 released
|
||||
Sep 16, 2007: Many fixes to bsdcpio 0.3: handle hardlinks with -p, recognize
|
||||
block size on writing, fix a couple of segfaults.
|
||||
Sep 16, 2007: Fixed return value from archive_write_data() when used
|
||||
with archive_write_disk() to match the documentation and other
|
||||
instances of this same function.
|
||||
Sep 15, 2007: Add archive_entry_link_resolver, archive_entry_strmode
|
||||
|
||||
Sep 11, 2007: libarchive 2.2.8 released
|
||||
Sep 09, 2007: bsdcpio 0.2 supports most (not yet all) of the old POSIX spec.
|
||||
|
||||
Sep 01, 2007: libarchive 2.2.7 released
|
||||
Aug 31, 2007: Support for reading mtree files, including an mtree.5 manpage
|
||||
(A little experimental still.)
|
||||
Aug 18, 2007: Read gtar 1.17 --posix --sparse entries.
|
||||
Aug 13, 2007: Refined suid/sgid restore handling; it is no longer
|
||||
an error if suid/sgid bits are dropped when you request
|
||||
perm restore but don't request owner restore.
|
||||
Aug 06, 2007: Use --enable-bsdcpio if you want to try bsdcpio
|
||||
|
||||
Aug 05, 2007: libarchive 2.2.6 released
|
||||
Aug 05, 2007: New configure option --disable-bsdtar, thanks to Joerg
|
||||
Sonnenberger.
|
||||
Aug 05, 2007: Several bug fixes from FreeBSD CVS repo.
|
||||
|
||||
Jul 13, 2007: libarchive 2.2.5 released
|
||||
|
||||
Jul 12, 2007: libarchive 2.2.4 released
|
||||
Jul 12, 2007: Thanks to Colin Percival's help in diagnosing and
|
||||
fixing several critical security bugs. Details available at
|
||||
http://security.freebsd.org/advisories/FreeBSD-SA-07:05.libarchive.asc
|
||||
|
||||
May 26, 2007: libarchive 2.2.3 released
|
||||
May 26, 2007: Fix memory leaks in ZIP reader and shar writer, add some
|
||||
missing system headers to archive_entry.h, dead code cleanup
|
||||
from Colin Percival, more tests for gzip/bzip2, fix an
|
||||
EOF anomaly in bzip2 decompression.
|
||||
|
||||
May 12, 2007: libarchive 2.2.2 released
|
||||
May 12, 2007: Fix archive_write_disk permission restore by cloning
|
||||
entry passed into write_header so that permission info is
|
||||
still available at finish_entry time. (archive_read_extract()
|
||||
worked okay because it held onto the passed-in entry, but
|
||||
direct consumers of archive_write_disk would break). This
|
||||
required fixing archive_entry_clone(), which now works and has
|
||||
a reasonably complete test case.
|
||||
May 10, 2007: Skeletal cpio implementation.
|
||||
|
||||
May 06, 2007: libarchive 2.2.1 released
|
||||
May 06, 2007: Flesh out a lot more of test_entry.c so as to catch
|
||||
problems such as the device node breakage before releasing <sigh>.
|
||||
May 05, 2007: Fix a bad bug introduced in 2.1.9 that broke device
|
||||
node entries in tar archives.
|
||||
May 03, 2007: Move 'struct stat' out of archive_entry core as well.
|
||||
This removes some portability headaches and fixes a bunch
|
||||
of corner cases that arise when manipulating archives on
|
||||
dissimilar systems.
|
||||
|
||||
Apr 30, 2007: libarchive 2.1.10 released
|
||||
Apr 31, 2007: Minor code cleanup.
|
||||
|
||||
Apr 24, 2007: libarchive 2.1.9 released
|
||||
Apr 24, 2007: Fix some recently-introduced problems with libraries
|
||||
(Just let automake handle it and it all works much better.)
|
||||
Finish isolating major()/minor()/makedev() in archive_entry.c.
|
||||
|
||||
Apr 23, 2007: libarchive 2.1.8 released
|
||||
Apr 23, 2007: Minor fixes found from building on MacOS X
|
||||
|
||||
Apr 22, 2007: libarchive 2.1.7 released
|
||||
Apr 22, 2007: Eliminated all uses of 'struct stat' from the
|
||||
format readers/writers. This should improve portability;
|
||||
'struct stat' is now only used in archive_entry and in
|
||||
code that actually touches the disk.
|
||||
|
||||
Apr 17, 2007: libarchive 2.1.6 released
|
||||
Libarchive now compiles and passes all tests on Interix.
|
||||
|
||||
Apr 16, 2007: libarchive 2.1.5 released
|
||||
|
||||
Apr 15, 2007: libarchive 2.1b2 released
|
||||
Apr 15, 2007: New libarchive_internals.3 documentation of internal APIs.
|
||||
Not complete, but should prove helpful.
|
||||
Apr 15, 2007: Experimental "read_compress_program" and "write_compress_program"
|
||||
for using libarchive with external compression. Not yet
|
||||
well tested, and likely has portability issues. Feedback
|
||||
appreciated.
|
||||
|
||||
Apr 14, 2007: libarchive 2.0.31 released
|
||||
Apr 14, 2007: More fixes for Interix, more 'ar' work
|
||||
|
||||
Apr 14, 2007: libarchive 2.0.30 released
|
||||
Apr 13, 2007: libarchive now enforces trailing '/' on dirs
|
||||
written to tar archives
|
||||
|
||||
Apr 11, 2007: libarchive 2.0.29 released
|
||||
Apr 11, 2007: Make it easier to statically configure for different platforms.
|
||||
Apr 11, 2007: Updated config.guess, config.sub, libtool
|
||||
|
||||
Apr 06, 2007: libarchive 2.0.28 released
|
||||
Apr 06, 2007: 'ar' format read/write support thanks to Kai Wang.
|
||||
|
||||
Apr 01, 2007: libarchive 2.0.27 released
|
||||
Mar 31, 2007: Several minor fixes from Colin Percival and Joerg Sonnenberger.
|
||||
|
||||
Mar 12, 2007: libarchive 2.0.25 released
|
||||
Mar 12, 2007: Fix broken --unlink flag.
|
||||
|
||||
Mar 11, 2007: libarchive 2.0.24 released
|
||||
Mar 10, 2007: Correct an ACL blunder that causes any ACL with an entry
|
||||
that refers to a non-existent user or group to not be restored correctly.
|
||||
The fix both makes the parser more tolerant (so that archives created
|
||||
with the buggy ACLs can be read now) and corrects the ACL formatter.
|
||||
Mar 10, 2007: More work on test portability to Linux.
|
||||
|
||||
Mar 10, 2007: libarchive 2.0.22 released
|
||||
Mar 10, 2007: Header cleanups; added linux/fs.h, removed
|
||||
some unnecessary headers, added #include guards in bsdtar.
|
||||
If you see any obvious compile failures from this, let me know.
|
||||
Mar 10, 2007: Work on bsdtar test scripts: not yet robust enough
|
||||
to enable as part of "make check", but getting better.
|
||||
Mar 10, 2007: libarchive now returns ARCHIVE_FAILED when
|
||||
a header write fails in a way that only affects this item.
|
||||
Less bad than ARCHIVE_FATAL, but worse than ARCHIVE_WARN.
|
||||
|
||||
Mar 07, 2007: libarchive 2.0.21 released
|
||||
Mar 07, 2007: Add some ACL tests (only for the system-independent
|
||||
portion of the ACL support for now).
|
||||
Mar 07, 2007: tar's ability to read ACLs off disk got
|
||||
turned off for FreeBSD; re-enable it. (ACL restores and
|
||||
libarchive support for storing/reading ACLs from pax
|
||||
archives was unaffected.)
|
||||
|
||||
Mar 02, 2007: libarchive 2.0.20 released
|
||||
Mar 2, 2007: It's not perfect, but it's pretty good.
|
||||
Libarchive 2.0 is officially out of beta.
|
||||
|
||||
Feb 28, 2007: libarchive 2.0b17 released
|
||||
Feb 27, 2007: Make the GID restore checks more robust by checking
|
||||
whether the current user has too few or too many privileges.
|
||||
|
||||
Feb 26, 2007: libarchive 2.0b15 released
|
||||
Feb 26, 2007: Don't lose symlinks when extracting from ISOs.
|
||||
Thanks to Diego "Flameeyes" Pettenò for telling me about the
|
||||
broken testcase on Gentoo that (finally!) led me to the cause
|
||||
of this long-standing bug.
|
||||
|
||||
Feb 26, 2007: libarchive 2.0b14 released
|
||||
Feb 26, 2007: Fix a broken test on platforms that lack lchmod().
|
||||
|
||||
Feb 25, 2007: libarchive 2.0b13 released
|
||||
Feb 25, 2007: Empty archives were being written as empty files,
|
||||
without a proper end-of-archive marker. Fixed.
|
||||
|
||||
Feb 23, 2007: libarchive 2.0b12 released
|
||||
Feb 22, 2007: Basic security checks added: _EXTRACT_SECURE_NODOTDOT
|
||||
and _EXTRACT_SECURE_SYMLINK. These checks used to be in bsdtar,
|
||||
but they belong down in libarchive where they can be used by
|
||||
other tools and where they can be better optimized.
|
||||
|
||||
Feb 11, 2007: libarchive 2.0b11 released
|
||||
Feb 10, 2007: Fixed a bunch of errors in libarchive's handling
|
||||
of EXTRACT_PERM and EXTRACT_OWNER, especially relating
|
||||
to SUID and SGID bits.
|
||||
|
||||
Jan 31, 2007: libarchive 2.0b9 released
|
||||
Jan 31, 2007: Added read support for "empty" archives as a
|
||||
distinct archive format. Bsdtar uses this to handle, e.g.,
|
||||
"touch foo.tar; tar -rf foo.tar"
|
||||
|
||||
Jan 22, 2007: libarchive 2.0b6 released
|
||||
Jan 22, 2007: archive_write_disk API is now in place. It provides
|
||||
a finer-grained interface than archive_read_extract. In particular,
|
||||
you can use it to create objects on disk without having an archive
|
||||
around (just feed it archive_entry objects describing what you
|
||||
want to create), you can override the uname/gname-to-uid/gid lookups
|
||||
(minitar uses this to avoid getpwXXX() and getgrXXX() bloat).
|
||||
|
||||
Jan 09, 2007: libarchive 2.0a3 released
|
||||
Jan 9, 2007: archive_extract is now much better; it handles the
|
||||
most common cases with a minimal number of system calls.
|
||||
Some features still need a lot of testing, especially corner
|
||||
cases involving objects that already exist on disk. I expect
|
||||
the next round of API overhaul will simplify building test cases.
|
||||
Jan 9, 2007: a number of fixes thanks to Colin Percival, especially
|
||||
corrections to the skip() framework and handling of large files.
|
||||
Jan 9, 2007: Fixes for large ISOs. The code should correctly handle
|
||||
very large ISOs with entries up to 4G. Thanks to Robert Sciuk
|
||||
for pointing out these issues.
|
||||
|
||||
Sep 05, 2006: libarchive 1.3.1 released
|
||||
Sep 5, 2006: Bump version to 1.3 for new I/O wrappers.
|
||||
Sep 4, 2006: New memory and FILE read/write wrappers.
|
||||
Sep 4, 2006: libarchive test harness is now minimally functional;
|
||||
it's located a few minor bugs in error-handling logic
|
||||
|
||||
Aug 17, 2006: libarchive 1.2.54 released
|
||||
Aug 17, 2006: Outline ABI changes for libarchive 2.0; these
|
||||
are protected behind #ifdef's until I think I've found everything
|
||||
that needs to change.
|
||||
Aug 17, 2006: Fix error-handling in archive_read/write_close()
|
||||
They weren't returning any errors before.
|
||||
Aug 17, 2006: Fix recursive-add logic to not trigger if it's not set
|
||||
Fixes a bug adding files when writing archive to pipe or when
|
||||
using archive_write_open() directly.
|
||||
Jul 2006: New "skip" handling improves performance extracting
|
||||
single files from large uncompressed archives.
|
||||
|
||||
Mar 21, 2006: 1.2.52 released
|
||||
Mar 21, 2006: Fix -p on platforms that don't have platform-specific
|
||||
extended attribute code.
|
||||
Mar 20, 2006: Add NEWS file; fill in some older history from other
|
||||
files. I'll try to keep this file up-to-date from now on.
|
||||
|
||||
OLDER NEWS SUMMARIES
|
||||
|
||||
Mar 19, 2006: libarchive 1.2.51 released
|
||||
Mar 18, 2006: Many fixes to extended attribute support, including a redesign
|
||||
of the storage format to simplify debugging.
|
||||
Mar 12, 2006: Remove 'tp' support; it was a fun idea, but not worth
|
||||
spending much time on.
|
||||
Mar 11, 2006: Incorporated Jaakko Heinonen's still-experimental support
|
||||
for extended attributes (Currently Linux-only.).
|
||||
Mar 11, 2006: Reorganized distribution package: There is now one tar.gz
|
||||
file that builds both libarchive and bsdtar.
|
||||
Feb 13, 2006: Minor bug fixes: correctly read cpio device entries, write
|
||||
Pax attribute entry names.
|
||||
Nov 7, 2005: Experimental 'tp' format support in libarchive. Feedback
|
||||
appreciated; this is not enabled by archive_read_support_format_all()
|
||||
yet as I'm not quite content with the format detection heuristics.
|
||||
Nov 7, 2005: Some more portability improvements thanks to Darin Broady,
|
||||
minor bugfixes.
|
||||
Oct 12, 2005: Use GNU libtool to build shared libraries on many systems.
|
||||
Aug 9, 2005: Correctly detect that MacOS X does not have POSIX ACLs.
|
||||
Apr 17, 2005: Kees Zeelenberg has ported libarchive and bsdtar to Windows:
|
||||
http://gnuwin32.sourceforge.net/
|
||||
Apr 11, 2005: Extended Zip/Zip64 support thanks to Dan Nelson. -L/-h
|
||||
fix from Jaakko Heinonen.
|
||||
Mar 12, 2005: archive_read_extract can now handle very long
|
||||
pathnames (I've tested with pathnames up to 1MB).
|
||||
Mar 12, 2005: Marcus Geiger has written an article about libarchive
|
||||
http://xsnil.antbear.org/2005/02/05/archive-mit-libarchive-verarbeiten/
|
||||
including examples of using it from Objective-C. His MoinX
|
||||
http://moinx.antbear.org/ desktop Wiki uses
|
||||
libarchive for archiving and restoring Wiki pages.
|
||||
Jan 22, 2005: Preliminary ZIP extraction support,
|
||||
new directory-walking code for bsdtar.
|
||||
Jan 16, 2005: ISO9660 extraction code added; manpage corrections.
|
||||
May 22, 2004: Many gtar-compatible long options have been added; almost
|
||||
all FreeBSD ports extract correctly with bsdtar.
|
||||
May 18, 2004: bsdtar can read Solaris, HP-UX, Unixware, star, gtar,
|
||||
and pdtar archives.
|
137
external/bsd/libarchive/dist/README
vendored
Normal file
137
external/bsd/libarchive/dist/README
vendored
Normal file
|
@ -0,0 +1,137 @@
|
|||
README for libarchive bundle.
|
||||
|
||||
Questions? Issues?
|
||||
* http://libarchive.googlecode.com/ is the home for ongoing
|
||||
libarchive development, including issue tracker, additional
|
||||
documentation, and links to the libarchive mailing lists.
|
||||
|
||||
This distribution bundle includes the following components:
|
||||
* libarchive: a library for reading and writing streaming archives
|
||||
* tar: the 'bsdtar' program is a full-featured 'tar'
|
||||
replacement built on libarchive
|
||||
* cpio: the 'bsdcpio' program is a different interface to
|
||||
essentially the same functionality
|
||||
* examples: Some small example programs that you may find useful.
|
||||
* examples/minitar: a compact sample demonstrating use of libarchive.
|
||||
I use this for testing link pollution; it should produce a very
|
||||
small executable file on most systems.
|
||||
* contrib: Various items sent to me by third parties;
|
||||
please contact the authors with any questions.
|
||||
|
||||
The top-level directory contains the following information files:
|
||||
* NEWS - highlights of recent changes
|
||||
* COPYING - what you can do with this
|
||||
* INSTALL - installation instructions
|
||||
* README - this file
|
||||
* configure - configuration script, see INSTALL for details.
|
||||
* CMakeLists.txt - input for "cmake" build tool, see INSTALL
|
||||
|
||||
The following files in the top-level directory are used by the
|
||||
'configure' script:
|
||||
* Makefile.am, aclocal.m4, configure.ac
|
||||
- used to build this distribution, only needed by maintainers
|
||||
* Makefile.in, config.h.in
|
||||
- templates used by configure script
|
||||
|
||||
Guide to Documentation installed by this system:
|
||||
* bsdtar.1 explains the use of the bsdtar program
|
||||
* bsdcpio.1 explains the use of the bsdcpio program
|
||||
* libarchive.3 gives an overview of the library as a whole
|
||||
* archive_read.3, archive_write.3, archive_write_disk.3, and
|
||||
archive_read_disk.3 provide detailed calling sequences for the read
|
||||
and write APIs
|
||||
* archive_entry.3 details the "struct archive_entry" utility class
|
||||
* archive_internals.3 provides some insight into libarchive's
|
||||
internal structure and operation.
|
||||
* libarchive-formats.5 documents the file formats supported by the library
|
||||
* cpio.5, mtree.5, and tar.5 provide detailed information about these
|
||||
popular archive formats, including hard-to-find details about
|
||||
modern cpio and tar variants.
|
||||
The manual pages above are provided in the 'doc' directory in
|
||||
a number of different formats.
|
||||
|
||||
You should also read the copious comments in "archive.h" and the
|
||||
source code for the sample programs for more details. Please let me
|
||||
know about any errors or omissions you find.
|
||||
|
||||
Currently, the library automatically detects and reads the following:
|
||||
* gzip compression
|
||||
* bzip2 compression
|
||||
* compress/LZW compression
|
||||
* lzma and xz compression
|
||||
* GNU tar format (including GNU long filenames, long link names, and
|
||||
sparse files)
|
||||
* Solaris 9 extended tar format (including ACLs)
|
||||
* Old V7 tar archives
|
||||
* POSIX ustar
|
||||
* POSIX pax interchange format
|
||||
* POSIX octet-oriented cpio
|
||||
* SVR4 ASCII cpio
|
||||
* POSIX octet-oriented cpio
|
||||
* Binary cpio (big-endian or little-endian)
|
||||
* ISO9660 CD-ROM images (with optional Rockridge or Joliet extensions)
|
||||
* ZIP archives (with uncompressed or "deflate" compressed entries)
|
||||
* GNU and BSD 'ar' archives
|
||||
* 'mtree' format
|
||||
|
||||
The library can write:
|
||||
* gzip compression
|
||||
* bzip2 compression
|
||||
* compress/LZW compression
|
||||
* lzma and xz compression
|
||||
* POSIX ustar
|
||||
* POSIX pax interchange format
|
||||
* "restricted" pax format, which will create ustar archives except for
|
||||
entries that require pax extensions (for long filenames, ACLs, etc).
|
||||
* POSIX octet-oriented cpio
|
||||
* SVR4 "newc" cpio
|
||||
* shar archives
|
||||
* ZIP archives (with uncompressed or "deflate" compressed entries)
|
||||
* GNU and BSD 'ar' archives
|
||||
* 'mtree' format
|
||||
|
||||
Notes about the library architecture:
|
||||
|
||||
* This is a heavily stream-oriented system. There is no direct
|
||||
support for in-place modification or random access.
|
||||
|
||||
* The library is designed to be extended with new compression and
|
||||
archive formats. The only requirement is that the format be
|
||||
readable or writable as a stream and that each archive entry be
|
||||
independent. There are articles on the libarchive Wiki explaining
|
||||
how to extend libarchive.
|
||||
|
||||
* On read, compression and format are always detected automatically.
|
||||
|
||||
* I've attempted to minimize static link pollution. If you don't
|
||||
explicitly invoke a particular feature (such as support for a
|
||||
particular compression or format), it won't get pulled in.
|
||||
In particular, if you don't explicitly enable a particular
|
||||
compression or decompression support, you won't need to link
|
||||
against the corresponding compression or decompression libraries.
|
||||
This also reduces the size of statically-linked binaries in
|
||||
environments where that matters.
|
||||
|
||||
* On read, the library accepts whatever blocks you hand it.
|
||||
Your read callback is free to pass the library a byte at a time
|
||||
or mmap the entire archive and give it to the library at once.
|
||||
On write, the library always produces correctly-blocked output.
|
||||
|
||||
* The object-style approach allows you to have multiple archive streams
|
||||
open at once. bsdtar uses this in its "@archive" extension.
|
||||
|
||||
* The archive itself is read/written using callback functions.
|
||||
You can read an archive directly from an in-memory buffer or
|
||||
write it to a socket, if you wish. There are some utility
|
||||
functions to provide easy-to-use "open file," etc, capabilities.
|
||||
|
||||
* The read/write APIs are designed to allow individual entries
|
||||
to be read or written to any data source: You can create
|
||||
a block of data in memory and add it to a tar archive without
|
||||
first writing a temporary file. You can also read an entry from
|
||||
an archive and write the data directly to a socket. If you want
|
||||
to read/write entries to disk, there are convenience functions to
|
||||
make this especially easy.
|
||||
|
||||
* Note: "pax interchange format" is really an extended tar format,
|
||||
despite what the name says.
|
405
external/bsd/libarchive/dist/cpio/bsdcpio.1
vendored
Normal file
405
external/bsd/libarchive/dist/cpio/bsdcpio.1
vendored
Normal file
|
@ -0,0 +1,405 @@
|
|||
.\" Copyright (c) 2003-2007 Tim Kientzle
|
||||
.\" 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 AND CONTRIBUTORS ``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 OR CONTRIBUTORS 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.
|
||||
.\"
|
||||
.\" $FreeBSD$
|
||||
.\"
|
||||
.Dd December 21, 2007
|
||||
.Dt BSDCPIO 1
|
||||
.Os
|
||||
.Sh NAME
|
||||
.Nm cpio
|
||||
.Nd copy files to and from archives
|
||||
.Sh SYNOPSIS
|
||||
.Nm
|
||||
.Brq Fl i
|
||||
.Op Ar options
|
||||
.Op Ar pattern ...
|
||||
.Op Ar < archive
|
||||
.Nm
|
||||
.Brq Fl o
|
||||
.Op Ar options
|
||||
.Ar < name-list
|
||||
.Op Ar > archive
|
||||
.Nm
|
||||
.Brq Fl p
|
||||
.Op Ar options
|
||||
.Ar dest-dir
|
||||
.Ar < name-list
|
||||
.Sh DESCRIPTION
|
||||
.Nm
|
||||
copies files between archives and directories.
|
||||
This implementation can extract from tar, pax, cpio, zip, jar, ar,
|
||||
and ISO 9660 cdrom images and can create tar, pax, cpio, ar,
|
||||
and shar archives.
|
||||
.Pp
|
||||
The first option to
|
||||
.Nm
|
||||
is a mode indicator from the following list:
|
||||
.Bl -tag -compact -width indent
|
||||
.It Fl i
|
||||
Input.
|
||||
Read an archive from standard input (unless overriden) and extract the
|
||||
contents to disk or (if the
|
||||
.Fl t
|
||||
option is specified)
|
||||
list the contents to standard output.
|
||||
If one or more file patterns are specified, only files matching
|
||||
one of the patterns will be extracted.
|
||||
.It Fl o
|
||||
Output.
|
||||
Read a list of filenames from standard input and produce a new archive
|
||||
on standard output (unless overriden) containing the specified items.
|
||||
.It Fl p
|
||||
Pass-through.
|
||||
Read a list of filenames from standard input and copy the files to the
|
||||
specified directory.
|
||||
.El
|
||||
.Pp
|
||||
.Sh OPTIONS
|
||||
Unless specifically stated otherwise, options are applicable in
|
||||
all operating modes.
|
||||
.Bl -tag -width indent
|
||||
.It Fl 0
|
||||
Read filenames separated by NUL characters instead of newlines.
|
||||
This is necessary if any of the filenames being read might contain newlines.
|
||||
.It Fl A
|
||||
(o mode only)
|
||||
Append to the specified archive.
|
||||
(Not yet implemented.)
|
||||
.It Fl a
|
||||
(o and p modes)
|
||||
Reset access times on files after they are read.
|
||||
.It Fl B
|
||||
(o mode only)
|
||||
Block output to records of 5120 bytes.
|
||||
.It Fl C Ar size
|
||||
(o mode only)
|
||||
Block output to records of
|
||||
.Ar size
|
||||
bytes.
|
||||
.It Fl c
|
||||
(o mode only)
|
||||
Use the old POSIX portable character format.
|
||||
Equivalent to
|
||||
.Fl -format Ar odc .
|
||||
.It Fl d
|
||||
(i and p modes)
|
||||
Create directories as necessary.
|
||||
.It Fl E Ar file
|
||||
(i mode only)
|
||||
Read list of file name patterns from
|
||||
.Ar file
|
||||
to list and extract.
|
||||
.It Fl F Ar file
|
||||
Read archive from or write archive to
|
||||
.Ar file .
|
||||
.It Fl f Ar pattern
|
||||
(i mode only)
|
||||
Ignore files that match
|
||||
.Ar pattern .
|
||||
.It Fl -format Ar format
|
||||
(o mode only)
|
||||
Produce the output archive in the specified format.
|
||||
Supported formats include:
|
||||
.Pp
|
||||
.Bl -tag -width "iso9660" -compact
|
||||
.It Ar cpio
|
||||
Synonym for
|
||||
.Ar odc .
|
||||
.It Ar newc
|
||||
The SVR4 portable cpio format.
|
||||
.It Ar odc
|
||||
The old POSIX.1 portable octet-oriented cpio format.
|
||||
.It Ar pax
|
||||
The POSIX.1 pax format, an extension of the ustar format.
|
||||
.It Ar ustar
|
||||
The POSIX.1 tar format.
|
||||
.El
|
||||
.Pp
|
||||
The default format is
|
||||
.Ar odc .
|
||||
See
|
||||
.Xr libarchive_formats 5
|
||||
for more complete information about the
|
||||
formats currently supported by the underlying
|
||||
.Xr libarchive 3
|
||||
library.
|
||||
.It Fl H Ar format
|
||||
Synonym for
|
||||
.Fl -format .
|
||||
.It Fl h , Fl -help
|
||||
Print usage information.
|
||||
.It Fl I Ar file
|
||||
Read archive from
|
||||
.Ar file .
|
||||
.It Fl i
|
||||
Input mode.
|
||||
See above for description.
|
||||
.It Fl -insecure
|
||||
(i and p mode only)
|
||||
Disable security checks during extraction or copying.
|
||||
This allows extraction via symbolic links and path names containing
|
||||
.Sq ..
|
||||
in the name.
|
||||
.It Fl J
|
||||
(o mode only)
|
||||
Compress the file with xz-compatible compression before writing it.
|
||||
In input mode, this option is ignored; xz compression is recognized
|
||||
automatically on input.
|
||||
.It Fl j
|
||||
Synonym for
|
||||
.Fl y .
|
||||
.It Fl L
|
||||
(o and p modes)
|
||||
All symbolic links will be followed.
|
||||
Normally, symbolic links are archived and copied as symbolic links.
|
||||
With this option, the target of the link will be archived or copied instead.
|
||||
.It Fl l
|
||||
(p mode only)
|
||||
Create links from the target directory to the original files,
|
||||
instead of copying.
|
||||
.It Fl lzma
|
||||
(o mode only)
|
||||
Compress the file with lzma-compatible compression before writing it.
|
||||
In input mode, this option is ignored; lzma compression is recognized
|
||||
automatically on input.
|
||||
.It Fl m
|
||||
(i and p modes)
|
||||
Set file modification time on created files to match
|
||||
those in the source.
|
||||
.It Fl n
|
||||
(i mode, only with
|
||||
.Fl t )
|
||||
Display numeric uid and gid.
|
||||
By default,
|
||||
.Nm
|
||||
displays the user and group names when they are provided in the
|
||||
archive, or looks up the user and group names in the system
|
||||
password database.
|
||||
.It Fl no-preserve-owner
|
||||
(i mode only)
|
||||
Do not attempt to restore file ownership.
|
||||
This is the default when run by non-root users.
|
||||
.It Fl O Ar file
|
||||
Write archive to
|
||||
.Ar file .
|
||||
.It Fl o
|
||||
Output mode.
|
||||
See above for description.
|
||||
.It Fl p
|
||||
Pass-through mode.
|
||||
See above for description.
|
||||
.It Fl preserve-owner
|
||||
(i mode only)
|
||||
Restore file ownership.
|
||||
This is the default when run by the root user.
|
||||
.It Fl -quiet
|
||||
Suppress unnecessary messages.
|
||||
.It Fl R Oo user Oc Ns Oo : Oc Ns Oo group Oc
|
||||
Set the owner and/or group on files in the output.
|
||||
If group is specified with no user
|
||||
(for example,
|
||||
.Fl R Ar :wheel )
|
||||
then the group will be set but not the user.
|
||||
If the user is specified with a trailing colon and no group
|
||||
(for example,
|
||||
.Fl R Ar root: )
|
||||
then the group will be set to the user's default group.
|
||||
If the user is specified with no trailing colon, then
|
||||
the user will be set but not the group.
|
||||
In
|
||||
.Fl i
|
||||
and
|
||||
.Fl p
|
||||
modes, this option can only be used by the super-user.
|
||||
(For compatibility, a period can be used in place of the colon.)
|
||||
.It Fl r
|
||||
(All modes.)
|
||||
Rename files interactively.
|
||||
For each file, a prompt is written to
|
||||
.Pa /dev/tty
|
||||
containing the name of the file and a line is read from
|
||||
.Pa /dev/tty .
|
||||
If the line read is blank, the file is skipped.
|
||||
If the line contains a single period, the file is processed normally.
|
||||
Otherwise, the line is taken to be the new name of the file.
|
||||
.It Fl t
|
||||
(i mode only)
|
||||
List the contents of the archive to stdout;
|
||||
do not restore the contents to disk.
|
||||
.It Fl u
|
||||
(i and p modes)
|
||||
Unconditionally overwrite existing files.
|
||||
Ordinarily, an older file will not overwrite a newer file on disk.
|
||||
.It Fl v
|
||||
Print the name of each file to stderr as it is processed.
|
||||
With
|
||||
.Fl t ,
|
||||
provide a detailed listing of each file.
|
||||
.It Fl -version
|
||||
Print the program version information and exit.
|
||||
.It Fl y
|
||||
(o mode only)
|
||||
Compress the archive with bzip2-compatible compression before writing it.
|
||||
In input mode, this option is ignored;
|
||||
bzip2 compression is recognized automatically on input.
|
||||
.It Fl Z
|
||||
(o mode only)
|
||||
Compress the archive with compress-compatible compression before writing it.
|
||||
In input mode, this option is ignored;
|
||||
compression is recognized automatically on input.
|
||||
.It Fl z
|
||||
(o mode only)
|
||||
Compress the archive with gzip-compatible compression before writing it.
|
||||
In input mode, this option is ignored;
|
||||
gzip compression is recognized automatically on input.
|
||||
.El
|
||||
.Sh ENVIRONMENT
|
||||
The following environment variables affect the execution of
|
||||
.Nm :
|
||||
.Bl -tag -width ".Ev BLOCKSIZE"
|
||||
.It Ev LANG
|
||||
The locale to use.
|
||||
See
|
||||
.Xr environ 7
|
||||
for more information.
|
||||
.It Ev TZ
|
||||
The timezone to use when displaying dates.
|
||||
See
|
||||
.Xr environ 7
|
||||
for more information.
|
||||
.El
|
||||
.Sh EXIT STATUS
|
||||
.Ex -std
|
||||
.Sh EXAMPLES
|
||||
The
|
||||
.Nm
|
||||
command is traditionally used to copy file heirarchies in conjunction
|
||||
with the
|
||||
.Xr find 1
|
||||
command.
|
||||
The first example here simply copies all files from
|
||||
.Pa src
|
||||
to
|
||||
.Pa dest :
|
||||
.Dl Nm find Pa src | Nm Fl pmud Pa dest
|
||||
.Pp
|
||||
By carefully selecting options to the
|
||||
.Xr find 1
|
||||
command and combining it with other standard utilities,
|
||||
it is possible to exercise very fine control over which files are copied.
|
||||
This next example copies files from
|
||||
.Pa src
|
||||
to
|
||||
.Pa dest
|
||||
that are more than 2 days old and whose names match a particular pattern:
|
||||
.Dl Nm find Pa src Fl mtime Ar +2 | Nm grep foo[bar] | Nm Fl pdmu Pa dest
|
||||
.Pp
|
||||
This example copies files from
|
||||
.Pa src
|
||||
to
|
||||
.Pa dest
|
||||
that are more than 2 days old and which contain the word
|
||||
.Do foobar Dc :
|
||||
.Dl Nm find Pa src Fl mtime Ar +2 | Nm xargs Nm grep -l foobar | Nm Fl pdmu Pa dest
|
||||
.Sh COMPATIBILITY
|
||||
The mode options i, o, and p and the options
|
||||
a, B, c, d, f, l, m, r, t, u, and v comply with SUSv2.
|
||||
.Pp
|
||||
The old POSIX.1 standard specified that only
|
||||
.Fl i ,
|
||||
.Fl o ,
|
||||
and
|
||||
.Fl p
|
||||
were interpreted as command-line options.
|
||||
Each took a single argument of a list of modifier
|
||||
characters.
|
||||
For example, the standard syntax allows
|
||||
.Fl imu
|
||||
but does not support
|
||||
.Fl miu
|
||||
or
|
||||
.Fl i Fl m Fl u ,
|
||||
since
|
||||
.Ar m
|
||||
and
|
||||
.Ar u
|
||||
are only modifiers to
|
||||
.Fl i ,
|
||||
they are not command-line options in their own right.
|
||||
The syntax supported by this implementation is backwards-compatible
|
||||
with the standard.
|
||||
For best compatibility, scripts should limit themselves to the
|
||||
standard syntax.
|
||||
.Sh SEE ALSO
|
||||
.Xr bzip2 1 ,
|
||||
.Xr tar 1 ,
|
||||
.Xr gzip 1 ,
|
||||
.Xr mt 1 ,
|
||||
.Xr pax 1 ,
|
||||
.Xr libarchive 3 ,
|
||||
.Xr cpio 5 ,
|
||||
.Xr libarchive-formats 5 ,
|
||||
.Xr tar 5
|
||||
.Sh STANDARDS
|
||||
There is no current POSIX standard for the cpio command; it appeared
|
||||
in
|
||||
.St -p1003.1-96
|
||||
but was dropped from
|
||||
.St -p1003.1-2001 .
|
||||
.Pp
|
||||
The cpio, ustar, and pax interchange file formats are defined by
|
||||
.St -p1003.1-2001
|
||||
for the pax command.
|
||||
.Sh HISTORY
|
||||
The original
|
||||
.Nm cpio
|
||||
and
|
||||
.Nm find
|
||||
utilities were written by Dick Haight
|
||||
while working in AT&T's Unix Support Group.
|
||||
They first appeared in 1977 in PWB/UNIX 1.0, the
|
||||
.Dq Programmer's Work Bench
|
||||
system developed for use within AT&T.
|
||||
They were first released outside of AT&T as part of System III Unix in 1981.
|
||||
As a result,
|
||||
.Nm cpio
|
||||
actually predates
|
||||
.Nm tar ,
|
||||
even though it was not well-known outside of AT&T until some time later.
|
||||
.Pp
|
||||
This is a complete re-implementation based on the
|
||||
.Xr libarchive 3
|
||||
library.
|
||||
.Sh BUGS
|
||||
The cpio archive format has several basic limitations:
|
||||
It does not store user and group names, only numbers.
|
||||
As a result, it cannot be reliably used to transfer
|
||||
files between systems with dissimilar user and group numbering.
|
||||
Older cpio formats limit the user and group numbers to
|
||||
16 or 18 bits, which is insufficient for modern systems.
|
||||
The cpio archive formats cannot support files over 4 gigabytes,
|
||||
except for the
|
||||
.Dq odc
|
||||
variant, which can support files up to 8 gigabytes.
|
369
external/bsd/libarchive/dist/cpio/cmdline.c
vendored
Normal file
369
external/bsd/libarchive/dist/cpio/cmdline.c
vendored
Normal file
|
@ -0,0 +1,369 @@
|
|||
/*-
|
||||
* Copyright (c) 2003-2007 Tim Kientzle
|
||||
* 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
|
||||
* in this position and unchanged.
|
||||
* 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(S) ``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(S) 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.
|
||||
*/
|
||||
|
||||
|
||||
#include "cpio_platform.h"
|
||||
__FBSDID("$FreeBSD: src/usr.bin/cpio/cmdline.c,v 1.5 2008/12/06 07:30:40 kientzle Exp $");
|
||||
|
||||
#ifdef HAVE_ERRNO_H
|
||||
#include <errno.h>
|
||||
#endif
|
||||
#ifdef HAVE_GRP_H
|
||||
#include <grp.h>
|
||||
#endif
|
||||
#ifdef HAVE_PWD_H
|
||||
#include <pwd.h>
|
||||
#endif
|
||||
#include <stdio.h>
|
||||
#ifdef HAVE_STDLIB_H
|
||||
#include <stdlib.h>
|
||||
#endif
|
||||
#ifdef HAVE_STRING_H
|
||||
#include <string.h>
|
||||
#endif
|
||||
|
||||
#include "cpio.h"
|
||||
#include "err.h"
|
||||
|
||||
/*
|
||||
* Short options for cpio. Please keep this sorted.
|
||||
*/
|
||||
static const char *short_options = "0AaBC:cdE:F:f:H:hI:iJjLlmnO:opR:rtuvW:yZz";
|
||||
|
||||
/*
|
||||
* Long options for cpio. Please keep this sorted.
|
||||
*/
|
||||
static const struct option {
|
||||
const char *name;
|
||||
int required; /* 1 if this option requires an argument */
|
||||
int equivalent; /* Equivalent short option. */
|
||||
} cpio_longopts[] = {
|
||||
{ "create", 0, 'o' },
|
||||
{ "extract", 0, 'i' },
|
||||
{ "file", 1, 'F' },
|
||||
{ "format", 1, 'H' },
|
||||
{ "help", 0, 'h' },
|
||||
{ "insecure", 0, OPTION_INSECURE },
|
||||
{ "link", 0, 'l' },
|
||||
{ "list", 0, 't' },
|
||||
{ "lzma", 0, OPTION_LZMA },
|
||||
{ "make-directories", 0, 'd' },
|
||||
{ "no-preserve-owner", 0, OPTION_NO_PRESERVE_OWNER },
|
||||
{ "null", 0, '0' },
|
||||
{ "numeric-uid-gid", 0, 'n' },
|
||||
{ "owner", 1, 'R' },
|
||||
{ "pass-through", 0, 'p' },
|
||||
{ "preserve-modification-time", 0, 'm' },
|
||||
{ "preserve-owner", 0, OPTION_PRESERVE_OWNER },
|
||||
{ "quiet", 0, OPTION_QUIET },
|
||||
{ "unconditional", 0, 'u' },
|
||||
{ "verbose", 0, 'v' },
|
||||
{ "version", 0, OPTION_VERSION },
|
||||
{ "xz", 0, 'J' },
|
||||
{ NULL, 0, 0 }
|
||||
};
|
||||
|
||||
/*
|
||||
* I used to try to select platform-provided getopt() or
|
||||
* getopt_long(), but that caused a lot of headaches. In particular,
|
||||
* I couldn't consistently use long options in the test harness
|
||||
* because not all platforms have getopt_long(). That in turn led to
|
||||
* overuse of the -W hack in the test harness, which made it rough to
|
||||
* run the test harness against GNU cpio. (I periodically run the
|
||||
* test harness here against GNU cpio as a sanity-check. Yes,
|
||||
* I've found a couple of bugs in GNU cpio that way.)
|
||||
*/
|
||||
int
|
||||
cpio_getopt(struct cpio *cpio)
|
||||
{
|
||||
enum { state_start = 0, state_next_word, state_short, state_long };
|
||||
static int state = state_start;
|
||||
static char *opt_word;
|
||||
|
||||
const struct option *popt, *match = NULL, *match2 = NULL;
|
||||
const char *p, *long_prefix = "--";
|
||||
size_t optlength;
|
||||
int opt = '?';
|
||||
int required = 0;
|
||||
|
||||
cpio->optarg = NULL;
|
||||
|
||||
/* First time through, initialize everything. */
|
||||
if (state == state_start) {
|
||||
/* Skip program name. */
|
||||
++cpio->argv;
|
||||
--cpio->argc;
|
||||
state = state_next_word;
|
||||
}
|
||||
|
||||
/*
|
||||
* We're ready to look at the next word in argv.
|
||||
*/
|
||||
if (state == state_next_word) {
|
||||
/* No more arguments, so no more options. */
|
||||
if (cpio->argv[0] == NULL)
|
||||
return (-1);
|
||||
/* Doesn't start with '-', so no more options. */
|
||||
if (cpio->argv[0][0] != '-')
|
||||
return (-1);
|
||||
/* "--" marks end of options; consume it and return. */
|
||||
if (strcmp(cpio->argv[0], "--") == 0) {
|
||||
++cpio->argv;
|
||||
--cpio->argc;
|
||||
return (-1);
|
||||
}
|
||||
/* Get next word for parsing. */
|
||||
opt_word = *cpio->argv++;
|
||||
--cpio->argc;
|
||||
if (opt_word[1] == '-') {
|
||||
/* Set up long option parser. */
|
||||
state = state_long;
|
||||
opt_word += 2; /* Skip leading '--' */
|
||||
} else {
|
||||
/* Set up short option parser. */
|
||||
state = state_short;
|
||||
++opt_word; /* Skip leading '-' */
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* We're parsing a group of POSIX-style single-character options.
|
||||
*/
|
||||
if (state == state_short) {
|
||||
/* Peel next option off of a group of short options. */
|
||||
opt = *opt_word++;
|
||||
if (opt == '\0') {
|
||||
/* End of this group; recurse to get next option. */
|
||||
state = state_next_word;
|
||||
return cpio_getopt(cpio);
|
||||
}
|
||||
|
||||
/* Does this option take an argument? */
|
||||
p = strchr(short_options, opt);
|
||||
if (p == NULL)
|
||||
return ('?');
|
||||
if (p[1] == ':')
|
||||
required = 1;
|
||||
|
||||
/* If it takes an argument, parse that. */
|
||||
if (required) {
|
||||
/* If arg is run-in, opt_word already points to it. */
|
||||
if (opt_word[0] == '\0') {
|
||||
/* Otherwise, pick up the next word. */
|
||||
opt_word = *cpio->argv;
|
||||
if (opt_word == NULL) {
|
||||
lafe_warnc(0,
|
||||
"Option -%c requires an argument",
|
||||
opt);
|
||||
return ('?');
|
||||
}
|
||||
++cpio->argv;
|
||||
--cpio->argc;
|
||||
}
|
||||
if (opt == 'W') {
|
||||
state = state_long;
|
||||
long_prefix = "-W "; /* For clearer errors. */
|
||||
} else {
|
||||
state = state_next_word;
|
||||
cpio->optarg = opt_word;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* We're reading a long option, including -W long=arg convention. */
|
||||
if (state == state_long) {
|
||||
/* After this long option, we'll be starting a new word. */
|
||||
state = state_next_word;
|
||||
|
||||
/* Option name ends at '=' if there is one. */
|
||||
p = strchr(opt_word, '=');
|
||||
if (p != NULL) {
|
||||
optlength = (size_t)(p - opt_word);
|
||||
cpio->optarg = (char *)(uintptr_t)(p + 1);
|
||||
} else {
|
||||
optlength = strlen(opt_word);
|
||||
}
|
||||
|
||||
/* Search the table for an unambiguous match. */
|
||||
for (popt = cpio_longopts; popt->name != NULL; popt++) {
|
||||
/* Short-circuit if first chars don't match. */
|
||||
if (popt->name[0] != opt_word[0])
|
||||
continue;
|
||||
/* If option is a prefix of name in table, record it.*/
|
||||
if (strncmp(opt_word, popt->name, optlength) == 0) {
|
||||
match2 = match; /* Record up to two matches. */
|
||||
match = popt;
|
||||
/* If it's an exact match, we're done. */
|
||||
if (strlen(popt->name) == optlength) {
|
||||
match2 = NULL; /* Forget the others. */
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Fail if there wasn't a unique match. */
|
||||
if (match == NULL) {
|
||||
lafe_warnc(0,
|
||||
"Option %s%s is not supported",
|
||||
long_prefix, opt_word);
|
||||
return ('?');
|
||||
}
|
||||
if (match2 != NULL) {
|
||||
lafe_warnc(0,
|
||||
"Ambiguous option %s%s (matches --%s and --%s)",
|
||||
long_prefix, opt_word, match->name, match2->name);
|
||||
return ('?');
|
||||
}
|
||||
|
||||
/* We've found a unique match; does it need an argument? */
|
||||
if (match->required) {
|
||||
/* Argument required: get next word if necessary. */
|
||||
if (cpio->optarg == NULL) {
|
||||
cpio->optarg = *cpio->argv;
|
||||
if (cpio->optarg == NULL) {
|
||||
lafe_warnc(0,
|
||||
"Option %s%s requires an argument",
|
||||
long_prefix, match->name);
|
||||
return ('?');
|
||||
}
|
||||
++cpio->argv;
|
||||
--cpio->argc;
|
||||
}
|
||||
} else {
|
||||
/* Argument forbidden: fail if there is one. */
|
||||
if (cpio->optarg != NULL) {
|
||||
lafe_warnc(0,
|
||||
"Option %s%s does not allow an argument",
|
||||
long_prefix, match->name);
|
||||
return ('?');
|
||||
}
|
||||
}
|
||||
return (match->equivalent);
|
||||
}
|
||||
|
||||
return (opt);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Parse the argument to the -R or --owner flag.
|
||||
*
|
||||
* The format is one of the following:
|
||||
* <username|uid> - Override user but not group
|
||||
* <username>: - Override both, group is user's default group
|
||||
* <uid>: - Override user but not group
|
||||
* <username|uid>:<groupname|gid> - Override both
|
||||
* :<groupname|gid> - Override group but not user
|
||||
*
|
||||
* Where uid/gid are decimal representations and groupname/username
|
||||
* are names to be looked up in system database. Note that we try
|
||||
* to look up an argument as a name first, then try numeric parsing.
|
||||
*
|
||||
* A period can be used instead of the colon.
|
||||
*
|
||||
* Sets uid/gid return as appropriate, -1 indicates uid/gid not specified.
|
||||
*
|
||||
* Returns NULL if no error, otherwise returns error string for display.
|
||||
*
|
||||
*/
|
||||
const char *
|
||||
owner_parse(const char *spec, int *uid, int *gid)
|
||||
{
|
||||
static char errbuff[128];
|
||||
const char *u, *ue, *g;
|
||||
|
||||
*uid = -1;
|
||||
*gid = -1;
|
||||
|
||||
if (spec[0] == '\0')
|
||||
return ("Invalid empty user/group spec");
|
||||
|
||||
/*
|
||||
* Split spec into [user][:.][group]
|
||||
* u -> first char of username, NULL if no username
|
||||
* ue -> first char after username (colon, period, or \0)
|
||||
* g -> first char of group name
|
||||
*/
|
||||
if (*spec == ':' || *spec == '.') {
|
||||
/* If spec starts with ':' or '.', then just group. */
|
||||
ue = u = NULL;
|
||||
g = spec + 1;
|
||||
} else {
|
||||
/* Otherwise, [user] or [user][:] or [user][:][group] */
|
||||
ue = u = spec;
|
||||
while (*ue != ':' && *ue != '.' && *ue != '\0')
|
||||
++ue;
|
||||
g = ue;
|
||||
if (*g != '\0') /* Skip : or . to find first char of group. */
|
||||
++g;
|
||||
}
|
||||
|
||||
if (u != NULL) {
|
||||
/* Look up user: ue is first char after end of user. */
|
||||
char *user;
|
||||
struct passwd *pwent;
|
||||
|
||||
user = (char *)malloc(ue - u + 1);
|
||||
if (user == NULL)
|
||||
return ("Couldn't allocate memory");
|
||||
memcpy(user, u, ue - u);
|
||||
user[ue - u] = '\0';
|
||||
if ((pwent = getpwnam(user)) != NULL) {
|
||||
*uid = pwent->pw_uid;
|
||||
if (*ue != '\0')
|
||||
*gid = pwent->pw_gid;
|
||||
} else {
|
||||
char *end;
|
||||
errno = 0;
|
||||
*uid = strtoul(user, &end, 10);
|
||||
if (errno || *end != '\0') {
|
||||
snprintf(errbuff, sizeof(errbuff),
|
||||
"Couldn't lookup user ``%s''", user);
|
||||
errbuff[sizeof(errbuff) - 1] = '\0';
|
||||
return (errbuff);
|
||||
}
|
||||
}
|
||||
free(user);
|
||||
}
|
||||
|
||||
if (*g != '\0') {
|
||||
struct group *grp;
|
||||
if ((grp = getgrnam(g)) != NULL) {
|
||||
*gid = grp->gr_gid;
|
||||
} else {
|
||||
char *end;
|
||||
errno = 0;
|
||||
*gid = strtoul(g, &end, 10);
|
||||
if (errno || *end != '\0') {
|
||||
snprintf(errbuff, sizeof(errbuff),
|
||||
"Couldn't lookup group ``%s''", g);
|
||||
errbuff[sizeof(errbuff) - 1] = '\0';
|
||||
return (errbuff);
|
||||
}
|
||||
}
|
||||
}
|
||||
return (NULL);
|
||||
}
|
1267
external/bsd/libarchive/dist/cpio/cpio.c
vendored
Normal file
1267
external/bsd/libarchive/dist/cpio/cpio.c
vendored
Normal file
File diff suppressed because it is too large
Load diff
109
external/bsd/libarchive/dist/cpio/cpio.h
vendored
Normal file
109
external/bsd/libarchive/dist/cpio/cpio.h
vendored
Normal file
|
@ -0,0 +1,109 @@
|
|||
/*-
|
||||
* Copyright (c) 2003-2007 Tim Kientzle
|
||||
* 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(S) ``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(S) 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.
|
||||
*
|
||||
* $FreeBSD: src/usr.bin/cpio/cpio.h,v 1.7 2008/12/06 07:30:40 kientzle Exp $
|
||||
*/
|
||||
|
||||
#ifndef CPIO_H_INCLUDED
|
||||
#define CPIO_H_INCLUDED
|
||||
|
||||
#include "cpio_platform.h"
|
||||
#include <stdio.h>
|
||||
|
||||
#include "matching.h"
|
||||
|
||||
/*
|
||||
* The internal state for the "cpio" program.
|
||||
*
|
||||
* Keeping all of the state in a structure like this simplifies memory
|
||||
* leak testing (at exit, anything left on the heap is suspect). A
|
||||
* pointer to this structure is passed to most cpio internal
|
||||
* functions.
|
||||
*/
|
||||
struct cpio {
|
||||
/* Option parsing */
|
||||
const char *optarg;
|
||||
|
||||
/* Options */
|
||||
const char *filename;
|
||||
char mode; /* -i -o -p */
|
||||
char compress; /* -j, -y, or -z */
|
||||
const char *format; /* -H format */
|
||||
int bytes_per_block; /* -b block_size */
|
||||
int verbose; /* -v */
|
||||
int quiet; /* --quiet */
|
||||
int extract_flags; /* Flags for extract operation */
|
||||
char symlink_mode; /* H or L, per BSD conventions */
|
||||
const char *compress_program;
|
||||
int option_append; /* -A, only relevant for -o */
|
||||
int option_atime_restore; /* -a */
|
||||
int option_follow_links; /* -L */
|
||||
int option_link; /* -l */
|
||||
int option_list; /* -t */
|
||||
char option_null; /* --null */
|
||||
int option_numeric_uid_gid; /* -n */
|
||||
int option_rename; /* -r */
|
||||
char *destdir;
|
||||
size_t pass_destpath_alloc;
|
||||
char *pass_destpath;
|
||||
int uid_override;
|
||||
int gid_override;
|
||||
int day_first; /* true if locale prefers day/mon */
|
||||
|
||||
/* If >= 0, then close this when done. */
|
||||
int fd;
|
||||
|
||||
/* Miscellaneous state information */
|
||||
struct archive *archive;
|
||||
struct archive *archive_read_disk;
|
||||
int argc;
|
||||
char **argv;
|
||||
int return_value; /* Value returned by main() */
|
||||
struct archive_entry_linkresolver *linkresolver;
|
||||
|
||||
struct name_cache *uname_cache;
|
||||
struct name_cache *gname_cache;
|
||||
|
||||
/* Work data. */
|
||||
struct lafe_matching *matching;
|
||||
char *buff;
|
||||
size_t buff_size;
|
||||
};
|
||||
|
||||
const char *owner_parse(const char *, int *, int *);
|
||||
|
||||
|
||||
/* Fake short equivalents for long options that otherwise lack them. */
|
||||
enum {
|
||||
OPTION_INSECURE = 1,
|
||||
OPTION_LZMA,
|
||||
OPTION_NO_PRESERVE_OWNER,
|
||||
OPTION_PRESERVE_OWNER,
|
||||
OPTION_QUIET,
|
||||
OPTION_VERSION
|
||||
};
|
||||
|
||||
int cpio_getopt(struct cpio *cpio);
|
||||
|
||||
#endif
|
77
external/bsd/libarchive/dist/cpio/cpio_platform.h
vendored
Normal file
77
external/bsd/libarchive/dist/cpio/cpio_platform.h
vendored
Normal file
|
@ -0,0 +1,77 @@
|
|||
/*-
|
||||
* Copyright (c) 2003-2007 Tim Kientzle
|
||||
* 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(S) ``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(S) 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.
|
||||
*
|
||||
* $FreeBSD: src/usr.bin/cpio/cpio_platform.h,v 1.2 2008/12/06 07:15:42 kientzle Exp $
|
||||
*/
|
||||
|
||||
/*
|
||||
* This header is the first thing included in any of the cpio
|
||||
* source files. As far as possible, platform-specific issues should
|
||||
* be dealt with here and not within individual source files.
|
||||
*/
|
||||
|
||||
#ifndef CPIO_PLATFORM_H_INCLUDED
|
||||
#define CPIO_PLATFORM_H_INCLUDED
|
||||
|
||||
#if defined(PLATFORM_CONFIG_H)
|
||||
/* Use hand-built config.h in environments that need it. */
|
||||
#include PLATFORM_CONFIG_H
|
||||
#else
|
||||
/* Read config.h or die trying. */
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
/* Get a real definition for __FBSDID if we can */
|
||||
#if HAVE_SYS_CDEFS_H
|
||||
#include <sys/cdefs.h>
|
||||
#endif
|
||||
|
||||
/* If not, define it so as to avoid dangling semicolons. */
|
||||
#ifndef __FBSDID
|
||||
#define __FBSDID(a) struct _undefined_hack
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_LIBARCHIVE
|
||||
/* If we're using the platform libarchive, include system headers. */
|
||||
#include <archive.h>
|
||||
#include <archive_entry.h>
|
||||
#else
|
||||
/* Otherwise, include user headers. */
|
||||
#include "archive.h"
|
||||
#include "archive_entry.h"
|
||||
#endif
|
||||
|
||||
/* How to mark functions that don't return. */
|
||||
#if defined(__GNUC__) && (__GNUC__ > 2 || \
|
||||
(__GNUC__ == 2 && __GNUC_MINOR__ >= 5))
|
||||
#define __LA_DEAD __attribute__((__noreturn__))
|
||||
#else
|
||||
#define __LA_DEAD
|
||||
#endif
|
||||
|
||||
#if defined(_WIN32) && !defined(__CYGWIN__)
|
||||
#include "cpio_windows.h"
|
||||
#endif
|
||||
|
||||
#endif /* !CPIO_PLATFORM_H_INCLUDED */
|
338
external/bsd/libarchive/dist/cpio/cpio_windows.c
vendored
Normal file
338
external/bsd/libarchive/dist/cpio/cpio_windows.c
vendored
Normal file
|
@ -0,0 +1,338 @@
|
|||
/*-
|
||||
* Copyright (c) 2009 Michihiro NAKAJIMA
|
||||
* 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(S) ``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(S) 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.
|
||||
*
|
||||
* $FreeBSD$
|
||||
*/
|
||||
|
||||
#if defined(_WIN32) && !defined(__CYGWIN__)
|
||||
|
||||
#include "cpio_platform.h"
|
||||
#include <ctype.h>
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
#include <io.h>
|
||||
#include <stddef.h>
|
||||
#ifdef HAVE_SYS_UTIME_H
|
||||
#include <sys/utime.h>
|
||||
#endif
|
||||
#include <sys/stat.h>
|
||||
#include <process.h>
|
||||
#include <stdlib.h>
|
||||
#include <wchar.h>
|
||||
#include <windows.h>
|
||||
#include <sddl.h>
|
||||
|
||||
#include "cpio.h"
|
||||
#include "err.h"
|
||||
|
||||
#define EPOC_TIME (116444736000000000ULL)
|
||||
|
||||
static void cpio_dosmaperr(unsigned long);
|
||||
|
||||
/*
|
||||
* Prepend "\\?\" to the path name and convert it to unicode to permit
|
||||
* an extended-length path for a maximum total path length of 32767
|
||||
* characters.
|
||||
* see also http://msdn.microsoft.com/en-us/library/aa365247.aspx
|
||||
*/
|
||||
static wchar_t *
|
||||
permissive_name(const char *name)
|
||||
{
|
||||
wchar_t *wn, *wnp;
|
||||
wchar_t *ws, *wsp;
|
||||
DWORD l, len, slen, alloclen;
|
||||
int unc;
|
||||
|
||||
len = (DWORD)strlen(name);
|
||||
wn = malloc((len + 1) * sizeof(wchar_t));
|
||||
if (wn == NULL)
|
||||
return (NULL);
|
||||
l = MultiByteToWideChar(CP_ACP, 0, name, len, wn, len);
|
||||
if (l == 0) {
|
||||
free(wn);
|
||||
return (NULL);
|
||||
}
|
||||
wn[l] = L'\0';
|
||||
|
||||
/* Get a full path names */
|
||||
l = GetFullPathNameW(wn, 0, NULL, NULL);
|
||||
if (l == 0) {
|
||||
free(wn);
|
||||
return (NULL);
|
||||
}
|
||||
wnp = malloc(l * sizeof(wchar_t));
|
||||
if (wnp == NULL) {
|
||||
free(wn);
|
||||
return (NULL);
|
||||
}
|
||||
len = GetFullPathNameW(wn, l, wnp, NULL);
|
||||
free(wn);
|
||||
wn = wnp;
|
||||
|
||||
if (wnp[0] == L'\\' && wnp[1] == L'\\' &&
|
||||
wnp[2] == L'?' && wnp[3] == L'\\')
|
||||
/* We have already permissive names. */
|
||||
return (wn);
|
||||
|
||||
if (wnp[0] == L'\\' && wnp[1] == L'\\' &&
|
||||
wnp[2] == L'.' && wnp[3] == L'\\') {
|
||||
/* Device names */
|
||||
if (((wnp[4] >= L'a' && wnp[4] <= L'z') ||
|
||||
(wnp[4] >= L'A' && wnp[4] <= L'Z')) &&
|
||||
wnp[5] == L':' && wnp[6] == L'\\')
|
||||
wnp[2] = L'?';/* Not device names. */
|
||||
return (wn);
|
||||
}
|
||||
|
||||
unc = 0;
|
||||
if (wnp[0] == L'\\' && wnp[1] == L'\\' && wnp[2] != L'\\') {
|
||||
wchar_t *p = &wnp[2];
|
||||
|
||||
/* Skip server-name letters. */
|
||||
while (*p != L'\\' && *p != L'\0')
|
||||
++p;
|
||||
if (*p == L'\\') {
|
||||
wchar_t *rp = ++p;
|
||||
/* Skip share-name letters. */
|
||||
while (*p != L'\\' && *p != L'\0')
|
||||
++p;
|
||||
if (*p == L'\\' && p != rp) {
|
||||
/* Now, match patterns such as
|
||||
* "\\server-name\share-name\" */
|
||||
wnp += 2;
|
||||
len -= 2;
|
||||
unc = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
alloclen = slen = 4 + (unc * 4) + len + 1;
|
||||
ws = wsp = malloc(slen * sizeof(wchar_t));
|
||||
if (ws == NULL) {
|
||||
free(wn);
|
||||
return (NULL);
|
||||
}
|
||||
/* prepend "\\?\" */
|
||||
wcsncpy(wsp, L"\\\\?\\", 4);
|
||||
wsp += 4;
|
||||
slen -= 4;
|
||||
if (unc) {
|
||||
/* append "UNC\" ---> "\\?\UNC\" */
|
||||
wcsncpy(wsp, L"UNC\\", 4);
|
||||
wsp += 4;
|
||||
slen -= 4;
|
||||
}
|
||||
wcsncpy(wsp, wnp, slen);
|
||||
free(wn);
|
||||
ws[alloclen - 1] = L'\0';
|
||||
return (ws);
|
||||
}
|
||||
|
||||
static HANDLE
|
||||
cpio_CreateFile(const char *path, DWORD dwDesiredAccess, DWORD dwShareMode,
|
||||
LPSECURITY_ATTRIBUTES lpSecurityAttributes, DWORD dwCreationDisposition,
|
||||
DWORD dwFlagsAndAttributes, HANDLE hTemplateFile)
|
||||
{
|
||||
wchar_t *wpath;
|
||||
HANDLE handle;
|
||||
|
||||
handle = CreateFileA(path, dwDesiredAccess, dwShareMode,
|
||||
lpSecurityAttributes, dwCreationDisposition, dwFlagsAndAttributes,
|
||||
hTemplateFile);
|
||||
if (handle != INVALID_HANDLE_VALUE)
|
||||
return (handle);
|
||||
if (GetLastError() != ERROR_PATH_NOT_FOUND)
|
||||
return (handle);
|
||||
wpath = permissive_name(path);
|
||||
if (wpath == NULL)
|
||||
return (handle);
|
||||
handle = CreateFileW(wpath, dwDesiredAccess, dwShareMode,
|
||||
lpSecurityAttributes, dwCreationDisposition, dwFlagsAndAttributes,
|
||||
hTemplateFile);
|
||||
free(wpath);
|
||||
return (handle);
|
||||
}
|
||||
|
||||
#define WINTIME(sec, usec) ((Int32x32To64(sec, 10000000) + EPOC_TIME) + (usec * 10))
|
||||
static int
|
||||
__hutimes(HANDLE handle, const struct __timeval *times)
|
||||
{
|
||||
ULARGE_INTEGER wintm;
|
||||
FILETIME fatime, fmtime;
|
||||
|
||||
wintm.QuadPart = WINTIME(times[0].tv_sec, times[0].tv_usec);
|
||||
fatime.dwLowDateTime = wintm.LowPart;
|
||||
fatime.dwHighDateTime = wintm.HighPart;
|
||||
wintm.QuadPart = WINTIME(times[1].tv_sec, times[1].tv_usec);
|
||||
fmtime.dwLowDateTime = wintm.LowPart;
|
||||
fmtime.dwHighDateTime = wintm.HighPart;
|
||||
if (SetFileTime(handle, NULL, &fatime, &fmtime) == 0) {
|
||||
errno = EINVAL;
|
||||
return (-1);
|
||||
}
|
||||
return (0);
|
||||
}
|
||||
|
||||
int
|
||||
futimes(int fd, const struct __timeval *times)
|
||||
{
|
||||
|
||||
return (__hutimes((HANDLE)_get_osfhandle(fd), times));
|
||||
}
|
||||
|
||||
int
|
||||
utimes(const char *name, const struct __timeval *times)
|
||||
{
|
||||
int ret;
|
||||
HANDLE handle;
|
||||
|
||||
handle = cpio_CreateFile(name, GENERIC_READ | GENERIC_WRITE,
|
||||
FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING,
|
||||
FILE_FLAG_BACKUP_SEMANTICS, NULL);
|
||||
if (handle == INVALID_HANDLE_VALUE) {
|
||||
cpio_dosmaperr(GetLastError());
|
||||
return (-1);
|
||||
}
|
||||
ret = __hutimes(handle, times);
|
||||
CloseHandle(handle);
|
||||
return (ret);
|
||||
}
|
||||
|
||||
/*
|
||||
* The following function was modified from PostgreSQL sources and is
|
||||
* subject to the copyright below.
|
||||
*/
|
||||
/*-------------------------------------------------------------------------
|
||||
*
|
||||
* win32error.c
|
||||
* Map win32 error codes to errno values
|
||||
*
|
||||
* Portions Copyright (c) 1996-2008, PostgreSQL Global Development Group
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/port/win32error.c,v 1.4 2008/01/01 19:46:00 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
/*
|
||||
PostgreSQL Database Management System
|
||||
(formerly known as Postgres, then as Postgres95)
|
||||
|
||||
Portions Copyright (c) 1996-2008, PostgreSQL Global Development Group
|
||||
|
||||
Portions Copyright (c) 1994, The Regents of the University of California
|
||||
|
||||
Permission to use, copy, modify, and distribute this software and its
|
||||
documentation for any purpose, without fee, and without a written agreement
|
||||
is hereby granted, provided that the above copyright notice and this
|
||||
paragraph and the following two paragraphs appear in all copies.
|
||||
|
||||
IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR
|
||||
DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING
|
||||
LOST PROFITS, ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS
|
||||
DOCUMENTATION, EVEN IF THE UNIVERSITY OF CALIFORNIA HAS BEEN ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES,
|
||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||
AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS
|
||||
ON AN "AS IS" BASIS, AND THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATIONS TO
|
||||
PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
|
||||
*/
|
||||
|
||||
static const struct {
|
||||
DWORD winerr;
|
||||
int doserr;
|
||||
} doserrors[] =
|
||||
{
|
||||
{ ERROR_INVALID_FUNCTION, EINVAL },
|
||||
{ ERROR_FILE_NOT_FOUND, ENOENT },
|
||||
{ ERROR_PATH_NOT_FOUND, ENOENT },
|
||||
{ ERROR_TOO_MANY_OPEN_FILES, EMFILE },
|
||||
{ ERROR_ACCESS_DENIED, EACCES },
|
||||
{ ERROR_INVALID_HANDLE, EBADF },
|
||||
{ ERROR_ARENA_TRASHED, ENOMEM },
|
||||
{ ERROR_NOT_ENOUGH_MEMORY, ENOMEM },
|
||||
{ ERROR_INVALID_BLOCK, ENOMEM },
|
||||
{ ERROR_BAD_ENVIRONMENT, E2BIG },
|
||||
{ ERROR_BAD_FORMAT, ENOEXEC },
|
||||
{ ERROR_INVALID_ACCESS, EINVAL },
|
||||
{ ERROR_INVALID_DATA, EINVAL },
|
||||
{ ERROR_INVALID_DRIVE, ENOENT },
|
||||
{ ERROR_CURRENT_DIRECTORY, EACCES },
|
||||
{ ERROR_NOT_SAME_DEVICE, EXDEV },
|
||||
{ ERROR_NO_MORE_FILES, ENOENT },
|
||||
{ ERROR_LOCK_VIOLATION, EACCES },
|
||||
{ ERROR_SHARING_VIOLATION, EACCES },
|
||||
{ ERROR_BAD_NETPATH, ENOENT },
|
||||
{ ERROR_NETWORK_ACCESS_DENIED, EACCES },
|
||||
{ ERROR_BAD_NET_NAME, ENOENT },
|
||||
{ ERROR_FILE_EXISTS, EEXIST },
|
||||
{ ERROR_CANNOT_MAKE, EACCES },
|
||||
{ ERROR_FAIL_I24, EACCES },
|
||||
{ ERROR_INVALID_PARAMETER, EINVAL },
|
||||
{ ERROR_NO_PROC_SLOTS, EAGAIN },
|
||||
{ ERROR_DRIVE_LOCKED, EACCES },
|
||||
{ ERROR_BROKEN_PIPE, EPIPE },
|
||||
{ ERROR_DISK_FULL, ENOSPC },
|
||||
{ ERROR_INVALID_TARGET_HANDLE, EBADF },
|
||||
{ ERROR_INVALID_HANDLE, EINVAL },
|
||||
{ ERROR_WAIT_NO_CHILDREN, ECHILD },
|
||||
{ ERROR_CHILD_NOT_COMPLETE, ECHILD },
|
||||
{ ERROR_DIRECT_ACCESS_HANDLE, EBADF },
|
||||
{ ERROR_NEGATIVE_SEEK, EINVAL },
|
||||
{ ERROR_SEEK_ON_DEVICE, EACCES },
|
||||
{ ERROR_DIR_NOT_EMPTY, ENOTEMPTY },
|
||||
{ ERROR_NOT_LOCKED, EACCES },
|
||||
{ ERROR_BAD_PATHNAME, ENOENT },
|
||||
{ ERROR_MAX_THRDS_REACHED, EAGAIN },
|
||||
{ ERROR_LOCK_FAILED, EACCES },
|
||||
{ ERROR_ALREADY_EXISTS, EEXIST },
|
||||
{ ERROR_FILENAME_EXCED_RANGE, ENOENT },
|
||||
{ ERROR_NESTING_NOT_ALLOWED, EAGAIN },
|
||||
{ ERROR_NOT_ENOUGH_QUOTA, ENOMEM }
|
||||
};
|
||||
|
||||
static void
|
||||
cpio_dosmaperr(unsigned long e)
|
||||
{
|
||||
int i;
|
||||
|
||||
if (e == 0) {
|
||||
errno = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
for (i = 0; i < sizeof(doserrors); i++) {
|
||||
if (doserrors[i].winerr == e) {
|
||||
errno = doserrors[i].doserr;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
/* fprintf(stderr, "unrecognized win32 error code: %lu", e); */
|
||||
errno = EINVAL;
|
||||
return;
|
||||
}
|
||||
#endif
|
72
external/bsd/libarchive/dist/cpio/cpio_windows.h
vendored
Normal file
72
external/bsd/libarchive/dist/cpio/cpio_windows.h
vendored
Normal file
|
@ -0,0 +1,72 @@
|
|||
/*-
|
||||
* Copyright (c) 2009 Michihiro NAKAJIMA
|
||||
* 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(S) ``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(S) 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.
|
||||
*
|
||||
* $FreeBSD$
|
||||
*/
|
||||
#ifndef CPIO_WINDOWS_H
|
||||
#define CPIO_WINDOWS_H 1
|
||||
|
||||
#include <io.h>
|
||||
#include <string.h>
|
||||
|
||||
#define getgrgid(id) NULL
|
||||
#define getgrnam(name) NULL
|
||||
#define getpwnam(name) NULL
|
||||
#define getpwuid(id) NULL
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#define snprintf sprintf_s
|
||||
#define strdup _strdup
|
||||
#define open _open
|
||||
#define read _read
|
||||
#define close _close
|
||||
#endif
|
||||
|
||||
struct passwd {
|
||||
char *pw_name;
|
||||
uid_t pw_uid;
|
||||
gid_t pw_gid;
|
||||
};
|
||||
|
||||
struct group {
|
||||
char *gr_name;
|
||||
gid_t gr_gid;
|
||||
};
|
||||
|
||||
struct _timeval64i32 {
|
||||
time_t tv_sec;
|
||||
long tv_usec;
|
||||
};
|
||||
#define __timeval _timeval64i32
|
||||
|
||||
extern int futimes(int fd, const struct __timeval *times);
|
||||
#ifndef HAVE_FUTIMES
|
||||
#define HAVE_FUTIMES 1
|
||||
#endif
|
||||
extern int utimes(const char *name, const struct __timeval *times);
|
||||
#ifndef HAVE_UTIMES
|
||||
#define HAVE_UTIMES 1
|
||||
#endif
|
||||
|
||||
#endif /* CPIO_WINDOWS_H */
|
79
external/bsd/libarchive/dist/cpio/test/CMakeLists.txt
vendored
Normal file
79
external/bsd/libarchive/dist/cpio/test/CMakeLists.txt
vendored
Normal file
|
@ -0,0 +1,79 @@
|
|||
############################################
|
||||
#
|
||||
# How to build bsdcpio_test
|
||||
#
|
||||
############################################
|
||||
IF(ENABLE_CPIO AND ENABLE_TEST)
|
||||
SET(bsdcpio_test_SOURCES
|
||||
../cmdline.c
|
||||
../../libarchive_fe/err.c
|
||||
../../libarchive_fe/pathmatch.c
|
||||
main.c
|
||||
test.h
|
||||
test_0.c
|
||||
test_basic.c
|
||||
test_cmdline.c
|
||||
test_format_newc.c
|
||||
test_gcpio_compat.c
|
||||
test_option_B_upper.c
|
||||
test_option_C_upper.c
|
||||
test_option_J_upper.c
|
||||
test_option_L_upper.c
|
||||
test_option_Z_upper.c
|
||||
test_option_a.c
|
||||
test_option_c.c
|
||||
test_option_d.c
|
||||
test_option_f.c
|
||||
test_option_help.c
|
||||
test_option_l.c
|
||||
test_option_lzma.c
|
||||
test_option_m.c
|
||||
test_option_t.c
|
||||
test_option_u.c
|
||||
test_option_version.c
|
||||
test_option_y.c
|
||||
test_option_z.c
|
||||
test_owner_parse.c
|
||||
test_passthrough_dotdot.c
|
||||
test_passthrough_reverse.c
|
||||
test_pathmatch.c
|
||||
)
|
||||
IF(WIN32 AND NOT CYGWIN)
|
||||
LIST(APPEND bsdcpio_test_SOURCES ../cpio_windows.h)
|
||||
ENDIF(WIN32 AND NOT CYGWIN)
|
||||
|
||||
#
|
||||
# Register target
|
||||
#
|
||||
ADD_EXECUTABLE(bsdcpio_test ${bsdcpio_test_SOURCES})
|
||||
SET_PROPERTY(TARGET bsdcpio_test PROPERTY COMPILE_DEFINITIONS LIST_H)
|
||||
|
||||
#
|
||||
# Generate list.h by grepping DEFINE_TEST() lines out of the C sources.
|
||||
#
|
||||
GENERATE_LIST_H(${CMAKE_CURRENT_BINARY_DIR}/list.h
|
||||
${CMAKE_CURRENT_LIST_FILE} ${bsdcpio_test_SOURCES})
|
||||
SET_PROPERTY(DIRECTORY APPEND PROPERTY INCLUDE_DIRECTORIES
|
||||
${CMAKE_CURRENT_BINARY_DIR})
|
||||
|
||||
# list.h has a line DEFINE_TEST(testname) for every
|
||||
# test. We can use that to define the tests for cmake by
|
||||
# defining a DEFINE_TEST macro and reading list.h in.
|
||||
MACRO (DEFINE_TEST _testname)
|
||||
ADD_TEST_28(
|
||||
NAME bsdcpio_${_testname}
|
||||
COMMAND bsdcpio_test -vv
|
||||
-p $<TARGET_FILE:bsdcpio>
|
||||
-r ${CMAKE_CURRENT_SOURCE_DIR}
|
||||
${_testname})
|
||||
ENDMACRO (DEFINE_TEST _testname)
|
||||
|
||||
INCLUDE(${CMAKE_CURRENT_BINARY_DIR}/list.h)
|
||||
|
||||
# Experimental new test handling
|
||||
ADD_CUSTOM_TARGET(run_bsdcpio_test
|
||||
COMMAND bsdcpio_test -p ${BSDCPIO} -r ${CMAKE_CURRENT_SOURCE_DIR})
|
||||
ADD_DEPENDENCIES(run_bsdcpio_test bsdcpio)
|
||||
ADD_DEPENDENCIES(run_all_tests run_bsdcpio_test)
|
||||
ENDIF(ENABLE_CPIO AND ENABLE_TEST)
|
||||
|
27
external/bsd/libarchive/dist/cpio/test/list.h
vendored
Normal file
27
external/bsd/libarchive/dist/cpio/test/list.h
vendored
Normal file
|
@ -0,0 +1,27 @@
|
|||
DEFINE_TEST(test_0)
|
||||
DEFINE_TEST(test_basic)
|
||||
DEFINE_TEST(test_cmdline)
|
||||
DEFINE_TEST(test_format_newc)
|
||||
DEFINE_TEST(test_gcpio_compat)
|
||||
DEFINE_TEST(test_option_B_upper)
|
||||
DEFINE_TEST(test_option_C_upper)
|
||||
DEFINE_TEST(test_option_J_upper)
|
||||
DEFINE_TEST(test_option_L_upper)
|
||||
DEFINE_TEST(test_option_Z_upper)
|
||||
DEFINE_TEST(test_option_a)
|
||||
DEFINE_TEST(test_option_c)
|
||||
DEFINE_TEST(test_option_d)
|
||||
DEFINE_TEST(test_option_f)
|
||||
DEFINE_TEST(test_option_help)
|
||||
DEFINE_TEST(test_option_l)
|
||||
DEFINE_TEST(test_option_lzma)
|
||||
DEFINE_TEST(test_option_m)
|
||||
DEFINE_TEST(test_option_t)
|
||||
DEFINE_TEST(test_option_u)
|
||||
DEFINE_TEST(test_option_version)
|
||||
DEFINE_TEST(test_option_y)
|
||||
DEFINE_TEST(test_option_z)
|
||||
DEFINE_TEST(test_owner_parse)
|
||||
DEFINE_TEST(test_passthrough_dotdot)
|
||||
DEFINE_TEST(test_passthrough_reverse)
|
||||
DEFINE_TEST(test_pathmatch)
|
2140
external/bsd/libarchive/dist/cpio/test/main.c
vendored
Normal file
2140
external/bsd/libarchive/dist/cpio/test/main.c
vendored
Normal file
File diff suppressed because it is too large
Load diff
285
external/bsd/libarchive/dist/cpio/test/test.h
vendored
Normal file
285
external/bsd/libarchive/dist/cpio/test/test.h
vendored
Normal file
|
@ -0,0 +1,285 @@
|
|||
/*
|
||||
* Copyright (c) 2003-2006 Tim Kientzle
|
||||
* 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(S) ``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(S) 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.
|
||||
*
|
||||
* $FreeBSD: src/usr.bin/cpio/test/test.h,v 1.2 2008/06/21 02:17:18 kientzle Exp $
|
||||
*/
|
||||
|
||||
/* Every test program should #include "test.h" as the first thing. */
|
||||
|
||||
/*
|
||||
* The goal of this file (and the matching test.c) is to
|
||||
* simplify the very repetitive test-*.c test programs.
|
||||
*/
|
||||
#if defined(HAVE_CONFIG_H)
|
||||
/* Most POSIX platforms use the 'configure' script to build config.h */
|
||||
#include "config.h"
|
||||
#elif defined(__FreeBSD__)
|
||||
/* Building as part of FreeBSD system requires a pre-built config.h. */
|
||||
#include "config_freebsd.h"
|
||||
#elif defined(_WIN32) && !defined(__CYGWIN__)
|
||||
/* Win32 can't run the 'configure' script. */
|
||||
#include "config_windows.h"
|
||||
#else
|
||||
/* Warn if the library hasn't been (automatically or manually) configured. */
|
||||
#error Oops: No config.h and no pre-built configuration in test.h.
|
||||
#endif
|
||||
|
||||
#include <sys/types.h> /* Windows requires this before sys/stat.h */
|
||||
#include <sys/stat.h>
|
||||
|
||||
#ifdef USE_DMALLOC
|
||||
#include <dmalloc.h>
|
||||
#endif
|
||||
#if HAVE_DIRENT_H
|
||||
#include <dirent.h>
|
||||
#endif
|
||||
#ifdef HAVE_DIRECT_H
|
||||
#include <direct.h>
|
||||
#define dirent direct
|
||||
#endif
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
#ifdef HAVE_IO_H
|
||||
#include <io.h>
|
||||
#endif
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <time.h>
|
||||
#ifdef HAVE_UNISTD_H
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
#include <wchar.h>
|
||||
#ifdef HAVE_WINDOWS_H
|
||||
#include <windows.h>
|
||||
#endif
|
||||
|
||||
/*
|
||||
* System-specific tweaks. We really want to minimize these
|
||||
* as much as possible, since they make it harder to understand
|
||||
* the mainline code.
|
||||
*/
|
||||
|
||||
/* Windows (including Visual Studio and MinGW but not Cygwin) */
|
||||
#if defined(_WIN32) && !defined(__CYGWIN__)
|
||||
#include "../cpio_windows.h"
|
||||
#if !defined(__BORLANDC__)
|
||||
#define strdup _strdup
|
||||
#endif
|
||||
#define LOCALE_DE "deu"
|
||||
#else
|
||||
#define LOCALE_DE "de_DE.UTF-8"
|
||||
#endif
|
||||
|
||||
/* Visual Studio */
|
||||
#ifdef _MSC_VER
|
||||
#define snprintf sprintf_s
|
||||
#endif
|
||||
|
||||
/* Cygwin */
|
||||
#if defined(__CYGWIN__)
|
||||
/* Cygwin-1.7.x is lazy about populating nlinks, so don't
|
||||
* expect it to be accurate. */
|
||||
# define NLINKS_INACCURATE_FOR_DIRS
|
||||
#endif
|
||||
|
||||
#if defined(__HAIKU__) || defined(__QNXNTO__)
|
||||
/* Haiku and QNX have typedefs in stdint.h (needed for int64_t) */
|
||||
#include <stdint.h>
|
||||
#endif
|
||||
|
||||
/* Get a real definition for __FBSDID if we can */
|
||||
#if HAVE_SYS_CDEFS_H
|
||||
#include <sys/cdefs.h>
|
||||
#endif
|
||||
|
||||
/* If not, define it so as to avoid dangling semicolons. */
|
||||
#ifndef __FBSDID
|
||||
#define __FBSDID(a) struct _undefined_hack
|
||||
#endif
|
||||
|
||||
#ifndef O_BINARY
|
||||
#define O_BINARY 0
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Redefine DEFINE_TEST for use in defining the test functions.
|
||||
*/
|
||||
#undef DEFINE_TEST
|
||||
#define DEFINE_TEST(name) void name(void); void name(void)
|
||||
|
||||
/* An implementation of the standard assert() macro */
|
||||
#define assert(e) assertion_assert(__FILE__, __LINE__, (e), #e, NULL)
|
||||
/* chdir() and error if it fails */
|
||||
#define assertChdir(path) \
|
||||
assertion_chdir(__FILE__, __LINE__, path)
|
||||
/* Assert two integers are the same. Reports value of each one if not. */
|
||||
#define assertEqualInt(v1,v2) \
|
||||
assertion_equal_int(__FILE__, __LINE__, (v1), #v1, (v2), #v2, NULL)
|
||||
/* Assert two strings are the same. Reports value of each one if not. */
|
||||
#define assertEqualString(v1,v2) \
|
||||
assertion_equal_string(__FILE__, __LINE__, (v1), #v1, (v2), #v2, NULL)
|
||||
/* As above, but v1 and v2 are wchar_t * */
|
||||
#define assertEqualWString(v1,v2) \
|
||||
assertion_equal_wstring(__FILE__, __LINE__, (v1), #v1, (v2), #v2, NULL)
|
||||
/* As above, but raw blocks of bytes. */
|
||||
#define assertEqualMem(v1, v2, l) \
|
||||
assertion_equal_mem(__FILE__, __LINE__, (v1), #v1, (v2), #v2, (l), #l, NULL)
|
||||
/* Assert two files are the same; allow printf-style expansion of second name.
|
||||
* See below for comments about variable arguments here...
|
||||
*/
|
||||
#define assertEqualFile \
|
||||
assertion_setup(__FILE__, __LINE__);assertion_equal_file
|
||||
/* Assert that a file is empty; supports printf-style arguments. */
|
||||
#define assertEmptyFile \
|
||||
assertion_setup(__FILE__, __LINE__);assertion_empty_file
|
||||
/* Assert that a file is not empty; supports printf-style arguments. */
|
||||
#define assertNonEmptyFile \
|
||||
assertion_setup(__FILE__, __LINE__);assertion_non_empty_file
|
||||
#define assertFileAtime(pathname, sec, nsec) \
|
||||
assertion_file_atime(__FILE__, __LINE__, pathname, sec, nsec)
|
||||
#define assertFileAtimeRecent(pathname) \
|
||||
assertion_file_atime_recent(__FILE__, __LINE__, pathname)
|
||||
#define assertFileBirthtime(pathname, sec, nsec) \
|
||||
assertion_file_birthtime(__FILE__, __LINE__, pathname, sec, nsec)
|
||||
#define assertFileBirthtimeRecent(pathname) \
|
||||
assertion_file_birthtime_recent(__FILE__, __LINE__, pathname)
|
||||
/* Assert that a file exists; supports printf-style arguments. */
|
||||
#define assertFileExists \
|
||||
assertion_setup(__FILE__, __LINE__);assertion_file_exists
|
||||
/* Assert that a file exists; supports printf-style arguments. */
|
||||
#define assertFileNotExists \
|
||||
assertion_setup(__FILE__, __LINE__);assertion_file_not_exists
|
||||
/* Assert that file contents match a string; supports printf-style arguments. */
|
||||
#define assertFileContents \
|
||||
assertion_setup(__FILE__, __LINE__);assertion_file_contents
|
||||
#define assertFileMtime(pathname, sec, nsec) \
|
||||
assertion_file_mtime(__FILE__, __LINE__, pathname, sec, nsec)
|
||||
#define assertFileMtimeRecent(pathname) \
|
||||
assertion_file_mtime_recent(__FILE__, __LINE__, pathname)
|
||||
#define assertFileNLinks(pathname, nlinks) \
|
||||
assertion_file_nlinks(__FILE__, __LINE__, pathname, nlinks)
|
||||
#define assertFileSize(pathname, size) \
|
||||
assertion_file_size(__FILE__, __LINE__, pathname, size)
|
||||
#define assertTextFileContents \
|
||||
assertion_setup(__FILE__, __LINE__);assertion_text_file_contents
|
||||
#define assertIsDir(pathname, mode) \
|
||||
assertion_is_dir(__FILE__, __LINE__, pathname, mode)
|
||||
#define assertIsHardlink(path1, path2) \
|
||||
assertion_is_hardlink(__FILE__, __LINE__, path1, path2)
|
||||
#define assertIsNotHardlink(path1, path2) \
|
||||
assertion_is_not_hardlink(__FILE__, __LINE__, path1, path2)
|
||||
#define assertIsReg(pathname, mode) \
|
||||
assertion_is_reg(__FILE__, __LINE__, pathname, mode)
|
||||
#define assertIsSymlink(pathname, contents) \
|
||||
assertion_is_symlink(__FILE__, __LINE__, pathname, contents)
|
||||
/* Create a directory, report error if it fails. */
|
||||
#define assertMakeDir(dirname, mode) \
|
||||
assertion_make_dir(__FILE__, __LINE__, dirname, mode)
|
||||
#define assertMakeFile(path, mode, contents) \
|
||||
assertion_make_file(__FILE__, __LINE__, path, mode, contents)
|
||||
#define assertMakeHardlink(newfile, oldfile) \
|
||||
assertion_make_hardlink(__FILE__, __LINE__, newfile, oldfile)
|
||||
#define assertMakeSymlink(newfile, linkto) \
|
||||
assertion_make_symlink(__FILE__, __LINE__, newfile, linkto)
|
||||
#define assertUmask(mask) \
|
||||
assertion_umask(__FILE__, __LINE__, mask)
|
||||
|
||||
/*
|
||||
* This would be simple with C99 variadic macros, but I don't want to
|
||||
* require that. Instead, I insert a function call before each
|
||||
* skipping() call to pass the file and line information down. Crude,
|
||||
* but effective.
|
||||
*/
|
||||
#define skipping \
|
||||
assertion_setup(__FILE__, __LINE__);test_skipping
|
||||
|
||||
/* Function declarations. These are defined in test_utility.c. */
|
||||
void failure(const char *fmt, ...);
|
||||
int assertion_assert(const char *, int, int, const char *, void *);
|
||||
int assertion_chdir(const char *, int, const char *);
|
||||
int assertion_empty_file(const char *, ...);
|
||||
int assertion_equal_file(const char *, const char *, ...);
|
||||
int assertion_equal_int(const char *, int, long long, const char *, long long, const char *, void *);
|
||||
int assertion_equal_mem(const char *, int, const void *, const char *, const void *, const char *, size_t, const char *, void *);
|
||||
int assertion_equal_string(const char *, int, const char *v1, const char *, const char *v2, const char *, void *);
|
||||
int assertion_equal_wstring(const char *, int, const wchar_t *v1, const char *, const wchar_t *v2, const char *, void *);
|
||||
int assertion_file_atime(const char *, int, const char *, long, long);
|
||||
int assertion_file_atime_recent(const char *, int, const char *);
|
||||
int assertion_file_birthtime(const char *, int, const char *, long, long);
|
||||
int assertion_file_birthtime_recent(const char *, int, const char *);
|
||||
int assertion_file_contents(const void *, int, const char *, ...);
|
||||
int assertion_file_exists(const char *, ...);
|
||||
int assertion_file_mtime(const char *, int, const char *, long, long);
|
||||
int assertion_file_mtime_recent(const char *, int, const char *);
|
||||
int assertion_file_nlinks(const char *, int, const char *, int);
|
||||
int assertion_file_not_exists(const char *, ...);
|
||||
int assertion_file_size(const char *, int, const char *, long);
|
||||
int assertion_is_dir(const char *, int, const char *, int);
|
||||
int assertion_is_hardlink(const char *, int, const char *, const char *);
|
||||
int assertion_is_not_hardlink(const char *, int, const char *, const char *);
|
||||
int assertion_is_reg(const char *, int, const char *, int);
|
||||
int assertion_is_symlink(const char *, int, const char *, const char *);
|
||||
int assertion_make_dir(const char *, int, const char *, int);
|
||||
int assertion_make_file(const char *, int, const char *, int, const char *);
|
||||
int assertion_make_hardlink(const char *, int, const char *newpath, const char *);
|
||||
int assertion_make_symlink(const char *, int, const char *newpath, const char *);
|
||||
int assertion_non_empty_file(const char *, ...);
|
||||
int assertion_text_file_contents(const char *buff, const char *f);
|
||||
int assertion_umask(const char *, int, int);
|
||||
void assertion_setup(const char *, int);
|
||||
|
||||
void test_skipping(const char *fmt, ...);
|
||||
|
||||
/* Like sprintf, then system() */
|
||||
int systemf(const char * fmt, ...);
|
||||
|
||||
/* Delay until time() returns a value after this. */
|
||||
void sleepUntilAfter(time_t);
|
||||
|
||||
/* Return true if this platform can create symlinks. */
|
||||
int canSymlink(void);
|
||||
|
||||
/* Return true if this platform can run the "gzip" program. */
|
||||
int canGzip(void);
|
||||
|
||||
/* Return true if this platform can run the "gunzip" program. */
|
||||
int canGunzip(void);
|
||||
|
||||
/* Suck file into string allocated via malloc(). Call free() when done. */
|
||||
/* Supports printf-style args: slurpfile(NULL, "%s/myfile", refdir); */
|
||||
char *slurpfile(size_t *, const char *fmt, ...);
|
||||
|
||||
/* Extracts named reference file to the current directory. */
|
||||
void extract_reference_file(const char *);
|
||||
|
||||
/*
|
||||
* Special interfaces for program test harness.
|
||||
*/
|
||||
|
||||
/* Pathname of exe to be tested. */
|
||||
const char *testprogfile;
|
||||
/* Name of exe to use in printf-formatted command strings. */
|
||||
/* On Windows, this includes leading/trailing quotes. */
|
||||
const char *testprog;
|
67
external/bsd/libarchive/dist/cpio/test/test_0.c
vendored
Normal file
67
external/bsd/libarchive/dist/cpio/test/test_0.c
vendored
Normal file
|
@ -0,0 +1,67 @@
|
|||
/*-
|
||||
* Copyright (c) 2003-2007 Tim Kientzle
|
||||
* 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(S) ``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(S) 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.
|
||||
*/
|
||||
#include "test.h"
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
/*
|
||||
* This first test does basic sanity checks on the environment. For
|
||||
* most of these, we just exit on failure.
|
||||
*/
|
||||
#if !defined(_WIN32) || defined(__CYGWIN__)
|
||||
#define DEV_NULL "/dev/null"
|
||||
#else
|
||||
#define DEV_NULL "NUL"
|
||||
#endif
|
||||
|
||||
DEFINE_TEST(test_0)
|
||||
{
|
||||
struct stat st;
|
||||
|
||||
failure("File %s does not exist?!", testprogfile);
|
||||
if (!assertEqualInt(0, stat(testprogfile, &st)))
|
||||
exit(1);
|
||||
|
||||
failure("%s is not executable?!", testprogfile);
|
||||
if (!assert((st.st_mode & 0111) != 0))
|
||||
exit(1);
|
||||
|
||||
/*
|
||||
* Try to succesfully run the program; this requires that
|
||||
* we know some option that will succeed.
|
||||
*/
|
||||
if (0 == systemf("%s --version >" DEV_NULL, testprog)) {
|
||||
/* This worked. */
|
||||
} else if (0 == systemf("%s -W version >" DEV_NULL, testprog)) {
|
||||
/* This worked. */
|
||||
} else {
|
||||
failure("Unable to successfully run any of the following:\n"
|
||||
" * %s --version\n"
|
||||
" * %s -W version\n",
|
||||
testprog, testprog);
|
||||
assert(0);
|
||||
}
|
||||
|
||||
/* TODO: Ensure that our reference files are available. */
|
||||
}
|
173
external/bsd/libarchive/dist/cpio/test/test_basic.c
vendored
Normal file
173
external/bsd/libarchive/dist/cpio/test/test_basic.c
vendored
Normal file
|
@ -0,0 +1,173 @@
|
|||
/*-
|
||||
* Copyright (c) 2003-2007 Tim Kientzle
|
||||
* 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(S) ``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(S) 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.
|
||||
*/
|
||||
#include "test.h"
|
||||
__FBSDID("$FreeBSD: src/usr.bin/cpio/test/test_basic.c,v 1.4 2008/08/25 06:39:29 kientzle Exp $");
|
||||
|
||||
static void
|
||||
verify_files(const char *msg)
|
||||
{
|
||||
/*
|
||||
* Verify unpacked files.
|
||||
*/
|
||||
|
||||
/* Regular file with 2 links. */
|
||||
assertIsReg("file", 0644);
|
||||
failure(msg);
|
||||
assertFileSize("file", 10);
|
||||
assertFileNLinks("file", 2);
|
||||
|
||||
/* Another name for the same file. */
|
||||
assertIsHardlink("linkfile", "file");
|
||||
|
||||
/* Symlink */
|
||||
if (canSymlink())
|
||||
assertIsSymlink("symlink", "file");
|
||||
|
||||
/* Another file with 1 link and different permissions. */
|
||||
assertIsReg("file2", 0777);
|
||||
assertFileSize("file2", 10);
|
||||
assertFileNLinks("file2", 1);
|
||||
|
||||
/* dir */
|
||||
assertIsDir("dir", 0775);
|
||||
}
|
||||
|
||||
static void
|
||||
basic_cpio(const char *target,
|
||||
const char *pack_options,
|
||||
const char *unpack_options,
|
||||
const char *se)
|
||||
{
|
||||
int r;
|
||||
|
||||
if (!assertMakeDir(target, 0775))
|
||||
return;
|
||||
|
||||
/* Use the cpio program to create an archive. */
|
||||
r = systemf("%s -o %s < filelist >%s/archive 2>%s/pack.err",
|
||||
testprog, pack_options, target, target);
|
||||
failure("Error invoking %s -o %s", testprog, pack_options);
|
||||
assertEqualInt(r, 0);
|
||||
|
||||
assertChdir(target);
|
||||
|
||||
/* Verify stderr. */
|
||||
failure("Expected: %s, options=%s", se, pack_options);
|
||||
assertTextFileContents(se, "pack.err");
|
||||
|
||||
/*
|
||||
* Use cpio to unpack the archive into another directory.
|
||||
*/
|
||||
r = systemf("%s -i %s< archive >unpack.out 2>unpack.err",
|
||||
testprog, unpack_options);
|
||||
failure("Error invoking %s -i %s", testprog, unpack_options);
|
||||
assertEqualInt(r, 0);
|
||||
|
||||
/* Verify stderr. */
|
||||
failure("Error invoking %s -i %s in dir %s", testprog, unpack_options, target);
|
||||
assertTextFileContents(se, "unpack.err");
|
||||
|
||||
verify_files(pack_options);
|
||||
|
||||
assertChdir("..");
|
||||
}
|
||||
|
||||
static void
|
||||
passthrough(const char *target)
|
||||
{
|
||||
int r;
|
||||
|
||||
if (!assertMakeDir(target, 0775))
|
||||
return;
|
||||
|
||||
/*
|
||||
* Use cpio passthrough mode to copy files to another directory.
|
||||
*/
|
||||
r = systemf("%s -p %s <filelist >%s/stdout 2>%s/stderr",
|
||||
testprog, target, target, target);
|
||||
failure("Error invoking %s -p", testprog);
|
||||
assertEqualInt(r, 0);
|
||||
|
||||
assertChdir(target);
|
||||
|
||||
/* Verify stderr. */
|
||||
failure("Error invoking %s -p in dir %s",
|
||||
testprog, target);
|
||||
assertTextFileContents("1 block\n", "stderr");
|
||||
|
||||
verify_files("passthrough");
|
||||
assertChdir("..");
|
||||
}
|
||||
|
||||
DEFINE_TEST(test_basic)
|
||||
{
|
||||
FILE *filelist;
|
||||
const char *msg;
|
||||
|
||||
assertUmask(0);
|
||||
|
||||
/*
|
||||
* Create an assortment of files on disk.
|
||||
*/
|
||||
filelist = fopen("filelist", "w");
|
||||
|
||||
/* File with 10 bytes content. */
|
||||
assertMakeFile("file", 0644, "1234567890");
|
||||
fprintf(filelist, "file\n");
|
||||
|
||||
/* hardlink to above file. */
|
||||
assertMakeHardlink("linkfile", "file");
|
||||
fprintf(filelist, "linkfile\n");
|
||||
|
||||
/* Symlink to above file. */
|
||||
if (canSymlink()) {
|
||||
assertMakeSymlink("symlink", "file");
|
||||
fprintf(filelist, "symlink\n");
|
||||
}
|
||||
|
||||
/* Another file with different permissions. */
|
||||
assertMakeFile("file2", 0777, "1234567890");
|
||||
fprintf(filelist, "file2\n");
|
||||
|
||||
/* Directory. */
|
||||
assertMakeDir("dir", 0775);
|
||||
fprintf(filelist, "dir\n");
|
||||
/* All done. */
|
||||
fclose(filelist);
|
||||
|
||||
assertUmask(022);
|
||||
|
||||
/* Archive/dearchive with a variety of options. */
|
||||
msg = canSymlink() ? "2 blocks\n" : "1 block\n";
|
||||
basic_cpio("copy", "", "", msg);
|
||||
basic_cpio("copy_odc", "--format=odc", "", msg);
|
||||
basic_cpio("copy_newc", "-H newc", "", "2 blocks\n");
|
||||
basic_cpio("copy_cpio", "-H odc", "", msg);
|
||||
msg = canSymlink() ? "9 blocks\n" : "8 blocks\n";
|
||||
basic_cpio("copy_ustar", "-H ustar", "", msg);
|
||||
|
||||
/* Copy in one step using -p */
|
||||
passthrough("passthrough");
|
||||
}
|
107
external/bsd/libarchive/dist/cpio/test/test_cmdline.c
vendored
Normal file
107
external/bsd/libarchive/dist/cpio/test/test_cmdline.c
vendored
Normal file
|
@ -0,0 +1,107 @@
|
|||
/*-
|
||||
* Copyright (c) 2003-2009 Tim Kientzle
|
||||
* 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(S) ``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(S) 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.
|
||||
*/
|
||||
#include "test.h"
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
/*
|
||||
* Test the command-line parsing.
|
||||
*/
|
||||
|
||||
DEFINE_TEST(test_cmdline)
|
||||
{
|
||||
FILE *f;
|
||||
|
||||
/* Create an empty file. */
|
||||
f = fopen("empty", "wb");
|
||||
assert(f != NULL);
|
||||
fclose(f);
|
||||
|
||||
failure("-Q is an invalid option on every cpio program I know of");
|
||||
assert(0 != systemf("%s -i -Q <empty >1.out 2>1.err", testprog));
|
||||
assertEmptyFile("1.out");
|
||||
|
||||
failure("-f requires an argument");
|
||||
assert(0 != systemf("%s -if <empty >2.out 2>2.err", testprog));
|
||||
assertEmptyFile("2.out");
|
||||
|
||||
failure("-f requires an argument");
|
||||
assert(0 != systemf("%s -i -f <empty >3.out 2>3.err", testprog));
|
||||
assertEmptyFile("3.out");
|
||||
|
||||
failure("--format requires an argument");
|
||||
assert(0 != systemf("%s -i --format <empty >4.out 2>4.err", testprog));
|
||||
assertEmptyFile("4.out");
|
||||
|
||||
failure("--badopt is an invalid option");
|
||||
assert(0 != systemf("%s -i --badop <empty >5.out 2>5.err", testprog));
|
||||
assertEmptyFile("5.out");
|
||||
|
||||
failure("--badopt is an invalid option");
|
||||
assert(0 != systemf("%s -i --badopt <empty >6.out 2>6.err", testprog));
|
||||
assertEmptyFile("6.out");
|
||||
|
||||
failure("--n is ambiguous");
|
||||
assert(0 != systemf("%s -i --n <empty >7.out 2>7.err", testprog));
|
||||
assertEmptyFile("7.out");
|
||||
|
||||
failure("--create forbids an argument");
|
||||
assert(0 != systemf("%s --create=arg <empty >8.out 2>8.err", testprog));
|
||||
assertEmptyFile("8.out");
|
||||
|
||||
failure("-i with empty input should succeed");
|
||||
assert(0 == systemf("%s -i <empty >9.out 2>9.err", testprog));
|
||||
assertEmptyFile("9.out");
|
||||
|
||||
failure("-o with empty input should succeed");
|
||||
assert(0 == systemf("%s -o <empty >10.out 2>10.err", testprog));
|
||||
|
||||
failure("-i -p is nonsense");
|
||||
assert(0 != systemf("%s -i -p <empty >11.out 2>11.err", testprog));
|
||||
assertEmptyFile("11.out");
|
||||
|
||||
failure("-p -i is nonsense");
|
||||
assert(0 != systemf("%s -p -i <empty >12.out 2>12.err", testprog));
|
||||
assertEmptyFile("12.out");
|
||||
|
||||
failure("-i -o is nonsense");
|
||||
assert(0 != systemf("%s -i -o <empty >13.out 2>13.err", testprog));
|
||||
assertEmptyFile("13.out");
|
||||
|
||||
failure("-o -i is nonsense");
|
||||
assert(0 != systemf("%s -o -i <empty >14.out 2>14.err", testprog));
|
||||
assertEmptyFile("14.out");
|
||||
|
||||
failure("-o -p is nonsense");
|
||||
assert(0 != systemf("%s -o -p <empty >15.out 2>15.err", testprog));
|
||||
assertEmptyFile("15.out");
|
||||
|
||||
failure("-p -o is nonsense");
|
||||
assert(0 != systemf("%s -p -o <empty >16.out 2>16.err", testprog));
|
||||
assertEmptyFile("16.out");
|
||||
|
||||
failure("-p with empty input should fail");
|
||||
assert(0 != systemf("%s -p <empty >17.out 2>17.err", testprog));
|
||||
assertEmptyFile("17.out");
|
||||
}
|
294
external/bsd/libarchive/dist/cpio/test/test_format_newc.c
vendored
Normal file
294
external/bsd/libarchive/dist/cpio/test/test_format_newc.c
vendored
Normal file
|
@ -0,0 +1,294 @@
|
|||
/*-
|
||||
* Copyright (c) 2003-2007 Tim Kientzle
|
||||
* 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(S) ``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(S) 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.
|
||||
*/
|
||||
#include "test.h"
|
||||
__FBSDID("$FreeBSD: src/usr.bin/cpio/test/test_format_newc.c,v 1.2 2008/08/22 02:09:10 kientzle Exp $");
|
||||
|
||||
/* Number of bytes needed to pad 'n' to multiple of 'block', assuming
|
||||
* that 'block' is a power of two. This trick can be more easily
|
||||
* remembered as -n & (block - 1), but many compilers quite reasonably
|
||||
* warn about "-n" when n is an unsigned value. (~(n) + 1) is the
|
||||
* same thing, but written in a way that won't offend anyone. */
|
||||
#define PAD(n, block) ((~(n) + 1) & ((block) - 1))
|
||||
|
||||
static int
|
||||
is_hex(const char *p, size_t l)
|
||||
{
|
||||
while (l > 0) {
|
||||
if ((*p >= '0' && *p <= '9')
|
||||
|| (*p >= 'a' && *p <= 'f')
|
||||
|| (*p >= 'A' && *p <= 'F'))
|
||||
{
|
||||
--l;
|
||||
++p;
|
||||
} else
|
||||
return (0);
|
||||
|
||||
}
|
||||
return (1);
|
||||
}
|
||||
|
||||
static int
|
||||
from_hex(const char *p, size_t l)
|
||||
{
|
||||
int r = 0;
|
||||
|
||||
while (l > 0) {
|
||||
r *= 16;
|
||||
if (*p >= 'a' && *p <= 'f')
|
||||
r += *p + 10 - 'a';
|
||||
else if (*p >= 'A' && *p <= 'F')
|
||||
r += *p + 10 - 'A';
|
||||
else
|
||||
r += *p - '0';
|
||||
--l;
|
||||
++p;
|
||||
}
|
||||
return (r);
|
||||
}
|
||||
|
||||
DEFINE_TEST(test_format_newc)
|
||||
{
|
||||
FILE *list;
|
||||
int r;
|
||||
int devmajor, devminor, ino, gid;
|
||||
int uid = -1;
|
||||
time_t t, t2, now;
|
||||
char *p, *e;
|
||||
size_t s, fs, ns;
|
||||
|
||||
assertUmask(0);
|
||||
|
||||
#if !defined(_WIN32)
|
||||
uid = getuid();
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Create an assortment of files.
|
||||
* TODO: Extend this to cover more filetypes.
|
||||
*/
|
||||
list = fopen("list", "w");
|
||||
|
||||
/* "file1" */
|
||||
assertMakeFile("file1", 0644, "1234567890");
|
||||
fprintf(list, "file1\n");
|
||||
|
||||
/* "hardlink" */
|
||||
assertMakeHardlink("hardlink", "file1");
|
||||
fprintf(list, "hardlink\n");
|
||||
|
||||
/* Another hardlink, but this one won't be archived. */
|
||||
assertMakeHardlink("hardlink2", "file1");
|
||||
|
||||
/* "symlink" */
|
||||
if (canSymlink()) {
|
||||
assertMakeSymlink("symlink", "file1");
|
||||
fprintf(list, "symlink\n");
|
||||
}
|
||||
|
||||
/* "dir" */
|
||||
assertMakeDir("dir", 0775);
|
||||
fprintf(list, "dir\n");
|
||||
|
||||
/* Record some facts about what we just created: */
|
||||
now = time(NULL); /* They were all created w/in last two seconds. */
|
||||
|
||||
/* Use the cpio program to create an archive. */
|
||||
fclose(list);
|
||||
r = systemf("%s -o --format=newc <list >newc.out 2>newc.err",
|
||||
testprog);
|
||||
if (!assertEqualInt(r, 0))
|
||||
return;
|
||||
|
||||
/* Verify that nothing went to stderr. */
|
||||
if (canSymlink()) {
|
||||
assertTextFileContents("2 blocks\n", "newc.err");
|
||||
} else {
|
||||
assertTextFileContents("1 block\n", "newc.err");
|
||||
}
|
||||
|
||||
/* Verify that stdout is a well-formed cpio file in "newc" format. */
|
||||
p = slurpfile(&s, "newc.out");
|
||||
assertEqualInt(s, canSymlink() ? 1024 : 512);
|
||||
e = p;
|
||||
|
||||
/*
|
||||
* Some of these assertions could be stronger, but it's
|
||||
* a little tricky because they depend on the local environment.
|
||||
*/
|
||||
|
||||
/* First entry is "file1" */
|
||||
assert(is_hex(e, 110)); /* Entire header is octal digits. */
|
||||
assertEqualMem(e + 0, "070701", 6); /* Magic */
|
||||
ino = from_hex(e + 6, 8); /* ino */
|
||||
#if defined(_WIN32) && !defined(__CYGWIN__)
|
||||
/* Group members bits and others bits do not work. */
|
||||
assertEqualInt(0x8180, from_hex(e + 14, 8) & 0xffc0); /* Mode */
|
||||
#else
|
||||
assertEqualInt(0x81a4, from_hex(e + 14, 8)); /* Mode */
|
||||
#endif
|
||||
if (uid < 0)
|
||||
uid = from_hex(e + 22, 8);
|
||||
assertEqualInt(from_hex(e + 22, 8), uid); /* uid */
|
||||
gid = from_hex(e + 30, 8); /* gid */
|
||||
assertEqualMem(e + 38, "00000003", 8); /* nlink */
|
||||
t = from_hex(e + 46, 8); /* mtime */
|
||||
failure("t=0x%08x now=0x%08x=%d", t, now, now);
|
||||
assert(t <= now); /* File wasn't created in future. */
|
||||
failure("t=0x%08x now - 2=0x%08x = %d", t, now - 2, now - 2);
|
||||
assert(t >= now - 2); /* File was created w/in last 2 secs. */
|
||||
failure("newc format stores body only with last appearance of a link\n"
|
||||
" first appearance should be empty, so this file size\n"
|
||||
" field should be zero");
|
||||
assertEqualInt(0, from_hex(e + 54, 8)); /* File size */
|
||||
fs = from_hex(e + 54, 8);
|
||||
fs += PAD(fs, 4);
|
||||
devmajor = from_hex(e + 62, 8); /* devmajor */
|
||||
devminor = from_hex(e + 70, 8); /* devminor */
|
||||
assert(is_hex(e + 78, 8)); /* rdevmajor */
|
||||
assert(is_hex(e + 86, 8)); /* rdevminor */
|
||||
assertEqualMem(e + 94, "00000006", 8); /* Name size */
|
||||
ns = from_hex(e + 94, 8);
|
||||
ns += PAD(ns + 2, 4);
|
||||
assertEqualInt(0, from_hex(e + 102, 8)); /* check field */
|
||||
assertEqualMem(e + 110, "file1\0", 6); /* Name contents */
|
||||
/* Since there's another link, no file contents here. */
|
||||
/* But add in file size so that an error here doesn't cascade. */
|
||||
e += 110 + fs + ns;
|
||||
|
||||
if (canSymlink()) {
|
||||
/* "symlink" pointing to "file1" */
|
||||
assert(is_hex(e, 110));
|
||||
assertEqualMem(e + 0, "070701", 6); /* Magic */
|
||||
assert(is_hex(e + 6, 8)); /* ino */
|
||||
assertEqualInt(0xa1ff, from_hex(e + 14, 8)); /* Mode */
|
||||
assertEqualInt(from_hex(e + 22, 8), uid); /* uid */
|
||||
assertEqualInt(gid, from_hex(e + 30, 8)); /* gid */
|
||||
assertEqualMem(e + 38, "00000001", 8); /* nlink */
|
||||
t2 = from_hex(e + 46, 8); /* mtime */
|
||||
failure("First entry created at t=0x%08x this entry created at t2=0x%08x", t, t2);
|
||||
assert(t2 == t || t2 == t + 1); /* Almost same as first entry. */
|
||||
assertEqualMem(e + 54, "00000005", 8); /* File size */
|
||||
fs = from_hex(e + 54, 8);
|
||||
fs += PAD(fs, 4);
|
||||
assertEqualInt(devmajor, from_hex(e + 62, 8)); /* devmajor */
|
||||
assertEqualInt(devminor, from_hex(e + 70, 8)); /* devminor */
|
||||
assert(is_hex(e + 78, 8)); /* rdevmajor */
|
||||
assert(is_hex(e + 86, 8)); /* rdevminor */
|
||||
assertEqualMem(e + 94, "00000008", 8); /* Name size */
|
||||
ns = from_hex(e + 94, 8);
|
||||
ns += PAD(ns + 2, 4);
|
||||
assertEqualInt(0, from_hex(e + 102, 8)); /* check field */
|
||||
assertEqualMem(e + 110, "symlink\0\0\0", 10); /* Name contents */
|
||||
assertEqualMem(e + 110 + ns, "file1\0\0\0", 8); /* symlink target */
|
||||
e += 110 + fs + ns;
|
||||
}
|
||||
|
||||
/* "dir" */
|
||||
assert(is_hex(e, 110));
|
||||
assertEqualMem(e + 0, "070701", 6); /* Magic */
|
||||
assert(is_hex(e + 6, 8)); /* ino */
|
||||
#if defined(_WIN32) && !defined(__CYGWIN__)
|
||||
/* Group members bits and others bits do not work. */
|
||||
assertEqualInt(0x41c0, from_hex(e + 14, 8) & 0xffc0); /* Mode */
|
||||
#else
|
||||
/* Mode: sgid bit sometimes propagates from parent dirs, ignore it. */
|
||||
assertEqualInt(040775, from_hex(e + 14, 8) & ~02000);
|
||||
#endif
|
||||
assertEqualInt(from_hex(e + 22, 8), uid); /* uid */
|
||||
assertEqualInt(gid, from_hex(e + 30, 8)); /* gid */
|
||||
#ifndef NLINKS_INACCURATE_FOR_DIRS
|
||||
assertEqualMem(e + 38, "00000002", 8); /* nlink */
|
||||
#endif
|
||||
t2 = from_hex(e + 46, 8); /* mtime */
|
||||
failure("First entry created at t=0x%08x this entry created at t2=0x%08x", t, t2);
|
||||
assert(t2 == t || t2 == t + 1); /* Almost same as first entry. */
|
||||
assertEqualMem(e + 54, "00000000", 8); /* File size */
|
||||
fs = from_hex(e + 54, 8);
|
||||
fs += PAD(fs, 4);
|
||||
assertEqualInt(devmajor, from_hex(e + 62, 8)); /* devmajor */
|
||||
assertEqualInt(devminor, from_hex(e + 70, 8)); /* devminor */
|
||||
assert(is_hex(e + 78, 8)); /* rdevmajor */
|
||||
assert(is_hex(e + 86, 8)); /* rdevminor */
|
||||
assertEqualMem(e + 94, "00000004", 8); /* Name size */
|
||||
ns = from_hex(e + 94, 8);
|
||||
ns += PAD(ns + 2, 4);
|
||||
assertEqualInt(0, from_hex(e + 102, 8)); /* check field */
|
||||
assertEqualMem(e + 110, "dir\0\0\0", 6); /* Name contents */
|
||||
e += 110 + fs + ns;
|
||||
|
||||
/* Hardlink identical to "file1" */
|
||||
/* Since we only wrote two of the three links to this
|
||||
* file, this link should get deferred by the hardlink logic. */
|
||||
assert(is_hex(e, 110));
|
||||
assertEqualMem(e + 0, "070701", 6); /* Magic */
|
||||
failure("If these aren't the same, then the hardlink detection failed to match them.");
|
||||
assertEqualInt(ino, from_hex(e + 6, 8)); /* ino */
|
||||
#if defined(_WIN32) && !defined(__CYGWIN__)
|
||||
/* Group members bits and others bits do not work. */
|
||||
assertEqualInt(0x8180, from_hex(e + 14, 8) & 0xffc0); /* Mode */
|
||||
#else
|
||||
assertEqualInt(0x81a4, from_hex(e + 14, 8)); /* Mode */
|
||||
#endif
|
||||
assertEqualInt(from_hex(e + 22, 8), uid); /* uid */
|
||||
assertEqualInt(gid, from_hex(e + 30, 8)); /* gid */
|
||||
assertEqualMem(e + 38, "00000003", 8); /* nlink */
|
||||
t2 = from_hex(e + 46, 8); /* mtime */
|
||||
failure("First entry created at t=0x%08x this entry created at t2=0x%08x", t, t2);
|
||||
assert(t2 == t || t2 == t + 1); /* Almost same as first entry. */
|
||||
assertEqualInt(10, from_hex(e + 54, 8)); /* File size */
|
||||
fs = from_hex(e + 54, 8);
|
||||
fs += PAD(fs, 4);
|
||||
assertEqualInt(devmajor, from_hex(e + 62, 8)); /* devmajor */
|
||||
assertEqualInt(devminor, from_hex(e + 70, 8)); /* devminor */
|
||||
assert(is_hex(e + 78, 8)); /* rdevmajor */
|
||||
assert(is_hex(e + 86, 8)); /* rdevminor */
|
||||
assertEqualMem(e + 94, "00000009", 8); /* Name size */
|
||||
ns = from_hex(e + 94, 8);
|
||||
ns += PAD(ns + 2, 4);
|
||||
assertEqualInt(0, from_hex(e + 102, 8)); /* check field */
|
||||
assertEqualMem(e + 110, "hardlink\0\0", 10); /* Name contents */
|
||||
assertEqualMem(e + 110 + ns, "1234567890\0\0", 12); /* File contents */
|
||||
e += 110 + ns + fs;
|
||||
|
||||
/* Last entry is end-of-archive marker. */
|
||||
assert(is_hex(e, 110));
|
||||
assertEqualMem(e + 0, "070701", 6); /* Magic */
|
||||
assertEqualMem(e + 8, "00000000", 8); /* ino */
|
||||
assertEqualMem(e + 14, "00000000", 8); /* mode */
|
||||
assertEqualMem(e + 22, "00000000", 8); /* uid */
|
||||
assertEqualMem(e + 30, "00000000", 8); /* gid */
|
||||
assertEqualMem(e + 38, "00000001", 8); /* nlink */
|
||||
assertEqualMem(e + 46, "00000000", 8); /* mtime */
|
||||
assertEqualMem(e + 54, "00000000", 8); /* size */
|
||||
assertEqualMem(e + 62, "00000000", 8); /* devmajor */
|
||||
assertEqualMem(e + 70, "00000000", 8); /* devminor */
|
||||
assertEqualMem(e + 78, "00000000", 8); /* rdevmajor */
|
||||
assertEqualMem(e + 86, "00000000", 8); /* rdevminor */
|
||||
assertEqualInt(11, from_hex(e + 94, 8)); /* name size */
|
||||
assertEqualMem(e + 102, "00000000", 8); /* check field */
|
||||
assertEqualMem(e + 110, "TRAILER!!!\0\0", 12); /* Name */
|
||||
|
||||
free(p);
|
||||
}
|
108
external/bsd/libarchive/dist/cpio/test/test_gcpio_compat.c
vendored
Normal file
108
external/bsd/libarchive/dist/cpio/test/test_gcpio_compat.c
vendored
Normal file
|
@ -0,0 +1,108 @@
|
|||
/*-
|
||||
* Copyright (c) 2003-2007 Tim Kientzle
|
||||
* 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(S) ``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(S) 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.
|
||||
*/
|
||||
#include "test.h"
|
||||
__FBSDID("$FreeBSD: src/usr.bin/cpio/test/test_gcpio_compat.c,v 1.2 2008/08/22 02:27:06 kientzle Exp $");
|
||||
|
||||
static void
|
||||
unpack_test(const char *from, const char *options, const char *se)
|
||||
{
|
||||
int r;
|
||||
|
||||
/* Create a work dir named after the file we're unpacking. */
|
||||
assertMakeDir(from, 0775);
|
||||
assertChdir(from);
|
||||
|
||||
/*
|
||||
* Use cpio to unpack the sample archive
|
||||
*/
|
||||
extract_reference_file(from);
|
||||
r = systemf("%s -i %s < %s >unpack.out 2>unpack.err",
|
||||
testprog, options, from);
|
||||
failure("Error invoking %s -i %s < %s",
|
||||
testprog, options, from);
|
||||
assertEqualInt(r, 0);
|
||||
|
||||
/* Verify that nothing went to stderr. */
|
||||
if (canSymlink()) {
|
||||
failure("Error invoking %s -i %s < %s",
|
||||
testprog, options, from);
|
||||
assertTextFileContents(se, "unpack.err");
|
||||
}
|
||||
|
||||
/*
|
||||
* Verify unpacked files.
|
||||
*/
|
||||
|
||||
/* Regular file with 2 links. */
|
||||
assertIsReg("file", 0644);
|
||||
failure("%s", from);
|
||||
assertFileSize("file", 10);
|
||||
assertFileSize("linkfile", 10);
|
||||
failure("%s", from);
|
||||
assertFileNLinks("file", 2);
|
||||
|
||||
/* Another name for the same file. */
|
||||
failure("%s", from);
|
||||
assertIsHardlink("linkfile", "file");
|
||||
assertFileSize("file", 10);
|
||||
assertFileSize("linkfile", 10);
|
||||
|
||||
/* Symlink */
|
||||
if (canSymlink())
|
||||
assertIsSymlink("symlink", "file");
|
||||
|
||||
/* dir */
|
||||
assertIsDir("dir", 0775);
|
||||
|
||||
assertChdir("..");
|
||||
}
|
||||
|
||||
DEFINE_TEST(test_gcpio_compat)
|
||||
{
|
||||
assertUmask(0);
|
||||
|
||||
/* Dearchive sample files with a variety of options. */
|
||||
if (canSymlink()) {
|
||||
unpack_test("test_gcpio_compat_ref.bin",
|
||||
"--no-preserve-owner", "1 block\n");
|
||||
unpack_test("test_gcpio_compat_ref.crc",
|
||||
"--no-preserve-owner", "2 blocks\n");
|
||||
unpack_test("test_gcpio_compat_ref.newc",
|
||||
"--no-preserve-owner", "2 blocks\n");
|
||||
/* gcpio-2.9 only reads 6 blocks here */
|
||||
unpack_test("test_gcpio_compat_ref.ustar",
|
||||
"--no-preserve-owner", "7 blocks\n");
|
||||
} else {
|
||||
unpack_test("test_gcpio_compat_ref_nosym.bin",
|
||||
"--no-preserve-owner", "1 block\n");
|
||||
unpack_test("test_gcpio_compat_ref_nosym.crc",
|
||||
"--no-preserve-owner", "2 blocks\n");
|
||||
unpack_test("test_gcpio_compat_ref_nosym.newc",
|
||||
"--no-preserve-owner", "2 blocks\n");
|
||||
/* gcpio-2.9 only reads 6 blocks here */
|
||||
unpack_test("test_gcpio_compat_ref_nosym.ustar",
|
||||
"--no-preserve-owner", "7 blocks\n");
|
||||
}
|
||||
}
|
16
external/bsd/libarchive/dist/cpio/test/test_gcpio_compat_ref.bin.uu
vendored
Normal file
16
external/bsd/libarchive/dist/cpio/test/test_gcpio_compat_ref.bin.uu
vendored
Normal file
|
@ -0,0 +1,16 @@
|
|||
$FreeBSD$
|
||||
begin 644 test_gcpio_compat_ref.bin
|
||||
MQW%9`*IWI('H`^@#`@````U'=YD%````"@!F:6QE```Q,C,T-38W.#D*QW%9
|
||||
M`*IWI('H`^@#`@````U'=YD)````"@!L:6YK9FEL90``,3(S-#4V-S@Y"L=Q
|
||||
M60"K=^VAZ`/H`P$````-1X29"`````0`<WEM;&EN:P!F:6QEQW%9`*YW_4'H
|
||||
M`^@#`@````U'A9D$``````!D:7(`QW$``````````````0`````````+````
|
||||
M``!44D%)3$52(2$A````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
1````````````````````````
|
||||
`
|
||||
end
|
27
external/bsd/libarchive/dist/cpio/test/test_gcpio_compat_ref.crc.uu
vendored
Normal file
27
external/bsd/libarchive/dist/cpio/test/test_gcpio_compat_ref.crc.uu
vendored
Normal file
|
@ -0,0 +1,27 @@
|
|||
$FreeBSD$
|
||||
begin 644 test_gcpio_compat_ref.crc
|
||||
M,#<P-S`R,#`S,S<W86$P,#`P.#%A-#`P,#`P,V4X,#`P,#`S93@P,#`P,#`P
|
||||
M,C0W,&0Y.3<W,#`P,#`P,#`P,#`P,#`P,#`P,#`P,#4Y,#`P,#`P,#`P,#`P
|
||||
M,#`P,#`P,#`P,#`U,#`P,#`P,#!F:6QE```P-S`W,#(P,#,S-S=A83`P,#`X
|
||||
M,6$T,#`P,#`S93@P,#`P,#-E.#`P,#`P,#`R-#<P9#DY-S<P,#`P,#`P83`P
|
||||
M,#`P,#`P,#`P,#`P-3DP,#`P,#`P,#`P,#`P,#`P,#`P,#`P,#DP,#`P,#%E
|
||||
M-VQI;FMF:6QE```Q,C,T-38W.#D*```P-S`W,#(P,#,S-S=A8C`P,#!A,65D
|
||||
M,#`P,#`S93@P,#`P,#-E.#`P,#`P,#`Q-#<P9#DY.#0P,#`P,#`P-#`P,#`P
|
||||
M,#`P,#`P,#`P-3DP,#`P,#`P,#`P,#`P,#`P,#`P,#`P,#@P,#`P,#`P,'-Y
|
||||
M;6QI;FL```!F:6QE,#<P-S`R,#`S,S<W864P,#`P-#%F9#`P,#`P,V4X,#`P
|
||||
M,#`S93@P,#`P,#`P,C0W,&0Y.3@U,#`P,#`P,#`P,#`P,#`P,#`P,#`P,#4Y
|
||||
M,#`P,#`P,#`P,#`P,#`P,#`P,#`P,#`T,#`P,#`P,#!D:7(````P-S`W,#(P
|
||||
M,#`P,#`P,#`P,#`P,#`P,#`P,#`P,#`P,#`P,#`P,#`P,#`P,#`Q,#`P,#`P
|
||||
M,#`P,#`P,#`P,#`P,#`P,#`P,#`P,#`P,#`P,#`P,#`P,#`P,#`P,#`P,#`P
|
||||
M,#`P,&(P,#`P,#`P,%1204E,15(A(2$`````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
B````````````````````````````````````````````````
|
||||
`
|
||||
end
|
27
external/bsd/libarchive/dist/cpio/test/test_gcpio_compat_ref.newc.uu
vendored
Normal file
27
external/bsd/libarchive/dist/cpio/test/test_gcpio_compat_ref.newc.uu
vendored
Normal file
|
@ -0,0 +1,27 @@
|
|||
$FreeBSD$
|
||||
begin 644 test_gcpio_compat_ref.newc
|
||||
M,#<P-S`Q,#`S,S<W86$P,#`P.#%A-#`P,#`P,V4X,#`P,#`S93@P,#`P,#`P
|
||||
M,C0W,&0Y.3<W,#`P,#`P,#`P,#`P,#`P,#`P,#`P,#4Y,#`P,#`P,#`P,#`P
|
||||
M,#`P,#`P,#`P,#`U,#`P,#`P,#!F:6QE```P-S`W,#$P,#,S-S=A83`P,#`X
|
||||
M,6$T,#`P,#`S93@P,#`P,#-E.#`P,#`P,#`R-#<P9#DY-S<P,#`P,#`P83`P
|
||||
M,#`P,#`P,#`P,#`P-3DP,#`P,#`P,#`P,#`P,#`P,#`P,#`P,#DP,#`P,#`P
|
||||
M,&QI;FMF:6QE```Q,C,T-38W.#D*```P-S`W,#$P,#,S-S=A8C`P,#!A,65D
|
||||
M,#`P,#`S93@P,#`P,#-E.#`P,#`P,#`Q-#<P9#DY.#0P,#`P,#`P-#`P,#`P
|
||||
M,#`P,#`P,#`P-3DP,#`P,#`P,#`P,#`P,#`P,#`P,#`P,#@P,#`P,#`P,'-Y
|
||||
M;6QI;FL```!F:6QE,#<P-S`Q,#`S,S<W864P,#`P-#%F9#`P,#`P,V4X,#`P
|
||||
M,#`S93@P,#`P,#`P,C0W,&0Y.3@U,#`P,#`P,#`P,#`P,#`P,#`P,#`P,#4Y
|
||||
M,#`P,#`P,#`P,#`P,#`P,#`P,#`P,#`T,#`P,#`P,#!D:7(````P-S`W,#$P
|
||||
M,#`P,#`P,#`P,#`P,#`P,#`P,#`P,#`P,#`P,#`P,#`P,#`P,#`Q,#`P,#`P
|
||||
M,#`P,#`P,#`P,#`P,#`P,#`P,#`P,#`P,#`P,#`P,#`P,#`P,#`P,#`P,#`P
|
||||
M,#`P,&(P,#`P,#`P,%1204E,15(A(2$`````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
B````````````````````````````````````````````````
|
||||
`
|
||||
end
|
84
external/bsd/libarchive/dist/cpio/test/test_gcpio_compat_ref.ustar.uu
vendored
Normal file
84
external/bsd/libarchive/dist/cpio/test/test_gcpio_compat_ref.ustar.uu
vendored
Normal file
|
@ -0,0 +1,84 @@
|
|||
$FreeBSD$
|
||||
begin 644 test_gcpio_compat_ref.ustar
|
||||
M9FEL90``````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M`````````````#`P,#`V-#0`,#`P,3<U,``P,#`Q-S4P`#`P,#`P,#`P,#$R
|
||||
M`#$P-S`S,S$T-38W`#`P,3$S-C,`,```````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M``````````````````````````````````````````!U<W1A<@`P,'1I;0``
|
||||
M````````````````````````````````````=&EM````````````````````
|
||||
M```````````````````P,#`P,#`P`#`P,#`P,#``````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M```````````````````````Q,C,T-38W.#D*````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M`````````````````````````````````````````````&QI;FMF:6QE````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M```````````````````````````````````````````````````````````P
|
||||
M,#`P-C0T`#`P,#$W-3``,#`P,3<U,``P,#`P,#`P,#`P,``Q,#<P,S,Q-#4V
|
||||
M-P`P,#$S,#<W`#%F:6QE````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````=7-T87(`,#!T:6T`````````````````
|
||||
M`````````````````````'1I;0``````````````````````````````````
|
||||
M````,#`P,#`P,``P,#`P,#`P````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````<WEM;&EN:P``````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M`````````````````````#`P,#`W-34`,#`P,3<U,``P,#`Q-S4P`#`P,#`P
|
||||
M,#`P,#`P`#$P-S`S,S$T-C`T`#`P,3(W-C0`,F9I;&4`````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M``````````````````````````````````````````````````!U<W1A<@`P
|
||||
M,'1I;0``````````````````````````````````````=&EM````````````
|
||||
M```````````````````````````P,#`P,#`P`#`P,#`P,#``````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M``````````````````````````````!D:7(O````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````,#`P,#<W-0`P,#`Q
|
||||
M-S4P`#`P,#$W-3``,#`P,#`P,#`P,#``,3`W,#,S,30V,#4`,#`Q,3,P,0`U
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M`````````````'5S=&%R`#`P=&EM````````````````````````````````
|
||||
M``````!T:6T``````````````````````````````````````#`P,#`P,#``
|
||||
M,#`P,#`P,```````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
=````````````````````````````````````````
|
||||
`
|
||||
end
|
15
external/bsd/libarchive/dist/cpio/test/test_gcpio_compat_ref_nosym.bin.uu
vendored
Normal file
15
external/bsd/libarchive/dist/cpio/test/test_gcpio_compat_ref_nosym.bin.uu
vendored
Normal file
|
@ -0,0 +1,15 @@
|
|||
begin 644 test_gcpio_compat_ref_nosym.bin
|
||||
MQW%4`-[Z_4'H`^@#`@`VNZU*NQX$``````!D:7(`QW%4`-SZI('H`^@#`@`G
|
||||
MNZU*NQX%````"@!F:6QE```Q,C,T-38W.#D*QW%4`-SZI('H`^@#`@`GNZU*
|
||||
MNQX)````"@!L:6YK9FEL90``,3(S-#4V-S@Y"L=Q``````````````$`````
|
||||
M````"P``````5%)!24Q%4B$A(0``````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
1````````````````````````
|
||||
`
|
||||
end
|
15
external/bsd/libarchive/dist/cpio/test/test_gcpio_compat_ref_nosym.crc.uu
vendored
Normal file
15
external/bsd/libarchive/dist/cpio/test/test_gcpio_compat_ref_nosym.crc.uu
vendored
Normal file
|
@ -0,0 +1,15 @@
|
|||
begin 644 test_gcpio_compat_ref_nosym.crc
|
||||
M,#<P-S`R,#`U-D9!1$4P,#`P-#%&1#`P,#`P,T4X,#`P,#`S13@P,#`P,#`P
|
||||
M,C1!040Q14)",#`P,#`P,#`P,#`P,#`P,#`P,#`P,#4T,#`P,#`P0D(P,35"
|
||||
M,#`S-C`P,#`P,#`T,#`P,#`P,#!D:7(````P-S`W,#(P,#4V1D%$0S`P,#`X
|
||||
M,4$T,#`P,#`S13@P,#`P,#-%.#`P,#`P,#`R-$%!1#%%0D(P,#`P,#`P,#`P
|
||||
M,#`P,#`P,#`P,#`P-30P,#`P,#!"0C`Q-4(P,#(W,#`P,#`P,#4P,#`P,#`P
|
||||
M,&9I;&4``#`W,#<P,C`P-39&041#,#`P,#@Q030P,#`P,#-%.#`P,#`P,T4X
|
||||
M,#`P,#`P,#(T04%$,45"0C`P,#`P,#!!,#`P,#`P,#`P,#`P,#`U-#`P,#`P
|
||||
M,$)",#$U0C`P,C<P,#`P,#`P.3`P,#`P,44W;&EN:V9I;&4``#$R,S0U-C<X
|
||||
M.0H``#`W,#<P,C`P,#`P,#`P,#`P,#`P,#`P,#`P,#`P,#`P,#`P,#`P,#`P
|
||||
M,#`P,#$P,#`P,#`P,#`P,#`P,#`P,#`P,#`P,#`P,#`P,#`P,#`P,#`P,#`P
|
||||
M,#`P,#`P,#`P,#`P,#`P0C`P,#`P,#`P5%)!24Q%4B$A(0``````````````
|
||||
1````````````````````````
|
||||
`
|
||||
end
|
15
external/bsd/libarchive/dist/cpio/test/test_gcpio_compat_ref_nosym.newc.uu
vendored
Normal file
15
external/bsd/libarchive/dist/cpio/test/test_gcpio_compat_ref_nosym.newc.uu
vendored
Normal file
|
@ -0,0 +1,15 @@
|
|||
begin 644 test_gcpio_compat_ref_nosym.newc
|
||||
M,#<P-S`Q,#`U-D9!1$4P,#`P-#%&1#`P,#`P,T4X,#`P,#`S13@P,#`P,#`P
|
||||
M,C1!040Q14)",#`P,#`P,#`P,#`P,#`P,#`P,#`P,#4T,#`P,#`P0D(P,35"
|
||||
M,#`S-C`P,#`P,#`T,#`P,#`P,#!D:7(````P-S`W,#$P,#4V1D%$0S`P,#`X
|
||||
M,4$T,#`P,#`S13@P,#`P,#-%.#`P,#`P,#`R-$%!1#%%0D(P,#`P,#`P,#`P
|
||||
M,#`P,#`P,#`P,#`P-30P,#`P,#!"0C`Q-4(P,#(W,#`P,#`P,#4P,#`P,#`P
|
||||
M,&9I;&4``#`W,#<P,3`P-39&041#,#`P,#@Q030P,#`P,#-%.#`P,#`P,T4X
|
||||
M,#`P,#`P,#(T04%$,45"0C`P,#`P,#!!,#`P,#`P,#`P,#`P,#`U-#`P,#`P
|
||||
M,$)",#$U0C`P,C<P,#`P,#`P.3`P,#`P,#`P;&EN:V9I;&4``#$R,S0U-C<X
|
||||
M.0H``#`W,#<P,3`P,#`P,#`P,#`P,#`P,#`P,#`P,#`P,#`P,#`P,#`P,#`P
|
||||
M,#`P,#$P,#`P,#`P,#`P,#`P,#`P,#`P,#`P,#`P,#`P,#`P,#`P,#`P,#`P
|
||||
M,#`P,#`P,#`P,#`P,#`P0C`P,#`P,#`P5%)!24Q%4B$A(0``````````````
|
||||
1````````````````````````
|
||||
`
|
||||
end
|
72
external/bsd/libarchive/dist/cpio/test/test_gcpio_compat_ref_nosym.ustar.uu
vendored
Normal file
72
external/bsd/libarchive/dist/cpio/test/test_gcpio_compat_ref_nosym.ustar.uu
vendored
Normal file
|
@ -0,0 +1,72 @@
|
|||
begin 644 test_gcpio_compat_ref_nosym.ustar
|
||||
M9&ER+P``````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M`````````````#`P,#`W-S4`,#`P,3<U,``P,#`Q-S4P`#`P,#`P,#`P,#`P
|
||||
M`#$Q,C4S,C$W,C<S`#`P,3$S-3$`-0``````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M``````````````````````````````````````````!U<W1A<@`P,'1I;0``
|
||||
M````````````````````````````````````=&EM````````````````````
|
||||
M```````````````````P,#`P,C<S`#8V,#`P-C8`````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M``````````````````````!F:6QE````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````,#`P,#8T-``P,#`Q-S4P`#`P
|
||||
M,#$W-3``,#`P,#`P,#`P,3(`,3$R-3,R,3<R-S,`,#`Q,30R,P`P````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M`````'5S=&%R`#`P=&EM``````````````````````````````````````!T
|
||||
M:6T``````````````````````````````````````#`P,#`R-S,`-C8P,#`T
|
||||
M-P``````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M`````````````````````````````````````````````#$R,S0U-C<X.0H`
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````;&EN:V9I;&4`````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M`````````````````````#`P,#`V-#0`,#`P,3<U,``P,#`Q-S4P`#`P,#`P
|
||||
M,#`P,#`P`#$Q,C4S,C$W,C<S`#`P,3,Q,S<`,69I;&4`````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M``````````````````````````````````````````````````!U<W1A<@`P
|
||||
M,'1I;0``````````````````````````````````````=&EM````````````
|
||||
M```````````````````````````P,#`P,C<S`#8V,#`P-#<`````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
,````````````````
|
||||
`
|
||||
end
|
52
external/bsd/libarchive/dist/cpio/test/test_option_B_upper.c
vendored
Normal file
52
external/bsd/libarchive/dist/cpio/test/test_option_B_upper.c
vendored
Normal file
|
@ -0,0 +1,52 @@
|
|||
/*-
|
||||
* Copyright (c) 2003-2007 Tim Kientzle
|
||||
* 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(S) ``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(S) 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.
|
||||
*/
|
||||
#include "test.h"
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
|
||||
DEFINE_TEST(test_option_B_upper)
|
||||
{
|
||||
struct stat st;
|
||||
int r;
|
||||
|
||||
/*
|
||||
* Create a file on disk.
|
||||
*/
|
||||
assertMakeFile("file", 0644, NULL);
|
||||
|
||||
/* Create an archive without -B; this should be 512 bytes. */
|
||||
r = systemf("echo file | %s -o > small.cpio 2>small.err", testprog);
|
||||
assertEqualInt(r, 0);
|
||||
assertTextFileContents("1 block\n", "small.err");
|
||||
assertEqualInt(0, stat("small.cpio", &st));
|
||||
assertEqualInt(512, st.st_size);
|
||||
|
||||
/* Create an archive with -B; this should be 5120 bytes. */
|
||||
r = systemf("echo file | %s -oB > large.cpio 2>large.err", testprog);
|
||||
assertEqualInt(r, 0);
|
||||
assertTextFileContents("1 block\n", "large.err");
|
||||
assertEqualInt(0, stat("large.cpio", &st));
|
||||
assertEqualInt(5120, st.st_size);
|
||||
}
|
62
external/bsd/libarchive/dist/cpio/test/test_option_C_upper.c
vendored
Normal file
62
external/bsd/libarchive/dist/cpio/test/test_option_C_upper.c
vendored
Normal file
|
@ -0,0 +1,62 @@
|
|||
/*-
|
||||
* Copyright (c) 2003-2007 Tim Kientzle
|
||||
* 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(S) ``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(S) 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.
|
||||
*/
|
||||
#include "test.h"
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
|
||||
DEFINE_TEST(test_option_C_upper)
|
||||
{
|
||||
int r;
|
||||
|
||||
/*
|
||||
* Create a file on disk.
|
||||
*/
|
||||
assertMakeFile("file", 0644, NULL);
|
||||
|
||||
/* Create an archive without -C; this should be 512 bytes. */
|
||||
r = systemf("echo file | %s -o > small.cpio 2>small.err", testprog);
|
||||
assertEqualInt(r, 0);
|
||||
assertTextFileContents("1 block\n", "small.err");
|
||||
assertFileSize("small.cpio", 512);
|
||||
|
||||
/* Create an archive with -C 513; this should be 513 bytes. */
|
||||
r = systemf("echo file | %s -o -C 513 > 513.cpio 2>513.err",
|
||||
testprog);
|
||||
assertEqualInt(r, 0);
|
||||
assertTextFileContents("1 block\n", "513.err");
|
||||
assertFileSize("513.cpio", 513);
|
||||
|
||||
/* Create an archive with -C 12345; this should be 12345 bytes. */
|
||||
r = systemf("echo file | %s -o -C12345 > 12345.cpio 2>12345.err",
|
||||
testprog);
|
||||
assertEqualInt(r, 0);
|
||||
assertTextFileContents("1 block\n", "12345.err");
|
||||
assertFileSize("12345.cpio", 12345);
|
||||
|
||||
/* Create an archive with invalid -C request */
|
||||
assert(0 != systemf("echo file | %s -o -C > bad.cpio 2>bad.err",
|
||||
testprog));
|
||||
assertEmptyFile("bad.cpio");
|
||||
}
|
56
external/bsd/libarchive/dist/cpio/test/test_option_J_upper.c
vendored
Normal file
56
external/bsd/libarchive/dist/cpio/test/test_option_J_upper.c
vendored
Normal file
|
@ -0,0 +1,56 @@
|
|||
/*-
|
||||
* Copyright (c) 2003-2009 Tim Kientzle
|
||||
* 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(S) ``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(S) 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.
|
||||
*/
|
||||
#include "test.h"
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
DEFINE_TEST(test_option_J_upper)
|
||||
{
|
||||
char *p;
|
||||
int r;
|
||||
size_t s;
|
||||
|
||||
/* Create a file. */
|
||||
assertMakeFile("f", 0644, "a");
|
||||
|
||||
/* Archive it with xz compression. */
|
||||
r = systemf("echo f | %s -o -J >archive.out 2>archive.err",
|
||||
testprog);
|
||||
p = slurpfile(&s, "archive.err");
|
||||
p[s] = '\0';
|
||||
if (r != 0) {
|
||||
if (strstr(p, "compression not available") != NULL) {
|
||||
skipping("This version of bsdcpio was compiled "
|
||||
"without xz support");
|
||||
return;
|
||||
}
|
||||
failure("-J option is broken");
|
||||
assertEqualInt(r, 0);
|
||||
return;
|
||||
}
|
||||
/* Check that the archive file has an xz signature. */
|
||||
p = slurpfile(&s, "archive.out");
|
||||
assert(s > 2);
|
||||
assertEqualMem(p, "\3757zXZ", 5);
|
||||
}
|
101
external/bsd/libarchive/dist/cpio/test/test_option_L_upper.c
vendored
Normal file
101
external/bsd/libarchive/dist/cpio/test/test_option_L_upper.c
vendored
Normal file
|
@ -0,0 +1,101 @@
|
|||
/*-
|
||||
* Copyright (c) 2003-2007 Tim Kientzle
|
||||
* 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(S) ``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(S) 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.
|
||||
*/
|
||||
#include "test.h"
|
||||
__FBSDID("$FreeBSD: src/usr.bin/cpio/test/test_option_L.c,v 1.2 2008/08/24 06:21:00 kientzle Exp $");
|
||||
|
||||
/* This is a little pointless, as Windows doesn't support symlinks
|
||||
* (except for the seriously crippled CreateSymbolicLink API) so these
|
||||
* tests won't run on Windows. */
|
||||
#if defined(_WIN32) && !defined(__CYGWIN__)
|
||||
#define CAT "type"
|
||||
#else
|
||||
#define CAT "cat"
|
||||
#endif
|
||||
|
||||
DEFINE_TEST(test_option_L_upper)
|
||||
{
|
||||
FILE *filelist;
|
||||
int r;
|
||||
|
||||
if (!canSymlink()) {
|
||||
skipping("Symlink tests");
|
||||
return;
|
||||
}
|
||||
|
||||
filelist = fopen("filelist", "w");
|
||||
|
||||
/* Create a file and a symlink to the file. */
|
||||
assertMakeFile("file", 0644, "1234567890");
|
||||
fprintf(filelist, "file\n");
|
||||
|
||||
/* Symlink to above file. */
|
||||
assertMakeSymlink("symlink", "file");
|
||||
fprintf(filelist, "symlink\n");
|
||||
|
||||
fclose(filelist);
|
||||
|
||||
r = systemf(CAT " filelist | %s -pd copy >copy.out 2>copy.err", testprog);
|
||||
assertEqualInt(r, 0);
|
||||
assertTextFileContents("1 block\n", "copy.err");
|
||||
|
||||
failure("Regular -p without -L should preserve symlinks.");
|
||||
assertIsSymlink("copy/symlink", NULL);
|
||||
|
||||
r = systemf(CAT " filelist | %s -pd -L copy-L >copy-L.out 2>copy-L.err", testprog);
|
||||
assertEqualInt(r, 0);
|
||||
assertEmptyFile("copy-L.out");
|
||||
assertTextFileContents("1 block\n", "copy-L.err");
|
||||
failure("-pdL should dereference symlinks and turn them into files.");
|
||||
assertIsReg("copy-L/symlink", -1);
|
||||
|
||||
r = systemf(CAT " filelist | %s -o >archive.out 2>archive.err", testprog);
|
||||
failure("Error invoking %s -o ", testprog);
|
||||
assertEqualInt(r, 0);
|
||||
assertTextFileContents("1 block\n", "archive.err");
|
||||
|
||||
assertMakeDir("unpack", 0755);
|
||||
assertChdir("unpack");
|
||||
r = systemf(CAT " ../archive.out | %s -i >unpack.out 2>unpack.err", testprog);
|
||||
failure("Error invoking %s -i", testprog);
|
||||
assertEqualInt(r, 0);
|
||||
assertTextFileContents("1 block\n", "unpack.err");
|
||||
assertChdir("..");
|
||||
|
||||
assertIsSymlink("unpack/symlink", NULL);
|
||||
|
||||
r = systemf(CAT " filelist | %s -oL >archive-L.out 2>archive-L.err", testprog);
|
||||
failure("Error invoking %s -oL", testprog);
|
||||
assertEqualInt(r, 0);
|
||||
assertTextFileContents("1 block\n", "archive-L.err");
|
||||
|
||||
assertMakeDir("unpack-L", 0755);
|
||||
assertChdir("unpack-L");
|
||||
r = systemf(CAT " ../archive-L.out | %s -i >unpack-L.out 2>unpack-L.err", testprog);
|
||||
failure("Error invoking %s -i < archive-L.out", testprog);
|
||||
assertEqualInt(r, 0);
|
||||
assertTextFileContents("1 block\n", "unpack-L.err");
|
||||
assertChdir("..");
|
||||
assertIsReg("unpack-L/symlink", -1);
|
||||
}
|
56
external/bsd/libarchive/dist/cpio/test/test_option_Z_upper.c
vendored
Normal file
56
external/bsd/libarchive/dist/cpio/test/test_option_Z_upper.c
vendored
Normal file
|
@ -0,0 +1,56 @@
|
|||
/*-
|
||||
* Copyright (c) 2003-2009 Tim Kientzle
|
||||
* 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(S) ``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(S) 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.
|
||||
*/
|
||||
#include "test.h"
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
DEFINE_TEST(test_option_Z_upper)
|
||||
{
|
||||
char *p;
|
||||
int r;
|
||||
size_t s;
|
||||
|
||||
/* Create a file. */
|
||||
assertMakeFile("f", 0644, "a");
|
||||
|
||||
/* Archive it with compress compression. */
|
||||
r = systemf("echo f | %s -oZ >archive.out 2>archive.err",
|
||||
testprog);
|
||||
p = slurpfile(&s, "archive.err");
|
||||
p[s] = '\0';
|
||||
if (r != 0) {
|
||||
if (strstr(p, "compression not available") != NULL) {
|
||||
skipping("This version of bsdcpio was compiled "
|
||||
"without compress support");
|
||||
return;
|
||||
}
|
||||
failure("-Z option is broken");
|
||||
assertEqualInt(r, 0);
|
||||
return;
|
||||
}
|
||||
/* Check that the archive file has a compress signature. */
|
||||
p = slurpfile(&s, "archive.out");
|
||||
assert(s > 2);
|
||||
assertEqualMem(p, "\x1f\x9d", 2);
|
||||
}
|
154
external/bsd/libarchive/dist/cpio/test/test_option_a.c
vendored
Normal file
154
external/bsd/libarchive/dist/cpio/test/test_option_a.c
vendored
Normal file
|
@ -0,0 +1,154 @@
|
|||
/*-
|
||||
* Copyright (c) 2003-2008 Tim Kientzle
|
||||
* 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(S) ``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(S) 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.
|
||||
*/
|
||||
#include "test.h"
|
||||
#if defined(HAVE_UTIME_H)
|
||||
#include <utime.h>
|
||||
#elif defined(HAVE_SYS_UTIME_H)
|
||||
#include <sys/utime.h>
|
||||
#endif
|
||||
__FBSDID("$FreeBSD: src/usr.bin/cpio/test/test_option_a.c,v 1.3 2008/08/24 06:21:00 kientzle Exp $");
|
||||
|
||||
static struct {
|
||||
const char *name;
|
||||
time_t atime_sec;
|
||||
} files[] = {
|
||||
{ "f0", 0 },
|
||||
{ "f1", 0 },
|
||||
{ "f2", 0 },
|
||||
{ "f3", 0 },
|
||||
{ "f4", 0 },
|
||||
{ "f5", 0 }
|
||||
};
|
||||
|
||||
/*
|
||||
* Create a bunch of test files and record their atimes.
|
||||
* For the atime preserve/change tests, the files must have
|
||||
* atimes in the past. We can accomplish this by explicitly invoking
|
||||
* utime() on platforms that support it or by simply sleeping
|
||||
* for a second after creating the files. (Creating all of the files
|
||||
* at once means we only need to sleep once.)
|
||||
*/
|
||||
static void
|
||||
test_create(void)
|
||||
{
|
||||
struct stat st;
|
||||
struct utimbuf times;
|
||||
static const int numfiles = sizeof(files) / sizeof(files[0]);
|
||||
int i;
|
||||
|
||||
for (i = 0; i < numfiles; ++i) {
|
||||
/*
|
||||
* Note: Have to write at least one byte to the file.
|
||||
* cpio doesn't bother reading the file if it's zero length,
|
||||
* so the atime never gets changed in that case, which
|
||||
* makes the tests below rather pointless.
|
||||
*/
|
||||
assertMakeFile(files[i].name, 0644, "a");
|
||||
|
||||
/* If utime() isn't supported on your platform, just
|
||||
* #ifdef this section out. Most of the test below is
|
||||
* still valid. */
|
||||
memset(×, 0, sizeof(times));
|
||||
times.actime = 1;
|
||||
times.modtime = 3;
|
||||
assertEqualInt(0, utime(files[i].name, ×));
|
||||
|
||||
/* Record whatever atime the file ended up with. */
|
||||
/* If utime() is available, this should be 1, but there's
|
||||
* no harm in being careful. */
|
||||
assertEqualInt(0, stat(files[i].name, &st));
|
||||
files[i].atime_sec = st.st_atime;
|
||||
}
|
||||
|
||||
/* Wait until the atime on the last file is actually in the past. */
|
||||
sleepUntilAfter(files[numfiles - 1].atime_sec);
|
||||
}
|
||||
|
||||
DEFINE_TEST(test_option_a)
|
||||
{
|
||||
struct stat st;
|
||||
int r;
|
||||
char *p;
|
||||
|
||||
/* Create all of the test files. */
|
||||
test_create();
|
||||
|
||||
/* Sanity check; verify that atimes really do get modified. */
|
||||
assert((p = slurpfile(NULL, "f0")) != NULL);
|
||||
free(p);
|
||||
assertEqualInt(0, stat("f0", &st));
|
||||
if (st.st_atime == files[0].atime_sec) {
|
||||
skipping("Cannot verify -a option\n"
|
||||
" Your system appears to not support atime.");
|
||||
}
|
||||
else
|
||||
{
|
||||
/*
|
||||
* If this disk is mounted noatime, then we can't
|
||||
* verify correct operation without -a.
|
||||
*/
|
||||
|
||||
/* Copy the file without -a; should change the atime. */
|
||||
r = systemf("echo %s | %s -pd copy-no-a > copy-no-a.out 2>copy-no-a.err", files[1].name, testprog);
|
||||
assertEqualInt(r, 0);
|
||||
assertTextFileContents("1 block\n", "copy-no-a.err");
|
||||
assertEmptyFile("copy-no-a.out");
|
||||
assertEqualInt(0, stat(files[1].name, &st));
|
||||
failure("Copying file without -a should have changed atime.");
|
||||
assert(st.st_atime != files[1].atime_sec);
|
||||
|
||||
/* Archive the file without -a; should change the atime. */
|
||||
r = systemf("echo %s | %s -o > archive-no-a.out 2>archive-no-a.err", files[2].name, testprog);
|
||||
assertEqualInt(r, 0);
|
||||
assertTextFileContents("1 block\n", "copy-no-a.err");
|
||||
assertEqualInt(0, stat(files[2].name, &st));
|
||||
failure("Archiving file without -a should have changed atime.");
|
||||
assert(st.st_atime != files[2].atime_sec);
|
||||
}
|
||||
|
||||
/*
|
||||
* We can, of course, still verify that the atime is unchanged
|
||||
* when using the -a option.
|
||||
*/
|
||||
|
||||
/* Copy the file with -a; should not change the atime. */
|
||||
r = systemf("echo %s | %s -pad copy-a > copy-a.out 2>copy-a.err",
|
||||
files[3].name, testprog);
|
||||
assertEqualInt(r, 0);
|
||||
assertTextFileContents("1 block\n", "copy-a.err");
|
||||
assertEmptyFile("copy-a.out");
|
||||
assertEqualInt(0, stat(files[3].name, &st));
|
||||
failure("Copying file with -a should not have changed atime.");
|
||||
assertEqualInt(st.st_atime, files[3].atime_sec);
|
||||
|
||||
/* Archive the file with -a; should not change the atime. */
|
||||
r = systemf("echo %s | %s -oa > archive-a.out 2>archive-a.err",
|
||||
files[4].name, testprog);
|
||||
assertEqualInt(r, 0);
|
||||
assertTextFileContents("1 block\n", "copy-a.err");
|
||||
assertEqualInt(0, stat(files[4].name, &st));
|
||||
failure("Archiving file with -a should not have changed atime.");
|
||||
assertEqualInt(st.st_atime, files[4].atime_sec);
|
||||
}
|
221
external/bsd/libarchive/dist/cpio/test/test_option_c.c
vendored
Normal file
221
external/bsd/libarchive/dist/cpio/test/test_option_c.c
vendored
Normal file
|
@ -0,0 +1,221 @@
|
|||
/*-
|
||||
* Copyright (c) 2003-2007 Tim Kientzle
|
||||
* 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(S) ``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(S) 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.
|
||||
*/
|
||||
#include "test.h"
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
static int
|
||||
is_octal(const char *p, size_t l)
|
||||
{
|
||||
while (l > 0) {
|
||||
if (*p < '0' || *p > '7')
|
||||
return (0);
|
||||
--l;
|
||||
++p;
|
||||
}
|
||||
return (1);
|
||||
}
|
||||
|
||||
static int
|
||||
from_octal(const char *p, size_t l)
|
||||
{
|
||||
int r = 0;
|
||||
|
||||
while (l > 0) {
|
||||
r *= 8;
|
||||
r += *p - '0';
|
||||
--l;
|
||||
++p;
|
||||
}
|
||||
return (r);
|
||||
}
|
||||
|
||||
DEFINE_TEST(test_option_c)
|
||||
{
|
||||
FILE *filelist;
|
||||
int r;
|
||||
int uid = -1;
|
||||
int dev, ino, gid;
|
||||
time_t t, now;
|
||||
char *p, *e;
|
||||
size_t s;
|
||||
|
||||
assertUmask(0);
|
||||
|
||||
#if !defined(_WIN32)
|
||||
uid = getuid();
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Create an assortment of files.
|
||||
* TODO: Extend this to cover more filetypes.
|
||||
*/
|
||||
filelist = fopen("filelist", "w");
|
||||
|
||||
/* "file" */
|
||||
assertMakeFile("file", 0644, "1234567890");
|
||||
fprintf(filelist, "file\n");
|
||||
|
||||
/* "symlink" */
|
||||
if (canSymlink()) {
|
||||
assertMakeSymlink("symlink", "file");
|
||||
fprintf(filelist, "symlink\n");
|
||||
}
|
||||
|
||||
/* "dir" */
|
||||
assertMakeDir("dir", 0775);
|
||||
/* Record some facts about what we just created: */
|
||||
now = time(NULL); /* They were all created w/in last two seconds. */
|
||||
fprintf(filelist, "dir\n");
|
||||
|
||||
/* Use the cpio program to create an archive. */
|
||||
fclose(filelist);
|
||||
r = systemf("%s -oc <filelist >basic.out 2>basic.err", testprog);
|
||||
/* Verify that nothing went to stderr. */
|
||||
assertTextFileContents("1 block\n", "basic.err");
|
||||
|
||||
/* Assert that the program finished. */
|
||||
failure("%s -oc crashed", testprog);
|
||||
if (!assertEqualInt(r, 0))
|
||||
return;
|
||||
|
||||
/* Verify that stdout is a well-formed cpio file in "odc" format. */
|
||||
p = slurpfile(&s, "basic.out");
|
||||
assertEqualInt(s, 512);
|
||||
e = p;
|
||||
|
||||
/*
|
||||
* Some of these assertions could be stronger, but it's
|
||||
* a little tricky because they depend on the local environment.
|
||||
*/
|
||||
|
||||
/* First entry is "file" */
|
||||
assert(is_octal(e, 76)); /* Entire header is octal digits. */
|
||||
assertEqualMem(e + 0, "070707", 6); /* Magic */
|
||||
assert(is_octal(e + 6, 6)); /* dev */
|
||||
dev = from_octal(e + 6, 6);
|
||||
assert(is_octal(e + 12, 6)); /* ino */
|
||||
ino = from_octal(e + 12, 6);
|
||||
#if defined(_WIN32) && !defined(__CYGWIN__)
|
||||
/* Group members bits and others bits do not work. */
|
||||
assertEqualMem(e + 18, "100666", 6); /* Mode */
|
||||
#else
|
||||
assertEqualMem(e + 18, "100644", 6); /* Mode */
|
||||
#endif
|
||||
if (uid < 0)
|
||||
uid = from_octal(e + 24, 6);
|
||||
assertEqualInt(from_octal(e + 24, 6), uid); /* uid */
|
||||
assert(is_octal(e + 30, 6)); /* gid */
|
||||
gid = from_octal(e + 30, 6);
|
||||
assertEqualMem(e + 36, "000001", 6); /* nlink */
|
||||
failure("file entries should not have rdev set (dev field was 0%o)",
|
||||
dev);
|
||||
assertEqualMem(e + 42, "000000", 6); /* rdev */
|
||||
t = from_octal(e + 48, 11); /* mtime */
|
||||
assert(t <= now); /* File wasn't created in future. */
|
||||
assert(t >= now - 2); /* File was created w/in last 2 secs. */
|
||||
assertEqualMem(e + 59, "000005", 6); /* Name size */
|
||||
assertEqualMem(e + 65, "00000000012", 11); /* File size */
|
||||
assertEqualMem(e + 76, "file\0", 5); /* Name contents */
|
||||
assertEqualMem(e + 81, "1234567890", 10); /* File contents */
|
||||
e += 91;
|
||||
|
||||
/* "symlink" pointing to "file" */
|
||||
if (canSymlink()) {
|
||||
assert(is_octal(e, 76)); /* Entire header is octal digits. */
|
||||
assertEqualMem(e + 0, "070707", 6); /* Magic */
|
||||
assertEqualInt(dev, from_octal(e + 6, 6)); /* dev */
|
||||
assert(ino != from_octal(e + 12, 6)); /* ino */
|
||||
#if !defined(_WIN32) || defined(__CYGWIN__)
|
||||
/* On Windows, symbolic link and group members bits and
|
||||
* others bits do not work. */
|
||||
assertEqualMem(e + 18, "120777", 6); /* Mode */
|
||||
#endif
|
||||
assertEqualInt(from_octal(e + 24, 6), uid); /* uid */
|
||||
assertEqualInt(gid, from_octal(e + 30, 6)); /* gid */
|
||||
assertEqualMem(e + 36, "000001", 6); /* nlink */
|
||||
failure("file entries should have rdev == 0 (dev was 0%o)",
|
||||
from_octal(e + 6, 6));
|
||||
assertEqualMem(e + 42, "000000", 6); /* rdev */
|
||||
t = from_octal(e + 48, 11); /* mtime */
|
||||
assert(t <= now); /* File wasn't created in future. */
|
||||
assert(t >= now - 2); /* File was created w/in last 2 secs. */
|
||||
assertEqualMem(e + 59, "000010", 6); /* Name size */
|
||||
assertEqualMem(e + 65, "00000000004", 11); /* File size */
|
||||
assertEqualMem(e + 76, "symlink\0", 8); /* Name contents */
|
||||
assertEqualMem(e + 84, "file", 4); /* Symlink target. */
|
||||
e += 88;
|
||||
}
|
||||
|
||||
/* "dir" */
|
||||
assert(is_octal(e, 76));
|
||||
assertEqualMem(e + 0, "070707", 6); /* Magic */
|
||||
/* Dev should be same as first entry. */
|
||||
assert(is_octal(e + 6, 6)); /* dev */
|
||||
assertEqualInt(dev, from_octal(e + 6, 6));
|
||||
/* Ino must be different from first entry. */
|
||||
assert(is_octal(e + 12, 6)); /* ino */
|
||||
assert(dev != from_octal(e + 12, 6));
|
||||
#if defined(_WIN32) && !defined(__CYGWIN__)
|
||||
/* Group members bits and others bits do not work. */
|
||||
assertEqualMem(e + 18, "040777", 6); /* Mode */
|
||||
#else
|
||||
/* Accept 042775 to accomodate systems where sgid bit propagates. */
|
||||
if (memcmp(e + 18, "042775", 6) != 0)
|
||||
assertEqualMem(e + 18, "040775", 6); /* Mode */
|
||||
#endif
|
||||
assertEqualInt(from_octal(e + 24, 6), uid); /* uid */
|
||||
/* Gid should be same as first entry. */
|
||||
assert(is_octal(e + 30, 6)); /* gid */
|
||||
assertEqualInt(gid, from_octal(e + 30, 6));
|
||||
#ifndef NLINKS_INACCURATE_FOR_DIRS
|
||||
assertEqualMem(e + 36, "000002", 6); /* Nlink */
|
||||
#endif
|
||||
t = from_octal(e + 48, 11); /* mtime */
|
||||
assert(t <= now); /* File wasn't created in future. */
|
||||
assert(t >= now - 2); /* File was created w/in last 2 secs. */
|
||||
assertEqualMem(e + 59, "000004", 6); /* Name size */
|
||||
assertEqualMem(e + 65, "00000000000", 11); /* File size */
|
||||
assertEqualMem(e + 76, "dir\0", 4); /* name */
|
||||
e += 80;
|
||||
|
||||
/* TODO: Verify other types of entries. */
|
||||
|
||||
/* Last entry is end-of-archive marker. */
|
||||
assert(is_octal(e, 76));
|
||||
assertEqualMem(e + 0, "070707", 6); /* Magic */
|
||||
assertEqualMem(e + 6, "000000", 6); /* dev */
|
||||
assertEqualMem(e + 12, "000000", 6); /* ino */
|
||||
assertEqualMem(e + 18, "000000", 6); /* Mode */
|
||||
assertEqualMem(e + 24, "000000", 6); /* uid */
|
||||
assertEqualMem(e + 30, "000000", 6); /* gid */
|
||||
assertEqualMem(e + 36, "000001", 6); /* Nlink */
|
||||
assertEqualMem(e + 42, "000000", 6); /* rdev */
|
||||
assertEqualMem(e + 48, "00000000000", 11); /* mtime */
|
||||
assertEqualMem(e + 59, "000013", 6); /* Name size */
|
||||
assertEqualMem(e + 65, "00000000000", 11); /* File size */
|
||||
assertEqualMem(e + 76, "TRAILER!!!\0", 11); /* Name */
|
||||
|
||||
free(p);
|
||||
}
|
64
external/bsd/libarchive/dist/cpio/test/test_option_d.c
vendored
Normal file
64
external/bsd/libarchive/dist/cpio/test/test_option_d.c
vendored
Normal file
|
@ -0,0 +1,64 @@
|
|||
/*-
|
||||
* Copyright (c) 2003-2007 Tim Kientzle
|
||||
* 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(S) ``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(S) 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.
|
||||
*/
|
||||
#include "test.h"
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
|
||||
DEFINE_TEST(test_option_d)
|
||||
{
|
||||
int r;
|
||||
|
||||
/*
|
||||
* Create a file in a directory.
|
||||
*/
|
||||
assertMakeDir("dir", 0755);
|
||||
assertMakeFile("dir/file", 0644, NULL);
|
||||
|
||||
/* Create an archive. */
|
||||
r = systemf("echo dir/file | %s -o > archive.cpio 2>archive.err", testprog);
|
||||
assertEqualInt(r, 0);
|
||||
assertTextFileContents("1 block\n", "archive.err");
|
||||
assertFileSize("archive.cpio", 512);
|
||||
|
||||
/* Dearchive without -d, this should fail. */
|
||||
assertMakeDir("without-d", 0755);
|
||||
assertChdir("without-d");
|
||||
r = systemf("%s -i < ../archive.cpio >out 2>err", testprog);
|
||||
assertEqualInt(r, 0);
|
||||
assertEmptyFile("out");
|
||||
/* And the file should not be restored. */
|
||||
assertFileNotExists("dir/file");
|
||||
|
||||
/* Dearchive with -d, this should succeed. */
|
||||
assertChdir("..");
|
||||
assertMakeDir("with-d", 0755);
|
||||
assertChdir("with-d");
|
||||
r = systemf("%s -id < ../archive.cpio >out 2>err", testprog);
|
||||
assertEqualInt(r, 0);
|
||||
assertEmptyFile("out");
|
||||
assertTextFileContents("1 block\n", "err");
|
||||
/* And the file should be restored. */
|
||||
assertFileExists("dir/file");
|
||||
}
|
76
external/bsd/libarchive/dist/cpio/test/test_option_f.c
vendored
Normal file
76
external/bsd/libarchive/dist/cpio/test/test_option_f.c
vendored
Normal file
|
@ -0,0 +1,76 @@
|
|||
/*-
|
||||
* Copyright (c) 2003-2007 Tim Kientzle
|
||||
* 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(S) ``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(S) 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.
|
||||
*/
|
||||
#include "test.h"
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
/*
|
||||
* Unpack the archive in a new dir.
|
||||
*/
|
||||
static void
|
||||
unpack(const char *dirname, const char *option)
|
||||
{
|
||||
int r;
|
||||
|
||||
assertMakeDir(dirname, 0755);
|
||||
assertChdir(dirname);
|
||||
extract_reference_file("test_option_f.cpio");
|
||||
r = systemf("%s -i %s < test_option_f.cpio > copy-no-a.out 2>copy-no-a.err", testprog, option);
|
||||
assertEqualInt(0, r);
|
||||
assertChdir("..");
|
||||
}
|
||||
|
||||
DEFINE_TEST(test_option_f)
|
||||
{
|
||||
/* Calibrate: No -f option, so everything should be extracted. */
|
||||
unpack("t0", "--no-preserve-owner");
|
||||
assertFileExists("t0/a123");
|
||||
assertFileExists("t0/a234");
|
||||
assertFileExists("t0/b123");
|
||||
assertFileExists("t0/b234");
|
||||
|
||||
/* Don't extract 'a*' files. */
|
||||
#if defined(_WIN32) && !defined(__CYGWIN__)
|
||||
/* Single quotes isn't used by command.exe. */
|
||||
unpack("t1", "--no-preserve-owner -f a*");
|
||||
#else
|
||||
unpack("t1", "--no-preserve-owner -f 'a*'");
|
||||
#endif
|
||||
assertFileNotExists("t1/a123");
|
||||
assertFileNotExists("t1/a234");
|
||||
assertFileExists("t1/b123");
|
||||
assertFileExists("t1/b234");
|
||||
|
||||
/* Don't extract 'b*' files. */
|
||||
#if defined(_WIN32) && !defined(__CYGWIN__)
|
||||
/* Single quotes isn't used by command.exe. */
|
||||
unpack("t2", "--no-preserve-owner -f b*");
|
||||
#else
|
||||
unpack("t2", "--no-preserve-owner -f 'b*'");
|
||||
#endif
|
||||
assertFileExists("t2/a123");
|
||||
assertFileExists("t2/a234");
|
||||
assertFileNotExists("t2/b123");
|
||||
assertFileNotExists("t2/b234");
|
||||
}
|
16
external/bsd/libarchive/dist/cpio/test/test_option_f.cpio.uu
vendored
Normal file
16
external/bsd/libarchive/dist/cpio/test/test_option_f.cpio.uu
vendored
Normal file
|
@ -0,0 +1,16 @@
|
|||
$FreeBSD$
|
||||
begin 644 test_option_f.cpio
|
||||
M,#<P-S`W,#`P,3,Q-C(Q-38Q,3`P-C0T,#`Q-S4P,#`Q-S4P,#`P,#`Q,#`P
|
||||
M,#`P,3`W,S4Q,3(U,C8P,#`P,#4P,#`P,#`P,#`P,&$Q,C,`,#<P-S`W,#`P
|
||||
M,3,Q-C(Q-38S,3`P-C0T,#`Q-S4P,#`Q-S4P,#`P,#`Q,#`P,#`P,3`W,S4Q
|
||||
M,3(U-#`P,#`P,#4P,#`P,#`P,#`P,&$R,S0`,#<P-S`W,#`P,3,Q-C(Q-38R
|
||||
M,3`P-C0T,#`Q-S4P,#`Q-S4P,#`P,#`Q,#`P,#`P,3`W,S4Q,3(U,S0P,#`P
|
||||
M,#4P,#`P,#`P,#`P,&(Q,C,`,#<P-S`W,#`P,3,Q-C(Q-38T,3`P-C0T,#`Q
|
||||
M-S4P,#`Q-S4P,#`P,#`Q,#`P,#`P,3`W,S4Q,3(U-#,P,#`P,#4P,#`P,#`P
|
||||
M,#`P,&(R,S0`,#<P-S`W,#`P,#`P,#`P,#`P,#`P,#`P,#`P,#`P,#`P,#`P
|
||||
M,#`P,#`Q,#`P,#`P,#`P,#`P,#`P,#`P,#`P,3,P,#`P,#`P,#`P,%1204E,
|
||||
M15(A(2$`````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
1````````````````````````
|
||||
`
|
||||
end
|
84
external/bsd/libarchive/dist/cpio/test/test_option_help.c
vendored
Normal file
84
external/bsd/libarchive/dist/cpio/test/test_option_help.c
vendored
Normal file
|
@ -0,0 +1,84 @@
|
|||
/*-
|
||||
* Copyright (c) 2003-2007 Tim Kientzle
|
||||
* 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(S) ``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(S) 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.
|
||||
*/
|
||||
#include "test.h"
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
/*
|
||||
* Test that "--help", "-h", and "-W help" options all work and
|
||||
* generate reasonable output.
|
||||
*/
|
||||
|
||||
static int
|
||||
in_first_line(const char *p, const char *substring)
|
||||
{
|
||||
size_t l = strlen(substring);
|
||||
|
||||
while (*p != '\0' && *p != '\n') {
|
||||
if (memcmp(p, substring, l) == 0)
|
||||
return (1);
|
||||
++p;
|
||||
}
|
||||
return (0);
|
||||
}
|
||||
|
||||
DEFINE_TEST(test_option_help)
|
||||
{
|
||||
int r;
|
||||
char *p;
|
||||
size_t plen;
|
||||
|
||||
/* Exercise --help option. */
|
||||
r = systemf("%s --help >help.stdout 2>help.stderr", testprog);
|
||||
assertEqualInt(r, 0);
|
||||
failure("--help should generate nothing to stderr.");
|
||||
assertEmptyFile("help.stderr");
|
||||
/* Help message should start with name of program. */
|
||||
p = slurpfile(&plen, "help.stdout");
|
||||
failure("Help output should be long enough.");
|
||||
assert(plen >= 7);
|
||||
failure("First line of help output should contain string 'bsdcpio'");
|
||||
assert(in_first_line(p, "bsdcpio"));
|
||||
/*
|
||||
* TODO: Extend this check to further verify that --help output
|
||||
* looks approximately right.
|
||||
*/
|
||||
free(p);
|
||||
|
||||
/* -h option should generate the same output. */
|
||||
r = systemf("%s -h >h.stdout 2>h.stderr", testprog);
|
||||
assertEqualInt(r, 0);
|
||||
failure("-h should generate nothing to stderr.");
|
||||
assertEmptyFile("h.stderr");
|
||||
failure("stdout should be same for -h and --help");
|
||||
assertEqualFile("h.stdout", "help.stdout");
|
||||
|
||||
/* -W help should be another synonym. */
|
||||
r = systemf("%s -W help >Whelp.stdout 2>Whelp.stderr", testprog);
|
||||
assertEqualInt(r, 0);
|
||||
failure("-W help should generate nothing to stderr.");
|
||||
assertEmptyFile("Whelp.stderr");
|
||||
failure("stdout should be same for -W help and --help");
|
||||
assertEqualFile("Whelp.stdout", "help.stdout");
|
||||
}
|
50
external/bsd/libarchive/dist/cpio/test/test_option_l.c
vendored
Normal file
50
external/bsd/libarchive/dist/cpio/test/test_option_l.c
vendored
Normal file
|
@ -0,0 +1,50 @@
|
|||
/*-
|
||||
* Copyright (c) 2003-2007 Tim Kientzle
|
||||
* 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(S) ``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(S) 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.
|
||||
*/
|
||||
#include "test.h"
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
DEFINE_TEST(test_option_l)
|
||||
{
|
||||
int r;
|
||||
|
||||
/* Create a file. */
|
||||
assertMakeFile("f", 0644, "a");
|
||||
|
||||
/* Copy the file to the "copy" dir. */
|
||||
r = systemf("echo f | %s -pd copy >copy.out 2>copy.err",
|
||||
testprog);
|
||||
assertEqualInt(r, 0);
|
||||
|
||||
/* Check that the copy is a true copy and not a link. */
|
||||
assertIsNotHardlink("f", "copy/f");
|
||||
|
||||
/* Copy the file to the "link" dir with the -l option. */
|
||||
r = systemf("echo f | %s -pld link >link.out 2>link.err",
|
||||
testprog);
|
||||
assertEqualInt(r, 0);
|
||||
|
||||
/* Check that this is a link and not a copy. */
|
||||
assertIsHardlink("f", "link/f");
|
||||
}
|
56
external/bsd/libarchive/dist/cpio/test/test_option_lzma.c
vendored
Normal file
56
external/bsd/libarchive/dist/cpio/test/test_option_lzma.c
vendored
Normal file
|
@ -0,0 +1,56 @@
|
|||
/*-
|
||||
* Copyright (c) 2003-2007 Tim Kientzle
|
||||
* 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(S) ``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(S) 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.
|
||||
*/
|
||||
#include "test.h"
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
DEFINE_TEST(test_option_lzma)
|
||||
{
|
||||
char *p;
|
||||
int r;
|
||||
size_t s;
|
||||
|
||||
/* Create a file. */
|
||||
assertMakeFile("f", 0644, "a");
|
||||
|
||||
/* Archive it with lzma compression. */
|
||||
r = systemf("echo f | %s -o --lzma >archive.out 2>archive.err",
|
||||
testprog);
|
||||
p = slurpfile(&s, "archive.err");
|
||||
p[s] = '\0';
|
||||
if (r != 0) {
|
||||
if (strstr(p, "compression not available") != NULL) {
|
||||
skipping("This version of bsdcpio was compiled "
|
||||
"without lzma support");
|
||||
return;
|
||||
}
|
||||
failure("--lzma option is broken");
|
||||
assertEqualInt(r, 0);
|
||||
return;
|
||||
}
|
||||
/* Check that the archive file has an lzma signature. */
|
||||
p = slurpfile(&s, "archive.out");
|
||||
assert(s > 2);
|
||||
assertEqualMem(p, "\x5d\00\00", 3);
|
||||
}
|
63
external/bsd/libarchive/dist/cpio/test/test_option_m.c
vendored
Normal file
63
external/bsd/libarchive/dist/cpio/test/test_option_m.c
vendored
Normal file
|
@ -0,0 +1,63 @@
|
|||
/*-
|
||||
* Copyright (c) 2003-2007 Tim Kientzle
|
||||
* 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(S) ``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(S) 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.
|
||||
*/
|
||||
#include "test.h"
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
|
||||
DEFINE_TEST(test_option_m)
|
||||
{
|
||||
int r;
|
||||
|
||||
/*
|
||||
* The reference archive has one file with an mtime in 1970, 1
|
||||
* second after the start of the epoch.
|
||||
*/
|
||||
|
||||
/* Restored without -m, the result should have a current mtime. */
|
||||
assertMakeDir("without-m", 0755);
|
||||
assertChdir("without-m");
|
||||
extract_reference_file("test_option_m.cpio");
|
||||
r = systemf("%s --no-preserve-owner -i < test_option_m.cpio >out 2>err", testprog);
|
||||
assertEqualInt(r, 0);
|
||||
assertEmptyFile("out");
|
||||
assertTextFileContents("1 block\n", "err");
|
||||
/* Should have been created within the last few seconds. */
|
||||
assertFileMtimeRecent("file");
|
||||
|
||||
/* With -m, it should have an mtime in 1970. */
|
||||
assertChdir("..");
|
||||
assertMakeDir("with-m", 0755);
|
||||
assertChdir("with-m");
|
||||
extract_reference_file("test_option_m.cpio");
|
||||
r = systemf("%s --no-preserve-owner -im < test_option_m.cpio >out 2>err", testprog);
|
||||
assertEqualInt(r, 0);
|
||||
assertEmptyFile("out");
|
||||
assertTextFileContents("1 block\n", "err");
|
||||
/*
|
||||
* mtime in reference archive is '1' == 1 second after
|
||||
* midnight Jan 1, 1970 UTC.
|
||||
*/
|
||||
assertFileMtime("file", 1, 0);
|
||||
}
|
16
external/bsd/libarchive/dist/cpio/test/test_option_m.cpio.uu
vendored
Normal file
16
external/bsd/libarchive/dist/cpio/test/test_option_m.cpio.uu
vendored
Normal file
|
@ -0,0 +1,16 @@
|
|||
$FreeBSD$
|
||||
begin 644 test_option_m.cpio
|
||||
M,#<P-S`W,#`P,3,Q-#4P,#8T,3`P-C0T,#`Q-S4P,#`Q-S4P,#`P,#`Q,#`P
|
||||
M,#`P,#`P,#`P,#`P,#$P,#`P,#4P,#`P,#`P,#`P,&9I;&4`,#<P-S`W,#`P
|
||||
M,#`P,#`P,#`P,#`P,#`P,#`P,#`P,#`P,#`P,#`P,#`Q,#`P,#`P,#`P,#`P
|
||||
M,#`P,#`P,#`P,3,P,#`P,#`P,#`P,%1204E,15(A(2$`````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
1````````````````````````
|
||||
`
|
||||
end
|
95
external/bsd/libarchive/dist/cpio/test/test_option_t.c
vendored
Normal file
95
external/bsd/libarchive/dist/cpio/test/test_option_t.c
vendored
Normal file
|
@ -0,0 +1,95 @@
|
|||
/*-
|
||||
* Copyright (c) 2003-2007 Tim Kientzle
|
||||
* 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(S) ``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(S) 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.
|
||||
*/
|
||||
#include "test.h"
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
|
||||
DEFINE_TEST(test_option_t)
|
||||
{
|
||||
char *p;
|
||||
int r;
|
||||
|
||||
/* List reference archive, make sure the TOC is correct. */
|
||||
extract_reference_file("test_option_t.cpio");
|
||||
r = systemf("%s -it < test_option_t.cpio >it.out 2>it.err", testprog);
|
||||
assertEqualInt(r, 0);
|
||||
assertTextFileContents("1 block\n", "it.err");
|
||||
extract_reference_file("test_option_t.stdout");
|
||||
p = slurpfile(NULL, "test_option_t.stdout");
|
||||
assertTextFileContents(p, "it.out");
|
||||
free(p);
|
||||
|
||||
/* We accept plain "-t" as a synonym for "-it" */
|
||||
r = systemf("%s -t < test_option_t.cpio >t.out 2>t.err", testprog);
|
||||
assertEqualInt(r, 0);
|
||||
assertTextFileContents("1 block\n", "t.err");
|
||||
extract_reference_file("test_option_t.stdout");
|
||||
p = slurpfile(NULL, "test_option_t.stdout");
|
||||
assertTextFileContents(p, "t.out");
|
||||
free(p);
|
||||
|
||||
/* But "-ot" is an error. */
|
||||
assert(0 != systemf("%s -ot < test_option_t.cpio >ot.out 2>ot.err",
|
||||
testprog));
|
||||
assertEmptyFile("ot.out");
|
||||
|
||||
/* List reference archive verbosely, make sure the TOC is correct. */
|
||||
r = systemf("%s -itv < test_option_t.cpio >tv.out 2>tv.err", testprog);
|
||||
assertEqualInt(r, 0);
|
||||
assertTextFileContents("1 block\n", "tv.err");
|
||||
extract_reference_file("test_option_tv.stdout");
|
||||
|
||||
/* This doesn't work because the usernames on different systems
|
||||
* are different and cpio now looks up numeric UIDs on
|
||||
* the local system. */
|
||||
/* assertEqualFile("tv.out", "test_option_tv.stdout"); */
|
||||
|
||||
/* List reference archive with numeric IDs, verify TOC is correct. */
|
||||
r = systemf("%s -itnv < test_option_t.cpio >itnv.out 2>itnv.err",
|
||||
testprog);
|
||||
assertEqualInt(r, 0);
|
||||
assertTextFileContents("1 block\n", "itnv.err");
|
||||
p = slurpfile(NULL, "itnv.out");
|
||||
/* Since -n uses numeric UID/GID, this part should be the
|
||||
* same on every system. */
|
||||
assertEqualMem(p, "-rw-r--r-- 1 1000 1000 0 ",42);
|
||||
/* Date varies depending on local timezone. */
|
||||
if (memcmp(p + 42, "Dec 31 1969", 12) == 0) {
|
||||
/* East of Greenwich we get Dec 31, 1969. */
|
||||
} else {
|
||||
/* West of Greenwich get Jan 1, 1970 */
|
||||
assertEqualMem(p + 42, "Jan ", 4);
|
||||
/* Some systems format "Jan 01", some "Jan 1" */
|
||||
assert(p[46] == ' ' || p[46] == '0');
|
||||
assertEqualMem(p + 47, "1 1970 ", 8);
|
||||
}
|
||||
assertEqualMem(p + 54, " file", 5);
|
||||
free(p);
|
||||
|
||||
/* But "-n" without "-t" is an error. */
|
||||
assert(0 != systemf("%s -in < test_option_t.cpio >in.out 2>in.err",
|
||||
testprog));
|
||||
assertEmptyFile("in.out");
|
||||
}
|
16
external/bsd/libarchive/dist/cpio/test/test_option_t.cpio.uu
vendored
Normal file
16
external/bsd/libarchive/dist/cpio/test/test_option_t.cpio.uu
vendored
Normal file
|
@ -0,0 +1,16 @@
|
|||
$FreeBSD$
|
||||
begin 644 test_option_t.cpio
|
||||
M,#<P-S`W,#`P,3,Q-#4P,#8T,3`P-C0T,#`Q-S4P,#`Q-S4P,#`P,#`Q,#`P
|
||||
M,#`P,#`P,#`P,#`P,#$P,#`P,#4P,#`P,#`P,#`P,&9I;&4`,#<P-S`W,#`P
|
||||
M,#`P,#`P,#`P,#`P,#`P,#`P,#`P,#`P,#`P,#`P,#`Q,#`P,#`P,#`P,#`P
|
||||
M,#`P,#`P,#`P,3,P,#`P,#`P,#`P,%1204E,15(A(2$`````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
1````````````````````````
|
||||
`
|
||||
end
|
5
external/bsd/libarchive/dist/cpio/test/test_option_t.stdout.uu
vendored
Normal file
5
external/bsd/libarchive/dist/cpio/test/test_option_t.stdout.uu
vendored
Normal file
|
@ -0,0 +1,5 @@
|
|||
$FreeBSD$
|
||||
begin 644 test_option_t.stdout
|
||||
%9FEL90H`
|
||||
`
|
||||
end
|
6
external/bsd/libarchive/dist/cpio/test/test_option_tv.stdout.uu
vendored
Normal file
6
external/bsd/libarchive/dist/cpio/test/test_option_tv.stdout.uu
vendored
Normal file
|
@ -0,0 +1,6 @@
|
|||
$FreeBSD: src/usr.bin/cpio/test/test_option_tv.stdout.uu,v 1.2 2008/11/29 20:22:02 kientzle Exp $
|
||||
begin 644 test_option_tv.stdout
|
||||
M+7)W+7(M+7(M+2`@(#$@=&EM("`@("`@=&EM("`@("`@("`@("`@(#`@1&5C
|
||||
/(#,Q("`Q.38Y(&9I;&4*
|
||||
`
|
||||
end
|
81
external/bsd/libarchive/dist/cpio/test/test_option_u.c
vendored
Normal file
81
external/bsd/libarchive/dist/cpio/test/test_option_u.c
vendored
Normal file
|
@ -0,0 +1,81 @@
|
|||
/*-
|
||||
* Copyright (c) 2003-2007 Tim Kientzle
|
||||
* 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(S) ``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(S) 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.
|
||||
*/
|
||||
#include "test.h"
|
||||
#if defined(HAVE_UTIME_H)
|
||||
#include <utime.h>
|
||||
#elif defined(HAVE_SYS_UTIME_H)
|
||||
#include <sys/utime.h>
|
||||
#endif
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
DEFINE_TEST(test_option_u)
|
||||
{
|
||||
struct utimbuf times;
|
||||
char *p;
|
||||
size_t s;
|
||||
int r;
|
||||
|
||||
/* Create a file. */
|
||||
assertMakeFile("f", 0644, "a");
|
||||
|
||||
/* Copy the file to the "copy" dir. */
|
||||
r = systemf("echo f | %s -pd copy >copy.out 2>copy.err",
|
||||
testprog);
|
||||
assertEqualInt(r, 0);
|
||||
|
||||
/* Check that the file contains only a single "a" */
|
||||
p = slurpfile(&s, "copy/f");
|
||||
assertEqualInt(s, 1);
|
||||
assertEqualMem(p, "a", 1);
|
||||
|
||||
/* Recreate the file with a single "b" */
|
||||
assertMakeFile("f", 0644, "b");
|
||||
|
||||
/* Set the mtime to the distant past. */
|
||||
memset(×, 0, sizeof(times));
|
||||
times.actime = 1;
|
||||
times.modtime = 3;
|
||||
assertEqualInt(0, utime("f", ×));
|
||||
|
||||
/* Copy the file to the "copy" dir. */
|
||||
r = systemf("echo f | %s -pd copy >copy.out 2>copy.err",
|
||||
testprog);
|
||||
assertEqualInt(r, 0);
|
||||
|
||||
/* Verify that the file hasn't changed (it wasn't overwritten) */
|
||||
p = slurpfile(&s, "copy/f");
|
||||
assertEqualInt(s, 1);
|
||||
assertEqualMem(p, "a", 1);
|
||||
|
||||
/* Copy the file to the "copy" dir with -u (force) */
|
||||
r = systemf("echo f | %s -pud copy >copy.out 2>copy.err",
|
||||
testprog);
|
||||
assertEqualInt(r, 0);
|
||||
|
||||
/* Verify that the file has changed (it was overwritten) */
|
||||
p = slurpfile(&s, "copy/f");
|
||||
assertEqualInt(s, 1);
|
||||
assertEqualMem(p, "b", 1);
|
||||
}
|
109
external/bsd/libarchive/dist/cpio/test/test_option_version.c
vendored
Normal file
109
external/bsd/libarchive/dist/cpio/test/test_option_version.c
vendored
Normal file
|
@ -0,0 +1,109 @@
|
|||
/*-
|
||||
* Copyright (c) 2003-2007 Tim Kientzle
|
||||
* 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(S) ``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(S) 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.
|
||||
*/
|
||||
#include "test.h"
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
/*
|
||||
* Test that --version option works and generates reasonable output.
|
||||
*/
|
||||
|
||||
static void
|
||||
verify(const char *p, size_t s)
|
||||
{
|
||||
const char *q = p;
|
||||
|
||||
/* Version message should start with name of program, then space. */
|
||||
failure("version message too short:", p);
|
||||
if (!assert(s > 6))
|
||||
return;
|
||||
failure("Version message should begin with 'bsdcpio': %s", p);
|
||||
if (!assertEqualMem(q, "bsdcpio ", 8))
|
||||
/* If we're not testing bsdcpio, don't keep going. */
|
||||
return;
|
||||
q += 8; s -= 8;
|
||||
/* Version number is a series of digits and periods. */
|
||||
while (s > 0 && (*q == '.' || (*q >= '0' && *q <= '9'))) {
|
||||
++q;
|
||||
--s;
|
||||
}
|
||||
/* Version number terminated by space. */
|
||||
failure("Version: %s", p);
|
||||
assert(s > 1);
|
||||
/* Skip a single trailing a,b,c, or d. */
|
||||
if (*q == 'a' || *q == 'b' || *q == 'c' || *q == 'd')
|
||||
++q;
|
||||
failure("Version: %s", p);
|
||||
assert(*q == ' ');
|
||||
++q; --s;
|
||||
/* Separator. */
|
||||
failure("Version: %s", p);
|
||||
assertEqualMem(q, "-- ", 3);
|
||||
q += 3; s -= 3;
|
||||
/* libarchive name and version number */
|
||||
assert(s > 11);
|
||||
failure("Version: %s", p);
|
||||
assertEqualMem(q, "libarchive ", 11);
|
||||
q += 11; s -= 11;
|
||||
/* Version number is a series of digits and periods. */
|
||||
while (s > 0 && (*q == '.' || (*q >= '0' && *q <= '9'))) {
|
||||
++q;
|
||||
--s;
|
||||
}
|
||||
/* Skip a single trailing a,b,c, or d. */
|
||||
if (*q == 'a' || *q == 'b' || *q == 'c' || *q == 'd')
|
||||
++q;
|
||||
/* All terminated by end-of-line: \r, \r\n, or \n */
|
||||
assert(s >= 1);
|
||||
failure("Version: %s", p);
|
||||
if (*q == '\x0d') {
|
||||
if (q[1] != '\0')
|
||||
assertEqualMem(q, "\x0d\x0a", 2);
|
||||
} else
|
||||
assertEqualMem(q, "\x0a", 1);
|
||||
}
|
||||
|
||||
|
||||
DEFINE_TEST(test_option_version)
|
||||
{
|
||||
int r;
|
||||
char *p;
|
||||
size_t s;
|
||||
|
||||
r = systemf("%s --version >version.stdout 2>version.stderr", testprog);
|
||||
if (r != 0)
|
||||
r = systemf("%s -W version >version.stdout 2>version.stderr",
|
||||
testprog);
|
||||
failure("Unable to run either %s --version or %s -W version",
|
||||
testprog, testprog);
|
||||
if (!assert(r == 0))
|
||||
return;
|
||||
|
||||
/* --version should generate nothing to stderr. */
|
||||
assertEmptyFile("version.stderr");
|
||||
/* Verify format of version message. */
|
||||
p = slurpfile(&s, "version.stdout");
|
||||
verify(p, s);
|
||||
free(p);
|
||||
}
|
57
external/bsd/libarchive/dist/cpio/test/test_option_y.c
vendored
Normal file
57
external/bsd/libarchive/dist/cpio/test/test_option_y.c
vendored
Normal file
|
@ -0,0 +1,57 @@
|
|||
/*-
|
||||
* Copyright (c) 2003-2007 Tim Kientzle
|
||||
* 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(S) ``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(S) 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.
|
||||
*/
|
||||
#include "test.h"
|
||||
__FBSDID("$FreeBSD: src/usr.bin/cpio/test/test_option_y.c,v 1.2 2008/08/24 06:21:00 kientzle Exp $");
|
||||
|
||||
DEFINE_TEST(test_option_y)
|
||||
{
|
||||
char *p;
|
||||
int r;
|
||||
size_t s;
|
||||
|
||||
/* Create a file. */
|
||||
assertMakeFile("f", 0644, "a");
|
||||
|
||||
/* Archive it with bzip2 compression. */
|
||||
r = systemf("echo f | %s -oy >archive.out 2>archive.err",
|
||||
testprog);
|
||||
p = slurpfile(&s, "archive.err");
|
||||
p[s] = '\0';
|
||||
if (r != 0) {
|
||||
if (strstr(p, "compression not available") != NULL) {
|
||||
skipping("This version of bsdcpio was compiled "
|
||||
"without bzip2 support");
|
||||
return;
|
||||
}
|
||||
failure("-y option is broken");
|
||||
assertEqualInt(r, 0);
|
||||
return;
|
||||
}
|
||||
assertTextFileContents("1 block\n", "archive.err");
|
||||
/* Check that the archive file has a bzip2 signature. */
|
||||
p = slurpfile(&s, "archive.out");
|
||||
assert(s > 2);
|
||||
assertEqualMem(p, "BZh9", 4);
|
||||
}
|
56
external/bsd/libarchive/dist/cpio/test/test_option_z.c
vendored
Normal file
56
external/bsd/libarchive/dist/cpio/test/test_option_z.c
vendored
Normal file
|
@ -0,0 +1,56 @@
|
|||
/*-
|
||||
* Copyright (c) 2003-2007 Tim Kientzle
|
||||
* 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(S) ``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(S) 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.
|
||||
*/
|
||||
#include "test.h"
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
DEFINE_TEST(test_option_z)
|
||||
{
|
||||
char *p;
|
||||
int r;
|
||||
size_t s;
|
||||
|
||||
/* Create a file. */
|
||||
assertMakeFile("f", 0644, "a");
|
||||
|
||||
/* Archive it with gzip compression. */
|
||||
r = systemf("echo f | %s -oz >archive.out 2>archive.err",
|
||||
testprog);
|
||||
p = slurpfile(&s, "archive.err");
|
||||
p[s] = '\0';
|
||||
if (r != 0) {
|
||||
if (strstr(p, "compression not available") != NULL) {
|
||||
skipping("This version of bsdcpio was compiled "
|
||||
"without gzip support");
|
||||
return;
|
||||
}
|
||||
failure("-z option is broken");
|
||||
assertEqualInt(r, 0);
|
||||
return;
|
||||
}
|
||||
/* Check that the archive file has a gzip signature. */
|
||||
p = slurpfile(&s, "archive.out");
|
||||
assert(s > 4);
|
||||
assertEqualMem(p, "\x1f\x8b\x08\x00", 4);
|
||||
}
|
122
external/bsd/libarchive/dist/cpio/test/test_owner_parse.c
vendored
Normal file
122
external/bsd/libarchive/dist/cpio/test/test_owner_parse.c
vendored
Normal file
|
@ -0,0 +1,122 @@
|
|||
/*-
|
||||
* Copyright (c) 2003-2009 Tim Kientzle
|
||||
* 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(S) ``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(S) 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.
|
||||
*/
|
||||
#include "test.h"
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
#include "../cpio.h"
|
||||
#include "err.h"
|
||||
|
||||
#if !defined(_WIN32)
|
||||
#define ROOT "root"
|
||||
static int root_uids[] = { 0 };
|
||||
/* Solaris 9 root has gid 1 (other) */
|
||||
static int root_gids[] = { 0, 1 };
|
||||
#elif defined(__CYGWIN__)
|
||||
/* On cygwin, the Administrator user most likely exists (unless
|
||||
* it has been renamed or is in a non-English localization), but
|
||||
* its primary group membership depends on how the user set up
|
||||
* their /etc/passwd. Likely values are 513 (None), 545 (Users),
|
||||
* or 544 (Administrators). Just check for one of those...
|
||||
* TODO: Handle non-English localizations...e.g. French 'Administrateur'
|
||||
* Use CreateWellKnownSID() and LookupAccountName()?
|
||||
*/
|
||||
#define ROOT "Administrator"
|
||||
static int root_uids[] = { 500 };
|
||||
static int root_gids[] = { 513, 545, 544 };
|
||||
#endif
|
||||
|
||||
#if defined(ROOT)
|
||||
static int
|
||||
int_in_list(int i, int *l, size_t n)
|
||||
{
|
||||
while (n-- > 0)
|
||||
if (*l++ == i)
|
||||
return (1);
|
||||
failure("%d", i);
|
||||
return (0);
|
||||
}
|
||||
#endif
|
||||
|
||||
DEFINE_TEST(test_owner_parse)
|
||||
{
|
||||
#if !defined(ROOT)
|
||||
skipping("No uid/gid configuration for this OS");
|
||||
#else
|
||||
int uid, gid;
|
||||
|
||||
assert(NULL == owner_parse(ROOT, &uid, &gid));
|
||||
assert(int_in_list(uid, root_uids,
|
||||
sizeof(root_uids)/sizeof(root_uids[0])));
|
||||
assertEqualInt(-1, gid);
|
||||
|
||||
|
||||
assert(NULL == owner_parse(ROOT ":", &uid, &gid));
|
||||
assert(int_in_list(uid, root_uids,
|
||||
sizeof(root_uids)/sizeof(root_uids[0])));
|
||||
assert(int_in_list(gid, root_gids,
|
||||
sizeof(root_gids)/sizeof(root_gids[0])));
|
||||
|
||||
assert(NULL == owner_parse(ROOT ".", &uid, &gid));
|
||||
assert(int_in_list(uid, root_uids,
|
||||
sizeof(root_uids)/sizeof(root_uids[0])));
|
||||
assert(int_in_list(gid, root_gids,
|
||||
sizeof(root_gids)/sizeof(root_gids[0])));
|
||||
|
||||
assert(NULL == owner_parse("111", &uid, &gid));
|
||||
assertEqualInt(111, uid);
|
||||
assertEqualInt(-1, gid);
|
||||
|
||||
assert(NULL == owner_parse("112:", &uid, &gid));
|
||||
assertEqualInt(112, uid);
|
||||
/* Can't assert gid, since we don't know gid for user #112. */
|
||||
|
||||
assert(NULL == owner_parse("113.", &uid, &gid));
|
||||
assertEqualInt(113, uid);
|
||||
/* Can't assert gid, since we don't know gid for user #113. */
|
||||
|
||||
assert(NULL == owner_parse(":114", &uid, &gid));
|
||||
assertEqualInt(-1, uid);
|
||||
assertEqualInt(114, gid);
|
||||
|
||||
assert(NULL == owner_parse(".115", &uid, &gid));
|
||||
assertEqualInt(-1, uid);
|
||||
assertEqualInt(115, gid);
|
||||
|
||||
assert(NULL == owner_parse("116:117", &uid, &gid));
|
||||
assertEqualInt(116, uid);
|
||||
assertEqualInt(117, gid);
|
||||
|
||||
/*
|
||||
* TODO: Lookup current user/group name, build strings and
|
||||
* use those to verify username/groupname lookups for ordinary
|
||||
* users.
|
||||
*/
|
||||
|
||||
assert(NULL != owner_parse(":nonexistentgroup", &uid, &gid));
|
||||
assert(NULL != owner_parse(ROOT ":nonexistentgroup", &uid, &gid));
|
||||
assert(NULL !=
|
||||
owner_parse("nonexistentuser:nonexistentgroup", &uid, &gid));
|
||||
#endif
|
||||
}
|
76
external/bsd/libarchive/dist/cpio/test/test_passthrough_dotdot.c
vendored
Normal file
76
external/bsd/libarchive/dist/cpio/test/test_passthrough_dotdot.c
vendored
Normal file
|
@ -0,0 +1,76 @@
|
|||
/*-
|
||||
* Copyright (c) 2003-2007 Tim Kientzle
|
||||
* 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(S) ``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(S) 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.
|
||||
*/
|
||||
#include "test.h"
|
||||
__FBSDID("$FreeBSD: src/usr.bin/cpio/test/test_passthrough_dotdot.c,v 1.4 2008/08/24 06:21:00 kientzle Exp $");
|
||||
|
||||
/*
|
||||
* Verify that "cpio -p .." works.
|
||||
*/
|
||||
|
||||
DEFINE_TEST(test_passthrough_dotdot)
|
||||
{
|
||||
int r;
|
||||
FILE *filelist;
|
||||
|
||||
assertUmask(0);
|
||||
|
||||
/*
|
||||
* Create an assortment of files on disk.
|
||||
*/
|
||||
filelist = fopen("filelist", "w");
|
||||
|
||||
/* Directory. */
|
||||
assertMakeDir("dir", 0755);
|
||||
assertChdir("dir");
|
||||
|
||||
fprintf(filelist, ".\n");
|
||||
|
||||
/* File with 10 bytes content. */
|
||||
assertMakeFile("file", 0642, "1234567890");
|
||||
fprintf(filelist, "file\n");
|
||||
|
||||
/* All done. */
|
||||
fclose(filelist);
|
||||
|
||||
|
||||
/*
|
||||
* Use cpio passthrough mode to copy files to another directory.
|
||||
*/
|
||||
r = systemf("%s -pdvm .. <../filelist >../stdout 2>../stderr",
|
||||
testprog);
|
||||
failure("Error invoking %s -pd ..", testprog);
|
||||
assertEqualInt(r, 0);
|
||||
|
||||
assertChdir("..");
|
||||
|
||||
/* Verify stderr and stdout. */
|
||||
assertTextFileContents("../.\n../file\n1 block\n", "stderr");
|
||||
assertEmptyFile("stdout");
|
||||
|
||||
/* Regular file. */
|
||||
assertIsReg("file", 0642);
|
||||
assertFileSize("file", 10);
|
||||
assertFileNLinks("file", 1);
|
||||
}
|
85
external/bsd/libarchive/dist/cpio/test/test_passthrough_reverse.c
vendored
Normal file
85
external/bsd/libarchive/dist/cpio/test/test_passthrough_reverse.c
vendored
Normal file
|
@ -0,0 +1,85 @@
|
|||
/*-
|
||||
* Copyright (c) 2003-2007 Tim Kientzle
|
||||
* 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(S) ``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(S) 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.
|
||||
*/
|
||||
#include "test.h"
|
||||
__FBSDID("$FreeBSD: src/usr.bin/cpio/test/test_passthrough_reverse.c,v 1.2 2008/08/24 06:21:00 kientzle Exp $");
|
||||
|
||||
/*
|
||||
* As reported by Bernd Walter: Some people are in the habit of
|
||||
* using "find -d" to generate a list for cpio -p because that
|
||||
* copies the top-level dir last, which preserves owner and mode
|
||||
* information. That's not necessary for bsdcpio (libarchive defers
|
||||
* restoring directory information), but bsdcpio should still generate
|
||||
* the correct results with this usage.
|
||||
*/
|
||||
|
||||
DEFINE_TEST(test_passthrough_reverse)
|
||||
{
|
||||
int r;
|
||||
FILE *filelist;
|
||||
|
||||
assertUmask(0);
|
||||
|
||||
/*
|
||||
* Create an assortment of files on disk.
|
||||
*/
|
||||
filelist = fopen("filelist", "w");
|
||||
|
||||
/* Directory. */
|
||||
assertMakeDir("dir", 0743);
|
||||
|
||||
/* File with 10 bytes content. */
|
||||
assertMakeFile("dir/file", 0644, "1234567890");
|
||||
fprintf(filelist, "dir/file\n");
|
||||
|
||||
/* Write dir last. */
|
||||
fprintf(filelist, "dir\n");
|
||||
|
||||
/* All done. */
|
||||
fclose(filelist);
|
||||
|
||||
|
||||
/*
|
||||
* Use cpio passthrough mode to copy files to another directory.
|
||||
*/
|
||||
r = systemf("%s -pdvm out <filelist >stdout 2>stderr", testprog);
|
||||
failure("Error invoking %s -pd out", testprog);
|
||||
assertEqualInt(r, 0);
|
||||
|
||||
assertChdir("out");
|
||||
|
||||
/* Verify stderr and stdout. */
|
||||
assertTextFileContents("out/dir/file\nout/dir\n1 block\n",
|
||||
"../stderr");
|
||||
assertEmptyFile("../stdout");
|
||||
|
||||
/* dir */
|
||||
assertIsDir("dir", 0743);
|
||||
|
||||
|
||||
/* Regular file. */
|
||||
assertIsReg("dir/file", 0644);
|
||||
assertFileSize("dir/file", 10);
|
||||
assertFileNLinks("dir/file", 1);
|
||||
}
|
243
external/bsd/libarchive/dist/cpio/test/test_pathmatch.c
vendored
Normal file
243
external/bsd/libarchive/dist/cpio/test/test_pathmatch.c
vendored
Normal file
|
@ -0,0 +1,243 @@
|
|||
/*-
|
||||
* Copyright (c) 2003-2007 Tim Kientzle
|
||||
* 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(S) ``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(S) 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.
|
||||
*/
|
||||
#include "test.h"
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
#include "pathmatch.h"
|
||||
|
||||
/*
|
||||
* Verify that the pattern matcher implements the wildcard logic specified
|
||||
* in SUSv2 for the cpio command. This is essentially the
|
||||
* shell glob syntax:
|
||||
* * - matches any sequence of chars, including '/'
|
||||
* ? - matches any single char, including '/'
|
||||
* [...] - matches any of a set of chars, '-' specifies a range,
|
||||
* initial '!' is undefined
|
||||
*
|
||||
* The specification in SUSv2 is a bit incomplete, I assume the following:
|
||||
* Trailing '-' in [...] is not special.
|
||||
*
|
||||
* TODO: Figure out if there's a good way to extend this to handle
|
||||
* Windows paths that use '\' as a path separator. <sigh>
|
||||
*/
|
||||
|
||||
DEFINE_TEST(test_pathmatch)
|
||||
{
|
||||
assertEqualInt(1, lafe_pathmatch("a/b/c", "a/b/c", 0));
|
||||
assertEqualInt(0, lafe_pathmatch("a/b/", "a/b/c", 0));
|
||||
assertEqualInt(0, lafe_pathmatch("a/b", "a/b/c", 0));
|
||||
assertEqualInt(0, lafe_pathmatch("a/b/c", "a/b/", 0));
|
||||
assertEqualInt(0, lafe_pathmatch("a/b/c", "a/b", 0));
|
||||
|
||||
/* Empty pattern only matches empty string. */
|
||||
assertEqualInt(1, lafe_pathmatch("","", 0));
|
||||
assertEqualInt(0, lafe_pathmatch("","a", 0));
|
||||
assertEqualInt(1, lafe_pathmatch("*","", 0));
|
||||
assertEqualInt(1, lafe_pathmatch("*","a", 0));
|
||||
assertEqualInt(1, lafe_pathmatch("*","abcd", 0));
|
||||
/* SUSv2: * matches / */
|
||||
assertEqualInt(1, lafe_pathmatch("*","abcd/efgh/ijkl", 0));
|
||||
assertEqualInt(1, lafe_pathmatch("abcd*efgh/ijkl","abcd/efgh/ijkl", 0));
|
||||
assertEqualInt(1, lafe_pathmatch("abcd***efgh/ijkl","abcd/efgh/ijkl", 0));
|
||||
assertEqualInt(1, lafe_pathmatch("abcd***/efgh/ijkl","abcd/efgh/ijkl", 0));
|
||||
assertEqualInt(0, lafe_pathmatch("?", "", 0));
|
||||
assertEqualInt(0, lafe_pathmatch("?", "\0", 0));
|
||||
assertEqualInt(1, lafe_pathmatch("?", "a", 0));
|
||||
assertEqualInt(0, lafe_pathmatch("?", "ab", 0));
|
||||
assertEqualInt(1, lafe_pathmatch("?", ".", 0));
|
||||
assertEqualInt(1, lafe_pathmatch("?", "?", 0));
|
||||
assertEqualInt(1, lafe_pathmatch("a", "a", 0));
|
||||
assertEqualInt(0, lafe_pathmatch("a", "ab", 0));
|
||||
assertEqualInt(0, lafe_pathmatch("a", "ab", 0));
|
||||
assertEqualInt(1, lafe_pathmatch("a?c", "abc", 0));
|
||||
/* SUSv2: ? matches / */
|
||||
assertEqualInt(1, lafe_pathmatch("a?c", "a/c", 0));
|
||||
assertEqualInt(1, lafe_pathmatch("a?*c*", "a/c", 0));
|
||||
assertEqualInt(1, lafe_pathmatch("*a*", "a/c", 0));
|
||||
assertEqualInt(1, lafe_pathmatch("*a*", "/a/c", 0));
|
||||
assertEqualInt(1, lafe_pathmatch("*a*", "defaaaaaaa", 0));
|
||||
assertEqualInt(0, lafe_pathmatch("a*", "defghi", 0));
|
||||
assertEqualInt(0, lafe_pathmatch("*a*", "defghi", 0));
|
||||
|
||||
/* Character classes */
|
||||
assertEqualInt(1, lafe_pathmatch("abc[def", "abc[def", 0));
|
||||
assertEqualInt(0, lafe_pathmatch("abc[def]", "abc[def", 0));
|
||||
assertEqualInt(0, lafe_pathmatch("abc[def", "abcd", 0));
|
||||
assertEqualInt(1, lafe_pathmatch("abc[def]", "abcd", 0));
|
||||
assertEqualInt(1, lafe_pathmatch("abc[def]", "abce", 0));
|
||||
assertEqualInt(1, lafe_pathmatch("abc[def]", "abcf", 0));
|
||||
assertEqualInt(0, lafe_pathmatch("abc[def]", "abcg", 0));
|
||||
assertEqualInt(1, lafe_pathmatch("abc[d*f]", "abcd", 0));
|
||||
assertEqualInt(1, lafe_pathmatch("abc[d*f]", "abc*", 0));
|
||||
assertEqualInt(0, lafe_pathmatch("abc[d*f]", "abcdefghi", 0));
|
||||
assertEqualInt(0, lafe_pathmatch("abc[d*", "abcdefghi", 0));
|
||||
assertEqualInt(1, lafe_pathmatch("abc[d*", "abc[defghi", 0));
|
||||
assertEqualInt(1, lafe_pathmatch("abc[d-f]", "abcd", 0));
|
||||
assertEqualInt(1, lafe_pathmatch("abc[d-f]", "abce", 0));
|
||||
assertEqualInt(1, lafe_pathmatch("abc[d-f]", "abcf", 0));
|
||||
assertEqualInt(0, lafe_pathmatch("abc[d-f]", "abcg", 0));
|
||||
assertEqualInt(0, lafe_pathmatch("abc[d-fh-k]", "abca", 0));
|
||||
assertEqualInt(1, lafe_pathmatch("abc[d-fh-k]", "abcd", 0));
|
||||
assertEqualInt(1, lafe_pathmatch("abc[d-fh-k]", "abce", 0));
|
||||
assertEqualInt(1, lafe_pathmatch("abc[d-fh-k]", "abcf", 0));
|
||||
assertEqualInt(0, lafe_pathmatch("abc[d-fh-k]", "abcg", 0));
|
||||
assertEqualInt(1, lafe_pathmatch("abc[d-fh-k]", "abch", 0));
|
||||
assertEqualInt(1, lafe_pathmatch("abc[d-fh-k]", "abci", 0));
|
||||
assertEqualInt(1, lafe_pathmatch("abc[d-fh-k]", "abcj", 0));
|
||||
assertEqualInt(1, lafe_pathmatch("abc[d-fh-k]", "abck", 0));
|
||||
assertEqualInt(0, lafe_pathmatch("abc[d-fh-k]", "abcl", 0));
|
||||
assertEqualInt(0, lafe_pathmatch("abc[d-fh-k]", "abc-", 0));
|
||||
|
||||
/* [] matches nothing, [!] is the same as ? */
|
||||
assertEqualInt(0, lafe_pathmatch("abc[]efg", "abcdefg", 0));
|
||||
assertEqualInt(0, lafe_pathmatch("abc[]efg", "abcqefg", 0));
|
||||
assertEqualInt(0, lafe_pathmatch("abc[]efg", "abcefg", 0));
|
||||
assertEqualInt(1, lafe_pathmatch("abc[!]efg", "abcdefg", 0));
|
||||
assertEqualInt(1, lafe_pathmatch("abc[!]efg", "abcqefg", 0));
|
||||
assertEqualInt(0, lafe_pathmatch("abc[!]efg", "abcefg", 0));
|
||||
|
||||
/* I assume: Trailing '-' is non-special. */
|
||||
assertEqualInt(0, lafe_pathmatch("abc[d-fh-]", "abcl", 0));
|
||||
assertEqualInt(1, lafe_pathmatch("abc[d-fh-]", "abch", 0));
|
||||
assertEqualInt(1, lafe_pathmatch("abc[d-fh-]", "abc-", 0));
|
||||
assertEqualInt(1, lafe_pathmatch("abc[d-fh-]", "abc-", 0));
|
||||
|
||||
/* ']' can be backslash-quoted within a character class. */
|
||||
assertEqualInt(1, lafe_pathmatch("abc[\\]]", "abc]", 0));
|
||||
assertEqualInt(1, lafe_pathmatch("abc[\\]d]", "abc]", 0));
|
||||
assertEqualInt(1, lafe_pathmatch("abc[\\]d]", "abcd", 0));
|
||||
assertEqualInt(1, lafe_pathmatch("abc[d\\]]", "abc]", 0));
|
||||
assertEqualInt(1, lafe_pathmatch("abc[d\\]]", "abcd", 0));
|
||||
assertEqualInt(1, lafe_pathmatch("abc[d]e]", "abcde]", 0));
|
||||
assertEqualInt(1, lafe_pathmatch("abc[d\\]e]", "abc]", 0));
|
||||
assertEqualInt(0, lafe_pathmatch("abc[d\\]e]", "abcd]e", 0));
|
||||
assertEqualInt(0, lafe_pathmatch("abc[d]e]", "abc]", 0));
|
||||
|
||||
/* backslash-quoted chars can appear as either end of a range. */
|
||||
assertEqualInt(1, lafe_pathmatch("abc[\\d-f]gh", "abcegh", 0));
|
||||
assertEqualInt(0, lafe_pathmatch("abc[\\d-f]gh", "abcggh", 0));
|
||||
assertEqualInt(0, lafe_pathmatch("abc[\\d-f]gh", "abc\\gh", 0));
|
||||
assertEqualInt(1, lafe_pathmatch("abc[d-\\f]gh", "abcegh", 0));
|
||||
assertEqualInt(1, lafe_pathmatch("abc[\\d-\\f]gh", "abcegh", 0));
|
||||
assertEqualInt(1, lafe_pathmatch("abc[\\d-\\f]gh", "abcegh", 0));
|
||||
/* backslash-quoted '-' isn't special. */
|
||||
assertEqualInt(0, lafe_pathmatch("abc[d\\-f]gh", "abcegh", 0));
|
||||
assertEqualInt(1, lafe_pathmatch("abc[d\\-f]gh", "abc-gh", 0));
|
||||
|
||||
/* Leading '!' negates a character class. */
|
||||
assertEqualInt(0, lafe_pathmatch("abc[!d]", "abcd", 0));
|
||||
assertEqualInt(1, lafe_pathmatch("abc[!d]", "abce", 0));
|
||||
assertEqualInt(1, lafe_pathmatch("abc[!d]", "abcc", 0));
|
||||
assertEqualInt(0, lafe_pathmatch("abc[!d-z]", "abcq", 0));
|
||||
assertEqualInt(1, lafe_pathmatch("abc[!d-gi-z]", "abch", 0));
|
||||
assertEqualInt(1, lafe_pathmatch("abc[!fgijkl]", "abch", 0));
|
||||
assertEqualInt(0, lafe_pathmatch("abc[!fghijkl]", "abch", 0));
|
||||
|
||||
/* Backslash quotes next character. */
|
||||
assertEqualInt(0, lafe_pathmatch("abc\\[def]", "abc\\d", 0));
|
||||
assertEqualInt(1, lafe_pathmatch("abc\\[def]", "abc[def]", 0));
|
||||
assertEqualInt(0, lafe_pathmatch("abc\\\\[def]", "abc[def]", 0));
|
||||
assertEqualInt(0, lafe_pathmatch("abc\\\\[def]", "abc\\[def]", 0));
|
||||
assertEqualInt(1, lafe_pathmatch("abc\\\\[def]", "abc\\d", 0));
|
||||
assertEqualInt(1, lafe_pathmatch("abcd\\", "abcd\\", 0));
|
||||
assertEqualInt(0, lafe_pathmatch("abcd\\", "abcd\\[", 0));
|
||||
assertEqualInt(0, lafe_pathmatch("abcd\\", "abcde", 0));
|
||||
assertEqualInt(0, lafe_pathmatch("abcd\\[", "abcd\\", 0));
|
||||
|
||||
/*
|
||||
* Because '.' and '/' have special meanings, we can
|
||||
* identify many equivalent paths even if they're expressed
|
||||
* differently. (But quoting a character with '\\' suppresses
|
||||
* special meanings!)
|
||||
*/
|
||||
assertEqualInt(0, lafe_pathmatch("a/b/", "a/bc", 0));
|
||||
assertEqualInt(1, lafe_pathmatch("a/./b", "a/b", 0));
|
||||
assertEqualInt(0, lafe_pathmatch("a\\/./b", "a/b", 0));
|
||||
assertEqualInt(0, lafe_pathmatch("a/\\./b", "a/b", 0));
|
||||
assertEqualInt(0, lafe_pathmatch("a/.\\/b", "a/b", 0));
|
||||
assertEqualInt(0, lafe_pathmatch("a\\/\\.\\/b", "a/b", 0));
|
||||
assertEqualInt(1, lafe_pathmatch("./abc/./def/", "abc/def/", 0));
|
||||
assertEqualInt(1, lafe_pathmatch("abc/def", "./././abc/./def", 0));
|
||||
assertEqualInt(1, lafe_pathmatch("abc/def/././//", "./././abc/./def/", 0));
|
||||
assertEqualInt(1, lafe_pathmatch(".////abc/.//def", "./././abc/./def", 0));
|
||||
assertEqualInt(1, lafe_pathmatch("./abc?def/", "abc/def/", 0));
|
||||
failure("\"?./\" is not the same as \"/./\"");
|
||||
assertEqualInt(0, lafe_pathmatch("./abc?./def/", "abc/def/", 0));
|
||||
failure("Trailing '/' should match no trailing '/'");
|
||||
assertEqualInt(1, lafe_pathmatch("./abc/./def/", "abc/def", 0));
|
||||
failure("Trailing '/./' is still the same directory.");
|
||||
assertEqualInt(1, lafe_pathmatch("./abc/./def/./", "abc/def", 0));
|
||||
failure("Trailing '/.' is still the same directory.");
|
||||
assertEqualInt(1, lafe_pathmatch("./abc/./def/.", "abc/def", 0));
|
||||
assertEqualInt(1, lafe_pathmatch("./abc/./def", "abc/def/", 0));
|
||||
failure("Trailing '/./' is still the same directory.");
|
||||
assertEqualInt(1, lafe_pathmatch("./abc/./def", "abc/def/./", 0));
|
||||
failure("Trailing '/.' is still the same directory.");
|
||||
assertEqualInt(1, lafe_pathmatch("./abc*/./def", "abc/def/.", 0));
|
||||
|
||||
/* Matches not anchored at beginning. */
|
||||
assertEqualInt(0,
|
||||
lafe_pathmatch("bcd", "abcd", PATHMATCH_NO_ANCHOR_START));
|
||||
assertEqualInt(1,
|
||||
lafe_pathmatch("abcd", "abcd", PATHMATCH_NO_ANCHOR_START));
|
||||
assertEqualInt(0,
|
||||
lafe_pathmatch("^bcd", "abcd", PATHMATCH_NO_ANCHOR_START));
|
||||
assertEqualInt(1,
|
||||
lafe_pathmatch("b/c/d", "a/b/c/d", PATHMATCH_NO_ANCHOR_START));
|
||||
assertEqualInt(0,
|
||||
lafe_pathmatch("b/c", "a/b/c/d", PATHMATCH_NO_ANCHOR_START));
|
||||
assertEqualInt(0,
|
||||
lafe_pathmatch("^b/c", "a/b/c/d", PATHMATCH_NO_ANCHOR_START));
|
||||
|
||||
/* Matches not anchored at end. */
|
||||
assertEqualInt(0,
|
||||
lafe_pathmatch("bcd", "abcd", PATHMATCH_NO_ANCHOR_END));
|
||||
assertEqualInt(1,
|
||||
lafe_pathmatch("abcd", "abcd", PATHMATCH_NO_ANCHOR_END));
|
||||
assertEqualInt(1,
|
||||
lafe_pathmatch("abcd", "abcd/", PATHMATCH_NO_ANCHOR_END));
|
||||
assertEqualInt(1,
|
||||
lafe_pathmatch("abcd", "abcd/.", PATHMATCH_NO_ANCHOR_END));
|
||||
assertEqualInt(0,
|
||||
lafe_pathmatch("abc", "abcd", PATHMATCH_NO_ANCHOR_END));
|
||||
assertEqualInt(1,
|
||||
lafe_pathmatch("a/b/c", "a/b/c/d", PATHMATCH_NO_ANCHOR_END));
|
||||
assertEqualInt(0,
|
||||
lafe_pathmatch("a/b/c$", "a/b/c/d", PATHMATCH_NO_ANCHOR_END));
|
||||
assertEqualInt(1,
|
||||
lafe_pathmatch("a/b/c$", "a/b/c", PATHMATCH_NO_ANCHOR_END));
|
||||
assertEqualInt(1,
|
||||
lafe_pathmatch("a/b/c$", "a/b/c/", PATHMATCH_NO_ANCHOR_END));
|
||||
assertEqualInt(1,
|
||||
lafe_pathmatch("a/b/c/", "a/b/c/d", PATHMATCH_NO_ANCHOR_END));
|
||||
assertEqualInt(0,
|
||||
lafe_pathmatch("a/b/c/$", "a/b/c/d", PATHMATCH_NO_ANCHOR_END));
|
||||
assertEqualInt(1,
|
||||
lafe_pathmatch("a/b/c/$", "a/b/c/", PATHMATCH_NO_ANCHOR_END));
|
||||
assertEqualInt(1,
|
||||
lafe_pathmatch("a/b/c/$", "a/b/c", PATHMATCH_NO_ANCHOR_END));
|
||||
assertEqualInt(0,
|
||||
lafe_pathmatch("b/c", "a/b/c/d", PATHMATCH_NO_ANCHOR_END));
|
||||
}
|
|
@ -66,11 +66,6 @@
|
|||
# define __LA_UID_T short
|
||||
# define __LA_GID_T short
|
||||
# endif
|
||||
#elif defined(__minix)
|
||||
#include <unistd.h> /* ssize_t, uid_t, and gid_t */
|
||||
#define __LA_SSIZE_T ssize_t
|
||||
#define __LA_UID_T uid_t
|
||||
#define __LA_GID_T gid_t
|
||||
#else
|
||||
#include <unistd.h> /* ssize_t, uid_t, and gid_t */
|
||||
#define __LA_INT64_T int64_t
|
||||
|
@ -134,13 +129,13 @@ extern "C" {
|
|||
* (ARCHIVE_API_VERSION * 1000000 + ARCHIVE_API_FEATURE * 1000)
|
||||
* #endif
|
||||
*/
|
||||
#define ARCHIVE_VERSION_NUMBER 2008003
|
||||
#define ARCHIVE_VERSION_NUMBER 2008004
|
||||
__LA_DECL int archive_version_number(void);
|
||||
|
||||
/*
|
||||
* Textual name/version of the library, useful for version displays.
|
||||
*/
|
||||
#define ARCHIVE_VERSION_STRING "libarchive 2.8.3"
|
||||
#define ARCHIVE_VERSION_STRING "libarchive 2.8.4"
|
||||
__LA_DECL const char * archive_version_string(void);
|
||||
|
||||
#if ARCHIVE_VERSION_NUMBER < 3000000
|
||||
|
@ -268,14 +263,12 @@ typedef int archive_close_callback(struct archive *, void *_client_data);
|
|||
* entry to be in a different format.)
|
||||
*/
|
||||
#define ARCHIVE_FORMAT_BASE_MASK 0xff0000
|
||||
#ifndef __minix
|
||||
#define ARCHIVE_FORMAT_CPIO 0x10000
|
||||
#define ARCHIVE_FORMAT_CPIO_POSIX (ARCHIVE_FORMAT_CPIO | 1)
|
||||
#define ARCHIVE_FORMAT_CPIO_BIN_LE (ARCHIVE_FORMAT_CPIO | 2)
|
||||
#define ARCHIVE_FORMAT_CPIO_BIN_BE (ARCHIVE_FORMAT_CPIO | 3)
|
||||
#define ARCHIVE_FORMAT_CPIO_SVR4_NOCRC (ARCHIVE_FORMAT_CPIO | 4)
|
||||
#define ARCHIVE_FORMAT_CPIO_SVR4_CRC (ARCHIVE_FORMAT_CPIO | 5)
|
||||
#endif
|
||||
#define ARCHIVE_FORMAT_SHAR 0x20000
|
||||
#define ARCHIVE_FORMAT_SHAR_BASE (ARCHIVE_FORMAT_SHAR | 1)
|
||||
#define ARCHIVE_FORMAT_SHAR_DUMP (ARCHIVE_FORMAT_SHAR | 2)
|
||||
|
@ -328,17 +321,13 @@ __LA_DECL int archive_read_support_compression_program_signature
|
|||
(struct archive *, const char *,
|
||||
const void * /* match */, size_t);
|
||||
|
||||
#ifndef __minix
|
||||
__LA_DECL int archive_read_support_compression_rpm(struct archive *);
|
||||
#endif
|
||||
__LA_DECL int archive_read_support_compression_uu(struct archive *);
|
||||
__LA_DECL int archive_read_support_compression_xz(struct archive *);
|
||||
|
||||
__LA_DECL int archive_read_support_format_all(struct archive *);
|
||||
__LA_DECL int archive_read_support_format_ar(struct archive *);
|
||||
#ifndef __minix
|
||||
__LA_DECL int archive_read_support_format_cpio(struct archive *);
|
||||
#endif
|
||||
__LA_DECL int archive_read_support_format_empty(struct archive *);
|
||||
__LA_DECL int archive_read_support_format_gnutar(struct archive *);
|
||||
__LA_DECL int archive_read_support_format_iso9660(struct archive *);
|
||||
|
@ -393,12 +382,7 @@ __LA_DECL int archive_read_next_header2(struct archive *,
|
|||
* Retrieve the byte offset in UNCOMPRESSED data where last-read
|
||||
* header started.
|
||||
*/
|
||||
#ifndef __minix
|
||||
__LA_DECL __LA_INT64_T archive_read_header_position(struct archive *);
|
||||
#else
|
||||
__LA_DECL off_t archive_read_header_position(struct archive *);
|
||||
#endif
|
||||
|
||||
|
||||
/* Read data from the body of an entry. Similar to read(2). */
|
||||
__LA_DECL __LA_SSIZE_T archive_read_data(struct archive *,
|
||||
|
@ -553,10 +537,8 @@ __LA_DECL int archive_write_set_format_by_name(struct archive *,
|
|||
/* To minimize link pollution, use one or more of the following. */
|
||||
__LA_DECL int archive_write_set_format_ar_bsd(struct archive *);
|
||||
__LA_DECL int archive_write_set_format_ar_svr4(struct archive *);
|
||||
#ifndef __minix
|
||||
__LA_DECL int archive_write_set_format_cpio(struct archive *);
|
||||
__LA_DECL int archive_write_set_format_cpio_newc(struct archive *);
|
||||
#endif
|
||||
__LA_DECL int archive_write_set_format_mtree(struct archive *);
|
||||
/* TODO: int archive_write_set_format_old_tar(struct archive *); */
|
||||
__LA_DECL int archive_write_set_format_pax(struct archive *);
|
||||
|
@ -724,17 +706,10 @@ __LA_DECL int archive_read_disk_set_uname_lookup(struct archive *,
|
|||
* Accessor functions to read/set various information in
|
||||
* the struct archive object:
|
||||
*/
|
||||
#ifndef __minix
|
||||
/* Bytes written after compression or read before decompression. */
|
||||
__LA_DECL __LA_INT64_T archive_position_compressed(struct archive *);
|
||||
/* Bytes written to compressor or read from decompressor. */
|
||||
__LA_DECL __LA_INT64_T archive_position_uncompressed(struct archive *);
|
||||
#else
|
||||
/* Bytes written after compression or read before decompression. */
|
||||
__LA_DECL off_t archive_position_compressed(struct archive *);
|
||||
/* Bytes written to compressor or read from decompressor. */
|
||||
__LA_DECL off_t archive_position_uncompressed(struct archive *);
|
||||
#endif
|
||||
|
||||
__LA_DECL const char *archive_compression_name(struct archive *);
|
||||
__LA_DECL int archive_compression(struct archive *);
|
||||
|
@ -744,7 +719,8 @@ __LA_DECL const char *archive_format_name(struct archive *);
|
|||
__LA_DECL int archive_format(struct archive *);
|
||||
__LA_DECL void archive_clear_error(struct archive *);
|
||||
__LA_DECL void archive_set_error(struct archive *, int _err,
|
||||
const char *fmt, ...);
|
||||
const char *fmt, ...)
|
||||
__attribute__((__format__(__printf__,3,4)));
|
||||
__LA_DECL void archive_copy_error(struct archive *dest,
|
||||
struct archive *src);
|
||||
__LA_DECL int archive_file_count(struct archive *);
|
|
@ -62,7 +62,7 @@ errmsg(const char *m)
|
|||
}
|
||||
}
|
||||
|
||||
static void
|
||||
__dead static void
|
||||
diediedie(void)
|
||||
{
|
||||
#if defined(_WIN32) && !defined(__CYGWIN__) && defined(_DEBUG)
|
|
@ -45,16 +45,12 @@
|
|||
* - SGI MIPSpro
|
||||
* - Microsoft Visual C++ 6.0 (supposedly newer versions too)
|
||||
*/
|
||||
#if defined(__WATCOMC__) || defined(__sgi) || defined(__hpux) || defined(__BORLANDC__) || defined(__ACK__)
|
||||
#if defined(__WATCOMC__) || defined(__sgi) || defined(__hpux) || defined(__BORLANDC__)
|
||||
#define inline
|
||||
#elif defined(_MSC_VER)
|
||||
#define inline __inline
|
||||
#endif
|
||||
|
||||
#ifdef __minix
|
||||
#include <minix/u64.h>
|
||||
#endif
|
||||
|
||||
/* Alignment-agnostic encode/decode bytestream to/from little/big endian. */
|
||||
|
||||
static inline uint16_t
|
||||
|
@ -73,7 +69,6 @@ archive_be32dec(const void *pp)
|
|||
return ((p[0] << 24) | (p[1] << 16) | (p[2] << 8) | p[3]);
|
||||
}
|
||||
|
||||
#ifndef __minix
|
||||
static inline uint64_t
|
||||
archive_be64dec(const void *pp)
|
||||
{
|
||||
|
@ -81,15 +76,6 @@ archive_be64dec(const void *pp)
|
|||
|
||||
return (((uint64_t)archive_be32dec(p) << 32) | archive_be32dec(p + 4));
|
||||
}
|
||||
#else
|
||||
static inline u64_t
|
||||
archive_be64dec(const void *pp)
|
||||
{
|
||||
unsigned char const *p = (unsigned char const *)pp;
|
||||
|
||||
return make64(archive_be32dec(p + 4), archive_be32dec(p));
|
||||
}
|
||||
#endif
|
||||
|
||||
static inline uint16_t
|
||||
archive_le16dec(const void *pp)
|
||||
|
@ -107,7 +93,6 @@ archive_le32dec(const void *pp)
|
|||
return ((p[3] << 24) | (p[2] << 16) | (p[1] << 8) | p[0]);
|
||||
}
|
||||
|
||||
#ifndef __minix
|
||||
static inline uint64_t
|
||||
archive_le64dec(const void *pp)
|
||||
{
|
||||
|
@ -115,15 +100,6 @@ archive_le64dec(const void *pp)
|
|||
|
||||
return (((uint64_t)archive_le32dec(p + 4) << 32) | archive_le32dec(p));
|
||||
}
|
||||
#else
|
||||
static inline u64_t
|
||||
archive_le64dec(const void *pp)
|
||||
{
|
||||
unsigned char const *p = (unsigned char const *)pp;
|
||||
|
||||
return make64(archive_le32dec(p), archive_le32dec(p + 4));
|
||||
}
|
||||
#endif
|
||||
|
||||
static inline void
|
||||
archive_be16enc(void *pp, uint16_t u)
|
||||
|
@ -145,7 +121,6 @@ archive_be32enc(void *pp, uint32_t u)
|
|||
p[3] = u & 0xff;
|
||||
}
|
||||
|
||||
#ifndef __minix
|
||||
static inline void
|
||||
archive_be64enc(void *pp, uint64_t u)
|
||||
{
|
||||
|
@ -154,16 +129,6 @@ archive_be64enc(void *pp, uint64_t u)
|
|||
archive_be32enc(p, u >> 32);
|
||||
archive_be32enc(p + 4, u & 0xffffffff);
|
||||
}
|
||||
#else
|
||||
static inline void
|
||||
archive_be64enc(void *pp, u64_t u)
|
||||
{
|
||||
unsigned char *p = (unsigned char *)pp;
|
||||
|
||||
archive_be32enc(p, ex64hi(u));
|
||||
archive_be32enc(p + 4, ex64lo(u));
|
||||
}
|
||||
#endif
|
||||
|
||||
static inline void
|
||||
archive_le16enc(void *pp, uint16_t u)
|
||||
|
@ -185,7 +150,6 @@ archive_le32enc(void *pp, uint32_t u)
|
|||
p[3] = (u >> 24) & 0xff;
|
||||
}
|
||||
|
||||
#ifndef __minix
|
||||
static inline void
|
||||
archive_le64enc(void *pp, uint64_t u)
|
||||
{
|
||||
|
@ -194,14 +158,5 @@ archive_le64enc(void *pp, uint64_t u)
|
|||
archive_le32enc(p, u & 0xffffffff);
|
||||
archive_le32enc(p + 4, u >> 32);
|
||||
}
|
||||
#else
|
||||
static inline void
|
||||
archive_le64enc(void *pp, u64_t u)
|
||||
{
|
||||
unsigned char *p = (unsigned char *)pp;
|
||||
|
||||
archive_le32enc(p, ex64lo(u));
|
||||
archive_le32enc(p + 4, ex64hi(u));
|
||||
}
|
||||
#endif
|
||||
#endif
|
|
@ -336,11 +336,11 @@ Returns the specified data.
|
|||
In the case of strings, a const-qualified pointer to
|
||||
the string is returned.
|
||||
.El
|
||||
String data can be set or accessed as wide character strings
|
||||
String data can be set or accessed as wide-character strings
|
||||
or normal
|
||||
.Va char
|
||||
strings.
|
||||
The functions that use wide character strings are suffixed with
|
||||
The functions that use wide-character strings are suffixed with
|
||||
.Cm _w .
|
||||
Note that these are different representations of the same data:
|
||||
For example, if you store a narrow string and read the corresponding
|
|
@ -625,14 +625,11 @@ archive_entry_ino(struct archive_entry *entry)
|
|||
return (entry->ae_stat.aest_ino);
|
||||
}
|
||||
|
||||
#ifndef __minix
|
||||
int64_t
|
||||
archive_entry_ino64(struct archive_entry *entry)
|
||||
{
|
||||
return (entry->ae_stat.aest_ino);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
mode_t
|
||||
archive_entry_mode(struct archive_entry *entry)
|
||||
|
@ -704,19 +701,11 @@ archive_entry_rdevminor(struct archive_entry *entry)
|
|||
return minor(entry->ae_stat.aest_rdev);
|
||||
}
|
||||
|
||||
#ifndef __minix
|
||||
int64_t
|
||||
archive_entry_size(struct archive_entry *entry)
|
||||
{
|
||||
return (entry->ae_stat.aest_size);
|
||||
}
|
||||
#else
|
||||
ssize_t
|
||||
archive_entry_size(struct archive_entry *entry)
|
||||
{
|
||||
return (entry->ae_stat.aest_size);
|
||||
}
|
||||
#endif
|
||||
|
||||
int
|
||||
archive_entry_size_is_set(struct archive_entry *entry)
|
||||
|
@ -841,14 +830,12 @@ archive_entry_set_ino(struct archive_entry *entry, unsigned long ino)
|
|||
entry->ae_stat.aest_ino = ino;
|
||||
}
|
||||
|
||||
#ifndef __minix
|
||||
void
|
||||
archive_entry_set_ino64(struct archive_entry *entry, int64_t ino)
|
||||
{
|
||||
entry->stat_valid = 0;
|
||||
entry->ae_stat.aest_ino = ino;
|
||||
}
|
||||
#endif
|
||||
|
||||
void
|
||||
archive_entry_set_hardlink(struct archive_entry *entry, const char *target)
|
||||
|
@ -1087,7 +1074,6 @@ archive_entry_set_rdevminor(struct archive_entry *entry, dev_t m)
|
|||
entry->ae_stat.aest_rdevminor = m;
|
||||
}
|
||||
|
||||
#ifndef __minix
|
||||
void
|
||||
archive_entry_set_size(struct archive_entry *entry, int64_t s)
|
||||
{
|
||||
|
@ -1095,15 +1081,6 @@ archive_entry_set_size(struct archive_entry *entry, int64_t s)
|
|||
entry->ae_stat.aest_size = s;
|
||||
entry->ae_set |= AE_SET_SIZE;
|
||||
}
|
||||
#else
|
||||
void
|
||||
archive_entry_set_size(struct archive_entry *entry, ssize_t s)
|
||||
{
|
||||
entry->stat_valid = 0;
|
||||
entry->ae_stat.aest_size = s;
|
||||
entry->ae_set |= AE_SET_SIZE;
|
||||
}
|
||||
#endif
|
||||
|
||||
void
|
||||
archive_entry_unset_size(struct archive_entry *entry)
|
|
@ -59,11 +59,6 @@
|
|||
# define __LA_DEV_T unsigned int
|
||||
# define __LA_MODE_T unsigned short
|
||||
# endif
|
||||
#elif defined(__minix)
|
||||
#define __LA_UID_T uid_t
|
||||
#define __LA_GID_T gid_t
|
||||
#define __LA_DEV_T dev_t
|
||||
#define __LA_MODE_T mode_t
|
||||
#else
|
||||
#include <unistd.h>
|
||||
#define __LA_INT64_T int64_t
|
||||
|
@ -210,9 +205,7 @@ __LA_DECL const wchar_t *archive_entry_gname_w(struct archive_entry *);
|
|||
__LA_DECL const char *archive_entry_hardlink(struct archive_entry *);
|
||||
__LA_DECL const wchar_t *archive_entry_hardlink_w(struct archive_entry *);
|
||||
__LA_DECL __LA_INO_T archive_entry_ino(struct archive_entry *);
|
||||
#ifndef __minix
|
||||
__LA_DECL __LA_INT64_T archive_entry_ino64(struct archive_entry *);
|
||||
#endif
|
||||
__LA_DECL __LA_MODE_T archive_entry_mode(struct archive_entry *);
|
||||
__LA_DECL time_t archive_entry_mtime(struct archive_entry *);
|
||||
__LA_DECL long archive_entry_mtime_nsec(struct archive_entry *);
|
||||
|
@ -224,11 +217,7 @@ __LA_DECL dev_t archive_entry_rdev(struct archive_entry *);
|
|||
__LA_DECL dev_t archive_entry_rdevmajor(struct archive_entry *);
|
||||
__LA_DECL dev_t archive_entry_rdevminor(struct archive_entry *);
|
||||
__LA_DECL const char *archive_entry_sourcepath(struct archive_entry *);
|
||||
#ifndef __minix
|
||||
__LA_DECL __LA_INT64_T archive_entry_size(struct archive_entry *);
|
||||
#else
|
||||
__LA_DECL ssize_t archive_entry_size(struct archive_entry *);
|
||||
#endif
|
||||
__LA_DECL int archive_entry_size_is_set(struct archive_entry *);
|
||||
__LA_DECL const char *archive_entry_strmode(struct archive_entry *);
|
||||
__LA_DECL const char *archive_entry_symlink(struct archive_entry *);
|
||||
|
@ -285,9 +274,7 @@ __LA_DECL void archive_entry_set_ino(struct archive_entry *, __LA_INT64_T);
|
|||
#else
|
||||
__LA_DECL void archive_entry_set_ino(struct archive_entry *, unsigned long);
|
||||
#endif
|
||||
#ifndef __minix
|
||||
__LA_DECL void archive_entry_set_ino64(struct archive_entry *, __LA_INT64_T);
|
||||
#endif
|
||||
__LA_DECL void archive_entry_set_link(struct archive_entry *, const char *);
|
||||
__LA_DECL void archive_entry_copy_link(struct archive_entry *, const char *);
|
||||
__LA_DECL void archive_entry_copy_link_w(struct archive_entry *, const wchar_t *);
|
||||
|
@ -304,11 +291,7 @@ __LA_DECL void archive_entry_set_perm(struct archive_entry *, __LA_MODE_T);
|
|||
__LA_DECL void archive_entry_set_rdev(struct archive_entry *, dev_t);
|
||||
__LA_DECL void archive_entry_set_rdevmajor(struct archive_entry *, dev_t);
|
||||
__LA_DECL void archive_entry_set_rdevminor(struct archive_entry *, dev_t);
|
||||
#ifndef __minix
|
||||
__LA_DECL void archive_entry_set_size(struct archive_entry *, __LA_INT64_T);
|
||||
#else
|
||||
__LA_DECL void archive_entry_set_size(struct archive_entry *, ssize_t);
|
||||
#endif
|
||||
__LA_DECL void archive_entry_unset_size(struct archive_entry *);
|
||||
__LA_DECL void archive_entry_copy_sourcepath(struct archive_entry *, const char *);
|
||||
__LA_DECL void archive_entry_set_symlink(struct archive_entry *, const char *);
|
|
@ -61,10 +61,8 @@ __FBSDID("$FreeBSD: head/lib/libarchive/archive_entry_link_resolver.c 201100 200
|
|||
/* Users pass us a format code, we translate that into a strategy here. */
|
||||
#define ARCHIVE_ENTRY_LINKIFY_LIKE_TAR 0
|
||||
#define ARCHIVE_ENTRY_LINKIFY_LIKE_MTREE 1
|
||||
#ifndef __minix
|
||||
#define ARCHIVE_ENTRY_LINKIFY_LIKE_OLD_CPIO 2
|
||||
#define ARCHIVE_ENTRY_LINKIFY_LIKE_NEW_CPIO 3
|
||||
#endif
|
||||
|
||||
/* Initial size of link cache. */
|
||||
#define links_cache_initial_size 1024
|
||||
|
@ -122,7 +120,6 @@ archive_entry_linkresolver_set_strategy(struct archive_entry_linkresolver *res,
|
|||
int fmtbase = fmt & ARCHIVE_FORMAT_BASE_MASK;
|
||||
|
||||
switch (fmtbase) {
|
||||
#ifndef __minix
|
||||
case ARCHIVE_FORMAT_CPIO:
|
||||
switch (fmt) {
|
||||
case ARCHIVE_FORMAT_CPIO_SVR4_NOCRC:
|
||||
|
@ -134,7 +131,6 @@ archive_entry_linkresolver_set_strategy(struct archive_entry_linkresolver *res,
|
|||
break;
|
||||
}
|
||||
break;
|
||||
#endif
|
||||
case ARCHIVE_FORMAT_MTREE:
|
||||
res->strategy = ARCHIVE_ENTRY_LINKIFY_LIKE_MTREE;
|
||||
break;
|
||||
|
@ -169,9 +165,7 @@ archive_entry_linkify(struct archive_entry_linkresolver *res,
|
|||
struct archive_entry **e, struct archive_entry **f)
|
||||
{
|
||||
struct links_entry *le;
|
||||
#ifndef __minix
|
||||
struct archive_entry *t;
|
||||
#endif
|
||||
|
||||
*f = NULL; /* Default: Don't return a second entry. */
|
||||
|
||||
|
@ -211,7 +205,6 @@ archive_entry_linkify(struct archive_entry_linkresolver *res,
|
|||
} else
|
||||
insert_entry(res, *e);
|
||||
return;
|
||||
#ifndef __minix
|
||||
case ARCHIVE_ENTRY_LINKIFY_LIKE_OLD_CPIO:
|
||||
/* This one is trivial. */
|
||||
return;
|
||||
|
@ -245,7 +238,6 @@ archive_entry_linkify(struct archive_entry_linkresolver *res,
|
|||
*e = NULL;
|
||||
}
|
||||
return;
|
||||
#endif
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
@ -259,11 +251,7 @@ find_entry(struct archive_entry_linkresolver *res,
|
|||
struct links_entry *le;
|
||||
int hash, bucket;
|
||||
dev_t dev;
|
||||
#ifndef __minix
|
||||
int64_t ino;
|
||||
#else
|
||||
int32_t ino;
|
||||
#endif
|
||||
|
||||
/* Free a held entry. */
|
||||
if (res->spare != NULL) {
|
||||
|
@ -278,25 +266,15 @@ find_entry(struct archive_entry_linkresolver *res,
|
|||
return (NULL);
|
||||
|
||||
dev = archive_entry_dev(entry);
|
||||
#ifndef __minix
|
||||
ino = archive_entry_ino64(entry);
|
||||
#else
|
||||
ino = archive_entry_ino(entry);
|
||||
#endif
|
||||
hash = (int)(dev ^ ino);
|
||||
|
||||
/* Try to locate this entry in the links cache. */
|
||||
bucket = hash % res->number_buckets;
|
||||
for (le = res->buckets[bucket]; le != NULL; le = le->next) {
|
||||
#ifndef __minix
|
||||
if (le->hash == hash
|
||||
&& dev == archive_entry_dev(le->canonical)
|
||||
&& ino == archive_entry_ino64(le->canonical)) {
|
||||
#else
|
||||
if (le->hash == hash
|
||||
&& dev == archive_entry_dev(le->canonical)
|
||||
&& ino == archive_entry_ino(le->canonical)) {
|
||||
#endif
|
||||
/*
|
||||
* Decrement link count each time and release
|
||||
* the entry if it hits zero. This saves
|
||||
|
@ -322,7 +300,6 @@ find_entry(struct archive_entry_linkresolver *res,
|
|||
return (NULL);
|
||||
}
|
||||
|
||||
|
||||
static struct links_entry *
|
||||
next_entry(struct archive_entry_linkresolver *res)
|
||||
{
|
||||
|
@ -375,11 +352,7 @@ insert_entry(struct archive_entry_linkresolver *res,
|
|||
if (res->number_entries > res->number_buckets * 2)
|
||||
grow_hash(res);
|
||||
|
||||
#ifndef __minix
|
||||
hash = archive_entry_dev(entry) ^ archive_entry_ino64(entry);
|
||||
#else
|
||||
hash = ((int)archive_entry_dev(entry)) ^ ((int)archive_entry_ino(entry));
|
||||
#endif
|
||||
bucket = hash % res->number_buckets;
|
||||
|
||||
/* If we could allocate the entry, record it. */
|
|
@ -110,43 +110,19 @@ struct archive_entry {
|
|||
int stat_valid; /* Set to 0 whenever a field in aest changes. */
|
||||
|
||||
struct aest {
|
||||
#ifndef __minix
|
||||
uint64_t aest_atime;
|
||||
#else
|
||||
time_t aest_atime;
|
||||
#endif
|
||||
int64_t aest_atime;
|
||||
uint32_t aest_atime_nsec;
|
||||
#ifndef __minix
|
||||
int64_t aest_ctime;
|
||||
#else
|
||||
time_t aest_ctime;
|
||||
#endif
|
||||
uint32_t aest_ctime_nsec;
|
||||
#ifndef __minix
|
||||
int64_t aest_mtime;
|
||||
#else
|
||||
time_t aest_mtime;
|
||||
#endif
|
||||
uint32_t aest_mtime_nsec;
|
||||
#ifndef __minix
|
||||
int64_t aest_birthtime;
|
||||
#else
|
||||
time_t aest_birthtime;
|
||||
#endif
|
||||
uint32_t aest_birthtime_nsec;
|
||||
gid_t aest_gid;
|
||||
#ifndef __minix
|
||||
int64_t aest_ino;
|
||||
#else
|
||||
ino_t aest_ino;
|
||||
#endif
|
||||
mode_t aest_mode;
|
||||
uint32_t aest_nlink;
|
||||
#ifndef __minix
|
||||
uint64_t aest_size;
|
||||
#else
|
||||
size_t aest_size;
|
||||
#endif
|
||||
uid_t aest_uid;
|
||||
/*
|
||||
* Because converting between device codes and
|
|
@ -72,12 +72,7 @@ archive_entry_stat(struct archive_entry *entry)
|
|||
st->st_dev = archive_entry_dev(entry);
|
||||
st->st_gid = archive_entry_gid(entry);
|
||||
st->st_uid = archive_entry_uid(entry);
|
||||
#ifndef __minix
|
||||
st->st_ino = archive_entry_ino64(entry);
|
||||
#else
|
||||
st->st_ino = archive_entry_ino(entry);
|
||||
#endif
|
||||
|
||||
st->st_nlink = archive_entry_nlink(entry);
|
||||
st->st_rdev = archive_entry_rdev(entry);
|
||||
st->st_size = archive_entry_size(entry);
|
|
@ -29,6 +29,10 @@
|
|||
#error This header is only to be used internally to libarchive.
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_SYS_TYPES_H
|
||||
#include <sys/types.h>
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Hash function support in various Operating Systems:
|
||||
*
|
||||
|
@ -44,40 +48,68 @@
|
|||
* - MD5 and SHA1 in libmd: without _ after algorithm name
|
||||
* - SHA256: with _ after algorithm name
|
||||
*
|
||||
* Mac OS X (10.4 and later):
|
||||
* - MD5, SHA1 and SHA2 in libSystem: with CC_ prefix and _ after algorithm name
|
||||
*
|
||||
* OpenSSL:
|
||||
* - MD5, SHA1 and SHA2 in libcrypto: with _ after algorithm name
|
||||
*
|
||||
* Windows:
|
||||
* - MD5, SHA1 and SHA2 in archive_windows.c: without algorithm name
|
||||
* and with __la_ prefix.
|
||||
*/
|
||||
#if defined(ARCHIVE_HASH_MD5_WIN) ||\
|
||||
defined(ARCHIVE_HASH_SHA1_WIN) || defined(ARCHIVE_HASH_SHA256_WIN) ||\
|
||||
defined(ARCHIVE_HASH_SHA384_WIN) || defined(ARCHIVE_HASH_SHA512_WIN)
|
||||
#include <wincrypt.h>
|
||||
typedef struct {
|
||||
int valid;
|
||||
HCRYPTPROV cryptProv;
|
||||
HCRYPTHASH hash;
|
||||
} Digest_CTX;
|
||||
extern void __la_hash_Init(Digest_CTX *, ALG_ID);
|
||||
extern void __la_hash_Final(unsigned char *, size_t, Digest_CTX *);
|
||||
extern void __la_hash_Update(Digest_CTX *, const unsigned char *, size_t);
|
||||
#endif
|
||||
|
||||
#if defined(HAVE_MD5_H) && defined(HAVE_MD5INIT)
|
||||
#if defined(ARCHIVE_HASH_MD5_LIBC)
|
||||
# include <md5.h>
|
||||
# define ARCHIVE_HAS_MD5
|
||||
typedef MD5_CTX archive_md5_ctx;
|
||||
# define archive_md5_init(ctx) MD5Init(ctx)
|
||||
# define archive_md5_final(ctx, buf) MD5Final(buf, ctx)
|
||||
# define archive_md5_update(ctx, buf, n) MD5Update(ctx, buf, n)
|
||||
#elif defined(HAVE_OPENSSL_MD5_H)
|
||||
#elif defined(ARCHIVE_HASH_MD5_LIBSYSTEM)
|
||||
# include <CommonCrypto/CommonDigest.h>
|
||||
# define ARCHIVE_HAS_MD5
|
||||
typedef CC_MD5_CTX archive_md5_ctx;
|
||||
# define archive_md5_init(ctx) CC_MD5_Init(ctx)
|
||||
# define archive_md5_final(ctx, buf) CC_MD5_Final(buf, ctx)
|
||||
# define archive_md5_update(ctx, buf, n) CC_MD5_Update(ctx, buf, n)
|
||||
#elif defined(ARCHIVE_HASH_MD5_OPENSSL)
|
||||
# include <openssl/md5.h>
|
||||
# define ARCHIVE_HAS_MD5
|
||||
typedef MD5_CTX archive_md5_ctx;
|
||||
# define archive_md5_init(ctx) MD5_Init(ctx)
|
||||
# define archive_md5_final(ctx, buf) MD5_Final(buf, ctx)
|
||||
# define archive_md5_update(ctx, buf, n) MD5_Update(ctx, buf, n)
|
||||
#elif defined(_WIN32) && !defined(__CYGWIN__) && defined(CALG_MD5)
|
||||
#elif defined(ARCHIVE_HASH_MD5_WIN)
|
||||
# define ARCHIVE_HAS_MD5
|
||||
typedef MD5_CTX archive_md5_ctx;
|
||||
# define archive_md5_init(ctx) MD5_Init(ctx)
|
||||
# define archive_md5_final(ctx, buf) MD5_Final(buf, ctx)
|
||||
# define archive_md5_update(ctx, buf, n) MD5_Update(ctx, buf, n)
|
||||
# define MD5_DIGEST_LENGTH 16
|
||||
typedef Digest_CTX archive_md5_ctx;
|
||||
# define archive_md5_init(ctx) __la_hash_Init(ctx, CALG_MD5)
|
||||
# define archive_md5_final(ctx, buf) __la_hash_Final(buf, MD5_DIGEST_LENGTH, ctx)
|
||||
# define archive_md5_update(ctx, buf, n) __la_hash_Update(ctx, buf, n)
|
||||
#endif
|
||||
|
||||
#if defined(HAVE_RMD160_H) && defined(HAVE_RMD160INIT)
|
||||
#if defined(ARCHIVE_HASH_RMD160_LIBC)
|
||||
# include <rmd160.h>
|
||||
# define ARCHIVE_HAS_RMD160
|
||||
typedef RMD160_CTX archive_rmd160_ctx;
|
||||
# define archive_rmd160_init(ctx) RMD160Init(ctx)
|
||||
# define archive_rmd160_final(ctx, buf) RMD160Final(buf, ctx)
|
||||
# define archive_rmd160_update(ctx, buf, n) RMD160Update(ctx, buf, n)
|
||||
#elif defined(HAVE_OPENSSL_RIPEMD_H)
|
||||
#elif defined(ARCHIVE_HASH_RMD160_OPENSSL)
|
||||
# include <openssl/ripemd.h>
|
||||
# define ARCHIVE_HAS_RMD160
|
||||
typedef RIPEMD160_CTX archive_rmd160_ctx;
|
||||
|
@ -86,111 +118,164 @@ typedef RIPEMD160_CTX archive_rmd160_ctx;
|
|||
# define archive_rmd160_update(ctx, buf, n) RIPEMD160_Update(ctx, buf, n)
|
||||
#endif
|
||||
|
||||
#if defined(HAVE_SHA1_H) && defined(HAVE_SHA1INIT)
|
||||
#if defined(ARCHIVE_HASH_SHA1_LIBC)
|
||||
# include <sha1.h>
|
||||
# define ARCHIVE_HAS_SHA1
|
||||
typedef SHA1_CTX archive_sha1_ctx;
|
||||
# define archive_sha1_init(ctx) SHA1Init(ctx)
|
||||
# define archive_sha1_final(ctx, buf) SHA1Final(buf, ctx)
|
||||
# define archive_sha1_update(ctx, buf, n) SHA1Update(ctx, buf, n)
|
||||
#elif defined(HAVE_OPENSSL_SHA_H)
|
||||
#elif defined(ARCHIVE_HASH_SHA1_LIBSYSTEM)
|
||||
# include <CommonCrypto/CommonDigest.h>
|
||||
# define ARCHIVE_HAS_SHA1
|
||||
typedef CC_SHA1_CTX archive_sha1_ctx;
|
||||
# define archive_sha1_init(ctx) CC_SHA1_Init(ctx)
|
||||
# define archive_sha1_final(ctx, buf) CC_SHA1_Final(buf, ctx)
|
||||
# define archive_sha1_update(ctx, buf, n) CC_SHA1_Update(ctx, buf, n)
|
||||
#elif defined(ARCHIVE_HASH_SHA1_OPENSSL)
|
||||
# include <openssl/sha.h>
|
||||
# define ARCHIVE_HAS_SHA1
|
||||
typedef SHA_CTX archive_sha1_ctx;
|
||||
# define archive_sha1_init(ctx) SHA1_Init(ctx)
|
||||
# define archive_sha1_final(ctx, buf) SHA1_Final(buf, ctx)
|
||||
# define archive_sha1_update(ctx, buf, n) SHA1_Update(ctx, buf, n)
|
||||
#elif defined(_WIN32) && !defined(__CYGWIN__) && defined(CALG_SHA1)
|
||||
#elif defined(ARCHIVE_HASH_SHA1_WIN)
|
||||
# define ARCHIVE_HAS_SHA1
|
||||
typedef SHA1_CTX archive_sha1_ctx;
|
||||
# define archive_sha1_init(ctx) SHA1_Init(ctx)
|
||||
# define archive_sha1_final(ctx, buf) SHA1_Final(buf, ctx)
|
||||
# define archive_sha1_update(ctx, buf, n) SHA1_Update(ctx, buf, n)
|
||||
# define SHA1_DIGEST_LENGTH 20
|
||||
typedef Digest_CTX archive_sha1_ctx;
|
||||
# define archive_sha1_init(ctx) __la_hash_Init(ctx, CALG_SHA1)
|
||||
# define archive_sha1_final(ctx, buf) __la_hash_Final(buf, SHA1_DIGEST_LENGTH, ctx)
|
||||
# define archive_sha1_update(ctx, buf, n) __la_hash_Update(ctx, buf, n)
|
||||
#endif
|
||||
|
||||
#if defined(HAVE_SHA2_H) && defined(HAVE_SHA256_INIT)
|
||||
#if defined(ARCHIVE_HASH_SHA256_LIBC)
|
||||
# include <sha2.h>
|
||||
# define ARCHIVE_HAS_SHA256
|
||||
typedef SHA256_CTX archive_sha256_ctx;
|
||||
# define archive_sha256_init(ctx) SHA256_Init(ctx)
|
||||
# define archive_sha256_final(ctx, buf) SHA256_Final(buf, ctx)
|
||||
# define archive_sha256_update(ctx, buf, n) SHA256_Update(ctx, buf, n)
|
||||
#elif defined(HAVE_SHA2_H) && defined(HAVE_SHA256INIT)
|
||||
#elif defined(ARCHIVE_HASH_SHA256_LIBC2)
|
||||
# include <sha2.h>
|
||||
# define ARCHIVE_HAS_SHA256
|
||||
typedef SHA256_CTX archive_sha256_ctx;
|
||||
# define archive_sha256_init(ctx) SHA256Init(ctx)
|
||||
# define archive_sha256_final(ctx, buf) SHA256Final(buf, ctx)
|
||||
# define archive_sha256_update(ctx, buf, n) SHA256Update(ctx, buf, n)
|
||||
#elif defined(HAVE_OPENSSL_SHA_H) && defined(HAVE_OPENSSL_SHA256_INIT)
|
||||
#elif defined(ARCHIVE_HASH_SHA256_LIBC3)
|
||||
# include <sha2.h>
|
||||
# define ARCHIVE_HAS_SHA256
|
||||
typedef SHA2_CTX archive_sha256_ctx;
|
||||
# define archive_sha256_init(ctx) SHA256Init(ctx)
|
||||
# define archive_sha256_final(ctx, buf) SHA256Final(buf, ctx)
|
||||
# define archive_sha256_update(ctx, buf, n) SHA256Update(ctx, buf, n)
|
||||
#elif defined(ARCHIVE_HASH_SHA256_LIBSYSTEM)
|
||||
# include <CommonCrypto/CommonDigest.h>
|
||||
# define ARCHIVE_HAS_SHA256
|
||||
typedef CC_SHA256_CTX archive_shs256_ctx;
|
||||
# define archive_shs256_init(ctx) CC_SHA256_Init(ctx)
|
||||
# define archive_shs256_final(ctx, buf) CC_SHA256_Final(buf, ctx)
|
||||
# define archive_shs256_update(ctx, buf, n) CC_SHA256_Update(ctx, buf, n)
|
||||
#elif defined(ARCHIVE_HASH_SHA256_OPENSSL)
|
||||
# include <openssl/sha.h>
|
||||
# define ARCHIVE_HAS_SHA256
|
||||
typedef SHA256_CTX archive_sha256_ctx;
|
||||
# define archive_sha256_init(ctx) SHA256_Init(ctx)
|
||||
# define archive_sha256_final(ctx, buf) SHA256_Final(buf, ctx)
|
||||
# define archive_sha256_update(ctx, buf, n) SHA256_Update(ctx, buf, n)
|
||||
#elif defined(_WIN32) && !defined(__CYGWIN__) && defined(CALG_SHA_256)
|
||||
#elif defined(ARCHIVE_HASH_SHA256_WIN)
|
||||
# define ARCHIVE_HAS_SHA256
|
||||
typedef SHA256_CTX archive_sha256_ctx;
|
||||
# define archive_sha256_init(ctx) SHA256_Init(ctx)
|
||||
# define archive_sha256_final(ctx, buf) SHA256_Final(buf, ctx)
|
||||
# define archive_sha256_update(ctx, buf, n) SHA256_Update(ctx, buf, n)
|
||||
# define SHA256_DIGEST_LENGTH 32
|
||||
typedef Digest_CTX archive_sha256_ctx;
|
||||
# define archive_sha256_init(ctx) __la_hash_Init(ctx, CALG_SHA_256)
|
||||
# define archive_sha256_final(ctx, buf) __la_hash_Final(buf, SHA256_DIGEST_LENGTH, ctx)
|
||||
# define archive_sha256_update(ctx, buf, n) __la_hash_Update(ctx, buf, n)
|
||||
#endif
|
||||
|
||||
#if defined(HAVE_SHA2_H) && defined(HAVE_SHA384_INIT)
|
||||
#if defined(ARCHIVE_HASH_SHA384_LIBC)
|
||||
# include <sha2.h>
|
||||
# define ARCHIVE_HAS_SHA384
|
||||
typedef SHA384_CTX archive_sha384_ctx;
|
||||
# define archive_sha384_init(ctx) SHA384_Init(ctx)
|
||||
# define archive_sha384_final(ctx, buf) SHA384_Final(buf, ctx)
|
||||
# define archive_sha384_update(ctx, buf, n) SHA384_Update(ctx, buf, n)
|
||||
#elif defined(HAVE_SHA2_H) && defined(HAVE_SHA384INIT)
|
||||
#elif defined(ARCHIVE_HASH_SHA384_LIBC2)
|
||||
# include <sha2.h>
|
||||
# define ARCHIVE_HAS_SHA384
|
||||
typedef SHA384_CTX archive_sha384_ctx;
|
||||
# define archive_sha384_init(ctx) SHA384Init(ctx)
|
||||
# define archive_sha384_final(ctx, buf) SHA384Final(buf, ctx)
|
||||
# define archive_sha384_update(ctx, buf, n) SHA384Update(ctx, buf, n)
|
||||
#elif defined(HAVE_OPENSSL_SHA_H) && defined(HAVE_OPENSSL_SHA384_INIT)
|
||||
#elif defined(ARCHIVE_HASH_SHA384_LIBC3)
|
||||
# include <sha2.h>
|
||||
# define ARCHIVE_HAS_SHA384
|
||||
typedef SHA2_CTX archive_sha384_ctx;
|
||||
# define archive_sha384_init(ctx) SHA384Init(ctx)
|
||||
# define archive_sha384_final(ctx, buf) SHA384Final(buf, ctx)
|
||||
# define archive_sha384_update(ctx, buf, n) SHA384Update(ctx, buf, n)
|
||||
#elif defined(ARCHIVE_HASH_SHA384_LIBSYSTEM)
|
||||
# include <CommonCrypto/CommonDigest.h>
|
||||
# define ARCHIVE_HAS_SHA384
|
||||
typedef CC_SHA512_CTX archive_shs384_ctx;
|
||||
# define archive_shs384_init(ctx) CC_SHA384_Init(ctx)
|
||||
# define archive_shs384_final(ctx, buf) CC_SHA384_Final(buf, ctx)
|
||||
# define archive_shs384_update(ctx, buf, n) CC_SHA384_Update(ctx, buf, n)
|
||||
#elif defined(ARCHIVE_HASH_SHA384_OPENSSL)
|
||||
# include <openssl/sha.h>
|
||||
# define ARCHIVE_HAS_SHA384
|
||||
typedef SHA512_CTX archive_sha384_ctx;
|
||||
# define archive_sha384_init(ctx) SHA384_Init(ctx)
|
||||
# define archive_sha384_final(ctx, buf) SHA384_Final(buf, ctx)
|
||||
# define archive_sha384_update(ctx, buf, n) SHA384_Update(ctx, buf, n)
|
||||
#elif defined(_WIN32) && !defined(__CYGWIN__) && defined(CALG_SHA_384)
|
||||
#elif defined(ARCHIVE_HASH_SHA384_WIN)
|
||||
# define ARCHIVE_HAS_SHA384
|
||||
typedef SHA512_CTX archive_sha384_ctx;
|
||||
# define archive_sha384_init(ctx) SHA384_Init(ctx)
|
||||
# define archive_sha384_final(ctx, buf) SHA384_Final(buf, ctx)
|
||||
# define archive_sha384_update(ctx, buf, n) SHA384_Update(ctx, buf, n)
|
||||
# define SHA384_DIGEST_LENGTH 48
|
||||
typedef Digest_CTX archive_sha384_ctx;
|
||||
# define archive_sha384_init(ctx) __la_hash_Init(ctx, CALG_SHA_384)
|
||||
# define archive_sha384_final(ctx, buf) __la_hash_Final(buf, SHA384_DIGEST_LENGTH, ctx)
|
||||
# define archive_sha384_update(ctx, buf, n) __la_hash_Update(ctx, buf, n)
|
||||
#endif
|
||||
|
||||
#if defined(HAVE_SHA2_H) && defined(HAVE_SHA512_INIT)
|
||||
#if defined(ARCHIVE_HASH_SHA512_LIBC)
|
||||
# include <sha2.h>
|
||||
# define ARCHIVE_HAS_SHA512
|
||||
typedef SHA512_CTX archive_sha512_ctx;
|
||||
# define archive_sha512_init(ctx) SHA512_Init(ctx)
|
||||
# define archive_sha512_final(ctx, buf) SHA512_Final(buf, ctx)
|
||||
# define archive_sha512_update(ctx, buf, n) SHA512_Update(ctx, buf, n)
|
||||
#elif defined(HAVE_SHA2_H) && defined(HAVE_SHA512INIT)
|
||||
#elif defined(ARCHIVE_HASH_SHA512_LIBC2)
|
||||
# include <sha2.h>
|
||||
# define ARCHIVE_HAS_SHA512
|
||||
typedef SHA512_CTX archive_sha512_ctx;
|
||||
# define archive_sha512_init(ctx) SHA512Init(ctx)
|
||||
# define archive_sha512_final(ctx, buf) SHA512Final(buf, ctx)
|
||||
# define archive_sha512_update(ctx, buf, n) SHA512Update(ctx, buf, n)
|
||||
#elif defined(HAVE_OPENSSL_SHA_H) && defined(HAVE_OPENSSL_SHA512_INIT)
|
||||
#elif defined(ARCHIVE_HASH_SHA512_LIBC3)
|
||||
# include <sha2.h>
|
||||
# define ARCHIVE_HAS_SHA512
|
||||
typedef SHA2_CTX archive_sha512_ctx;
|
||||
# define archive_sha512_init(ctx) SHA512Init(ctx)
|
||||
# define archive_sha512_final(ctx, buf) SHA512Final(buf, ctx)
|
||||
# define archive_sha512_update(ctx, buf, n) SHA512Update(ctx, buf, n)
|
||||
#elif defined(ARCHIVE_HASH_SHA512_LIBSYSTEM)
|
||||
# include <CommonCrypto/CommonDigest.h>
|
||||
# define ARCHIVE_HAS_SHA512
|
||||
typedef CC_SHA512_CTX archive_shs512_ctx;
|
||||
# define archive_shs512_init(ctx) CC_SHA512_Init(ctx)
|
||||
# define archive_shs512_final(ctx, buf) CC_SHA512_Final(buf, ctx)
|
||||
# define archive_shs512_update(ctx, buf, n) CC_SHA512_Update(ctx, buf, n)
|
||||
#elif defined(ARCHIVE_HASH_SHA512_OPENSSL)
|
||||
# include <openssl/sha.h>
|
||||
# define ARCHIVE_HAS_SHA512
|
||||
typedef SHA512_CTX archive_sha512_ctx;
|
||||
# define archive_sha512_init(ctx) SHA512_Init(ctx)
|
||||
# define archive_sha512_final(ctx, buf) SHA512_Final(buf, ctx)
|
||||
# define archive_sha512_update(ctx, buf, n) SHA512_Update(ctx, buf, n)
|
||||
#elif defined(_WIN32) && !defined(__CYGWIN__) && defined(CALG_SHA_512)
|
||||
#elif defined(ARCHIVE_HASH_SHA512_WIN)
|
||||
# define ARCHIVE_HAS_SHA512
|
||||
typedef SHA512_CTX archive_sha512_ctx;
|
||||
# define archive_sha512_init(ctx) SHA512_Init(ctx)
|
||||
# define archive_sha512_final(ctx, buf) SHA512_Final(buf, ctx)
|
||||
# define archive_sha512_update(ctx, buf, n) SHA512_Update(ctx, buf, n)
|
||||
# define SHA512_DIGEST_LENGTH 64
|
||||
typedef Digest_CTX archive_sha512_ctx;
|
||||
# define archive_sha512_init(ctx) __la_hash_Init(ctx, CALG_SHA_512)
|
||||
# define archive_sha512_final(ctx, buf) __la_hash_Final(buf, SHA512_DIGEST_LENGTH, ctx)
|
||||
# define archive_sha512_update(ctx, buf, n) __la_hash_Update(ctx, buf, n)
|
||||
#endif
|
|
@ -105,7 +105,6 @@
|
|||
#endif
|
||||
|
||||
/* Some platforms lack the standard *_MAX definitions. */
|
||||
#ifndef __minix
|
||||
#if !HAVE_DECL_SIZE_MAX
|
||||
#define SIZE_MAX (~(size_t)0)
|
||||
#endif
|
||||
|
@ -124,7 +123,6 @@
|
|||
#if !HAVE_DECL_INT64_MIN
|
||||
#define INT64_MIN ((int64_t)(~INT64_MAX))
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/*
|
||||
* If this platform has <sys/acl.h>, acl_create(), acl_init(),
|
|
@ -90,19 +90,13 @@ struct archive {
|
|||
int compression_code; /* Currently active compression. */
|
||||
const char *compression_name;
|
||||
|
||||
#ifndef __minix
|
||||
/* Position in UNCOMPRESSED data stream. */
|
||||
int64_t file_position;
|
||||
/* Position in COMPRESSED data stream. */
|
||||
int64_t raw_position;
|
||||
#else
|
||||
/* Position in UNCOMPRESSED data stream. */
|
||||
off_t file_position;
|
||||
/* Position in COMPRESSED data stream. */
|
||||
off_t raw_position;
|
||||
#endif
|
||||
int file_count;
|
||||
/* Number of file entries processed. */
|
||||
int file_count;
|
||||
|
||||
int archive_error_number;
|
||||
const char *error;
|
||||
struct archive_string error_string;
|
|
@ -211,14 +211,12 @@ order they would be used:
|
|||
Allocates and initializes a
|
||||
.Tn struct archive
|
||||
object suitable for reading from an archive.
|
||||
.It Xo
|
||||
.Fn archive_read_support_compression_bzip2 ,
|
||||
.Fn archive_read_support_compression_compress ,
|
||||
.Fn archive_read_support_compression_gzip ,
|
||||
.Fn archive_read_support_compression_lzma ,
|
||||
.Fn archive_read_support_compression_none ,
|
||||
.Fn archive_read_support_compression_xz
|
||||
.Xc
|
||||
.It Fn archive_read_support_compression_bzip2 , \
|
||||
Fn archive_read_support_compression_compress , \
|
||||
Fn archive_read_support_compression_gzip , \
|
||||
Fn archive_read_support_compression_lzma , \
|
||||
Fn archive_read_support_compression_none , \
|
||||
Fn archive_read_support_compression_xz
|
||||
Enables auto-detection code and decompression support for the
|
||||
specified compression.
|
||||
Returns
|
||||
|
@ -242,16 +240,14 @@ decompression option.
|
|||
This feeds data through the specified external program
|
||||
but only if the initial bytes of the data match the specified
|
||||
signature value.
|
||||
.It Xo
|
||||
.Fn archive_read_support_format_all ,
|
||||
.Fn archive_read_support_format_ar ,
|
||||
.Fn archive_read_support_format_cpio ,
|
||||
.Fn archive_read_support_format_empty ,
|
||||
.Fn archive_read_support_format_iso9660 ,
|
||||
.Fn archive_read_support_format_mtree ,
|
||||
.Fn archive_read_support_format_tar ,
|
||||
.Fn archive_read_support_format_zip
|
||||
.Xc
|
||||
.It Fn archive_read_support_format_all , \
|
||||
Fn archive_read_support_format_ar , \
|
||||
Fn archive_read_support_format_cpio , \
|
||||
Fn archive_read_support_format_empty , \
|
||||
Fn archive_read_support_format_iso9660 , \
|
||||
Fn archive_read_support_format_mtree , \
|
||||
Fn archive_read_support_format_tar , \
|
||||
Fn archive_read_support_format_zip
|
||||
Enables support---including auto-detection code---for the
|
||||
specified archive format.
|
||||
For example,
|
||||
|
@ -273,11 +269,9 @@ all other entry fields are unset.
|
|||
This is not enabled by
|
||||
.Fn archive_read_support_format_all
|
||||
in order to avoid erroneous handling of damaged archives.
|
||||
.It Xo
|
||||
.Fn archive_read_set_filter_options ,
|
||||
.Fn archive_read_set_format_options ,
|
||||
.Fn archive_read_set_options
|
||||
.Xc
|
||||
.It Fn archive_read_set_filter_options , \
|
||||
Fn archive_read_set_format_options , \
|
||||
Fn archive_read_set_options
|
||||
Specifies options that will be passed to currently-registered
|
||||
filters (including decompression filters) and/or format readers.
|
||||
The argument is a comma-separated list of individual options.
|
||||
|
@ -597,7 +591,7 @@ list_archive(const char *name)
|
|||
archive_read_support_format_all(a);
|
||||
archive_read_open(a, mydata, myopen, myread, myclose);
|
||||
while (archive_read_next_header(a, &entry) == ARCHIVE_OK) {
|
||||
printf("%s\\n",archive_entry_pathname(entry));
|
||||
printf("%s\en",archive_entry_pathname(entry));
|
||||
archive_read_data_skip(a);
|
||||
}
|
||||
archive_read_finish(a);
|
|
@ -249,7 +249,6 @@ client_read_proxy(struct archive_read_filter *self, const void **buff)
|
|||
return (r);
|
||||
}
|
||||
|
||||
#ifndef __minix
|
||||
static int64_t
|
||||
client_skip_proxy(struct archive_read_filter *self, int64_t request)
|
||||
{
|
||||
|
@ -274,32 +273,6 @@ client_skip_proxy(struct archive_read_filter *self, int64_t request)
|
|||
total += get;
|
||||
}
|
||||
}
|
||||
#else
|
||||
static ssize_t
|
||||
client_skip_proxy(struct archive_read_filter *self, ssize_t request)
|
||||
{
|
||||
size_t ask, get, total;
|
||||
/* Limit our maximum seek request to 1GB on platforms
|
||||
* with 32-bit off_t (such as Windows). */
|
||||
size_t skip_limit = ((size_t)1) << (sizeof(off_t) * 8 - 2);
|
||||
|
||||
if (self->archive->client.skipper == NULL)
|
||||
return (0);
|
||||
total = 0;
|
||||
for (;;) {
|
||||
ask = request;
|
||||
if (ask > skip_limit)
|
||||
ask = skip_limit;
|
||||
get = (self->archive->client.skipper)(&self->archive->archive,
|
||||
self->data, ask);
|
||||
if (get == 0)
|
||||
return (total);
|
||||
request -= get;
|
||||
self->archive->archive.raw_position += get;
|
||||
total += get;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
static int
|
||||
client_close_proxy(struct archive_read_filter *self)
|
||||
|
@ -574,7 +547,6 @@ choose_format(struct archive_read *a)
|
|||
* Return the file offset (within the uncompressed data stream) where
|
||||
* the last header started.
|
||||
*/
|
||||
#ifndef __minix
|
||||
int64_t
|
||||
archive_read_header_position(struct archive *_a)
|
||||
{
|
||||
|
@ -583,16 +555,6 @@ archive_read_header_position(struct archive *_a)
|
|||
ARCHIVE_STATE_ANY, "archive_read_header_position");
|
||||
return (a->header_position);
|
||||
}
|
||||
#else
|
||||
off_t
|
||||
archive_read_header_position(struct archive *_a)
|
||||
{
|
||||
struct archive_read *a = (struct archive_read *)_a;
|
||||
__archive_check_magic(_a, ARCHIVE_READ_MAGIC,
|
||||
ARCHIVE_STATE_ANY, "archive_read_header_position");
|
||||
return (a->header_position);
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Read data from an archive entry, using a read(2)-style interface.
|
||||
|
@ -1194,7 +1156,6 @@ __archive_read_filter_consume(struct archive_read_filter * filter,
|
|||
* isn't feasible, this at least pushes the read-and-discard loop
|
||||
* down closer to the data source.
|
||||
*/
|
||||
#ifndef __minix
|
||||
int64_t
|
||||
__archive_read_skip(struct archive_read *a, int64_t request)
|
||||
{
|
||||
|
@ -1210,25 +1171,7 @@ __archive_read_skip(struct archive_read *a, int64_t request)
|
|||
(intmax_t)request, (intmax_t)skipped);
|
||||
return (ARCHIVE_FATAL);
|
||||
}
|
||||
#else
|
||||
ssize_t
|
||||
__archive_read_skip(struct archive_read *a, ssize_t request)
|
||||
{
|
||||
ssize_t skipped = __archive_read_skip_lenient(a, request);
|
||||
if (skipped == request)
|
||||
return (skipped);
|
||||
/* We hit EOF before we satisfied the skip request. */
|
||||
if (skipped < 0) /* Map error code to 0 for error message below. */
|
||||
skipped = 0;
|
||||
archive_set_error(&a->archive,
|
||||
ARCHIVE_ERRNO_MISC,
|
||||
"Truncated input file (needed %jd bytes, only %jd available)",
|
||||
(intmax_t)request, (intmax_t)skipped);
|
||||
return (ARCHIVE_FATAL);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef __minix
|
||||
int64_t
|
||||
__archive_read_skip_lenient(struct archive_read *a, int64_t request)
|
||||
{
|
||||
|
@ -1237,18 +1180,7 @@ __archive_read_skip_lenient(struct archive_read *a, int64_t request)
|
|||
a->archive.file_position += skipped;
|
||||
return (skipped);
|
||||
}
|
||||
#else
|
||||
ssize_t
|
||||
__archive_read_skip_lenient(struct archive_read *a, ssize_t request)
|
||||
{
|
||||
size_t skipped = __archive_read_filter_skip(a->filter, request);
|
||||
if (skipped > 0)
|
||||
a->archive.file_position += skipped;
|
||||
return (skipped);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef __minix
|
||||
int64_t
|
||||
__archive_read_filter_skip(struct archive_read_filter *filter, int64_t request)
|
||||
{
|
||||
|
@ -1315,71 +1247,3 @@ __archive_read_filter_skip(struct archive_read_filter *filter, int64_t request)
|
|||
}
|
||||
return (total_bytes_skipped);
|
||||
}
|
||||
#else
|
||||
ssize_t
|
||||
__archive_read_filter_skip(struct archive_read_filter *filter, ssize_t request)
|
||||
{
|
||||
ssize_t bytes_skipped, total_bytes_skipped = 0;
|
||||
size_t min;
|
||||
|
||||
if (filter->fatal)
|
||||
return (-1);
|
||||
/*
|
||||
* If there is data in the buffers already, use that first.
|
||||
*/
|
||||
if (filter->avail > 0) {
|
||||
min = minimum(request, (off_t)filter->avail);
|
||||
bytes_skipped = __archive_read_filter_consume(filter, min);
|
||||
request -= bytes_skipped;
|
||||
total_bytes_skipped += bytes_skipped;
|
||||
}
|
||||
if (filter->client_avail > 0) {
|
||||
min = minimum(request, (off_t)filter->client_avail);
|
||||
bytes_skipped = __archive_read_filter_consume(filter, min);
|
||||
request -= bytes_skipped;
|
||||
total_bytes_skipped += bytes_skipped;
|
||||
}
|
||||
if (request == 0)
|
||||
return (total_bytes_skipped);
|
||||
/*
|
||||
* If a client_skipper was provided, try that first.
|
||||
*/
|
||||
#if ARCHIVE_API_VERSION < 2
|
||||
if ((filter->skip != NULL) && (request < SSIZE_MAX)) {
|
||||
#else
|
||||
if (filter->skip != NULL) {
|
||||
#endif
|
||||
bytes_skipped = (filter->skip)(filter, request);
|
||||
if (bytes_skipped < 0) { /* error */
|
||||
filter->client_total = filter->client_avail = 0;
|
||||
filter->client_next = filter->client_buff = NULL;
|
||||
filter->fatal = 1;
|
||||
return (bytes_skipped);
|
||||
}
|
||||
total_bytes_skipped += bytes_skipped;
|
||||
request -= bytes_skipped;
|
||||
filter->client_next = filter->client_buff;
|
||||
filter->client_avail = filter->client_total = 0;
|
||||
}
|
||||
/*
|
||||
* Note that client_skipper will usually not satisfy the
|
||||
* full request (due to low-level blocking concerns),
|
||||
* so even if client_skipper is provided, we may still
|
||||
* have to use ordinary reads to finish out the request.
|
||||
*/
|
||||
while (request > 0) {
|
||||
ssize_t bytes_read;
|
||||
(void)__archive_read_filter_ahead(filter, 1, &bytes_read);
|
||||
if (bytes_read < 0)
|
||||
return (bytes_read);
|
||||
if (bytes_read == 0) {
|
||||
return (total_bytes_skipped);
|
||||
}
|
||||
min = (size_t)(minimum(bytes_read, request));
|
||||
bytes_read = __archive_read_filter_consume(filter, min);
|
||||
total_bytes_skipped += bytes_read;
|
||||
request -= bytes_read;
|
||||
}
|
||||
return (total_bytes_skipped);
|
||||
}
|
||||
#endif
|
|
@ -93,11 +93,9 @@ objects.
|
|||
Allocates and initializes a
|
||||
.Tn struct archive
|
||||
object suitable for reading object information from disk.
|
||||
.It Xo
|
||||
.Fn archive_read_disk_set_symlink_logical ,
|
||||
.Fn archive_read_disk_set_symlink_physical ,
|
||||
.Fn archive_read_disk_set_symlink_hybrid
|
||||
.Xc
|
||||
.It Fn archive_read_disk_set_symlink_logical , \
|
||||
Fn archive_read_disk_set_symlink_physical , \
|
||||
Fn archive_read_disk_set_symlink_hybrid
|
||||
This sets the mode used for handling symbolic links.
|
||||
The
|
||||
.Dq logical
|
||||
|
@ -110,16 +108,12 @@ The
|
|||
mode currently behaves identically to the
|
||||
.Dq logical
|
||||
mode.
|
||||
.It Xo
|
||||
.Fn archive_read_disk_gname ,
|
||||
.Fn archive_read_disk_uname
|
||||
.Xc
|
||||
.It Fn archive_read_disk_gname , \
|
||||
Fn archive_read_disk_uname
|
||||
Returns a user or group name given a gid or uid value.
|
||||
By default, these always return a NULL string.
|
||||
.It Xo
|
||||
.Fn archive_read_disk_set_gname_lookup ,
|
||||
.Fn archive_read_disk_set_uname_lookup
|
||||
.Xc
|
||||
.It Fn archive_read_disk_set_gname_lookup , \
|
||||
Fn archive_read_disk_set_uname_lookup
|
||||
These allow you to override the functions used for
|
||||
user and group name lookups.
|
||||
You may also provide a
|
|
@ -425,7 +425,8 @@ setup_xattrs(struct archive_read_disk *a,
|
|||
return (ARCHIVE_OK);
|
||||
}
|
||||
|
||||
#elif HAVE_EXTATTR_GET_FILE && HAVE_EXTATTR_LIST_FILE
|
||||
#elif HAVE_EXTATTR_GET_FILE && HAVE_EXTATTR_LIST_FILE && \
|
||||
HAVE_DECL_EXTATTR_NAMESPACE_USER
|
||||
|
||||
/*
|
||||
* FreeBSD extattr interface.
|
|
@ -54,7 +54,7 @@ struct archive_read_disk {
|
|||
const char * (*lookup_gname)(void *private, gid_t gid);
|
||||
void (*cleanup_gname)(void *private);
|
||||
void *lookup_gname_data;
|
||||
const char * (*lookup_uname)(void *private, uid_t gid);
|
||||
const char * (*lookup_uname)(void *private, gid_t gid);
|
||||
void (*cleanup_uname)(void *private);
|
||||
void *lookup_uname_data;
|
||||
};
|
|
@ -182,6 +182,7 @@ lookup_uname(void *data, uid_t uid)
|
|||
&lookup_uname_helper, (id_t)uid));
|
||||
}
|
||||
|
||||
#if HAVE_GETPWUID_R
|
||||
static const char *
|
||||
lookup_uname_helper(struct name_cache *cache, id_t id)
|
||||
{
|
||||
|
@ -196,13 +197,8 @@ lookup_uname_helper(struct name_cache *cache, id_t id)
|
|||
return (NULL);
|
||||
for (;;) {
|
||||
result = &pwent; /* Old getpwuid_r ignores last arg. */
|
||||
#if defined(HAVE_GETPWUID_R)
|
||||
r = getpwuid_r((uid_t)id, &pwent,
|
||||
cache->buff, cache->buff_size, &result);
|
||||
#else
|
||||
result = getpwuid((uid_t)id);
|
||||
r = errno;
|
||||
#endif
|
||||
if (r == 0)
|
||||
break;
|
||||
if (r != ERANGE)
|
||||
|
@ -227,6 +223,20 @@ lookup_uname_helper(struct name_cache *cache, id_t id)
|
|||
|
||||
return strdup(result->pw_name);
|
||||
}
|
||||
#else
|
||||
static const char *
|
||||
lookup_uname_helper(struct name_cache *cache, id_t id)
|
||||
{
|
||||
struct passwd *result;
|
||||
|
||||
result = getpwuid((uid_t)id);
|
||||
|
||||
if (result == NULL)
|
||||
return (NULL);
|
||||
|
||||
return strdup(result->pw_name);
|
||||
}
|
||||
#endif
|
||||
|
||||
static const char *
|
||||
lookup_gname(void *data, gid_t gid)
|
||||
|
@ -236,6 +246,7 @@ lookup_gname(void *data, gid_t gid)
|
|||
&lookup_gname_helper, (id_t)gid));
|
||||
}
|
||||
|
||||
#if HAVE_GETGRGID_R
|
||||
static const char *
|
||||
lookup_gname_helper(struct name_cache *cache, id_t id)
|
||||
{
|
||||
|
@ -250,13 +261,8 @@ lookup_gname_helper(struct name_cache *cache, id_t id)
|
|||
return (NULL);
|
||||
for (;;) {
|
||||
result = &grent; /* Old getgrgid_r ignores last arg. */
|
||||
#if defined(HAVE_GETGRGID_R)
|
||||
r = getgrgid_r((gid_t)id, &grent,
|
||||
cache->buff, cache->buff_size, &result);
|
||||
#else
|
||||
result = getgrgid((gid_t)id);
|
||||
r = errno;
|
||||
#endif
|
||||
if (r == 0)
|
||||
break;
|
||||
if (r != ERANGE)
|
||||
|
@ -279,4 +285,19 @@ lookup_gname_helper(struct name_cache *cache, id_t id)
|
|||
|
||||
return strdup(result->gr_name);
|
||||
}
|
||||
#else
|
||||
static const char *
|
||||
lookup_gname_helper(struct name_cache *cache, id_t id)
|
||||
{
|
||||
struct group *result;
|
||||
|
||||
result = getgrgid((gid_t)id);
|
||||
|
||||
if (result == NULL)
|
||||
return (NULL);
|
||||
|
||||
return strdup(result->gr_name);
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* ! (_WIN32 && !__CYGWIN__) */
|
|
@ -116,12 +116,16 @@ file_read(struct archive *a, void *client_data, const void **buff)
|
|||
ssize_t bytes_read;
|
||||
|
||||
*buff = mine->buffer;
|
||||
for (;;) {
|
||||
bytes_read = read(mine->fd, mine->buffer, mine->block_size);
|
||||
if (bytes_read < 0) {
|
||||
if (errno == EINTR)
|
||||
continue;
|
||||
archive_set_error(a, errno, "Error reading fd %d", mine->fd);
|
||||
}
|
||||
return (bytes_read);
|
||||
}
|
||||
}
|
||||
|
||||
#if ARCHIVE_API_VERSION < 2
|
||||
static ssize_t
|
|
@ -160,9 +160,12 @@ file_read(struct archive *a, void *client_data, const void **buff)
|
|||
ssize_t bytes_read;
|
||||
|
||||
*buff = mine->buffer;
|
||||
for (;;) {
|
||||
bytes_read = read(mine->fd, mine->buffer, mine->block_size);
|
||||
if (bytes_read < 0) {
|
||||
if (mine->filename[0] == '\0')
|
||||
if (errno == EINTR)
|
||||
continue;
|
||||
else if (mine->filename[0] == '\0')
|
||||
archive_set_error(a, errno, "Error reading stdin");
|
||||
else
|
||||
archive_set_error(a, errno, "Error reading '%s'",
|
||||
|
@ -170,6 +173,7 @@ file_read(struct archive *a, void *client_data, const void **buff)
|
|||
}
|
||||
return (bytes_read);
|
||||
}
|
||||
}
|
||||
|
||||
#if ARCHIVE_API_VERSION < 2
|
||||
static ssize_t
|
|
@ -79,11 +79,7 @@ struct archive_read_filter {
|
|||
/* Return next block. */
|
||||
ssize_t (*read)(struct archive_read_filter *, const void **);
|
||||
/* Skip forward this many bytes. */
|
||||
#ifndef __minix
|
||||
int64_t (*skip)(struct archive_read_filter *self, int64_t request);
|
||||
#else
|
||||
ssize_t (*skip)(struct archive_read_filter *self, ssize_t request);
|
||||
#endif
|
||||
/* Close (just this filter) and free(self). */
|
||||
int (*close)(struct archive_read_filter *self);
|
||||
/* My private data. */
|
||||
|
@ -101,11 +97,7 @@ struct archive_read_filter {
|
|||
size_t client_total;
|
||||
const char *client_next;
|
||||
size_t client_avail;
|
||||
#ifndef __minix
|
||||
int64_t position;
|
||||
#else
|
||||
off_t position;
|
||||
#endif
|
||||
char end_of_file;
|
||||
char fatal;
|
||||
};
|
||||
|
@ -200,14 +192,8 @@ const void *__archive_read_filter_ahead(struct archive_read_filter *,
|
|||
size_t, ssize_t *);
|
||||
ssize_t __archive_read_consume(struct archive_read *, size_t);
|
||||
ssize_t __archive_read_filter_consume(struct archive_read_filter *, size_t);
|
||||
#ifndef __minix
|
||||
int64_t __archive_read_skip(struct archive_read *, int64_t);
|
||||
int64_t __archive_read_skip_lenient(struct archive_read *, int64_t);
|
||||
int64_t __archive_read_filter_skip(struct archive_read_filter *, int64_t);
|
||||
#else
|
||||
ssize_t __archive_read_skip(struct archive_read *, ssize_t);
|
||||
ssize_t __archive_read_skip_lenient(struct archive_read *, ssize_t);
|
||||
ssize_t __archive_read_filter_skip(struct archive_read_filter *, ssize_t);
|
||||
#endif /* __minix */
|
||||
int __archive_read_program(struct archive_read_filter *, const char *);
|
||||
#endif
|
|
@ -47,9 +47,8 @@ archive_read_support_compression_all(struct archive *a)
|
|||
/* The decode code doesn't use an outside library. */
|
||||
archive_read_support_compression_uu(a);
|
||||
/* The decode code doesn't use an outside library. */
|
||||
#ifndef __minix
|
||||
archive_read_support_compression_rpm(a);
|
||||
#endif
|
||||
|
||||
/* Note: We always return ARCHIVE_OK here, even if some of the
|
||||
* above return ARCHIVE_WARN. The intent here is to enable
|
||||
* "as much as possible." Clients who need specific
|
|
@ -48,7 +48,7 @@ __FBSDID("$FreeBSD: head/lib/libarchive/archive_read_support_compression_bzip2.c
|
|||
#include "archive_private.h"
|
||||
#include "archive_read_private.h"
|
||||
|
||||
#if HAVE_BZLIB_H
|
||||
#if defined(HAVE_BZLIB_H) && defined(BZ_CONFIG_ERROR)
|
||||
struct private_data {
|
||||
bz_stream stream;
|
||||
char *out_block;
|
||||
|
@ -86,7 +86,7 @@ archive_read_support_compression_bzip2(struct archive *_a)
|
|||
reader->init = bzip2_reader_init;
|
||||
reader->options = NULL;
|
||||
reader->free = bzip2_reader_free;
|
||||
#if HAVE_BZLIB_H
|
||||
#if defined(HAVE_BZLIB_H) && defined(BZ_CONFIG_ERROR)
|
||||
return (ARCHIVE_OK);
|
||||
#else
|
||||
archive_set_error(_a, ARCHIVE_ERRNO_MISC,
|
||||
|
@ -146,7 +146,7 @@ bzip2_reader_bid(struct archive_read_filter_bidder *self, struct archive_read_fi
|
|||
return (bits_checked);
|
||||
}
|
||||
|
||||
#ifndef HAVE_BZLIB_H
|
||||
#if !defined(HAVE_BZLIB_H) || !defined(BZ_CONFIG_ERROR)
|
||||
|
||||
/*
|
||||
* If we don't have the library on this system, we can't actually do the
|
||||
|
@ -350,4 +350,4 @@ bzip2_filter_close(struct archive_read_filter *self)
|
|||
return (ret);
|
||||
}
|
||||
|
||||
#endif /* HAVE_BZLIB_H */
|
||||
#endif /* HAVE_BZLIB_H && BZ_CONFIG_ERROR */
|
|
@ -54,11 +54,7 @@ struct private_data {
|
|||
char in_stream;
|
||||
unsigned char *out_block;
|
||||
size_t out_block_size;
|
||||
#ifndef __minix
|
||||
int64_t total_out;
|
||||
#else
|
||||
int32_t total_out;
|
||||
#endif
|
||||
unsigned long crc;
|
||||
char eof; /* True = found end of compressed data. */
|
||||
};
|
287
external/bsd/libarchive/dist/libarchive/archive_read_support_compression_rpm.c
vendored
Normal file
287
external/bsd/libarchive/dist/libarchive/archive_read_support_compression_rpm.c
vendored
Normal file
|
@ -0,0 +1,287 @@
|
|||
/*-
|
||||
* Copyright (c) 2009 Michihiro NAKAJIMA
|
||||
* 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(S) ``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(S) 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.
|
||||
*/
|
||||
|
||||
#include "archive_platform.h"
|
||||
|
||||
#ifdef HAVE_ERRNO_H
|
||||
#include <errno.h>
|
||||
#endif
|
||||
#ifdef HAVE_STDLIB_H
|
||||
#include <stdlib.h>
|
||||
#endif
|
||||
|
||||
#include "archive.h"
|
||||
#include "archive_endian.h"
|
||||
#include "archive_private.h"
|
||||
#include "archive_read_private.h"
|
||||
|
||||
struct rpm {
|
||||
int64_t total_in;
|
||||
size_t hpos;
|
||||
size_t hlen;
|
||||
unsigned char header[16];
|
||||
enum {
|
||||
ST_LEAD, /* Skipping 'Lead' section. */
|
||||
ST_HEADER, /* Reading 'Header' section;
|
||||
* first 16 bytes. */
|
||||
ST_HEADER_DATA, /* Skipping 'Header' section. */
|
||||
ST_PADDING, /* Skipping padding data after the
|
||||
* 'Header' section. */
|
||||
ST_ARCHIVE /* Reading 'Archive' section. */
|
||||
} state;
|
||||
int first_header;
|
||||
};
|
||||
#define RPM_LEAD_SIZE 96 /* Size of 'Lead' section. */
|
||||
|
||||
static int rpm_bidder_bid(struct archive_read_filter_bidder *,
|
||||
struct archive_read_filter *);
|
||||
static int rpm_bidder_init(struct archive_read_filter *);
|
||||
|
||||
static ssize_t rpm_filter_read(struct archive_read_filter *,
|
||||
const void **);
|
||||
static int rpm_filter_close(struct archive_read_filter *);
|
||||
|
||||
int
|
||||
archive_read_support_compression_rpm(struct archive *_a)
|
||||
{
|
||||
struct archive_read *a = (struct archive_read *)_a;
|
||||
struct archive_read_filter_bidder *bidder;
|
||||
|
||||
bidder = __archive_read_get_bidder(a);
|
||||
archive_clear_error(_a);
|
||||
if (bidder == NULL)
|
||||
return (ARCHIVE_FATAL);
|
||||
|
||||
bidder->data = NULL;
|
||||
bidder->bid = rpm_bidder_bid;
|
||||
bidder->init = rpm_bidder_init;
|
||||
bidder->options = NULL;
|
||||
bidder->free = NULL;
|
||||
return (ARCHIVE_OK);
|
||||
}
|
||||
|
||||
static int
|
||||
rpm_bidder_bid(struct archive_read_filter_bidder *self,
|
||||
struct archive_read_filter *filter)
|
||||
{
|
||||
const unsigned char *b;
|
||||
ssize_t avail;
|
||||
int bits_checked;
|
||||
|
||||
(void)self; /* UNUSED */
|
||||
|
||||
b = __archive_read_filter_ahead(filter, 8, &avail);
|
||||
if (b == NULL)
|
||||
return (0);
|
||||
|
||||
bits_checked = 0;
|
||||
/*
|
||||
* Verify Header Magic Bytes : 0xed 0xab 0xee 0xdb
|
||||
*/
|
||||
if (b[0] != 0xed)
|
||||
return (0);
|
||||
bits_checked += 8;
|
||||
if (b[1] != 0xab)
|
||||
return (0);
|
||||
bits_checked += 8;
|
||||
if (b[2] != 0xee)
|
||||
return (0);
|
||||
bits_checked += 8;
|
||||
if (b[3] != 0xdb)
|
||||
return (0);
|
||||
bits_checked += 8;
|
||||
/*
|
||||
* Check major version.
|
||||
*/
|
||||
if (b[4] != 3 && b[4] != 4)
|
||||
return (0);
|
||||
bits_checked += 8;
|
||||
/*
|
||||
* Check package type; binary or source.
|
||||
*/
|
||||
if (b[6] != 0)
|
||||
return (0);
|
||||
bits_checked += 8;
|
||||
if (b[7] != 0 && b[7] != 1)
|
||||
return (0);
|
||||
bits_checked += 8;
|
||||
|
||||
return (bits_checked);
|
||||
}
|
||||
|
||||
static int
|
||||
rpm_bidder_init(struct archive_read_filter *self)
|
||||
{
|
||||
struct rpm *rpm;
|
||||
|
||||
self->code = ARCHIVE_COMPRESSION_RPM;
|
||||
self->name = "rpm";
|
||||
self->read = rpm_filter_read;
|
||||
self->skip = NULL; /* not supported */
|
||||
self->close = rpm_filter_close;
|
||||
|
||||
rpm = (struct rpm *)calloc(sizeof(*rpm), 1);
|
||||
if (rpm == NULL) {
|
||||
archive_set_error(&self->archive->archive, ENOMEM,
|
||||
"Can't allocate data for rpm");
|
||||
return (ARCHIVE_FATAL);
|
||||
}
|
||||
|
||||
self->data = rpm;
|
||||
rpm->state = ST_LEAD;
|
||||
|
||||
return (ARCHIVE_OK);
|
||||
}
|
||||
|
||||
static ssize_t
|
||||
rpm_filter_read(struct archive_read_filter *self, const void **buff)
|
||||
{
|
||||
struct rpm *rpm;
|
||||
const unsigned char *b;
|
||||
ssize_t avail_in, total;
|
||||
size_t used, n;
|
||||
uint32_t section;
|
||||
uint32_t bytes;
|
||||
|
||||
rpm = (struct rpm *)self->data;
|
||||
*buff = NULL;
|
||||
total = avail_in = 0;
|
||||
b = NULL;
|
||||
used = 0;
|
||||
do {
|
||||
if (b == NULL) {
|
||||
b = __archive_read_filter_ahead(self->upstream, 1,
|
||||
&avail_in);
|
||||
if (b == NULL) {
|
||||
if (avail_in < 0)
|
||||
return (ARCHIVE_FATAL);
|
||||
else
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
switch (rpm->state) {
|
||||
case ST_LEAD:
|
||||
if (rpm->total_in + avail_in < RPM_LEAD_SIZE)
|
||||
used += avail_in;
|
||||
else {
|
||||
n = RPM_LEAD_SIZE - rpm->total_in;
|
||||
used += n;
|
||||
b += n;
|
||||
rpm->state = ST_HEADER;
|
||||
rpm->hpos = 0;
|
||||
rpm->hlen = 0;
|
||||
rpm->first_header = 1;
|
||||
}
|
||||
break;
|
||||
case ST_HEADER:
|
||||
n = 16 - rpm->hpos;
|
||||
if (n > avail_in - used)
|
||||
n = avail_in - used;
|
||||
memcpy(rpm->header+rpm->hpos, b, n);
|
||||
b += n;
|
||||
used += n;
|
||||
rpm->hpos += n;
|
||||
|
||||
if (rpm->hpos == 16) {
|
||||
if (rpm->header[0] != 0x8e ||
|
||||
rpm->header[1] != 0xad ||
|
||||
rpm->header[2] != 0xe8 ||
|
||||
rpm->header[3] != 0x01) {
|
||||
if (rpm->first_header) {
|
||||
archive_set_error(
|
||||
&self->archive->archive,
|
||||
ARCHIVE_ERRNO_FILE_FORMAT,
|
||||
"Unrecoginized rpm header");
|
||||
return (ARCHIVE_FATAL);
|
||||
}
|
||||
rpm->state = ST_ARCHIVE;
|
||||
*buff = rpm->header;
|
||||
total = rpm->hpos;
|
||||
break;
|
||||
}
|
||||
/* Calculate 'Header' length. */
|
||||
section = archive_be32dec(rpm->header+8);
|
||||
bytes = archive_be32dec(rpm->header+12);
|
||||
rpm->hlen = 16 + section * 16 + bytes;
|
||||
rpm->state = ST_HEADER_DATA;
|
||||
rpm->first_header = 0;
|
||||
}
|
||||
break;
|
||||
case ST_HEADER_DATA:
|
||||
n = rpm->hlen - rpm->hpos;
|
||||
if (n > avail_in - used)
|
||||
n = avail_in - used;
|
||||
b += n;
|
||||
used += n;
|
||||
rpm->hpos += n;
|
||||
if (rpm->hpos == rpm->hlen)
|
||||
rpm->state = ST_PADDING;
|
||||
break;
|
||||
case ST_PADDING:
|
||||
while (used < (size_t)avail_in) {
|
||||
if (*b != 0) {
|
||||
/* Read next header. */
|
||||
rpm->state = ST_HEADER;
|
||||
rpm->hpos = 0;
|
||||
rpm->hlen = 0;
|
||||
break;
|
||||
}
|
||||
b++;
|
||||
used++;
|
||||
}
|
||||
break;
|
||||
case ST_ARCHIVE:
|
||||
*buff = b;
|
||||
total = avail_in;
|
||||
used = avail_in;
|
||||
break;
|
||||
}
|
||||
if (used == (size_t)avail_in) {
|
||||
rpm->total_in += used;
|
||||
__archive_read_filter_consume(self->upstream, used);
|
||||
b = NULL;
|
||||
used = 0;
|
||||
}
|
||||
} while (total == 0 && avail_in > 0);
|
||||
|
||||
if (used > 0 && b != NULL) {
|
||||
rpm->total_in += used;
|
||||
__archive_read_filter_consume(self->upstream, used);
|
||||
}
|
||||
return (total);
|
||||
}
|
||||
|
||||
static int
|
||||
rpm_filter_close(struct archive_read_filter *self)
|
||||
{
|
||||
struct rpm *rpm;
|
||||
|
||||
rpm = (struct rpm *)self->data;
|
||||
free(rpm);
|
||||
|
||||
return (ARCHIVE_OK);
|
||||
}
|
||||
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue