linux: Refactor directory creation logic to be more readable