All of lore.kernel.org
 help / color / mirror / Atom feed
From: Hannes Reinecke <hare@suse.de>
To: christophe varoqui <christophe.varoqui@free.fr>
Cc: device-mapper development <dm-devel@redhat.com>
Subject: [kpartx] add support for S/390 DASD
Date: Wed, 07 Dec 2005 15:08:05 +0100	[thread overview]
Message-ID: <4396ECC5.2090202@suse.de> (raw)

[-- Attachment #1: Type: text/plain, Size: 302 bytes --]

Hi Christophe,

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

Cheers,

Hannes
-- 
Dr. Hannes Reinecke			hare@suse.de
SuSE Linux Products GmbH		S390 & zSeries
Maxfeldstraße 5				+49 911 74053 688
90409 Nürnberg				http://www.suse.de

[-- Attachment #2: kpartx-dasd-support.patch --]
[-- Type: text/x-patch, Size: 3187 bytes --]

[kpartx] Add support for S/390 DASD partitions

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

Signed-off-by: Hannes Reinecke <hare@suse.de>

---
 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(-)

diff --git a/kpartx/Makefile b/kpartx/Makefile
--- a/kpartx/Makefile
+++ b/kpartx/Makefile
@@ -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
 
diff --git a/kpartx/devmapper.c b/kpartx/devmapper.c
--- a/kpartx/devmapper.c
+++ b/kpartx/devmapper.c
@@ -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;
+}
+
diff --git a/kpartx/devmapper.h b/kpartx/devmapper.h
--- a/kpartx/devmapper.h
+++ b/kpartx/devmapper.h
@@ -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);
diff --git a/kpartx/kpartx.c b/kpartx/kpartx.c
--- a/kpartx/kpartx.c
+++ b/kpartx/kpartx.c
@@ -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:";
diff --git a/kpartx/kpartx.h b/kpartx/kpartx.h
--- a/kpartx/kpartx.h
+++ b/kpartx/kpartx.h
@@ -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);
 

[-- Attachment #3: Type: text/plain, Size: 0 bytes --]



             reply	other threads:[~2005-12-07 14:08 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-12-07 14:08 Hannes Reinecke [this message]
2005-12-07 22:44 ` [kpartx] add support for S/390 DASD Christophe Varoqui
2005-12-09 11:48   ` [kpartx] Resend: " Hannes Reinecke
2005-12-07 23:03 ` [kpartx] " Christophe Varoqui
2005-12-07 23:12   ` Christophe Varoqui

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4396ECC5.2090202@suse.de \
    --to=hare@suse.de \
    --cc=christophe.varoqui@free.fr \
    --cc=dm-devel@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.