From nobody Thu Feb 16 15:58:49 2023 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4PHfkd3ZH6z3r742; Thu, 16 Feb 2023 15:58:49 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4PHfkd37Psz3xZ1; Thu, 16 Feb 2023 15:58:49 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1676563129; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=lp4YOAi1p9DCSw+MRn4xpU/61RH8nQZHJNewBz2D8ws=; b=SNoD2We9o1xSsmETZ3flU3uocsfxQOdeeSeb+4teLLq0+/byGpbuj3fL2wrBWuQnJZH7US Zmmn2PJC+OSFp2Hjzc2X5Kf4rPy4C8gnJzjztAg/9QQxZKTeAnEKVurvrnCkffpdHnjILk doENsa8InwVvEp8oX9kIYZNzpT+BIddRuLoi5sOqJ/NKd4d+8fgN4pDX+fF0V+o+QjZbPp 7q9Ez+VPEJdmH8qwQPQMW45MRLjJfXF3qYbcRKSiiessW5fVe0XgNRr4oNhFCcJ6UzAeP6 3uykNlsNUU67RSIt3gSgVBXkaQdbvmgc+6rNoG44Qm+50cKCbvRmgZHDTD6tIA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1676563129; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=lp4YOAi1p9DCSw+MRn4xpU/61RH8nQZHJNewBz2D8ws=; b=EeOT3hVDHy+gGhug8lIdlzAzexXQ07wfpBvpmssO6kEsPm30BLckSCvyhtdvSgZSYZUxV+ mqOzGhUH9ChLO1sXg4aNfoBmoFotDJmaBKJjkYW8GWIqloo8MftlwKvfeYcmmE71PqeWyN DRwgI30sZo9g5PjcOxaoYM5E7Sz3BjOZvVehfHL4RqGISs67/EWFxp3HAsjL7C3EkRbl++ V6gRBIIUk/tDq8vmD7pOlrwZQtUsDAJIgWU77Zuj4cUqgbUbTvC35slMxoPNXvWThV6LSA 4k4UkfPFRoXjvj36N6ujn+izLAEhMIX0LMt7tgweL7vX5L5uot0uu7n7NA6mZg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1676563129; a=rsa-sha256; cv=none; b=I8grGzNAaBQVsD8imOq+ugwHooF3rEWKG7uY/HB1lxJOWmWIu4F1ayYbPGy7/Im7or3Whx tUMzs5Qwz18EaXr0wZVSLuKn1OaazOIoBvqkHblgvcjy+iwy2oxRcRvT71ixpAe8MecQu9 gwOfO0YASnbF2s+ZI9gw/tGCFCxYOFA7RAKZdHE5Gk2acKX6XLgGebxuks76NHIO+di/Cn JvKTLuf9iPTsv3+C658o8ovZPzxo856lNwu4vNInx5J7SavAxgEJFUVX93PNJBy5NGlB5Q 5g2yvbpr0BSgjjZWVwy8m7lB/z514y3gwRgRnv18Vki18hVGex/QicucgUy3jg== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4PHfkd2FNwz187W; Thu, 16 Feb 2023 15:58:49 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 31GFwnjG000029; Thu, 16 Feb 2023 15:58:49 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 31GFwndd000028; Thu, 16 Feb 2023 15:58:49 GMT (envelope-from git) Date: Thu, 16 Feb 2023 15:58:49 GMT Message-Id: <202302161558.31GFwndd000028@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Warner Losh Subject: git: 57d5ca4eeba6 - main - efivar: support device paths as well as mounted paths in path_to_dp List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: imp X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 57d5ca4eeba6192e91044aad86fca4429966cfac Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by imp: URL: https://cgit.FreeBSD.org/src/commit/?id=57d5ca4eeba6192e91044aad86fca4429966cfac commit 57d5ca4eeba6192e91044aad86fca4429966cfac Author: Warner Losh AuthorDate: 2023-02-16 15:53:35 +0000 Commit: Warner Losh 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