Page MenuHomeFreeBSD

D22304.id64146.diff
No OneTemporary

D22304.id64146.diff

Index: lib/geom/nop/geom_nop.c
===================================================================
--- lib/geom/nop/geom_nop.c
+++ lib/geom/nop/geom_nop.c
@@ -56,12 +56,13 @@
{ 'w', "wfailprob", "-1", G_TYPE_NUMBER },
{ 'x', "wdelayprob", "-1", G_TYPE_NUMBER },
{ 'z', "physpath", G_NOP_PHYSPATH_PASSTHROUGH, G_TYPE_STRING },
+ { 'Z', "strnprefix", G_VAL_OPTIONAL, G_TYPE_STRING },
G_OPT_SENTINEL
},
"[-v] [-c count_until_fail] [-d delaymsec] [-e error] [-o offset] "
"[-p stripesize] [-P stripeoffset] [-q rdelayprob] [-r rfailprob] "
"[-s size] [-S secsize] [-w wfailprob] [-x wdelayprob] "
- "[-z physpath] dev ..."
+ "[-z physpath] [-Z strnprefix] dev ..."
},
{ "configure", G_FLAG_VERBOSE, NULL,
{
Index: lib/geom/nop/gnop.8
===================================================================
--- lib/geom/nop/gnop.8
+++ lib/geom/nop/gnop.8
@@ -24,7 +24,7 @@
.\"
.\" $FreeBSD$
.\"
-.Dd September 13, 2019
+.Dd November 10, 2019
.Dt GNOP 8
.Os
.Sh NAME
@@ -47,6 +47,7 @@
.Op Fl w Ar wfailprob
.Op Fl x Ar wdelayprob
.Op Fl z Ar physpath
+.Op Fl Z Ar strnprefix
.Ar dev ...
.Nm
.Cm configure
@@ -153,6 +154,9 @@
Specifies write delay probability in percent.
.It Fl z Ar physpath
Physical path of the transparent provider.
+.It Fl Z Ar strnprefix
+The prefix to the device name.
+The nop keyword will be added after it.
.El
.Sh SYSCTL VARIABLES
The following
Index: sys/geom/nop/g_nop.c
===================================================================
--- sys/geom/nop/g_nop.c
+++ sys/geom/nop/g_nop.c
@@ -29,6 +29,7 @@
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
+#include <sys/ctype.h>
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/kernel.h>
@@ -81,6 +82,20 @@
TAILQ_ENTRY(g_nop_delay) dl_next;
};
+static bool
+g_nop_verify_nprefix(const char *name)
+{
+ int i;
+
+ for (i = 0; i < strlen(name); i++) {
+ if (islower(name[i]) == 0 && isdigit(name[i]) == 0) {
+ return (false);
+ }
+ }
+
+ return (true);
+}
+
static void
g_nop_orphan(struct g_consumer *cp)
{
@@ -312,17 +327,17 @@
static int
g_nop_create(struct gctl_req *req, struct g_class *mp, struct g_provider *pp,
- int ioerror, u_int count_until_fail, u_int rfailprob, u_int wfailprob,
- u_int delaymsec, u_int rdelayprob, u_int wdelayprob, off_t offset,
- off_t size, u_int secsize, off_t stripesize, off_t stripeoffset,
- const char *physpath)
+ const char *strnprefix, int ioerror, u_int count_until_fail,
+ u_int rfailprob, u_int wfailprob, u_int delaymsec, u_int rdelayprob,
+ u_int wdelayprob, off_t offset, off_t size, u_int secsize, off_t stripesize,
+ off_t stripeoffset, const char *physpath)
{
struct g_nop_softc *sc;
struct g_geom *gp;
struct g_provider *newpp;
struct g_consumer *cp;
char name[64];
- int error;
+ int error, n;
off_t explicitsize;
g_topology_assert();
@@ -373,7 +388,22 @@
gctl_error(req, "stripeoffset is too big.");
return (EINVAL);
}
- snprintf(name, sizeof(name), "%s%s", pp->name, G_NOP_SUFFIX);
+ if (strnprefix != NULL && !g_nop_verify_nprefix(strnprefix)) {
+ gctl_error(req, "Invalid name prefix.");
+ return (EINVAL);
+ }
+
+ if (strnprefix != NULL) {
+ n = snprintf(name, sizeof(name), "%s.%s%s", pp->name,
+ strnprefix, G_NOP_SUFFIX);
+ } else {
+ n = snprintf(name, sizeof(name), "%s%s", pp->name,
+ G_NOP_SUFFIX);
+ }
+ if (n <= 0 || n >= sizeof(name)) {
+ gctl_error(req, "Invalid provider name.");
+ return (EINVAL);
+ }
LIST_FOREACH(gp, &mp->geom, geom) {
if (strcmp(gp->name, name) == 0) {
gctl_error(req, "Provider %s already exists.", name);
@@ -500,7 +530,7 @@
intmax_t *val, error, rfailprob, wfailprob, count_until_fail, offset,
secsize, size, stripesize, stripeoffset, delaymsec,
rdelayprob, wdelayprob;
- const char *name, *physpath;
+ const char *name, *physpath, *strnprefix;
char param[16];
int i, *nargs;
@@ -623,6 +653,7 @@
}
}
physpath = gctl_get_asciiparam(req, "physpath");
+ strnprefix = gctl_get_asciiparam(req, "strnprefix");
for (i = 0; i < *nargs; i++) {
snprintf(param, sizeof(param), "arg%d", i);
@@ -640,6 +671,7 @@
return;
}
if (g_nop_create(req, mp, pp,
+ strnprefix,
error == -1 ? EIO : (int)error,
count_until_fail == -1 ? 0 : (u_int)count_until_fail,
rfailprob == -1 ? 0 : (u_int)rfailprob,

File Metadata

Mime Type
text/plain
Expires
Thu, Apr 30, 7:56 PM (19 h, 40 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
32414797
Default Alt Text
D22304.id64146.diff (4 KB)

Event Timeline