Changeset View
Changeset View
Standalone View
Standalone View
stand/uboot/main.c
Show First 20 Lines • Show All 227 Lines • ▼ Show 20 Lines | get_load_device(int *type, int *unit, int *slice, int *partition) | ||||
/* | /* | ||||
* If type is DEV_TYP_STOR we have a disk-like device. If the remainder | * If type is DEV_TYP_STOR we have a disk-like device. If the remainder | ||||
* of the string contains spaces, dots, or a colon in any location other | * of the string contains spaces, dots, or a colon in any location other | ||||
* than the last char, it's legacy format. Otherwise it might be | * than the last char, it's legacy format. Otherwise it might be | ||||
* 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. | ||||
* | |||||
* disk_parsedev now assumes that it points to the start of the device | |||||
* name, but since it doesn't know about uboot's usage, just subtract 4 | |||||
* since it always adds 4. This is the least-bad solution since it makes | |||||
* all the other loader code easier (might be better to create a fake | |||||
* 'disk...' string, but that's more work than uboot is worth). | |||||
*/ | */ | ||||
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((struct devdesc **)&dev, p, NULL) == 0) { | disk_parsedev((struct devdesc **)&dev, p - 4, NULL) == 0) { /* Hack */ | ||||
*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); | free(dev); | ||||
return; | return; | ||||
} | } | ||||
} | } | ||||
▲ Show 20 Lines • Show All 479 Lines • Show Last 20 Lines |