X-Git-Url: https://git.brokenzipper.com/gitweb?a=blobdiff_plain;f=src%2Fincremen.c;h=69cbd59a470687af78ba9623c8e5696853b9fa90;hb=03858cf583ce299b836d8a848967ce290a6bf303;hp=4d86ed791c88d57b40e4a7fe705f4d711eb85b1a;hpb=efe26f98ec84856025f56673639d6bd520aa2e64;p=chaz%2Ftar diff --git a/src/incremen.c b/src/incremen.c index 4d86ed7..69cbd59 100644 --- a/src/incremen.c +++ b/src/incremen.c @@ -300,6 +300,24 @@ dirlist_replace_prefix (const char *pref, const char *repl) replace_prefix (&dp->name, pref, pref_len, repl, repl_len); } +void +clear_directory_table (void) +{ + struct directory *dp; + + if (directory_table) + hash_clear (directory_table); + if (directory_meta_table) + hash_clear (directory_meta_table); + for (dp = dirhead; dp; ) + { + struct directory *next = dp->next; + free_directory (dp); + dp = next; + } + dirhead = dirtail = NULL; +} + /* Create and link a new directory entry for directory NAME, having a device number DEV and an inode number INO, with NFS indicating whether it is an NFS device and FOUND indicating whether we have @@ -327,7 +345,8 @@ note_directory (char const *name, struct timespec mtime, if (! ((directory_table || (directory_table = hash_initialize (0, 0, hash_directory_canonical_name, - compare_directory_canonical_names, 0))) + compare_directory_canonical_names, + 0))) && hash_insert (directory_table, directory))) xalloc_die (); @@ -408,7 +427,7 @@ update_parent_directory (struct tar_stat_info *parent) if (directory) { struct stat st; - if (fstatat (parent->fd, ".", &st, fstatat_flags) != 0) + if (fstat (parent->fd, &st) != 0) stat_diag (directory->name); else directory->mtime = get_stat_mtime (&st); @@ -426,7 +445,6 @@ procdir (const char *name_buffer, struct tar_stat_info *st, { struct directory *directory; struct stat *stat_data = &st->stat; - dev_t device = st->parent ? st->parent->stat.st_dev : 0; bool nfs = NFS_FILE_STAT (*stat_data); if ((directory = find_directory (name_buffer)) != NULL) @@ -540,11 +558,8 @@ procdir (const char *name_buffer, struct tar_stat_info *st, } } - /* If the directory is on another device and --one-file-system was given, - omit it... */ - if (one_file_system_option && device != stat_data->st_dev - /* ... except if it was explicitely given in the command line */ - && !is_individual_file (name_buffer)) + if (one_file_system_option && st->parent + && stat_data->st_dev != st->parent->stat.st_dev) /* FIXME: WARNOPT (WARN_XDEV, (0, 0, @@ -783,8 +798,7 @@ scan_directory (struct tar_stat_info *st) namebuf_free (nbuf); - if (dirp) - free (dirp); + free (dirp); return directory; } @@ -1352,8 +1366,7 @@ read_directory_file (void) if (ferror (listed_incremental_stream)) read_error (listed_incremental_option); - if (buf) - free (buf); + free (buf); } /* Output incremental data for the directory ENTRY to the file DATA. @@ -1664,11 +1677,10 @@ try_purge_directory (char const *directory_name) { const char *entry; struct stat st; - if (p) - free (p); + free (p); p = new_name (directory_name, cur); - if (deref_stat (false, p, &st)) + if (deref_stat (p, &st) != 0) { if (errno != ENOENT) /* FIXME: Maybe keep a list of renamed dirs and check it here? */