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