Skip to content

Commit

Permalink
mtree: append "/" to all directory entries
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
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: vbatts/go-mtree#146
Signed-off-by: Aleksa Sarai <[email protected]>
  • Loading branch information
cyphar committed Jun 4, 2023
1 parent 0efa7ab commit 44f2234
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/casync-tool.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 44f2234

Please sign in to comment.