rawdisk.scheme package

Submodules

rawdisk.scheme.common module

This module is used for partitioning scheme detection (GPT or MBR)

Attributes:
SCHEME_UNKNOWN (int): When scheme is neither GPT or MBR SCHEME_GPT (int): GPT Scheme was identified SCHEME_MBR (int): MBR Scheme was indentified
rawdisk.scheme.common.detect_scheme(filename)[source]

Detects partitioning scheme of the source

Args:
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 == SCHEME_MBR):
>>> <...>

rawdisk.scheme.gpt module

class rawdisk.scheme.gpt.Gpt[source]

Bases: object

Represents GPT partition table.

Attributes:
partition_entries (list): List of initialized GptPartition objects. header (GptHeader): Initialized GptHeader object
load(filename, bs=512)[source]

Loads GPT partition table.

Args:
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
class rawdisk.scheme.gpt.GptHeader(data)[source]

Bases: rawdisk.util.rawstruct.RawStruct

Represents GUID partition table header (LBA1).

Args:
data (str): byte array to initialize structure with. Must be valid gpt header.
Attributes:
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 (uuid): 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
See Also:
http://en.wikipedia.org/wiki/GUID_Partition_Table#Partition_table_header_.28LBA_1.29
class rawdisk.scheme.gpt.GptPartitionEntry(data)[source]

Bases: rawdisk.util.rawstruct.RawStruct

Represents GPT partition entry.

Args:
data (str): byte array that belongs to valid GPT partition entry.
Attributes:
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)
See Also:
http://en.wikipedia.org/wiki/GUID_Partition_Table#Partition_entries

rawdisk.scheme.mbr module

class rawdisk.scheme.mbr.Mbr(filename=None, load_partition_table=True)[source]

Bases: rawdisk.util.rawstruct.RawStruct

Represents the Master Boot Record of the filesystem.

Args:
filename (str): path to file or device to open for reading
Attributes:
partition_table (PartitionTable): Initialized PartitionTable object
Raises:
IOError: If file does not exist or is not readable. Exception: If source has invalid MBR signature
class rawdisk.scheme.mbr.PartitionEntry(data)[source]

Bases: rawdisk.util.rawstruct.RawStruct

Represents MBR partition entry

Args:
data (str): byte array to initialize structure with.
Attributes:
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:
class rawdisk.scheme.mbr.PartitionTable(data)[source]

Bases: rawdisk.util.rawstruct.RawStruct

Represents MBR partition table.

Args:
data (str): byte array to initialize structure with.
Attributes:
entries (list): List of initialized PartitionEntry objects

Module contents

Table Of Contents

This Page