From nobody Mon Mar 07 16:12:33 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 CBA5B19FB60A; Mon, 7 Mar 2022 16:12:34 +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 4KC3QB00V2z4XSK; Mon, 7 Mar 2022 16:12:33 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1646669554; 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=xuNHyWkDyyCoKlD502TMJPi/L+/EgdpvL2s+6fOEVSg=; b=xY5AZBOFvHCa+B0f6i7mni5yOuNfPA4neEdLKaahrdPmmEA4hTvZdqmcfe+g1FWwFLXyDB 3OvEnTsRRJJBFWKfjevc2YgT05GawPQSJEEZlm8zi+Iu6xAuopwTAUHUunbUxpfssxZecP fHF6Kh9msCtrEiCH2Uvoi546a0uDm1rBOQAJ60VYa3XbRHXMQjS9EcFexUmGUgkBwE9FZv 4hKevQYFJRGImqQke128YMb1nUyyyOeZfy2shTkiqx2sBx0Ffx9VfyB5AMNUH0+IksPVxy 9rdlPAl9wB7N/+WTtTRNDnXWRfyDpbpVBuuBTACom731i1Sxhg0KJxrr1p5dsg== 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 D303936F9; Mon, 7 Mar 2022 16:12:33 +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 227GCXp8090225; Mon, 7 Mar 2022 16:12:33 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 227GCX93090224; Mon, 7 Mar 2022 16:12:33 GMT (envelope-from git) Date: Mon, 7 Mar 2022 16:12:33 GMT Message-Id: <202203071612.227GCX93090224@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Alexander Motin Subject: git: 2117cdd4b4eb - main - GEOM: Introduce gctl_add_param() 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: mav X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 2117cdd4b4ebda7db0270c56f5a3cbdd37ec8cfc Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1646669554; 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=xuNHyWkDyyCoKlD502TMJPi/L+/EgdpvL2s+6fOEVSg=; b=HtUXA7I1u0ZnJVU/X8kc6Piic8ZQ7lOZvjLEqgozoulGHFHZHjYFdP3UDfhITAd9rqXTyk Rt0AZvcwX4odT2zxahJoDq6+hjiH1hFFDjhEbfuqRn64FbIp8cYgnZxt+8V0tp7Z8usSPK AfpoPt61eME0gq7dF6MWiZS6u4P+kKgKMAKJTPNval3zIZMiYOFJrwgo/Cm89RkXJLgGrq nuv4sq/8cotB2jEU5sbfghQotxfwvkmBInFkE4pQ80DwCJUX6978tlQM1gmmFdZQ/YxAAI CVYC3/33inz+Qn3QMKsPPEZgRn0hmUDltViUS56scIlZkh2pU3ZKMGUY1V5t0A== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1646669554; a=rsa-sha256; cv=none; b=rydk0OHrPoFVTdQO7i3j6Rh1zSa7OPRZyzTR/oPnFncHg5uKinfObDqA35W/U2F3UqIBJv 111DAwhhGrG3XnorLJue08SG7THEO+l/UKEipIfYVac5efWs/WYlF27xPxjFa20frbO+ZA JQ1qjlUN7LGURYCohjmxdfQOpVKBFz/QjQ2E61zJv3h+NuePrzRRd8TU9XxAcNzleaDf5x GUf1//8kCRAHTmjUvI7RqouLqPJESCTSXUSC2Um1tUfOCkH3KhoQVysdW3mrhkWDa/kLD7 ZRqXIIgMYqm8goBcP0FSaCZNvxbfS3QVsP+eES+D3Jk1IpwNzuiPgtestX193A== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by mav: URL: https://cgit.FreeBSD.org/src/commit/?id=2117cdd4b4ebda7db0270c56f5a3cbdd37ec8cfc commit 2117cdd4b4ebda7db0270c56f5a3cbdd37ec8cfc Author: Alexander Motin AuthorDate: 2022-03-07 16:06:11 +0000 Commit: Alexander Motin CommitDate: 2022-03-07 16:12:25 +0000 GEOM: Introduce gctl_add_param() API. Make gctl_add_param() API public, allowing more precise control over parameter flags. Previously it was impossible to properly declare write-only ASCII parameters, used for result reporting, they were declared as read-write binary instead, that was not nice. MFC after: 1 month --- lib/geom/part/geom_part.c | 5 +++-- lib/libgeom/geom_ctl.c | 8 ++++---- lib/libgeom/libgeom.h | 2 ++ sbin/ccdconfig/ccdconfig.c | 8 ++++++-- sbin/geom/core/geom.c | 5 +++-- sbin/gvinum/gvinum.c | 15 +++++++++++---- usr.sbin/bsdinstall/partedit/gpart_ops.c | 6 ++++-- 7 files changed, 33 insertions(+), 16 deletions(-) diff --git a/lib/geom/part/geom_part.c b/lib/geom/part/geom_part.c index b21ebf7ef8d8..41131646e246 100644 --- a/lib/geom/part/geom_part.c +++ b/lib/geom/part/geom_part.c @@ -1327,8 +1327,9 @@ gpart_issue(struct gctl_req *req, unsigned int fl __unused) goto done; } - bzero(buf, sizeof(buf)); - gctl_rw_param(req, "output", sizeof(buf), buf); + buf[0] = '\0'; + gctl_add_param(req, "output", sizeof(buf), buf, + GCTL_PARAM_WR | GCTL_PARAM_ASCII); errstr = gctl_issue(req); if (errstr == NULL || errstr[0] == '\0') { if (buf[0] != '\0') diff --git a/lib/libgeom/geom_ctl.c b/lib/libgeom/geom_ctl.c index 1d5c52fc3779..b60c4c297257 100644 --- a/lib/libgeom/geom_ctl.c +++ b/lib/libgeom/geom_ctl.c @@ -151,8 +151,8 @@ gctl_new_arg(struct gctl_req *req) return (ap); } -static void -gctl_param_add(struct gctl_req *req, const char *name, int len, void *value, +void +gctl_add_param(struct gctl_req *req, const char *name, int len, void *value, int flag) { struct gctl_req_arg *ap; @@ -181,14 +181,14 @@ void gctl_ro_param(struct gctl_req *req, const char *name, int len, const void* value) { - gctl_param_add(req, name, len, __DECONST(void *, value), GCTL_PARAM_RD); + gctl_add_param(req, name, len, __DECONST(void *, value), GCTL_PARAM_RD); } void gctl_rw_param(struct gctl_req *req, const char *name, int len, void *value) { - gctl_param_add(req, name, len, value, GCTL_PARAM_RW); + gctl_add_param(req, name, len, value, GCTL_PARAM_RW); } const char * diff --git a/lib/libgeom/libgeom.h b/lib/libgeom/libgeom.h index fc593b234302..9be27208a98c 100644 --- a/lib/libgeom/libgeom.h +++ b/lib/libgeom/libgeom.h @@ -149,6 +149,8 @@ void gctl_dump(struct gctl_req *, FILE *); void gctl_free(struct gctl_req *); struct gctl_req *gctl_get_handle(void); const char *gctl_issue(struct gctl_req *); +void gctl_add_param(struct gctl_req *req, const char *name, int len, + void *value, int flag); void gctl_ro_param(struct gctl_req *, const char *, int, const void *); void gctl_rw_param(struct gctl_req *, const char *, int, void *); diff --git a/sbin/ccdconfig/ccdconfig.c b/sbin/ccdconfig/ccdconfig.c index 6d22b14deed8..1429426e8638 100644 --- a/sbin/ccdconfig/ccdconfig.c +++ b/sbin/ccdconfig/ccdconfig.c @@ -263,7 +263,9 @@ do_single(int argc, char **argv, int action) cp += strlen(_PATH_DEV); gctl_ro_param(grq, buf1, -1, cp); } - gctl_rw_param(grq, "output", sizeof(buf1), buf1); + buf1[0] = '\0'; + gctl_add_param(grq, "output", sizeof(buf1), buf1, + GCTL_PARAM_WR | GCTL_PARAM_ASCII); errstr = gctl_issue(grq); if (errstr == NULL) { if (verbose) { @@ -371,10 +373,12 @@ dumpout(int unit) grq = gctl_get_handle(); ncp = 65536; cp = malloc(ncp); + cp[0] = '\0'; gctl_ro_param(grq, "verb", -1, "list"); gctl_ro_param(grq, "class", -1, "CCD"); gctl_ro_param(grq, "unit", sizeof(unit), &unit); - gctl_rw_param(grq, "output", ncp, cp); + gctl_add_param(grq, "output", ncp, cp, + GCTL_PARAM_WR | GCTL_PARAM_ASCII); errstr = gctl_issue(grq); if (errstr != NULL) errx(1, "%s\nor possibly kernel and ccdconfig out of sync", diff --git a/sbin/geom/core/geom.c b/sbin/geom/core/geom.c index 0202be9a063e..9d93e9b9989f 100644 --- a/sbin/geom/core/geom.c +++ b/sbin/geom/core/geom.c @@ -487,7 +487,7 @@ run_command(int argc, char *argv[]) gctl_ro_param(req, "version", sizeof(*version), version); parse_arguments(cmd, req, &argc, &argv); - bzero(buf, sizeof(buf)); + buf[0] = '\0'; if (cmd->gc_func != NULL) { unsigned flags; @@ -495,7 +495,8 @@ run_command(int argc, char *argv[]) cmd->gc_func(req, flags); errstr = req->error; } else { - gctl_rw_param(req, "output", sizeof(buf), buf); + gctl_add_param(req, "output", sizeof(buf), buf, + GCTL_PARAM_WR | GCTL_PARAM_ASCII); errstr = gctl_issue(req); } if (errstr != NULL && errstr[0] != '\0') { diff --git a/sbin/gvinum/gvinum.c b/sbin/gvinum/gvinum.c index 50947a30a725..5a081e92a8df 100644 --- a/sbin/gvinum/gvinum.c +++ b/sbin/gvinum/gvinum.c @@ -575,13 +575,15 @@ find_name(const char *prefix, int type, int namelen) char line[1024]; comment[0] = '\0'; + buf[0] = '\0'; /* Find a name. Fetch out configuration first. */ req = gctl_get_handle(); gctl_ro_param(req, "class", -1, "VINUM"); gctl_ro_param(req, "verb", -1, "getconfig"); gctl_ro_param(req, "comment", -1, comment); - gctl_rw_param(req, "config", sizeof(buf), buf); + gctl_add_param(req, "config", sizeof(buf), buf, + GCTL_PARAM_WR | GCTL_PARAM_ASCII); errstr = gctl_issue(req); if (errstr != NULL) { warnx("can't get configuration: %s", errstr); @@ -841,13 +843,16 @@ gvinum_list(int argc, char * const *argv) } + config[0] = '\0'; + req = gctl_get_handle(); gctl_ro_param(req, "class", -1, "VINUM"); gctl_ro_param(req, "verb", -1, "list"); gctl_ro_param(req, "cmd", -1, cmd); gctl_ro_param(req, "argc", sizeof(int), &argc); gctl_ro_param(req, "flags", sizeof(int), &flags); - gctl_rw_param(req, "config", sizeof(config), config); + gctl_add_param(req, "config", sizeof(config), config, + GCTL_PARAM_WR | GCTL_PARAM_ASCII); if (argc) { for (i = 0; i < argc; i++) { snprintf(buf, sizeof(buf), "argv%d", i); @@ -1418,15 +1423,17 @@ printconfig(FILE *of, const char *comment) const char *errstr; time_t now; char buf[GV_CFG_LEN + 1]; - + uname(&uname_s); time(&now); + buf[0] = '\0'; req = gctl_get_handle(); gctl_ro_param(req, "class", -1, "VINUM"); gctl_ro_param(req, "verb", -1, "getconfig"); gctl_ro_param(req, "comment", -1, comment); - gctl_rw_param(req, "config", sizeof(buf), buf); + gctl_add_param(req, "config", sizeof(buf), buf, + GCTL_PARAM_WR | GCTL_PARAM_ASCII); errstr = gctl_issue(req); if (errstr != NULL) { warnx("can't get configuration: %s", errstr); diff --git a/usr.sbin/bsdinstall/partedit/gpart_ops.c b/usr.sbin/bsdinstall/partedit/gpart_ops.c index b49ff1c9fd42..f95cc514903b 100644 --- a/usr.sbin/bsdinstall/partedit/gpart_ops.c +++ b/usr.sbin/bsdinstall/partedit/gpart_ops.c @@ -1207,12 +1207,13 @@ addpartform: } } + output[0] = '\0'; + r = gctl_get_handle(); gctl_ro_param(r, "class", -1, "PART"); gctl_ro_param(r, "arg0", -1, geom->lg_name); gctl_ro_param(r, "flags", -1, GPART_FLAGS); gctl_ro_param(r, "verb", -1, "add"); - gctl_ro_param(r, "type", -1, items[0].text); snprintf(sizestr, sizeof(sizestr), "%jd", size); gctl_ro_param(r, "size", -1, sizestr); @@ -1220,7 +1221,8 @@ addpartform: gctl_ro_param(r, "start", -1, startstr); if (items[3].text[0] != '\0') gctl_ro_param(r, "label", -1, items[3].text); - gctl_rw_param(r, "output", sizeof(output), output); + gctl_add_param(r, "output", sizeof(output), output, + GCTL_PARAM_WR | GCTL_PARAM_ASCII); errstr = gctl_issue(r); if (errstr != NULL && errstr[0] != '\0') { gpart_show_error("Error", NULL, errstr);