preserve errno to prevent an bug if an intermediate system call gets added
add test case for ro intermediate dir