Commit 2e4197e6 authored by Petri Hintukainen's avatar Petri Hintukainen

Handle Volume Descriptor Pointer

parent dca42695
????-??-??: Version ?.?.?
- Fix possible memory corruption with inline files.
- Improve error resilience and stability.
- Add support for Volume Descriptor Pointer.
2017-06-07: Version 1.0.0
......@@ -106,7 +106,7 @@ void decode_primary_volume(const uint8_t *p, struct primary_volume_descriptor *p
memcpy(pvd->volume_set_identifier, p + 72, 128);
}
/* Anchor Volume Description Pointer (ECMA 167 3/10.2) */
/* Anchor Volume Descriptor Pointer (ECMA 167 3/10.2) */
void decode_avdp(const uint8_t *p, struct anchor_volume_descriptor *avdp)
{
/* Main volume descriptor sequence extent */
......@@ -116,6 +116,12 @@ void decode_avdp(const uint8_t *p, struct anchor_volume_descriptor *avdp)
_decode_extent_ad(p + 24, &avdp->rvds);
}
/* Volume Descriptor Pointer (ECMA 167 3/10.3) */
void decode_vdp(const uint8_t *p, struct volume_descriptor_pointer *vdp)
{
_decode_extent_ad(p + 20, &vdp->next_extent);
}
/* Partition Descriptor (ECMA 167 3/10.5) */
void decode_partition(const uint8_t *p, struct partition_descriptor *pd)
{
......
......@@ -87,6 +87,7 @@ enum tag_identifier {
/* ECMA 167, 3/7.2.1) */
ECMA_PrimaryVolumeDescriptor = 1,
ECMA_AnchorVolumeDescriptorPointer = 2,
ECMA_VolumeDescriptorPointer = 3,
ECMA_PartitionDescriptor = 5,
ECMA_LogicalVolumeDescriptor = 6,
ECMA_TerminatingDescriptor = 8,
......@@ -122,6 +123,14 @@ struct anchor_volume_descriptor {
void decode_avdp(const uint8_t *p, struct anchor_volume_descriptor *avdp);
/* Volume Descriptor Pointer (ECMA 167, 3/10.3) */
struct volume_descriptor_pointer {
struct extent_ad next_extent; /* Next Volume Descriptor Sequence Extent */
};
void decode_vdp(const uint8_t *p, struct volume_descriptor_pointer *vdp);
/* Partition Descriptor (ECMA 167, 3/10.5) */
struct partition_descriptor {
......
......@@ -379,15 +379,19 @@ static int _search_vds(udfread_block_input *input, int part_number,
struct volume_descriptor_set *vds)
{
struct volume_descriptor_pointer vdp;
uint8_t buf[UDF_BLOCK_SIZE];
int tag_id;
uint32_t lba;
uint32_t end_lba = loc->lba + loc->length / UDF_BLOCK_SIZE;
uint32_t end_lba;
int have_part = 0, have_lvd = 0, have_pvd = 0;
memset(vds, 0, sizeof(*vds));
next_extent:
udf_trace("reading Volume Descriptor Sequence at lba %u, len %u bytes\n", loc->lba, loc->length);
memset(vds, 0, sizeof(*vds));
end_lba = loc->lba + loc->length / UDF_BLOCK_SIZE;
/* parse Volume Descriptor Sequence */
for (lba = loc->lba; lba < end_lba; lba++) {
......@@ -396,6 +400,11 @@ static int _search_vds(udfread_block_input *input, int part_number,
switch (tag_id) {
case ECMA_VolumeDescriptorPointer:
decode_vdp(buf, &vdp);
loc = &vdp.next_extent;
goto next_extent;
case ECMA_PrimaryVolumeDescriptor:
udf_log("Primary Volume Descriptor in lba %u\n", lba);
decode_primary_volume(buf, &vds->pvd);
......
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