Date: Sun, 5 Apr 2020 02:45:54 +0000 (UTC) From: Xin LI <delphij@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r359638 - stable/12/sbin/fsck_msdosfs Message-ID: <202004050245.0352js2Z075220@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: delphij Date: Sun Apr 5 02:45:54 2020 New Revision: 359638 URL: https://svnweb.freebsd.org/changeset/base/359638 Log: MFC r357716: Use humanize_number to format available and bad space size Modified: stable/12/sbin/fsck_msdosfs/Makefile stable/12/sbin/fsck_msdosfs/check.c Directory Properties: stable/12/ (props changed) Modified: stable/12/sbin/fsck_msdosfs/Makefile ============================================================================== --- stable/12/sbin/fsck_msdosfs/Makefile Sun Apr 5 02:27:49 2020 (r359637) +++ stable/12/sbin/fsck_msdosfs/Makefile Sun Apr 5 02:45:54 2020 (r359638) @@ -9,6 +9,7 @@ PROG= fsck_msdosfs MAN= fsck_msdosfs.8 SRCS= main.c check.c boot.c fat.c dir.c fsutil.c -CFLAGS+= -I${FSCK} +CFLAGS+= -I${FSCK} -DHAVE_LIBUTIL_H +LIBADD= util .include <bsd.prog.mk> Modified: stable/12/sbin/fsck_msdosfs/check.c ============================================================================== --- stable/12/sbin/fsck_msdosfs/check.c Sun Apr 5 02:27:49 2020 (r359637) +++ stable/12/sbin/fsck_msdosfs/check.c Sun Apr 5 02:45:54 2020 (r359638) @@ -33,6 +33,9 @@ static const char rcsid[] = "$FreeBSD$"; #endif /* not lint */ +#ifdef HAVE_LIBUTIL_H +#include <libutil.h> +#endif #include <stdlib.h> #include <string.h> #include <stdio.h> @@ -126,15 +129,38 @@ checkfilesys(const char *fname) mod |= FSERROR; } +#ifdef HAVE_LIBUTIL_H + char freestr[7], badstr[7]; + + int64_t freebytes = boot.NumFree * boot.ClusterSize; + humanize_number(freestr, sizeof(freestr), freebytes, "", + HN_AUTOSCALE, HN_DECIMAL | HN_IEC_PREFIXES); + if (boot.NumBad) { + int64_t badbytes = boot.NumBad * boot.ClusterSize; + + humanize_number(badstr, sizeof(badstr), badbytes, "", + HN_AUTOSCALE, HN_B | HN_DECIMAL | HN_IEC_PREFIXES); + + pwarn("%d files, %sB free (%d clusters), %sB bad (%d clusters)\n", + boot.NumFiles, + freestr, boot.NumFree, + badstr, boot.NumBad); + } else { + pwarn("%d files, %sB free (%d clusters)\n", + boot.NumFiles, + freestr, boot.NumFree); + } +#else if (boot.NumBad) - pwarn("%d files, %d free (%d clusters), %d bad (%d clusters)\n", + pwarn("%d files, %d KiB free (%d clusters), %d KiB bad (%d clusters)\n", boot.NumFiles, boot.NumFree * boot.ClusterSize / 1024, boot.NumFree, boot.NumBad * boot.ClusterSize / 1024, boot.NumBad); else - pwarn("%d files, %d free (%d clusters)\n", + pwarn("%d files, %d KiB free (%d clusters)\n", boot.NumFiles, boot.NumFree * boot.ClusterSize / 1024, boot.NumFree); +#endif if (mod && (mod & FSERROR) == 0) { if (mod & FSDIRTY) {
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202004050245.0352js2Z075220>