Minor fixes.
* 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.
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -16,6 +16,7 @@ Makefile
|
||||
Makefile.in
|
||||
aclocal.m4
|
||||
autom4te.cache
|
||||
build-aux
|
||||
build-aux/
|
||||
config.h
|
||||
config.h.in
|
||||
|
||||
@@ -505,7 +505,6 @@ char *dumpdir_locate (dumpdir_t dump, const char *name);
|
||||
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);
|
||||
@@ -513,6 +512,9 @@ void write_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);
|
||||
|
||||
@@ -399,18 +399,8 @@ rebase_directory (const char *name, size_t old_prefix_len,
|
||||
{
|
||||
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
|
||||
|
||||
14
src/names.c
14
src/names.c
@@ -912,9 +912,9 @@ collect_and_sort_names (void)
|
||||
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)
|
||||
@@ -934,15 +934,10 @@ collect_and_sort_names (void)
|
||||
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;
|
||||
@@ -980,7 +975,8 @@ collect_and_sort_names (void)
|
||||
}
|
||||
}
|
||||
name->found_count = 0;
|
||||
hash_insert (nametab, name);
|
||||
if (!hash_insert (nametab, name))
|
||||
xalloc_die ();
|
||||
prev_name = name;
|
||||
num_names++;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user