1
0
mirror of https://git.FreeBSD.org/src.git synced 2024-12-14 10:09:48 +00:00

efivar: support device paths as well as mounted paths in path_to_dp

In path_to_dp, allow passing in either the actual device path "eg
/dev/foo/bar" or the path where the device is mounted (say
/mnt/baz/bing). In the former case we'll assume the path within the
device is nothing (the relpath). In the latter, we'll take from the
mount point on down as the relpath.

Sponsored by:		Netflix
Reviewed by:		corvink, manu, asomers
Differential Revision:	https://reviews.freebsd.org/D38616
This commit is contained in:
Warner Losh 2023-02-16 08:53:35 -07:00
parent 49fd6affdb
commit 57d5ca4eeb

View File

@ -648,6 +648,7 @@ dev_path_to_dp(struct gmesh *mesh, char *path, efidp *dp)
} }
/* Handles /path/to/file */ /* Handles /path/to/file */
/* Handles /dev/foo/bar */
static int static int
path_to_dp(struct gmesh *mesh, char *path, efidp *dp) path_to_dp(struct gmesh *mesh, char *path, efidp *dp)
{ {
@ -667,9 +668,19 @@ path_to_dp(struct gmesh *mesh, char *path, efidp *dp)
} }
dev = buf.f_mntfromname; dev = buf.f_mntfromname;
if (strncmp(dev, _PATH_DEV, sizeof(_PATH_DEV) - 1) == 0) /*
dev += sizeof(_PATH_DEV) -1; * If we're fed a raw /dev/foo/bar, then devfs is returned from the
ep = rp + strlen(buf.f_mntonname); * statfs call. In that case, use that dev and assume we have a path
* of nothing.
*/
if (strcmp(dev, "devfs") == 0) {
dev = rp + sizeof(_PATH_DEV) - 1;
ep = NULL;
} else {
if (strncmp(dev, _PATH_DEV, sizeof(_PATH_DEV) - 1) == 0)
dev += sizeof(_PATH_DEV) - 1;
ep = rp + strlen(buf.f_mntonname);
}
efimedia = find_geom_efimedia(mesh, dev); efimedia = find_geom_efimedia(mesh, dev);
#ifdef notyet #ifdef notyet