Skip to content

Commit

Permalink
mtree: prepend "./" to all entries other than "."
Browse files Browse the repository at this point in the history
casync attempts to output all entries as a Full entry but for top-level
entries, 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 (and the one that "nmtree -C" does) is to prefix
every path with "./". However, nmtree does not like "./." (internally it
requires every entry referenced in an Full entry's path to already have
been referenced in the spec) and so we have to special-case the "."
path.

[1]: https://man.netbsd.org/mtree.5

Ref: vbatts/go-mtree#146
Signed-off-by: Aleksa Sarai <[email protected]>
  • Loading branch information
cyphar committed Jun 5, 2023
1 parent 0efa7ab commit 9a71693
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/casync-tool.c
Original file line number Diff line number Diff line change
Expand Up @@ -1846,6 +1846,13 @@ static int list_one_file(const char *arg0, CaSync *s, bool *toplevel_shown) {
(void) ca_sync_current_chattr(s, &flags);
(void) ca_sync_current_fat_attrs(s, &fat_attrs);

/*
* Prepend "./" to every entry other than "." to force them to
* be treated as a Full path. This matches the output of
* "nmtree -C".
*/
if (!isempty(escaped))
fputs("./", stdout);
fputs(empty_to_dot(escaped), stdout);

if (S_ISLNK(mode))
Expand Down

0 comments on commit 9a71693

Please sign in to comment.