Page MenuHomeFreeBSD

D37554.diff
No OneTemporary

D37554.diff

diff --git a/stand/libsa/dev.c b/stand/libsa/dev.c
--- a/stand/libsa/dev.c
+++ b/stand/libsa/dev.c
@@ -126,8 +126,13 @@
/* look for a device that matches */
for (i = 0; devsw[i] != NULL; i++) {
dv = devsw[i];
- if (!strncmp(devspec, dv->dv_name, strlen(dv->dv_name)))
- break;
+ if (dv->dv_match != NULL) {
+ if (dv->dv_match(dv, devspec) != 0)
+ break;
+ } else {
+ if (!strncmp(devspec, dv->dv_name, strlen(dv->dv_name)))
+ break;
+ }
}
if (devsw[i] == NULL)
return (ENOENT);
diff --git a/stand/libsa/libsa.3 b/stand/libsa/libsa.3
--- a/stand/libsa/libsa.3
+++ b/stand/libsa/libsa.3
@@ -750,6 +750,7 @@
char * (*dv_fmtdev)(struct devdesc *);
int (*dv_parsedev)(struct devdesc **dev, const char *devpart,
const char **path);
+ bool (*dv_match)(struct devsw *dv, const char *devspec);
};
.Ed
.Bl -tag -width ".Fn dv_strategy"
@@ -823,6 +824,17 @@
Generally, code needing to parse a path will use
.Fa devparse
instead of calling this routine directly.
+.It Fn dv_match
+.Dv NULL
+to specify that all device paths starting with
+.Fa dv_name
+match.
+Otherwise, this function returns 0 for a match and a non-zero
+.Dv errno
+to indicate why it didn't match.
+This is helpful when you claim the device path after using it to query
+properties on systems that have uniform naming for different types of
+devices.
.El
.Sh HISTORY
The
diff --git a/stand/libsa/stand.h b/stand/libsa/stand.h
--- a/stand/libsa/stand.h
+++ b/stand/libsa/stand.h
@@ -161,6 +161,7 @@
void (*dv_cleanup)(void);
char * (*dv_fmtdev)(struct devdesc *);
int (*dv_parsedev)(struct devdesc **, const char *, const char **);
+ bool (*dv_match)(struct devsw *, const char *);
};
/*

File Metadata

Mime Type
text/plain
Expires
Mon, Nov 18, 1:14 PM (20 h, 40 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
14698277
Default Alt Text
D37554.diff (1 KB)

Event Timeline