From owner-freebsd-bugs@FreeBSD.ORG Mon Aug 31 19:40:06 2009 Return-Path: Delivered-To: freebsd-bugs@hub.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id EEDA61065670 for ; Mon, 31 Aug 2009 19:40:06 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:4f8:fff6::28]) by mx1.freebsd.org (Postfix) with ESMTP id CC09A8FC12 for ; Mon, 31 Aug 2009 19:40:06 +0000 (UTC) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.14.3/8.14.3) with ESMTP id n7VJe6UB093604 for ; Mon, 31 Aug 2009 19:40:06 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.3/8.14.3/Submit) id n7VJe6Ox093603; Mon, 31 Aug 2009 19:40:06 GMT (envelope-from gnats) Resent-Date: Mon, 31 Aug 2009 19:40:06 GMT Resent-Message-Id: <200908311940.n7VJe6Ox093603@freefall.freebsd.org> Resent-From: FreeBSD-gnats-submit@FreeBSD.org (GNATS Filer) Resent-To: freebsd-bugs@FreeBSD.org Resent-Reply-To: FreeBSD-gnats-submit@FreeBSD.org, "Rick C. Petty" Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id B478C106568F for ; Mon, 31 Aug 2009 19:39:20 +0000 (UTC) (envelope-from nobody@FreeBSD.org) Received: from www.freebsd.org (www.freebsd.org [IPv6:2001:4f8:fff6::21]) by mx1.freebsd.org (Postfix) with ESMTP id A38DC8FC19 for ; Mon, 31 Aug 2009 19:39:20 +0000 (UTC) Received: from www.freebsd.org (localhost [127.0.0.1]) by www.freebsd.org (8.14.3/8.14.3) with ESMTP id n7VJdKAS045572 for ; Mon, 31 Aug 2009 19:39:20 GMT (envelope-from nobody@www.freebsd.org) Received: (from nobody@localhost) by www.freebsd.org (8.14.3/8.14.3/Submit) id n7VJdKti045565; Mon, 31 Aug 2009 19:39:20 GMT (envelope-from nobody) Message-Id: <200908311939.n7VJdKti045565@www.freebsd.org> Date: Mon, 31 Aug 2009 19:39:20 GMT From: "Rick C. Petty" To: freebsd-gnats-submit@FreeBSD.org X-Send-Pr-Version: www-3.1 Cc: Subject: misc/138421: UFS label limitations X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 31 Aug 2009 19:40:07 -0000 >Number: 138421 >Category: misc >Synopsis: UFS label limitations >Confidential: no >Severity: non-critical >Priority: medium >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: change-request >Submitter-Id: current-users >Arrival-Date: Mon Aug 31 19:40:06 UTC 2009 >Closed-Date: >Last-Modified: >Originator: Rick C. Petty >Release: 8-STABLE >Organization: >Environment: FreeBSD myhost 8.0-BETA3 FreeBSD 8.0-BETA3 #2 r196660M: Sun Aug 30 19:54:44 CDT 2009 root@myhost:/usr/obj/usr/src/sys/GENERIC amd64 >Description: UFS filesystems allow label/volume names containing alphanumeric characters only. There is a need for at least one separator character. This request and patches were submitted to freebsd-fs@ and freebsd-current@ but no one on those lists seems to be willing to commit this innocuous patch. I've been using a patched system for well over a year on a number of systems. >How-To-Repeat: /sbin/newfs -L volume-name ... -or- /sbin/tunefs -L volume-name ... >Fix: One of the following patches, to allow acceptable POSIX filename characters as part of UFS labels. The first manually tests against the acceptable characters, which should be faster. This second patch is using strspn(3) as suggested by des@ in case the first patch is not acceptable. It is slower but we are likely going to do I/O anyway. I don't care which patch you chose, just please someone commit the damn thing! =) Patch attached with submission follows: --- 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); } --- src/sbin/newfs/newfs.c.orig 2008-05-03 23:51:38.000000000 -0500 +++ src/sbin/newfs/newfs.c 2009-07-22 16:58:48.000000000 -0500 @@ -167,10 +167,10 @@ break; case 'L': volumelabel = optarg; - i = -1; - while (isalnum(volumelabel[++i])); + i = strspn(volumelabel, + "-.0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz"); if (volumelabel[i] != '\0') { - errx(1, "bad volume label. Valid characters are alphanumerics."); + errx(1, "bad volume label. Valid characters are [0-9A-Za-z._-]."); } if (strlen(volumelabel) >= MAXVOLLEN) { errx(1, "bad volume label. Length is longer than %d.", --- src/sbin/tunefs/tunefs.c.orig 2008-05-03 23:51:52.000000000 -0500 +++ src/sbin/tunefs/tunefs.c 2009-07-22 17:01:23.000000000 -0500 @@ -152,11 +152,11 @@ found_arg = 1; name = "volume label"; Lvalue = optarg; - i = -1; - while (isalnum(Lvalue[++i])); + i = strspn(Lvalue, + "-.0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz"); if (Lvalue[i] != '\0') { errx(10, - "bad %s. Valid characters are alphanumerics.", + "bad %s. Valid characters are [0-9A-Za-z._-].", name); } if (strlen(Lvalue) >= MAXVOLLEN) { >Release-Note: >Audit-Trail: >Unformatted: