Every caller path()s its arguments anyways, just simplify these and push
path() into moveifchanged(). This fixes a number of memory leaks since
path() allocates memory.
While we're here, make sure we close from_fd/to_fd appropriately and
have path() error out if the allocation fails.
CID: 1471040, 1471714, 1472045, 1505250, 1006907, 1006908