avoid race condition in profile creation

ignores EEXIST, which can happen when two processes
are starting up at the same time on the same new profile.

Centralizes some of the mkdir code in a new method,
reducing some duplication.
Merge pull request #3220 from minrk/profile-race

avoid race condition in profile creation