fix write-protect detection by attempting to write, and handling the error, instead of checking