packages: multipath-tools/multipath-tools-git.patch, multipath-tools/multip...

baggins baggins at pld-linux.org
Tue Apr 3 19:21:46 CEST 2012


Author: baggins                      Date: Tue Apr  3 17:21:46 2012 GMT
Module: packages                      Tag: HEAD
---- Log message:
- rel 7
- updated to current git

---- Files affected:
packages/multipath-tools:
   multipath-tools-git.patch (1.2 -> 1.3) , multipath-tools-kpartx-udev.patch (1.3 -> 1.4) , multipath-tools.spec (1.75 -> 1.76) 

---- Diffs:

================================================================
Index: packages/multipath-tools/multipath-tools-git.patch
diff -u packages/multipath-tools/multipath-tools-git.patch:1.2 packages/multipath-tools/multipath-tools-git.patch:1.3
--- packages/multipath-tools/multipath-tools-git.patch:1.2	Tue Feb  8 11:44:29 2011
+++ packages/multipath-tools/multipath-tools-git.patch	Tue Apr  3 19:21:40 2012
@@ -1,8 +1,81 @@
+diff --git a/Makefile b/Makefile
+index d0063d0..5b0c61a 100644
+--- a/Makefile
++++ b/Makefile
+@@ -23,8 +23,10 @@ BUILDDIRS = \
+ 	libmultipath \
+ 	libmultipath/prioritizers \
+ 	libmultipath/checkers \
++	libmpathpersist \
+ 	multipath \
+ 	multipathd \
++	mpathpersist \
+ 	kpartx
+ 
+ ifeq   ($(MULTIPATH_VERSION),)
+diff --git a/Makefile.inc b/Makefile.inc
+index dbcbc3b..02aef4f 100644
+--- a/Makefile.inc
++++ b/Makefile.inc
+@@ -28,9 +28,12 @@ libudevdir  = ${prefix}/lib/udev
+ multipathdir = $(TOPDIR)/libmultipath
+ mandir      = $(prefix)/usr/share/man/man8
+ man5dir     = $(prefix)/usr/share/man/man5
++man3dir      = $(prefix)/usr/share/man/man3
+ rcdir	    = $(prefix)/etc/init.d
+ syslibdir   = $(prefix)/$(LIB)
+ libdir	    = $(prefix)/$(LIB)/multipath
++unitdir     = $(prefix)/lib/systemd/system
++mpathpersistdir = $(TOPDIR)/libmpathpersist
+ 
+ GZIP        = /bin/gzip -9 -c
+ INSTALL_PROGRAM = install
+diff --git a/kpartx/Makefile b/kpartx/Makefile
+index e1e9651..1287053 100644
+--- a/kpartx/Makefile
++++ b/kpartx/Makefile
+@@ -6,6 +6,12 @@ include ../Makefile.inc
+ 
+ CFLAGS += -I. -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64
+ 
++LIBDM_API_COOKIE = $(shell grep -Ecs '^[a-z]*[[:space:]]+dm_task_set_cookie' /usr/include/libdevmapper.h)
++
++ifneq ($(strip $(LIBDM_API_COOKIE)),0)
++	CFLAGS += -DLIBDM_API_COOKIE
++endif
++
+ LDFLAGS = -ldevmapper
+ OBJS = bsd.o dos.o kpartx.o solaris.o unixware.o dasd.o sun.o \
+        gpt.o mac.o crc32.o lopart.o xstrncpy.o devmapper.o
+@@ -16,7 +22,7 @@ all: $(EXEC)
+ $(EXEC): $(OBJS)
+ 	$(CC) $(OBJS) -o $(EXEC) $(LDFLAGS)
+ 	$(GZIP) $(EXEC).8 > $(EXEC).8.gz
+-	
++
+ install: $(EXEC) $(EXEC).8
+ 	$(INSTALL_PROGRAM) -d $(DESTDIR)$(bindir)
+ 	$(INSTALL_PROGRAM) -m 755 $(EXEC) $(DESTDIR)$(bindir)
 diff --git a/kpartx/devmapper.c b/kpartx/devmapper.c
-index f884511..7ebc5b6 100644
+index f884511..4baebd9 100644
 --- a/kpartx/devmapper.c
 +++ b/kpartx/devmapper.c
-@@ -81,7 +81,7 @@ dm_simplecmd (int task, const char *name, int no_flush, uint32_t *cookie) {
+@@ -12,6 +12,14 @@
+ 
+ #define UUID_PREFIX "part%d-"
+ #define MAX_PREFIX_LEN 8
++#define PARAMS_SIZE 1024
++
++#ifndef LIBDM_API_COOKIE
++static inline int dm_task_set_cookie(struct dm_task *dmt, uint32_t *c, int a)
++{
++	return 1;
++}
++#endif
+ 
+ extern int
+ dm_prereq (char * str, int x, int y, int z)
+@@ -81,7 +89,7 @@ dm_simplecmd (int task, const char *name, int no_flush, uint32_t *cookie) {
  
  extern int
  dm_addmap (int task, const char *name, const char *target,
@@ -11,7 +84,7 @@
  	   mode_t mode, uid_t uid, gid_t gid, uint32_t *cookie) {
  	int r = 0;
  	struct dm_task *dmt;
-@@ -96,6 +96,9 @@ dm_addmap (int task, const char *name, const char *target,
+@@ -96,6 +104,9 @@ dm_addmap (int task, const char *name, const char *target,
  	if (!dm_task_add_target (dmt, 0, size, target, params))
  		goto addout;
  
@@ -21,11 +94,74 @@
  	if (task == DM_DEVICE_CREATE && uuid) {
  		prefixed_uuid = malloc(MAX_PREFIX_LEN + strlen(uuid) + 1);
  		if (!prefixed_uuid) {
+@@ -268,3 +279,62 @@ out:
+ 	return r;
+ }
+ 
++int
++dm_get_map(int major, int minor, char * outparams)
++{
++	int r = 1;
++	struct dm_task *dmt;
++	void *next = NULL;
++	uint64_t start, length;
++	char *target_type = NULL;
++	char *params = NULL;
++
++	if (!(dmt = dm_task_create(DM_DEVICE_TABLE)))
++		return 1;
++
++	dm_task_set_major(dmt, major);
++	dm_task_set_minor(dmt, minor);
++	dm_task_no_open_count(dmt);
++
++	if (!dm_task_run(dmt))
++		goto out;
++
++	/* Fetch 1st target */
++	next = dm_get_next_target(dmt, next, &start, &length,
++				  &target_type, &params);
++
++	if (snprintf(outparams, PARAMS_SIZE, "%s", params) <= PARAMS_SIZE)
++		r = 0;
++out:
++	dm_task_destroy(dmt);
++	return r;
++}
++
++#define FEATURE_NO_PART "no_partitions"
++
++int
++dm_no_partitions(int major, int minor)
++{
++	char params[PARAMS_SIZE], *ptr;
++	int i, num_features;
++
++	if (dm_get_map(major, minor, params))
++		return 0;
++
++	ptr = params;
++	num_features = strtoul(params, &ptr, 10);
++	if ((ptr == params) || num_features == 0) {
++		/* No features found, return success */
++		return 0;
++	}
++	for (i = 0; (i < num_features); i++) {
++		if (!ptr || ptr > params + strlen(params))
++			break;
++		/* Skip whitespaces */
++		while(ptr && *ptr == ' ') ptr++;
++		if (!strncmp(ptr, FEATURE_NO_PART, strlen(FEATURE_NO_PART)))
++			return 1;
++		ptr = strchr(ptr, ' ');
++	}
++	return 0;
++}
 diff --git a/kpartx/devmapper.h b/kpartx/devmapper.h
-index f8692cc..6226129 100644
+index f8692cc..8e350a0 100644
 --- a/kpartx/devmapper.h
 +++ b/kpartx/devmapper.h
-@@ -5,7 +5,7 @@
+@@ -5,9 +5,10 @@
  int dm_prereq (char *, int, int, int);
  int dm_simplecmd (int, const char *, int, uint32_t *);
  int dm_addmap (int, const char *, const char *, const char *, uint64_t,
@@ -34,47 +170,250 @@
  int dm_map_present (char *);
  char * dm_mapname(int major, int minor);
  dev_t dm_get_first_dep(char *devname);
+ char * dm_mapuuid(int major, int minor);
+ int dm_devn (char * mapname, int *major, int *minor);
++int dm_no_partitions(int major, int minor);
+diff --git a/kpartx/gpt.c b/kpartx/gpt.c
+index 047a829..3082cae 100644
+--- a/kpartx/gpt.c
++++ b/kpartx/gpt.c
+@@ -358,6 +358,24 @@ is_gpt_valid(int fd, uint64_t lba,
+ 		return 0;
+ 	}
+ 
++	/* Check that sizeof_partition_entry has the correct value */
++	if (__le32_to_cpu((*gpt)->sizeof_partition_entry) != sizeof(gpt_entry)) {
++		// printf("GUID partition entry size check failed.\n");
++		free(*gpt);
++		*gpt = NULL;
++		return 0;
++	}
++
++
++	/* Check that sizeof_partition_entry has the correct value */
++	if (__le32_to_cpu((*gpt)->sizeof_partition_entry) != sizeof(gpt_entry)) {
++		// printf("GUID partition entry size check failed.\n");
++		free(*gpt);
++		*gpt = NULL;
++		return 0;
++	}
++
++
+ 	if (!(*ptes = alloc_read_gpt_entries(fd, *gpt))) {
+ 		free(*gpt);
+ 		*gpt = NULL;
+diff --git a/kpartx/kpartx.8 b/kpartx/kpartx.8
+index 923be1e..8a37d4f 100644
+--- a/kpartx/kpartx.8
++++ b/kpartx/kpartx.8
+@@ -17,20 +17,52 @@ creation and deletion.
+ .B \-a
+ Add partition mappings
+ .TP
++.B \-r
++Readonly partition mappings
++.TP
+ .B \-d
+ Delete partition mappings
+ .TP
++.B \-u
++Update partition mappings
++.TP
+ .B \-l
+ List partition mappings that would be added -a
+ .TP
+ .B \-p
+ set device name-partition number delimiter
+ .TP
++.B \-f
++force creation of mappings; overrides 'no_partitions' feature
++.TP
+ .B \-g
+ force GUID partition table (GPT)
+ .TP
+ .B \-v
+ Operate verbosely
++.TP
++.B \-s
++Sync mode. Don't return until the partitions are created
++.SH EXAMPLE
++To mount all the partitions in a raw disk image:
++.IP
++kpartx -av disk.img
++.PP
++This will output lines such as:
++.IP
++loop3p1 : 0 20964762 /dev/loop3 63
++.PP
++The 
++.I loop3p1
++is the name of a device file under 
++.I /dev/mapper
++which you can use to access the partition, for example to fsck it:
++.IP
++fsck /dev/mapper/loop3p1
++.PP
++When you're done, you need to remove the devices:
++.IP
++kpartx -d disk.img
+ .SH "SEE ALSO"
+ .BR multipath (8)
+ .BR multipathd (8)
 diff --git a/kpartx/kpartx.c b/kpartx/kpartx.c
-index 3d33990..f518aa0 100644
+index 3d33990..b5e0a32 100644
 --- a/kpartx/kpartx.c
 +++ b/kpartx/kpartx.c
-@@ -82,7 +82,7 @@ initpts(void)
+@@ -48,7 +48,7 @@
+ 
+ struct slice slices[MAXSLICES];
+ 
+-enum action { LIST, ADD, DELETE };
++enum action { LIST, ADD, DELETE, UPDATE };
+ 
+ struct pt {
+ 	char *type;
+@@ -82,19 +82,24 @@ initpts(void)
  	addpts("sun", read_sun_pt);
  }
  
 -static char short_opts[] = "ladgvp:t:s";
-+static char short_opts[] = "rladgvp:t:s";
++static char short_opts[] = "rladfgvp:t:su";
  
  /* Used in gpt.c */
  int force_gpt=0;
-@@ -91,6 +91,7 @@ static int
+ 
++int force_devmap=0;
++
+ static int
  usage(void) {
- 	printf("usage : kpartx [-a|-d|-l] [-v] wholedisk\n");
+-	printf("usage : kpartx [-a|-d|-l] [-v] wholedisk\n");
++	printf("usage : kpartx [-a|-d|-l] [-f] [-v] wholedisk\n");
  	printf("\t-a add partition devmappings\n");
 +	printf("\t-r devmappings will be readonly\n");
  	printf("\t-d del partition devmappings\n");
++	printf("\t-u update partition devmappings\n");
  	printf("\t-l list partitions devmappings that would be added by -a\n");
  	printf("\t-p set device name-partition number delimiter\n");
-@@ -185,7 +186,7 @@ get_hotplug_device(void)
+ 	printf("\t-g force GUID partition table (GPT)\n");
++	printf("\t-f force devmap create\n");
+ 	printf("\t-v verbose\n");
+ 	printf("\t-s sync mode. Don't return until the partitions are created\n");
+ 	return 1;
+@@ -185,7 +190,8 @@ get_hotplug_device(void)
  
  int
  main(int argc, char **argv){
 -	int fd, i, j, m, n, op, off, arg, c, d;
-+	int fd, i, j, m, n, op, off, arg, c, d, ro=0;
++	int i, j, m, n, op, off, arg, c, d, ro=0;
++	int fd = -1;
  	struct slice all;
  	struct pt *ptp;
  	enum action what = LIST;
-@@ -233,6 +234,9 @@ main(int argc, char **argv){
+@@ -233,6 +239,12 @@ main(int argc, char **argv){
  	}
  
  	while ((arg = getopt(argc, argv, short_opts)) != EOF) switch(arg) {
 +		case 'r':
 +			ro=1;
 +			break;
++		case 'f':
++			force_devmap=1;
++			break;
  		case 'g':
  			force_gpt=1;
  			break;
-@@ -470,7 +474,7 @@ main(int argc, char **argv){
+@@ -257,15 +269,20 @@ main(int argc, char **argv){
+ 		case 's':
+ 			sync = 1;
+ 			break;
++		case 'u':
++			what = UPDATE;
++			break;
+ 		default:
+ 			usage();
+ 			exit(1);
+ 	}
+ 
++#ifdef LIBDM_API_COOKIE
+ 	if (!sync)
+ 		dm_udev_set_sync_support(0);
++#endif
+ 
+-	if (dm_prereq(DM_TARGET, 0, 0, 0) && (what == ADD || what == DELETE)) {
++	if (dm_prereq(DM_TARGET, 0, 0, 0) && (what == ADD || what == DELETE || what == UPDATE)) {
+ 		fprintf(stderr, "device mapper prerequisites not met\n");
+ 		exit(1);
+ 	}
+@@ -306,12 +323,6 @@ main(int argc, char **argv){
+ 		device = loopdev;
+ 	}
+ 
+-	if (delim == NULL) {
+-		delim = malloc(DELIM_SIZE);
+-		memset(delim, 0, DELIM_SIZE);
+-		set_delimiter(device, delim);
+-	}
+-
+ 	off = find_devname_offset(device);
+ 
+ 	if (!loopdev) {
+@@ -326,6 +337,18 @@ main(int argc, char **argv){
+ 
+ 	if (!mapname)
+ 		mapname = device + off;
++	else if (!force_devmap &&
++		 dm_no_partitions((unsigned int)MAJOR(buf.st_rdev),
++				  (unsigned int)MINOR(buf.st_rdev))) {
++		/* Feature 'no_partitions' is set, return */
++		return 0;
++	}
++
++	if (delim == NULL) {
++		delim = malloc(DELIM_SIZE);
++		memset(delim, 0, DELIM_SIZE);
++		set_delimiter(device, delim);
++	}
+ 
+ 	fd = open(device, O_RDONLY);
+ 
+@@ -350,8 +373,10 @@ main(int argc, char **argv){
+ 			printf("%s: %d slices\n", ptp->type, n);
+ #endif
+ 
+-		if (n > 0)
++		if (n > 0) {
+ 			close(fd);
++			fd = -1;
++		}
+ 		else
+ 			continue;
+ 
+@@ -399,15 +424,6 @@ main(int argc, char **argv){
+ 					break;
+ 			}
+ 
+-			if (loopcreated && S_ISREG (buf.st_mode)) {
+-				if (del_loop(device)) {
+-					if (verbose)
+-						printf("can't del loop : %s\n",
+-							device);
+-					exit(1);
+-				}
+-				printf("loop deleted : %s\n", device);
+-			}
+ 			break;
+ 
+ 		case DELETE:
+@@ -443,6 +459,8 @@ main(int argc, char **argv){
+ 			break;
+ 
+ 		case ADD:
++		case UPDATE:
++			/* ADD and UPDATE share the same code that adds new partitions. */
+ 			for (j = 0, c = 0; j < n; j++) {
+ 				if (slices[j].size == 0)
+ 					continue;
+@@ -470,7 +488,7 @@ main(int argc, char **argv){
  					DM_DEVICE_RELOAD : DM_DEVICE_CREATE);
  
  				if (!dm_addmap(op, partname, DM_TARGET, params,
@@ -83,7 +422,7 @@
  					       buf.st_mode & 0777, buf.st_uid,
  					       buf.st_gid, &cookie)) {
  					fprintf(stderr, "create/reload failed on %s\n",
-@@ -536,7 +540,7 @@ main(int argc, char **argv){
+@@ -536,7 +554,7 @@ main(int argc, char **argv){
  					      DM_DEVICE_RELOAD : DM_DEVICE_CREATE);
  
  					dm_addmap(op, partname, DM_TARGET, params,
@@ -92,1885 +431,7302 @@
  						  buf.st_mode & 0777,
  						  buf.st_uid, buf.st_gid,
  						  &cookie);
-diff --git a/libmultipath/Makefile b/libmultipath/Makefile
-index 203833d..c07b073 100644
---- a/libmultipath/Makefile
-+++ b/libmultipath/Makefile
-@@ -26,7 +26,7 @@ endif
- all: $(LIBS)
- 
- $(LIBS): $(OBJS)
--	$(CC) $(SHARED_FLAGS) $(LIBDEPS) -Wl,-soname=$@ $(CFLAGS) -o $@ $(OBJS)
-+	$(CC) $(LDFLAGS) $(SHARED_FLAGS) -Wl,-soname=$@ $(CFLAGS) -o $@ $(OBJS) $(LIBDEPS)
- 	ln -sf $@ $(DEVLIB)
- 
- install:
-diff --git a/libmultipath/alias.c b/libmultipath/alias.c
-index 95506b4..4159ec6 100644
---- a/libmultipath/alias.c
-+++ b/libmultipath/alias.c
-@@ -180,34 +180,35 @@ fail:
- }
- 
- static int
--format_devname(char *name, int id, int len)
-+format_devname(char *name, int id, int len, char *prefix)
- {
- 	int pos;
-+	int prefix_len = strlen(prefix);
+@@ -559,7 +577,31 @@ main(int argc, char **argv){
+ 				if (d == c)
+ 					break;
+ 			}
+-			break;
++
++			if (what == ADD) {
++				/* Skip code that removes devmappings for deleted partitions */
++				break;
++			}
++
++			for (j = MAXSLICES-1; j >= 0; j--) {
++				if (safe_sprintf(partname, "%s%s%d",
++					     mapname, delim, j+1)) {
++					fprintf(stderr, "partname too small\n");
++					exit(1);
++				}
++				strip_slash(partname);
++
++				if (slices[j].size || !dm_map_present(partname))
++					continue;
++
++				if (!dm_simplecmd(DM_DEVICE_REMOVE,
++						  partname, 1, &cookie)) {
++					r++;
++					continue;
++				}
++				if (verbose)
++					printf("del devmap : %s\n", partname);
++			}
  
- 	memset(name,0, len);
--	strcpy(name,"mpath");
--	for (pos = len - 1; pos >= 5; pos--) {
-+	strcpy(name, prefix);
-+	for (pos = len - 1; pos >= prefix_len; pos--) {
- 		name[pos] = 'a' + id % 26;
- 		if (id < 26)
+ 		default:
+ 			break;
+@@ -568,7 +610,20 @@ main(int argc, char **argv){
+ 		if (n > 0)
  			break;
- 		id /= 26;
- 		id--;
- 	}
--	memmove(name + 5, name + pos, len - pos);
--	name[5 + len - pos] = '\0';
--	return (5 + len - pos);
-+	memmove(name + prefix_len, name + pos, len - pos);
-+	name[prefix_len + len - pos] = '\0';
-+	return (prefix_len + len - pos);
- }
- 
- static int
--scan_devname(char *alias)
-+scan_devname(char *alias, char *prefix)
- {
- 	char *c;
- 	int i, n = 0;
- 
--	if (strncmp(alias, "mpath", 5))
-+	if (!prefix || strncmp(alias, prefix, strlen(prefix)))
- 		return -1;
- 
--	c = alias + 5;
-+	c = alias + strlen(prefix);
- 	while (*c != '\0' && *c != ' ' && *c != '\t') {
- 		i = *c - 'a';
- 		n = ( n * 26 ) + i;
-@@ -221,7 +222,7 @@ scan_devname(char *alias)
- }
- 
- static int
--lookup_binding(FILE *f, char *map_wwid, char **map_alias)
-+lookup_binding(FILE *f, char *map_wwid, char **map_alias, char *prefix)
- {
- 	char buf[LINE_MAX];
- 	unsigned int line_nr = 0;
-@@ -240,7 +241,7 @@ lookup_binding(FILE *f, char *map_wwid, char **map_alias)
- 		alias = strtok(buf, " \t");
- 		if (!alias) /* blank line */
- 			continue;
--		curr_id = scan_devname(alias);
-+		curr_id = scan_devname(alias, prefix);
- 		if (curr_id >= id)
- 			id = curr_id + 1;
- 		wwid = strtok(NULL, "");
-@@ -284,7 +285,7 @@ rlookup_binding(FILE *f, char **map_wwid, char *map_alias)
- 		alias = strtok(buf, " \t");
- 		if (!alias) /* blank line */
- 			continue;
--		curr_id = scan_devname(alias);
-+		curr_id = scan_devname(alias, NULL); /* TBD: Why this call? */
- 		if (curr_id >= id)
- 			id = curr_id + 1;
- 		wwid = strtok(NULL, " \t");
-@@ -309,7 +310,7 @@ rlookup_binding(FILE *f, char **map_wwid, char *map_alias)
- }
- 
- static char *
--allocate_binding(int fd, char *wwid, int id)
-+allocate_binding(int fd, char *wwid, int id, char *prefix)
- {
- 	char buf[LINE_MAX];
- 	off_t offset;
-@@ -321,7 +322,7 @@ allocate_binding(int fd, char *wwid, int id)
- 		return NULL;
- 	}
- 
--	i = format_devname(buf, id, LINE_MAX);
-+	i = format_devname(buf, id, LINE_MAX, prefix);
- 	c = buf + i;
- 	snprintf(c,LINE_MAX - i, " %s\n", wwid);
- 	buf[LINE_MAX - 1] = '\0';
-@@ -352,7 +353,8 @@ allocate_binding(int fd, char *wwid, int id)
- }
- 
- char *
--get_user_friendly_alias(char *wwid, char *file)
-+get_user_friendly_alias(char *wwid, char *file, char *prefix,
-+			int bindings_read_only)
- {
<<Diff was trimmed, longer than 597 lines>>

---- CVS-web:
    http://cvs.pld-linux.org/packages/multipath-tools/multipath-tools-git.patch?r1=1.2&r2=1.3
    http://cvs.pld-linux.org/packages/multipath-tools/multipath-tools-kpartx-udev.patch?r1=1.3&r2=1.4
    http://cvs.pld-linux.org/packages/multipath-tools/multipath-tools.spec?r1=1.75&r2=1.76



More information about the pld-cvs-commit mailing list