summaryrefslogtreecommitdiffstats
path: root/usr.bin/tar/write.c
Commit message (Collapse)AuthorAgeFilesLines
* Use contrib sources for building libarchive, tar and cpio.mm2011-12-221-1176/+0
| | | | | | Make "make test" fully operational. MFC after: 2 weeks
* Sync bsdtar with vendor branch release/2.8:mm2011-12-201-3/+2
| | | | | | | | | Revision 3769: Merge r3744 from trunk: Correctly return errors when reading an archive using @archive extension. Obtained from: http://code.google.com/p/libarchive MFC after: 2 weeks
* Bring in the --gid --gname --uid and --uname implementationkientzle2011-10-221-0/+18
| | | | | | from libarchive.googlecode.com. MFC after: 3 days
* Update bsdtar to 2.8.4mm2011-07-171-45/+45
| | | | | | | Use common code from lib/libarchive/libarchive_fe Approved by: kientzle MFC after: 2 weeks
* The --newer-than test should descend into oldkientzle2011-06-261-4/+12
| | | | | | | | directories to look for new files. PR: bin/150890 Submitted by: Tobias Herre MFC after: 3 weeks
* If there is a read error reading Y/N confirmation from the keyboard,kientzle2011-06-251-0/+7
| | | | | | | | | 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
* If the compressed data is larger than the uncompressed,kientzle2010-06-141-1/+7
| | | | | | | | | | report the compression ratio as 0% instead of displaying nonsense triggered by numeric overflow. This is common when dealing with uncompressed files when the I/O blocking causes there to be small transient differences in the accounting. Thanks to: Boris Samorodov
* Consistently specify O_BINARY when opening files.kientzle2010-04-111-5/+9
|
* Merge a bunch of refactoring from Joerg Sonnenberger tokientzle2010-02-071-23/+26
| | | | | | 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.
* Style & Portability: Use archive_entry methods to examinekientzle2010-02-071-8/+5
| | | | | file information, change some functions to static, remove some unused headers.
* Various portability workarounds for non-FreeBSD platforms.kientzle2010-02-071-6/+45
|
* Restructure the logic that determines when we're crossing a mountkientzle2010-02-071-8/+29
| | | | | point. In particular, this carves out a place for detecting and excluding synthetic or network filesystems.
* Trim out some unused configuration variables, removekientzle2010-02-071-3/+0
| | | | some unused headers, etc.
* Fill in some missing error handling, be a little more careful aboutkientzle2010-02-061-16/+17
| | | | error reporting, prefer int64_t to off_t.
* bsdtar doesn't actually know what compression is supported by libarchivekientzle2010-02-061-12/+11
| | | | | and it should not pretend that it does. It should just pass along the user's request and handle an error if it's not supported.
* Refactor the siginfo/sigusr1 handling. The read/write reportingkientzle2010-02-061-24/+37
| | | | | | | | | 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-41/+42
| | | | | program name into a global, which eliminates an extra argument from a lot of places.
* Merge remaining changes from libarchive.googlecode.com:kientzle2009-04-171-23/+20
| | | | | | | | * Add xz and lzma compression options * Rename --format-options to simply --options * Add --same-owner for GNU tar compat * Add -lmd and -lcrypto to fix link * Documentation
* Merge r492 from libarchive.googlecode.com: First cut at exposing thekientzle2009-03-081-0/+17
| | | | new options mechanism to userland. Documentation pending...
* Merger r629-631,633-646,648,654,678,681,682 from libarchive.googlecode.com:kientzle2009-03-081-0/+5
| | | | | Many changes for Windows compatibility. bsdtar_test now runs successfully on both POSIX platforms and Windows.
* Merge r529 from libarchive.googlecode.com: Fix how we read ext2fs_fs.hkientzle2009-03-081-4/+11
| | | | headers on Linux.
* Merge r283,r423 from libarchive.googlecode.com: Use libarchive's newkientzle2009-03-081-528/+124
| | | | | | archive_read_disk API to pull metadata off of disk. This removes a lot of platform-specific knowledge of things like ACLs, file flags, and extended attributes from bsdtar.
* When copying file data to the archive, don't write morekientzle2009-02-081-1/+1
| | | | | | | | | than was read. This seems to have only affected the shar writer, since other formats proactively truncate output to the originally-advertised size. PR: bin/131244 MFC after: 7 days
* After visiting a subdirectory, we use chdir("..") orkientzle2008-11-271-1/+6
| | | | | | | | | | fchdir() to return back to the parent. If those fail, we're just dead in the water. Add a new error value TREE_ERROR_FATAL to indicate that directory traversal cannot continue. Have write.c honor that by exiting immediately. MFC after: 30 days
* If we're unable to chdir() to a directory that we know exists,kientzle2008-11-271-1/+3
| | | | | | | | | | that should result in a non-zero return value. In particular, this should address the issue that David Wolfskill ran into with a somewhat flaky NFS mount resulting in a damaged archive even though tar returned success. MFC after: 4 days
* Clean up flags support just a tad: FreeBSD support depends onkientzle2008-09-141-28/+29
| | | | | | | HAVE_STRUCT_STAT_ST_FLAGS, Linux support depends on the existence of the appropriate ioctl() options. In particular, this should fix some nagging compile errors on Linux platforms that don't have e2fsprogs-devel installed.
* Move duplicated code from tar_mode_[cru] into archive_write.cperciva2008-07-051-32/+15
| | | | | Fix a bug I introduced 7 minutes ago: clean up properly from archive_write if we exit the argv-handling loop due to -C not having an argument.
* Use malloc in write_archive to allocate a 64kB buffer for holding file datacperciva2008-07-051-12/+20
| | | | instead of using 64kB of stack space in copy_file_data and write_file_data.
* Clean up write_entry by eliminating fd except in the #ifdef __linux blockcperciva2008-07-051-13/+14
| | | | | | | | | where it is used. [1] Don't leak file descriptors in write_entry_backend if archive_write_header returns ARCHIVE_FAILED. Found by: Coverity Prevent [1]
* Revert CVS revision 1.68; it is now possible for entry to be NULL at the endcperciva2008-07-051-1/+2
| | | | | of write_entry. (This was perfectly safe, since archive_entry_free(NULL) is a no-op, but adding the check back makes the style more consistent.)
* Stop using the deprecated linux/ext2_fs.h.kientzle2008-07-051-3/+0
|
* Pass the entry down into the core write loop, so wekientzle2008-06-251-4/+6
| | | | | | can include the filename when reporting errors. Thanks to: Dan Nelson
* MFp4: bsdtar 2.5.4bkientzle2008-05-261-222/+87
| | | | | | | | | | | | | 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.
* The value le->name cannot be NULL when we're freeing an entry in thecperciva2008-05-231-2/+1
| | | | | | | | | | | | | hardlink table for two reasons: 1. If le->name is set to NULL, the structure le won't be inserted into the table; 2. Even if le somehow did manage to get into the table with le->name equal to NULL, we would die when we dereferenced le->null before we could get to the point of freeing the entry. Remove the unnecessary "if (le->name != NULL)" test and just free the pointer. Found by: Coverity Prevent
* There's no way for entry to possibly be NULL at the end of write_entrycperciva2008-05-191-2/+1
| | | | | | | | (in fact, there has never been any way for it to be NULL, going all the way back to revision 1.1 of this file), so remove the check and unconditionally free entry. Found by: Coverity Prevent
* Add SIGINFO (and for portability to SIGINFO-lacking systems, SIGUSR1)cperciva2008-05-181-0/+25
| | | | | | | | | | | handling to bsdtar. When writing archives (including copying via the @archive directive) a line is output to stderr indicating what is being done (adding or copying), the path, and how far through the file we are; extracting currently does not report progress within each file, but this is likely to happen eventually. Discussed with: kientzle Obtained from: tarsnap
* Allow -r with -T even if there are no files on the command line.kientzle2008-05-021-1/+1
| | | | | PR: bin/123246 MFC after: 3 days
* Enable and document the -Z option for selecting "compress" compression,kientzle2008-03-151-0/+3
| | | | now that libarchive supports it.
* Allow appending to archives on block devices as well askientzle2008-02-191-1/+1
| | | | | | archives in regular files, since both are seekable. Thanks to: Reinoud Zandijk (@netbsd.org)
* bsdtar 2.2.3:kientzle2007-05-291-13/+18
| | | | | | | | | * Implement --use-compress-program using new libarchive feature. * Minor portability improvement by adjusting casts used to print out uids, gids, and device numbers. Thanks to: Joerg Sonnenberger for the --use-compress-program implementation. MFC after: 15 days
* If lstat(2) fails, have bsdtar return a non-zero exit code if thecperciva2007-05-031-0/+10
| | | | | | | | | | | | | failed path is one which was specified on the command line. This is a compromise between the situation prior to revision 1.57 (where a race between tar(1) and rm(1) could cause tar(1) to spuriously report an error) and the situation after revision 1.57 (where "tar -c /no/such/path" prints a warning but returns with an exit code of zero). Inspired by: rafan MFC after: 1 week
* Clean up error handling in archive_append to match how errors arecperciva2007-04-091-19/+39
| | | | | | handled in write_hierarchy. Approved by: kientzle
* Split the append_archive function (used for processing @<archive> directives)cperciva2007-03-311-13/+28
| | | | | | | | | | | | into separate append_archive and append_archive_filename functions; the first takes a "struct archive *" as input, while the second takes a filename, opens the archive, and calls the first. There should be no changes in behaviour as a result of this commit; it simply reorganizes code to make more sense. At some point in the future it may be possible to share code between append_archive and read_archive, but not yet. Discussed with: kientzle
* Remove pathlen argument from write_entry function. It has never been used.cperciva2007-03-171-5/+2
| | | | | Approved by: kientzle MFC after: 3 days
* Fix logic bug; we want to do_chdir if arg doesn't start with / _and_ itcperciva2007-03-171-1/+1
| | | | | | | | doesn't start with @/ either. This unbreaks "tar -c -C /no/such/directory @/path/to/archive". MFC after: 3 days
* Don't consider an lstat(2) failure to be an error (in the sense ofcperciva2007-03-151-1/+0
| | | | | | | | | | | | affecting the return value from bsdtar), since (a) it usually occurs due to a perfectly innocent (and unavoidable) race condition where a user deletes a file in the window between bsdtar reading a directory and attempting to read the file; and (b) aside from printing a warning message, bsdtar behaves exactly as if the file had been deleted prior to bsdtar reading its parent directory. Reviewed by: kientzle MFC after: 6 days
* Reduce the risk of inducing heart attacks, by printing the right path whencperciva2007-03-141-1/+1
| | | | | | | | complaining about lstat(2) failing. It's a bit scary to find the message tar: /: Cannot stat: No such file or directory printed while doing a backup. MFC after: 1 week
* bsdtar 2.0.23:kientzle2007-03-111-10/+37
| | | | | | | | | | * 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.
* Andrew and Colin each pointed out to me that truncating the backupkientzle2007-02-181-2/+0
| | | | | | | | of a growing file should not be considered a "bad thing." PR: bin/108990 MFC after: 7 days Pointy hat: /me
* Correctly handle writes beyond the end of the archive entrykientzle2007-02-141-1/+9
| | | | | | | (as determined by the initial size given to the header). Libarchive recently changed to correctly return the amount of data actually consumed in this case, which revealed this bug in bsdtar.
OpenPOWER on IntegriCloud