[libbluray-devel] Implement reading files with unallocated / unwritten blocks
Petri Hintukainen
git at videolan.org
Tue Jun 21 22:34:56 CEST 2016
libudfread | branch: master | Petri Hintukainen <phintuka at gmail.com> | Tue Jun 21 22:59:01 2016 +0300| [a209bb593f9ac9a4a1d7e81c71ce104d198db182] | committer: Petri Hintukainen
Implement reading files with unallocated / unwritten blocks
> http://git.videolan.org/gitweb.cgi/libudfread.git/?a=commit;h=a209bb593f9ac9a4a1d7e81c71ce104d198db182
---
src/udfread.c | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/src/udfread.c b/src/udfread.c
index 73947d7..df0111d 100644
--- a/src/udfread.c
+++ b/src/udfread.c
@@ -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++) {
uint32_t lba = _file_lba(p, file_block + i);
uint8_t *block = (uint8_t *)buf + UDF_BLOCK_SIZE * i;
+
udf_trace("map block %u to lba %u\n", file_block + i, 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;
}
+
if (_read_blocks(p->udf->input, lba, block, 1, flags) != 1) {
break;
}
More information about the libbluray-devel
mailing list