Only create the directory if it does not already exist.
Avoid a race condition by testing errno after mkdir()

The previous code could still get an error if the directory was created
by an external process between access() and mkdir().
Fix possible buffer overflows
Use a more correct const declaration for main
Version 2.2.1