Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 15 Dec 2008 17:48:09 -0600
From:      "Rick C. Petty" <rick-freebsd2008@kiwi-computer.com>
To:        Dag-Erling =?iso-8859-1?Q?Sm=F8rgrav?= <des@des.no>
Cc:        freebsd-fs@freebsd.org
Subject:   Re: UFS label limitations
Message-ID:  <20081215234809.GA24403@keira.kiwi-computer.com>
In-Reply-To: <86y6yh5pz0.fsf@ds4.des.no>
References:  <20081213173902.GA96883@keira.kiwi-computer.com> <20081213183058.GA20992@a91-153-125-115.elisa-laajakaista.fi> <20081213192320.GA97766@keira.kiwi-computer.com> <86y6yh5pz0.fsf@ds4.des.no>

next in thread | previous in thread | raw e-mail | index | archive | help
On Mon, Dec 15, 2008 at 06:05:07PM +0100, Dag-Erling Smørgrav wrote:
> "Rick C. Petty" <rick-freebsd2008@kiwi-computer.com> writes:
> > Well at the very least can we allow all characters between 0x20 and 0x7e
> > except for:  "&/<>\
> 
> Stick to the POSIX portable file name character set: [A-Za-z0-9._-]

Good idea.  It gives me the separators I need.  Would a committer be
willing to review and commit the attached (inline) patch?

-- Rick C. Petty


--- src/sbin/newfs/newfs.c.orig	2007-03-02 14:07:59.000000000 -0600
+++ src/sbin/newfs/newfs.c	2008-12-15 17:29:26.000000000 -0600
@@ -168,11 +168,15 @@
 		case 'L':
 			volumelabel = optarg;
 			i = -1;
-			while (isalnum(volumelabel[++i]));
-			if (volumelabel[i] != '\0') {
-				errx(1, "bad volume label. Valid characters are alphanumerics.");
-			}
-			if (strlen(volumelabel) >= MAXVOLLEN) {
+			while ((ch = volumelabel[++i]) != '\0')
+				if (ch != '-' && ch != '.' && ch != '_' &&
+				    (ch < '0' || ch > '9') &&
+				    (ch < 'A' || ch > 'Z') &&
+				    (ch < 'a' || ch > 'z'))
+					errx(1,
+					"bad volume label. Valid characters are "
+					"[0-9A-Za-z._-].");
+			if (i >= MAXVOLLEN) {
 				errx(1, "bad volume label. Length is longer than %d.",
 				    MAXVOLLEN);
 			}
--- src/sbin/tunefs/tunefs.c.orig	2008-02-26 14:25:35.000000000 -0600
+++ src/sbin/tunefs/tunefs.c	2008-12-15 17:27:58.000000000 -0600
@@ -153,13 +153,16 @@
 			name = "volume label";
 			Lvalue = optarg;
 			i = -1;
-			while (isalnum(Lvalue[++i]));
-			if (Lvalue[i] != '\0') {
+			while ((ch = Lvalue[++i]) != '\0')
+				if (ch != '-' && ch != '.' && ch != '_' &&
+				    (ch < '0' || ch > '9') &&
+				    (ch < 'A' || ch > 'Z') &&
+				    (ch < 'a' || ch > 'z'))
 				errx(10,
-				"bad %s. Valid characters are alphanumerics.",
+					"bad %s. Valid characters are "
+					"[0-9A-Za-z._-].",
 				    name);
-			}
-			if (strlen(Lvalue) >= MAXVOLLEN) {
+			if (i >= MAXVOLLEN) {
 				errx(10, "bad %s. Length is longer than %d.",
 				    name, MAXVOLLEN - 1);
 			}



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20081215234809.GA24403>