pvcreate: don't support unpartitioned DASD devices with CDL formatted

The former patch(dab3ebce4c7) is a little bit strict. For example, it is
OK to create PV on unpartitioned DASD devices with LDL formatted. So
after lvm version containing the patch, LVs created on those devices
could not be found.

Signed-off-by: Lidong Zhong <lzhong@suse.com>
References: bnc#948859#946217

---
Index: LVM2.2.02.98/lib/device/dev-dasd.c
===================================================================
--- /dev/null
+++ LVM2.2.02.98/lib/device/dev-dasd.c
@@ -0,0 +1,74 @@
+/*
+ * Copyright (C) 2010 Red Hat, Inc. All rights reserved.
+ *
+ * This file is part of LVM2.
+ *
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License v.2.1.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+
+#include "lib.h"
+#include "metadata.h"
+#include <sys/ioctl.h>
+
+
+typedef struct dasd_information_t {
+	unsigned int devno;         /* S/390 devno */
+	unsigned int real_devno;    /* for aliases */
+	unsigned int schid;         /* S/390 subchannel identifier */
+	unsigned int cu_type  : 16; /* from SenseID */
+	unsigned int cu_model :  8; /* from SenseID */
+	unsigned int dev_type : 16; /* from SenseID */
+	unsigned int dev_model : 8; /* from SenseID */
+	unsigned int open_count;
+	unsigned int req_queue_len;
+	unsigned int chanq_len;     /* length of chanq */
+	char type[4];               /* from discipline.name, 'none' for unknown */
+	unsigned int status;        /* current device level */
+	unsigned int label_block;   /* where to find the VOLSER */
+	unsigned int FBA_layout;    /* fixed block size (like AIXVOL) */
+	unsigned int characteristics_size;
+	unsigned int confdata_size;
+	unsigned char characteristics[64];/*from read_device_characteristics */
+	unsigned char configuration_data[256];/*from read_configuration_data */
+	unsigned int format;          /* format info like formatted/cdl/ldl/... */
+	unsigned int features;        /* dasd features like 'ro',...            */
+	unsigned int reserved0;       /* reserved for further use ,...          */
+	unsigned int reserved1;       /* reserved for further use ,...          */
+	unsigned int reserved2;       /* reserved for further use ,...          */
+	unsigned int reserved3;       /* reserved for further use ,...          */
+	unsigned int reserved4;       /* reserved for further use ,...          */
+	unsigned int reserved5;       /* reserved for further use ,...          */
+	unsigned int reserved6;       /* reserved for further use ,...          */
+	unsigned int reserved7;       /* reserved for further use ,...          */
+} dasd_information_t;
+
+#define DASD_FORMAT_CDL 2
+#define BIODASDINFO2  _IOR('D',3,dasd_information_t)
+
+int dasd_is_cdl_formatted(struct device *dev)
+{
+	int ret = 0;
+	dasd_information_t dasd_info;
+
+	if (!dev_open_readonly(dev)) {
+		stack;
+		return ret;
+	}
+
+	if (ioctl(dev->fd, BIODASDINFO2, &dasd_info) != 0)
+		goto_out;
+
+	if (dasd_info.format == DASD_FORMAT_CDL)
+		ret = 1;
+
+out:
+	if (!dev_close(dev))
+		stack;
+	return ret;
+}
Index: LVM2.2.02.98/lib/device/device.c
===================================================================
--- LVM2.2.02.98.orig/lib/device/device.c
+++ LVM2.2.02.98/lib/device/device.c
@@ -93,7 +93,7 @@ int is_partitioned_dev(struct device *de
 		return 0;
 
 	/*Unpartitioned DASD devices are not supported*/
-	if (MAJOR(dev->dev) == dasd_major())
+	if ((MAJOR(dev->dev) == dasd_major()) && dasd_is_cdl_formatted(dev))
 		return 1;
 
 	return _has_partition_table(dev);
Index: LVM2.2.02.98/lib/device/device.h
===================================================================
--- LVM2.2.02.98.orig/lib/device/device.h
+++ LVM2.2.02.98/lib/device/device.h
@@ -103,6 +103,7 @@ const char *dev_name_confirmed(struct de
 int dev_is_md(struct device *dev, uint64_t *sb);
 int dev_is_swap(struct device *dev, uint64_t *signature);
 int dev_is_luks(struct device *dev, uint64_t *signature);
+int dasd_is_cdl_formatted(struct device *dev);
 unsigned long dev_md_stripe_width(const char *sysfs_dir, struct device *dev);
 
 int is_partitioned_dev(struct device *dev);
Index: LVM2.2.02.98/lib/Makefile.in
===================================================================
--- LVM2.2.02.98.orig/lib/Makefile.in
+++ LVM2.2.02.98/lib/Makefile.in
@@ -56,6 +56,7 @@ SOURCES =\
 	device/dev-md.c \
 	device/dev-swap.c \
 	device/dev-luks.c \
+	device/dev-dasd.c \
 	device/device.c \
 	display/display.c \
 	error/errseg.c \
