From nobody Tue Jan 24 22:13:10 2023 X-Original-To: dev-commits-src-branches@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 4P1h7C3zSyz3bgNp; Tue, 24 Jan 2023 22:13:11 +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 4P1h7C1YgLz3FyJ; Tue, 24 Jan 2023 22:13:11 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1674598391; 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=Xp3TR2DZ675QLcP5j888Zyqhw6Temu4p85Wj/1g8MGQ=; b=ndq9AxQ5C9XwtOJm4frY5jIhkgXeQoJxS5mqZzGTK6oph3UDI2kaurerTILDIDtHMlcVDb QMLpVRpJBKz03DsBezNri+b/UpIP504KEetq1G+LbwSYxh6qJ973M3oaUJxFpvG/Xwjrar zY5wBN/6VRdXy25UssL6Luk8b6sA883SoiRbkoCCi+1FsmFgfG+7j/g7rfmKXWjtmDkpHs oQHhR0Z7+jA2a3V7OzzRoBdEupuUW7a6e9hEKybIz7TE7mIa78VAebuTnp5lCHxn2e8com nPk/VTWq1P6/W4EPSZoCwHXISrXejmTqxAFvEJPHEpD5OMrnhSbZrD0ix+2PXA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1674598391; 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=Xp3TR2DZ675QLcP5j888Zyqhw6Temu4p85Wj/1g8MGQ=; b=koLzkNsnO9s0+smgjvXTN1gkdZuAaX5KQcDAvwYJkLlw8rtqBuod+eRyz6DkpqaViPlSTx U5RBNTxNAMirQVKB/pLrF3MqyxKZWJTpd8QHWgXDh0C0pjfKjR3GKAdieCtazY6zOzS5AU VdcHK4mxFCj3XE4VZeE+N3MkVXThcPBx0GAwy8dkkvxWMs68Kdf/yd/Arun6O0x8UGpeWZ wM/J4OoAldsb7jebMByv/MBmAcZybbMlocwt0W3hipCEro4F4euQzUlhzzxa6v10rTbv2H bics7Rgw7y3pXU0E/yO7gY7LqJbGNz1gjSV56g6Mz8XaKLuFYTOJNjALfTfWnw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1674598391; a=rsa-sha256; cv=none; b=o1hL41YpWgAJuP8hyDih2vNlsp1M8FLRWg8T7sYSwsqnmzyM5qUiGiYdfXiUKZg81xBuql +CJGgV2+9ZbDyq2ND/CFxf1US5ULOaXOvDuXf5WA2UJYNQKB3UeeShmdi+Adobg9uAPv0h +RZKdphzBnMjjHv4ng7bq1M3dS5DFpTf3J7Uj0VTaceybxErlwBpqfzWYKaUGJOssxeIkv 546ADo4SNVAqW3r7/Y/oOl3h7MZ2qRVVRRdMW29wQH1igY5P9EnIeBZHMaEw2EWMrnEEox CZXmIknE6AYAmhn1PINNrKePlVo50wEo+zCK3BjHkULszhDK/ymBb6KPzwwFZA== 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 4P1h7C0MKpzQYZ; Tue, 24 Jan 2023 22:13:11 +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 30OMDADA088068; Tue, 24 Jan 2023 22:13:10 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 30OMDAV5088067; Tue, 24 Jan 2023 22:13:10 GMT (envelope-from git) Date: Tue, 24 Jan 2023 22:13:10 GMT Message-Id: <202301242213.30OMDAV5088067@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Warner Losh Subject: git: e29ff543be64 - stable/13 - stand: Introduce new dv_parsedev routine List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@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/stable/13 X-Git-Reftype: branch X-Git-Commit: e29ff543be64de4f0c3c8008a1b6d762b553a6da Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by imp: URL: https://cgit.FreeBSD.org/src/commit/?id=e29ff543be64de4f0c3c8008a1b6d762b553a6da commit e29ff543be64de4f0c3c8008a1b6d762b553a6da Author: Warner Losh AuthorDate: 2022-11-30 22:08:36 +0000 Commit: Warner Losh CommitDate: 2023-01-24 21:49:38 +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 (cherry picked from commit a0aad69f9556221283b8f6ddcd332329b50463e4) --- 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 **); }; /*