From c28fa0bcabf3996e0d33a69d18681eed8e6df7ff Mon Sep 17 00:00:00 2001 From: Michihiro NAKAJIMA Date: Sun, 6 Dec 2009 11:00:34 -0500 Subject: [PATCH] Do not try finding hardlinked files which are resolved. SVN-Revision: 1707 --- libarchive/archive_read_support_format_xar.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/libarchive/archive_read_support_format_xar.c b/libarchive/archive_read_support_format_xar.c index 2fb62a091..f4425fb6e 100644 --- a/libarchive/archive_read_support_format_xar.c +++ b/libarchive/archive_read_support_format_xar.c @@ -596,26 +596,31 @@ read_toc(struct archive_read *a) * Connect hardlinked files. */ for (i = 0; i < xar->file_queue.used; i++) { - struct hdlink *hdlink; + struct hdlink **hdlink; struct xar_file *file; file = xar->file_queue.files[i]; /* Check if 'file' is a target file of the hardlink. */ if (file->link != (unsigned int)-1) continue; - for (hdlink = xar->hdlink_list; hdlink != NULL; - hdlink = hdlink->next) { - if (hdlink->id == file->id) { + for (hdlink = &(xar->hdlink_list); *hdlink != NULL; + hdlink = &((*hdlink)->next)) { + if ((*hdlink)->id == file->id) { + struct hdlink *hltmp; struct xar_file *f2; - int nlink = hdlink->cnt + 1; + int nlink = (*hdlink)->cnt + 1; file->nlink = nlink; - for (f2 = hdlink->files; f2 != NULL; + for (f2 = (*hdlink)->files; f2 != NULL; f2 = f2->hdnext) { f2->nlink = nlink; archive_string_copy( &(f2->hardlink), &(file->pathname)); } + /* Remove resolved files from hdlist_list. */ + hltmp = *hdlink; + *hdlink = hltmp->next; + free(hltmp); break; } } -- 2.47.3