summaryrefslogtreecommitdiff
path: root/src/incremen.c
Commit message (Collapse)AuthorAgeFilesLines
* Update copyright yearsPaul Eggert2023-01-061-1/+1
| | | | | | | | | UPDATE_COPYRIGHT_USE_INTERVALS=1 \ gnulib/build-aux/update-copyright \ $(git ls-files | sed -e '/^gnulib$/d /^paxutils$/d /^COPYING$/d /\/fdl.texi$/d')
* Update copyright yearsSergey Poznyakoff2022-01-021-1/+1
|
* Fix null rereference if low-memoryPaul Eggert2021-09-171-5/+5
| | | | | * src/incremen.c (read_incr_db_01): Use xstrdup not strdup. Problem found by gcc -Wanalyzer-possible-null-argument.
* Update copyright yearsSergey Poznyakoff2021-01-061-1/+1
|
* Fix handling of linked rename chains in incremental backupsSergey Poznyakoff2020-02-151-39/+42
| | | | | | | | | | | | | | | | | * src/incremen.c: Change the meaning of the DIRF_RENAMED flag. Now it marks a directory which is the last one in a chain of renames. Regular renamed directories are recognized by their orig member being non-NULL. Directories marked with DIRF_RENAMED start encoding of renames. (procdir): Clear DIRF_RENAMED flag on directories which are origins for renames. (makedumpdir): Use the orig member to check if the directory is a result of a rename. (store_rename): Move the check for DIR_IS_RENAMED to the caller. Don't clear the DIRF_RENAMED, it is not needed any more. * tests/rename06.at: New test. * tests/Makefile.am: Add rename06.at * tests/testsuite.at: Likewise.
* Update copyright yearsSergey Poznyakoff2020-02-081-1/+1
|
* Version 1.31release_1_31Sergey Poznyakoff2019-01-021-2/+1
|
* Fix error handling when reading incremental snapshotsSergey Poznyakoff2018-12-211-15/+15
| | | | | | | Bug reported in http://lists.gnu.org/archive/html/bug-tar/2018-12/msg00008.html * incremen.c (read_incr_db_01): Don't try to continue after errors.
* Avoid some resource leaksPavel Raiskup2018-07-311-0/+1
| | | | | | | | | | | * src/incremen.c (store_rename): Free temp_name, leaked before for each renamed directory with --listed-incremental. * src/transform.c (add_literal_segment): Tighten arguments by const. (parse_transform_expr): Free 'str', leaked storage for each --transform option before. * src/utf8.c (utf8_convert): Deallocate buffer for failed iconv() call so callers don't have to.
* Update copyright yearsSergey Poznyakoff2017-01-021-1/+1
|
* Minor fixSergey Poznyakoff2016-05-161-1/+1
| | | | * src/names.c (new_name): rename to make_file_name. All uses changed.
* Update copyright yearsSergey Poznyakoff2016-01-201-2/+2
|
* Fix typos (preceeded etc.)Anders Jonsson2015-07-251-1/+1
| | | | Copyright-paperwork-exempt: yes
* tar: pacify GCC 5.1 -Wformat-signednessPaul Eggert2015-07-131-7/+11
| | | | | | | * lib/wordsplit.c (struct wordsplit_node.flags): Now unsigned, so that 'printf ("%x", p->flags)' doesn't provoke GCC. * src/incremen.c (read_num, dumpdir_ok): Don't printf an int with %x or %o.
* Support exclusion patterns from various VCS ignore lists.Sergey Poznyakoff2014-02-221-1/+3
| | | | | | | | | | | | | | | | | | | | | | * src/Makefile.am (tar_SOURCES): Add exclist.c * src/common.h (EXCL_DEFAULT, EXCL_RECURSIVE) (EXCL_NON_RECURSIVE): New flags. (excfile_add, info_attach_exclist) (info_cleanup_exclist,info_free_exclist) (exclude_vcs_ignores): New prototypes. * src/create.c (dump_dir0): Call info_attach_exclist. * src/exclist.c: New file. * src/incremen.c (scan_directory): Call info_attach_exclist. * src/names.c (excluded_name): Moved to exclist.c. Change signature. All uses updated. * src/tar.c: New options: --exclude-ignore, --exclude-ignore-recursive and --exclude-vcs-ignores. (tar_stat_destroy): Free exclist. * src/tar.h (tar_stat_info): New member exclude_list. * NEWS: Document new exclusion options. * doc/tar.texi: Likewise. * doc/tar.1: Likewise.
* Update copyright years.Sergey Poznyakoff2014-01-301-1/+1
|
* tar: work aruond IBM XL C bugPaul Eggert2014-01-071-8/+8
| | | | | | | | * src/incremen.c (show_snapshot_field_ranges) (write_directory_file_entry): Use simpler array size expression, one that evaluates to the same value. This works around a compiler bug with IBM XL C. Problem reported by Yannick Bergeron in <http://lists.gnu.org/archive/html/bug-tar/2014-01/msg00009.html>.
* Revamp tar_getcwd/normalize_filename stuff.Sergey Poznyakoff2013-10-011-2/+2
| | | | | | | | | | | | | | | | | | The changes are based on the discussion with Nathan. * src/common.h (normalize_filename): Take two arguments. All callers updated. (tar_getcwd): Replaced with .. (tar_getcdpath): New proto. * src/misc.c (normalize_filename): Take two arguments. (chdir_arg): Populate cwd along with creating the structure. (tar_getcwd): Removed. (tar_getcdpath): New function. * tests/incr09.at: New test case. * tests/Makefile.am: Add new tests. * tests/testsuite.at: Likewise.
* Implement the --show-snapshot-field-ranges optionNathan Stratton Treadway2013-09-151-0/+45
| | | | | | | | | * src/common.h (show_snapshot_field_ranges): New prototype. * src/incremen.c (show_snapshot_field_ranges): New function. * src/tar.c: New option --show-snapshot-field-ranges. * doc/snapshot.texi: Document the --show-snapshot-field-ranges option. * doc/tar.texi: Likewise.
* Take into account chdir_fd when extracting from incremental dumps.Sergey Poznyakoff2013-09-151-1/+1
| | | | | | | | | | | | * src/common.h (tar_savedir): New prototype. * src/misc.c (tar_savedir): New function. (remove_any_file): Use tar_savedir. * src/incremen.c (try_purge_directory): Use tar_savedir. * src/update.c (update_archive): Use tar_savedir. * tests/incr07.at: New testcase. * tests/Makefile.am (TESTSUITE_AT): Add new test. * tests/testsuite.at: Likewise. * THANKS: Updated.
* Fix interaction of various --exclude-tag options with --listed-incremental.Sergey Poznyakoff2013-03-121-73/+97
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * src/incremen.c (procdir): Set directory->tagfile in the exclusion_tag_contents case. (makedumpdir): Mark all entries as ignored if directory->tagfile is set. Free new_dump before returning. (maketagdumpdir): New function. (scan_directory): If directory->children is set to NO_CHILDREN and directory->tagfile is set, create a dumpdir consisting of the tagfile only. * tests/exclude08.at: New testcase. * tests/exclude09.at: New testcase. * tests/exclude10.at: New testcase. * tests/exclude11.at: New testcase. * tests/exclude12.at: New testcase. * tests/exclude13.at: New testcase. * tests/exclude14.at: New testcase. * tests/exclude15.at: New testcase. * tests/exclude16.at: New testcase. * tests/Makefile.am: Add new tests. * tests/testsuite.at: Include new tests. * tests/atlocal.in (mkexcltest): New function. * tests/chtype.at: Update keywords. * tests/filerem01.at: Likewise. * tests/filerem02.at: Likewise. * tests/incremental.at: Likewise. * tests/multiv04.at: Likewise.
* tar: improve quality of diagnostics with incrementalsPaul Eggert2013-01-271-93/+78
| | | | | | | | | | | Inspired by a prototype by Nathan Stratton Treadway in <http://lists.gnu.org/archive/html/bug-tar/2013-01/msg00000.html>. * src/incremen.c (read_num): Rewrite by merging read_negative_num and read_unsigned_num. Use strtosysint rather than rolling this stuff ourselves. Change return type to bool. All uses changed. (read_negative_num, read_unsigned_num): Remove. (read_num, read_timespec, read_incr_db_2): Improve quality of diagnostics, e.g., by supplying byte offset of error.
* maint: update copyrights for 2013 and as per current GNU standardsPaul Eggert2012-12-311-16/+17
|
* Handle incremental format 2 with negative numbers, too.Paul Eggert2012-12-221-32/+31
| | | | | | | * src/incremen.c (read_unsigned_num): Last arg is intmax_t *, not uintmax_t, for consistency with other readers. All callers changed. Avoid signed integer overflow. (read_num):
* Fix some problems with negative and out-of-range integers.Paul Eggert2012-12-221-75/+37
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Original problem reported for HP-UX LVM v2.2 by Michael White in <http://lists.gnu.org/archive/html/bug-tar/2012-10/msg00000.html>. This patch fixes some other gotchas that I noticed. * gnulib.modules: Add extern-inline. * src/common.h: Use _GL_INLINE_HEADER_BEGIN, _GL_INLINE_HEADER_END. (COMMON_INLINE, max, min): New macros. (represent_uintmax, valid_timespec): New inline functions. (SYSINT_BUFSIZE): New constant. (sysinttostr, strtosysint, decode_timespec): New decls. * src/create.c (start_private_header): Silently bring the time_t value into range; it is now the caller's responsibility to deal with any overflow error. Use uid 0 and gid 0 rather than the user's uid/gid, since the faked header isn't "owned" by the user and the uid/gid could in theory be out of range. Leave major and minor zeroed. (FILL): Remove. (write_gnu_long_link): Let start_private_header zero things out. * src/create.c (write_gnu_long_link, write_extended): * src/xheader.c (xheader_write_global): Use start_time, not current time; no point hammering on the clock. * src/compare.c (diff_multivol): Check that offset, size are in range. * src/incremen.c (read_incr_db_01, write_directory_file_entry): Allow negative time_t, dev_t, and ino_t. * src/list.c (max): Remove (moved to common.h). (read_header): Check that size is in range. (from_header): Return intmax_t, not uintmax_t, to allow negative. All callers changed. At compile time, check assumptions about intmax_t and uintmax_t. Use bool for booleans. Avoid overflow hassles on picky hosts. (mode_from_header): Last arg is now bool *, not unsigned *. All callers changed. (simple_print_header): Do not assume UID, GID fit in 'long'. * src/list.c (from_header): * src/xheader.c (out_of_range_header): Arg is now a plain minimum value, not minus minval converted to uintmax_t. All callers changed. * src/misc.c (COMMON_INLINE): New macro. (sysinttostr, strtosysint, decode_timespec): New functions. * src/sparse.c (oldgnu_add_sparse, oldgnu_fixup_header) (star_fixup_header): Check for offset overflow. (decode_num): Clear errno before calling strtoumax. * src/tar.c (expand_pax_option): Don't discard nanoseconds. * src/xheader.c (assign_time_option): Allow negative time_t. (decode_record): Simplify, since out-of-range string is guaranteed to produce a value exceeding len_max. (xheader_read): Last arg is off_t, not size_t. Caller should diagnose negative arg, as needed. Check that it's in range. (enum decode_time_status): Remove. (_decode_time): Remove, folding into decode_time. (decode_time): Return bool, not enum decode_time_status. Rely on decode_timespec to do most of the work. (code_signed_num): New function. (code_num): Use it. (decode_signed_num): New function. (decode_num): Use it. (gid_coder, gid_decoder, uid_coder, uid_decoder, sparse_map_decoder) (sparse_map_decoder): Code and decode negative values. (sparse_map_decoder): Improve check for out-of-range values. * tests/time01.at: New file. * tests/Makefile.am (TESTSUITE_AT): Add it. * tests/testsuite.at: Include it.
* Fix creation of incremental archives when a subdirectory becomes a mountpoint.Sergey Poznyakoff2012-11-141-11/+23
| | | | | | | | | | | | | | | When used with --listed-incrfental and --one-file-system, tar was unable to cope with directories that had once been part of the dumped system and became separate mount points afterwards. The bug has been reported and a fix proposed by Nathan Stratton Treadway. * src/incremen.c (procdir): If one_file_system_option is in effect, clear out dumpdir info from the directory. * tests/Makefile.am: Add new testcase. * tests/listed05.at: New testcase. * tests/testsuite.at (AT_PRIVILEGED_PREREQ): New macro. include listed05.at. * THANKS: Update.
* tar: quote 'like this', not `like this'Paul Eggert2012-01-181-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This fixes some test failures recently introduced by gnulib updates prompted by recent changes to the GNU coding standards, which now advise to use quotes 'like this' or "like this" rather than `like this'. * NEWS: Document this. * README, README-hacking, doc/Makefile.am, scripts/backup.in: * scripts/backup.sh.in, scripts/dump-remind.in: * src/buffer.c, src/checkpoint.c, src/create.c, src/incremen.c: * src/misc.c, src/names.c, src/sparse.c, src/transform.c: * tests/incr02.at, tests/incremental.at, tests/multiv08.at: * tests/sparse04.at, tests/star/README, tests/update01.at: Quote 'like this' in comments. * src/tar.h: Quote "like this" in comments, when quoting English phrases rather than code. * configure.ac: * scripts/xsparse.c (get_var, read_xheader, main): * src/compare.c (diff_archive): * src/extract.c (prepare_to_extract): * src/tar.c (request_stdin, tar_set_quoting_style, doc, options) (set_subcommand_option, report_textual_dates, parse_opt) (decode_options, main): * src/xheader.c (decx): Quote 'like this' in diagnostics. * doc/tar.texi (list, warnings, override) (Selecting Archive Members, quoting styles, after, hard links) (Sparse Recovery, Multi-Volume Archives, label): Adjust documentation to match new output. * tests/backup01.at, tests/incr01.at, tests/incr04.at: * tests/label04.at, tests/label05.at, tests/link03.at: * tests/listed02.at, tests/multiv03.at, tests/multiv05.at: * tests/rename01.at, tests/rename02.at, tests/rename03.at: * tests/volume.at: Adjust tests to match new quoting behavior.
* Fix operation of --verify in conjunction with --listed-incrementalSergey Poznyakoff2011-11-151-1/+20
| | | | | | | | | | * src/common.h (clear_directory_table): New proto. * src/incremen.c (clear_directory_table): New function. * src/compare.c (diff_dumpdir): Take a pointer to struct tar_stat_info as argument. Initialize its fd. (diff_archive): Update call to diff_dumpdir. (verify_volume): Call clear_directory_table.
* tar: if (p) free (p); -> free (p);Paul Eggert2011-02-161-6/+3
| | | | | | | | | | | There is no longer (since SunOS 4) any need to guard against free (NULL), so replace each "if (p) free (p);" with "free (p);". From Jim Meyering in <http://lists.gnu.org/archive/html/bug-tar/2011-01/msg00026.html>. * src/incremen.c (scan_directory, read_directory_file): As above. (try_purge_directory): Likewise. * src/list.c (read_header): Likewise. * src/misc.c (assign_string): Likewise.
* * src/names.c: tar: fix bug with --one-file-system --listed-incrementalPaul Eggert2010-11-221-6/+2
| | | | | | | | | | | | | Problem (and idea for fix) reported by Martin Weigel <http://lists.gnu.org/archive/html/bug-tar/2010-11/msg00071.html>. * src/common.h (is_individual_file): Remove decl. * src/create.c (dump_file0): Replace "is_individual_file (p)" with "top_level". * src/incremen.c (procdir): Replace "!is_individual_file (name_buffer)" with "st->parent". Fix bug with --one-file-system and --listed-incremental. * src/names.c (individual_file_table, register_individual_file): (is_individual_file): Remove. All uses removed.
* tar: --dereference consistencyPaul Eggert2010-09-231-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This closes another race condition, that occurs when overwriting a symlink with a regular file. * NEWS (--dereference consistency): New section. * doc/tar.texi (Option Summary): Describe new --deference behavior. (dereference): Likewise. Remove discussion that I didn't follow, even before --dereference was changed. * src/common.h (deref_stat, set_file_atime): Adjust signatures. * src/compare.c (diff_file, diff_multivol): Respect open_read_flags instead of rolling our own flags. This implements the new behavior for --dereference. (diff_file, diff_dumpdir): Likewise, for fstatat_flags. * src/create.c: Adjust to set_file_atime signature change. * src/extract.c (mark_after_links, file_newer_p, extract_dir): Likewise. * src/incremen.c (try_purge_directory): Likewise. * src/misc.c (maybe_backup_file): Likewise. * src/extract.c (file_newer_p): New arg STP. All callers changed. (maybe_recoverable): New arg REGULAR. All callers changed. Handle the case of overwriting a symlink with a regular file, when --overwrite is specified but --dereference is not. (open_output_file): Add O_CLOEXEC, O_NOCTTY, O_NONBLOCK for consistency with file creation. Add O_NOFOLLOW if overwriting_old_files && ! dereference_option. * src/incremen.c (update_parent_directory): Use fstat, not fstatat; there's less to go wrong. * src/misc.c (deref_stat): Remove DEREF arg. All callers changed. Instead, use fstatat_flags. (set_file_atime): Remove ATFLAG arg. All callers changed. Instead, use fstatat_flags. * src/names.c, src/update.c: Adjust to deref_stat signature change. * src/tar.c (get_date_or_file): Use stat, not deref_stat, as this is not a file to be archived. * tests/Makefile.am (TESTSUITE_AT): Add extrac13.at. * tests/extrac13.at: New file. * tests/testsuite.at: Include it.
* tar: do not crash with --listed-incrementalPaul Eggert2010-09-201-1/+2
| | | | | | | | | | Problem reported by Frantisek Hanzlik in <https://bugzilla.redhat.com/635318> via Kamil Dudka in <http://lists.gnu.org/archive/html/bug-tar/2010-09/msg00066.html>. I don't understand this code either, but Sergey can take a look at this patch, and perhaps install a better one, when he has the time. * src/incremen.c (append_incremental_renames): Don't actually append anything to DIR if DIR is null.
* tar: live within system-supplied limits on file descriptorsPaul Eggert2010-09-121-21/+20
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * NEWS: Note the change. Mention dirfd and fdopendir. * gnulib.modules: Add dirfd and fdopendir. The code was already using fdopendir; dirfd is a new need. * src/common.h (open_searchdir_flags, get_directory_entries): (subfile_open, restore_parent_fd, tar_stat_close): New decls. (check_exclusion_tags): Adjust signature to match code change. * src/create.c (IMPOSTOR_ERRNO): New constant. (check_exclusion_tags): First arg is now a struct tar_stat_info const *, not an fd. All callers changed. (dump_regular_file, dump_file0): A zero fd represents an unused slot, so play it safe if the fd member is zero here. A negative fd represents the negation of an errno value, so play it safe and do not assign -1 to fd merely because an open fails. (open_failure_recover, get_directory_entries, restore_parent_fd): (subfile_open): New functions. These help to recover from file descriptor exhaustion. (dump_dir, dump_file0): Use them. (dump_file0): Use tar_stat_close instead of rolling our own close. * src/incremen.c (scan_directory): Use get_directory_entries, subfile_open, etc., to recover from file descriptor exhaustion. * src/names.c (add_hierarchy_to_namelist): Likewise. (collect_and_sort_names): A negative fd represents the negation of an errno value, so play it safe and do not assign -1 to fd. * src/tar.c (decode_options): Set open_searchdir_flags. Add O_CLOEXEC to all the open flags. (tar_stat_close): New function, which knows how to deal with new convention for directory streams and file descriptors. Diagnose 'close' failures. (tar_stat_destroy): Use it. * src/tar.h (struct tar_stat_info): New member dirstream. fd now has the negative of an errno value, not merely -1, if the file could not be opened, so that failures to reopen directories are better-diagnosed later. * tests/Makefile.am (TESTSUITE_AT): Add extrac11.at. * tests/testsuite.at: Likewise. * tests/extrac11.at: New file.
* tar: more reliable directory traversal when creating archivesPaul Eggert2010-09-061-53/+53
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * NEWS: Document this. * gnulib.modules: Add openat, readlinkat. * src/common.h (open_read_flags, fstatat_flags): New global variables. (cachedir_file_p, dump_file, check_exclusion_tags, scan_directory): Adjust to new signatures, described below. (name_fill_directory): Remove. * src/compare.c (diff_file, diff_multivol): Use open_read_flags. * src/create.c (struct exclusion_tag): Exclusion predicates now take a file descriptor, not a file name. (add_exclusion_tag): Likewise. All uses changed. (cachedir_file_p): Likewise. (check_exclusion_tags): The directory is now a file descriptor, not a file name. All uses changed. Use openat for better traversal. (file_dumpable_p): Arg is now a struct stat, not a struct tar_stat_info. All uses changed. Check the arg's file types too. (dump_dir0, dump_dir, dump_file0, dump_file): Omit top_level and parent_device args, since st->parent tells us that now. All uses changed. (dump_dir): Likewise. Also, omit fd arg for similar reasons. Apply fdsavedir to a dup of the file descriptor, since we need a file descriptor for openat etc. as well, and fdsavedir (perhaps unwisely) consumes its file descriptor when successful. Do not consume st->fd when successful; this simplifies the caller. (create_archive): Allocate a file descriptor when retraversing a directory, during incremental dumps. (dump_file0): Use fstatat, openat, and readlinkat for better traversal. When opening a file, use the result of fstat on the file descriptor rather than the fstatat on the directory entry, to avoid some race conditions. No need to reopen the directory since we now no longer close it. Change "did we open the file?" test from 0 <= fd to 0 < fd since fd == 0 now represents uninitialized. (dump_file): Now accepts struct tar_stat_info describing parent, not parent_device. Also, accept basename and fullname of entry. All uses changed. * src/incremen.c (update_parent_directory): Accept struct tar_stat_info for parent, not name. All callers changed. Use fstatat for safer directory traversal. (procdir): Accept struct tar_stat_info, not struct stat and dev_t, for info about directory. All callers changed. (scan_directory): Accept struct tar_stat_info, not name, device, and cmdline, for info about directory. All callers changed. Do not consume the file descriptor, since caller might need it. Use fstatat and openat for safer directory traversal; also, use fstat after opening to double-check. (name_fill_directory): Remove. * src/names.c (add_hierarchy_to_namelist): Accept struct tar_stat_info instead of device and cmdline. All callers changed. When descending into a subdirectory, use openat and fstat for safer directory traversal. (collect_and_sort_names): Use open and fstat for safer directory traversal. Set up struct tar_stat_info for callee's new API. * src/tar.c (decode_options): Initialize open_read_flags and fstatat_flags. (tar_stat_destroy): Close st->fd if it is positive (not zero!). * src/tar.h (struct tar_stat_info): New members parent, fd. * src/update.c (update_archive): Adjust to dump_file's API change. * tests/filerem02.at: Ignore stderr since its contents now depend on the file system implementation.
* tar: remove unused macrosPaul Eggert2010-09-021-1/+1
| | | | | | | | * src/create.c (UINTMAX_TO_CHARS): Remove; no longer used. * src/tar.c (LOW_DENSITY_NUM, MID_DENSITY_NUM, HIGH_DENSITY_NUM): Likewise. * src/incremen.c (DIR_IS_NEW): Comment out; not used. Mark this with a FIXME, since it looks like it should be used.
* tar: don't export names that aren't used elsewherePaul Eggert2010-08-231-8/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * src/common.h (file_dumpable_p, gid_to_chars, major_to_chars): (minor_to_chars, mode_to_chars, uid_to_chars, uintmax_to_chars): (string_to_chars, dumpdir_creat0, dumpdir_create, dumpdir_free): (dumpdir_locate, dumpdir_next, dumpdir_first, gid_from_header): (major_from_header, minor_from_header, mode_from_header): (time_from_header, uid_from_header, quote_copy_string, request_stdin): (xheader_init, transform_header_name): Remove declarations; these are no longer exported from their modules. (GID_TO_CHARS, MAJOR_TO_CHARS, MINOR_TO_CHARS, MODE_TO_CHARS): (UID_TO_CHARS, UINTMAX_TO_CHARS, UNAME_TO_CHARS, GNAME_TO_CHARS): Move to src/create.c, since no other module uses these. (GID_FROM_HEADER, MAJOR_FROM_HEADER, MINOR_FROM_HEADER): (MODE_FROM_HEADER, TIME_FROM_HEADER, UID_FROM_HEADER): Move to src/extract.c, since no other module uses these. (dumpdir_t, dumpdir_iter_t): Remove; no longer used. * src/create.c (gid_to_chars, major_to_chars, minor_to_chars): (mode_to_chars, uid_to_chars, uintmax_to_chars, string_to_chars): (file_dumpable_p): Now static. * src/incremen.c (dumpdir_create0, dumpdir_create, dumpdir_free): (dumpdir_locate, dumpdir_next, dumpdir_first): Now static. (scan_directory, write_directory_file_entry): Use struct dumpdir_iter * rather than dumpdir_iter_t. * src/list.c (gid_from_header, major_from_header, minor_from_header): (mode_from_header, time_from_header, uid_from_header): (transform_member_name): Now static. * src/misc.c (quote_copy_string): #if 0 out, as it's not used anywhere. * src/system.c (wait_for_grandchild): Now static. * src/tar.c (request_stdin): Now static. * src/xheader.c (xheader_init): Now static.
* Keep a detailed map of archive members stored in the record buffer.Sergey Poznyakoff2010-07-111-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | A separate map (bufmap) provides information for creating multi-volume continuation headers. * src/buffer.c (bufmap): New struct. (bufmap_head, bufmap_tail, inhibit_map): New variables. (mv_begin_write): New function. (mv_begin): Rename to mv_begin_read. Rewrite using mv_begin_write. All callers changed. (mv_total_size): Remove. (bufmap_locate, bufmap_free, bufmap_reset): New functions. (_flush_write): Update bufmap. (close_archive): Free bufmap. (add_chunk_header): Take a bufmap argument. (gnu_add_multi_volume_header): Likewise. (add_multi_volume_header): Likewise. (_gnu_flush_write): Rewrite using bufmap. (real_s_name, real_s_totsize) (real_s_sizeleft) (save_name, save_totsize, save_sizeleft): Removed. All uses updated. (mv_size_left): Update bufmap_head. (mv_end): Rewrite. (multi_volume_sync): Remove. * src/common.h (mv_begin_write): New prototype. (mv_begin): Rename to mv_begin_read. * src/create.c: Use mv_begin_write instead of mv_begin. Remove calls to mv_size_left and mv_end. * src/sparse.c: Likewise. * tests/multiv07.at: Close stdin. * tests/spmvp00.at: Update AT_KEYWORDS. * tests/spmvp10.at: Likewise. * tests/multiv08.at: New testcase. * tests/Makefile.am, tests/testsuite.at: Add multiv08.at.
* Remove some lint, found by gcc -W etc.Paul Eggert2010-06-161-25/+25
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * src/common.h (label_notfound): New decl. * src/buffer.c (set_volume_start_time, compress_type): (guess_seekable_archive, open_compressed_archive, init_buffer): (_flush_write, archive_is-dev, increase_volume_number): (change_tape_menu, try_new_volume, add_chunk_header): (multi_volume_sync): Declare as 'static' if it's not exported. Use function prototype (void) rather than old-style (). * src/checkpoint.c (expand_checkpoint_string): Likewise. * src/incremen.c (dirlist_replace_prefix, makedumpdir, read_incr_db_2): Likewise. * src/list.c (print_volume_label): Likewise. * src/misc.c (normalize_filename_x): Likewise. * src/names.c (make_name, free_name, check_name_alloc, name_next_elt): Likewise. * src/tar.c (tar_list_quoting_style, add_exclude_array): (set_stat_signal): Likewise. * src/transform.c (new_transform, _single_transform_name_to_obstack): (_transform_name_to_obstack): Likewise. * src/unlink.c (dunlink_alloc): Likewise. * src/buffer.c (struct zip_magic): Use const when appropriate. * src/incremen.c (obstack_code_rename, write_directory_file_entry): Likewise. * src/sparse.c (COPY_STRING): Likewise. * src/system.c (dec_to_env, time_to_env, oct_to_env, str_to_env): (chr_to_env): Likewise. * src/tar.c (tar_list_quoting_style, set_stat_signal): Likewise. * src/extract.c (extract_node): Don't return garbage. * src/names.c: Remove old-style declarations of getgrnam etc. All modern systems declare these, and it's not worth the hassle of ignoring the warnings on modern systems for old-style decls.
* Bugfix.Sergey Poznyakoff2010-05-171-1/+1
| | | | | * src/incremen.c (make_directory): Retain the slash if it is the only character in a filename.
* Fix large file support.Eric Blake2010-03-021-1/+1
| | | | | * scripts/xsparse.c (read_map): Use fseeko. * src/incremen.c (write_directory_file): Likewise.
* Minor fix.Sergey Poznyakoff2010-01-241-4/+4
| | | | | | * src/incremen.c (read_incr_db_01) (read_directory_file): Initialize bufsize to 0. Suggested by noordsij@cs.helsinki.fi.
* Rewrite update algorithm.Sergey Poznyakoff2009-10-141-33/+18
| | | | | | | | | | | | | | | | | | | | | | | | | | * src/common.h (namebuf_t): New typedef. (namebuf_create, namebuf_free) (namebuf_name): New prototypes. (remname): New prototype. * src/misc.c (struct namebuf): New structure. (namebuf_create, namebuf_free) (namebuf_name): New functions. * src/create.c (dup_dir0): Remove is_avoided_name checks. This is taken care of in update_archive. * src/incremen.c (scan_directory): Use namebuf to produce full file names. * src/names.c (nametail): Remove extra level of indirection. All uses updated. (avoided_name_table, add_avoided_name) (is_avoided_name): Remove. * src/update.c (update_archive): Change algorithm. Instead of adding unmodified files to the avoided_name table, create namelist so that it contains only modified files. * tests/Makefile.am: Add update01.at, update02.at * tests/testsuite.at: Likewise. * tests/update.at (AT_KEYWORDS): Add update00.
* Avoid overwriting exit_status with a value indicating less important condition.Sergey Poznyakoff2009-09-081-5/+2
| | | | | | | | | | | | | | * src/tar.c (set_exit_status): New function. * src/common.h (set_exit_status): New prototype. * src/compare.c: Use set_exit_status instead of exit_status assignments. * src/create.c: Likewise. * src/misc.c: Likewise. * src/system.c (wait_for_grandchild): Use auto variable instead of the global exit_status. * src/incremen.c (scan_directory): Use file_removed_diag instead of stat_diag.
* Fix interaction between --listed-incremental and -CSergey Poznyakoff2009-08-131-0/+7
| | | | | | | | * src/incremen.c (read_directory_file): Execute eventual -C dir after opening the snapshot file. (collect_and_sort_names): Remove call to chdir_do * tests/incr05.at, tests/incr06.at: Use relative file names for snapshot files.
* Fix handling of files removed during incremental dumps.Sergey Poznyakoff2009-08-081-2/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Changes to src/create.c and src/incremen.c are partially based on patch from Alexander Peslyak <solar at openwall.com>. The new testcases require paxutils commit f653a2b or later. * src/common.h (struct name): New member `cmdline'. (dump_file): Change type of the 2nd argument to bool. (file_removed_diag, dir_removed_diag): New prototypes. (addname): New argument `cmdline'. (name_from_list): Change return value. * src/create.c (dump_dir0, dump_dir): top_level is bool. (create_archive): Update calls to name_from_list. Take advantage of the name->cmdline to set top_level argument during incremental backups. (dump_file0): top_level is bool. Do not bail out if a no-top-level file disappears during incremental backup, use file_removed_diag instead. (dump_filed): top_level is bool. * src/incremen.c (update_parent_directory): Silently ignore ENOENT. It should have already been reported elsewhere. (scan_directory): Use dir_removed_diag to report missing directories. * src/misc.c (file_removed_diag, dir_removed_diag): New functions. * src/names.c (name_gather): Set ->cmdname. (addname): Likewise. All uses updated. (name_from_list): Return struct name const *. All uses updated. * tests/filerem01.at: New testcase. * tests/filerem02.at: New testcase. * tests/Makefile.am, tests/testsuite.at: Add filerem01.at, filerem02.at * tests/grow.at, test/truncate.at: Use new syntax for genfile --run. * NEWS: Update. * doc/tar.texi: Minor fix.
* Optimize searches for directory structures by keeping a pointer to struct ↵Sergey Poznyakoff2009-08-081-41/+40
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | directory in struct name. * src/common.h (struct name): New member `directory' replaces dir_contents. Rearrange members. (rebase_directory): Change signature. (scan_directory): Change signature. (name_fill_directory) (directory_contents, safe_directory_contents): New prototypes. (append_incremental_renames): Change signature. (replace_prefix): New proto. * src/compare.c (diff_dumpdir): Use directory_contents + scan_directory. * src/create.c * src/incremen.c (replace_prefix): Move to misc.c (rebase_directory): Rewrite. (scan_directory): Return pointer to struct directory. (directory_contents, safe_directory_contents): New functions. (get_directory_contents): Remove. (name_fill_directory): New function. (append_incremental_renames): Rewrite. This also fixes a memory leak. * src/names.c (name_gather, addname): Reflect changes in struct name. (add_hierarchy_to_namelist): Rewrite using name_fill_directory and directory_contents. (rebase_child_list): Update call to rebase_directory. (collect_and_sort_names): Optimize * src/misc.c (replace_prefix): New function. * src/names.c (add_hierarchy_to_namelist): Use new get_directory_contents. * tests/incr05.at: New test case. * tests/incr06.at: New test case. * tests/Makefile.am, test/testsuite.at: Add incr05.at and incr06.at. * doc/Makefile.am (check-options): Improve rule. * doc/tar.texi, NEWS: Update.
* Minor fixes.Sergey Poznyakoff2009-08-071-12/+2
| | | | | | | * src/common.h (rebase_directory): New prototype. * src/incremen.c (rebase_directory): Use replace_prefix. * src/names.c (collect_and_sort_names): Abort if hash_insert fails.
* Improve listed incremental dumps.Sergey Poznyakoff2009-08-071-52/+122
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The modified algorithm tries to avoid dumping the same directory twice and ensures the order of the directories in the resulting archive is the same, whatever their order on the command line. It also fixes the operation of --listed-incremental -C. * gnulib.modules: Add canonicalize * src/common.h (incremental_level): New global. (check_exclusion_tags): first argument is const. (get_directory_contents): Add third argument. (zap_slashes, normalize_filename): New prototypes. (chdir_count): New prototype. (WARN_VERBOSE_WARNINGS): New define. (WARN_ALL): Exclude WARN_VERBOSE_WARNINGS. * src/compare.c (diff_dumpdir): Update the call to get_directory_contents. * src/create.c (check_exclusion_tags): First argument is const. Use ISSLASH and DIRECTORY_SEPARATOR instead of referring to '/'. * src/incremen.c (struct directory): New member `caname'. (hash_directory_name): Rename to hash_directory_canonical_name. Operate on the canonical name. (compare_directory_names): Rename to compare_directory_canonical_names. Operate on the canonical name. (make_directory): Take two arguments. (free_directory): Free caname. (attach_directory): Create caname. (find_directory): Use caname for lookups. (PD_VERBOSE): Remove. (PD_FORCE_INIT): New define. (procdir): First argument is const. Reinitialize directory if PD_FORCE_INIT bit is set. Do not use PD_VERBOSE or verbose_option for issuing warnings. Rely on WARNOPT instead. Always set *entry. (scan_directory): Take three arguments. The third one is a boolean which is true if the directory is explicitly mentioned on the command line. (get_directory_contents): Remove. Use scan_directory instead. All callers updated. (read_directory_file): Truncate the file if --level=0 is given. * src/misc.c: Include canonicalize.h (zap_slashes, normalize_filename): New functions. (chdir_count): New function. * src/names.c (add_hierarchy_to_namelist): Take three arguments, as get_directory_contents and scan_directory. (collect_and_sort_names): Allow at most one -C, before file name arguments. Read directory file after eventual changing to another directory. Avoid adding the same directory under different pathnames to the list. * src/tar.c: New option --level. * tests/incr03.at, tests/incr04.at, tests/listed01.at, tests/listed02.at, tests/rename01.at, tests/rename02.at, tests/rename03.at: Update for new tar behavior. * tests/multiv01.at: Do not use --listed-incremental.
* Implement the --warning option.Sergey Poznyakoff2009-08-051-11/+17
| | | | | | | | | | | | | | | | | * src/warning.c: New file. * src/Makefile.am: Add warning.c * src/common.h: Provide definitions for warning classes. (warning_option): New global. (WARNOPT): New define. (set_warning_option): New prototype. * src/tar.c: New option `--warning'. * src/compare.c: When applicable WARNOPT instead of WARN. * src/create.c: Likewise. * src/extract.c: Likewise. * src/incremen.c: Likewise. * src/list.c: Likewise. * NEWS, doc/tar.texi: Update.
* Version 1.22Sergey Poznyakoff2009-03-051-43/+53
|