|
32 | 32 |
|
33 | 33 | # For mypy annotations
|
34 | 34 | if False: # pylint: disable=using-constant-test
|
35 |
| - from typing import List, Optional, Type, Union # NOQA pylint: disable=unused-import |
| 35 | + from typing import List, Optional, Tuple, Type, Union # NOQA pylint: disable=unused-import |
36 | 36 | # NOTE: this import has to be here to avoid circular deps
|
37 | 37 | from pycdlib import inode # NOQA pylint: disable=unused-import
|
38 | 38 |
|
@@ -5786,3 +5786,37 @@ def parse_anchor(anchor_data, anchor_location):
|
5786 | 5786 | anchor = UDFAnchorVolumeStructure()
|
5787 | 5787 | anchor.parse(anchor_data, anchor_location, anchor_tag)
|
5788 | 5788 | return anchor
|
| 5789 | + |
| 5790 | + |
| 5791 | +def parse_logical_volume_integrity(integrity_data, current_extent, logical_block_size): |
| 5792 | + # type: (bytes, int, int) -> Tuple[UDFLogicalVolumeIntegrityDescriptor, Optional[UDFTerminatingDescriptor]] |
| 5793 | + """ |
| 5794 | + An internal method to parse Logical Volume Integrity data, and an optional |
| 5795 | + Logical Volume Integrity Terminator. |
| 5796 | +
|
| 5797 | + Parameters: |
| 5798 | + integrity_data - The data to parse. |
| 5799 | + current_extent - The extent location of the data. |
| 5800 | + logical_block_size - The logical block size of the ISO. |
| 5801 | + Returns: |
| 5802 | + A tuple where the first item is a UDFLogicalVolumeIntegrityDescriptor, and |
| 5803 | + the second item is a optional UDFTerminatorDescriptor. |
| 5804 | + """ |
| 5805 | + desc_tag = UDFTag() |
| 5806 | + desc_tag.parse(integrity_data, current_extent) |
| 5807 | + if desc_tag.tag_ident != 9: |
| 5808 | + raise pycdlibexception.PyCdlibInvalidISO('UDF Volume Integrity Tag identifier not 9') |
| 5809 | + logical_volume_integrity = UDFLogicalVolumeIntegrityDescriptor() |
| 5810 | + logical_volume_integrity.parse(integrity_data[:512], current_extent, desc_tag) |
| 5811 | + |
| 5812 | + logical_volume_integrity_terminator = None |
| 5813 | + offset = logical_block_size |
| 5814 | + if len(integrity_data) >= (offset + logical_block_size): |
| 5815 | + desc_tag = UDFTag() |
| 5816 | + desc_tag.parse(integrity_data[offset:], current_extent + 1) |
| 5817 | + if desc_tag.tag_ident != 8: |
| 5818 | + raise pycdlibexception.PyCdlibInvalidISO('UDF Logical Volume Integrity Terminator Tag identifier not 8') |
| 5819 | + logical_volume_integrity_terminator = UDFTerminatingDescriptor() |
| 5820 | + logical_volume_integrity_terminator.parse(current_extent + 1, desc_tag) |
| 5821 | + |
| 5822 | + return logical_volume_integrity, logical_volume_integrity_terminator |
0 commit comments