* 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.
Makefile.in
aclocal.m4
autom4te.cache
+build-aux
build-aux/
config.h
config.h.in
char *dumpdir_next (dumpdir_iter_t itr);
char *dumpdir_first (dumpdir_t dump, int all, dumpdir_iter_t *pitr);
-
const char *scan_directory (char *dir_name, dev_t device, bool cmdline);
const char *append_incremental_renames (const char *dump);
void read_directory_file (void);
void purge_directory (char const *directory_name);
void list_dumpdir (char *buffer, size_t size);
void update_parent_directory (const char *name);
+void rebase_directory (const char *name, size_t old_prefix_len,
+ const char *old_prefix,
+ const char *new_prefix);
size_t dumpdir_size (const char *p);
bool is_dumpdir (struct tar_stat_info *stat_info);
{
struct directory *dir = find_directory (name);
if (dir)
- {
- size_t len = strlen (dir->name);
- if (len > old_prefix_len
- && memcmp (dir->name, old_prefix, old_prefix_len) == 0)
- {
- char *newp = xmalloc (len - old_prefix_len + strlen (new_prefix));
- strcpy (newp, new_prefix);
- strcat (newp, dir->name + old_prefix_len);
- free (dir->name);
- dir->name = newp;
- }
- }
+ replace_prefix (&dir->name, old_prefix, old_prefix_len,
+ new_prefix, strlen (new_prefix));
}
/* Return a directory entry for a given combination of device and inode
read_directory_file ();
}
- for (name = namelist; name; name = next_name)
+ num_names = 0;
+ for (name = namelist; name; name = name->next, num_names++)
{
- next_name = name->next;
if (name->found_count || name->dir_contents)
continue;
if (name->matching_flags & EXCLUDE_WILDCARDS)
if (S_ISDIR (statbuf.st_mode))
{
name->found_count++;
- if (name->found_count == 1)
- add_hierarchy_to_namelist (name, statbuf.st_dev, true);
+ add_hierarchy_to_namelist (name, statbuf.st_dev, true);
}
}
- num_names = 0;
- for (name = namelist; name; name = name->next)
- num_names++;
-
namelist = merge_sort (namelist, num_names, compare_names);
num_names = 0;
}
}
name->found_count = 0;
- hash_insert (nametab, name);
+ if (!hash_insert (nametab, name))
+ xalloc_die ();
prev_name = name;
num_names++;
}