From owner-freebsd-current@FreeBSD.ORG Wed Jul 29 20:30:20 2009 Return-Path: Delivered-To: freebsd-current@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 5418E106564A; Wed, 29 Jul 2009 20:30:20 +0000 (UTC) (envelope-from dimitry@andric.com) Received: from tensor.andric.com (cl-327.ede-01.nl.sixxs.net [IPv6:2001:7b8:2ff:146::2]) by mx1.freebsd.org (Postfix) with ESMTP id CB39F8FC1F; Wed, 29 Jul 2009 20:30:19 +0000 (UTC) (envelope-from dimitry@andric.com) Received: from [IPv6:2001:7b8:3a7:0:ec34:577f:fc0b:b456] (unknown [IPv6:2001:7b8:3a7:0:ec34:577f:fc0b:b456]) (using TLSv1 with cipher DHE-RSA-CAMELLIA256-SHA (256/256 bits)) (No client certificate requested) by tensor.andric.com (Postfix) with ESMTPSA id 414EA5C42; Wed, 29 Jul 2009 22:30:18 +0200 (CEST) Message-ID: <4A70B15B.4050907@andric.com> Date: Wed, 29 Jul 2009 22:30:19 +0200 From: Dimitry Andric User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.2; en-US; rv:1.9.1.2pre) Gecko/20090727 Shredder/3.0b4pre MIME-Version: 1.0 To: =?ISO-8859-1?Q?Marius_N=FCnnerich?= References: <4A5CB2D1.5070106@omnilan.de> <4A5CC981.8010000@omnilan.de> <4A5EDA14.8000703@omnilan.de> <4A5F0F4F.5060505@andric.com> <4A6F52BE.9000901@omnilan.de> <9bbcef730907281255u3f426923g886893585899d210@mail.gmail.com> <4A6F5A1F.2070906@omnilan.de> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Cc: Harald Schmalzbauer , freebsd-current@freebsd.org, Ivan Voras Subject: Re: gmirror provider name limit [Was: Re: geom_label: gpt/labelname for gmirror provider?] X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 29 Jul 2009 20:30:20 -0000 On 2009-07-28 22:59, Marius N=FCnnerich wrote: > The current size of the gmirror metadata is 135 bytes so a > providername of 64 would easily fit but I'm not sure it's worth the > hassle. Maybe one could include it if/when there is a new version. > Anyway till then it should be documented and there should be an error > message from the utils which create the mirror (and the other setups). Please try the following patch, to enable an error message, in case any of the providers' names exceeds the maximum length. It should be enough to do "cd /usr/src/sbin/geom && make && sudo make install". I'm not very good at manpages, though... any takers? :) Index: sbin/geom/class/raid3/geom_raid3.c =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- sbin/geom/class/raid3/geom_raid3.c (revision 195939) +++ sbin/geom/class/raid3/geom_raid3.c (working copy) @@ -184,6 +184,8 @@ raid3_label(struct gctl_req *req) return; } hardcode =3D gctl_get_int(req, "hardcode"); + if (hardcode && gctl_check_provider(req, sizeof(md.md_provider))) + return; =20 /* * Calculate sectorsize by finding least common multiple from Index: sbin/geom/class/shsec/geom_shsec.c =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- sbin/geom/class/shsec/geom_shsec.c (revision 195939) +++ sbin/geom/class/shsec/geom_shsec.c (working copy) @@ -116,6 +116,8 @@ shsec_label(struct gctl_req *req) return; } hardcode =3D gctl_get_int(req, "hardcode"); + if (hardcode && gctl_check_provider(req, sizeof(md.md_provider))) + return; =20 /* * Clear last sector first to spoil all components if device exists. Index: sbin/geom/class/stripe/geom_stripe.c =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- sbin/geom/class/stripe/geom_stripe.c (revision 195939) +++ sbin/geom/class/stripe/geom_stripe.c (working copy) @@ -134,6 +134,8 @@ stripe_label(struct gctl_req *req) return; } hardcode =3D gctl_get_int(req, "hardcode"); + if (hardcode && gctl_check_provider(req, sizeof(md.md_provider))) + return; =20 /* * Clear last sector first to spoil all components if device exists. Index: sbin/geom/class/concat/geom_concat.c =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- sbin/geom/class/concat/geom_concat.c (revision 195939) +++ sbin/geom/class/concat/geom_concat.c (working copy) @@ -123,6 +123,8 @@ concat_label(struct gctl_req *req) return; } hardcode =3D gctl_get_int(req, "hardcode"); + if (hardcode && gctl_check_provider(req, sizeof(md.md_provider))) + return; =20 /* * Clear last sector first to spoil all components if device exists. Index: sbin/geom/class/journal/geom_journal.c =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- sbin/geom/class/journal/geom_journal.c (revision 195939) +++ sbin/geom/class/journal/geom_journal.c (working copy) @@ -164,6 +164,9 @@ journal_label(struct gctl_req *req) return; } =20 + if (hardcode && gctl_check_provider(req, sizeof(md.md_provider))) + return; + /* Verify the given providers. */ for (i =3D 0; i < nargs; i++) { str =3D gctl_get_ascii(req, "arg%d", i); Index: sbin/geom/class/mirror/geom_mirror.c =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- sbin/geom/class/mirror/geom_mirror.c (revision 195939) +++ sbin/geom/class/mirror/geom_mirror.c (working copy) @@ -190,6 +190,8 @@ mirror_label(struct gctl_req *req) if (gctl_get_int(req, "nofailsync")) md.md_mflags |=3D G_MIRROR_DEVICE_FLAG_NOFAILSYNC; hardcode =3D gctl_get_int(req, "hardcode"); + if (hardcode && gctl_check_provider(req, sizeof(md.md_provider))) + return; =20 /* * Calculate sectorsize by finding least common multiple from Index: sbin/geom/misc/subr.h =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- sbin/geom/misc/subr.h (revision 195939) +++ sbin/geom/misc/subr.h (working copy) @@ -49,5 +49,6 @@ int gctl_change_param(struct gctl_req *req, const const void *value); int gctl_delete_param(struct gctl_req *req, const char *name); int gctl_has_param(struct gctl_req *req, const char *name); +int gctl_check_provider(struct gctl_req *req, size_t size); =20 #endif /* !_SUBR_H_ */ Index: sbin/geom/misc/subr.c =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- sbin/geom/misc/subr.c (revision 195939) +++ sbin/geom/misc/subr.c (working copy) @@ -458,3 +458,24 @@ gctl_has_param(struct gctl_req *req, const char *n } return (0); } + +int +gctl_check_provider(struct gctl_req *req, size_t size) +{ + const char *str; + int i, nargs; + + nargs =3D gctl_get_int(req, "nargs"); + + for (i =3D 1; i < nargs; i++) { + str =3D gctl_get_ascii(req, "arg%d", i); + if (strncmp(str, _PATH_DEV, strlen(_PATH_DEV)) =3D=3D 0) + str +=3D strlen(_PATH_DEV); + if (strlen(str) > size - 1) { + gctl_error(req, "Provider name '%s' too long (max %zu " + "chars).", str, size - 1); + return (ENAMETOOLONG); + } + } + return (0); +}