2
0

300-blocksize-creator.patch 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558
  1. Index: genext2fs/genext2fs.c
  2. ===================================================================
  3. --- genext2fs.orig/genext2fs.c 2011-09-03 14:21:17.000000000 +0200
  4. +++ genext2fs/genext2fs.c 2011-09-03 14:21:17.000000000 +0200
  5. @@ -151,13 +151,24 @@
  6. // block size
  7. -#define BLOCKSIZE 1024
  8. +static int blocksize = 1024;
  9. +
  10. +#define BLOCKSIZE blocksize
  11. #define BLOCKS_PER_GROUP 8192
  12. #define INODES_PER_GROUP 8192
  13. /* Percentage of blocks that are reserved.*/
  14. #define RESERVED_BLOCKS 5/100
  15. #define MAX_RESERVED_BLOCKS 25/100
  16. +/* The default value for s_creator_os. */
  17. +#if defined(__GNU__)
  18. +# define CREATOR_OS 1 /* Hurd */
  19. +#elif defined(__FreeBSD__)
  20. +# define CREATOR_OS 3 /* FreeBSD */
  21. +#else
  22. +# define CREATOR_OS 0 /* Linux */
  23. +#endif
  24. +
  25. // inode block size (why is it != BLOCKSIZE ?!?)
  26. /* The field i_blocks in the ext2 inode stores the number of data blocks
  27. @@ -239,10 +250,10 @@
  28. (fs)->sb.s_blocks_per_group - 1) / (fs)->sb.s_blocks_per_group)
  29. // Get group block bitmap (bbm) given the group number
  30. -#define GRP_GET_GROUP_BBM(fs,grp) ( get_blk((fs),(fs)->gd[(grp)].bg_block_bitmap) )
  31. +#define GRP_GET_GROUP_BBM(fs,grp) ( get_blk((fs), get_gd((fs),(grp))->bg_block_bitmap) )
  32. // Get group inode bitmap (ibm) given the group number
  33. -#define GRP_GET_GROUP_IBM(fs,grp) ( get_blk((fs),(fs)->gd[(grp)].bg_inode_bitmap) )
  34. +#define GRP_GET_GROUP_IBM(fs,grp) ( get_blk((fs), get_gd((fs),(grp))->bg_inode_bitmap) )
  35. // Given an inode number find the group it belongs to
  36. #define GRP_GROUP_OF_INODE(fs,nod) ( ((nod)-1) / (fs)->sb.s_inodes_per_group)
  37. @@ -532,7 +543,7 @@
  38. char d_name[0];
  39. } directory;
  40. -typedef uint8 block[BLOCKSIZE];
  41. +typedef uint8 *block;
  42. /* blockwalker fields:
  43. The blockwalker is used to access all the blocks of a file (including
  44. @@ -571,16 +582,12 @@
  45. /* Filesystem structure that support groups */
  46. -#if BLOCKSIZE == 1024
  47. typedef struct
  48. {
  49. - block zero; // The famous block 0
  50. - superblock sb; // The superblock
  51. - groupdescriptor gd[0]; // The group descriptors
  52. + uint8 zero[1024]; // Room for bootloader stuff
  53. + superblock sb; // The superblock, always at 1024
  54. + // group descriptors come next, see get_gd() below
  55. } filesystem;
  56. -#else
  57. -#error UNHANDLED BLOCKSIZE
  58. -#endif
  59. // now the endianness swap
  60. @@ -820,6 +827,14 @@
  61. return (uint8*)fs + blk*BLOCKSIZE;
  62. }
  63. +// the group descriptors are aligned on the block size
  64. +static inline groupdescriptor *
  65. +get_gd(filesystem *fs, int no)
  66. +{
  67. + int gdblk = (sizeof (filesystem) + BLOCKSIZE - 1) / BLOCKSIZE;
  68. + return ((groupdescriptor *) get_blk(fs, gdblk)) + no;
  69. +}
  70. +
  71. // return a given inode from a filesystem
  72. static inline inode *
  73. get_nod(filesystem *fs, uint32 nod)
  74. @@ -829,7 +844,7 @@
  75. offset = GRP_IBM_OFFSET(fs,nod);
  76. grp = GRP_GROUP_OF_INODE(fs,nod);
  77. - itab = (inode *)get_blk(fs, fs->gd[grp].bg_inode_table);
  78. + itab = (inode *)get_blk(fs, get_gd(fs,grp)->bg_inode_table);
  79. return itab+offset-1;
  80. }
  81. @@ -875,18 +890,18 @@
  82. grp = GRP_GROUP_OF_INODE(fs,nod);
  83. nbgroups = GRP_NBGROUPS(fs);
  84. - if(!(bk = allocate(get_blk(fs,fs->gd[grp].bg_block_bitmap), 0))) {
  85. + if(!(bk = allocate(GRP_GET_GROUP_BBM(fs, grp), 0))) {
  86. for(grp=0;grp<nbgroups && !bk;grp++)
  87. - bk=allocate(get_blk(fs,fs->gd[grp].bg_block_bitmap),0);
  88. + bk = allocate(GRP_GET_GROUP_BBM(fs, grp), 0);
  89. grp--;
  90. }
  91. if (!bk)
  92. error_msg_and_die("couldn't allocate a block (no free space)");
  93. - if(!(fs->gd[grp].bg_free_blocks_count--))
  94. + if(!(get_gd(fs, grp)->bg_free_blocks_count--))
  95. error_msg_and_die("group descr %d. free blocks count == 0 (corrupted fs?)",grp);
  96. if(!(fs->sb.s_free_blocks_count--))
  97. error_msg_and_die("superblock free blocks count == 0 (corrupted fs?)");
  98. - return fs->sb.s_blocks_per_group*grp + bk;
  99. + return fs->sb.s_first_data_block + fs->sb.s_blocks_per_group*grp + (bk-1);
  100. }
  101. // free a block
  102. @@ -897,8 +912,8 @@
  103. grp = bk / fs->sb.s_blocks_per_group;
  104. bk %= fs->sb.s_blocks_per_group;
  105. - deallocate(get_blk(fs,fs->gd[grp].bg_block_bitmap), bk);
  106. - fs->gd[grp].bg_free_blocks_count++;
  107. + deallocate(GRP_GET_GROUP_BBM(fs, grp), bk);
  108. + get_gd(fs, grp)->bg_free_blocks_count++;
  109. fs->sb.s_free_blocks_count++;
  110. }
  111. @@ -918,16 +933,16 @@
  112. /* We do it for all inodes. */
  113. avefreei = fs->sb.s_free_inodes_count / nbgroups;
  114. for(grp=0; grp<nbgroups; grp++) {
  115. - if (fs->gd[grp].bg_free_inodes_count < avefreei ||
  116. - fs->gd[grp].bg_free_inodes_count == 0)
  117. + if (get_gd(fs, grp)->bg_free_inodes_count < avefreei ||
  118. + get_gd(fs, grp)->bg_free_inodes_count == 0)
  119. continue;
  120. if (!best_group ||
  121. - fs->gd[grp].bg_free_blocks_count > fs->gd[best_group].bg_free_blocks_count)
  122. + get_gd(fs, grp)->bg_free_blocks_count > get_gd(fs, best_group)->bg_free_blocks_count)
  123. best_group = grp;
  124. }
  125. - if (!(nod = allocate(get_blk(fs,fs->gd[best_group].bg_inode_bitmap),0)))
  126. + if (!(nod = allocate(GRP_GET_GROUP_IBM(fs, best_group), 0)))
  127. error_msg_and_die("couldn't allocate an inode (no free inode)");
  128. - if(!(fs->gd[best_group].bg_free_inodes_count--))
  129. + if(!(get_gd(fs, best_group)->bg_free_inodes_count--))
  130. error_msg_and_die("group descr. free blocks count == 0 (corrupted fs?)");
  131. if(!(fs->sb.s_free_inodes_count--))
  132. error_msg_and_die("superblock free blocks count == 0 (corrupted fs?)");
  133. @@ -1390,7 +1405,7 @@
  134. case FM_IFDIR:
  135. add2dir(fs, nod, nod, ".");
  136. add2dir(fs, nod, parent_nod, "..");
  137. - fs->gd[GRP_GROUP_OF_INODE(fs,nod)].bg_used_dirs_count++;
  138. + get_gd(fs, GRP_GROUP_OF_INODE(fs,nod))->bg_used_dirs_count++;
  139. break;
  140. }
  141. }
  142. @@ -1860,7 +1875,7 @@
  143. swap_nod(nod);
  144. }
  145. for(i=0;i<GRP_NBGROUPS(fs);i++)
  146. - swap_gd(&(fs->gd[i]));
  147. + swap_gd(get_gd(fs, i));
  148. swap_sb(&fs->sb);
  149. }
  150. @@ -1870,7 +1885,7 @@
  151. uint32 i;
  152. swap_sb(&fs->sb);
  153. for(i=0;i<GRP_NBGROUPS(fs);i++)
  154. - swap_gd(&(fs->gd[i]));
  155. + swap_gd(get_gd(fs, i));
  156. for(i = 1; i < fs->sb.s_inodes_count; i++)
  157. {
  158. inode *nod = get_nod(fs, i);
  159. @@ -1895,7 +1910,8 @@
  160. // initialize an empty filesystem
  161. static filesystem *
  162. -init_fs(int nbblocks, int nbinodes, int nbresrvd, int holes, uint32 fs_timestamp)
  163. +init_fs(int nbblocks, int nbinodes, int nbresrvd, int holes,
  164. + uint32 fs_timestamp, uint32 creator_os)
  165. {
  166. uint32 i;
  167. filesystem *fs;
  168. @@ -1921,10 +1937,14 @@
  169. */
  170. min_nbgroups = (nbinodes + INODES_PER_GROUP - 1) / INODES_PER_GROUP;
  171. + /* On filesystems with 1k block size, the bootloader area uses a full
  172. + * block. For 2048 and up, the superblock can be fitted into block 0.
  173. + */
  174. + first_block = (BLOCKSIZE == 1024);
  175. +
  176. /* nbblocks is the total number of blocks in the filesystem.
  177. * a block group can have no more than 8192 blocks.
  178. */
  179. - first_block = (BLOCKSIZE == 1024);
  180. nbgroups = (nbblocks - first_block + BLOCKS_PER_GROUP - 1) / BLOCKS_PER_GROUP;
  181. if(nbgroups < min_nbgroups) nbgroups = min_nbgroups;
  182. nbblocks_per_group = rndup((nbblocks - first_block + nbgroups - 1)/nbgroups, 8);
  183. @@ -1936,10 +1956,10 @@
  184. gdsz = rndup(nbgroups*sizeof(groupdescriptor),BLOCKSIZE)/BLOCKSIZE;
  185. itblsz = nbinodes_per_group * sizeof(inode)/BLOCKSIZE;
  186. overhead_per_group = 3 /*sb,bbm,ibm*/ + gdsz + itblsz;
  187. - if((uint32)nbblocks - 1 < overhead_per_group * nbgroups)
  188. - error_msg_and_die("too much overhead, try fewer inodes or more blocks. Note: options have changed, see --help or the man page.");
  189. - free_blocks = nbblocks - overhead_per_group*nbgroups - 1 /*boot block*/;
  190. + free_blocks = nbblocks - overhead_per_group*nbgroups - first_block;
  191. free_blocks_per_group = nbblocks_per_group - overhead_per_group;
  192. + if(free_blocks < 0)
  193. + error_msg_and_die("too much overhead, try fewer inodes or more blocks. Note: options have changed, see --help or the man page.");
  194. if(!(fs = (filesystem*)calloc(nbblocks, BLOCKSIZE)))
  195. error_msg_and_die("not enough memory for filesystem");
  196. @@ -1959,28 +1979,31 @@
  197. fs->sb.s_wtime = fs_timestamp;
  198. fs->sb.s_magic = EXT2_MAGIC_NUMBER;
  199. fs->sb.s_lastcheck = fs_timestamp;
  200. + fs->sb.s_creator_os = creator_os;
  201. // set up groupdescriptors
  202. - for(i=0, bbmpos=gdsz+2, ibmpos=bbmpos+1, itblpos=ibmpos+1;
  203. + for(i=0, bbmpos=first_block+1+gdsz, ibmpos=bbmpos+1, itblpos=ibmpos+1;
  204. i<nbgroups;
  205. i++, bbmpos+=nbblocks_per_group, ibmpos+=nbblocks_per_group, itblpos+=nbblocks_per_group)
  206. {
  207. + groupdescriptor *gd = get_gd(fs, i);
  208. +
  209. if(free_blocks > free_blocks_per_group) {
  210. - fs->gd[i].bg_free_blocks_count = free_blocks_per_group;
  211. + gd->bg_free_blocks_count = free_blocks_per_group;
  212. free_blocks -= free_blocks_per_group;
  213. } else {
  214. - fs->gd[i].bg_free_blocks_count = free_blocks;
  215. + gd->bg_free_blocks_count = free_blocks;
  216. free_blocks = 0; // this is the last block group
  217. }
  218. if(i)
  219. - fs->gd[i].bg_free_inodes_count = nbinodes_per_group;
  220. + gd->bg_free_inodes_count = nbinodes_per_group;
  221. else
  222. - fs->gd[i].bg_free_inodes_count = nbinodes_per_group -
  223. + gd->bg_free_inodes_count = nbinodes_per_group -
  224. EXT2_FIRST_INO + 2;
  225. - fs->gd[i].bg_used_dirs_count = 0;
  226. - fs->gd[i].bg_block_bitmap = bbmpos;
  227. - fs->gd[i].bg_inode_bitmap = ibmpos;
  228. - fs->gd[i].bg_inode_table = itblpos;
  229. + gd->bg_used_dirs_count = 0;
  230. + gd->bg_block_bitmap = bbmpos;
  231. + gd->bg_inode_bitmap = ibmpos;
  232. + gd->bg_inode_table = itblpos;
  233. }
  234. /* Mark non-filesystem blocks and inodes as allocated */
  235. @@ -1988,9 +2011,9 @@
  236. for(i = 0; i<nbgroups;i++) {
  237. /* Block bitmap */
  238. - bbm = get_blk(fs,fs->gd[i].bg_block_bitmap);
  239. + bbm = GRP_GET_GROUP_BBM(fs, i);
  240. //non-filesystem blocks
  241. - for(j = fs->gd[i].bg_free_blocks_count
  242. + for(j = get_gd(fs, i)->bg_free_blocks_count
  243. + overhead_per_group + 1; j <= BLOCKSIZE * 8; j++)
  244. allocate(bbm, j);
  245. //system blocks
  246. @@ -1998,7 +2021,7 @@
  247. allocate(bbm, j);
  248. /* Inode bitmap */
  249. - ibm = get_blk(fs,fs->gd[i].bg_inode_bitmap);
  250. + ibm = GRP_GET_GROUP_IBM(fs, i);
  251. //non-filesystem inodes
  252. for(j = fs->sb.s_inodes_per_group+1; j <= BLOCKSIZE * 8; j++)
  253. allocate(ibm, j);
  254. @@ -2012,9 +2035,9 @@
  255. // make root inode and directory
  256. /* We have groups now. Add the root filesystem in group 0 */
  257. /* Also increment the directory count for group 0 */
  258. - fs->gd[0].bg_free_inodes_count--;
  259. - fs->gd[0].bg_used_dirs_count = 1;
  260. - itab0 = (inode *)get_blk(fs,fs->gd[0].bg_inode_table);
  261. + get_gd(fs, 0)->bg_free_inodes_count--;
  262. + get_gd(fs, 0)->bg_used_dirs_count = 1;
  263. + itab0 = (inode *)get_blk(fs, get_gd(fs,0)->bg_inode_table);
  264. itab0[EXT2_ROOT_INO-1].i_mode = FM_IFDIR | FM_IRWXU | FM_IRGRP | FM_IROTH | FM_IXGRP | FM_IXOTH;
  265. itab0[EXT2_ROOT_INO-1].i_ctime = fs_timestamp;
  266. itab0[EXT2_ROOT_INO-1].i_mtime = fs_timestamp;
  267. @@ -2338,8 +2361,9 @@
  268. for (i = 0; i < GRP_NBGROUPS(fs); i++) {
  269. printf("Group No: %d\n", i+1);
  270. printf("block bitmap: block %d,inode bitmap: block %d, inode table: block %d\n",
  271. - fs->gd[i].bg_block_bitmap, fs->gd[i].bg_inode_bitmap,
  272. - fs->gd[i].bg_inode_table);
  273. + get_gd(fs, i)->bg_block_bitmap,
  274. + get_gd(fs, i)->bg_inode_bitmap,
  275. + get_gd(fs, i)->bg_inode_table);
  276. printf("block bitmap allocation:\n");
  277. print_bm(GRP_GET_GROUP_BBM(fs, i),fs->sb.s_blocks_per_group);
  278. printf("inode bitmap allocation:\n");
  279. @@ -2421,10 +2445,12 @@
  280. " -x, --starting-image <image>\n"
  281. " -d, --root <directory>\n"
  282. " -D, --devtable <file>\n"
  283. + " -B, --block-size <bytes>\n"
  284. " -b, --size-in-blocks <blocks>\n"
  285. " -i, --bytes-per-inode <bytes per inode>\n"
  286. " -N, --number-of-inodes <number of inodes>\n"
  287. " -m, --reserved-percentage <percentage of blocks to reserve>\n"
  288. + " -o, --creator-os <os> 'linux', 'hurd', 'freebsd' or a numerical value.\n"
  289. " -g, --block-map <path> Generate a block map file for this path.\n"
  290. " -e, --fill-value <value> Fill unallocated blocks with value.\n"
  291. " -z, --allow-holes Allow files with holes.\n"
  292. @@ -2446,6 +2472,29 @@
  293. extern char* optarg;
  294. extern int optind, opterr, optopt;
  295. +// parse the value for -o <os>
  296. +int
  297. +lookup_creator_os(const char *name)
  298. +{
  299. + static const char *const creators[] =
  300. + {"linux", "hurd", "2", "freebsd", NULL};
  301. + char *endptr;
  302. + int i;
  303. +
  304. + // numerical value ?
  305. + i = strtol(name, &endptr, 0);
  306. + if(name[0] && *endptr == '\0')
  307. + return i;
  308. +
  309. + // symbolic name ?
  310. + for(i=0; creators[i]; i++)
  311. + if(strcasecmp(creators[i], name) == 0)
  312. + return i;
  313. +
  314. + // whatever ?
  315. + return -1;
  316. +}
  317. +
  318. int
  319. main(int argc, char **argv)
  320. {
  321. @@ -2455,6 +2504,7 @@
  322. float bytes_per_inode = -1;
  323. float reserved_frac = -1;
  324. int fs_timestamp = -1;
  325. + int creator_os = CREATOR_OS;
  326. char * fsout = "-";
  327. char * fsin = 0;
  328. char * dopt[MAX_DOPT];
  329. @@ -2478,10 +2528,12 @@
  330. { "starting-image", required_argument, NULL, 'x' },
  331. { "root", required_argument, NULL, 'd' },
  332. { "devtable", required_argument, NULL, 'D' },
  333. + { "block-size", required_argument, NULL, 'B' },
  334. { "size-in-blocks", required_argument, NULL, 'b' },
  335. { "bytes-per-inode", required_argument, NULL, 'i' },
  336. { "number-of-inodes", required_argument, NULL, 'N' },
  337. { "reserved-percentage", required_argument, NULL, 'm' },
  338. + { "creator-os", required_argument, NULL, 'o' },
  339. { "block-map", required_argument, NULL, 'g' },
  340. { "fill-value", required_argument, NULL, 'e' },
  341. { "allow-holes", no_argument, NULL, 'z' },
  342. @@ -2497,11 +2549,11 @@
  343. app_name = argv[0];
  344. - while((c = getopt_long(argc, argv, "x:d:D:b:i:N:m:g:e:zfqUPhVv", longopts, NULL)) != EOF) {
  345. + while((c = getopt_long(argc, argv, "x:d:D:B:b:i:N:m:o:g:e:zfqUPhVv", longopts, NULL)) != EOF) {
  346. #else
  347. app_name = argv[0];
  348. - while((c = getopt(argc, argv, "x:d:D:b:i:N:m:g:e:zfqUPhVv")) != EOF) {
  349. + while((c = getopt(argc, argv, "x:d:D:B:b:i:N:m:o:g:e:zfqUPhVv")) != EOF) {
  350. #endif /* HAVE_GETOPT_LONG */
  351. switch(c)
  352. {
  353. @@ -2512,6 +2564,9 @@
  354. case 'D':
  355. dopt[didx++] = optarg;
  356. break;
  357. + case 'B':
  358. + blocksize = SI_atof(optarg);
  359. + break;
  360. case 'b':
  361. nbblocks = SI_atof(optarg);
  362. break;
  363. @@ -2524,6 +2579,9 @@
  364. case 'm':
  365. reserved_frac = SI_atof(optarg) / 100;
  366. break;
  367. + case 'o':
  368. + creator_os = lookup_creator_os(optarg);
  369. + break;
  370. case 'g':
  371. gopt[gidx++] = optarg;
  372. break;
  373. @@ -2567,6 +2625,11 @@
  374. error_msg_and_die("Not enough arguments. Try --help or else see the man page.");
  375. fsout = argv[optind];
  376. + if(blocksize != 1024 && blocksize != 2048 && blocksize != 4096)
  377. + error_msg_and_die("Valid block sizes: 1024, 2048 or 4096.");
  378. + if(creator_os < 0)
  379. + error_msg_and_die("Creator OS unknown.");
  380. +
  381. hdlinks.hdl = (struct hdlink_s *)malloc(hdlink_cnt * sizeof(struct hdlink_s));
  382. if (!hdlinks.hdl)
  383. error_msg_and_die("Not enough memory");
  384. @@ -2611,7 +2674,8 @@
  385. }
  386. if(fs_timestamp == -1)
  387. fs_timestamp = time(NULL);
  388. - fs = init_fs(nbblocks, nbinodes, nbresrvd, holes, fs_timestamp);
  389. + fs = init_fs(nbblocks, nbinodes, nbresrvd, holes,
  390. + fs_timestamp, creator_os);
  391. }
  392. populate_fs(fs, dopt, didx, squash_uids, squash_perms, fs_timestamp, NULL);
  393. Index: genext2fs/test-gen.lib
  394. ===================================================================
  395. --- genext2fs.orig/test-gen.lib 2011-09-03 13:40:35.000000000 +0200
  396. +++ genext2fs/test-gen.lib 2011-09-03 14:21:17.000000000 +0200
  397. @@ -8,7 +8,7 @@
  398. # Creates an image with a file of given size
  399. # Usage: dgen file-size number-of-blocks
  400. dgen () {
  401. - size=$1; blocks=$2
  402. + size=$1; blocks=$2; blocksz=$3;
  403. rm -rf test
  404. mkdir -p test
  405. cd test
  406. @@ -20,7 +20,7 @@
  407. chmod 777 file.$1
  408. TZ=UTC-11 touch -t 200502070321.43 file.$1 .
  409. cd ..
  410. - ./genext2fs -N 17 -b $blocks -d test -f -q ext2.img
  411. + ./genext2fs -B $blocksz -N 17 -b $blocks -d test -f -o Linux -q ext2.img
  412. }
  413. # fgen - Exercises the -f spec-file option of genext2fs
  414. @@ -31,7 +31,7 @@
  415. mkdir -p test
  416. cp $fname test
  417. TZ=UTC-11 touch -t 200502070321.43 test/$fname
  418. - ./genext2fs -N 92 -b $blocks -D test/$fname -f ext2.img
  419. + ./genext2fs -N 92 -b $blocks -D test/$fname -f -o Linux ext2.img
  420. }
  421. # gen_cleanup - Remove the files generated by the above functions
  422. Index: genext2fs/test-mount.sh
  423. ===================================================================
  424. --- genext2fs.orig/test-mount.sh 2011-09-03 13:40:35.000000000 +0200
  425. +++ genext2fs/test-mount.sh 2011-09-03 14:21:17.000000000 +0200
  426. @@ -33,9 +33,9 @@
  427. # and returns the command line with which to invoke dtest()
  428. # Usage: dtest-mount file-size number-of-blocks
  429. dtest_mount () {
  430. - size=$1; blocks=$2
  431. - echo Testing with file of size $size
  432. - dgen $size $blocks
  433. + size=$1; blocks=$2; blocksz=$3;
  434. + echo Testing $blocks blocks of $blocksz bytes with file of size $size
  435. + dgen $size $blocks $blocksz
  436. /sbin/e2fsck -fn ext2.img || fail
  437. mkdir -p mnt
  438. mount -t ext2 -o ro,loop ext2.img mnt || fail
  439. @@ -44,7 +44,7 @@
  440. awk '{print $5}'`" ] ; then
  441. fail
  442. fi
  443. - pass dtest $size $blocks
  444. + pass dtest $size $blocks $blocksz
  445. }
  446. # ftest-mount - Exercise the -f spec-file option of genext2fs
  447. @@ -75,13 +75,21 @@
  448. pass ftest $fname $blocks
  449. }
  450. -dtest_mount 0 4096
  451. -dtest_mount 0 8193
  452. -dtest_mount 0 8194
  453. -dtest_mount 1 4096
  454. -dtest_mount 12288 4096
  455. -dtest_mount 274432 4096
  456. -dtest_mount 8388608 9000
  457. -dtest_mount 16777216 20000
  458. +dtest_mount 0 4096 1024
  459. +dtest_mount 0 2048 2048
  460. +dtest_mount 0 1024 4096
  461. +dtest_mount 0 8193 1024
  462. +dtest_mount 0 8194 1024
  463. +dtest_mount 0 8193 4096
  464. +dtest_mount 0 8194 2048
  465. +dtest_mount 1 4096 1024
  466. +dtest_mount 1 1024 4096
  467. +dtest_mount 12288 4096 1024
  468. +dtest_mount 274432 4096 1024
  469. +dtest_mount 8388608 9000 1024
  470. +dtest_mount 8388608 4500 2048
  471. +dtest_mount 8388608 2250 4096
  472. +dtest_mount 16777216 20000 1024
  473. +dtest_mount 16777216 10000 2048
  474. ftest_mount device_table.txt 4096
  475. Index: genext2fs/test.sh
  476. ===================================================================
  477. --- genext2fs.orig/test.sh 2011-09-03 13:40:35.000000000 +0200
  478. +++ genext2fs/test.sh 2011-09-03 14:21:17.000000000 +0200
  479. @@ -30,9 +30,9 @@
  480. # Creates an image with a file of given size and verifies it
  481. # Usage: dtest file-size number-of-blocks correct-checksum
  482. dtest () {
  483. - size=$1; blocks=$2; checksum=$3
  484. + size=$1; blocks=$2; blocksz=$3; checksum=$4
  485. echo Testing with file of size $size
  486. - dgen $size $blocks
  487. + dgen $size $blocks $blocksz
  488. md5cmp $checksum
  489. gen_cleanup
  490. }
  491. @@ -53,12 +53,20 @@
  492. # replace the following lines with the output of
  493. # sudo sh test-mount.sh|grep test
  494. -dtest 0 4096 3bc6424b8fcd51a0de34ee59d91d5f16
  495. -dtest 0 8193 f174804f6b433b552706cbbfc60c416d
  496. -dtest 0 8194 4855a55d0cbdc44584634df49ebd5711
  497. -dtest 1 4096 09c569b6bfb45222c729c42d04d5451f
  498. -dtest 12288 4096 61febcbfbf32024ef99103fcdc282c39
  499. -dtest 274432 4096 0c517803552c55c1806e4220b0a0164f
  500. -dtest 8388608 9000 e0e5ea15bced10ab486d8135584b5d8e
  501. -dtest 16777216 20000 fdf636eb905ab4dc1bf76dce5ac5d209
  502. +dtest 0 4096 1024 3bc6424b8fcd51a0de34ee59d91d5f16
  503. +dtest 0 2048 2048 230afa16496df019878cc2370c661cdc
  504. +dtest 0 1024 4096 ebff5eeb38b70f3f1cd081e60eb44561
  505. +dtest 0 8193 1024 f174804f6b433b552706cbbfc60c416d
  506. +dtest 0 8194 1024 4855a55d0cbdc44584634df49ebd5711
  507. +dtest 0 8193 4096 c493679698418ec7e6552005e2d2a6d8
  508. +dtest 0 8194 2048 ec13f328fa7543563f35f494bddc059c
  509. +dtest 1 4096 1024 09c569b6bfb45222c729c42d04d5451f
  510. +dtest 1 1024 4096 d318a326fdc907810ae9e6b0a20e9b06
  511. +dtest 12288 4096 1024 61febcbfbf32024ef99103fcdc282c39
  512. +dtest 274432 4096 1024 0c517803552c55c1806e4220b0a0164f
  513. +dtest 8388608 9000 1024 e0e5ea15bced10ab486d8135584b5d8e
  514. +dtest 8388608 4500 2048 39f4d537a72f5053fd6891721c59680d
  515. +dtest 8388608 2250 4096 1d697fa4bc2cfffe02ac91edfadc40bf
  516. +dtest 16777216 20000 1024 fdf636eb905ab4dc1bf76dce5ac5d209
  517. +dtest 16777216 10000 2048 f9824a81ea5e74fdf469c097927c292b
  518. ftest device_table.txt 4096 a0af06d944b11d2902dfd705484c64cc