FAQ Search Today's Posts Mark Forums Read
» Video Reviews

» Linux Archive

Linux-archive is a website aiming to archive linux email lists and to make them easily accessible for linux users/developers.


» Sponsor

» Partners

» Sponsor

Go Back   Linux Archive > Ubuntu > Ubuntu Development

 
 
LinkBack Thread Tools
 
Old 03-24-2009, 06:17 PM
Hans de Goede
 
Default : Make the constraint argument for add_partition and maximize_partition optional

---
src/parted/disk.py | 16 ++++++++++++----
src/pydisk.c | 26 ++++++++++++++++----------
2 files changed, 28 insertions(+), 14 deletions(-)

diff --git a/src/parted/disk.py b/src/parted/disk.py
index b090c0e..cdfdf0a 100644
--- a/src/parted/disk.py
+++ b/src/parted/disk.py
@@ -177,8 +177,13 @@ class Disk(object):

def addPartition(self, partition=None, constraint=None):
"""Add a new Partition to this Disk with the given Constraint."""
- if self.__disk.add_partition(partition.getPedPartitio n(),
- constraint.getPedConstraint()):
+ if constraint:
+ result = self.__disk.add_partition(partition.getPedPartitio n(),
+ constraint.getPedConstraint())
+ else:
+ result = self.__disk.add_partition(partition.getPedPartitio n())
+
+ if result:
partition.geometry = parted.Geometry(PedGeometry=partition.getPedPartit ion().geom)
self.partitions.invalidate()
return True
@@ -227,8 +232,11 @@ class Disk(object):
def maximizePartition(self, partition=None, constraint=None):
"""Grow the Partition's Geometry to the maximum possible subject
to Constraint."""
- return self.__disk.maximize_partition(partition.getPedPar tition(),
- constraint.getPedConstraint())
+ if constraint:
+ return self.__disk.maximize_partition(partition.getPedPar tition(),
+ constraint.getPedConstraint())
+ else:
+ return self.__disk.maximize_partition(partition.getPedPar tition())

def calculateMaxPartitionGeometry(self, partition=None, constraint=None):
"""Get the maximum Geometry the Partition can be grown to,
diff --git a/src/pydisk.c b/src/pydisk.c
index eef0efb..5886403 100644
--- a/src/pydisk.c
+++ b/src/pydisk.c
@@ -1148,7 +1148,7 @@ PyObject *py_ped_disk_add_partition(PyObject *s, PyObject *args) {
PedConstraint *out_constraint = NULL;
int ret = 0;

- if (!PyArg_ParseTuple(args, "O!O!",&_ped_Partition_Type_obj,
+ if (!PyArg_ParseTuple(args, "O!|O!",&_ped_Partition_Type_obj,
&in_part, &_ped_Constraint_Type_obj, &in_constraint)) {
return NULL;
}
@@ -1168,9 +1168,11 @@ PyObject *py_ped_disk_add_partition(PyObject *s, PyObject *args) {
return NULL;
}

- out_constraint = _ped_Constraint2PedConstraint(in_constraint);
- if (out_constraint == NULL) {
- return NULL;
+ if (in_constraint) {
+ out_constraint = _ped_Constraint2PedConstraint(in_constraint);
+ if (out_constraint == NULL) {
+ return NULL;
+ }
}

ret = ped_disk_add_partition(disk, out_part, out_constraint);
@@ -1193,7 +1195,8 @@ PyObject *py_ped_disk_add_partition(PyObject *s, PyObject *args) {
in_part->_owned = 1;
*((_ped_Geometry *)in_part->geom)->ped_geometry = out_part->geom;

- ped_constraint_destroy(out_constraint);
+ if (out_constraint)
+ ped_constraint_destroy(out_constraint);

if (ret) {
Py_RETURN_TRUE;
@@ -1367,7 +1370,7 @@ PyObject *py_ped_disk_maximize_partition(PyObject *s, PyObject *args) {
PedConstraint *out_constraint = NULL;
int ret = 0;

- if (!PyArg_ParseTuple(args, "O!O!", &_ped_Partition_Type_obj, &in_part,
+ if (!PyArg_ParseTuple(args, "O!|O!", &_ped_Partition_Type_obj, &in_part,
&_ped_Constraint_Type_obj, &in_constraint)) {
return NULL;
}
@@ -1387,14 +1390,17 @@ PyObject *py_ped_disk_maximize_partition(PyObject *s, PyObject *args) {
return NULL;
}

- out_constraint = _ped_Constraint2PedConstraint(in_constraint);
- if (out_constraint == NULL) {
- return NULL;
+ if (in_constraint) {
+ out_constraint = _ped_Constraint2PedConstraint(in_constraint);
+ if (out_constraint == NULL) {
+ return NULL;
+ }
}

ret = ped_disk_maximize_partition(disk, out_part, out_constraint);

- ped_constraint_destroy(out_constraint);
+ if (out_constraint)
+ ped_constraint_destroy(out_constraint);

if (ret == 0) {
if (partedExnRaised) {
--
1.6.2

_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@redhat.com
https://www.redhat.com/mailman/listinfo/anaconda-devel-list
 
Old 03-24-2009, 06:59 PM
David Cantrell
 
Default : Make the constraint argument for add_partition and maximize_partition optional

Please file pyparted bugs/patches at http://fedorahosted.org/pyparted/

On 03/24/2009 09:17 AM, Hans de Goede wrote:

---
src/parted/disk.py | 16 ++++++++++++----
src/pydisk.c | 26 ++++++++++++++++----------
2 files changed, 28 insertions(+), 14 deletions(-)

diff --git a/src/parted/disk.py b/src/parted/disk.py
index b090c0e..cdfdf0a 100644
--- a/src/parted/disk.py
+++ b/src/parted/disk.py
@@ -177,8 +177,13 @@ class Disk(object):

def addPartition(self, partition=None, constraint=None):
"""Add a new Partition to this Disk with the given Constraint."""
- if self.__disk.add_partition(partition.getPedPartitio n(),
- constraint.getPedConstraint()):
+ if constraint:
+ result = self.__disk.add_partition(partition.getPedPartitio n(),
+ constraint.getPedConstraint())
+ else:
+ result = self.__disk.add_partition(partition.getPedPartitio n())
+
+ if result:
partition.geometry =
parted.Geometry(PedGeometry=partition.getPedPartit ion().geom)
self.partitions.invalidate()
return True
@@ -227,8 +232,11 @@ class Disk(object):
def maximizePartition(self, partition=None, constraint=None):
"""Grow the Partition's Geometry to the maximum possible subject
to Constraint."""
- return self.__disk.maximize_partition(partition.getPedPar tition(),
- constraint.getPedConstraint())
+ if constraint:
+ return self.__disk.maximize_partition(partition.getPedPar tition(),
+ constraint.getPedConstraint())
+ else:
+ return self.__disk.maximize_partition(partition.getPedPar tition())

def calculateMaxPartitionGeometry(self, partition=None, constraint=None):
"""Get the maximum Geometry the Partition can be grown to,
diff --git a/src/pydisk.c b/src/pydisk.c
index eef0efb..5886403 100644
--- a/src/pydisk.c
+++ b/src/pydisk.c
@@ -1148,7 +1148,7 @@ PyObject *py_ped_disk_add_partition(PyObject *s,
PyObject *args) {
PedConstraint *out_constraint = NULL;
int ret = 0;

- if (!PyArg_ParseTuple(args, "O!O!",&_ped_Partition_Type_obj,
+ if (!PyArg_ParseTuple(args, "O!|O!",&_ped_Partition_Type_obj,
&in_part, &_ped_Constraint_Type_obj, &in_constraint)) {
return NULL;
}
@@ -1168,9 +1168,11 @@ PyObject *py_ped_disk_add_partition(PyObject *s,
PyObject *args) {
return NULL;
}

- out_constraint = _ped_Constraint2PedConstraint(in_constraint);
- if (out_constraint == NULL) {
- return NULL;
+ if (in_constraint) {
+ out_constraint = _ped_Constraint2PedConstraint(in_constraint);
+ if (out_constraint == NULL) {
+ return NULL;
+ }
}

ret = ped_disk_add_partition(disk, out_part, out_constraint);
@@ -1193,7 +1195,8 @@ PyObject *py_ped_disk_add_partition(PyObject *s,
PyObject *args) {
in_part->_owned = 1;
*((_ped_Geometry *)in_part->geom)->ped_geometry = out_part->geom;

- ped_constraint_destroy(out_constraint);
+ if (out_constraint)
+ ped_constraint_destroy(out_constraint);

if (ret) {
Py_RETURN_TRUE;
@@ -1367,7 +1370,7 @@ PyObject *py_ped_disk_maximize_partition(PyObject
*s, PyObject *args) {
PedConstraint *out_constraint = NULL;
int ret = 0;

- if (!PyArg_ParseTuple(args, "O!O!", &_ped_Partition_Type_obj, &in_part,
+ if (!PyArg_ParseTuple(args, "O!|O!", &_ped_Partition_Type_obj, &in_part,
&_ped_Constraint_Type_obj, &in_constraint)) {
return NULL;
}
@@ -1387,14 +1390,17 @@ PyObject
*py_ped_disk_maximize_partition(PyObject *s, PyObject *args) {
return NULL;
}

- out_constraint = _ped_Constraint2PedConstraint(in_constraint);
- if (out_constraint == NULL) {
- return NULL;
+ if (in_constraint) {
+ out_constraint = _ped_Constraint2PedConstraint(in_constraint);
+ if (out_constraint == NULL) {
+ return NULL;
+ }
}

ret = ped_disk_maximize_partition(disk, out_part, out_constraint);

- ped_constraint_destroy(out_constraint);
+ if (out_constraint)
+ ped_constraint_destroy(out_constraint);

if (ret == 0) {
if (partedExnRaised) {



--
David Cantrell <dcantrell@redhat.com>
Red Hat / Honolulu, HI

_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@redhat.com
https://www.redhat.com/mailman/listinfo/anaconda-devel-list
 
Old 03-24-2009, 07:07 PM
Hans de Goede
 
Default : Make the constraint argument for add_partition and maximize_partition optional

On 03/24/2009 08:59 PM, David Cantrell wrote:

Please file pyparted bugs/patches at http://fedorahosted.org/pyparted/



I know, but this one was for testing purposes to see if this fixes an issue
dlehman is having. If it does I'll submit it to trac.

Regards,

Hans




On 03/24/2009 09:17 AM, Hans de Goede wrote:

---
src/parted/disk.py | 16 ++++++++++++----
src/pydisk.c | 26 ++++++++++++++++----------
2 files changed, 28 insertions(+), 14 deletions(-)

diff --git a/src/parted/disk.py b/src/parted/disk.py
index b090c0e..cdfdf0a 100644
--- a/src/parted/disk.py
+++ b/src/parted/disk.py
@@ -177,8 +177,13 @@ class Disk(object):

def addPartition(self, partition=None, constraint=None):
"""Add a new Partition to this Disk with the given Constraint."""
- if self.__disk.add_partition(partition.getPedPartitio n(),
- constraint.getPedConstraint()):
+ if constraint:
+ result = self.__disk.add_partition(partition.getPedPartitio n(),
+ constraint.getPedConstraint())
+ else:
+ result = self.__disk.add_partition(partition.getPedPartitio n())
+
+ if result:
partition.geometry =
parted.Geometry(PedGeometry=partition.getPedPartit ion().geom)
self.partitions.invalidate()
return True
@@ -227,8 +232,11 @@ class Disk(object):
def maximizePartition(self, partition=None, constraint=None):
"""Grow the Partition's Geometry to the maximum possible subject
to Constraint."""
- return self.__disk.maximize_partition(partition.getPedPar tition(),
- constraint.getPedConstraint())
+ if constraint:
+ return self.__disk.maximize_partition(partition.getPedPar tition(),
+ constraint.getPedConstraint())
+ else:
+ return self.__disk.maximize_partition(partition.getPedPar tition())

def calculateMaxPartitionGeometry(self, partition=None, constraint=None):
"""Get the maximum Geometry the Partition can be grown to,
diff --git a/src/pydisk.c b/src/pydisk.c
index eef0efb..5886403 100644
--- a/src/pydisk.c
+++ b/src/pydisk.c
@@ -1148,7 +1148,7 @@ PyObject *py_ped_disk_add_partition(PyObject *s,
PyObject *args) {
PedConstraint *out_constraint = NULL;
int ret = 0;

- if (!PyArg_ParseTuple(args, "O!O!",&_ped_Partition_Type_obj,
+ if (!PyArg_ParseTuple(args, "O!|O!",&_ped_Partition_Type_obj,
&in_part, &_ped_Constraint_Type_obj, &in_constraint)) {
return NULL;
}
@@ -1168,9 +1168,11 @@ PyObject *py_ped_disk_add_partition(PyObject *s,
PyObject *args) {
return NULL;
}

- out_constraint = _ped_Constraint2PedConstraint(in_constraint);
- if (out_constraint == NULL) {
- return NULL;
+ if (in_constraint) {
+ out_constraint = _ped_Constraint2PedConstraint(in_constraint);
+ if (out_constraint == NULL) {
+ return NULL;
+ }
}

ret = ped_disk_add_partition(disk, out_part, out_constraint);
@@ -1193,7 +1195,8 @@ PyObject *py_ped_disk_add_partition(PyObject *s,
PyObject *args) {
in_part->_owned = 1;
*((_ped_Geometry *)in_part->geom)->ped_geometry = out_part->geom;

- ped_constraint_destroy(out_constraint);
+ if (out_constraint)
+ ped_constraint_destroy(out_constraint);

if (ret) {
Py_RETURN_TRUE;
@@ -1367,7 +1370,7 @@ PyObject *py_ped_disk_maximize_partition(PyObject
*s, PyObject *args) {
PedConstraint *out_constraint = NULL;
int ret = 0;

- if (!PyArg_ParseTuple(args, "O!O!", &_ped_Partition_Type_obj, &in_part,
+ if (!PyArg_ParseTuple(args, "O!|O!", &_ped_Partition_Type_obj,
&in_part,
&_ped_Constraint_Type_obj, &in_constraint)) {
return NULL;
}
@@ -1387,14 +1390,17 @@ PyObject
*py_ped_disk_maximize_partition(PyObject *s, PyObject *args) {
return NULL;
}

- out_constraint = _ped_Constraint2PedConstraint(in_constraint);
- if (out_constraint == NULL) {
- return NULL;
+ if (in_constraint) {
+ out_constraint = _ped_Constraint2PedConstraint(in_constraint);
+ if (out_constraint == NULL) {
+ return NULL;
+ }
}

ret = ped_disk_maximize_partition(disk, out_part, out_constraint);

- ped_constraint_destroy(out_constraint);
+ if (out_constraint)
+ ped_constraint_destroy(out_constraint);

if (ret == 0) {
if (partedExnRaised) {





_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@redhat.com
https://www.redhat.com/mailman/listinfo/anaconda-devel-list
 
Old 03-24-2009, 07:47 PM
David Lehman
 
Default : Make the constraint argument for add_partition and maximize_partition optional

On Tue, 2009-03-24 at 20:17 +0100, Hans de Goede wrote:
> ---
> src/parted/disk.py | 16 ++++++++++++----
> src/pydisk.c | 26 ++++++++++++++++----------
> 2 files changed, 28 insertions(+), 14 deletions(-)

I think we will have the cylinder-alignment issue anytime a partition
has a max size, either explicitly or because of a filesystem limit,
since this forces us to pass a constraint to maximizePartition.

Dave

>
> diff --git a/src/parted/disk.py b/src/parted/disk.py
> index b090c0e..cdfdf0a 100644
> --- a/src/parted/disk.py
> +++ b/src/parted/disk.py
> @@ -177,8 +177,13 @@ class Disk(object):
>
> def addPartition(self, partition=None, constraint=None):
> """Add a new Partition to this Disk with the given Constraint."""
> - if self.__disk.add_partition(partition.getPedPartitio n(),
> - constraint.getPedConstraint()):
> + if constraint:
> + result = self.__disk.add_partition(partition.getPedPartitio n(),
> + constraint.getPedConstraint())
> + else:
> + result = self.__disk.add_partition(partition.getPedPartitio n())
> +
> + if result:
> partition.geometry = parted.Geometry(PedGeometry=partition.getPedPartit ion().geom)
> self.partitions.invalidate()
> return True
> @@ -227,8 +232,11 @@ class Disk(object):
> def maximizePartition(self, partition=None, constraint=None):
> """Grow the Partition's Geometry to the maximum possible subject
> to Constraint."""
> - return self.__disk.maximize_partition(partition.getPedPar tition(),
> - constraint.getPedConstraint())
> + if constraint:
> + return self.__disk.maximize_partition(partition.getPedPar tition(),
> + constraint.getPedConstraint())
> + else:
> + return self.__disk.maximize_partition(partition.getPedPar tition())
>
> def calculateMaxPartitionGeometry(self, partition=None, constraint=None):
> """Get the maximum Geometry the Partition can be grown to,
> diff --git a/src/pydisk.c b/src/pydisk.c
> index eef0efb..5886403 100644
> --- a/src/pydisk.c
> +++ b/src/pydisk.c
> @@ -1148,7 +1148,7 @@ PyObject *py_ped_disk_add_partition(PyObject *s, PyObject *args) {
> PedConstraint *out_constraint = NULL;
> int ret = 0;
>
> - if (!PyArg_ParseTuple(args, "O!O!",&_ped_Partition_Type_obj,
> + if (!PyArg_ParseTuple(args, "O!|O!",&_ped_Partition_Type_obj,
> &in_part, &_ped_Constraint_Type_obj, &in_constraint)) {
> return NULL;
> }
> @@ -1168,9 +1168,11 @@ PyObject *py_ped_disk_add_partition(PyObject *s, PyObject *args) {
> return NULL;
> }
>
> - out_constraint = _ped_Constraint2PedConstraint(in_constraint);
> - if (out_constraint == NULL) {
> - return NULL;
> + if (in_constraint) {
> + out_constraint = _ped_Constraint2PedConstraint(in_constraint);
> + if (out_constraint == NULL) {
> + return NULL;
> + }
> }
>
> ret = ped_disk_add_partition(disk, out_part, out_constraint);
> @@ -1193,7 +1195,8 @@ PyObject *py_ped_disk_add_partition(PyObject *s, PyObject *args) {
> in_part->_owned = 1;
> *((_ped_Geometry *)in_part->geom)->ped_geometry = out_part->geom;
>
> - ped_constraint_destroy(out_constraint);
> + if (out_constraint)
> + ped_constraint_destroy(out_constraint);
>
> if (ret) {
> Py_RETURN_TRUE;
> @@ -1367,7 +1370,7 @@ PyObject *py_ped_disk_maximize_partition(PyObject *s, PyObject *args) {
> PedConstraint *out_constraint = NULL;
> int ret = 0;
>
> - if (!PyArg_ParseTuple(args, "O!O!", &_ped_Partition_Type_obj, &in_part,
> + if (!PyArg_ParseTuple(args, "O!|O!", &_ped_Partition_Type_obj, &in_part,
> &_ped_Constraint_Type_obj, &in_constraint)) {
> return NULL;
> }
> @@ -1387,14 +1390,17 @@ PyObject *py_ped_disk_maximize_partition(PyObject *s, PyObject *args) {
> return NULL;
> }
>
> - out_constraint = _ped_Constraint2PedConstraint(in_constraint);
> - if (out_constraint == NULL) {
> - return NULL;
> + if (in_constraint) {
> + out_constraint = _ped_Constraint2PedConstraint(in_constraint);
> + if (out_constraint == NULL) {
> + return NULL;
> + }
> }
>
> ret = ped_disk_maximize_partition(disk, out_part, out_constraint);
>
> - ped_constraint_destroy(out_constraint);
> + if (out_constraint)
> + ped_constraint_destroy(out_constraint);
>
> if (ret == 0) {
> if (partedExnRaised) {

_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@redhat.com
https://www.redhat.com/mailman/listinfo/anaconda-devel-list
 
Old 03-25-2009, 09:03 AM
Hans de Goede
 
Default : Make the constraint argument for add_partition and maximize_partition optional

On 03/24/2009 09:47 PM, David Lehman wrote:

On Tue, 2009-03-24 at 20:17 +0100, Hans de Goede wrote:

---
src/parted/disk.py | 16 ++++++++++++----
src/pydisk.c | 26 ++++++++++++++++----------
2 files changed, 28 insertions(+), 14 deletions(-)


I think we will have the cylinder-alignment issue anytime a partition
has a max size, either explicitly or because of a filesystem limit,
since this forces us to pass a constraint to maximizePartition.



True, suck. Well we could only grow partitions without any max size limit,
that would catch the most common automated partitioning case. And, well, if
people give size constraints they shouldn't be surprised if we do not use the
whole disk. Although we could end up not using the whole disk when they have
given size constraints which are way bigger then the disk.

Or we could just live with the cylinder-alignment. We've always been doing
cylinder aligned partitioning in the old code AFAIK.

Regards,

Hans

_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@redhat.com
https://www.redhat.com/mailman/listinfo/anaconda-devel-list
 

Thread Tools




All times are GMT. The time now is 09:06 AM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright 2007 - 2008, www.linux-archive.org