From 5ab1cb52b21fdc5524bd970e9b5cdff21a5bcabf Mon Sep 17 00:00:00 2001 From: Conrad Meyer Date: Mon, 23 Dec 2019 20:23:02 +0000 Subject: [PATCH] fstyp(8): Fix WITHOUT_ICONV build Reported by: olivier --- usr.sbin/fstyp/Makefile | 4 ++++ usr.sbin/fstyp/apfs.c | 1 - usr.sbin/fstyp/exfat.c | 6 ++++++ usr.sbin/fstyp/fstyp.c | 4 ++++ usr.sbin/fstyp/hfsplus.c | 1 - usr.sbin/fstyp/ntfs.c | 6 ++++++ 6 files changed, 20 insertions(+), 2 deletions(-) diff --git a/usr.sbin/fstyp/Makefile b/usr.sbin/fstyp/Makefile index 2d3a4681c58d..7915147edac7 100644 --- a/usr.sbin/fstyp/Makefile +++ b/usr.sbin/fstyp/Makefile @@ -13,6 +13,10 @@ MAN= fstyp.8 WARNS?= 2 +.if ${MK_ICONV} == "yes" +CFLAGS+= -DWITH_ICONV +.endif + .include .if ${TARGET_ENDIANNESS} == 1234 diff --git a/usr.sbin/fstyp/apfs.c b/usr.sbin/fstyp/apfs.c index 7d4794b967bb..049a9f862f2b 100644 --- a/usr.sbin/fstyp/apfs.c +++ b/usr.sbin/fstyp/apfs.c @@ -29,7 +29,6 @@ __FBSDID("$FreeBSD$"); #include #include #include -#include #include #include #include diff --git a/usr.sbin/fstyp/exfat.c b/usr.sbin/fstyp/exfat.c index a3b19c151244..d77ba9253d39 100644 --- a/usr.sbin/fstyp/exfat.c +++ b/usr.sbin/fstyp/exfat.c @@ -33,7 +33,9 @@ __FBSDID("$FreeBSD$"); #include #include #include +#ifdef WITH_ICONV #include +#endif #include #include #include @@ -184,6 +186,7 @@ exfat_compute_boot_chksum(FILE *fp, unsigned region, unsigned bytespersec, return (0); } +#ifdef WITH_ICONV static void convert_label(const uint16_t *ucs2label /* LE */, unsigned ucs2len, char *label_out, size_t label_sz) @@ -316,6 +319,7 @@ exfat_find_label(FILE *fp, const struct exfat_vbr *ev, unsigned BPS, free(declust); } } +#endif /* WITH_ICONV */ int fstyp_exfat(FILE *fp, char *label, size_t size) @@ -356,8 +360,10 @@ fstyp_exfat(FILE *fp, char *label, size_t size) goto done; } +#ifdef WITH_ICONV if (show_label) exfat_find_label(fp, ev, bytespersec, label, size); +#endif done: free(cksect); diff --git a/usr.sbin/fstyp/fstyp.c b/usr.sbin/fstyp/fstyp.c index e4c96903dcc6..632fbcb2623c 100644 --- a/usr.sbin/fstyp/fstyp.c +++ b/usr.sbin/fstyp/fstyp.c @@ -38,7 +38,9 @@ __FBSDID("$FreeBSD$"); #include #include #include +#ifdef WITH_ICONV #include +#endif #include #include #include @@ -199,6 +201,7 @@ main(int argc, char **argv) err(1, "setlocale"); caph_cache_catpages(); +#ifdef WITH_ICONV /* Cache iconv conversion data before entering capability mode. */ if (show_label) { for (i = 0; i < nitems(fstypes); i++) { @@ -214,6 +217,7 @@ main(int argc, char **argv) iconv_close(cd); } } +#endif fp = fopen(path, "r"); if (fp == NULL) diff --git a/usr.sbin/fstyp/hfsplus.c b/usr.sbin/fstyp/hfsplus.c index 6e90840b978e..71287465e4ff 100644 --- a/usr.sbin/fstyp/hfsplus.c +++ b/usr.sbin/fstyp/hfsplus.c @@ -29,7 +29,6 @@ __FBSDID("$FreeBSD$"); #include #include #include -#include #include #include #include diff --git a/usr.sbin/fstyp/ntfs.c b/usr.sbin/fstyp/ntfs.c index d7e29c23fe85..440f5716392f 100644 --- a/usr.sbin/fstyp/ntfs.c +++ b/usr.sbin/fstyp/ntfs.c @@ -32,7 +32,9 @@ __FBSDID("$FreeBSD$"); #include +#ifdef WITH_ICONV #include +#endif #include #include #include @@ -94,6 +96,7 @@ struct ntfs_bootfile { uint32_t bf_volsn; } __packed; +#ifdef WITH_ICONV static void convert_label(const void *label /* LE */, size_t labellen, char *label_out, size_t label_sz) @@ -125,6 +128,7 @@ convert_label(const void *label /* LE */, size_t labellen, char *label_out, iconv_close(cd); } +#endif int fstyp_ntfs(FILE *fp, char *label, size_t size) @@ -142,6 +146,7 @@ fstyp_ntfs(FILE *fp, char *label, size_t size) bf = (struct ntfs_bootfile *)read_buf(fp, 0, 512); if (bf == NULL || strncmp(bf->bf_sysid, "NTFS ", 8) != 0) goto fail; +#ifdef WITH_ICONV if (!show_label) goto ok; @@ -171,6 +176,7 @@ fstyp_ntfs(FILE *fp, char *label, size_t size) } ok: +#endif /* WITH_ICONV */ free(bf); free(filerecp);