git: 4b72bab96e89 - main - mdconfig: don't print NUL in the options list
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Sat, 01 Jun 2024 15:00:22 UTC
The branch main has been updated by imp: URL: https://cgit.FreeBSD.org/src/commit/?id=4b72bab96e8978eaed30fd44f7f51e1b4918d4db commit 4b72bab96e8978eaed30fd44f7f51e1b4918d4db Author: Alan Somers <asomers@FreeBSD.org> AuthorDate: 2024-05-31 21:13:03 +0000 Commit: Warner Losh <imp@FreeBSD.org> 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 }