Hi, I have added a sparse option to makefs, where the tool does not fill the file with zeros, before laying out the data on it. This is handy when we are creating a VM image because, 1. It reduces the creation time significantly. 2. Copying around is less time consuming (Tools like rsync and cp can deal efficiently with sparse files) 3. Easily fits the image into a CD without additional processing like 'cp --sparse=Always' etc. Please see if this can be made a part of main tree. ============ *** ../9/usr/src/usr.sbin/makefs/makefs.c 2012-01-02 19:25:41.000000000 -0800 --- usr/src/usr.sbin/makefs/makefs.c 2012-04-22 22:38:49.000000000 -0700 *************** *** 112,118 **** start_time.tv_sec = start.tv_sec; start_time.tv_nsec = start.tv_usec * 1000; ! while ((ch = getopt(argc, argv, "B:b:d:f:F:M:m:N:o:s:S:t:x")) != -1) { switch (ch) { case 'B': --- 112,118 ---- start_time.tv_sec = start.tv_sec; start_time.tv_nsec = start.tv_usec * 1000; ! while ((ch = getopt(argc, argv, "B:b:d:f:F:M:m:N:o:s:S:t:xp")) != -1) { switch (ch) { case 'B': *************** *** 224,230 **** case 'x': fsoptions.onlyspec = 1; break; ! case '?': default: usage(); --- 224,232 ---- case 'x': fsoptions.onlyspec = 1; break; ! case 'p': ! fsoptions.sparse = 1; ! break; case '?': default: usage(); *************** *** 335,341 **** 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] [-x]\n" "\t[-N userdb-dir] image-file directory | manifest\n", prog); exit(1); --- 337,343 ---- 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] [-x] [-p sparse]\n" "\t[-N userdb-dir] image-file directory | manifest\n", prog); exit(1); *** ../9/usr/src/usr.sbin/makefs/makefs.h 2012-01-02 19:25:41.000000000 -0800 --- usr/src/usr.sbin/makefs/makefs.h 2012-04-22 22:49:25.000000000 -0700 *************** *** 127,132 **** --- 127,133 ---- int freeblockpc; /* free block % */ int needswap; /* non-zero if byte swapping needed */ int sectorsize; /* sector size */ + int sparse; /* sparse image, don't fill it with zeros */ void *fs_specific; /* File system specific additions. */ } fsinfo_t; *** ../9/usr/src/usr.sbin/makefs/ffs.c 2012-01-02 19:25:41.000000000 -0800 --- usr/src/usr.sbin/makefs/ffs.c 2012-04-30 16:06:01.715365000 -0700 *************** *** 493,498 **** --- 493,508 ---- bufsize = sfs.f_iosize; #endif bufrem = fsopts->size; + + if (fsopts->sparse) { + if (lseek(fsopts->fd, bufrem - bufsize, SEEK_SET) == -1) { + printf ("ERROR in lseek. Sparse option disabled\n"); + fsopts->sparse = 0; + } else { + bufrem = bufsize; /* Seek to end and write one block */ + } + } + if (debug & DEBUG_FS_CREATE_IMAGE) printf( "zero-ing image `%s', %lld sectors, using %d byte chunks\n", ============ -- Thanks, Shésha (uint64_t cache, uint16_t FOOD) { return 0XCODE; }Received on Mon Apr 30 2012 - 22:24:45 UTC
This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:40:26 UTC