mirror of
https://github.com/opnsense/src.git
synced 2026-06-11 01:30:30 -04:00
Add a function for parsing an Open Firmware boot path into the
ofw_devdesc structure.
This commit is contained in:
parent
8716f26121
commit
cdfc68815b
1 changed files with 29 additions and 3 deletions
|
|
@ -185,6 +185,32 @@ ofw_parsedev(struct ofw_devdesc **dev, const char *devspec, const char **path)
|
|||
return(err);
|
||||
}
|
||||
|
||||
/* hack to correctly parse bootpath for currdev. */
|
||||
int
|
||||
ofw_parseofwdev(struct ofw_devdesc *dev, const char *devspec)
|
||||
{
|
||||
char *cp, *ep;
|
||||
int i;
|
||||
struct devsw *dv;
|
||||
|
||||
if ((cp = strrchr(devspec, '@')) == 0)
|
||||
return EINVAL;
|
||||
cp++;
|
||||
ep = cp;
|
||||
dev->d_kind.ofwdisk.unit = strtol(cp, &cp, 10);
|
||||
if (cp == ep)
|
||||
return EUNIT;
|
||||
if (*cp != ',')
|
||||
return ESLICE;
|
||||
ep = ++cp;
|
||||
dev->d_kind.ofwdisk.slice = strtol(cp, &cp, 10) + 1;
|
||||
if (cp == ep)
|
||||
return ESLICE;
|
||||
if (*cp != ':')
|
||||
return EPART;
|
||||
dev->d_kind.ofwdisk.partition = *++cp - 'a';
|
||||
}
|
||||
|
||||
char *
|
||||
ofw_fmtdev(void *vdev)
|
||||
{
|
||||
|
|
@ -198,9 +224,9 @@ ofw_fmtdev(void *vdev)
|
|||
break;
|
||||
|
||||
case DEVT_DISK:
|
||||
/* XXX Insert stuff here */
|
||||
sprintf(buf, "%s%d:", dev->d_dev->dv_name,
|
||||
dev->d_kind.ofwdisk.unit);
|
||||
sprintf(buf, "%s%ds%d%c:", dev->d_dev->dv_name,
|
||||
dev->d_kind.ofwdisk.unit, dev->d_kind.ofwdisk.slice,
|
||||
dev->d_kind.ofwdisk.partition + 'a');
|
||||
break;
|
||||
|
||||
case DEVT_NET:
|
||||
|
|
|
|||
Loading…
Reference in a new issue