Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 16 Feb 2023 15:58:49 GMT
From:      Warner Losh <imp@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org
Subject:   git: 57d5ca4eeba6 - main - efivar: support device paths as well as mounted paths in path_to_dp
Message-ID:  <202302161558.31GFwndd000028@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch main has been updated by imp:

URL: https://cgit.FreeBSD.org/src/commit/?id=57d5ca4eeba6192e91044aad86fca4429966cfac

commit 57d5ca4eeba6192e91044aad86fca4429966cfac
Author:     Warner Losh <imp@FreeBSD.org>
AuthorDate: 2023-02-16 15:53:35 +0000
Commit:     Warner Losh <imp@FreeBSD.org>
CommitDate: 2023-02-16 15:54:39 +0000

    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
---
 lib/libefivar/efivar-dp-xlate.c | 17 ++++++++++++++---
 1 file changed, 14 insertions(+), 3 deletions(-)

diff --git a/lib/libefivar/efivar-dp-xlate.c b/lib/libefivar/efivar-dp-xlate.c
index b6adae80fdb4..586ba7d08180 100644
--- a/lib/libefivar/efivar-dp-xlate.c
+++ b/lib/libefivar/efivar-dp-xlate.c
@@ -648,6 +648,7 @@ errout:
 }
 
 /* Handles /path/to/file */
+/* Handles /dev/foo/bar */
 static int
 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;
-	if (strncmp(dev, _PATH_DEV, sizeof(_PATH_DEV) - 1) == 0)
-		dev += sizeof(_PATH_DEV) -1;
-	ep = rp + strlen(buf.f_mntonname);
+	/*
+	 * If we're fed a raw /dev/foo/bar, then devfs is returned from the
+	 * 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);
 #ifdef notyet



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202302161558.31GFwndd000028>