From 44f2234f2b01a48775cedb9e51384d18f827fef6 Mon Sep 17 00:00:00 2001 From: Aleksa Sarai Date: Sun, 4 Jun 2023 19:46:19 +1000 Subject: [PATCH] mtree: append "/" to all directory entries casync attempts to output all entries as a Full entry but for top-level directories, there is no "/" in the escaped pathname, resulting in the entry being treated as a Relative entry. As per the specification[1], this results in any subsequent Relative entries (such as top-level files) being treated as children of the directory which causes manifests produced by casync to fail. The simplest solution is to force all directories to be treated as Full entries by adding a dummy "/" to the end of the pathname. It's not necessary to do anything for top-level files because they do not affect the "current directory" during parsing. [1]: https://man.netbsd.org/mtree.5 Ref: https://github.com/vbatts/go-mtree/issues/146 Signed-off-by: Aleksa Sarai --- src/casync-tool.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/casync-tool.c b/src/casync-tool.c index ec21759..56e6a56 100644 --- a/src/casync-tool.c +++ b/src/casync-tool.c @@ -1847,6 +1847,9 @@ static int list_one_file(const char *arg0, CaSync *s, bool *toplevel_shown) { (void) ca_sync_current_fat_attrs(s, &fat_attrs); fputs(empty_to_dot(escaped), stdout); + /* append a "/" to force directory entries to be treated as a Full path */ + if (S_ISDIR(mode)) + fputc('/', stdout); if (S_ISLNK(mode)) fputs(" type=link", stdout);