|
18 | 18 |
|
19 | 19 | from __future__ import absolute_import
|
20 | 20 |
|
| 21 | +import logging |
21 | 22 | import random
|
22 | 23 | import struct
|
23 | 24 | import sys
|
|
92 | 93 | have_py_3 = False
|
93 | 94 |
|
94 | 95 |
|
| 96 | +_logger = logging.getLogger('pycdlib') |
| 97 | + |
| 98 | + |
95 | 99 | def crc_ccitt(data):
|
96 | 100 | # type: (bytes) -> int
|
97 | 101 | """
|
@@ -5822,6 +5826,44 @@ def parse_logical_volume_integrity(integrity_data, current_extent, logical_block
|
5822 | 5826 | return logical_volume_integrity, logical_volume_integrity_terminator
|
5823 | 5827 |
|
5824 | 5828 |
|
| 5829 | +def parse_file_set(file_set_and_term_data, current_extent, logical_block_size): |
| 5830 | + # type: (bytes, int, int) -> Tuple[UDFFileSetDescriptor, UDFTerminatingDescriptor] |
| 5831 | + """ |
| 5832 | + An internal method to parse File Set data, and the File Set Terminator. |
| 5833 | +
|
| 5834 | + Parameters: |
| 5835 | + file_set_and_term_data - The data to parse. |
| 5836 | + current_extent - The extent location of the data. |
| 5837 | + logical_block_size - The logical block size of the ISO. |
| 5838 | + Returns: |
| 5839 | + A tuple where the first item is a UDFFileSetDescriptor, and the second item |
| 5840 | + is a UDFTerminatorDescriptor. |
| 5841 | + """ |
| 5842 | + desc_tag = UDFTag() |
| 5843 | + desc_tag.parse(file_set_and_term_data[:logical_block_size], 0) |
| 5844 | + if desc_tag.tag_ident != 256: |
| 5845 | + raise pycdlibexception.PyCdlibInvalidISO('UDF File Set Tag identifier not 256') |
| 5846 | + file_set = UDFFileSetDescriptor() |
| 5847 | + file_set.parse(file_set_and_term_data[:logical_block_size], |
| 5848 | + current_extent, desc_tag) |
| 5849 | + |
| 5850 | + (tag_ident,) = struct.unpack_from('<H', file_set_and_term_data, logical_block_size) |
| 5851 | + file_set_terminator = UDFTerminatingDescriptor() |
| 5852 | + if tag_ident == 8: |
| 5853 | + desc_tag = UDFTag() |
| 5854 | + desc_tag.parse(file_set_and_term_data[logical_block_size:], 1) |
| 5855 | + file_set_terminator.parse(current_extent + 1, desc_tag) |
| 5856 | + else: |
| 5857 | + # In this case, the UDF ISO had an invalid File Set Terminator Tag. |
| 5858 | + # But this isn't fatal, so log a warning and continue on. |
| 5859 | + _logger.warning('Missing UDF File Set Terminator, continuing') |
| 5860 | + file_set_terminator.new() |
| 5861 | + file_set_terminator.orig_extent_loc = current_extent + 1 |
| 5862 | + file_set_terminator.desc_tag.tag_location = 1 |
| 5863 | + |
| 5864 | + return file_set, file_set_terminator |
| 5865 | + |
| 5866 | + |
5825 | 5867 | def parse_file_entry(icbdata, abs_file_entry_extent, icb_log_block_num, parent):
|
5826 | 5868 | # type: (bytes, int, int, Optional[UDFFileEntry]) -> Optional[UDFFileEntry]
|
5827 | 5869 | """
|
|
0 commit comments