Give a friendly error message if the DB directory is not writable

Previously we would say "error: setting synchronous mode: unable to
open database file" which isn't very helpful.