From nobody Sat Jun 01 15:00:22 2024 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 4Vs37q11j5z5N1fc; Sat, 01 Jun 2024 15:00:23 +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 4Vs37q0X1Xz4J6F; Sat, 1 Jun 2024 15:00:23 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1717254023; 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=OoJvUcSHPHKCxZDXv16bbrLP0E1JSj+m4H6rl/WIaLo=; b=oFNSnoIPt/9BrSVTLk2rsdbN73VqeLVZOav4c2vBhPaU48FxLm5sjR/S3a2RLXD7s4badF sUdJQpADSiVYGAkUkMtK+VQs1r7h0OjPiuz9wBG4sAZwDGh8VVQb2BmGrdJNNL4jCeVSws Pa6SNn+QYbvE1IwPIDrUw44HuTp4nvVx924t3njTlevsbnwD4BnwbC8A777eD5kGb4fJ28 M+Yx8E4mSNlZ2VHD1e1sgYqD3qfwGPU5Dz58An0k4yGvcw2nUjtsAeyjwB0GciCQRqHtR6 xbueKSRvqu+1n23TBksjdGWcsAb6TqNREvTBcfYVr4IDWLrj4u3Q+xyuEkPt9g== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1717254023; a=rsa-sha256; cv=none; b=nxgu3SqyUuG0kvooBPXFh3Laaw1IgcgJ60MWISwCpjyRarzXkOwf3gK8dE+xN5CPR4D+sD MdPBHfrDxgaMBGfeYrbRAHqOclNhmtS8snowwcENCSajVTf1WaWldsxiCanmBYAyoLr78r zcsK1J9ducQx0ree2cnxTRlSEGZQ/f0HUXUNih0kMWo981ljhb1rfI0AmSB5tKuUkcctc0 xsCs1D29bZjl7J9joboxTUlsQAQbrSofgFz2mZHEbZkhcXzwZY6y876R4SAK9RY0wr4Wq5 AZsCaEkTpDpfOENIgBzsYM3TVQVzyTRHDxVM3gr6ItreNjOzgeFpZ4rvdvICgQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1717254023; 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=OoJvUcSHPHKCxZDXv16bbrLP0E1JSj+m4H6rl/WIaLo=; b=WL1jKQzyefyR9YLSFF5lzW8z4WEuZb8wop3E26BuiXWB+AT3GBYTJNPZnuWBMP2UWH60Rw dlo1hQ8Eyu50aiH1Fm2g+Vx8xT+Dd7FCNB06XDkT5O02S/mKfYhdT5UW1xk+Wodbac4ylY CrJypzOIZXLV+5qYc3cZKYS1cpxKZLYPgLONKS/FQqWgWryu+n67bcCYlaEkd5EToT5lDn AzmFPqIerJLGQoIyMobePgFt1I1wKUH5kz9xZLAM7ktDOPDSkg/fYswMcJobFRPliNqghD D2nmkYreP0joIlOB48Na8bTYrwvbH19yt4xFGWa8PUzYAGI+iF26nTbaMkP8nw== 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 4Vs37q06hPz1BXW; Sat, 1 Jun 2024 15:00:23 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 451F0MZw038240; Sat, 1 Jun 2024 15:00:22 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 451F0MHx038237; Sat, 1 Jun 2024 15:00:22 GMT (envelope-from git) Date: Sat, 1 Jun 2024 15:00:22 GMT Message-Id: <202406011500.451F0MHx038237@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: 4b72bab96e89 - main - mdconfig: don't print NUL in the options list 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: X-BeenThere: dev-commits-src-main@freebsd.org Sender: owner-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: 4b72bab96e8978eaed30fd44f7f51e1b4918d4db Auto-Submitted: auto-generated The branch main has been updated by imp: URL: https://cgit.FreeBSD.org/src/commit/?id=4b72bab96e8978eaed30fd44f7f51e1b4918d4db commit 4b72bab96e8978eaed30fd44f7f51e1b4918d4db Author: Alan Somers AuthorDate: 2024-05-31 21:13:03 +0000 Commit: Warner Losh CommitDate: 2024-06-01 14:08:16 +0000 mdconfig: don't print NUL in the options list Fixes: b01988d5e570 Sponsored by: Axcient Reviewed by: imp, Ricardo Branco Pull Request: https://github.com/freebsd/freebsd-src/pull/1268 --- sbin/mdconfig/mdconfig.c | 38 ++++++++++++++++++------------------ sbin/mdconfig/tests/mdconfig_test.sh | 20 +++++++++++++++++++ 2 files changed, 39 insertions(+), 19 deletions(-) diff --git a/sbin/mdconfig/mdconfig.c b/sbin/mdconfig/mdconfig.c index d49eb6ed08e5..abcb34c1fed1 100644 --- a/sbin/mdconfig/mdconfig.c +++ b/sbin/mdconfig/mdconfig.c @@ -409,7 +409,7 @@ print_options(const char *dev, const char *file) { struct md_ioctl mdiox; int unit; - char sep = '\0'; + const char *sep = ""; if (sscanf(dev, "md%d", &unit) != 1) err(1, "invalid device: %s", dev); @@ -427,40 +427,40 @@ print_options(const char *dev, const char *file) printf("\t"); if (mdiox.md_options & MD_ASYNC) { - printf("%casync", sep); - sep = ','; + printf("%sasync", sep); + sep = ","; } if (mdiox.md_options & MD_CACHE) { - printf("%ccache", sep); - sep = ','; + printf("%scache", sep); + sep = ","; } if (mdiox.md_options & MD_CLUSTER) { - printf("%ccluster", sep); - sep = ','; + printf("%scluster", sep); + sep = ","; } if (mdiox.md_options & MD_COMPRESS) { - printf("%ccompress", sep); - sep = ','; + printf("%scompress", sep); + sep = ","; } if (mdiox.md_options & MD_FORCE) { - printf("%cforce", sep); - sep = ','; + printf("%sforce", sep); + sep = ","; } if (mdiox.md_options & MD_READONLY) { - printf("%creadonly", sep); - sep = ','; + printf("%sreadonly", sep); + sep = ","; } if (mdiox.md_options & MD_RESERVE) { - printf("%creserve", sep); - sep = ','; + printf("%sreserve", sep); + sep = ","; } if (mdiox.md_options & MD_VERIFY) { - printf("%cverify", sep); - sep = ','; + printf("%sverify", sep); + sep = ","; } if (mdiox.md_options & MD_MUSTDEALLOC) { - printf("%cmustdealloc", sep); - sep = ','; + printf("%smustdealloc", sep); + sep = ","; } } diff --git a/sbin/mdconfig/tests/mdconfig_test.sh b/sbin/mdconfig/tests/mdconfig_test.sh index 655b7fd63b40..ea87ff5d542d 100755 --- a/sbin/mdconfig/tests/mdconfig_test.sh +++ b/sbin/mdconfig/tests/mdconfig_test.sh @@ -296,6 +296,25 @@ attach_size_rounddown_cleanup() cleanup_common } +atf_test_case query_verbose cleanup +query_verbose() +{ + atf_set "descr" "mdconfig -lv should print device details" +} +query_verbose_body() +{ + atf_check -s exit:0 -o save:mdconfig.out \ + -x 'mdconfig -a -t swap -s 1m -o reserve -o force' + md=$(cat mdconfig.out) + atf_check -s exit:0 \ + -o match:"$md[[:space:]]+swap[[:space:]]+1024K[[:space:]]+[-][[:space:]]+[-][[:space:]]+force,reserve" \ + -x "mdconfig -lv -u $md" +} +query_verbose_cleanup() +{ + cleanup_common +} + atf_init_test_cases() { atf_add_test_case attach_vnode_non_explicit_type @@ -307,4 +326,5 @@ atf_init_test_cases() atf_add_test_case attach_swap atf_add_test_case attach_with_specific_unit_number atf_add_test_case attach_size_rounddown + atf_add_test_case query_verbose }