Refactoring: Split off the non-recursive canonicalisePathMetaData()

Also, change the file mode before changing the owner.  This prevents a
slight time window in which a setuid binary would be setuid root.
Handle hard links to other files in the output