aboutsummaryrefslogtreecommitdiff
path: root/stand/common/disk.c
diff options
context:
space:
mode:
Diffstat (limited to 'stand/common/disk.c')
-rw-r--r--stand/common/disk.c19
1 files changed, 12 insertions, 7 deletions
diff --git a/stand/common/disk.c b/stand/common/disk.c
index 733b7b0d57e7..1baf91efaa49 100644
--- a/stand/common/disk.c
+++ b/stand/common/disk.c
@@ -25,15 +25,13 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/disk.h>
#include <sys/queue.h>
#include <stand.h>
#include <stdarg.h>
#include <bootstrap.h>
#include <part.h>
+#include <assert.h>
#include "disk.h"
@@ -385,12 +383,14 @@ disk_close(struct disk_devdesc *dev)
return (0);
}
-char*
-disk_fmtdev(struct disk_devdesc *dev)
+char *
+disk_fmtdev(struct devdesc *vdev)
{
+ struct disk_devdesc *dev = (struct disk_devdesc *)vdev;
static char buf[128];
char *cp;
+ assert(vdev->d_dev->dv_type == DEVT_DISK);
cp = buf + sprintf(buf, "%s%d", dev->dd.d_dev->dv_name, dev->dd.d_unit);
if (dev->d_slice > D_SLICENONE) {
#ifdef LOADER_GPT_SUPPORT
@@ -410,13 +410,14 @@ disk_fmtdev(struct disk_devdesc *dev)
}
int
-disk_parsedev(struct disk_devdesc *dev, const char *devspec, const char **path)
+disk_parsedev(struct devdesc **idev, const char *devspec, const char **path)
{
int unit, slice, partition;
const char *np;
char *cp;
+ struct disk_devdesc *dev;
- np = devspec;
+ np = devspec + 4; /* Skip the leading 'disk' */
unit = -1;
/*
* If there is path/file info after the device info, then any missing
@@ -467,9 +468,13 @@ disk_parsedev(struct disk_devdesc *dev, const char *devspec, const char **path)
if (*cp != '\0' && *cp != ':')
return (EINVAL);
+ dev = calloc(sizeof(*dev), 1);
+ if (dev == NULL)
+ return (ENOMEM);
dev->dd.d_unit = unit;
dev->d_slice = slice;
dev->d_partition = partition;
+ *idev = &dev->dd;
if (path != NULL)
*path = (*cp == '\0') ? cp: cp + 1;
return (0);