From nobody Wed Nov 30 22:31:31 2022 X-Original-To: dev-commits-src-all@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 4NMv7m1zPwz4jCKb; Wed, 30 Nov 2022 22:31:32 +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 4NMv7l6Jqqz452t; Wed, 30 Nov 2022 22:31:31 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1669847491; 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=DH6+mFyr0FpSDAoIWiGZqPM7cMeal06up3E1JcbzTS4=; b=Ld6u9beDtwf4sFgOkzDWQMgSZw126qUHg3AYSEA+Sn4af9OnEW5EFeBkVMtFXZClfCdfO8 kJaN/YP2/lTe/Fwqa4TOaZ/QcxV7bUMBpHg+c3vC+Tn2IlirZcqFxKyTkO7vriWCjMqeW6 joSKyl0EEFZal+pJa3h7RIB68wxOsp4bDyrxwizEaICcPG0L8uY4SWyxq0my0qPqj8INB0 /Cox8fek/iJBDnv1t6fB6VuON6ZTvnJraRD3emaNKRlLbT49ZZegnebZrwsBq2e8tnFIMP cZTiB7fu5wIa92we2bcvsBZV97q90DBxx1jEoKGJHqZkCaU5V7DXDImxHJ5oYg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1669847491; 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=DH6+mFyr0FpSDAoIWiGZqPM7cMeal06up3E1JcbzTS4=; b=g6Iy9qXlYzV1WlG2JxTheJ9mteHYX+8k/x/zBEOf+uWdlwOcMXcoSrFUsTWH7kifVedxCm NzKCTbT4sUEMVBiUo53asAowM7mcnCowMH2wzDh0HTJ8xl6KlWcXtgEPbIb8Pu4QMWon7V AZmil/CK8qzgEsgNmGBo/F64duGaf/v/1sn8rb2wGSTQpQ/IFcj+8n5olGSdsrI1v1zs+I O6HGv7Bo8q52/LaHr0Fh68o+vTVEvfdD60n8IXfax7QED6ljBOp6eVdu1oqa7+Dw9G0GUi JKRK4sZeWoVk+BEvi02l0gyRedMprtbb1/QIScUZO8BtOoD0B7DcdCHgW9rlMg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1669847491; a=rsa-sha256; cv=none; b=B62cIVdLtlmnMbY1Dc+Gl+AiTt3zeOzwP1gv7MNQsc/Sz7RO6TiHUJ6+ZRrw/Kmk3u49P2 MjEaxzzpu6Ryd/e0Yx12k5Yj0J5RrvivUa2iPvMaGOHiE82VHSvdPdKAdGQ8/cVq5pqJFn irABXVDnB4EJA5D3l+3zt1mIiB66hGxUyjGvocEh3j8XR5uncu5N1ITd9sHkmLytk+22J5 taEUWRazFs2/Oc7ncbhUIsF8fFwM2BXl9pxfTB36DSxtM6hFfNDRtcllJ8kVBMgDGMl4Lm X3OEP6EMrp6huVTamHwDdohlGS4FfMdaffmWRQU7Kyvf9K6nnSUZ8Jsv3ZXVVg== 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 4NMv7l5KHWz1Ctn; Wed, 30 Nov 2022 22:31:31 +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 2AUMVVNG023736; Wed, 30 Nov 2022 22:31:31 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 2AUMVVmP023735; Wed, 30 Nov 2022 22:31:31 GMT (envelope-from git) Date: Wed, 30 Nov 2022 22:31:31 GMT Message-Id: <202211302231.2AUMVVmP023735@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: 88a8c68298db - main - ofw/disk: Add parsedev support List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@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: 88a8c68298dbc86370d9a7eff06314da398829cb Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by imp: URL: https://cgit.FreeBSD.org/src/commit/?id=88a8c68298dbc86370d9a7eff06314da398829cb commit 88a8c68298dbc86370d9a7eff06314da398829cb Author: Warner Losh AuthorDate: 2022-11-30 22:10:11 +0000 Commit: Warner Losh CommitDate: 2022-11-30 22:30:33 +0000 ofw/disk: Add parsedev support Add a parsedev support for OpenFirmware disks. We must look at characteristics of the OFW node to know if we match this device (so supply a match routine) or not. Add a parsing routine to allocate devdesc for OpenFirmware disks as well. Sponsored by: Netflix Differential Revision: https://reviews.freebsd.org/D37558 --- stand/libofw/ofw_disk.c | 37 ++++++++++++++++++++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) diff --git a/stand/libofw/ofw_disk.c b/stand/libofw/ofw_disk.c index 67da8cbeb310..ae2776ee4689 100644 --- a/stand/libofw/ofw_disk.c +++ b/stand/libofw/ofw_disk.c @@ -50,7 +50,8 @@ static int ofwd_close(struct open_file *f); static int ofwd_ioctl(struct open_file *f, u_long cmd, void *data); static int ofwd_print(int verbose); static char * ofwd_fmtdev(struct devdesc *); - +static int ofwd_parsedev(struct devdesc **, const char *, const char **); +static bool ofwd_match(struct devsw *, const char *); struct devsw ofwdisk = { .dv_name = "block", @@ -62,7 +63,9 @@ struct devsw ofwdisk = { .dv_ioctl = ofwd_ioctl, .dv_print = ofwd_print, .dv_cleanup = nullsys, + .dv_match = ofwd_match, .dv_fmtdev = ofwd_fmtdev, + .dv_parsedev = ofwd_parsedev, }; /* @@ -210,6 +213,16 @@ ofwd_print(int verbose __unused) return (0); } + + +static bool +ofwd_match(struct devsw *devsw, const char *devspec) +{ + const char *path; + + return (ofw_path_to_handle(devspec, devsw->dv_name, &path) != -1); +} + static char * ofwd_fmtdev(struct devdesc *idev) { @@ -217,3 +230,25 @@ ofwd_fmtdev(struct devdesc *idev) return (dev->d_path); } + +static int +ofwd_parsedev(struct devdesc **dev, const char *devspec, const char **path) +{ + const char *rem_path; + struct ofw_devdesc *idev; + + if (ofw_path_to_handle(devspec, ofwdisk.dv_name, &rem_path) == -1) + return (ENOENT); + idev = malloc(sizeof(struct ofw_devdesc)); + if (idev == NULL) { + printf("ofw_parsedev: malloc failed\n"); + return ENOMEM; + }; + strlcpy(idev->d_path, devspec, min(rem_path - devspec + 1, + sizeof(idev->d_path))); + if (dev != NULL) + *dev = &idev->dd; + if (path != NULL) + *path = rem_path; + return 0; +}