Changeset View
Changeset View
Standalone View
Standalone View
stand/common/disk.c
Show First 20 Lines • Show All 407 Lines • ▼ Show 20 Lines | #endif | ||||
} | } | ||||
if (dev->d_partition > D_PARTNONE) | if (dev->d_partition > D_PARTNONE) | ||||
cp += sprintf(cp, "%c", dev->d_partition + 'a'); | cp += sprintf(cp, "%c", dev->d_partition + 'a'); | ||||
strcat(cp, ":"); | strcat(cp, ":"); | ||||
return (buf); | return (buf); | ||||
} | } | ||||
int | 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; | int unit, slice, partition; | ||||
const char *np; | const char *np; | ||||
char *cp; | char *cp; | ||||
struct disk_devdesc *dev; | |||||
np = devspec; | np = devspec; | ||||
unit = -1; | unit = -1; | ||||
/* | /* | ||||
* If there is path/file info after the device info, then any missing | * If there is path/file info after the device info, then any missing | ||||
* slice or partition info should be considered a request to search for | * slice or partition info should be considered a request to search for | ||||
* an appropriate partition. Otherwise we want to open the raw device | * an appropriate partition. Otherwise we want to open the raw device | ||||
* itself and not try to fill in missing info by searching. | * itself and not try to fill in missing info by searching. | ||||
Show All 36 Lines | if (*cp != '\0' && *cp != ':') { | ||||
return (EPART); | return (EPART); | ||||
cp++; | cp++; | ||||
} | } | ||||
} else | } else | ||||
return (EINVAL); | return (EINVAL); | ||||
if (*cp != '\0' && *cp != ':') | if (*cp != '\0' && *cp != ':') | ||||
return (EINVAL); | return (EINVAL); | ||||
dev = malloc(sizeof(*dev)); | |||||
if (dev == NULL) | |||||
return (ENOMEM); | |||||
dev->dd.d_unit = unit; | dev->dd.d_unit = unit; | ||||
dev->d_slice = slice; | dev->d_slice = slice; | ||||
dev->d_partition = partition; | dev->d_partition = partition; | ||||
*idev = &dev->dd; | |||||
if (path != NULL) | if (path != NULL) | ||||
*path = (*cp == '\0') ? cp: cp + 1; | *path = (*cp == '\0') ? cp: cp + 1; | ||||
return (0); | return (0); | ||||
} | } |