tdb2: rework some io.c functions to return enum TDB_ERROR.