From nobody Tue Jan 24 22:13:09 2023 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 4P1h7B3hJ3z3bg6W; Tue, 24 Jan 2023 22:13:10 +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 4P1h7B0FPFz3Fxs; Tue, 24 Jan 2023 22:13:10 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1674598390; 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=aQZY0TFZ4h7Ay3K8VyBtYqZk5Bbm+FAdCBK+XgwfGOw=; b=NJ+/T6ZYkBoLzsAgtIz9t+dbWXFnBp1H6m5q0licwAAyZ6QfplSQy58ESp0kSqCbQaXNGe 4dtUK5EpPn7qUiLJaFToKKlXQatnRyxDu/2imbrjHnT41/09ekyL0sZWzb20RdeiqDx0Ok PhpzwbX2hEPA9XhZT9OmJ0uWYDC9+1tJ0/fjq6WK72HRv4/F1X5NlALWjlIPvWSoXV+lo9 dHSdVNso2F7bdOderUkm56Q4OzAlmohb4F3Gjwmd34EFxlByqvyxP9dBSOV9DL/cFvQHE6 mlPNqO1bu75pVGr5AgH//J1KKSsaaxyEYgC/CMm4dBwn702LEe2INpkOaQzalQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1674598390; 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=aQZY0TFZ4h7Ay3K8VyBtYqZk5Bbm+FAdCBK+XgwfGOw=; b=gu7xdbtVkyETvJnD7+Yu2vkPcWfQMYR+8xF+jES2NWmI1yao7Px1UUPQpdBsnT8qa1z6cQ EQN6cWREseFK/7T4+Q6yiuM3lBGvs1lVCxaBm4/Sqy5kPpa1wt3z29m0a3WJFg0Q6Dd5Ph efQhd+uBsy/FxREaYUWJihsAGjZtJxnPsOwiveDkbtxcyxVdXvQTIc+SAd+ecVt3n8WW8M 6Yng3v5gM8LjqfnKyYvC9Vh6/+x2cPlnJ8C668gTrDNswsphEHfRHVGjupCQU5xEccXofN QG+NJ3V1mohOSMYikCePb8ffFwZKzAsPGXqobj22kiRj48mPkeN5aKQ0VSQo2g== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1674598390; a=rsa-sha256; cv=none; b=GDPktHm6lg+YphBoLA+xWlGNDjiRaNe/vhC3oWWjpv8P3YkwF+3d+B+lSunlkECgbRgXU4 zJZGTh/WK+OXLi9uM+17lNA4t9rpJ+eXXxnHTadIZBEK5rdTI5EUMJn+nI8FptKATcuQ53 lsfUdhKKfWipFsqfT65lAa45AwZJKurPRPHbr7UiD/SqBI9+EhUfB8v2cSn8GvVFdE5bCs 1He12uRMeozDmlQ4fRfjlgbciTRSwbXYMU5/qDD/NshVKnW0XVpBW7qZBj6yKLXzFU9qt9 i0r2TmGJ+ZumFJotFBWRxJkOl0RPYLPPN9jVzrrAtcgBHXqD5m4uQ68xSU5MfQ== 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 4P1h796SrRzQh0; Tue, 24 Jan 2023 22:13:09 +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 30OMD93l088038; Tue, 24 Jan 2023 22:13:09 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 30OMD9um088037; Tue, 24 Jan 2023 22:13:09 GMT (envelope-from git) Date: Tue, 24 Jan 2023 22:13:09 GMT Message-Id: <202301242213.30OMD9um088037@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: 9fd7cf55e6ff - stable/13 - stand: Change zfs_parsedev() API 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/stable/13 X-Git-Reftype: branch X-Git-Commit: 9fd7cf55e6fff04b049bfda70da48b2c9d4b57b3 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by imp: URL: https://cgit.FreeBSD.org/src/commit/?id=9fd7cf55e6fff04b049bfda70da48b2c9d4b57b3 commit 9fd7cf55e6fff04b049bfda70da48b2c9d4b57b3 Author: Warner Losh AuthorDate: 2022-11-30 22:08:22 +0000 Commit: Warner Losh CommitDate: 2023-01-24 21:49:38 +0000 stand: Change zfs_parsedev() API Change the first argument to zfs_parsedev() to be a pointer to a struct devdesc *. This now gets filled in with a malloc'd structure that's returned to the caller that the caller is repsonsible for freeing. Most nplaces in the tree passed in a malloc'd pointer anyway, and this moves knowledge of zfs_devdesc more firmly into the zfs.c code. Sponsored by: Netflix Differential Revision: https://reviews.freebsd.org/D37336 (cherry picked from commit ba11bc368e612e7c5bbc195830a280f8af73ce18) --- stand/efi/libefi/devicename.c | 6 +----- stand/i386/libi386/devicename.c | 6 +----- stand/libofw/devicename.c | 4 ++-- stand/libsa/zfs/devicename_stubs.c | 2 +- stand/libsa/zfs/libzfs.h | 2 +- stand/libsa/zfs/zfs.c | 18 ++++++++++-------- stand/userboot/userboot/devicename.c | 4 ++-- 7 files changed, 18 insertions(+), 24 deletions(-) diff --git a/stand/efi/libefi/devicename.c b/stand/efi/libefi/devicename.c index ad4b5d590609..73b1d783c01f 100644 --- a/stand/efi/libefi/devicename.c +++ b/stand/efi/libefi/devicename.c @@ -118,11 +118,7 @@ efi_parsedev(struct devdesc **dev, const char *devspec, const char **path) #ifdef EFI_ZFS_BOOT case DEVT_ZFS: - idev = malloc(sizeof(struct zfs_devdesc)); - if (idev == NULL) - return (ENOMEM); - - err = zfs_parsedev((struct zfs_devdesc*)idev, np, path); + err = zfs_parsedev(&idev, np, path); if (err != 0) goto fail; break; diff --git a/stand/i386/libi386/devicename.c b/stand/i386/libi386/devicename.c index 9ac4c9742593..1d7e4c7d3fa3 100644 --- a/stand/i386/libi386/devicename.c +++ b/stand/i386/libi386/devicename.c @@ -119,11 +119,7 @@ i386_parsedev(struct i386_devdesc **dev, const char *devspec, const char **path) break; case DEVT_ZFS: - idev = malloc(sizeof (struct zfs_devdesc)); - if (idev == NULL) - return (ENOMEM); - - err = zfs_parsedev((struct zfs_devdesc *)idev, np, path); + err = zfs_parsedev((struct devdesc **)&idev, np, path); if (err != 0) goto fail; break; diff --git a/stand/libofw/devicename.c b/stand/libofw/devicename.c index 353675db6b1f..292fba927d1a 100644 --- a/stand/libofw/devicename.c +++ b/stand/libofw/devicename.c @@ -113,9 +113,9 @@ found: idev->dd.d_dev = dv; if (dv->dv_type == DEVT_ZFS) { p = devspec + strlen(dv->dv_name); - err = zfs_parsedev((struct zfs_devdesc *)idev, p, path); + free(idev); + err = zfs_parsedev((struct devdesc **)&idev, p, path); if (err != 0) { - free(idev); return (err); } } diff --git a/stand/libsa/zfs/devicename_stubs.c b/stand/libsa/zfs/devicename_stubs.c index e58bc9c40e35..4b1ebca8e5a3 100644 --- a/stand/libsa/zfs/devicename_stubs.c +++ b/stand/libsa/zfs/devicename_stubs.c @@ -32,7 +32,7 @@ __FBSDID("$FreeBSD$"); __attribute__((weak)) int -zfs_parsedev(struct zfs_devdesc *dev, const char *devspec, const char **path) +zfs_parsedev(struct devdesc **dev, const char *devspec, const char **path) { return (EINVAL); } diff --git a/stand/libsa/zfs/libzfs.h b/stand/libsa/zfs/libzfs.h index 2f0dfd8afc86..a8ce762d2bc2 100644 --- a/stand/libsa/zfs/libzfs.h +++ b/stand/libsa/zfs/libzfs.h @@ -48,7 +48,7 @@ struct zfs_devdesc { uint64_t root_guid; }; -int zfs_parsedev(struct zfs_devdesc *dev, const char *devspec, +int zfs_parsedev(struct devdesc **dev, const char *devspec, const char **path); char *zfs_fmtdev(struct devdesc *); int zfs_probe_dev(const char *devname, uint64_t *pool_guid); diff --git a/stand/libsa/zfs/zfs.c b/stand/libsa/zfs/zfs.c index bee243352f78..a97d5fe59226 100644 --- a/stand/libsa/zfs/zfs.c +++ b/stand/libsa/zfs/zfs.c @@ -382,13 +382,8 @@ zfs_mount(const char *dev, const char *path, void **data) int rv; errno = 0; - zfsdev = malloc(sizeof(*zfsdev)); - if (zfsdev == NULL) - return (errno); - - rv = zfs_parsedev(zfsdev, dev + 3, NULL); + rv = zfs_parsedev((struct devdesc **)&zfsdev, dev + 3, NULL); if (rv != 0) { - free(zfsdev); return (rv); } @@ -1634,7 +1629,7 @@ struct devsw zfs_dev = { }; int -zfs_parsedev(struct zfs_devdesc *dev, const char *devspec, const char **path) +zfs_parsedev(struct devdesc **idev, const char *devspec, const char **path) { static char rootname[ZFS_MAXNAMELEN]; static char poolname[ZFS_MAXNAMELEN]; @@ -1643,6 +1638,7 @@ zfs_parsedev(struct zfs_devdesc *dev, const char *devspec, const char **path) const char *np; const char *sep; int rv; + struct zfs_devdesc *dev; np = devspec; if (*np != ':') @@ -1667,13 +1663,19 @@ zfs_parsedev(struct zfs_devdesc *dev, const char *devspec, const char **path) spa = spa_find_by_name(poolname); if (!spa) return (ENXIO); + dev = malloc(sizeof(*dev)); + if (dev == NULL) + return (ENOMEM); dev->pool_guid = spa->spa_guid; rv = zfs_lookup_dataset(spa, rootname, &dev->root_guid); - if (rv != 0) + if (rv != 0) { + free(dev); return (rv); + } if (path != NULL) *path = (*end == '\0') ? end : end + 1; dev->dd.d_dev = &zfs_dev; + *idev = &dev->dd; return (0); } diff --git a/stand/userboot/userboot/devicename.c b/stand/userboot/userboot/devicename.c index 2fffebf282c6..c8b46e7f590c 100644 --- a/stand/userboot/userboot/devicename.c +++ b/stand/userboot/userboot/devicename.c @@ -151,8 +151,8 @@ userboot_parsedev(struct devdesc **dev, const char *devspec, case DEVT_ZFS: #if defined(USERBOOT_ZFS_SUPPORT) - /* XXX assumes sizeof disk_devdesc >= sizeof zfs_devdesc */ - err = zfs_parsedev((struct zfs_devdesc *)idev, np, path); + free(idev); + err = zfs_parsedev(&idev, np, path); if (err != 0) goto fail; break;