public inbox for lvm2-cvs@sourceware.org
help / color / mirror / Atom feed
* LVM2 ./WHATS_NEW lib/misc/lvm-string.c lib/mis ...
@ 2010-11-17 10:19 agk
  0 siblings, 0 replies; 2+ messages in thread
From: agk @ 2010-11-17 10:19 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	agk@sourceware.org	2010-11-17 10:19:30

Modified files:
	.              : WHATS_NEW 
	lib/misc       : lvm-string.c lvm-string.h 
	man            : lvm.8.in 
	tools          : lvmcmdline.c toollib.c 

Log message:
	Remove tag length restriction and allow / = ! : # & characters.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.1797&r2=1.1798
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/misc/lvm-string.c.diff?cvsroot=lvm2&r1=1.23&r2=1.24
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/misc/lvm-string.h.diff?cvsroot=lvm2&r1=1.21&r2=1.22
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/man/lvm.8.in.diff?cvsroot=lvm2&r1=1.5&r2=1.6
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/lvmcmdline.c.diff?cvsroot=lvm2&r1=1.130&r2=1.131
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/toollib.c.diff?cvsroot=lvm2&r1=1.211&r2=1.212

--- LVM2/WHATS_NEW	2010/11/12 16:04:52	1.1797
+++ LVM2/WHATS_NEW	2010/11/17 10:19:29	1.1798
@@ -1,5 +1,6 @@
 Version 2.02.77 -
 ===================================
+  Remove tag length restriction and allow / = ! : # & characters.
   Support repetition of --addtag and --deltag arguments.
   Add infrastructure for specific cmdline arguments to be repeated in groups.
   Split the_args cmdline arguments and values into arg_props and arg_values.
--- LVM2/lib/misc/lvm-string.c	2010/09/28 01:29:07	1.23
+++ LVM2/lib/misc/lvm-string.c	2010/11/17 10:19:30	1.24
@@ -286,6 +286,25 @@
 }
 
 /*
+ * A-Za-z0-9._-+/=!:&#
+ */
+int validate_tag(const char *n)
+{
+	register char c;
+	register int len = 0;
+
+	if (!n || !*n)
+		return 0;
+
+	while ((len++, c = *n++))
+		if (!isalnum(c) && c != '.' && c != '_' && c != '-' && c != '+' && c != '/'
+		    && c != '=' && c != '!' && c != ':' && c != '&' && c != '#')
+			return 0;
+
+	return 1;
+}
+
+/*
  * Device layer names are all of the form <vg>-<lv>-<layer>, any
  * other hyphens that appear in these names are quoted with yet
  * another hyphen.  The top layer of any device has no layer
--- LVM2/lib/misc/lvm-string.h	2010/09/23 12:02:34	1.21
+++ LVM2/lib/misc/lvm-string.h	2010/11/17 10:19:30	1.22
@@ -33,6 +33,7 @@
 		    const char *layer);
 
 int validate_name(const char *n);
+int validate_tag(const char *n);
 
 int apply_lvname_restrictions(const char *name);
 int is_reserved_lvname(const char *name);
--- LVM2/man/lvm.8.in	2010/05/20 13:47:22	1.5
+++ LVM2/man/lvm.8.in	2010/11/17 10:19:30	1.6
@@ -205,6 +205,7 @@
 .TP
 \fB--addtag tag\fP
 Add the tag \fBtag\fP to a PV, VG or LV.  
+Supply this argument multiple times to add more than one tag at once.
 A tag is a word that can be used to group LVM2 objects of the same type 
 together. 
 Tags can be given on the command line in place of PV, VG or LV 
@@ -221,10 +222,13 @@
 LVM1 metadata format cannot be tagged because the on-disk format does not
 support it.
 Snapshots cannot be tagged.
-Characters allowed in tags are: A-Z a-z 0-9 _ + . -
+Characters allowed in tags are: A-Z a-z 0-9 _ + . - and 
+as of version 2.02.78 the following characters are also
+accepted: / = ! : # &
 .TP
 \fB--deltag tag\fP
 Delete the tag \fBtag\fP from a PV, VG or LV, if it's present.
+Supply this argument multiple times to remove more than one tag at once.
 .TP
 \fB--alloc AllocationPolicy\fP
 The allocation policy to use: \fBcontiguous\fP, \fBcling\fP, \fBnormal\fP, \fBanywhere\fP or \fBinherit\fP.
--- LVM2/tools/lvmcmdline.c	2010/11/11 17:29:06	1.130
+++ LVM2/tools/lvmcmdline.c	2010/11/17 10:19:30	1.131
@@ -418,7 +418,7 @@
 	if (*pos == '@')
 		pos++;
 
-	if (!validate_name(pos))
+	if (!validate_tag(pos))
 		return 0;
 
 	av->value = pos;
--- LVM2/tools/toollib.c	2010/11/09 12:34:43	1.211
+++ LVM2/tools/toollib.c	2010/11/17 10:19:30	1.212
@@ -222,7 +222,7 @@
 			vgname = lv_name;
 
 			if (*vgname == '@') {
-				if (!validate_name(vgname + 1)) {
+				if (!validate_tag(vgname + 1)) {
 					log_error("Skipping invalid tag %s",
 						  vgname);
 					continue;
@@ -528,7 +528,7 @@
 		for (; opt < argc; opt++) {
 			vg_name = argv[opt];
 			if (*vg_name == '@') {
-				if (!validate_name(vg_name + 1)) {
+				if (!validate_tag(vg_name + 1)) {
 					log_error("Skipping invalid tag %s",
 						  vg_name);
 					if (ret_max < EINVALID_CMD_LINE)
@@ -698,7 +698,7 @@
 			if (at_sign && (at_sign == argv[opt])) {
 				tagname = at_sign + 1;
 
-				if (!validate_name(tagname)) {
+				if (!validate_tag(tagname)) {
 					log_error("Skipping invalid tag %s",
 						  tagname);
 					if (ret_max < EINVALID_CMD_LINE)
@@ -1113,7 +1113,7 @@
 
 		if (at_sign && (at_sign == argv[i])) {
 			tagname = at_sign + 1;
-			if (!validate_name(tagname)) {
+			if (!validate_tag(tagname)) {
 				log_error("Skipping invalid tag %s", tagname);
 				continue;
 			}


^ permalink raw reply	[flat|nested] 2+ messages in thread

* LVM2 ./WHATS_NEW lib/misc/lvm-string.c lib/mis ...
@ 2007-04-25 18:24 wysochanski
  0 siblings, 0 replies; 2+ messages in thread
From: wysochanski @ 2007-04-25 18:24 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	wysochanski@sourceware.org	2007-04-25 19:24:19

Modified files:
	.              : WHATS_NEW 
	lib/misc       : lvm-string.c lvm-string.h 

Log message:
	Add count_chars and count_chars_len functions, two
	generic string utility functions.
	
	--

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.601&r2=1.602
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/misc/lvm-string.c.diff?cvsroot=lvm2&r1=1.12&r2=1.13
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/misc/lvm-string.h.diff?cvsroot=lvm2&r1=1.13&r2=1.14

--- LVM2/WHATS_NEW	2007/04/25 14:49:27	1.601
+++ LVM2/WHATS_NEW	2007/04/25 18:24:19	1.602
@@ -1,5 +1,6 @@
 Version 2.02.25 -
 =================================
+  Add count_chars and count_chars_len functions
   Add /sys/block listings to lvm_dump.sh
   Make lvm_dump.sh list /dev recursively
   Fix thread race in clvmd.
--- LVM2/lib/misc/lvm-string.c	2006/08/21 12:54:53	1.12
+++ LVM2/lib/misc/lvm-string.c	2007/04/25 18:24:19	1.13
@@ -36,18 +36,38 @@
 }
 
 /*
- * Device layer names are all of the form <vg>-<lv>-<layer>, any
- * other hyphens that appear in these names are quoted with yet
- * another hyphen.  The top layer of any device has no layer
- * name.  eg, vg0-lvol0.
+ * Count occurences of 'c' in 'str' until we reach a null char.
+ *
+ * Returns:
+ *  len - incremented for each char we encounter, whether 'c' or not.
+ *  count - number of occurences of 'c'
  */
-static void _count_hyphens(const char *str, size_t *len, int *hyphens)
+void count_chars(const char *str, size_t *len, int *count,
+		 const char c)
 {
 	const char *ptr;
 
 	for (ptr = str; *ptr; ptr++, (*len)++)
-		if (*ptr == '-')
-			(*hyphens)++;
+		if (*ptr == c)
+			(*count)++;
+}
+
+/*
+ * Count occurences of 'c' in 'str' of length 'size'.
+ *
+ * Returns:
+ *   # of occurences of 'c'
+ */
+unsigned count_chars_len(const char *str, size_t size, const char c)
+{
+	int i;
+	unsigned count=0;
+
+	for (i=0; i < size; i++)
+		if (str[i] == c)
+			count++;
+	return count;
+
 }
 
 /*
@@ -73,11 +93,11 @@
 	int hyphens = 1;
 	char *r, *out;
 
-	_count_hyphens(vgname, &len, &hyphens);
-	_count_hyphens(lvname, &len, &hyphens);
+	count_chars(vgname, &len, &hyphens, '-');
+	count_chars(lvname, &len, &hyphens, '-');
 
 	if (layer && *layer) {
-		_count_hyphens(layer, &len, &hyphens);
+		count_chars(layer, &len, &hyphens, '-');
 		hyphens++;
 	}
 
@@ -105,6 +125,12 @@
 	return r;
 }
 
+/*
+ * Device layer names are all of the form <vg>-<lv>-<layer>, any
+ * other hyphens that appear in these names are quoted with yet
+ * another hyphen.  The top layer of any device has no layer
+ * name.  eg, vg0-lvol0.
+ */
 int validate_name(const char *n)
 {
 	register char c;
--- LVM2/lib/misc/lvm-string.h	2006/08/21 12:54:53	1.13
+++ LVM2/lib/misc/lvm-string.h	2007/04/25 18:24:19	1.14
@@ -30,4 +30,8 @@
 
 int validate_name(const char *n);
 
+void count_chars(const char *str, size_t *len, int *count,
+		 char c);
+unsigned count_chars_len(const char *str, size_t size, char c);
+
 #endif


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2010-11-17 10:19 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-11-17 10:19 LVM2 ./WHATS_NEW lib/misc/lvm-string.c lib/mis agk
  -- strict thread matches above, loose matches on Subject: below --
2007-04-25 18:24 wysochanski

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).