Skip to contentSkip to conversation

add support for S/390 DASD

kpartx Applied Hannes Reinecke 2 participants 5 messages Dec 7, 2005 – Dec 9, 2005 Device mapper

lore
Share & tools
lore
#0 lore raw

Hi Christophe,

this patch adds kpartx support for S/390 DASD partitions. Helpful when using multipath-tools on them.

Cheers,

Hannes

Signature · 4 lines
Dr. Hannes Reinecke			[email protected]
SuSE Linux Products GmbH		S390 & zSeries
Maxfeldstraße 5				+49 911 74053 688
90409 Nürnberg				http://www.suse.de

[kpartx] Add support for S/390 DASD partitions

As multipath-tools now supports S/390 DASDs there is no reason why kpartx should not.

---
 kpartx/Makefile    |    4 ++--
 kpartx/devmapper.c |   40 ++++++++++++++++++++++++++++++++++++++--
 kpartx/devmapper.h |    1 +
 kpartx/kpartx.c    |    1 +
 kpartx/kpartx.h    |    1 +
 5 files changed, 43 insertions(+), 4 deletions(-)
kpartx/Makefile +2 -2
@@ -10,11 +10,11 @@ CFLAGS = -pipe -g -Wall -Wunused -Wstric
 
 ifeq ($(strip $(BUILD)),klibc)
 	OBJS = bsd.o dos.o kpartx.o solaris.o unixware.o gpt.o crc32.o \
-	       lopart.o xstrncpy.o devmapper.o \
+	       lopart.o xstrncpy.o devmapper.o dasd.o \
 	       $(MULTIPATHLIB)-$(BUILD).a $(libdm)
 else
 	LDFLAGS = -ldevmapper
-	OBJS = bsd.o dos.o kpartx.o solaris.o unixware.o \
+	OBJS = bsd.o dos.o kpartx.o solaris.o unixware.o dasd.o \
 	       gpt.o crc32.o lopart.o xstrncpy.o devmapper.o
 endif
 
kpartx/devmapper.c +38 -2
@@ -123,7 +123,7 @@ const char *
 dm_mapname(int major, int minor)
 {
 	struct dm_task *dmt;
-	const char *mapname;
+	const char *mapname = NULL, *map;
 
 	if (!(dmt = dm_task_create(DM_DEVICE_INFO)))
 		return NULL;
@@ -135,9 +135,45 @@ dm_mapname(int major, int minor)
 	if (!dm_task_run(dmt))
 		goto out;
 
-	mapname = strdup(dm_task_get_name(dmt));
+	map = dm_task_get_name(dmt);
+	if (map && map[0] != '\0')
+		mapname = strdup(map);
+
 out:
 	dm_task_destroy(dmt);
 	return mapname;
 }
 
+/*
+ * dm_get_first_dep
+ *
+ * Return the device number of the first dependend device
+ * for a given target.
+ */
+dev_t dm_get_first_dep(char *devname)
+{
+	struct dm_task *dmt;
+	struct dm_deps *dm_deps;
+	dev_t ret = 0;
+
+	if ((dmt = dm_task_create(DM_DEVICE_DEPS)) == NULL) {
+		return ret;
+	}
+	if (!dm_task_set_name(dmt, devname)) {
+		goto out;
+	}
+	if (!dm_task_run(dmt)) {
+		goto out;
+	}
+	if ((dm_deps = dm_task_get_deps(dmt)) == NULL) {
+		goto out;
+	}
+	if (dm_deps->count > 0) {
+		ret = dm_deps->device[0];
+	}
+out:
+	dm_task_destroy(dmt);
+
+	return ret;
+}
+
kpartx/devmapper.h +1 -0
@@ -3,3 +3,4 @@ int dm_simplecmd (int, const char *);
 int dm_addmap (int, const char *, const char *, const char *, unsigned long);
 int dm_map_present (char *);
 const char * dm_mapname(int major, int minor);
+dev_t dm_get_first_dep(char *devname);
kpartx/kpartx.c +1 -0
@@ -77,6 +77,7 @@ initpts(void)
 	addpts("bsd", read_bsd_pt);
 	addpts("solaris", read_solaris_pt);
 	addpts("unixware", read_unixware_pt);
+	addpts("dasd", read_dasd_pt);
 }
 
 static char short_opts[] = "ladgvnp:t:";
kpartx/kpartx.h +1 -0
@@ -31,6 +31,7 @@ extern ptreader read_bsd_pt;
 extern ptreader read_solaris_pt;
 extern ptreader read_unixware_pt;
 extern ptreader read_gpt_pt;
+extern ptreader read_dasd_pt;
 
 char *getblock(int fd, unsigned int secnr);
 
#1 lore raw
Quoted 5 lines · Hannes Reinecke

Hi Christophe,

this patch adds kpartx support for S/390 DASD partitions. Helpful when using multipath-tools on them.

Looks promising.

Can you split the fix [1] from the rest and include the dasd.c you seem to have left out.

Regards,
cvaroqui

[1] this one :

-       mapname = strdup(dm_task_get_name(dmt));
+       map = dm_task_get_name(dmt);
+       if (map && map[0] != '\0')

+ mapname = strdup(map);
+

#3 lore raw
In reply to Hannes Reinecke
Quoted 5 lines · Hannes Reinecke

Hi Christophe,

this patch adds kpartx support for S/390 DASD partitions. Helpful when using multipath-tools on them.

Applied, thanks.

The way you bend DASD to the vendor/product scsi-ism is quite inventive :)

Regards,
cvaroqui

#4 lore raw
Quoted 11 lines · Christophe Varoqui
Quoted 5 lines · Hannes Reinecke

Hi Christophe,

this patch adds kpartx support for S/390 DASD partitions. Helpful when using multipath-tools on them.

Applied, thanks.

The way you bend DASD to the vendor/product scsi-ism is quite inventive :)

Oops, this reply applied to this mail from you :
"[PATCH] S/390 DASD support for multipath-tools"

Sorry,
cvaroqui

#2 lore raw

[kpartx] Resend: add support for S/390 DASD

In reply to Christophe Varoqui
Quoted 11 lines · Christophe Varoqui
Quoted 5 lines · Hannes Reinecke

Hi Christophe,

this patch adds kpartx support for S/390 DASD partitions. Helpful when using multipath-tools on them.

Looks promising.

Can you split the fix [1] from the rest and include the dasd.c you seem to have left out.

Errm. Of course.
Here is it.

The fix [1] is already sent (check for 'fix mapname length').

Cheers,

Hannes

Signature · 4 lines
Dr. Hannes Reinecke			[email protected]
SuSE Linux Products GmbH		S390 & zSeries
Maxfeldstraße 5				+49 911 74053 688
90409 Nürnberg				http://www.suse.de

[kpartx] Add suport for S/390 ECKD DASD

This patch adds support for S/390 ECKD DASD partition tables.

kpartx/Makefile +2 -2
@@ -10,11 +10,11 @@ CFLAGS = -pipe -g -Wall -Wunused -Wstric
 
 ifeq ($(strip $(BUILD)),klibc)
 	OBJS = bsd.o dos.o kpartx.o solaris.o unixware.o gpt.o crc32.o \
-	       lopart.o xstrncpy.o devmapper.o \
+	       lopart.o xstrncpy.o devmapper.o dasd.o \
 	       $(MULTIPATHLIB)-$(BUILD).a $(libdm)
 else
 	LDFLAGS = -ldevmapper
-	OBJS = bsd.o dos.o kpartx.o solaris.o unixware.o \
+	OBJS = bsd.o dos.o kpartx.o solaris.o unixware.o dasd.o \
 	       gpt.o crc32.o lopart.o xstrncpy.o devmapper.o
 endif
 
kpartx/dasd.c new file +240 -0

240 lines not on this page · raw message

kpartx/dasd.h new file +272 -0

272 lines not on this page · raw message

kpartx/devmapper.c +33 -0
@@ -144,3 +144,36 @@ out:
 	return mapname;
 }
 
+/*
+ * dm_get_first_dep
+ *
+ * Return the device number of the first dependend device
+ * for a given target.
+ */
+dev_t dm_get_first_dep(char *devname)
+{
+	struct dm_task *dmt;
+	struct dm_deps *dm_deps;
+	dev_t ret = 0;
+
+	if ((dmt = dm_task_create(DM_DEVICE_DEPS)) == NULL) {
+		return ret;
+	}
+	if (!dm_task_set_name(dmt, devname)) {
+		goto out;
+	}
+	if (!dm_task_run(dmt)) {
+		goto out;
+	}
+	if ((dm_deps = dm_task_get_deps(dmt)) == NULL) {
+		goto out;
+	}
+	if (dm_deps->count > 0) {
+		ret = dm_deps->device[0];
+	}
+out:
+	dm_task_destroy(dmt);
+
+	return ret;
+}
+
kpartx/devmapper.h +1 -0
@@ -3,3 +3,4 @@ int dm_simplecmd (int, const char *);
 int dm_addmap (int, const char *, const char *, const char *, unsigned long);
 int dm_map_present (char *);
 const char * dm_mapname(int major, int minor);
+dev_t dm_get_first_dep(char *devname);
kpartx/kpartx.c +1 -0
@@ -77,6 +77,7 @@ initpts(void)
 	addpts("bsd", read_bsd_pt);
 	addpts("solaris", read_solaris_pt);
 	addpts("unixware", read_unixware_pt);
+	addpts("dasd", read_dasd_pt);
 }
 
 static char short_opts[] = "ladgvnp:t:";
kpartx/kpartx.h +1 -0
@@ -31,6 +31,7 @@ extern ptreader read_bsd_pt;
 extern ptreader read_solaris_pt;
 extern ptreader read_unixware_pt;
 extern ptreader read_gpt_pt;
+extern ptreader read_dasd_pt;
 
 char *getblock(int fd, unsigned int secnr);