summaryrefslogtreecommitdiffstats
path: root/usr.bin/tar/util.c
Commit message (Collapse)AuthorAgeFilesLines
* Use contrib sources for building libarchive, tar and cpio.mm2011-12-221-563/+0
| | | | | | Make "make test" fully operational. MFC after: 2 weeks
* Update bsdtar to 2.8.4mm2011-07-171-7/+7
| | | | | | | Use common code from lib/libarchive/libarchive_fe Approved by: kientzle MFC after: 2 weeks
* If there is a read error reading Y/N confirmation from the keyboard,kientzle2011-06-251-1/+5
| | | | | | | | | exit immediately with an error. If there is an error opening or reading a file to put into the archive, set the return value for a deferred error exit. PR: bin/154407
* Merge a bunch of refactoring from Joerg Sonnenberger tokientzle2010-02-071-107/+46
| | | | | | isolate common code used by tar and cpio (and useful to other libarchive clients). The functions here are prefixed with "lafe" (libarchive front-end) to indicate their use.
* Refactor the siginfo/sigusr1 handling. The read/write reportingkientzle2010-02-061-0/+22
| | | | | | | | | is sufficiently different that it was simpler to just put separate reporting functions into read.c and write.c rather than try to have a single all-purpose reporting function. Switch to a custom function for converting int64_t to a string; in the portable version, this saves a lot of configuration headaches trying to decipher the platform printf().
* Diff reduction compared to portable bsdtar 2.8: Move thekientzle2010-02-061-45/+13
| | | | | program name into a global, which eliminates an extra argument from a lot of places.
* Minor portability improvement in calls to ctype.h macros.kientzle2009-04-171-2/+2
|
* Merge r709,r710 from libarchive.googlecode.com: More work onkientzle2009-03-081-31/+58
| | | | Windows support.
* Merger r629-631,633-646,648,654,678,681,682 from libarchive.googlecode.com:kientzle2009-03-081-11/+34
| | | | | Many changes for Windows compatibility. bsdtar_test now runs successfully on both POSIX platforms and Windows.
* Merge r622 from libarchive.googlecode.com: Avoid warning on platformskientzle2009-03-081-1/+1
| | | | that lack regex.h.
* Spell "substitution" correctly.kientzle2008-12-151-3/+3
| | | | | | | PR: bin/128616 Submitted by: Jaakko Heinonen Pointy hat: Tim Kientzle MFC after: 30 days
* When deciding which characters (of a filename, for instance)kientzle2008-11-291-49/+118
| | | | | | | | | | | | are safe to print, try to take into account the current locale. This iterates over output strings using mbtowc() to identify multi-byte sequences. If iswprint() claims the corresponding wide character is printable, the original bytes are passed through. Otherwise, we expand characters into C-style \-escape sequences. Submitted by: Michihiro NAKAJIMA MFC after: 30 days
* Test --strip-components and fix it to actually work. Jaakko did akientzle2008-11-101-16/+38
| | | | | | | | | | | | | | | good job writing this test; it exercises a lot of subtle cases. The trickiest one is that a hardlink to something that didn't get extracted should not itself be extracted. In some sense, this is not the desired behavior (we'd rather restore the file), but it's the best you can do in a single-pass restore of a tar archive. The test here should be extended to exercise cpio and newc formats as well, since their hardlink models are different, which will lead to different handling of some of these edge cases. Submitted by: Jaakko Heinonen MFC after: 30 days
* Rework code to avoid using a pointer after freeing it. Aside from thecperciva2008-06-091-2/+4
| | | | | | | possibility of memory becoming undereferenceable when it is freed, this change should have no effect on bsdtar behaviour. Found by: Coverity Prevent
* MFp4: bsdtar 2.5.4bkientzle2008-05-261-5/+55
| | | | | | | | | | | | | In addition to a number of bug fixes and minor changes: * --numeric-owner (ignore user/group names on create and extract) * -S (sparsify files on extraction) * -s (regex filename substitutions) * Use new libarchive 'linkify' to get correct hardlink handling for both old and new cpio formats * Rework 'copy' test to be insensitive to readdir() filename ordering Most of the credit for this work goes to Joerg Sonnenberger, who has been duplicating features from NetBSD's 'pax' program.
* Use archive_entry_strmode() instead of a local bsdtar_strmode().kientzle2008-01-021-50/+0
| | | | | | (This does a couple of things that the standard library's strmode() doesn't; it proved useful in bsdcpio as well, so I pushed it down into libarchive.)
* Ignore trailing '/' when comparing pathnames, so thatkientzle2007-04-181-3/+26
| | | | | "tar -u" works again. Otherwise, "tar -u" wants to treat every dir as new and re-adds it.
* bsdtar 2.0.23:kientzle2007-03-111-4/+30
| | | | | | | | | | * New test scripts exercise some basic functionality * Most header inclusions are now protected (portability) * read.c now relies on security checks in libarchive instead of trying to do its own (optimization) * -p now enabled by default for root, add --no-same-permissions to disable it * Comments, minor style fixes.
* Correct the copyright messages: Make this a standard vanillakientzle2007-01-091-3/+2
| | | | 2-clause BSD license, update the year to 2007.
* Extended attribute support on write for Linux; FreeBSD hooks arekientzle2006-03-211-1/+0
| | | | | | | | | | forthcoming. This commit also has a number of style(9) fixes and minor corrections so the code works better with the build system being used for non-FreeBSD builds. Many thanks to: Jaakko Heinonen, who proposed a mechanism for extended attribute support and implemented both the machine-independent portion and the Linux-specific portion.
* A very minor tweak to the handling of leading '/' characters.kientzle2005-04-171-1/+6
|
* Support path-rewriting options (including --strip-components) for bothkientzle2005-04-171-0/+53
| | | | | | extraction and creation. While I'm here, fix a bug reported by Garrett Wollman: when stripping the leading '/' from the path "/", don't produce an entry with an empty name; produce "." instead.
* Move the smart chdir logic into a couple of utility functions in util.c.kientzle2004-08-081-0/+58
| | | | | Then use them to provide consistent -C support throughout the program. Thanks to: Christoph Mallon
* A bunch of style and security fixes (error checking return values, etc),kientzle2004-07-251-2/+4
| | | | mostly from: Tim J Robbins
* Augment the -T handling:kientzle2004-06-271-0/+86
| | | | | | | | | | | | * Add --null option (sort #defines here) * Add process_lines function to util.c that reads newline-terminated or null-terminated lines (with self-sizing buffers, etc) and iteratively invokes a provided function. Use this to dramatically simplify: -T handling for -c, --exclude-from-file, and --include-from-file. * Add -T handling to -x (via include_from_file) Hopefully, this will fix the openoffice port and a couple of others that rely on -T and --null.
* Pointy hat: sticky bit 't' or 'T' is shown over IXOTH bit, not IXGRP. <sigh>kientzle2004-06-031-1/+1
|
* Speed up safe_fprintf by copying to a temp buffer, then writingkientzle2004-05-171-13/+32
| | | | blocks at a time, rather than using putc().
* Propagate struct bsdtar down into a lot more places.kientzle2004-05-171-16/+8
| | | | Move global progname variable into struct bsdtar.
* Contrariwise, Linux sys/stat.h doesn't define mode_t and friends,kientzle2004-05-041-0/+1
| | | | even though POSIX requires it. <sigh>
* For portability, don't rely on libc's strmode(3). <sigh>kientzle2004-05-031-0/+51
|
* As suggested by Julian Elischer, use a self-sizing hashkientzle2004-04-151-15/+21
| | | | | | | | table for the hardlink cache. This dramatically improves performance when archiving millions of hardlinked files. While I'm here, clean up some style bugs (per Bruce Evans) and clarify some comments.
* Eliminate a lot of malloc/free calls by usingkientzle2004-04-131-4/+11
| | | | | a stack-allocated buffer for safe_fprintf formatting. Only if the result is too large do we resort to malloc.
* Initial commit for bsdtar.kientzle2004-04-051-0/+160
OpenPOWER on IntegriCloud