From nobody Wed Nov 30 22:31:12 2022 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 4NMv7N5yChz4jC33; Wed, 30 Nov 2022 22:31:12 +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 4NMv7N54wwz43pC; Wed, 30 Nov 2022 22:31:12 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1669847472; 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=y2ZK4GKGmMZkMrBbIfUVV3ow7ZFkK3JAUz9rlVE9488=; b=asAwXf4D2JZKxQ3CnZdXcsi+jlISfmKouOW/NRD6UqmmQkYN+dEcg2TkBcxSw1RvSjG9iP YyHSJI5pon44U20cyC4RRlZeD16uAQTjdRFBu5tF/CTIDKzTe3iq63KWXkiapFOd4Ca8j+ Yo3nv+06dLL9XorG+QVD8rK2SQavCWozkBY6ZIOni2R+RPQIUmaU6qGRR1sgFlT6x4QGd4 flaLBWVt9cFD2jmqN7qK70vaYdUTtKezTS35CVVUfiNStW9CVAyVEbHZOkWFchdFdBisvE Tz8oqz5DlsrIMi6tLYVNqksKQX21Gmk0uMh9rDZWFybSRYI1bjYnCtKjKUfaOw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1669847472; 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=y2ZK4GKGmMZkMrBbIfUVV3ow7ZFkK3JAUz9rlVE9488=; b=R5Q16qy8+mgoNxAMMbzG9YtiVWpPGxZgRcKu8DnIHUQl0yA7pKI9K8Ez6DHRg+u9kpg9xo UcAFbDNWm5RqxfH4/j1i9IY5N/uvzusNm0mUuGwc8yVHbbMQynPua43H/40dQDQvbpS0TX WYbBEEQ6amIWrC5+APbAB3Nf6InOqvSD2pjCOJnxRnr0ykM26fYm30+2XpaNC23FPgrpvU 8wTinxrB531TSAY983TDlRI1T0P9mDtqrLEdwKVcS7lqWXb5jm2/lc+JDCplMljom0hy6q mfURQ9uO/PpRkrrXGs2PaIADHWgohQyTADl6iUdnnYPCUhMADFG9iryKhuHm4Q== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1669847472; a=rsa-sha256; cv=none; b=ZKhDRwhgL2le3yQAAsX3iwqfT8AG8EGjTQXng8z+3pjS2yz+P+R16iRj4PxdAueOnSfjj4 DQJly8oTlp2BLL8DTgsL6b7hCo9SsYFN4sojL3abs0Bsp1F7jL2ulh/cdIOrBOEavzoyoW T1Wx1Dy528Yjqx9m+Wv27+7qbcwdItzFG6KQurQUwKkK7H5A7ayJKWPeVVsUIYB+CG6yv3 bgjA38pzUSgKWo8FxjsU5j/Swc84uCBKJUQYoot9QcHrzwNF5oPBOlckTuJByG9RJFoc+K 9aKUIRW5gGi4td9Fq5nuXuAmkzUfLzZ2wSBiRSg4iAbWNh6UXYMdr+nsrTLDmg== 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 4NMv7N4B6Fz1CH5; Wed, 30 Nov 2022 22:31:12 +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 2AUMVCF1023302; Wed, 30 Nov 2022 22:31:12 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 2AUMVCae023301; Wed, 30 Nov 2022 22:31:12 GMT (envelope-from git) Date: Wed, 30 Nov 2022 22:31:12 GMT Message-Id: <202211302231.2AUMVCae023301@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: a0aad69f9556 - main - stand: Introduce new dv_parsedev routine 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: a0aad69f9556221283b8f6ddcd332329b50463e4 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by imp: URL: https://cgit.FreeBSD.org/src/commit/?id=a0aad69f9556221283b8f6ddcd332329b50463e4 commit a0aad69f9556221283b8f6ddcd332329b50463e4 Author: Warner Losh AuthorDate: 2022-11-30 22:08:36 +0000 Commit: Warner Losh CommitDate: 2022-11-30 22:30:31 +0000 stand: Introduce new dv_parsedev routine Allow device classes to define a parsing routine. Most device classes already have these routines, but there's much duplication in their use. Define an interface for a common routine to parse an individual device. By convetion, files have the form "[device:]/path/to/file" where device is optional (filled in to be the value of currdev) and it starts with the dv_name field of the device, with the rest of the name up to the device (typically a unit number, but disks add partition inforation, and other devices may do artibtrary otehr things). Sponsored by: Netflix Differential Revision: https://reviews.freebsd.org/D37337 --- stand/libsa/libsa.3 | 32 +++++++++++++++++++++++++++++++- stand/libsa/stand.h | 1 + 2 files changed, 32 insertions(+), 1 deletion(-) diff --git a/stand/libsa/libsa.3 b/stand/libsa/libsa.3 index 7bd7a848cd3d..f732595bc647 100644 --- a/stand/libsa/libsa.3 +++ b/stand/libsa/libsa.3 @@ -710,7 +710,9 @@ struct devsw { int (*dv_ioctl)(struct open_file *f, u_long cmd, void *data); int (*dv_print)(int verbose); void (*dv_cleanup)(void); - void (*dv_fmtdev)(struct devdesc *); + char * (*dv_fmtdev)(struct devdesc *); + int (*dv_parsedev)(struct devdesc **dev, const char *devpart, + const char **path); }; .Ed .Bl -tag -width ".Fn dv_strategy" @@ -751,6 +753,34 @@ Cleans up any memory used by the device before the next stage is run. .It Fn dv_fmtdev Converts the specified devdesc to the canonical string representation for that device. +.It Fn dv_parsedev +Parses the device portion of a file path. +The +.Dv devpart +will point to the +.Sq tail +of device name, possibly followed by a colon and a path within the device. +The +.Sq tail +is, by convention, the part of the device specification that follows the +.Fa dv_name +part of the string. +So when parsing the string +.Dq disk3p5:/xxx +.Dv devpart +will point to the +.Sq 3 +in that string. +The parsing routine is expected to allocate a new +.Dv struct devdesc +or subclass and return it in +.Dv dev +when successful. +This routine should set +.Dv path +to point to the portion of the string after device specification, or +.Dq /xxx +in the earlier example. .El .Sh HISTORY The diff --git a/stand/libsa/stand.h b/stand/libsa/stand.h index 3b2627355ed6..716486107b27 100644 --- a/stand/libsa/stand.h +++ b/stand/libsa/stand.h @@ -160,6 +160,7 @@ struct devsw { int (*dv_print)(int verbose); /* print device information */ void (*dv_cleanup)(void); char * (*dv_fmtdev)(struct devdesc *); + int (*dv_parsedev)(struct devdesc **, const char *, const char **); }; /*