From owner-freebsd-fs@FreeBSD.ORG Wed Jul 22 22:10:48 2009 Return-Path: Delivered-To: freebsd-fs@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 0CA841065675 for ; Wed, 22 Jul 2009 22:10:48 +0000 (UTC) (envelope-from rick@kiwi-computer.com) Received: from hamlet.setfilepointer.com (hamlet.SetFilePointer.com [63.224.10.2]) by mx1.freebsd.org (Postfix) with SMTP id 86DEA8FC14 for ; Wed, 22 Jul 2009 22:10:47 +0000 (UTC) (envelope-from rick@kiwi-computer.com) Received: (qmail 29042 invoked from network); 22 Jul 2009 17:10:46 -0500 Received: from keira.kiwi-computer.com (HELO kiwi-computer.com) (63.224.10.3) by hamlet.setfilepointer.com with SMTP; 22 Jul 2009 17:10:46 -0500 Received: (qmail 62054 invoked by uid 2001); 22 Jul 2009 22:10:46 -0000 Date: Wed, 22 Jul 2009 17:10:46 -0500 From: "Rick C. Petty" To: freebsd-fs@freebsd.org Message-ID: <20090722221046.GA62007@keira.kiwi-computer.com> 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> <20081215234809.GA24403@keira.kiwi-computer.com> <8663lk5ju7.fsf@ds4.des.no> <20081216201046.GA34809@keira.kiwi-computer.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20081216201046.GA34809@keira.kiwi-computer.com> User-Agent: Mutt/1.4.2.3i Subject: Re: UFS label limitations X-BeenThere: freebsd-fs@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: rick-freebsd2008@kiwi-computer.com List-Id: Filesystems List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 22 Jul 2009 22:10:48 -0000 I posted this patch back in December, which allows some separator characters to be used in UFS labels. I've attached the patch below. des@ suggested using strspn(3) instead, so I've attached that version also. Is someone willing to commit this into 8.0? It's rather innocuous. -- Rick C. Petty ~~~ ~~~ original patch ~~~ --- 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); } ~~~ ~~~ using strspn instead ~~~ --- 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) {