Blame SOURCES/0003-Subject-PATCH-pyparted-export-ped_disk_new-functiona.patch

47a405
From 36384816c56d666bbf3492ddcc531bf4c4a38674 Mon Sep 17 00:00:00 2001
47a405
From: Nageswara R Sastry <rnsastry@linux.vnet.ibm.com>
47a405
Date: Thu, 23 May 2013 09:14:10 -0400
47a405
Subject: [PATCH 03/03] Subject: [PATCH] pyparted: export ped_disk_new
47a405
 functionality
47a405
47a405
Fixed Block Access (FBA) DASDs are mainframe-specific disk devices
47a405
which are layed out as a sequence of 512-byte sectors. In contrast
47a405
to ECKD DASDs, these disks do not require formatting and resemble
47a405
the LBA layout of non-mainframe disks. Despite this resemblance,
47a405
the Linux kernel applies special handling during partition detection
47a405
for FBA DASDs, resulting in a single, immutable partition being
47a405
reported.
47a405
47a405
While actual FBA DASD hardware is no longer available, the z/VM
47a405
hypervisor can simulate FBA DASD disks, backed by either ECKD or
47a405
SCSI devices.
47a405
47a405
This patch adds support for FBA DASD partitions and successful
47a405
installation by Anaconda.
47a405
47a405
Signed-off-by: Nageswara R Sastry <rnsastry@linux.vnet.ibm.com>
47a405
---
47a405
 include/pydisk.h       |  1 +
47a405
 src/_pedmodule.c       |  7 +++++++
47a405
 src/parted/__init__.py |  9 +++++++++
47a405
 src/pydisk.c           | 32 ++++++++++++++++++++++++++++++++
47a405
 4 files changed, 49 insertions(+)
47a405
47a405
diff --git a/include/pydisk.h b/include/pydisk.h
47a405
index c0bf92e..a2bcc4f 100644
47a405
--- a/include/pydisk.h
47a405
+++ b/include/pydisk.h
47a405
@@ -152,6 +152,7 @@ PyObject *py_ped_disk_get_partition(PyObject *, PyObject *);
47a405
 PyObject *py_ped_disk_get_partition_by_sector(PyObject *, PyObject *);
47a405
 PyObject *py_ped_disk_extended_partition(PyObject *, PyObject *);
47a405
 PyObject *py_ped_disk_new_fresh(PyObject *, PyObject *);
47a405
+PyObject *py_ped_disk_new(PyObject *, PyObject *);
47a405
 
47a405
 #endif /* PYDISK_H_INCLUDED */
47a405
 
47a405
diff --git a/src/_pedmodule.c b/src/_pedmodule.c
47a405
index add0e8c..efdf831 100644
47a405
--- a/src/_pedmodule.c
47a405
+++ b/src/_pedmodule.c
47a405
@@ -162,6 +162,11 @@ PyDoc_STRVAR(disk_new_fresh_doc,
47a405
 "will have to use the commit_to_dev() method to write the new label to\n"
47a405
 "the disk.");
47a405
 
47a405
+PyDoc_STRVAR(disk_new_doc,
47a405
+"disk_new(Device) -> Disk\n\n"
47a405
+"Given the Device, create a new Disk object. And probe, read the details of\n"
47a405
+"the disk.");
47a405
+
47a405
 PyDoc_STRVAR(disk_flag_get_name_doc,
47a405
 "disk_flag_get_name(integer) -> string\n\n"
47a405
 "Return a name for a disk flag constant.  If an invalid flag is provided,\n"
47a405
@@ -252,6 +257,8 @@ static struct PyMethodDef PyPedModuleMethods[] = {
47a405
                             METH_VARARGS, partition_flag_next_doc},
47a405
     {"disk_new_fresh", (PyCFunction) py_ped_disk_new_fresh,
47a405
                        METH_VARARGS, disk_new_fresh_doc},
47a405
+    {"disk_new", (PyCFunction) py_ped_disk_new,
47a405
+                       METH_VARARGS, disk_new_doc},
47a405
     {"disk_flag_get_name", (PyCFunction) py_ped_disk_flag_get_name,
47a405
                                 METH_VARARGS, disk_flag_get_name_doc},
47a405
     {"disk_flag_get_by_name", (PyCFunction) py_ped_disk_flag_get_by_name,
47a405
diff --git a/src/parted/__init__.py b/src/parted/__init__.py
47a405
index 01f9575..0eb23d2 100644
47a405
--- a/src/parted/__init__.py
47a405
+++ b/src/parted/__init__.py
47a405
@@ -418,6 +418,15 @@ def freshDisk(device, ty):
47a405
     return Disk(PedDisk=peddisk)
47a405
 
47a405
 @localeC
47a405
+def newDisk(device):
47a405
+    """Return a Disk object for this Device. Read the partition table off
47a405
+       a device (if one is found)."""
47a405
+    from _ped import disk_new
47a405
+
47a405
+    peddisk = disk_new(device.getPedDevice())
47a405
+    return Disk(PedDisk=peddisk)
47a405
+
47a405
+@localeC
47a405
 def version():
47a405
     """Return a dict containing the pyparted and libparted versions."""
47a405
     from _ped import libparted_version
47a405
diff --git a/src/pydisk.c b/src/pydisk.c
47a405
index f58eeef..4e70f55 100644
47a405
--- a/src/pydisk.c
47a405
+++ b/src/pydisk.c
47a405
@@ -2004,5 +2004,37 @@ PyObject *py_ped_disk_new_fresh(PyObject *s, PyObject *args) {
47a405
     return (PyObject *) ret;
47a405
 }
47a405
 
47a405
+PyObject *py_ped_disk_new(PyObject *s, PyObject *args) {
47a405
+    _ped_Device *in_device = NULL;
47a405
+    PedDevice *device = NULL;
47a405
+    PedDisk *disk = NULL;
47a405
+    _ped_Disk *ret = NULL;
47a405
+
47a405
+    if (!PyArg_ParseTuple(args, "O!", &_ped_Device_Type_obj, &in_device)) {
47a405
+        return NULL;
47a405
+    }
47a405
+
47a405
+    if ((device = _ped_Device2PedDevice((PyObject *) in_device)) == NULL) {
47a405
+        return NULL;
47a405
+    }
47a405
+
47a405
+    if ((disk = ped_disk_new(device)) == NULL) {
47a405
+        if (partedExnRaised) {
47a405
+            partedExnRaised = 0;
47a405
+
47a405
+            if (!PyErr_ExceptionMatches(PartedException) &&
47a405
+                !PyErr_ExceptionMatches(PyExc_NotImplementedError))
47a405
+                PyErr_SetString(DiskException, partedExnMessage);
47a405
+        } else {
47a405
+            PyErr_Format(DiskException, "Could not create new disk label on %s", disk->dev->path);
47a405
+        }
47a405
+
47a405
+        return NULL;
47a405
+    }
47a405
+
47a405
+    ret = PedDisk2_ped_Disk(disk);
47a405
+    return (PyObject *) ret;
47a405
+}
47a405
+
47a405
 /* vim:tw=78:ts=4:et:sw=4
47a405
  */
47a405
-- 
47a405
1.8.1.2
47a405