diff --git a/format/main.c b/format/main.c index fbf1a00..4a45583 100644 --- a/format/main.c +++ b/format/main.c @@ -99,8 +99,7 @@ if (q == 0x0) { memset(sector,0x0,512); - - if (fseek(fd,d->partitions[i].p_offset * 512,0x0) != 0x0) { + if (fseek(fd,d->partitions[i].p_offset * 512,SEEK_SET) != 0x0) { fprintf(stderr, "Error: fseek failed\n"); exit(0x1); } @@ -121,12 +120,10 @@ blocks--; } - batSect = (d->partitions[i].p_offset + 1) + (blocks * 8); - - + batSect = (d->partitions[i].p_offset + (blocks * 8)); /* write super block here */ - if (fseek(fd,d->partitions[i].p_offset * 512,0x0) != 0x0) { - fprintf(stderr, "Error: fseek failed\n"); + if (fseek(fd,d->partitions[i].p_offset + (d->partitions[i].p_size - 1),SEEK_SET) != 0x0) { + fprintf(stderr, "Error: fseek failed for super block\n"); exit(0x1); } // fill in superblock here @@ -163,9 +160,11 @@ fwrite(sb,512,1,fd); + /* Write BAT */ - if (fseek(fd,batSect * 512,0x0) != 0x0) { - fprintf(stderr, "Error: fseek failed\n"); + rewind(fd); + if (fseek(fd,batSect * 512,SEEK_SET) != 0x0) { + fprintf(stderr, "Error: fseek failed for bat\n"); exit(0x1); } @@ -191,6 +190,10 @@ /*** $Log$ + Revision 1.6 2004/09/03 13:33:00 flameshadow + chg: BAT should be empty before allocating space for the root dir, + indicies, and journal + Revision 1.5 2004/09/03 12:30:56 flameshadow chg: used original/new superblock definition add: most of the superblock info filled in for format