[rhel6-branch] Fix detection of unformatted and LDL DASDs. (#1144979)

Samantha N. Bueno sbueno+anaconda at redhat.com
Mon Mar 2 16:12:39 UTC 2015


The isLdlDasd function was not properly netting all LDL DASDs that were
available to a system. This cleans up some unnecessary code in isLdlDasd
and makes it a bit simpler by just checking dasd_info.format to see
whether it's CDL; anything else we can run dasdfmt on.

Resolves: rhbz#1144979
---
 isys/dasd.c  | 38 +++++++-------------------------------
 isys/isys.c  |  9 ---------
 isys/isys.py |  3 ---
 3 files changed, 7 insertions(+), 43 deletions(-)

diff --git a/isys/dasd.c b/isys/dasd.c
index 726281a..676bf21 100644
--- a/isys/dasd.c
+++ b/isys/dasd.c
@@ -39,9 +39,8 @@
 #include <asm/dasd.h>
 #endif
 
-#if defined(__s390__) || defined(__s390x__)
 /* s390 stuff to detect DASDs */
-static int read_vlabel(dasd_information_t *dasd_info, int fd, int blksize,
+static int read_vlabel(dasd_information2_t *dasd_info, int fd, int blksize,
                        volume_label_t *vlabel) {
     int rc;
     unsigned long vlabel_start = dasd_info->label_block * blksize;
@@ -59,18 +58,14 @@ static int read_vlabel(dasd_information_t *dasd_info, int fd, int blksize,
 
     return 0;
 }
-#endif
 
-int isUsableDasd(char *device) {
+int isLdlDasd(char *device) {
 #if !defined(__s390__) && !defined(__s390x__)
     return 0;
 #else
     char devname[16];
-    char label[5], v4_hex[9];
-    char l4ebcdic_hex[] = "d3d5e7f1";  /* LNX1 */
-    char cms1_hex[] = "c3d4e2f1";      /* CMS1 */
     int f, ret, blksize;
-    dasd_information_t dasd_info;
+    dasd_information2_t dasd_info;
     volume_label_t vlabel;
 
     memset(&dasd_info, 0, sizeof(dasd_info));
@@ -85,42 +80,23 @@ int isUsableDasd(char *device) {
         return 0;
     }
 
-    if (ioctl(f, BIODASDINFO, &dasd_info) != 0) {
+    if (ioctl(f, BIODASDINFO2, &dasd_info) != 0) {
         close(f);
         return 0;
     }
 
     ret = read_vlabel(&dasd_info, f, blksize, &vlabel);
     close(f);
-
     if (ret == 2)
         return 0;
-    else if (ret == 1) /* probably unformatted DASD */
-        return 1;
-
-    memset(label, 0, 5);
-    memset(v4_hex, 0, 9);
-    strncpy(label, vlabel.volkey, 4);
 
-    ret = sprintf(v4_hex, "%02x%02x%02x%02x", label[0], label[1],
-                                              label[2], label[3]);
-    if (ret < 0 || ret < strlen(cms1_hex))
-        return 3;
-        
-    if (!strncmp(v4_hex, cms1_hex, 9))
+    if (dasd_info.format == DASD_FORMAT_CDL) /* VOL1, CDL */
         return 0;
-
-    if (!strncmp(v4_hex, l4ebcdic_hex, 9))
-        return 2;
-
-    return 1;
+    else
+        return 1;
 #endif
 }
 
-int isLdlDasd(char * device) {
-    return (isUsableDasd(device) == 2);
-}
-
 char *getDasdPorts() {
 #if !defined(__s390__) && !defined(__s390x__)
     return 0;
diff --git a/isys/isys.c b/isys/isys.c
index a273751..fb3f583 100644
--- a/isys/isys.c
+++ b/isys/isys.c
@@ -103,7 +103,6 @@ static PyObject * doisIsoImage(PyObject * s, PyObject * args);
 static PyObject * printObject(PyObject * s, PyObject * args);
 static PyObject * py_bind_textdomain_codeset(PyObject * o, PyObject * args);
 static PyObject * py_getDasdPorts(PyObject * s, PyObject * args);
-static PyObject * py_isUsableDasd(PyObject * s, PyObject * args);
 static PyObject * py_isLdlDasd(PyObject * s, PyObject * args);
 static PyObject * doSegvHandler(PyObject *s, PyObject *args);
 static PyObject * doAuditDaemon(PyObject *s);
@@ -136,7 +135,6 @@ static PyMethodDef isysModuleMethods[] = {
     { "printObject", (PyCFunction) printObject, METH_VARARGS, NULL},
     { "bind_textdomain_codeset", (PyCFunction) py_bind_textdomain_codeset, METH_VARARGS, NULL},
     { "getDasdPorts", (PyCFunction) py_getDasdPorts, METH_VARARGS, NULL},
-    { "isUsableDasd", (PyCFunction) py_isUsableDasd, METH_VARARGS, NULL},
     { "isLdlDasd", (PyCFunction) py_isLdlDasd, METH_VARARGS, NULL},
     { "handleSegv", (PyCFunction) doSegvHandler, METH_VARARGS, NULL },
     { "auditdaemon", (PyCFunction) doAuditDaemon, METH_NOARGS, NULL },
@@ -554,13 +552,6 @@ static PyObject * py_getDasdPorts(PyObject * o, PyObject * args) {
     return Py_BuildValue("s", getDasdPorts());
 }
 
-static PyObject * py_isUsableDasd(PyObject * o, PyObject * args) {
-    char *devname;
-    if (!PyArg_ParseTuple(args, "s", &devname))
-	return NULL;
-    return Py_BuildValue("i", isUsableDasd(devname));
-}
-
 static PyObject * py_isLdlDasd(PyObject * o, PyObject * args) {
     char *devname;
     if (!PyArg_ParseTuple(args, "s", &devname))
diff --git a/isys/isys.py b/isys/isys.py
index 078e53e..5bf5793 100755
--- a/isys/isys.py
+++ b/isys/isys.py
@@ -199,9 +199,6 @@ def loadKeymap(keymap):
 def getDasdPorts():
     return _isys.getDasdPorts()
 
-def isUsableDasd(device):
-    return _isys.isUsableDasd(device)
-
 def isLdlDasd(device):
     return _isys.isLdlDasd(device)
 
-- 
1.9.3



More information about the anaconda-patches mailing list