summaryrefslogtreecommitdiffstats
Commit message (Collapse)AuthorAgeFilesLines
* context: add add_partition methodJose M. Guisado2022-12-152-0/+27
| | | | | | | | 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.
* context: add disklabel creation and writingJose M. Guisado2022-12-151-0/+36
| | | | | | | | | Adds wrappers for following label related functions from libfdisk: - fdisk_create_disklabel - fdisk_write_disklabel These functions are declared as methods of a Context python object.
* context: rename set_size_unit variablesJose M. Guisado2022-12-151-3/+3
| | | | | | Renames 'cval' to 'szunit' for better readability. This variable is used to store the size_unit constant that is going to be set using fdisk_set_size_unit.
* context: add readonly parameterJose M. Guisado2022-12-151-10/+11
| | | | | | | | fdisk_assign_device() contains 'readonly' parameter to indicate how to open the device. Assigned device 'readonly' must be false (0) in order to write in-memory changes to it.
* context: add size_unit getsetJose M. Guisado Gomez2022-06-071-0/+30
| | | | | | | | | | | | | | | | | | | | | | | | Size unit can be get or set using 'size_unit' context member. >>> for pa in cxt.partitions: ... cxt.partition_to_string(pa, fdisk.FDISK_FIELD_SIZE) ... '114.6G' >>> cxt.size_unit 0 >>> cxt.size_unit == fdisk.FDISK_SIZEUNIT_HUMAN True >>> cxt.size_unit = fdisk.FDISK_SIZEUNIT_BYTES >>> for pa in cxt.partitions: ... cxt.partition_to_string(pa, fdisk.FDISK_FIELD_SIZE) ... '123010531328' Use fdisk_get_size_unit to get size unit value. https://cdn.kernel.org/pub/linux/utils/util-linux/v2.34/libfdisk-docs/libfdisk-Context.html#fdisk-get-size-unit Use fdisk_set_size_unit to set size unit value. https://cdn.kernel.org/pub/linux/utils/util-linux/v2.34/libfdisk-docs/libfdisk-Context.html#fdisk-set-size-unit
* Use c99 struct initializationJose M. Guisado Gomez2022-04-283-111/+34
| | | | Declutters PyTypeObject struct initialization when declaring new types.
* context: rename parts to partitionsJose M. Guisado Gomez2022-04-281-2/+2
|
* fdisk.c: add partition module objectJose M. Guisado Gomez2022-04-262-0/+2
| | | | | | | | | | | | | | | | Call Partition_AddModuleObject when initializing the python module. Fixes bug when using the Partition class but the class has not been added to the module via Py_TypeReady. A common error was the type not being ready (missing attributes): >>> for pa in cxt.parts: ... print(pa.partno) ... Traceback (most recent call last): File "<stdin>", line 2, in <module> AttributeError: 'libfdisk.Partition' object has no attribute 'partno'
* Add COPYING and license headersJose M. Guisado Gomez2022-04-076-0/+562
| | | | LGPL2.1 or later.
* Add MANIFEST.inJose M. Guisado Gomez2022-04-061-0/+1
| | | | Add MANIFEST.in to include .h files in source distributions.
* Initial commitJose M. Guisado Gomez2022-04-067-0/+796
Add sources, setup.py and .gitignore Build/Install: python setup.py build python setup.py install