diff options
author | Joel Andres Granados <jgranado@redhat.com> | 2008-03-06 19:16:59 +0100 |
---|---|---|
committer | Joel Andres Granados <jgranado@redhat.com> | 2008-03-07 15:07:55 +0100 |
commit | 36e1656f5587d079c1fc2f78c6fc9c3add1d020a (patch) | |
tree | 37966684b6ee8a14c49ef7cc1ad25abf0eb6bfa9 /plugins | |
parent | aca470cbb934d661f4bca0e55fae0483ccc0fe57 (diff) | |
download | firstaidkit-36e1656f5587d079c1fc2f78c6fc9c3add1d020a.tar.gz firstaidkit-36e1656f5587d079c1fc2f78c6fc9c3add1d020a.tar.xz firstaidkit-36e1656f5587d079c1fc2f78c6fc9c3add1d020a.zip |
setPartition is useless.
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/plugin_undelete_partitions/_undelpart.c | 146 |
1 files changed, 0 insertions, 146 deletions
diff --git a/plugins/plugin_undelete_partitions/_undelpart.c b/plugins/plugin_undelete_partitions/_undelpart.c index 577d3aa..eba95b2 100644 --- a/plugins/plugin_undelete_partitions/_undelpart.c +++ b/plugins/plugin_undelete_partitions/_undelpart.c @@ -455,152 +455,6 @@ undelpart_getPartitionList(PyObject * self, PyObject * args){ } /* - * Set the partition table for a specific disk. It recieves a part number and - * start and end sectors for a specific partitions. If the partition is in - * the list but not in the system, the function will try to add it. If the - * partition is in the system but not in the table, it will be removed. - * The object recieved must be (string), [[(string), ing, int],...] - */ -static PyObject * -undelpart_setPartitionList(PyObject * self, PyObject * args){ - - PedDisk * disk; - PedPartition * part; //individual partitions. - - PyObject * partList; //list of partitions. - - partElem * _partList = NULL, * _toErase = NULL, * _toAdd = NULL;//arrays. - int _partListSize = 0, _toEraseSize = 0, _toAddSize = 0;//array sizes - int aOffset = 0, eOffset = 0; //array offsets - int erasable; - int i; - char * path; - - /* Check the arguments */ - if(!PyArg_ParseTuple(args, "sO", &path, &partList)){ - PyErr_SetString(PyExc_TypeError, "Arguments passed are of the wrong type."); - goto handle_error; - } - if(! PyList_Check(partList)){ - PyErr_SetString(PyExc_TypeError, - "The object that was passed is not a list."); - goto handle_error; - } - - /* Put the values of the list into a array of partElem */ - _partListSize = PyList_Size(partList); - _partList = malloc(sizeof(partElem)*_partListSize+1); - if(!_partList){ - PyErr_SetString(PyExc_StandardError, "Error allocating memory."); - goto handle_error; - } - for(i=0; i < _partListSize ; i++){ - _partList[i] = _getCPartList(PyList_GetItem(partList, i)); - if(PyErr_Occurred() || _partList[i].partnum == '\0') - goto handle_error; - } - _partList[_partListSize].partnum = '\0'; - - /* create the disk */ - disk = _getDiskFromPath(path); - if(disk == NULL){ - PyErr_SetString(PyExc_StandardError, "Error reading disk information."); - goto handle_error; - } - - /* - * create the erasable array - */ - // our size will be the greates part number for disk. - _toEraseSize = ped_disk_get_last_partition_num(disk); - _toErase = malloc(sizeof(partElem)*_toEraseSize+1); - if(!_toErase){ - PyErr_SetString(PyExc_StandardError, "Error allocating memory."); - goto handle_error; - } - for(part = ped_disk_next_partition(disk, NULL) ; part ; - part = ped_disk_next_partition(disk, part)){ - erasable = 1; - for(i=0; _partList[i].partnum != '\0'; i++){ - if(part->num == _partList[i].partnum){ - erasable = 0; - break; - } - } - if(erasable){ - _toErase[eOffset] = _partList[i]; - _toErase[++eOffset].partnum = '\0'; - } - } - - /* - * Create the addable array - */ - _toAddSize = _partListSize; - _toAdd = malloc(sizeof(partElem)*_toAddSize+1); - if(!_toAdd){ - PyErr_SetString(PyExc_StandardError, "Error allocating memory."); - goto handle_error; - } - for(i=0; _partList[i].partnum != '\0' ; i++){ - part = ped_disk_get_partition(disk, i); - if(part == NULL){ - _toAdd[aOffset] = _partList[i]; - _toAdd[++aOffset].partnum = '\0'; - } - ped_partition_destroy(part);//might be overkill here. - } - - /* - * We add and erase and commit. - */ - for(i=0; _toErase[i].partnum != '\0'; i++){ - part = ped_disk_get_partition(disk, i); - if(part == NULL){ - PyErr_SetString(PyExc_StandardError, - "Error reading partition partition."); - goto handle_error; - } - if(!ped_disk_delete_partition(disk, part)){ - PyErr_SetString(PyExc_StandardError, "Error deleting partition."); - goto handle_error; - } - } - for(i=0; _toAdd[i].partnum != '\0'; i++){ - if(!add_partition(disk, _toAdd[i])){ - PyErr_SetString(PyExc_StandardError, "Error adding partition."); - goto handle_error; - } - } - if(!ped_disk_check(disk)){ - PyErr_SetString(PyExc_StandardError, - "The resulting partition table is invalid."); - goto handle_error; - } - // commit to the device and tell the operating system about it. - if( !ped_disk_commit_to_dev(disk) && !ped_disk_commit_to_os(disk)){ - PyErr_SetString(PyExc_StandardError, - "Could not commit partition table to device or os."); - goto handle_error; - } - - free(_toAdd); - free(_toErase); - free(_partList); - - return Py_True; - - handle_error: - assert(PyErr_Occurred()); - - free(_toAdd); - free(_toErase); - free(_partList); - - return NULL; -} - -/* * On a specific disk try to rescue a list of partitions. Return the list of partitions * that was recovered. The partitions should be in the [[partNum, start, end]...] * format. |