From 32675a9001011095eddf6607513fed2901f0849d Mon Sep 17 00:00:00 2001 From: Allan McRae Date: Sat, 8 Sep 2012 18:59:33 +1000 Subject: [PATCH] Fix mtree generation When generating an mtree file, libarchive writes a "Relative" type (entries that have no /) for files in the base directory. For directories, this causes the mtree reader to change the parent directory and give subsequent files in the root directory the wrong path. Fix this by prefixing entries in the root directory with "./". --- libarchive/archive_write_set_format_mtree.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/libarchive/archive_write_set_format_mtree.c b/libarchive/archive_write_set_format_mtree.c index 4b300012f..6d558a038 100644 --- a/libarchive/archive_write_set_format_mtree.c +++ b/libarchive/archive_write_set_format_mtree.c @@ -887,6 +887,9 @@ write_entry(struct archive_write *a, struct mtree_entry *me) archive_string_empty(&mtree->ebuf); str = (mtree->indent)? &mtree->ebuf : &mtree->buf; + if (strchr(me->pathname, '/') == NULL ) { + archive_strcat(str, "./"); + } mtree_quote(str, me->pathname); keys = get_keys(mtree, me); if ((keys & F_NLINK) != 0 && -- 2.47.3