82 lines
3 KiB
Diff
82 lines
3 KiB
Diff
diff --git a/include/docstrings/pydisk.h b/include/docstrings/pydisk.h
|
|
index 77a399f..f9f6f09 100644
|
|
--- a/include/docstrings/pydisk.h
|
|
+++ b/include/docstrings/pydisk.h
|
|
@@ -82,6 +82,12 @@ PyDoc_STRVAR(partition_get_path_doc,
|
|
"level. For instance, on Linux this could return '/dev/sda' for a partition.\n"
|
|
"If an error occurs, _ped.PartitionException is raised.");
|
|
|
|
+PyDoc_STRVAR(partition_reset_num_doc,
|
|
+"reset_num(self) -> boolean\n\n"
|
|
+"Reset the partition's number to value allowing it to be set correctly when\n"
|
|
+"the partition is added to _ped.PartedDisk. The returned value means\n"
|
|
+"success/failure");
|
|
+
|
|
PyDoc_STRVAR(disk_duplicate_doc,
|
|
"duplicate(self) -> Disk\n\n"
|
|
"Return a new Disk that is a copy of self. This method raises\n"
|
|
diff --git a/include/pydisk.h b/include/pydisk.h
|
|
index 6f6bff7..ef37a58 100644
|
|
--- a/include/pydisk.h
|
|
+++ b/include/pydisk.h
|
|
@@ -134,6 +134,7 @@ PyObject *py_ped_partition_set_name(_ped_Partition *, PyObject *);
|
|
PyObject *py_ped_partition_get_name(_ped_Partition *, PyObject *);
|
|
PyObject *py_ped_partition_is_busy(_ped_Partition *, PyObject *);
|
|
PyObject *py_ped_partition_get_path(_ped_Partition *, PyObject *);
|
|
+PyObject *py_ped_partition_reset_num(_ped_Partition *, PyObject *);
|
|
PyObject *py_ped_partition_type_get_name(PyObject *, PyObject *);
|
|
PyObject *py_ped_partition_flag_get_name(PyObject *, PyObject *);
|
|
PyObject *py_ped_partition_flag_get_by_name(PyObject *, PyObject *);
|
|
diff --git a/include/typeobjects/pydisk.h b/include/typeobjects/pydisk.h
|
|
index 3cadf7d..3adca3f 100644
|
|
--- a/include/typeobjects/pydisk.h
|
|
+++ b/include/typeobjects/pydisk.h
|
|
@@ -60,6 +60,8 @@ static PyMethodDef _ped_Partition_methods[] = {
|
|
partition_is_busy_doc},
|
|
{"get_path", (PyCFunction) py_ped_partition_get_path, METH_VARARGS,
|
|
partition_get_path_doc},
|
|
+ {"reset_num", (PyCFunction) py_ped_partition_reset_num, METH_VARARGS,
|
|
+ partition_reset_num_doc},
|
|
{NULL}
|
|
};
|
|
|
|
diff --git a/src/parted/partition.py b/src/parted/partition.py
|
|
index ee3e2d0..c91dbc4 100644
|
|
--- a/src/parted/partition.py
|
|
+++ b/src/parted/partition.py
|
|
@@ -246,6 +246,10 @@ class Partition(object):
|
|
For internal module use only."""
|
|
return self.__partition
|
|
|
|
+ def resetNumber(self):
|
|
+ """Reset the partition's number to default"""
|
|
+ return self.__partition.reset_num()
|
|
+
|
|
# collect all partition flags and store them in a hash
|
|
partitionFlag = {}
|
|
__flag = _ped.partition_flag_next(0)
|
|
diff --git a/src/pydisk.c b/src/pydisk.c
|
|
index 5a525a1..aea6282 100644
|
|
--- a/src/pydisk.c
|
|
+++ b/src/pydisk.c
|
|
@@ -1377,6 +1377,20 @@ PyObject *py_ped_partition_get_path(_ped_Partition *s, PyObject *args) {
|
|
return PyString_FromString(ret);
|
|
}
|
|
|
|
+PyObject *py_ped_partition_reset_num(_ped_Partition *s, PyObject *args) {
|
|
+ PedPartition *part = NULL;
|
|
+
|
|
+ part = _ped_Partition2PedPartition(s);
|
|
+ if (part == NULL) {
|
|
+ Py_RETURN_FALSE;
|
|
+ }
|
|
+
|
|
+ part->num = -1;
|
|
+
|
|
+ Py_RETURN_TRUE;
|
|
+}
|
|
+
|
|
+
|
|
PyObject *py_ped_partition_type_get_name(PyObject *s, PyObject *args) {
|
|
long type;
|
|
char *ret = NULL;
|