summaryrefslogtreecommitdiffstats
path: root/partition.c
Commit message (Collapse)AuthorAgeFilesLines
* partition: add partition type getsetJose M. Guisado2022-12-151-0/+31
| | | | | | | | | | | | | | | | | | | | | | | | Partition type getset enables modifying and getting the type of a give libfdisk partition. The type of a partition is defined using PartType, which can only be instanced via label specific functions get_parttype_from_string or get_parttype_from_code. For example, to set the type of a new partitions to 'EFI System': >>> import fdisk >>> pa = fdisk.Partition() >>> pa.type >>> cxt = fdisk.Context('./disk.bin', readonly=False) >>> cxt.create_disklabel('gpt') >>> efitype = cxt.label.get_parttype_from_string("c12a7328-f81f-11d2-ba4b-00a0c93ec93b") >>> pa.type = efitype Following the previous example, getting its current partition type: >>> pa.type <libfdisk.PartType object at 0x7f2f0a9a12d0, name=EFI System>
* partition: add *_follow_default optional paramsJose M. Guisado2022-12-151-9/+27
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Add optional parameters inside init function of partition. Optional parameters refer to: - partno_follow_default - start_follow_default - end_follow_default These options can be used in order to enable or disable default partno, start and end value when adding partitions. With those optional parameters enabled by default a user is able to add a partition into the context label without specifying any attribute. >>> import fdisk >>> cxt = fdisk.Context('./disk.bin', readonly=False) >>> cxt.create_disklabel('gpt') >>> pa = fdisk.Partition() >>> cxt.add_partition(pa) This enables: - "Filling" the rest of the disk with last partition - No need to track start/end sector for any following partition - No need to track next partno number for any following partition See: https://cdn.kernel.org/pub/linux/utils/util-linux/v2.34/libfdisk-docs/libfdisk-Partition.html#fdisk-partition-partno-follow-default https://cdn.kernel.org/pub/linux/utils/util-linux/v2.34/libfdisk-docs/libfdisk-Partition.html#fdisk-partition-start-follow-default https://cdn.kernel.org/pub/linux/utils/util-linux/v2.34/libfdisk-docs/libfdisk-Partition.html#fdisk-partition-end-follow-default
* context: add add_partition methodJose M. Guisado2022-12-151-0/+1
| | | | | | | | This method wraps fdisk_add_partition. Allows modifying in-memory partition table of a given context. Remember that changes need to be written to disk using the relevant fdisk_write_disklabel function wrapper.
* partition: add partno setterJose M. Guisado2022-12-151-4/+57
| | | | | | | | | | | | | | | | | Allows changing in-memory partno field of a Partition instance: >>> import fdisk >>> pa = fdisk.Partition() >>> pa.partno = 3 >>> pa <libfdisk.Partition object at 0x7f4603a38f30, partno=3> If partno is unset repr shows 'None': >>> import fdisk >>> pa = fdisk.Partition() >>> pa <libfdisk.Partition object at 0x7f86c4338f30, partno=None>
* partition: return None if partno is unsetJose M. Guisado2022-12-151-2/+1
| | | | | | | Undefined values in libfdisk should map to None type in Python. Py_BuildValue("%d", -1); is also incorrectly formatted and raises an error when executed.
* Use c99 struct initializationJose M. Guisado Gomez2022-04-281-37/+12
| | | | Declutters PyTypeObject struct initialization when declaring new types.
* Add COPYING and license headersJose M. Guisado Gomez2022-04-071-0/+12
| | | | LGPL2.1 or later.
* Initial commitJose M. Guisado Gomez2022-04-061-0/+150
Add sources, setup.py and .gitignore Build/Install: python setup.py build python setup.py install