debian/0000755000000000000000000000000012032530420007155 5ustar debian/copyright0000644000000000000000000000246611644157370011141 0ustar This package was debianized by David Kimdon on Sat, 14 Jul 2001 13:24:49 -0700. The current Debian Maintainer is Jérémie Koenig . The previous Debian Maintainer was Franz Pletz . It was downloaded from http://genext2fs.sourceforge.net/ Upstream Author: Xavier Bestel Copyright: 1999 - 2000 Lineo, inc. and John Beppu 1999 - 2001 John Beppu 2000 Xavier Bestel 2002 Edward Betts 2002 Ixia communications This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; version 2 of the License. You should have received a copy of the GNU General Public License with the Debian GNU/Linux distribution in file /usr/share/common-licenses/GPL-2; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. On Debian systems, the complete text of the GNU General Public License can be found in /usr/share/common-licenses/GPL-2 file. The Debian packaging is Copyright (C) 2006, Franz Pletz and is licensed under the GPL, see /usr/share/common-licenses/GPL-2. debian/source/0000755000000000000000000000000011644157370010476 5ustar debian/source/format0000644000000000000000000000001411644157370011704 0ustar 3.0 (quilt) debian/changelog0000644000000000000000000001350312032530420011031 0ustar genext2fs (1.4.1-4build1) quantal; urgency=low * Rebuild for new armel compiler default of ARMv5t. -- Colin Watson Tue, 02 Oct 2012 10:17:04 +0100 genext2fs (1.4.1-4) unstable; urgency=low * debian/patches/byteswap_fix.diff: New patch by Samuel Thibault, fix a segfault in the byte swapping code on little-endian architectures (closes: 644776). -- Jérémie Koenig Tue, 29 Nov 2011 17:42:14 +0100 genext2fs (1.4.1-3) unstable; urgency=low * New maintainer (closes: 579369). * Packaging cleanup: - update autotools dependencies; - update to debhelper 8; - switch to source format 3.0 (quilt); - bump Standards-Version to 3.9.2. * debian/patches/blocksize+creator.diff: New patch, add options -B and -o to select the block size and creator OS (closes: 562999). * Add Vcs-Git and Vcs-Browser fields to debian/control. * Add debian/gbp.conf (configuration for git-buildpackage). -- Jérémie Koenig Sat, 03 Sep 2011 21:35:48 +0200 genext2fs (1.4.1-2.2) unstable; urgency=low * Non-maintainer upload. * Build depend on automake instead of automake1.4. (Closes: #549097). * Version GPL version in debian/copyright. * Bump Standards Version to 3.8.3. -- Barry deFreese Wed, 30 Sep 2009 14:49:16 -0400 genext2fs (1.4.1-2.1) unstable; urgency=low * Non-Maintainer Upload, at BSP in Zurich * in sscanf the "a" could mean "malloc" or the new C99 floating, so don't use it, not to have surprises. -- Giacomo Catenazzi Sat, 12 Jan 2008 23:03:59 +0100 genext2fs (1.4.1-2) unstable; urgency=low * configure.in: Change AC_CONFIG_HEADER to AM_CONFIG_HEADER. -- Franz Pletz Sun, 29 Jul 2007 19:13:04 +0200 genext2fs (1.4.1-1) unstable; urgency=low * New upstream release. (Closes: #406078) * clean.sh: updated. * Switch to debhelper 5. -- Franz Pletz Sun, 29 Jul 2007 19:10:18 +0200 genext2fs (1.4-rc1-2.1) unstable; urgency=low * Non-maintainer upload. * FTBFS: Cannot satisfy Build-Depends on automake (Closes: #395150) -- Neil Williams Fri, 27 Oct 2006 19:08:55 +0100 genext2fs (1.4-rc1-2) unstable; urgency=low * Fixed description (Closes: #371083) -- Franz Pletz Mon, 26 Jun 2006 10:50:19 +0200 genext2fs (1.4-rc1-1) unstable; urgency=low * New upstream release, removed cvs blurb from diff. * debian/control: - New Maintainer. (Closes: #369191) - Tweaked Description. - Bumped Standards-Version to 3.7.2, no further changes necessary. * Updated debian/changelog. * debian/rules: - Moved debhelper compatibility level setting to debian/compat. - Miscellaneous minor cleanups. * Added debian/watch. -- Franz Pletz Sun, 28 May 2006 15:47:23 +0200 genext2fs (1.3-10) unstable; urgency=low * Add build depends on automake and autoconf. (Closes: #341750) -- David Kimdon Mon, 5 Dec 2005 18:09:00 -0800 genext2fs (1.3-9) unstable; urgency=low * chmod +x clean.sh before running it. (Closes: #341457) -- David Kimdon Thu, 1 Dec 2005 17:45:34 -0800 genext2fs (1.3-8) unstable; urgency=low * Update to upstream cvs as of 29-11-2005. This is similar to what 1.4 will be. Preserve permissions. (Closes: #341173) Create lost+found (Closes: #258661) -- David Kimdon Tue, 29 Nov 2005 11:12:31 -0800 genext2fs (1.3-7.1) unstable; urgency=high * Non-maintainer upload. * Apply patch from Finn Thain to fix byteswapping code issues that broke d-i on several arches. Thanks. (Closes: #266039) -- Joshua Kwan Tue, 24 Aug 2004 19:09:01 -0700 genext2fs (1.3-7) unstable; urgency=low * Fix block count rounding. The -b switch again specifies the size of the resulting filesystem image. Patch thanks to Finn Thain (closes: #262352) -- David Kimdon Sat, 7 Aug 2004 09:51:37 +0200 genext2fs (1.3-6) unstable; urgency=low * Fix block counts, now created image fsck clean. (closes: #232023) Thanks to Finn Thain for the fix. -- David Kimdon Sat, 10 Jul 2004 17:37:17 +0200 genext2fs (1.3-5) unstable; urgency=low * - Compile with -O2. - get_workblk() should return zero'd memory. This way we get nul terminations in the produced image. - get_workblk() now allocates the block dynamically on the heap. The previous method of allocating the block as 'static' apparently results in undefined behavior since get_workblk() is 'inline'. Thanks to Vincent Sanders for the patch. (closes: #248987) -- David Kimdon Sat, 15 May 2004 19:37:54 +0200 genext2fs (1.3-4) unstable; urgency=low * Fix assertion failure when there is a 268K file on the filesystem. Patch thanks to Matt Kraai (closes: #201277) -- David Kimdon Mon, 17 Nov 2003 22:53:15 +0100 genext2fs (1.3-3) unstable; urgency=low * Update to current upstream cvs - support triple indirect blocks (removes 8MB limit) - support for groups. -- David Kimdon Sat, 11 Jan 2003 18:45:58 -0800 genext2fs (1.3-2) unstable; urgency=low * apply fix from upstream cvs that appears to fix endian bug (closes: #122411) * mention filesystem size limit in manpage (closes: #122729) * mention that hard links are not supported in manpage (closes: #155464) * add sanity check at the end of the build -- David Kimdon Fri, 8 Mar 2002 23:17:36 -0800 genext2fs (1.3-1) unstable; urgency=low * Initial Release. (closes: #105263) -- David Kimdon Sat, 14 Jul 2001 13:24:49 -0700 debian/watch0000644000000000000000000000014211644157370010224 0ustar version=3 opts=uversionmangle=s/[a-z]+(1-9)$/-$1/ http://sf.net/genext2fs/genext2fs-(.*)\.tar\.gz debian/patches/0000755000000000000000000000000011665275776010643 5ustar debian/patches/autoconf.diff0000644000000000000000000000201611644157370013274 0ustar Index: genext2fs/configure.in =================================================================== --- genext2fs.orig/configure.in 2011-09-03 21:28:05.000000000 +0200 +++ genext2fs/configure.in 2011-09-03 21:29:54.000000000 +0200 @@ -8,7 +8,7 @@ builtin(include, [m4/ac_func_scanf_can_malloc.m4])dnl AM_INIT_AUTOMAKE(genext2fs,1.4.1) -AC_CONFIG_HEADER([config.h]) +AM_CONFIG_HEADER([config.h]) AC_GNU_SOURCE Index: genext2fs/m4/ac_func_scanf_can_malloc.m4 =================================================================== --- genext2fs.orig/m4/ac_func_scanf_can_malloc.m4 2011-09-03 21:28:49.000000000 +0200 +++ genext2fs/m4/ac_func_scanf_can_malloc.m4 2011-09-03 21:29:41.000000000 +0200 @@ -9,7 +9,7 @@ # -------------------------------------- AC_DEFUN([AC_FUNC_SCANF_CAN_MALLOC], [ AC_CHECK_HEADERS([stdlib.h]) - AC_CACHE_CHECK([whether scanf can malloc], [ac_scanf_can_malloc], + AC_CACHE_CHECK([whether scanf can malloc], [ac_cv_func_scanf_can_malloc], [ AC_RUN_IFELSE( [ AC_LANG_PROGRAM( [ debian/patches/series0000644000000000000000000000010611665275776012055 0ustar c99_scanf.diff autoconf.diff blocksize+creator.diff byteswap_fix.diff debian/patches/c99_scanf.diff0000644000000000000000000000132711644157370013240 0ustar commit 3b8ca0ce9a0b58287a780747c90c449bdebfe464 Author: Xavier Bestel Date: Mon Jan 14 08:52:44 2008 +0000 removed use of %as is scanf (GNU conflicts with C99) by Giacomo Catenazzi diff --git a/genext2fs.c b/genext2fs.c index 070b270..f0d797d 100644 --- a/genext2fs.c +++ b/genext2fs.c @@ -286,7 +286,9 @@ typedef unsigned int uint32; // older solaris. Note that this is still not very portable, in that // the return value cannot be trusted. -#if SCANF_CAN_MALLOC +#if 0 // SCANF_CAN_MALLOC +// C99 define "a" for floating point, so you can have runtime surprise +// according the library versions # define SCANF_PREFIX "a" # define SCANF_STRING(s) (&s) #else debian/patches/blocksize+creator.diff0000644000000000000000000004617611644157370015115 0ustar Index: genext2fs/genext2fs.c =================================================================== --- genext2fs.orig/genext2fs.c 2011-09-03 14:21:17.000000000 +0200 +++ genext2fs/genext2fs.c 2011-09-03 14:21:17.000000000 +0200 @@ -151,13 +151,24 @@ // block size -#define BLOCKSIZE 1024 +static int blocksize = 1024; + +#define BLOCKSIZE blocksize #define BLOCKS_PER_GROUP 8192 #define INODES_PER_GROUP 8192 /* Percentage of blocks that are reserved.*/ #define RESERVED_BLOCKS 5/100 #define MAX_RESERVED_BLOCKS 25/100 +/* The default value for s_creator_os. */ +#if defined(__GNU__) +# define CREATOR_OS 1 /* Hurd */ +#elif defined(__FreeBSD__) +# define CREATOR_OS 3 /* FreeBSD */ +#else +# define CREATOR_OS 0 /* Linux */ +#endif + // inode block size (why is it != BLOCKSIZE ?!?) /* The field i_blocks in the ext2 inode stores the number of data blocks @@ -239,10 +250,10 @@ (fs)->sb.s_blocks_per_group - 1) / (fs)->sb.s_blocks_per_group) // Get group block bitmap (bbm) given the group number -#define GRP_GET_GROUP_BBM(fs,grp) ( get_blk((fs),(fs)->gd[(grp)].bg_block_bitmap) ) +#define GRP_GET_GROUP_BBM(fs,grp) ( get_blk((fs), get_gd((fs),(grp))->bg_block_bitmap) ) // Get group inode bitmap (ibm) given the group number -#define GRP_GET_GROUP_IBM(fs,grp) ( get_blk((fs),(fs)->gd[(grp)].bg_inode_bitmap) ) +#define GRP_GET_GROUP_IBM(fs,grp) ( get_blk((fs), get_gd((fs),(grp))->bg_inode_bitmap) ) // Given an inode number find the group it belongs to #define GRP_GROUP_OF_INODE(fs,nod) ( ((nod)-1) / (fs)->sb.s_inodes_per_group) @@ -532,7 +543,7 @@ char d_name[0]; } directory; -typedef uint8 block[BLOCKSIZE]; +typedef uint8 *block; /* blockwalker fields: The blockwalker is used to access all the blocks of a file (including @@ -571,16 +582,12 @@ /* Filesystem structure that support groups */ -#if BLOCKSIZE == 1024 typedef struct { - block zero; // The famous block 0 - superblock sb; // The superblock - groupdescriptor gd[0]; // The group descriptors + uint8 zero[1024]; // Room for bootloader stuff + superblock sb; // The superblock, always at 1024 + // group descriptors come next, see get_gd() below } filesystem; -#else -#error UNHANDLED BLOCKSIZE -#endif // now the endianness swap @@ -820,6 +827,14 @@ return (uint8*)fs + blk*BLOCKSIZE; } +// the group descriptors are aligned on the block size +static inline groupdescriptor * +get_gd(filesystem *fs, int no) +{ + int gdblk = (sizeof (filesystem) + BLOCKSIZE - 1) / BLOCKSIZE; + return ((groupdescriptor *) get_blk(fs, gdblk)) + no; +} + // return a given inode from a filesystem static inline inode * get_nod(filesystem *fs, uint32 nod) @@ -829,7 +844,7 @@ offset = GRP_IBM_OFFSET(fs,nod); grp = GRP_GROUP_OF_INODE(fs,nod); - itab = (inode *)get_blk(fs, fs->gd[grp].bg_inode_table); + itab = (inode *)get_blk(fs, get_gd(fs,grp)->bg_inode_table); return itab+offset-1; } @@ -875,18 +890,18 @@ grp = GRP_GROUP_OF_INODE(fs,nod); nbgroups = GRP_NBGROUPS(fs); - if(!(bk = allocate(get_blk(fs,fs->gd[grp].bg_block_bitmap), 0))) { + if(!(bk = allocate(GRP_GET_GROUP_BBM(fs, grp), 0))) { for(grp=0;grpgd[grp].bg_block_bitmap),0); + bk = allocate(GRP_GET_GROUP_BBM(fs, grp), 0); grp--; } if (!bk) error_msg_and_die("couldn't allocate a block (no free space)"); - if(!(fs->gd[grp].bg_free_blocks_count--)) + if(!(get_gd(fs, grp)->bg_free_blocks_count--)) error_msg_and_die("group descr %d. free blocks count == 0 (corrupted fs?)",grp); if(!(fs->sb.s_free_blocks_count--)) error_msg_and_die("superblock free blocks count == 0 (corrupted fs?)"); - return fs->sb.s_blocks_per_group*grp + bk; + return fs->sb.s_first_data_block + fs->sb.s_blocks_per_group*grp + (bk-1); } // free a block @@ -897,8 +912,8 @@ grp = bk / fs->sb.s_blocks_per_group; bk %= fs->sb.s_blocks_per_group; - deallocate(get_blk(fs,fs->gd[grp].bg_block_bitmap), bk); - fs->gd[grp].bg_free_blocks_count++; + deallocate(GRP_GET_GROUP_BBM(fs, grp), bk); + get_gd(fs, grp)->bg_free_blocks_count++; fs->sb.s_free_blocks_count++; } @@ -918,16 +933,16 @@ /* We do it for all inodes. */ avefreei = fs->sb.s_free_inodes_count / nbgroups; for(grp=0; grpgd[grp].bg_free_inodes_count < avefreei || - fs->gd[grp].bg_free_inodes_count == 0) + if (get_gd(fs, grp)->bg_free_inodes_count < avefreei || + get_gd(fs, grp)->bg_free_inodes_count == 0) continue; if (!best_group || - fs->gd[grp].bg_free_blocks_count > fs->gd[best_group].bg_free_blocks_count) + get_gd(fs, grp)->bg_free_blocks_count > get_gd(fs, best_group)->bg_free_blocks_count) best_group = grp; } - if (!(nod = allocate(get_blk(fs,fs->gd[best_group].bg_inode_bitmap),0))) + if (!(nod = allocate(GRP_GET_GROUP_IBM(fs, best_group), 0))) error_msg_and_die("couldn't allocate an inode (no free inode)"); - if(!(fs->gd[best_group].bg_free_inodes_count--)) + if(!(get_gd(fs, best_group)->bg_free_inodes_count--)) error_msg_and_die("group descr. free blocks count == 0 (corrupted fs?)"); if(!(fs->sb.s_free_inodes_count--)) error_msg_and_die("superblock free blocks count == 0 (corrupted fs?)"); @@ -1390,7 +1405,7 @@ case FM_IFDIR: add2dir(fs, nod, nod, "."); add2dir(fs, nod, parent_nod, ".."); - fs->gd[GRP_GROUP_OF_INODE(fs,nod)].bg_used_dirs_count++; + get_gd(fs, GRP_GROUP_OF_INODE(fs,nod))->bg_used_dirs_count++; break; } } @@ -1860,7 +1875,7 @@ swap_nod(nod); } for(i=0;igd[i])); + swap_gd(get_gd(fs, i)); swap_sb(&fs->sb); } @@ -1870,7 +1885,7 @@ uint32 i; swap_sb(&fs->sb); for(i=0;igd[i])); + swap_gd(get_gd(fs, i)); for(i = 1; i < fs->sb.s_inodes_count; i++) { inode *nod = get_nod(fs, i); @@ -1895,7 +1910,8 @@ // initialize an empty filesystem static filesystem * -init_fs(int nbblocks, int nbinodes, int nbresrvd, int holes, uint32 fs_timestamp) +init_fs(int nbblocks, int nbinodes, int nbresrvd, int holes, + uint32 fs_timestamp, uint32 creator_os) { uint32 i; filesystem *fs; @@ -1921,10 +1937,14 @@ */ min_nbgroups = (nbinodes + INODES_PER_GROUP - 1) / INODES_PER_GROUP; + /* On filesystems with 1k block size, the bootloader area uses a full + * block. For 2048 and up, the superblock can be fitted into block 0. + */ + first_block = (BLOCKSIZE == 1024); + /* nbblocks is the total number of blocks in the filesystem. * a block group can have no more than 8192 blocks. */ - first_block = (BLOCKSIZE == 1024); nbgroups = (nbblocks - first_block + BLOCKS_PER_GROUP - 1) / BLOCKS_PER_GROUP; if(nbgroups < min_nbgroups) nbgroups = min_nbgroups; nbblocks_per_group = rndup((nbblocks - first_block + nbgroups - 1)/nbgroups, 8); @@ -1936,10 +1956,10 @@ gdsz = rndup(nbgroups*sizeof(groupdescriptor),BLOCKSIZE)/BLOCKSIZE; itblsz = nbinodes_per_group * sizeof(inode)/BLOCKSIZE; overhead_per_group = 3 /*sb,bbm,ibm*/ + gdsz + itblsz; - if((uint32)nbblocks - 1 < overhead_per_group * nbgroups) - error_msg_and_die("too much overhead, try fewer inodes or more blocks. Note: options have changed, see --help or the man page."); - free_blocks = nbblocks - overhead_per_group*nbgroups - 1 /*boot block*/; + free_blocks = nbblocks - overhead_per_group*nbgroups - first_block; free_blocks_per_group = nbblocks_per_group - overhead_per_group; + if(free_blocks < 0) + error_msg_and_die("too much overhead, try fewer inodes or more blocks. Note: options have changed, see --help or the man page."); if(!(fs = (filesystem*)calloc(nbblocks, BLOCKSIZE))) error_msg_and_die("not enough memory for filesystem"); @@ -1959,28 +1979,31 @@ fs->sb.s_wtime = fs_timestamp; fs->sb.s_magic = EXT2_MAGIC_NUMBER; fs->sb.s_lastcheck = fs_timestamp; + fs->sb.s_creator_os = creator_os; // set up groupdescriptors - for(i=0, bbmpos=gdsz+2, ibmpos=bbmpos+1, itblpos=ibmpos+1; + for(i=0, bbmpos=first_block+1+gdsz, ibmpos=bbmpos+1, itblpos=ibmpos+1; i free_blocks_per_group) { - fs->gd[i].bg_free_blocks_count = free_blocks_per_group; + gd->bg_free_blocks_count = free_blocks_per_group; free_blocks -= free_blocks_per_group; } else { - fs->gd[i].bg_free_blocks_count = free_blocks; + gd->bg_free_blocks_count = free_blocks; free_blocks = 0; // this is the last block group } if(i) - fs->gd[i].bg_free_inodes_count = nbinodes_per_group; + gd->bg_free_inodes_count = nbinodes_per_group; else - fs->gd[i].bg_free_inodes_count = nbinodes_per_group - + gd->bg_free_inodes_count = nbinodes_per_group - EXT2_FIRST_INO + 2; - fs->gd[i].bg_used_dirs_count = 0; - fs->gd[i].bg_block_bitmap = bbmpos; - fs->gd[i].bg_inode_bitmap = ibmpos; - fs->gd[i].bg_inode_table = itblpos; + gd->bg_used_dirs_count = 0; + gd->bg_block_bitmap = bbmpos; + gd->bg_inode_bitmap = ibmpos; + gd->bg_inode_table = itblpos; } /* Mark non-filesystem blocks and inodes as allocated */ @@ -1988,9 +2011,9 @@ for(i = 0; igd[i].bg_block_bitmap); + bbm = GRP_GET_GROUP_BBM(fs, i); //non-filesystem blocks - for(j = fs->gd[i].bg_free_blocks_count + for(j = get_gd(fs, i)->bg_free_blocks_count + overhead_per_group + 1; j <= BLOCKSIZE * 8; j++) allocate(bbm, j); //system blocks @@ -1998,7 +2021,7 @@ allocate(bbm, j); /* Inode bitmap */ - ibm = get_blk(fs,fs->gd[i].bg_inode_bitmap); + ibm = GRP_GET_GROUP_IBM(fs, i); //non-filesystem inodes for(j = fs->sb.s_inodes_per_group+1; j <= BLOCKSIZE * 8; j++) allocate(ibm, j); @@ -2012,9 +2035,9 @@ // make root inode and directory /* We have groups now. Add the root filesystem in group 0 */ /* Also increment the directory count for group 0 */ - fs->gd[0].bg_free_inodes_count--; - fs->gd[0].bg_used_dirs_count = 1; - itab0 = (inode *)get_blk(fs,fs->gd[0].bg_inode_table); + get_gd(fs, 0)->bg_free_inodes_count--; + get_gd(fs, 0)->bg_used_dirs_count = 1; + itab0 = (inode *)get_blk(fs, get_gd(fs,0)->bg_inode_table); itab0[EXT2_ROOT_INO-1].i_mode = FM_IFDIR | FM_IRWXU | FM_IRGRP | FM_IROTH | FM_IXGRP | FM_IXOTH; itab0[EXT2_ROOT_INO-1].i_ctime = fs_timestamp; itab0[EXT2_ROOT_INO-1].i_mtime = fs_timestamp; @@ -2338,8 +2361,9 @@ for (i = 0; i < GRP_NBGROUPS(fs); i++) { printf("Group No: %d\n", i+1); printf("block bitmap: block %d,inode bitmap: block %d, inode table: block %d\n", - fs->gd[i].bg_block_bitmap, fs->gd[i].bg_inode_bitmap, - fs->gd[i].bg_inode_table); + get_gd(fs, i)->bg_block_bitmap, + get_gd(fs, i)->bg_inode_bitmap, + get_gd(fs, i)->bg_inode_table); printf("block bitmap allocation:\n"); print_bm(GRP_GET_GROUP_BBM(fs, i),fs->sb.s_blocks_per_group); printf("inode bitmap allocation:\n"); @@ -2421,10 +2445,12 @@ " -x, --starting-image \n" " -d, --root \n" " -D, --devtable \n" + " -B, --block-size \n" " -b, --size-in-blocks \n" " -i, --bytes-per-inode \n" " -N, --number-of-inodes \n" " -m, --reserved-percentage \n" + " -o, --creator-os 'linux', 'hurd', 'freebsd' or a numerical value.\n" " -g, --block-map Generate a block map file for this path.\n" " -e, --fill-value Fill unallocated blocks with value.\n" " -z, --allow-holes Allow files with holes.\n" @@ -2446,6 +2472,29 @@ extern char* optarg; extern int optind, opterr, optopt; +// parse the value for -o +int +lookup_creator_os(const char *name) +{ + static const char *const creators[] = + {"linux", "hurd", "2", "freebsd", NULL}; + char *endptr; + int i; + + // numerical value ? + i = strtol(name, &endptr, 0); + if(name[0] && *endptr == '\0') + return i; + + // symbolic name ? + for(i=0; creators[i]; i++) + if(strcasecmp(creators[i], name) == 0) + return i; + + // whatever ? + return -1; +} + int main(int argc, char **argv) { @@ -2455,6 +2504,7 @@ float bytes_per_inode = -1; float reserved_frac = -1; int fs_timestamp = -1; + int creator_os = CREATOR_OS; char * fsout = "-"; char * fsin = 0; char * dopt[MAX_DOPT]; @@ -2478,10 +2528,12 @@ { "starting-image", required_argument, NULL, 'x' }, { "root", required_argument, NULL, 'd' }, { "devtable", required_argument, NULL, 'D' }, + { "block-size", required_argument, NULL, 'B' }, { "size-in-blocks", required_argument, NULL, 'b' }, { "bytes-per-inode", required_argument, NULL, 'i' }, { "number-of-inodes", required_argument, NULL, 'N' }, { "reserved-percentage", required_argument, NULL, 'm' }, + { "creator-os", required_argument, NULL, 'o' }, { "block-map", required_argument, NULL, 'g' }, { "fill-value", required_argument, NULL, 'e' }, { "allow-holes", no_argument, NULL, 'z' }, @@ -2497,11 +2549,11 @@ app_name = argv[0]; - while((c = getopt_long(argc, argv, "x:d:D:b:i:N:m:g:e:zfqUPhVv", longopts, NULL)) != EOF) { + while((c = getopt_long(argc, argv, "x:d:D:B:b:i:N:m:o:g:e:zfqUPhVv", longopts, NULL)) != EOF) { #else app_name = argv[0]; - while((c = getopt(argc, argv, "x:d:D:b:i:N:m:g:e:zfqUPhVv")) != EOF) { + while((c = getopt(argc, argv, "x:d:D:B:b:i:N:m:o:g:e:zfqUPhVv")) != EOF) { #endif /* HAVE_GETOPT_LONG */ switch(c) { @@ -2512,6 +2564,9 @@ case 'D': dopt[didx++] = optarg; break; + case 'B': + blocksize = SI_atof(optarg); + break; case 'b': nbblocks = SI_atof(optarg); break; @@ -2524,6 +2579,9 @@ case 'm': reserved_frac = SI_atof(optarg) / 100; break; + case 'o': + creator_os = lookup_creator_os(optarg); + break; case 'g': gopt[gidx++] = optarg; break; @@ -2567,6 +2625,11 @@ error_msg_and_die("Not enough arguments. Try --help or else see the man page."); fsout = argv[optind]; + if(blocksize != 1024 && blocksize != 2048 && blocksize != 4096) + error_msg_and_die("Valid block sizes: 1024, 2048 or 4096."); + if(creator_os < 0) + error_msg_and_die("Creator OS unknown."); + hdlinks.hdl = (struct hdlink_s *)malloc(hdlink_cnt * sizeof(struct hdlink_s)); if (!hdlinks.hdl) error_msg_and_die("Not enough memory"); @@ -2611,7 +2674,8 @@ } if(fs_timestamp == -1) fs_timestamp = time(NULL); - fs = init_fs(nbblocks, nbinodes, nbresrvd, holes, fs_timestamp); + fs = init_fs(nbblocks, nbinodes, nbresrvd, holes, + fs_timestamp, creator_os); } populate_fs(fs, dopt, didx, squash_uids, squash_perms, fs_timestamp, NULL); Index: genext2fs/test-gen.lib =================================================================== --- genext2fs.orig/test-gen.lib 2011-09-03 13:40:35.000000000 +0200 +++ genext2fs/test-gen.lib 2011-09-03 14:21:17.000000000 +0200 @@ -8,7 +8,7 @@ # Creates an image with a file of given size # Usage: dgen file-size number-of-blocks dgen () { - size=$1; blocks=$2 + size=$1; blocks=$2; blocksz=$3; rm -rf test mkdir -p test cd test @@ -20,7 +20,7 @@ chmod 777 file.$1 TZ=UTC-11 touch -t 200502070321.43 file.$1 . cd .. - ./genext2fs -N 17 -b $blocks -d test -f -q ext2.img + ./genext2fs -B $blocksz -N 17 -b $blocks -d test -f -o Linux -q ext2.img } # fgen - Exercises the -f spec-file option of genext2fs @@ -31,7 +31,7 @@ mkdir -p test cp $fname test TZ=UTC-11 touch -t 200502070321.43 test/$fname - ./genext2fs -N 92 -b $blocks -D test/$fname -f ext2.img + ./genext2fs -N 92 -b $blocks -D test/$fname -f -o Linux ext2.img } # gen_cleanup - Remove the files generated by the above functions Index: genext2fs/test-mount.sh =================================================================== --- genext2fs.orig/test-mount.sh 2011-09-03 13:40:35.000000000 +0200 +++ genext2fs/test-mount.sh 2011-09-03 14:21:17.000000000 +0200 @@ -33,9 +33,9 @@ # and returns the command line with which to invoke dtest() # Usage: dtest-mount file-size number-of-blocks dtest_mount () { - size=$1; blocks=$2 - echo Testing with file of size $size - dgen $size $blocks + size=$1; blocks=$2; blocksz=$3; + echo Testing $blocks blocks of $blocksz bytes with file of size $size + dgen $size $blocks $blocksz /sbin/e2fsck -fn ext2.img || fail mkdir -p mnt mount -t ext2 -o ro,loop ext2.img mnt || fail @@ -44,7 +44,7 @@ awk '{print $5}'`" ] ; then fail fi - pass dtest $size $blocks + pass dtest $size $blocks $blocksz } # ftest-mount - Exercise the -f spec-file option of genext2fs @@ -75,13 +75,21 @@ pass ftest $fname $blocks } -dtest_mount 0 4096 -dtest_mount 0 8193 -dtest_mount 0 8194 -dtest_mount 1 4096 -dtest_mount 12288 4096 -dtest_mount 274432 4096 -dtest_mount 8388608 9000 -dtest_mount 16777216 20000 +dtest_mount 0 4096 1024 +dtest_mount 0 2048 2048 +dtest_mount 0 1024 4096 +dtest_mount 0 8193 1024 +dtest_mount 0 8194 1024 +dtest_mount 0 8193 4096 +dtest_mount 0 8194 2048 +dtest_mount 1 4096 1024 +dtest_mount 1 1024 4096 +dtest_mount 12288 4096 1024 +dtest_mount 274432 4096 1024 +dtest_mount 8388608 9000 1024 +dtest_mount 8388608 4500 2048 +dtest_mount 8388608 2250 4096 +dtest_mount 16777216 20000 1024 +dtest_mount 16777216 10000 2048 ftest_mount device_table.txt 4096 Index: genext2fs/test.sh =================================================================== --- genext2fs.orig/test.sh 2011-09-03 13:40:35.000000000 +0200 +++ genext2fs/test.sh 2011-09-03 14:21:17.000000000 +0200 @@ -30,9 +30,9 @@ # Creates an image with a file of given size and verifies it # Usage: dtest file-size number-of-blocks correct-checksum dtest () { - size=$1; blocks=$2; checksum=$3 + size=$1; blocks=$2; blocksz=$3; checksum=$4 echo Testing with file of size $size - dgen $size $blocks + dgen $size $blocks $blocksz md5cmp $checksum gen_cleanup } @@ -53,12 +53,20 @@ # replace the following lines with the output of # sudo sh test-mount.sh|grep test -dtest 0 4096 3bc6424b8fcd51a0de34ee59d91d5f16 -dtest 0 8193 f174804f6b433b552706cbbfc60c416d -dtest 0 8194 4855a55d0cbdc44584634df49ebd5711 -dtest 1 4096 09c569b6bfb45222c729c42d04d5451f -dtest 12288 4096 61febcbfbf32024ef99103fcdc282c39 -dtest 274432 4096 0c517803552c55c1806e4220b0a0164f -dtest 8388608 9000 e0e5ea15bced10ab486d8135584b5d8e -dtest 16777216 20000 fdf636eb905ab4dc1bf76dce5ac5d209 +dtest 0 4096 1024 3bc6424b8fcd51a0de34ee59d91d5f16 +dtest 0 2048 2048 230afa16496df019878cc2370c661cdc +dtest 0 1024 4096 ebff5eeb38b70f3f1cd081e60eb44561 +dtest 0 8193 1024 f174804f6b433b552706cbbfc60c416d +dtest 0 8194 1024 4855a55d0cbdc44584634df49ebd5711 +dtest 0 8193 4096 c493679698418ec7e6552005e2d2a6d8 +dtest 0 8194 2048 ec13f328fa7543563f35f494bddc059c +dtest 1 4096 1024 09c569b6bfb45222c729c42d04d5451f +dtest 1 1024 4096 d318a326fdc907810ae9e6b0a20e9b06 +dtest 12288 4096 1024 61febcbfbf32024ef99103fcdc282c39 +dtest 274432 4096 1024 0c517803552c55c1806e4220b0a0164f +dtest 8388608 9000 1024 e0e5ea15bced10ab486d8135584b5d8e +dtest 8388608 4500 2048 39f4d537a72f5053fd6891721c59680d +dtest 8388608 2250 4096 1d697fa4bc2cfffe02ac91edfadc40bf +dtest 16777216 20000 1024 fdf636eb905ab4dc1bf76dce5ac5d209 +dtest 16777216 10000 2048 f9824a81ea5e74fdf469c097927c292b ftest device_table.txt 4096 a0af06d944b11d2902dfd705484c64cc debian/patches/byteswap_fix.diff0000644000000000000000000000347411665275776014211 0ustar Index: genext2fs/genext2fs.c =================================================================== --- genext2fs.orig/genext2fs.c 2011-11-29 17:36:06.000000000 +0100 +++ genext2fs/genext2fs.c 2011-11-29 17:37:37.000000000 +0100 @@ -1779,7 +1779,8 @@ assert(nod->i_block[EXT2_DIND_BLOCK] != 0); for(i = 0; i < BLOCKSIZE/4; i++) if(nblk > EXT2_IND_BLOCK + BLOCKSIZE/4 + (BLOCKSIZE/4)*i ) - swap_block(get_blk(fs, ((uint32*)get_blk(fs, nod->i_block[EXT2_DIND_BLOCK]))[i])); + if (((uint32*)get_blk(fs, nod->i_block[EXT2_DIND_BLOCK]))[i]) + swap_block(get_blk(fs, ((uint32*)get_blk(fs, nod->i_block[EXT2_DIND_BLOCK]))[i])); swap_block(get_blk(fs, nod->i_block[EXT2_DIND_BLOCK])); if(nblk <= EXT2_IND_BLOCK + BLOCKSIZE/4 + BLOCKSIZE/4 * BLOCKSIZE/4) return; @@ -1792,7 +1793,8 @@ (BLOCKSIZE/4)*(BLOCKSIZE/4) + i*(BLOCKSIZE/4)*(BLOCKSIZE/4) + j*(BLOCKSIZE/4)) ) - swap_block(get_blk(fs,b2[j])); + if (b2[j]) + swap_block(get_blk(fs,b2[j])); else { done = 1; break; @@ -1825,7 +1827,8 @@ swap_block(get_blk(fs, nod->i_block[EXT2_DIND_BLOCK])); for(i = 0; i < BLOCKSIZE/4; i++) if(nblk > EXT2_IND_BLOCK + BLOCKSIZE/4 + (BLOCKSIZE/4)*i ) - swap_block(get_blk(fs, ((uint32*)get_blk(fs, nod->i_block[EXT2_DIND_BLOCK]))[i])); + if (((uint32*)get_blk(fs, nod->i_block[EXT2_DIND_BLOCK]))[i]) + swap_block(get_blk(fs, ((uint32*)get_blk(fs, nod->i_block[EXT2_DIND_BLOCK]))[i])); if(nblk <= EXT2_IND_BLOCK + BLOCKSIZE/4 + BLOCKSIZE/4 * BLOCKSIZE/4) return; /* Adding support for triple indirection */ @@ -1839,7 +1842,8 @@ (BLOCKSIZE/4)*(BLOCKSIZE/4) + i*(BLOCKSIZE/4)*(BLOCKSIZE/4) + j*(BLOCKSIZE/4)) ) - swap_block(get_blk(fs,b2[j])); + if (b2[j]) + swap_block(get_blk(fs,b2[j])); else { done = 1; break; debian/control0000644000000000000000000000127511644157370010606 0ustar Source: genext2fs Section: admin Priority: optional Maintainer: Jérémie Koenig Vcs-Git: git://github.com/jeremie-koenig/genext2fs.git Vcs-Browser: http://github.com/jeremie-koenig/genext2fs Build-Depends: debhelper (>> 8), autoconf (>= 2.59), automake (>= 1.10) Build-Conflicts: autoconf2.13 Standards-Version: 3.9.2 Package: genext2fs Architecture: any Depends: ${shlibs:Depends}, ${misc:Depends} Description: ext2 filesystem generator for embedded systems genext2fs is meant to generate an ext2 filesystem as a normal (non-root) user. It doesn't require you to mount the image file to copy files on it. It doesn't even require you to be the superuser to make device nodes. debian/rules0000755000000000000000000000047311644157370010262 0ustar #!/usr/bin/make -f %: dh $@ # Make sure we always regenerate the autoconf files autocruft = Makefile.in aclocal.m4 config.h.in configure depcomp \ install-sh missing override_dh_auto_configure: $(RM) $(autocruft) autoreconf -i dh_auto_configure override_dh_auto_clean: dh_auto_clean $(RM) $(autocruft) debian/compat0000644000000000000000000000000211644157370010374 0ustar 8 debian/gbp.conf0000644000000000000000000000026711644157370010622 0ustar # git-buildpackage(1) configuration for genext2fs [DEFAULT] pristine-tar = True upstream-tag = genext2fs-%(version)s debian-branch = debian debian-tag = debian/genext2fs_%(version)s