- Add support for exact constraints

This commit is contained in:
Jeremy Katz 2007-11-19 16:34:01 +00:00
parent 7befbff3d3
commit 614ff7b582
2 changed files with 95 additions and 1 deletions

View File

@ -0,0 +1,89 @@
diff --git a/pydisk.c b/pydisk.c
index 51c2e27..20bb714 100644
--- a/pydisk.c
+++ b/pydisk.c
@@ -589,6 +589,28 @@ py_ped_partition_set_system (PyPedPartition *p, PyObject * args)
}
static PyObject *
+py_ped_partition_set_geometry (PyPedPartition *p, PyObject * args)
+{
+ PyPedConstraint *cs = NULL;
+ PedSector start, end;
+
+ if (!PyArg_ParseTuple(args, "O!LL", &PyPedConstraintType, &cs,
+ &start, &end))
+ return NULL;
+
+ py_ped_exception_string_clear ();
+
+ if (!ped_disk_set_partition_geom (p->disk->disk, p->part, cs->constraint,
+ start, end)) {
+ py_ped_set_error_from_ped_exception ();
+ return NULL;
+ }
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+static PyObject *
py_ped_partition_set_name (PyPedPartition *p, PyObject * args)
{
char *name;
@@ -685,6 +707,8 @@ static struct PyMethodDef PyPedPartitionMethods[] = {
METH_VARARGS, NULL },
{ "set_name", (PyCFunction) py_ped_partition_set_name,
METH_VARARGS, NULL },
+ { "set_geometry", (PyCFunction) py_ped_partition_set_geometry,
+ METH_VARARGS, NULL },
{ "get_name", (PyCFunction) py_ped_partition_get_name,
METH_VARARGS, NULL },
{ "is_busy", (PyCFunction) py_ped_partition_is_busy,
diff --git a/pygeometry.c b/pygeometry.c
index fdd7614..8522161 100644
--- a/pygeometry.c
+++ b/pygeometry.c
@@ -24,6 +24,7 @@
#include "partedmodule.h"
#include "pygeometry.h"
#include "pyfilesystem.h"
+#include "pyconstraint.h"
/* geometry implementation */
@@ -157,6 +158,24 @@ py_ped_geometry_duplicate (PyPedGeometry * self, PyObject * args)
return (PyObject *) py_ped_geometry_obj_new (geom, self->dev, 0);
}
+static PyObject *
+py_ped_constraint_exact (PyPedGeometry * self, PyObject * args)
+{
+ PedConstraint *constraint;
+ PyPedConstraint *pyconstraint;
+
+ py_ped_exception_string_clear ();
+ constraint = ped_constraint_exact (self->geom);
+ if (constraint == NULL) {
+ py_ped_set_error_from_ped_exception ();
+ return NULL;
+ }
+
+ pyconstraint = py_ped_constraint_obj_new (constraint, self->dev, 0);
+
+ return (PyObject *) pyconstraint;
+}
+
static struct PyMethodDef PyPedGeometryMethods[] = {
{ "file_system_open",
(PyCFunction) py_ped_file_system_open, METH_VARARGS, NULL },
@@ -172,7 +191,8 @@ static struct PyMethodDef PyPedGeometryMethods[] = {
(PyCFunction) py_ped_geometry_set_end, METH_VARARGS, NULL },
{ "duplicate",
(PyCFunction) py_ped_geometry_duplicate, METH_VARARGS, NULL },
-
+ { "constraint_exact",
+ (PyCFunction) py_ped_constraint_exact, METH_VARARGS, NULL },
{ NULL, NULL, 0, NULL }
};

View File

@ -3,12 +3,13 @@
Summary: Python module for GNU parted
Name: pyparted
Version: 1.8.9
Release: 2%{?dist}
Release: 3%{?dist}
License: GPLv2+
Group: System Environment/Libraries
URL: http://dcantrel.fedorapeople.org/%{name}
Source0: http://dcantrel.fedorapeople.org/%{name}/%{name}-%{version}.tar.bz2
Patch0: pyparted-exact-constraint.patch
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
BuildRequires: python-devel, parted-devel >= 1.8.6, pkgconfig
@ -20,6 +21,7 @@ partition tables.
%prep
%setup -q
%patch0 -p1
%build
CFLAGS="%{optflags}" CC="%{__cc}" %{__make} %{?_smp_mflags}
@ -37,6 +39,9 @@ CFLAGS="%{optflags}" CC="%{__cc}" %{__make} %{?_smp_mflags}
%{python_sitearch}/partedmodule.so
%changelog
* Mon Nov 19 2007 Jeremy Katz <katzj@redhat.com> - 1.8.9-3
- Add support for exact constraints
* Tue Aug 21 2007 David Cantrell <dcantrell@redhat.com> - 1.8.9-2
- Rebuild