aboutsummaryrefslogtreecommitdiff
path: root/lib/libarchive/archive_write_set_format_pax.c
Commit message (Collapse)AuthorAgeFilesLines
* Use contrib sources for building libarchive, tar and cpio.Martin Matuska2011-12-221-1386/+0
| | | | | | | | | Make "make test" fully operational. MFC after: 2 weeks Notes: svn path=/head/; revision=228797
* Style and portability fixes for pax writer. Mostly very routine, except for:Tim Kientzle2009-12-291-31/+25
| | | | | | | | * Use ino64 where appropriate * Don't pass atime or nsec to ustar formatter Notes: svn path=/head/; revision=201162
* Merge r1021 from libarchive.googlecode.com:Tim Kientzle2009-04-271-1/+7
| | | | | | | If we know it's a socket, say so. Notes: svn path=/head/; revision=191579
* Merge r491,493,500,507,510,530,543 from libarchive.googlecode.com:Tim Kientzle2009-03-061-0/+1
| | | | | | | | This implements the new generic options framework that provides a way to override format- and compression-specific parameters. Notes: svn path=/head/; revision=189438
* Merge r294:337,r348:350 from libarchive.googlecode.com: A lotTim Kientzle2009-03-031-0/+16
| | | | | | | of work to make libarchive work on Windows. Notes: svn path=/head/; revision=189308
* MfP4: Store/read birthtime data in pax format.Tim Kientzle2008-09-301-0/+9
| | | | | | | | Submitted by: Pedro Giffuni MFC after: 30 days Notes: svn path=/head/; revision=183482
* MfP4: Joerg Sonnenberger's fixes to make 'ar' and 'pax' writersTim Kientzle2008-08-101-0/+3
| | | | | | | robust against multiple calls to their destroy() functions. Notes: svn path=/head/; revision=181485
* MFp4: libarchive 2.5.4b. (Still 'b' until I get a bit moreTim Kientzle2008-05-261-17/+58
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | feedback, but the 2.5 branch is shaping up nicely.) In addition to many small bug fixes and code improvements: * Another iteration of versioning; I think I've got it right now. * Portability: A lot of progress on Windows support (though I'm not committing all of the Windows support files to FreeBSD CVS) * Explicit tracking of MBS, WCS, and UTF-8 versions of strings in archive_entry; the archive_entry routines now correctly return NULL only when something is unset, setting NULL properly clears string values. Most charset conversions have been pushed down to archive_string. * Better handling of charset conversion failure when writing or reading UTF-8 headers in pax archives * archive_entry_linkify() provides multiple strategies for hardlink matching to suit different format expectations * More accurate bzip2 format detection * Joerg Sonnenberger's extensive improvements to mtree support * Rough support for self-extracting ZIP archives. Not an ideal approach, but it works for the archives I've tried. * New "sparsify" option in archive_write_disk converts blocks of nulls into seeks. * Better default behavior for the test harness; it now reports all failures by default instead of coredumping at the first one. Notes: svn path=/head/; revision=179321
* Remove the duplicate "archive_format" and "archive_format_name" fieldsTim Kientzle2008-03-151-6/+6
| | | | | | | | | | from the private archive_write structure and fix up all writers to use the format fields in the base "archive" structure. This error made it impossible to query the format after setting up a writer because the write format was stored in an inaccessible place. Notes: svn path=/head/; revision=177220
* Testability is more important than standards conformance.Tim Kientzle2008-03-151-3/+8
| | | | | | | | | Disable the use of PaxHeader.<pid> for the fake pax extension pathname until I can make the name here settable. Otherwise, tests that try to compare output to static pre-generated reference files break. Notes: svn path=/head/; revision=177212
* Resolve a minor nit in SUS compliance by including the PID in theTim Kientzle2008-03-151-12/+26
| | | | | | | fake directory name used for pax extended headers. Notes: svn path=/head/; revision=177201
* A subtle point: "pax interchange format" mandates that all stringsTim Kientzle2008-03-151-50/+126
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | (including pathname, gname, uname) be stored in UTF-8. This usually doesn't cause problems on FreeBSD because the "C" locale on FreeBSD can convert any byte to Unicode/wchar_t and from there to UTF-8. In other locales (including the "C" locale on Linux which is really ASCII), you can get into trouble with pathnames that cannot be converted to UTF-8. Libarchive's pax writer truncated pathnames and other strings at the first nonconvertible character. (ouch!) Other archivers have worked around this by storing unconvertible pathnames as raw binary, a practice which has been sanctioned by the Austin group. However, libarchive's pax reader would segfault reading headers that weren't proper UTF-8. (ouch!) Since bsdtar defaults to pax format, this affects bsdtar rather heavily. To correctly support the new "hdrcharset" header that is going into SUS and to handle conversion failures in general, libarchive's pax reader and writer have been overhauled fairly extensively. They used to do most of the pax header processing using wchar_t (Unicode); they now do most of it using char so that common logic applies to either UTF-8 or "binary" strings. As a bonus, a number of extraneous conversions to/from wchar_t have been eliminated, which should speed things up just a tad. Thanks to: Bjoern Jacke for originally reporting this to me Thanks to: Joerg Sonnenberger for noting a bad typo in my first draft of this Thanks to: Gunnar Ritter for getting the standard fixed MFC after: 5 days Notes: svn path=/head/; revision=177199
* Update libarchive to 2.4.10. This includes a number of improvementsTim Kientzle2007-12-301-5/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | that I've been working on but put off committing until after the RELENG_7 branch, including: * New manpages: cpio.5 mtree.5 * New archive_entry_strmode() * New archive_entry_link_resolver() * New read support: mtree format * Internal API change: read format auction only runs once * Running the auction only once allowed simplifying a lot of bid logic. * Cpio robustness: search for next header after a sync error * Support device nodes on ISO9660 images * Eliminate a lot of unnecessary copies for uncompressed archives * Corrected handling of new GNU --sparse --posix formats * Correctly handle a zero-byte write to a compressed archive * Fixed memory leaks Many of these improvements were motivated by the upcoming bsdcpio front-end. There have also been extensive improvements to the libarchive_test test harness, which I'll commit separately. Notes: svn path=/head/; revision=174991
* libarchive 2.2.3Tim Kientzle2007-05-291-165/+146
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * "compression_program" support uses an external program * Portability: no longer uses "struct stat" as a primary data interchange structure internally * Part of the above: refactor archive_entry to separate out copy_stat() and stat() functions * More complete tests for archive_entry * Finish archive_entry_clone() * Isolate major()/minor()/makedev() in archive_entry; remove these from everywhere else. * Bug fix: properly handle decompression look-ahead at end-of-data * Bug fixes to 'ar' support * Fix memory leak in ZIP reader * Portability: better timegm() emulation in iso9660 reader * New write_disk flags to suppress auto dir creation and not overwrite newer files (for future cpio front-end) * Simplify trailing-'/' fixup when writing tar and pax * Test enhancements: fix various compiler warnings, improve portability, add lots of new tests. * Documentation: document new functions, first draft of libarchive_internals.3 MFC after: 14 days Thanks to: Joerg Sonnenberger (compression_program) Thanks to: Kai Wang (ar) Thanks to: Colin Percival (many small fixes) Thanks to: Many others who sent me various patches and problem reports. Notes: svn path=/head/; revision=170079
* Conventionally, tar archives have always included a trailing '/'Tim Kientzle2007-04-141-65/+87
| | | | | | | | | | | | | | | | for directories. bsdtar used to add this, but that recently got lost somehow. So now I'm adding it back in libarchive. The only odd part of doing this in libarchive: Adding a directory to a tar archive and then reading it back again can yield a different name. Add a test case to exercise some boundary conditions with tar filenames and ensure that trailing slashes are added to dir names only as necessary. Thanks to: Oliver Lehmann for bringing this regression to my attention. Notes: svn path=/head/; revision=168706
* libarchive 2.0Tim Kientzle2007-03-031-25/+37
| | | | | | | | | | | | | | | | | | | | | | * libarchive_test program exercises many of the core features * Refactored old "read_extract" into new "archive_write_disk", which uses archive_write methods to put entries onto disk. In particular, you can now use archive_write_disk to create objects on disk without having an archive available. * Pushed some security checks from bsdtar down into libarchive, where they can be better optimized. * Rearchitected the logic for creating objects on disk to reduce the number of system calls. Several common cases now use a minimum number of system calls. * Virtualized some internal interfaces to provide a clearer separation of read and write handling and make it simpler to override key methods. * New "empty" format reader. * Corrected return types (this ABI breakage required the "2.0" version bump) * Many bug fixes. Notes: svn path=/head/; revision=167186
* Fix the copyright notice; it was always intended to beTim Kientzle2007-01-091-3/+2
| | | | | | | | | | | | a vanilla 2-clause BSD license, but somehow some confusing extra verbage get copied from somewhere. Also, update the copyright dates to 2007 for all of the files. Prompted by: several questions about what those extra words really mean Notes: svn path=/head/; revision=165912
* Fill in a couple of missing casts: clarify one narrowing conversionTim Kientzle2006-11-241-2/+2
| | | | | | | | | and correct the use of unary minus with an unsigned value. (The unary minus here is actually being used as a bitwise operation, which is unusual enough to deserve a clarifying cast.) Notes: svn path=/head/; revision=164576
* Change the internal API for writing data to an entry; make theTim Kientzle2006-11-151-3/+6
| | | | | | | | | | | | | | | internal format-specific functions return the same as the public function, so that the public API layer doesn't have to guess the correct return value. This addresses an obscure problem that occurs when someone tries to write more data than the size of the entry (as indicated in the entry header). In this case, the return value from archive_write_data() was incorrect, reflecting the requested write rather than the amount actually written. MFC after: 15 days Notes: svn path=/head/; revision=164290
* Portability and style fixes:Tim Kientzle2006-11-101-10/+24
| | | | | | | | | | | | | | | | | * Actually use the HAVE_<header>_H macros to conditionally include system headers. They've been defined for a long time, but only used in a few places. Now they're used pretty consistently throughout. * Fill in a lot of missing casts for conversions from void*. Although Standard C doesn't require this, some people have been trying to use C++ compilers with this code, and they do require it. Bit-for-bit, the compiled object files are identical, except for one assert() whose line number changed, so I'm pretty confident I didn't break anything. ;-) Notes: svn path=/head/; revision=164142
* POSIX.1e-style Extended Attribute supportTim Kientzle2006-03-211-5/+164
| | | | | | | | | | | | | | This commit implements storing/reading POSIX.1e-style extended attribute information in "pax" format archives. An outline of the storage format is in the tar.5 manpage. The archive_read_extract() function has code to restore those archives to disk for Linux; FreeBSD implementation is forthcoming. Many thanks to Jaakko Heinonen for finding flaws in earlier proposals and doing the bulk of the coding in this work. Notes: svn path=/head/; revision=156961
* Minor fixes to the code that generates an internal ustar filenameTim Kientzle2006-02-141-21/+22
| | | | | | | for Pax extended attribute entries. Notes: svn path=/head/; revision=155654
* Portability: Use some autoconf magic to include theTim Kientzle2005-11-081-0/+7
| | | | | | | | | | correct headers for major()/minor()/makedev() on various platforms. Thanks to: Darin Broady Notes: svn path=/head/; revision=152174
* In pax interchange format, use UTF8 for writingTim Kientzle2005-10-121-21/+38
| | | | | | | | | | | | | link names, usernames, or group names that contain non-ASCII characters. In particular, this corrects an inconsistency reported by Ed Maste when archiving symlinks with odd characters: long symlinks would get preserved, short ones would be changed. Notes: svn path=/head/; revision=151249
* Add a lot of error checks, based on the patches provided by Dan Lukes.Tim Kientzle2005-09-211-0/+3
| | | | | | | | | | Also fixes a memory leak reported by Andrew Turner. PR: bin/83476 Thanks to: Dan Lukes, Andrew Turner Notes: svn path=/head/; revision=150407
* Style issue: Don't include <wchar.h> where it is not actually needed.Tim Kientzle2005-09-101-1/+0
| | | | | | | | | | | | (wchar_t is defined in stddef.h, and only two files need more than that.) Portability: Since the wchar requirements are really quite modest, it's easy to define basic replacements for wcslen, wcscmp, wcscpy, etc, for use on systems that lack <wchar.h>. In particular, this allows libarchive to be used on older OpenBSD systems. Notes: svn path=/head/; revision=149964
* When copying time values from the main entry header to be used in theTim Kientzle2005-08-021-10/+19
| | | | | | | | | | | header of the pax extension entry, clip them to ustar limits. In particular, this prevents an internal panic for very old files. Thanks to: Chris Spiegel MFC after: 7 days Notes: svn path=/head/; revision=148634
* A minor refinement to "pax" output: Remove suid/sgid/sticky bitsTim Kientzle2005-06-011-0/+22
| | | | | | | | | | | from mode before using mode for extended attributes entry, copy mtime/atime/ctime to extended attributes entry so it's a little more clear that it corresponds to the like-named regular entry. MFC after: 14 days Notes: svn path=/head/; revision=146875
* Certain filenames between 245 and 255 characters long would cause anTim Kientzle2005-04-231-71/+72
| | | | | | | | | | | | | | | | | | | | internal error if pax extended attributes were being generated. Being < 255 characters, the first-pass path editing (to generate a ustar-compatible name for the main entry) wouldn't occur, and the second-pass path editing (to generate a ustar name for the pax attributes entry) assumed the input was already < 245 chars. The core problem here was using an abbreviated algorithm for the second pass that relied on the first pass having already run. The rewritten code is much simpler: It just uses the full path-shortening algorithm for building both ustar pathnames. This way, the second ustar pathname will always be short enough. Thanks to: Mark Cammidge Related to: bin/74385 Notes: svn path=/head/; revision=145454
* Rewrite the code that hacks a short names to use inTim Kientzle2004-12-291-60/+152
| | | | | | | | | | | | | | the regular ustar entry. The old code sometimes created a too-long name that overflowed the ustar fields and triggered an internal assertion failure. This version should be more robust. Thanks to: Michal Listos Fixes: bin/74385 MFC after: 15 days Notes: svn path=/head/; revision=139420
* Don't truncate major/minor numbers written to the legacyTim Kientzle2004-12-221-3/+15
| | | | | | | | | | | | | | | ustar fields. Later, we're going to permit numeric extensions for these fields, so we can support large values here. In particular, this allows GNU tar to correctly extract such entries even though it doesn't support the pax extended attributes. Note: r1.18 and r1.17.2.1 of this file allowed similar treatment of the uid/gid fields. Thanks to: Ben Mesander Notes: svn path=/head/; revision=139157
* When determining whether filename is too long for aTim Kientzle2004-11-281-6/+6
| | | | | | | | | | | | regular 'ustar' entry, use narrow-character version, not wide-character version, as the ustar entry always uses the narrow-character filename. Thanks to: Michal Listos Inspired by, but doesn't fix: bin/74385 Notes: svn path=/head/; revision=138165
* Correct the spelling of "archive_write_pax_header"Tim Kientzle2004-11-281-1/+1
| | | | | | | | | | in an error message. Thanks to: Michal Listos Inspired by, but doesn't fix: bin/74385 Notes: svn path=/head/; revision=138163
* Since I'm not using the public API for writingTim Kientzle2004-11-151-6/+8
| | | | | | | | | | the the pax attributes, I shouldn't try using the public API for finishing out the attribute entry, either. This also removes some old dubious state manipulations. Notes: svn path=/head/; revision=137711
* Pax extended headers were always failingTim Kientzle2004-11-151-1/+1
| | | | | | | | | | | | because the code was using the external API (archive_write_data) and assuming internal error-return conventions. Use the internal API for writing data. Thanks to: Joe Marcus Clarke Notes: svn path=/head/; revision=137710
* Clean up the error handling in theTim Kientzle2004-11-051-8/+8
| | | | | | | | | write path. In particular, this should solve some problems people have seen with bsdtar not exiting on various write errors. Notes: svn path=/head/; revision=137236
* Fix two ugly errors:Tim Kientzle2004-09-171-2/+6
| | | | | | | | | | | | 1. The correct cutoff for large uid/gid handling is 1<<18, not 1<<20. 2. Limit the uid/gid in the 'x' extension header (where numeric extensions are not permitted) to 1<<18, but use the correct value in the regular header (where numeric extensions are permitted). Thanks to: Dan Nelson MFC after: 3 days Notes: svn path=/head/; revision=135358
* Oops. Use "unsigned long" instead of "int" for the intermediate variablesTim Kientzle2004-08-081-8/+6
| | | | | | | | in wide-character conversions, since it's guaranteed to be large enough. Thanks to: Andrey Chernov Notes: svn path=/head/; revision=133304
* Use 'int' for certain wide-character conversions instead of wchar_t.Tim Kientzle2004-08-081-1/+1
| | | | | | | | That quiets some compiler warnings on platforms with 16-bit wchar_t. With this change, libarchive now compiles cleanly on Win32/cygwin. Notes: svn path=/head/; revision=133299
* Beef up the "cannot archive this" error message with theTim Kientzle2004-08-071-1/+2
| | | | | | | actual mode that failed, to help track down a bug. Notes: svn path=/head/; revision=133242
* When writing "pax" format, readers are supposed to ignore fieldsTim Kientzle2004-07-261-5/+28
| | | | | | | | | | | | | | | | | | | | | in the regular ustar header that are overridden by the pax extended attributes. As a result, it makes perfect sense to use numeric extensions in the regular ustar header so that readers that don't understand pax extensions but do understand some other extensions can still get useful information out of it. This is especially important for filesizes, as the failure to read a file size correctly can get the reader out of sync. This commit introduces a "non-strict" option into the internal function to format a ustar header. In non-strict mode, the formatter will use longer octal values (overwriting terminators) or binary ("base-256") values as needed to ensure that large file sizes, negative mtimes, etc, have the correct values stored in the regular ustar header. Notes: svn path=/head/; revision=132647
* We were forcing a pax extension header for files >= 1G. Set thatTim Kientzle2004-07-251-1/+1
| | | | | | | cutoff to >= 8G, as it should be. Notes: svn path=/head/; revision=132635
* Clean up some consistent confusion between "dev" and "rdev."Tim Kientzle2004-06-271-14/+18
| | | | | | | | | | | Mostly, these were being used correctly even though a lot of variables and function names were mis-named. In the process, I found and fixed a couple of latent bugs and added a guard against adding an archive to itself. Notes: svn path=/head/; revision=131205
* Update file flag handling.Tim Kientzle2004-04-261-1/+7
| | | | | | | | | | | | | | | | | | | The new fflags support in archive_entry supports Linux and FreeBSD file flags and is a bit more gracious about unrecognized flag names than strtofflags(3). This involves some minor API breakage. The default tar format ("restricted pax") now enables pax extensions when archiving files that have flags. In particular, copying dir heirarchies with 'bsdtar cf - -C src . | bsdtar xpf - -C dest' now preserves file flags. (Note the "p" on extract!) While I'm here, fill in some additional explanation in the archive_entry.3 manpage, fill in some missing MLINKS, mark some overlooked internal functions 'static', and make a few minor style fixes. Notes: svn path=/head/; revision=128669
* More portability improvements, thanks to Juergen Lock.Tim Kientzle2004-04-211-8/+11
| | | | | | | | | High-resolution mtime/ctime/atime is not POSIX-standard, so hide set/get of high-resolution time fields behind easily-mutable macros. That makes it easier to change how those fields are accessed. Notes: svn path=/head/; revision=128515
* Eliminate some redundant calls to archive_entry_hardlink.Tim Kientzle2004-04-201-5/+8
| | | | Notes: svn path=/head/; revision=128495
* * Plug a buffer overrun in ACL parsing. (archive_entry.c)Tim Kientzle2004-04-131-3/+7
| | | | | | | | | | * Re-use a single buffer for shar output formatting rather than hammering the heap. (archive_write_set_format_shar.c) * Fix a handful of minor memory leaks and clean up some of the memory-management code. Notes: svn path=/head/; revision=128204
* More work on ACLs: fix error in archive_entry's ACL parsing code,Tim Kientzle2004-04-121-6/+2
| | | | | | | | | | | | | | | | | try to set ACLs even if fflag restore fails, first cut at reading Solaris tar ACLs Code improvement: merge gnu tar read support into main tar reader; this eliminates a lot of duplicate code and generalizes the tar reader to handle formats with GNU-like extensions. Style: Makefile cleanup, eliminate 'dmalloc' references, remove 'tartype' from archive_entry (this makes archive_entry more format-agnostic) Thanks to: David Magda for providing Solaris tar test files Notes: svn path=/head/; revision=128148
* Fix some issues with ACL handling:Tim Kientzle2004-04-061-12/+20
| | | | | | | | | | | | | * ACL storage is no longer erased before a group of entries are added. * ACL text creation no longer tries to skip over non-existent text. * UTF8 encoder no longer blows up on invalid wide characters. * Fixed ACL state management for default ACLs. Also, publicize function for obtaining text-format ACL in various formats. The interface is now extensible through a "flags" argument that allows you to select a variant format. Notes: svn path=/head/; revision=127971
* Overhauled ACL support. This makes us compatibleTim Kientzle2004-04-051-8/+20
| | | | | | | | | | | | | | | with 'star' ACL handling, though there's still a bit more work needed in this area. Added 'write_open_fd' and 'read_open_fd' to simplify, e.g., tar's u and r modes. Eliminated old 'write_open_file_position' as a bad idea. (It required closing/reopening files to do updates, which led to unpleasant implications.) Various other minor fixes, API tweaks, etc. Notes: svn path=/head/; revision=127912