Changeset View
Changeset View
Standalone View
Standalone View
stand/uboot/main.c
Show First 20 Lines • Show All 200 Lines • ▼ Show 20 Lines | |||||
* | * | ||||
* For valid type names, see the device_types array, above. | * For valid type names, see the device_types array, above. | ||||
* | * | ||||
* Slice numbers are 1-based. 0 is a wildcard. | * Slice numbers are 1-based. 0 is a wildcard. | ||||
*/ | */ | ||||
static void | static void | ||||
get_load_device(int *type, int *unit, int *slice, int *partition) | get_load_device(int *type, int *unit, int *slice, int *partition) | ||||
{ | { | ||||
struct disk_devdesc dev; | struct disk_devdesc *dev; | ||||
char *devstr; | char *devstr; | ||||
const char *p; | const char *p; | ||||
char *endp; | char *endp; | ||||
*type = DEV_TYP_NONE; | *type = DEV_TYP_NONE; | ||||
*unit = -1; | *unit = -1; | ||||
*slice = D_SLICEWILD; | *slice = D_SLICEWILD; | ||||
*partition = D_PARTWILD; | *partition = D_PARTWILD; | ||||
Show All 14 Lines | get_load_device(int *type, int *unit, int *slice, int *partition) | ||||
* standard loader(8) format (e.g., disk0s2a or mmc1p12), so try to | * standard loader(8) format (e.g., disk0s2a or mmc1p12), so try to | ||||
* parse the remainder of the string as such, and if it works, return | * parse the remainder of the string as such, and if it works, return | ||||
* those results. Otherwise we'll fall through to the code that parses | * those results. Otherwise we'll fall through to the code that parses | ||||
* the legacy format. | * the legacy format. | ||||
*/ | */ | ||||
if (*type & DEV_TYP_STOR) { | if (*type & DEV_TYP_STOR) { | ||||
size_t len = strlen(p); | size_t len = strlen(p); | ||||
if (strcspn(p, " .") == len && strcspn(p, ":") >= len - 1 && | if (strcspn(p, " .") == len && strcspn(p, ":") >= len - 1 && | ||||
disk_parsedev(&dev, p, NULL) == 0) { | disk_parsedev((struct devdesc **)&dev, p, NULL) == 0) { | ||||
*unit = dev.dd.d_unit; | *unit = dev->dd.d_unit; | ||||
*slice = dev.d_slice; | *slice = dev->d_slice; | ||||
*partition = dev.d_partition; | *partition = dev->d_partition; | ||||
free(dev); | |||||
return; | return; | ||||
} | } | ||||
} | } | ||||
/* Ignore optional spaces after the device name. */ | /* Ignore optional spaces after the device name. */ | ||||
while (*p == ' ') | while (*p == ' ') | ||||
p++; | p++; | ||||
▲ Show 20 Lines • Show All 475 Lines • Show Last 20 Lines |