From nobody Wed Nov 30 22:31:11 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 4NMv7M5cQYz4jCJW; Wed, 30 Nov 2022 22:31: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 4NMv7M4VyHz43Tv; Wed, 30 Nov 2022 22:31:11 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1669847471; 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=u5Bh6YOtKX2cftYFBVGK1/Q/e6CkVx2lntZcbJiaJKM=; b=FZuxfPtn6FYHeIvUkdas4FDz7VxT5rtsaLeE5U18sKw1O1d4E5n8aGZoJdTc7xC+SUQPke yNQaXUdRTYz8pO7AAC4PVmNb4h6xxAfW39/dTaeAEecM556MCqXPUjkcB+A3zkUJm1vHJC 0iCjNQs1gNPQJUSK6pyNKrymkfmZrcLVD+i+MfFsnt3O2m10y1NZuOrkunYjR+e5ov7pL8 8kEvk5YG8KG+Uns1+Q73u0NuT6EaR3r0Q8VDLNP0IxAcb023SJFziQPnC+Wma3GsxlzJAx Mv+AZ73d5qQcFDzNV08ttMdPqgEJR4wr64uilpp8cgToMV2kwBXZx1PPDc/Thw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1669847471; 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=u5Bh6YOtKX2cftYFBVGK1/Q/e6CkVx2lntZcbJiaJKM=; b=fMShm395K/oU4rTzl5W2lYWn/y4ifiOm17L2DZLI2bs63At3740gblzuJoCu+kvuzhoY7u iz8eEbpTGUSItmsuHszKkwpDSaBK6dux0quEX8yLjhQzO5IdvZZNChFLR8i9RkMqz01KMZ vvlwUhht+fpmbkT7cguGaYqSNTnfMcsmLlhyZWt6nl7dWiUu97ccygGUM/P+s59jsT2T8D h1ZwcRJQVNuIvsoUj0hYq8Q6pTPalT2qrAqBDtRe4QER6RLbqwQwMxwj0o3zpNXhOGYv0/ tXxfmMhcTIAFHnamUHSNEf2K3qEtJ2Eto3IB0ysQPY9hwVEGWkfKTP1TdshMbw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1669847471; a=rsa-sha256; cv=none; b=OuO/NAux7CoCkuuXVcxB5VdrIWTVCZ7tAbNNweulHzTT6H0ygajjJqA3jcllpOE+UDsdFq DzlcivPnR+K8tsOtkXgYWg8Q7vUrKBpr3V917AmRe5Y1V25VShyg0Pl9xepukoOqh2xzpa Rh4qlICRQwljVEJPmdXdvkV+l4LqqUO8aIGlP6d0s54PzA6K5X//3yNF1MZVWxXwhPjFkK LRtekuoeTRc2ZxlpO2XpZnlOtNRuqV08jgNxRhKCi8cDoNS0KRK5pCF5z8+3dyGvxnPra/ C93AJoPscWf5Rd7ba1g0AryDHp6Q8Pi0RtGAzqddYYZSSNcMkRIzex3Sxjo66A== 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 4NMv7M322FzDcw; Wed, 30 Nov 2022 22:31: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 2AUMVBeH023277; Wed, 30 Nov 2022 22:31:11 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 2AUMVBaO023276; Wed, 30 Nov 2022 22:31:11 GMT (envelope-from git) Date: Wed, 30 Nov 2022 22:31:11 GMT Message-Id: <202211302231.2AUMVBaO023276@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: ba11bc368e61 - main - stand: Change zfs_parsedev() API 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: ba11bc368e612e7c5bbc195830a280f8af73ce18 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by imp: URL: https://cgit.FreeBSD.org/src/commit/?id=ba11bc368e612e7c5bbc195830a280f8af73ce18 commit ba11bc368e612e7c5bbc195830a280f8af73ce18 Author: Warner Losh AuthorDate: 2022-11-30 22:08:22 +0000 Commit: Warner Losh CommitDate: 2022-11-30 22:30:31 +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 --- 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;