summaryrefslogtreecommitdiff
path: root/lib/libarchive/archive_write_disk.c
Commit message (Collapse)AuthorAgeFilesLines
* Fix a minor memory leak.Tim Kientzle2009-04-171-0/+2
| | | | Notes: svn path=/head/; revision=191167
* Merge from libarchive.googlecode.com: Mostly a bunch ofTim Kientzle2009-04-121-8/+16
| | | | | | | | | | | | | | | | corrections to the Windows support to reconcile differences between Visual Studio and Cygwin. Includes parts of revisions 757, 774, 787, 815, 817, 819, 820, 844, and 886. Of particular note, r886 overhauled the UTF-8/Unicode conversions to work correctly regardless of whether the local system uses 16-bit or 32-bit wchar_t. (I assume that systems with 16-bit wchar_t use UTF-16 and those with 32-bit wchar_t use UCS-4.) This revision also added a preference for wcrtomb() (which is thread-safe) on platforms that support it. Notes: svn path=/head/; revision=190959
* Merge r723 from libarchive.googlecode.com: Don't try to restoreTim Kientzle2009-03-071-0/+8
| | | | | | | owner or SUID bits on Windows; just ignore them. Notes: svn path=/head/; revision=189479
* Merge r552,r559 from libarchive.googlecode.com: Support high-resolutionTim Kientzle2009-03-071-7/+13
| | | | | | | timestamps on Tru64, AIX, and GNU Hurd. Thanks to Björn Jacke. Notes: svn path=/head/; revision=189466
* Merge r283,r529 from libarchive.googlecode.com: Fix ext2_fs.h includesTim Kientzle2009-03-071-4/+10
| | | | | | | for Linux. Notes: svn path=/head/; revision=189465
* Merge r403,702,721 from libarchive.googlecode.com: Handle oddTim Kientzle2009-03-061-0/+54
| | | | | | | | pathnames on Windows by mapping '\\' to '/' and converting illegal characters to '_'. Notes: svn path=/head/; revision=189436
* Merge r416 from libarchive.googlecode.com:Tim Kientzle2009-03-061-6/+93
| | | | | | | | | | Restoring POSIX.1e Extended Attributes on FreeBSD, part 1 This implements the basic ability to restore extended attributes on FreeBSD, including a test suite. Notes: svn path=/head/; revision=189431
* Merge r407,r508 from libarchive.googlecode.com: Correctly handleTim Kientzle2009-03-061-0/+3
| | | | | | | | | | | | | Zip entries that are zero length but stored with deflate. This is arguably a silly thing to do (deflating a zero-length file actually makes it bigger) but apparently quite a few Zip writers do this. This was broken in two places: archive_write_disk disliked being asked to write data to zero-length files (even if the write was zero-length) and zip_read_file_header tripped over itself when non-regular files had compressed bodies. Notes: svn path=/head/; revision=189430
* Merge r390,r391,r392,r397 from libarchive.googlecode.com: VirtualizeTim Kientzle2009-03-051-2/+2
| | | | | | | | | "close" and "finish" across both read and write interfaces. (Someday, "finish" should be renamed to "free" to better reflect what it actually does...) Notes: svn path=/head/; revision=189424
* Correct r189383, which mis-merged a change from libarchive.googlecode.com.Tim Kientzle2009-03-051-2/+2
| | | | Notes: svn path=/head/; revision=189388
* Merge r342 from libarchive.googlecode.com: Remove someTim Kientzle2009-03-051-28/+1
| | | | | | | Windows special casing. Notes: svn path=/head/; revision=189383
* Merge r294:337,r348:350 from libarchive.googlecode.com: A lotTim Kientzle2009-03-031-1/+35
| | | | | | | of work to make libarchive work on Windows. Notes: svn path=/head/; revision=189308
* Fix ARCHIVE_EXTRACT_SPARSE handling in libarchive.Tim Kientzle2009-01-261-22/+26
| | | | | | | | | | | Add a test to exercise this feature. This should fix --sparse/-S support in tar. Thanks to: Daichi GOTO MFC after: 1 week Notes: svn path=/head/; revision=187704
* Merge-from-Googlecode r419Tim Kientzle2009-01-211-17/+17
| | | | | | | | | | | | | | | | | | In archive_write_disk: If archive_write_header() fails to create the file, that's a failure and should return ARCHIVE_FAILED. Metadata restore failures still return ARCHIVE_WARN, because that's non-critical. Fix test_write_disk_secure test to verify the correct return code in one case; add test_write_disk_failures to do another very simple test of restore failure. This should fix cpio coredumping when it tries to restore to a write-protected directory. Thanks to: Giorgos Keramidas MFC after: 30 days Notes: svn path=/head/; revision=187521
* Minor portability: Declare 'r' only within the conditionalTim Kientzle2008-12-061-2/+2
| | | | | | | block where it's used; S_ISLNK is more portable than S_ISLINK. Notes: svn path=/head/; revision=185666
* Add test to verify ACL restores on FreeBSD, verify kern/128203 (mtimeTim Kientzle2008-10-191-4/+4
| | | | | | | | | | | restore fails if ACL provided), apply patch from kern/128203, and verify fix. PR: kern/128203 Submitted by: Udo Schweigert MFC after: 3 days Notes: svn path=/head/; revision=184038
* MfP4: restore birth time data to disk + more thorough tests forTim Kientzle2008-09-301-83/+121
| | | | | | | | | time restore to disk. MFC after: 30 days Notes: svn path=/head/; revision=183483
* Choose a flag-handling strategy based on platform capabilitiesTim Kientzle2008-09-141-6/+7
| | | | | | | rather than on platform. Notes: svn path=/head/; revision=183011
* Portability: Not everyone is lucky enough to have ftruncate()Tim Kientzle2008-09-121-0/+2
| | | | Notes: svn path=/head/; revision=182955
* Portability: Support platforms that lack (struct stat).st_blksize or SSIZE_MAXTim Kientzle2008-09-121-0/+6
| | | | | | | Of course, FreeBSD has both. Notes: svn path=/head/; revision=182954
* When restoring a directory, allow symlinks to be followed. The fullTim Kientzle2008-09-071-3/+15
| | | | | | | | | | | | | | | logic here gets a little complex, but the net effect is that the SECURE_SYMLINKS flag will prevent us from ever following a symlink. Without it, we'll only follow symlinks to dirs. bsdtar specifies SECURE_SYMLINKS by default, suppresses it for -P. I've also beefed up the write_disk_secure test to verify this behavior. PR: bin/126849 Notes: svn path=/head/; revision=182838
* MfP4: Handle entries with unset size properly: Regular files withTim Kientzle2008-09-051-43/+81
| | | | | | | | | | | unspecified size are "unlimited" (required by Zip reader, which sometimes does not know the uncompressed size of an entry until it gets to the end). Also, hardlinks with unspecified (or zero) size do not overwrite the data on disk nor do they set metadata. This is compatible with GNU tar and NetBSD pax behavior. Notes: svn path=/head/; revision=182779
* MfP4: Use the set/unset tracking to determine when mtime or atimeTim Kientzle2008-09-051-14/+51
| | | | | | | | is unavailable. Use start_time as a substitute when one is missing; if both are missing, skip the call to {f,l,}utime{s,}() entirely. Notes: svn path=/head/; revision=182778
* Use the "start_time" (time at which the restore process began)Tim Kientzle2008-09-011-5/+13
| | | | | | | | | to fill in a missing atime instead of substituting mtime. PR: bin/124915 Notes: svn path=/head/; revision=182587
* If no atime was specified (for example, when extracting from ustarTim Kientzle2008-08-281-0/+5
| | | | | | | | archives), set atime == mtime. Before this, atime would get restored to 0. Notes: svn path=/head/; revision=182360
* Update the total archive byte counters when writing entries to disk usingTim Kientzle2008-08-241-0/+2
| | | | | | | | | archive_write_disk. Update cpio to use this to emit block counts in -p mode. Update cpio tests to verify these block counts. Notes: svn path=/head/; revision=182102
* Fail copying path/.. only if SECURE_NODOTDOT was specified.Tim Kientzle2008-08-241-15/+3
| | | | | | | | | | Since we already warn for any '..' elements in that case, the extra "lastdotdot" tracking turns out to be unnecessary. PR: bin/124924 Notes: svn path=/head/; revision=182097
* Fix the cpio bug tested for by r182092 of usr.bin/cpio/test.Tim Kientzle2008-08-241-1/+5
| | | | | | | | | | | Since various 'find' incantations can emit container directories in various orders, we cannot refuse to update a dir because it's apparently the same age. MFC after: 3 days Notes: svn path=/head/; revision=182093
* When ARCHIVE_EXTRACT_PERM is requested (e.g., by "tar -p"), alwaysTim Kientzle2008-07-051-5/+9
| | | | | | | | | | | | | | | schedule a chmod() fixup for directories. In particular, this fixes sgid handling on systems where the sgid bit is inherited from the parent directory (which means that the actual mode of the dir does not match the mode used in the mkdir() system call. It may be possible to tighten this condition a bit. In working through this, I also found a few other places where it looks like we can avoid a redundant syscall or two. I've commented those here but not yet tried to address them. Notes: svn path=/head/; revision=180270
* Don't use the deprecated linux/ext2_fs.h include file.Tim Kientzle2008-07-051-3/+0
| | | | Notes: svn path=/head/; revision=180269
* A security-check failure here should be ARCHIVE_FAILED (cannot continue thisTim Kientzle2008-06-211-3/+3
| | | | | | | | | operation) and not ARCHIVE_WARN, since we don't actually open the file. Both bsdtar and bsdcpio will try to copy file contents after an ARCHIVE_WARN, which will fail loudly. Notes: svn path=/head/; revision=179914
* MFp4: libarchive 2.5.4b. (Still 'b' until I get a bit moreTim Kientzle2008-05-261-43/+120
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* FreeBSD does have fstat().Tim Kientzle2008-03-151-1/+1
| | | | | | | Correct the nasty typo this uncovers. Notes: svn path=/head/; revision=177213
* Spelling correction, thanks to Joerg Sonnenberger.Tim Kientzle2008-02-271-1/+1
| | | | Notes: svn path=/head/; revision=176620
* Portability improvements:Tim Kientzle2008-02-191-23/+66
| | | | | | | | | | | | | | | | | | * If the platform can't restore char nodes, block nodes, or fifos, don't try and just return error. * Include O_BINARY in most open() calls (define O_BINARY to 0 if the platform doesn't provide a definition already) * Refactor the ownership restore to more cleanly support platforms that don't have any form of {l,f,}chown() call. * Comment a lingering issue with older Unix-like systems that allow root to hose the filesystem. I don't (yet) have a good solution for this, but I expect it will require adding more redundant stat() calls. <sigh> MFC after: 14 days Notes: svn path=/head/; revision=176396
* I misread the Tinderbox error; this should really unbreak 64-bit builds.Tim Kientzle2008-01-181-1/+1
| | | | | | | Pointy hats, yep, keep 'em coming. ;-/ Notes: svn path=/head/; revision=175428
* Fix 64-bit build after my last commit. <sigh>Tim Kientzle2008-01-181-1/+1
| | | | Notes: svn path=/head/; revision=175427
* Issues with hardlinks in newc-format files prompted me toTim Kientzle2008-01-181-6/+32
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | write a new test to exercise the hardlink strategies used by different archive formats (tar, old cpio, new cpio). This uncovered two problems, both fixed by this commit: 1) Enforce file size when writing files to disk. 2) When restoring hardlink entries, if they have data associated, go ahead and open the file so we can write the data. In particular, this fixes bsdtar/bsdcpio extraction of new cpio formats where the "original" is empty and the subsequent "hardlink" entry actually carries the data. It also provides correct behavior for old cpio archives where hardlinked entries have their bodies stored multiple times in the archive; the last body should always be the one that ends up in the final file. The new pax format also permits (but does not require) hardlinks to carry file data; again, the last contents should always win. Note that with any of these, a size of zero on a hardlink simply means that the hardlink carries no data; it does not mean that the file has zero size. A non-zero size on a hardlink does provide the file size. Thanks to: John Baldwin, for reminding me about this long-standing bug and sending me a simple example archive that prompted this test case Notes: svn path=/head/; revision=175423
* Update libarchive to 2.4.10. This includes a number of improvementsTim Kientzle2007-12-301-0/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* Fix the archive_write_data() function so it always returnsTim Kientzle2007-09-211-3/+10
| | | | | | | | | | | | | | | | number of bytes written, even when used to write files to disk. Extend the test suite to verify the correct return values for archive_write_data() and archive_write_data_block(). Thanks to: Bruce Mah, for stepping in promptly to back out the earlier broken version of this fix Thanks to: Colin Percival, for pointing out the correct fix MFC after: 5 days Approved by: re (ksmith) Pointy hat: \me Notes: svn path=/head/; revision=172267
* Revert the last commit to libarchive. It introduced some regresssions,Bruce A. Mah2007-09-181-7/+4
| | | | | | | | | | | | | | most noticably the incorrect extraction of files by bsdtar. This commit reverts: src/lib/libarchive/archive_write_disk.c 1.15 src/lib/libarchive/test/test_write_disk.c 1.4 Approved by: re (implicitly) Notes: svn path=/head/; revision=172222
* Correct the return value from archive_write_data()Tim Kientzle2007-09-181-4/+7
| | | | | | | | | | | | | | (when used to restore files to disk) to match: * The documentation * The return values of this function when used to write files into an archive. Approved by: re (bmah) Pointy hat: \me MFC after: 5 days Notes: svn path=/head/; revision=172215
* Make suid/sgid restore be "opportunistic" ifTim Kientzle2007-08-121-6/+22
| | | | | | | | | | | | | | | | | | | | | | | | | | | owner restore is not requested. If you ask for permissions to be restored but not owner, you will now get no error if suid/sgid bits cannot be set. (It's a security hole to restore suid/sgid bits if the owner/group aren't restored.) This fixes an obscure problem where a simple "tar -xf" with no other options will sometimes fail gratuitously because of suid/sgid bits. This is causing occasional problems for people using bsdtar as a drop-in replacement for "that other tar program." ;-) Note: If you do ask for owner restore, then suid/sgid restore failures still issue an error. This only suppresses the error in the case where an suid/sgid bit restore fails because of an owner mismatch and owner restore was not requested. Approved by: re (bmah) MFC after: 7 days Notes: svn path=/head/; revision=171811
* archive_string_ensure() used to call exit(3) if itTim Kientzle2007-07-151-1/+4
| | | | | | | | | | | | | couldn't allocate more memory for a string. Change this so it returns NULL in that case, and update all of its callers to handle the error. Some of those callers can now return errors back to the client instead of calling exit(3). Approved by: re (bmah) Notes: svn path=/head/; revision=171460
* libarchive 2.2.3Tim Kientzle2007-05-291-20/+92
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * "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
* Remove pointless code: Don't assign a value to a variable when we'reColin Percival2007-05-211-1/+0
| | | | | | | | | | | | | | going to overwrite it with a new value a few lines later. Visual inspection of the surrounding code indicates that the code does what it's supposed to do; i.e., the pointless code wasn't supposed to be doing something other than what it was doing. CID: 3323 Found by: Coverity Prevent(tm) Notes: svn path=/head/; revision=169812
* Properly cleanup the UID/GID lookup data.Tim Kientzle2007-04-151-0/+4
| | | | Notes: svn path=/head/; revision=168747
* Invoke utime(2) properly. (It's only used on platformsTim Kientzle2007-04-141-2/+2
| | | | | | | that lack utimes(2).) Notes: svn path=/head/; revision=168739
* More portability improvements from Martin Koeppe:Tim Kientzle2007-04-141-0/+51
| | | | | | | | | conditionally use utime() when utimes() is not available; allow the most common wide-char functions to be replaced when local alternatives are lacking. Notes: svn path=/head/; revision=168701
* Make Lint happier.Tim Kientzle2007-04-121-1/+2
| | | | Notes: svn path=/head/; revision=168647