Submodules¶
These modules are generally only interesting if you debug or want to extend this library.
simplediskimage.cfr module¶
Wrappers and implementations of copy_file_range
-
simplediskimage.cfr.
get_copy_file_range
()[source]¶ Get best suited copy_file_range implementation
Returns: copy_file_range function
-
simplediskimage.cfr.
naive_copy_file_range
(src_fd, dst_fd, count, offset_src=None, offset_dst=None)[source]¶ Naïve copy_file_range implementation, with some non-compatibilities
This function does not behave exactly like the libc version, as it does not care about the position in the file; it will gladly change it no matter the values of offset_*.
Parameters: - src_fd (int) – Source/in file descriptor
- dst_fd (int) – Destination/out file descriptor
- offset_src (int or None) – Offset to seek to in source fd, or None to run from the current position
- offset_dst (int or None) – Offset to seek to in destination fd, or None to run from the current position
Returns: The amount copied, or a negative value on error
simplediskimage.common module¶
Common parts shared between the simple disk image modules
-
exception
simplediskimage.common.
CheckFailed
[source]¶ Bases:
simplediskimage.common.DiskImageException
A check has failed
-
exception
simplediskimage.common.
DiskImageException
[source]¶ Bases:
Exception
A generic DiskImage error
-
exception
simplediskimage.common.
InvalidArguments
[source]¶ Bases:
simplediskimage.common.DiskImageException
Invalid arguments was passed
-
class
simplediskimage.common.
SI
[source]¶ Bases:
object
Helper class with some constants for calculating sizes in bytes.
-
G
= 1000000000¶
-
Gi
= 1073741824¶
-
M
= 1000000¶
-
Mi
= 1048576¶
-
T
= 1000000000000¶
-
Ti
= 1099511627776¶
-
k
= 1000¶
-
ki
= 1024¶
-
-
exception
simplediskimage.common.
UnknownError
[source]¶ Bases:
simplediskimage.common.DiskImageException
Unknown error, probably related to an underlying library
simplediskimage.partitioners module¶
Abstraction of different partitioning tools used by simple disk image
-
class
simplediskimage.partitioners.
NullPartitioner
(image_path, table_type)[source]¶ Bases:
simplediskimage.partitioners.Partitioner
Null partitioner abstraction, only allows for one partition
-
new_partition
(offset_blocks, size_blocks, filesystem, label=None, flags=())[source]¶ Create new partition
Parameters: - offset_blocks – Offset for the new partition in blocks (sectors)
- size_blocks – Size of the new partition in blocks (sectors)
- filesystem – Filesystem of the new partition
- label – Partition label of the new partition, only for GPT
- flags – Flags for the new partition
-
-
class
simplediskimage.partitioners.
Partitioner
(image_path, table_type)[source]¶ Bases:
object
Partitioner abstraction class
Parameters: - image_path – Path to the image to be created
- table_type – Partition table type (label type), ‘gpt’ or ‘msdos’ (or ‘null’ when using the NullPartitioner)
-
new_partition
(offset_blocks, size_blocks, filesystem, label=None, flags=())[source]¶ Create new partition
Parameters: - offset_blocks – Offset for the new partition in blocks (sectors)
- size_blocks – Size of the new partition in blocks (sectors)
- filesystem – Filesystem of the new partition
- label – Partition label of the new partition, only for GPT
- flags – Flags for the new partition
-
exception
simplediskimage.partitioners.
PartitionerException
[source]¶ Bases:
simplediskimage.common.DiskImageException
Generic partitioner error
-
class
simplediskimage.partitioners.
PyParted
(image_path, table_type)[source]¶ Bases:
simplediskimage.partitioners.Partitioner
PyParted partitioner abstraction
-
new_partition
(offset_blocks, size_blocks, filesystem, label=None, flags=())[source]¶ Create new partition
Parameters: - offset_blocks – Offset for the new partition in blocks (sectors)
- size_blocks – Size of the new partition in blocks (sectors)
- filesystem – Filesystem of the new partition
- label – Partition label of the new partition, only for GPT
- flags – Flags for the new partition
-
-
exception
simplediskimage.partitioners.
PyPartedException
[source]¶ Bases:
simplediskimage.partitioners.PartitionerException
PyParted partitioner error
-
class
simplediskimage.partitioners.
Sfdisk
(image_path, table_type)[source]¶ Bases:
simplediskimage.partitioners.Partitioner
Sfdisk partitioner abstraction
-
new_partition
(offset_blocks, size_blocks, filesystem, label=None, flags=())[source]¶ Create new partition
Parameters: - offset_blocks – Offset for the new partition in blocks (sectors)
- size_blocks – Size of the new partition in blocks (sectors)
- filesystem – Filesystem of the new partition
- label – Partition label of the new partition, only for GPT
- flags – Flags for the new partition
-
-
exception
simplediskimage.partitioners.
SfdiskException
[source]¶ Bases:
simplediskimage.partitioners.PartitionerException
Sfdisk partitioner error
simplediskimage.tools module¶
Tool helpers; used to run commands for the simple disk image package
-
exception
simplediskimage.tools.
DoubleQuoteInExtFile
[source]¶ Bases:
simplediskimage.common.DiskImageException
debugfs does not cope well with double quotes in file names, which was detected.
-
class
simplediskimage.tools.
MkfsExt
(command)[source]¶ Bases:
simplediskimage.tools.Tool
Tool wrapper for mkfs.ext*
-
class
simplediskimage.tools.
MkfsExt2
[source]¶ Bases:
simplediskimage.tools.MkfsExt
Tool wrapper for mkfs.ext2
-
class
simplediskimage.tools.
MkfsExt3
[source]¶ Bases:
simplediskimage.tools.MkfsExt
Tool wrapper for mkfs.ext3
-
class
simplediskimage.tools.
MkfsExt4
[source]¶ Bases:
simplediskimage.tools.MkfsExt
Tool wrapper for mkfs.ext4
-
class
simplediskimage.tools.
MkfsFAT
(fat_size)[source]¶ Bases:
simplediskimage.tools.Tool
Tool wrapper for mkfs.fat
-
class
simplediskimage.tools.
MkfsFAT12
[source]¶ Bases:
simplediskimage.tools.MkfsFAT
Tool wrapper for mkfs.fat -F 12
-
class
simplediskimage.tools.
MkfsFAT16
[source]¶ Bases:
simplediskimage.tools.MkfsFAT
Tool wrapper for mkfs.fat -F 16
-
class
simplediskimage.tools.
MkfsFAT32
[source]¶ Bases:
simplediskimage.tools.MkfsFAT
Tool wrapper for mkfs.fat -F 32
-
class
simplediskimage.tools.
PopulateExt
[source]¶ Bases:
simplediskimage.tools.Tool
Tool wrapper for debugfs
-
class
simplediskimage.tools.
Sfdisk
[source]¶ Bases:
simplediskimage.tools.Tool
Tool wrapper for sfdisk
-
class
simplediskimage.tools.
Tool
(command)[source]¶ Bases:
object
Wrapper class for a runnable tool (command).
Parameters: command – Command to be run, e.g. ls.
-
exception
simplediskimage.tools.
ToolNotFound
[source]¶ Bases:
simplediskimage.common.DiskImageException
The tool requested was not found (check $PATH and install all dependencies).