From 5ad283b3c60d63086221068d6f7619bfe7650d2d Mon Sep 17 00:00:00 2001 From: Juli Mallett Date: Wed, 27 Nov 2013 21:55:43 +0000 Subject: [PATCH] Provide a helpful diagnostic when the minimum size rounded to the block size would exceed the maximum size. This can be a difficult problem to diagnose if one is, for instance, using -s with a fixed size in a script and the bsize calculated for a filesystem image changes, necessitating a re-rounding of the image size or a hand-setting of the bsize. Previously one would get a cryptic message about how the size exceeded the maximum size, which normally only happens if the contents of the image are larger than specified. --- usr.sbin/makefs/ffs.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/usr.sbin/makefs/ffs.c b/usr.sbin/makefs/ffs.c index 0417d86095ec..92d5508f5d24 100644 --- a/usr.sbin/makefs/ffs.c +++ b/usr.sbin/makefs/ffs.c @@ -361,6 +361,13 @@ ffs_validate(const char *dir, fsnode *root, fsinfo_t *fsopts) if (ffs_opts->avgfpdir == -1) ffs_opts->avgfpdir = AFPDIR; + if (roundup(fsopts->minsize, ffs_opts->bsize) > fsopts->maxsize) + errx(1, "`%s' minsize of %lld rounded up to ffs bsize of %d " + "exceeds maxsize %lld. Lower bsize, or round the minimum " + "and maximum sizes to bsize.", dir, + (long long)fsopts->minsize, ffs_opts->bsize, + (long long)fsopts->maxsize); + /* calculate size of tree */ ffs_size_dir(root, fsopts); fsopts->inodes += ROOTINO; /* include first two inodes */