mirror of
https://github.com/freebsd/freebsd-src
synced 2024-10-07 00:50:50 +00:00
efivar: Allow NULL paths in build_dp
Allow there to be NULL paths in buildp. This lets us return the device path to the partition, as well as to files on the partition. Sponsored by: Netflix Reviewed by: corvink, manu, asomers Differential Revision: https://reviews.freebsd.org/D38615
This commit is contained in:
parent
ccf2121d59
commit
49fd6affdb
|
@ -544,23 +544,25 @@ find_geom_efimedia(struct gmesh *mesh, const char *dev)
|
|||
static int
|
||||
build_dp(const char *efimedia, const char *relpath, efidp *dp)
|
||||
{
|
||||
char *fp, *dptxt = NULL, *cp, *rp;
|
||||
char *fp = NULL, *dptxt = NULL, *cp, *rp = NULL;
|
||||
int rv = 0;
|
||||
efidp out = NULL;
|
||||
size_t len;
|
||||
|
||||
rp = strdup(relpath);
|
||||
for (cp = rp; *cp; cp++)
|
||||
if (*cp == '/')
|
||||
*cp = '\\';
|
||||
fp = path_to_file_dp(rp);
|
||||
free(rp);
|
||||
if (fp == NULL) {
|
||||
rv = ENOMEM;
|
||||
goto errout;
|
||||
if (relpath != NULL) {
|
||||
rp = strdup(relpath);
|
||||
for (cp = rp; *cp; cp++)
|
||||
if (*cp == '/')
|
||||
*cp = '\\';
|
||||
fp = path_to_file_dp(rp);
|
||||
free(rp);
|
||||
if (fp == NULL) {
|
||||
rv = ENOMEM;
|
||||
goto errout;
|
||||
}
|
||||
}
|
||||
|
||||
asprintf(&dptxt, "%s/%s", efimedia, fp);
|
||||
asprintf(&dptxt, "%s/%s", efimedia, fp == NULL ? "" : fp);
|
||||
out = malloc(8192);
|
||||
len = efidp_parse_device_path(dptxt, out, 8192);
|
||||
if (len > 8192) {
|
||||
|
|
Loading…
Reference in a new issue