From owner-svn-src-stable@freebsd.org Mon Nov 9 08:59:57 2015 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 750BFA268D1; Mon, 9 Nov 2015 08:59:57 +0000 (UTC) (envelope-from ngie@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 48E601823; Mon, 9 Nov 2015 08:59:57 +0000 (UTC) (envelope-from ngie@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id tA98xurk008165; Mon, 9 Nov 2015 08:59:56 GMT (envelope-from ngie@FreeBSD.org) Received: (from ngie@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id tA98xtWb008161; Mon, 9 Nov 2015 08:59:55 GMT (envelope-from ngie@FreeBSD.org) Message-Id: <201511090859.tA98xtWb008161@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ngie set sender to ngie@FreeBSD.org using -f From: Garrett Cooper Date: Mon, 9 Nov 2015 08:59:55 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r290589 - stable/10/usr.sbin/makefs X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 09 Nov 2015 08:59:57 -0000 Author: ngie Date: Mon Nov 9 08:59:55 2015 New Revision: 290589 URL: https://svnweb.freebsd.org/changeset/base/290589 Log: MFC r289203,r290180: r289203 (by adrian): makefs: introduce a new option to specify what to round the resulting image up to. From ticket: While trying to run FreeBSD/mips on some device having very small flash media, one is forced to compress file system with mkulzma(8) utility. It is desirable to specify small UFS block/fragment sizes like 4096/512 bytes for makefs(8) and big compression block size like 65535 bytes to mkulzma at the same time. Then one obtains very good comression ratios (like 75% and more) but faces the following problem. geom_uncompress kernel module reports GEOM provider size rounded up to its compression block size. Generally, this changes original media size and now it fails to match the size of embedded UFS file system that leads to other problems, f.e. geom_label kernel module does not like this and skips the file system while tasting the GEOM and looking for UFS label. This makes it impossible to refer to the file system using known UFS label instead of something like /dev/map/rootfs.uncompress. The following patch introduces new command line option "-r roundup" for makefs that makes it round up the image to specified block size. Hence, geom_uncompress does not change GEOM media size for images rounded that way and geom_label accepts such GEOMs just fine. With the patch applied, one can use following commands: $ makefs -t ffs -r 65536 -o bsize=4096,fsize=512,label=flash optimization=space fs.img fs $ mkulzma -s 65536 -o fs.img.ulzma fs.img PR: bin/203707 Submitted by: r290180: Follow up to roundup feature addition in r289203 - Rename -r to -R to avoid the clash with makefs -r in NetBSD - Note that -R is an FFS-specific option because it's not implemented in cd9660 today - Rename the roundup variable to "roundup-size" in the manpage and help text for consistency with other variables. - Bump .Dd (missed in r289203) PR: 203707 Differential Revision: https://reviews.freebsd.org/D3959 Reviewed by: adrian (earlier patch), emaste Sponsored by: EMC / Isilon Storage Division Modified: stable/10/usr.sbin/makefs/ffs.c stable/10/usr.sbin/makefs/makefs.8 stable/10/usr.sbin/makefs/makefs.c stable/10/usr.sbin/makefs/makefs.h Directory Properties: stable/10/ (props changed) Modified: stable/10/usr.sbin/makefs/ffs.c ============================================================================== --- stable/10/usr.sbin/makefs/ffs.c Mon Nov 9 08:05:15 2015 (r290588) +++ stable/10/usr.sbin/makefs/ffs.c Mon Nov 9 08:59:55 2015 (r290589) @@ -410,6 +410,10 @@ ffs_validate(const char *dir, fsnode *ro /* round up to the next block */ fsopts->size = roundup(fsopts->size, ffs_opts->bsize); + /* round up to requested block size, if any */ + if (fsopts->roundup > 0) + fsopts->size = roundup(fsopts->size, fsopts->roundup); + /* calculate density if necessary */ if (ffs_opts->density == -1) ffs_opts->density = fsopts->size / fsopts->inodes + 1; Modified: stable/10/usr.sbin/makefs/makefs.8 ============================================================================== --- stable/10/usr.sbin/makefs/makefs.8 Mon Nov 9 08:05:15 2015 (r290588) +++ stable/10/usr.sbin/makefs/makefs.8 Mon Nov 9 08:59:55 2015 (r290589) @@ -35,7 +35,7 @@ .\" .\" $FreeBSD$ .\" -.Dd August 16, 2013 +.Dd October 29, 2015 .Dt MAKEFS 8 .Os .Sh NAME @@ -53,6 +53,7 @@ .Op Fl m Ar maximum-size .Op Fl N Ar userdb-dir .Op Fl o Ar fs-options +.Op Fl R Ar roundup-size .Op Fl S Ar sector-size .Op Fl s Ar image-size .Op Fl t Ar fs-type @@ -195,6 +196,14 @@ Deprecated. See the .Fl Z flag. +.It Fl R Ar roundup-size +Round the image up to +.Ar roundup-size . +.Ar roundup-size +should be a multiple of the file system block size. +This option only applies to the +.Sy ffs +file system type. .It Fl S Ar sector-size Set the file system sector size to .Ar sector-size . Modified: stable/10/usr.sbin/makefs/makefs.c ============================================================================== --- stable/10/usr.sbin/makefs/makefs.c Mon Nov 9 08:05:15 2015 (r290588) +++ stable/10/usr.sbin/makefs/makefs.c Mon Nov 9 08:59:55 2015 (r290589) @@ -113,7 +113,7 @@ main(int argc, char *argv[]) start_time.tv_sec = start.tv_sec; start_time.tv_nsec = start.tv_usec * 1000; - while ((ch = getopt(argc, argv, "B:b:Dd:f:F:M:m:N:o:ps:S:t:xZ")) != -1) { + while ((ch = getopt(argc, argv, "B:b:Dd:f:F:M:m:N:o:pr:s:S:t:xZ")) != -1) { switch (ch) { case 'B': @@ -209,6 +209,12 @@ main(int argc, char *argv[]) fsoptions.sparse = 1; break; + case 'R': + /* Round image size up to specified block size */ + fsoptions.roundup = + strsuftoll("roundup-size", optarg, 0, LLONG_MAX); + break; + case 's': fsoptions.minsize = fsoptions.maxsize = strsuftoll("size", optarg, 1LL, LLONG_MAX); @@ -359,9 +365,9 @@ usage(void) prog = getprogname(); fprintf(stderr, "usage: %s [-t fs-type] [-o fs-options] [-d debug-mask] [-B endian]\n" -"\t[-S sector-size] [-M minimum-size] [-m maximum-size] [-s image-size]\n" -"\t[-b free-blocks] [-f free-files] [-F mtree-specfile] [-xZ]\n" -"\t[-N userdb-dir] image-file directory | manifest [extra-directory ...]\n", +"\t[-S sector-size] [-M minimum-size] [-m maximum-size] [-R roundup-size]\n" +"\t[-s image-size] [-b free-blocks] [-f free-files] [-F mtree-specfile]\n" +"\t[-xZ] [-N userdb-dir] image-file directory | manifest [extra-directory ...]\n", prog); exit(1); } Modified: stable/10/usr.sbin/makefs/makefs.h ============================================================================== --- stable/10/usr.sbin/makefs/makefs.h Mon Nov 9 08:05:15 2015 (r290588) +++ stable/10/usr.sbin/makefs/makefs.h Mon Nov 9 08:59:55 2015 (r290589) @@ -130,6 +130,7 @@ typedef struct { int needswap; /* non-zero if byte swapping needed */ int sectorsize; /* sector size */ int sparse; /* sparse image, don't fill it with zeros */ + off_t roundup; /* round image size up to this value */ void *fs_specific; /* File system specific additions. */ } fsinfo_t;