mtree: follow-up all type=dir entries with ".."
In the mtree(8) format, each directory entry is treated as a parent entry for subsequent entries (which are then considered to be lexically children of their parent when figuring out what paths to compare for manifest verification).
'casync mtree' outputs a fairly unconventional "flat" version of the mtree(8) format, and as a result didn't handle this correctly in the past. The most trivial way of handling the type=dir problem is to negate it after each entry with a ".." entry. Because this acts on the node level, having nodes with names like "a/b/c" doesn't cause an issue.
This is necessary for compatibility with go-mtree. It should be noted that this change is still not sufficient for compatibility with FreeBSD mtree(8), which does not permit "/" characters in node names. Supporting this would require us to make significant changes to how generation works (because we'd need to output a hierarchy-friendly format which would require some more housekeeping). This is a stop-gap solution to at least end up with basic compatibility.
Fixes: systemd/casync#167 vbatts/go-mtree#146 Signed-off-by: Aleksa Sarai [email protected]
I'm not sure what's with the build failure -- looks like it had trouble pulling a meson package.
/cc @vbatts
Would you prefer if we fixed this "fully" by making it so that nodes are actually constructed correctly?
I definitely thought it was funny that casync mtree choose the outdated BSD mtree flat style. Albeit it is an "easier" approach without requiring any amount of nesting. It ought to not be incompatible staying as the flat style though.
No mtree implementation I've tried supports the format that systemd spits out, so I'm firmly in the "it's not outputting valid mtrees" camp.
@poettering PTAL