Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def record(self):
# type: () -> bytes
'''
Generate a string representing the Rock Ridge Continuation Entry record.
Parameters:
None.
Returns:
String containing the Rock Ridge record.
'''
if not self._initialized:
raise pycdlibexception.PyCdlibInternalError('CE record not initialized')
return b'CE' + struct.pack(self.FMT,
RRCERecord.length(),
SU_ENTRY_VERSION,
self.bl_cont_area,
utils.swab_32bit(self.bl_cont_area),
self.offset_cont_area,
utils.swab_32bit(self.offset_cont_area),
self.len_cont_area,
utils.swab_32bit(self.len_cont_area))
def record(self):
# type: () -> bytes
'''
A method to generate the string representing this UDF File Entry.
Parameters:
None.
Returns:
A string representing this UDF File Entry.
'''
if not self._initialized:
raise pycdlibexception.PyCdlibInternalError('UDF File Entry not initialized')
rec = struct.pack(self.FMT, b'\x00' * 16,
self.icb_tag.record(), self.uid, self.gid,
self.perms, self.file_link_count, 0, 0, 0,
self.info_len, self.log_block_recorded,
self.access_time.record(), self.mod_time.record(),
self.attr_time.record(), 1,
self.extended_attr_icb.record(),
self.impl_ident.record(), self.unique_id,
self.len_extended_attrs, len(self.alloc_descs) * 8)[16:]
rec += self.extended_attrs
for length, pos in self.alloc_descs:
rec += struct.pack('=LL', length, pos)
return self.desc_tag.record(rec) + rec
def record(self):
# type: () -> bytes
'''
Generate a string representing this Version Volume Descriptor. Note that
right now, this is always a string of zeros.
Parameters:
log_block_size - The logical block size to use when generating this string.
Returns:
A string representing this Version Volume Descriptor.
'''
if not self._initialized:
raise pycdlibexception.PyCdlibInternalError('This Version Volume Descriptor is not initialized')
return self._data
def extent_location(self):
# type: () -> int
'''
Get the location of this Directory Record on the ISO.
Parameters:
None.
Returns:
Extent location of this Directory Record on the ISO.
'''
if not self.initialized:
raise pycdlibexception.PyCdlibInternalError('Directory Record not initialized')
return self._extent_location()
def is_symlink(self):
# type: () -> bool
'''
Determine whether this Directory Record is a Rock Ridge
symlink. If using this to distinguish between symlinks, files, and
directories, it is important to call this API *first*; symlinks are
also considered files.
'''
if not self.initialized:
raise pycdlibexception.PyCdlibInternalError('Directory Record not initialized')
return self.rock_ridge is not None and self.rock_ridge.is_symlink()
rr_name - The Rock Ridge name to associate with this directory record.
rr_symlink_target - The target for the symlink, if this is a symlink
record (otherwise, None).
rr_relocated_child - True if this is a directory record for a rock
ridge relocated child.
rr_relocated - True if this is a directory record for a relocated
entry.
rr_relocated_parent - True if this is a directory record for a rock
ridge relocated parent.
file_mode - The Unix file mode for this Rock Ridge entry.
Returns:
Nothing.
'''
if self.parent is None:
raise pycdlibexception.PyCdlibInternalError('Invalid call to create new Rock Ridge on root directory')
self.rock_ridge = rockridge.RockRidge()
is_first_dir_record_of_root = self.file_ident == b'\x00' and self.parent.is_root
bytes_to_skip = 0
if self.xa_record is not None:
bytes_to_skip = XARecord.length()
self.dr_len = self.rock_ridge.new(is_first_dir_record_of_root, rr_name,
file_mode, rr_symlink_target,
rr_version, rr_relocated_child,
rr_relocated, rr_relocated_parent,
bytes_to_skip, self.dr_len)
# For files, we are done
if not self.isdir:
return
Create a new El Torito Boot Catalog.
Parameters:
br - The boot record that this El Torito Boot Catalog is associated with.
ino - The Inode to associate with the initial entry.
sector_count - The number of sectors for the initial entry.
load_seg - The load segment address of the boot image.
media_name - The name of the media type, one of 'noemul', 'floppy', or 'hdemul'.
system_type - The partition type the entry should be.
platform_id - The platform id to set in the validation entry.
bootable - Whether this entry should be bootable.
Returns:
Nothing.
'''
if self._initialized:
raise pycdlibexception.PyCdlibInternalError('El Torito Boot Catalog already initialized')
# Create the El Torito validation entry
self.validation_entry.new(platform_id)
self.initial_entry.new(sector_count, load_seg, media_name, system_type,
bootable)
self.initial_entry.set_inode(ino)
ino.linked_records.append((self.initial_entry, False))
self.br = br
self._initialized = True
def parse(self, data):
# type: (bytes) -> None
'''
Parse the passed in data into a UDF Partition Map.
Parameters:
data - The data to parse.
Returns:
Nothing.
'''
if self._initialized:
raise pycdlibexception.PyCdlibInternalError('UDF Partition Map already initialized')
(map_type, map_length, vol_seqnum,
self.part_num) = struct.unpack_from(self.FMT, data, 0)
if map_type != 1:
raise pycdlibexception.PyCdlibInvalidISO('UDF Partition Map type is not 1')
if map_length != 6:
raise pycdlibexception.PyCdlibInvalidISO('UDF Partition Map length is not 6')
if vol_seqnum != 1:
raise pycdlibexception.PyCdlibInvalidISO('UDF Partition Volume Sequence Number is not 1')
self._initialized = True
Ridge Continuation Blocks are shared across multiple Rock Ridge
Directory Records, the most logical place to track them is in the PVD.
This method is expected to be used during parse time, when an extent,
offset and length are already assigned to the entry.
Parameters:
extent - The extent that this Continuation Entry lives at.
offset - The offset within the extent that this Continuation Entry
lives at.
length - The length of this Continuation Entry.
Returns:
The object representing the block in which the Continuation Entry was
placed in.
'''
if not self._initialized:
raise pycdlibexception.PyCdlibInternalError('This Primary Volume Descriptor is not initialized')
for block in self.rr_ce_blocks:
if block.extent_location() == extent:
break
else:
# We didn't find it in the list, add it
block = rockridge.RockRidgeContinuationBlock(extent, self.log_block_size)
self.rr_ce_blocks.append(block)
block.track_entry(offset, length)
return block
def record(self):
# type: () -> bytes
'''
A method to generate the string representing this UDF Partition Map.
Parameters:
None.
Returns:
A string representing this UDF Partition Map.
'''
if not self._initialized:
raise pycdlibexception.PyCdlibInternalError('UDF Partition Map not initialized')
return struct.pack(self.FMT, 1, 6, 1, self.part_num)