Refactor recursive mkdir() into sys_mkpath()