rawdisk.scheme package¶
Submodules¶
rawdisk.scheme.headers module¶
-
class
rawdisk.scheme.headers.GPT_HEADER[source]¶ Bases:
_ctypes.StructureRepresents GUID partition table header (LBA1).
-
signature¶ str – “EFI PART”, 45h 46h 49h 20h 50h 41h 52h 54h
-
revision¶ uint – GPT Revision
-
header_size¶ uint – Total length of gpt header
-
crc32¶ uint – CRC32 of the header
-
current_lba¶ ulonglong – LBA location of this header
-
backup_lba¶ ulonglong – LBA loction of header’s copy
-
first_usable_lba¶ ulonglong – First usable LBA for partitions
-
last_usable_lba¶ ulonglong – Last usable LBA for partitions
-
disk_guid¶ char[16] – Disk GUID (UUID for Unixes)
-
part_lba¶ ulonglong – Starting LBA of array of partition entries
-
num_partitions¶ uint – Number of partition entries in array
-
part_size¶ uint – Size of a single partition entry (usually 128)
-
part_array_crc32¶ uint – CRC32 of partition array
Raises: Exception– If signature does not match valid GPT signature-
backup_lba Structure/Union member
-
crc32 Structure/Union member
-
current_lba Structure/Union member
-
disk_guid Structure/Union member
-
first_usable_lba Structure/Union member
-
header_size Structure/Union member
-
last_usable_lba Structure/Union member
-
num_partitions Structure/Union member
-
part_array_crc32 Structure/Union member
-
part_lba Structure/Union member
-
part_size Structure/Union member
-
reserved_0¶ Structure/Union member
-
revision Structure/Union member
-
signature Structure/Union member
-
-
class
rawdisk.scheme.headers.GPT_PARTITION_ENTRY[source]¶ Bases:
_ctypes.StructureRepresents GPT partition entry.
-
type_guid¶ uuid – Partition type GUID
-
part_guid¶ uuid – Unique partition GUID
-
first_lba¶ ulonglong – First LBA of partition
-
last_lba¶ ulonglong – Last LBA of partition
-
attr_flags¶ ulonglong – Attribute flags (e.g. bit 60 denotes read-only)
-
name¶ str – Partition name (36 UTF-16LE code units)
-
attr_flags Structure/Union member
-
first_lba Structure/Union member
-
last_lba Structure/Union member
-
name Structure/Union member
-
part_guid Structure/Union member
-
type_guid Structure/Union member
-
-
class
rawdisk.scheme.headers.MBR_PARTITION_ENTRY[source]¶ Bases:
_ctypes.StructureRepresents MBR partition entry
-
boot_indicator¶ ubyte – Boot indicator bit flag: 0 = no, 0x80 = bootable (or “active”)
-
starting_head¶ ubyte – Starting head for the partition
-
starting_sector¶ 6 bits – Starting sector for the partition
-
starting_cylinder¶ 10 bits – Starting cylinder for the partition
-
part_type¶ ubyte – Partition type id
-
ending_head¶ ubyte – Ending head of the partition
-
ending_sector¶ 6 bits – Ending sector
-
ending_cylinder¶ 10 bits – Ending cylinder
-
relative_sector¶ uint – The offset from the beginning of the disk to the beginning of the volume, counting by sectors.
-
total_sectors¶ uint – The total number of sectors in the volume.
-
part_offset¶ uint – The offset from the beginning of the disk to the beginning of the volume, counting by bytes.
See also
MBR Partition Types (http://en.wikipedia.org/wiki/Partition_type#List_of_partition_IDs)-
boot_indicator Structure/Union member
-
ending_cylinder Structure/Union member
-
ending_head Structure/Union member
-
ending_sector Structure/Union member
-
part_type Structure/Union member
-
relative_sector Structure/Union member
-
starting_cylinder Structure/Union member
-
starting_head Structure/Union member
-
starting_sector Structure/Union member
-
total_sectors Structure/Union member
-
rawdisk.scheme.common module¶
This module is used for partitioning scheme detection (GPT or MBR)
-
rawdisk.scheme.common.SCHEME_UNKNOWN¶ int – When scheme is neither GPT or MBR
-
rawdisk.scheme.common.SCHEME_GPT¶ int – GPT Scheme was identified
-
rawdisk.scheme.common.SCHEME_MBR¶ int – MBR Scheme was indentified
-
class
rawdisk.scheme.common.PartitionScheme[source]¶ Bases:
enum.EnumAn enumeration.
-
SCHEME_GPT= 4¶
-
SCHEME_MBR= 2¶
-
SCHEME_UNKNOWN= 1¶
-
-
rawdisk.scheme.common.detect_scheme(filename)[source]¶ Detects partitioning scheme of the source
Parameters: filename (str) – path to file or device for detection of partitioning scheme. Returns: SCHEME_MBR, SCHEME_GPT or SCHEME_UNKNOWN Raises: IOError– The file doesn’t exist or cannot be opened for reading>>> from rawdisk.scheme.common import * >>> scheme = detect_scheme('/dev/disk1') >>> if scheme == PartitionScheme.SCHEME_MBR: >>> <...>
rawdisk.scheme.gpt module¶
-
class
rawdisk.scheme.gpt.Gpt[source]¶ Bases:
objectRepresents GPT partition table.
-
partition_entries¶ list – List of initialized
GptPartitionobjects.
-
header¶ GptHeader – Initialized
GptHeaderobject
-
load(filename, bs=512)[source]¶ Loads GPT partition table.
Parameters: - filename (str) – path to file or device to open for reading
- bs (uint) – Block size of the volume, default: 512
Raises: IOError– If file does not exist or not readable
-
partition_entries
-
rawdisk.scheme.mbr module¶
-
class
rawdisk.scheme.mbr.Mbr(filename=None, load_partition_table=True)[source]¶ Bases:
rawdisk.util.rawstruct.RawStructRepresents the Master Boot Record of the filesystem.
Parameters: filename (str) – path to file or device to open for reading -
partition_table¶ PartitionTable – Initialized
PartitionTableobject
Raises: IOError– If file does not exist or is not readable.Exception– If source has invalid MBR signature
-
partition_table
-
-
class
rawdisk.scheme.mbr.MbrPartitionEntry(data)[source]¶ Bases:
rawdisk.util.rawstruct.RawStruct-
part_offset¶
-
part_type¶
-
total_sectors¶
-
-
class
rawdisk.scheme.mbr.PartitionTable(data)[source]¶ Bases:
rawdisk.util.rawstruct.RawStructRepresents MBR partition table.
Parameters: data (bytes) – byte array to initialize structure with. -
entries¶ list – List of initialized
PartitionEntryobjects
-
partitions¶
-