Ticket #13: 0001-Check-for-the-owner-of-partition-before-removing.patch

File 0001-Check-for-the-owner-of-partition-before-removing.patch, 1.6 KB (added by jgranado, 5 years ago)

patch to handle the owned attr in partition

  • src/pydisk.c

    From 8500f8ac2a74330c772a145927186be580f43cbb Mon Sep 17 00:00:00 2001
    From: Joel Granados Moreno <jgranado@redhat.com>
    Date: Mon, 23 Mar 2009 16:16:23 +0100
    Subject: [PATCH] Check for the owner of partition before removing.
    
    ---
     src/pydisk.c |   18 ++++++++++++++++++
     1 files changed, 18 insertions(+), 0 deletions(-)
    
    diff --git a/src/pydisk.c b/src/pydisk.c
    index 3004e9d..11d58c4 100644
    a b int _ped_Partition_init(_ped_Partition *self, PyObject *args, PyObject *kwds) { 
    195195 
    196196    self->ped_partition = part; 
    197197 
     198    /*On creation the object is not owned by any disk*/ 
     199    self->_owned = 0; 
     200 
    198201    return 0; 
    199202} 
    200203 
    PyObject *py_ped_disk_add_partition(PyObject *s, PyObject *args) { 
    11581161        return NULL; 
    11591162    } 
    11601163 
     1164    /* Its non-sense  to add an owned partition*/ 
     1165    if(in_part->_owned == 1){ 
     1166        PyErr_SetString(PartitionException, "Attempting to add a partition " 
     1167                "that is already owned by a disk."); 
     1168        return NULL; 
     1169    } 
     1170 
     1171 
    11611172    out_part = _ped_Partition2PedPartition(in_part); 
    11621173    if (out_part == NULL) { 
    11631174        return NULL; 
    PyObject *py_ped_disk_remove_partition(PyObject *s, PyObject *args) { 
    12121223        return NULL; 
    12131224    } 
    12141225 
     1226    /* Its non-sense  to remove an unowned partition*/ 
     1227    if(in_part->_owned == 0){ 
     1228        PyErr_SetString(PartitionException, "Attempting to remove a partition " 
     1229                "that is not owned by any disk."); 
     1230        return NULL; 
     1231    } 
     1232 
    12151233    out_part = _ped_Partition2PedPartition(in_part); 
    12161234    if (out_part == NULL) { 
    12171235        return NULL;