Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 29 Jul 2009 22:30:19 +0200
From:      Dimitry Andric <dimitry@andric.com>
To:        =?ISO-8859-1?Q?Marius_N=FCnnerich?= <marius@nuenneri.ch>
Cc:        Harald Schmalzbauer <h.schmalzbauer@omnilan.de>, freebsd-current@freebsd.org, Ivan Voras <ivoras@freebsd.org>
Subject:   Re: gmirror provider name limit [Was: Re: geom_label: gpt/labelname for gmirror provider?]
Message-ID:  <4A70B15B.4050907@andric.com>
In-Reply-To: <b649e5e0907281359h9804499me9119c04281ec659@mail.gmail.com>
References:  <4A5CB2D1.5070106@omnilan.de> <h3iegi$kpu$1@ger.gmane.org>	<4A5CC981.8010000@omnilan.de> <4A5EDA14.8000703@omnilan.de>	<4A5F0F4F.5060505@andric.com> <4A6F52BE.9000901@omnilan.de>	<9bbcef730907281255u3f426923g886893585899d210@mail.gmail.com>	<4A6F5A1F.2070906@omnilan.de> <b649e5e0907281359h9804499me9119c04281ec659@mail.gmail.com>

next in thread | previous in thread | raw e-mail | index | archive | help
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);
+}




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