All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Jun'ichi Nomura" <j-nomura@ce.jp.nec.com>
To: dm-devel@redhat.com
Subject: [Patch] kpartx to accept device map name
Date: Mon, 16 May 2005 15:21:26 -0400	[thread overview]
Message-ID: <4288F2B6.9070808@ce.jp.nec.com> (raw)

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

Hello Christophe,

Attached patch adds '-m' option which makes kpartx
to accept device map name.

Using with the cvs version of libdevmapper or with the
patch suggested by Kiyoshi Ueda today, we don't need
to depend on asynchronous nature of hotplug when it's
not necessary.

For example, we can do this for initialization:
  multipath
  dmsetup info -c --noheadings -o name | xargs -l1 kpartx -a -m
otherwise we had to insert adhoc length of sleep to wait for
the completion of hotplug events.

Please consider to apply.

Thanks,
Jun'ichi Nomura


[-- Attachment #2: kpartx-mapname.patch --]
[-- Type: text/x-patch, Size: 1401 bytes --]

Index: kpartx/kpartx.c
===================================================================
--- e5bb12309df918f41b63a339fdc936f77241d332/kpartx/kpartx.c  (mode:100644)
+++ uncommitted/kpartx/kpartx.c  (mode:100644)
@@ -70,7 +70,7 @@
 	addpts("unixware", read_unixware_pt);
 }
 
-static char short_opts[] = "ladgvnp:t:";
+static char short_opts[] = "ladgvnp:t:m";
 
 /* Used in gpt.c */
 int force_gpt=0;
@@ -183,6 +183,7 @@
 	char * delim = NULL;
 	int loopro = 0;
 	int hotplug = 0;
+	int use_mapname = 0;
 	struct stat buf;
 
 	initpts();
@@ -245,12 +246,16 @@
 		case 'd':
 			what = DELETE;
 			break;
+		case 'm':
+			use_mapname = 1;
+			break;
 		default:
 			usage();
 			exit(1);
 	}
 
-	if (dm_prereq(DM_TARGET, 0, 0, 0) && (what == ADD || what == DELETE)) {
+	if (dm_prereq(DM_TARGET, 0, 0, 0)
+	    && (what == ADD || what == DELETE || use_mapname)) {
 		fprintf(stderr, "device mapper prerequisites not met\n"); 
 		exit(1);
 	}
@@ -267,6 +272,21 @@
 		exit(1);
 	}
 
+	if (use_mapname) {
+		int len;
+		char *realdev, *dmdir;
+
+		dmdir = dm_dir();
+		len = strlen(dmdir) + strlen(device) + 2;
+		realdev = malloc(sizeof(char) * len);
+		if (!realdev) {
+			printf("failed to alloc memory\n");
+			exit(1);
+		}
+		snprintf(realdev, len, "%s/%s", dmdir, device);
+		diskdevice = device = realdev;
+	}
+
 	if (stat(device, &buf)) {
 		printf("failed to stat() %s\n", device);
 		exit (1);

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



             reply	other threads:[~2005-05-16 19:21 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-05-16 19:21 Jun'ichi Nomura [this message]
2005-05-16 22:50 ` [Patch] kpartx to accept device map name christophe varoqui
2005-05-16 23:50   ` Jun'ichi Nomura

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=4288F2B6.9070808@ce.jp.nec.com \
    --to=j-nomura@ce.jp.nec.com \
    --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.