race-condition-free directory creation