bufopen: Factor out the pre-checking.