Commit a209bb59 authored by Petri Hintukainen's avatar Petri Hintukainen

Implement reading files with unallocated / unwritten blocks

parent d2a977a9
...@@ -1414,10 +1414,21 @@ uint32_t udfread_read_blocks(UDFFILE *p, void *buf, uint32_t file_block, uint32_ ...@@ -1414,10 +1414,21 @@ uint32_t udfread_read_blocks(UDFFILE *p, void *buf, uint32_t file_block, uint32_
for (i = 0; i < num_blocks; i++) { for (i = 0; i < num_blocks; i++) {
uint32_t lba = _file_lba(p, file_block + i); uint32_t lba = _file_lba(p, file_block + i);
uint8_t *block = (uint8_t *)buf + UDF_BLOCK_SIZE * i; uint8_t *block = (uint8_t *)buf + UDF_BLOCK_SIZE * i;
udf_trace("map block %u to lba %u\n", file_block + i, lba); udf_trace("map block %u to lba %u\n", file_block + i, lba);
if (!lba) { if (!lba) {
/* unallocated/unwritten block or EOF */
uint32_t file_blocks = (udfread_file_size(p) + UDF_BLOCK_SIZE - 1) / UDF_BLOCK_SIZE;
if (file_block + i >= file_blocks) {
udf_trace("zero-fill unallocated / unwritten block %u\n", file_block + i);
memset(block, 0, UDF_BLOCK_SIZE);
continue;
}
udf_error("block %u outside of file (size %u blocks)\n", file_block + i, file_blocks);
break; break;
} }
if (_read_blocks(p->udf->input, lba, block, 1, flags) != 1) { if (_read_blocks(p->udf->input, lba, block, 1, flags) != 1) {
break; break;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment