* Read a block-sized buffer from the specified block of the underlying file. * * No need for an error return convention; we ereport() on any error. This * module should never attempt to read a block it doesn't know is there. */
| 286 | * module should never attempt to read a block it doesn't know is there. |
| 287 | */ |
| 288 | static void |
| 289 | ltsReadBlock(LogicalTapeSet *lts, long blocknum, void *buffer) |
| 290 | { |
| 291 | size_t nread; |
| 292 | |
| 293 | if (BufFileSeekBlock(lts->pfile, blocknum) != 0) |
| 294 | ereport(ERROR, |
| 295 | (errcode_for_file_access(), |
| 296 | errmsg("could not seek to block %ld of temporary file", |
| 297 | blocknum))); |
| 298 | nread = BufFileRead(lts->pfile, buffer, BLCKSZ); |
| 299 | if (nread != BLCKSZ) |
| 300 | ereport(ERROR, |
| 301 | (errcode_for_file_access(), |
| 302 | errmsg("could not read block %ld of temporary file: read only %zu of %zu bytes", |
| 303 | blocknum, nread, (size_t) BLCKSZ))); |
| 304 | } |
| 305 | |
| 306 | /* |
| 307 | * Read as many blocks as we can into the per-tape buffer. |
no test coverage detected