~csurbhi/ubuntu/maverick/e2fsprogs/e2fsprogs.fix-505719

« back to all changes in this revision

Viewing changes to misc/mke2fs.c

  • Committer: Bazaar Package Importer
  • Author(s): Matt Zimmerman
  • Date: 2004-09-19 09:43:14 UTC
  • mto: (8.1.1 lenny) (1.2.3 upstream)
  • mto: This revision was merged to the branch mainline in revision 3.
  • Revision ID: james.westby@ubuntu.com-20040919094314-2tafd19i76fhu6ei
Tags: upstream-1.35
ImportĀ upstreamĀ versionĀ 1.35

Show diffs side-by-side

added added

removed removed

Lines of Context:
84
84
char *journal_device;
85
85
int sync_kludge;        /* Set using the MKE2FS_SYNC env. option */
86
86
 
 
87
int sys_page_size = 4096;
 
88
 
87
89
static void usage(void)
88
90
{
89
91
        fprintf(stderr, _("Usage: %s [-c|-t|-l filename] [-b block-size] "
125
127
 * of zero meaning that it is the default parameter for the type.
126
128
 * Note that order is important in the table below.
127
129
 */
 
130
#define DEF_MAX_BLOCKSIZE -1
128
131
static char default_str[] = "default";
129
132
struct mke2fs_defaults {
130
133
        const char      *type;
137
140
        { default_str, 3, 1024, 8192 },
138
141
        { "journal", 0, 4096, 8192 },
139
142
        { "news", 0, 4096, 4096 },
140
 
        { "largefile", 0, 4096, 1024 * 1024 },
141
 
        { "largefile4", 0, 4096, 4096 * 1024 },
 
143
        { "largefile", 0, DEF_MAX_BLOCKSIZE, 1024 * 1024 },
 
144
        { "largefile4", 0, DEF_MAX_BLOCKSIZE, 4096 * 1024 },
142
145
        { 0, 0, 0, 0},
143
146
};
144
147
 
145
148
static void set_fs_defaults(const char *fs_type,
146
149
                            struct ext2_super_block *super,
147
 
                            int blocksize, int *inode_ratio)
 
150
                            int blocksize, int sector_size,
 
151
                            int *inode_ratio)
148
152
{
149
153
        int     megs;
150
154
        int     ratio = 0;
151
155
        struct mke2fs_defaults *p;
 
156
        int     use_bsize = 1024;
152
157
 
153
 
        megs = (super->s_blocks_count * (EXT2_BLOCK_SIZE(super) / 1024) /
154
 
                1024);
 
158
        megs = super->s_blocks_count * (EXT2_BLOCK_SIZE(super) / 1024) / 1024;
155
159
        if (inode_ratio)
156
160
                ratio = *inode_ratio;
157
161
        if (!fs_type)
160
164
                if ((strcmp(p->type, fs_type) != 0) &&
161
165
                    (strcmp(p->type, default_str) != 0))
162
166
                        continue;
163
 
                if ((p->size != 0) &&
164
 
                    (megs > p->size))
 
167
                if ((p->size != 0) && (megs > p->size))
165
168
                        continue;
166
169
                if (ratio == 0)
167
 
                        *inode_ratio = p->inode_ratio;
168
 
                if (blocksize == 0) {
169
 
                        super->s_log_frag_size = super->s_log_block_size =
170
 
                                int_log2(p->blocksize >> EXT2_MIN_BLOCK_LOG_SIZE);
171
 
                }
172
 
        }
173
 
        if (blocksize == 0)
174
 
                super->s_blocks_count /= EXT2_BLOCK_SIZE(super) / 1024;
 
170
                        *inode_ratio = p->inode_ratio < blocksize ?
 
171
                                blocksize : p->inode_ratio;
 
172
                use_bsize = p->blocksize;
 
173
        }
 
174
        if (blocksize <= 0) {
 
175
                if (use_bsize == DEF_MAX_BLOCKSIZE)
 
176
                        use_bsize = sys_page_size;
 
177
                if (sector_size && use_bsize < sector_size)
 
178
                        use_bsize = sector_size;
 
179
                if ((blocksize < 0) && (use_bsize < (-blocksize)))
 
180
                        use_bsize = -blocksize;
 
181
                blocksize = use_bsize;
 
182
                super->s_blocks_count /= blocksize / 1024;
 
183
        }
 
184
        super->s_log_frag_size = super->s_log_block_size =
 
185
                int_log2(blocksize >> EXT2_MIN_BLOCK_LOG_SIZE);
175
186
}
176
187
 
 
188
 
177
189
/*
178
190
 * Helper function for read_bb_file and test_disk
179
191
 */
180
 
static void invalid_block(ext2_filsys fs, blk_t blk)
 
192
static void invalid_block(ext2_filsys fs EXT2FS_ATTR((unused)), blk_t blk)
181
193
{
182
194
        fprintf(stderr, _("Bad block %u out of range; ignored.\n"), blk);
183
195
        return;
238
250
 
239
251
static void handle_bad_blocks(ext2_filsys fs, badblocks_list bb_list)
240
252
{
241
 
        int                     i, j;
242
 
        int                     must_be_good;
 
253
        dgrp_t                  i;
 
254
        blk_t                   j;
 
255
        unsigned                must_be_good;
243
256
        blk_t                   blk;
244
257
        badblocks_iterate       bb_iter;
245
258
        errcode_t               retval;
262
275
                        fprintf(stderr, _("Blocks %d through %d must be good "
263
276
                                "in order to build a filesystem.\n"),
264
277
                                fs->super->s_first_data_block, must_be_good);
265
 
                        fprintf(stderr, _("Aborting....\n"));
 
278
                        fputs(_("Aborting....\n"), stderr);
266
279
                        exit(1);
267
280
                }
268
281
        }
315
328
        char            format[20];
316
329
        char            backup[80];
317
330
        __u32           max;
 
331
        int             skip_progress;
318
332
};
319
333
 
320
334
static void progress_init(struct progress_struct *progress,
333
347
        sprintf(progress->format, "%%%dd/%%%dld", i, i);
334
348
        memset(progress->backup, '\b', sizeof(progress->backup)-1);
335
349
        progress->backup[sizeof(progress->backup)-1] = 0;
336
 
        if ((2*i)+1 < sizeof(progress->backup))
 
350
        if ((2*i)+1 < (int) sizeof(progress->backup))
337
351
                progress->backup[(2*i)+1] = 0;
338
352
        progress->max = max;
339
353
 
 
354
        progress->skip_progress = 0;
 
355
        if (getenv("MKE2FS_SKIP_PROGRESS"))
 
356
                progress->skip_progress++;
 
357
 
340
358
        fputs(label, stdout);
341
359
        fflush(stdout);
342
360
}
343
361
 
344
362
static void progress_update(struct progress_struct *progress, __u32 val)
345
363
{
346
 
        if (progress->format[0] == 0)
 
364
        if ((progress->format[0] == 0) || progress->skip_progress)
347
365
                return;
348
366
        printf(progress->format, val, progress->max);
349
367
        fputs(progress->backup, stdout);
399
417
        if (next_update_incr < 1)
400
418
                next_update_incr = 1;
401
419
        for (j=0; j < num; j += STRIDE_LENGTH, blk += STRIDE_LENGTH) {
402
 
                if (num-j > STRIDE_LENGTH)
 
420
                count = num - j;
 
421
                if (count > STRIDE_LENGTH)
403
422
                        count = STRIDE_LENGTH;
404
 
                else
405
 
                        count = num - j;
406
423
                retval = io_channel_write_blk(fs->io, blk, count, buf);
407
424
                if (retval) {
408
425
                        if (ret_count)
423
440
{
424
441
        errcode_t       retval;
425
442
        blk_t           blk;
426
 
        int             i, num;
 
443
        dgrp_t          i;
 
444
        int             num;
427
445
        struct progress_struct progress;
428
446
 
429
447
        if (quiet)
566
584
                       sect, sect + nsect - 1);
567
585
                exit(1);
568
586
        }
569
 
        memset(buf, 0, 512*nsect);
570
587
 
571
588
        if (sect == 0) {
572
589
                /* Check for a BSD disklabel, and don't erase it if so */
583
600
                }
584
601
        }
585
602
 
 
603
        memset(buf, 0, 512*nsect);
586
604
        io_channel_set_blksize(fs->io, 512);
587
605
        retval = io_channel_write_blk(fs->io, sect, -512*nsect, buf);
588
606
        io_channel_set_blksize(fs->io, fs->blocksize);
639
657
        struct ext2_super_block *s = fs->super;
640
658
        char                    buf[80];
641
659
        blk_t                   group_block;
642
 
        int                     i, need, col_left;
 
660
        dgrp_t                  i;
 
661
        int                     need, col_left;
643
662
        
644
663
        if (param.s_blocks_count != s->s_blocks_count)
645
664
                fprintf(stderr, _("warning: %d blocks unused.\n\n"),
648
667
        memset(buf, 0, sizeof(buf));
649
668
        strncpy(buf, s->s_volume_name, sizeof(s->s_volume_name));
650
669
        printf(_("Filesystem label=%s\n"), buf);
651
 
        printf(_("OS type: "));
 
670
        fputs(_("OS type: "), stdout);
652
671
        switch (fs->super->s_creator_os) {
653
 
            case EXT2_OS_LINUX: printf ("Linux"); break;
654
 
            case EXT2_OS_HURD:  printf ("GNU/Hurd");   break;
655
 
            case EXT2_OS_MASIX: printf ("Masix"); break;
656
 
            default:            printf (_("(unknown os)"));
 
672
            case EXT2_OS_LINUX: fputs("Linux", stdout); break;
 
673
            case EXT2_OS_HURD:  fputs("GNU/Hurd", stdout);   break;
 
674
            case EXT2_OS_MASIX: fputs ("Masix", stdout); break;
 
675
            default:            fputs(_("(unknown os)"), stdout);
657
676
        }
658
677
        printf("\n");
659
678
        printf(_("Block size=%u (log=%u)\n"), fs->blocksize,
773
792
}       
774
793
 
775
794
static __u32 ok_features[3] = {
776
 
        EXT3_FEATURE_COMPAT_HAS_JOURNAL,        /* Compat */
 
795
        EXT3_FEATURE_COMPAT_HAS_JOURNAL |
 
796
                EXT2_FEATURE_COMPAT_DIR_INDEX,  /* Compat */
777
797
        EXT2_FEATURE_INCOMPAT_FILETYPE|         /* Incompat */
778
 
                EXT3_FEATURE_INCOMPAT_JOURNAL_DEV,
 
798
                EXT3_FEATURE_INCOMPAT_JOURNAL_DEV|
 
799
                EXT2_FEATURE_INCOMPAT_META_BG,
779
800
        EXT2_FEATURE_RO_COMPAT_SPARSE_SUPER     /* R/O compat */
780
801
};
781
802
 
782
803
 
783
804
static void PRS(int argc, char *argv[])
784
805
{
785
 
        int             c;
 
806
        int             b, c;
786
807
        int             size;
787
808
        char *          tmp;
788
 
        blk_t           group_blk_max = 8192;
789
809
        int             blocksize = 0;
790
810
        int             inode_ratio = 0;
 
811
        int             inode_size = 0;
791
812
        int             reserved_ratio = 5;
 
813
        int             sector_size = 0;
 
814
        int             show_version_only = 0;
792
815
        ext2_ino_t      num_inodes = 0;
793
816
        errcode_t       retval;
794
817
        char *          oldpath = getenv("PATH");
799
822
#ifdef __linux__
800
823
        struct          utsname ut;
801
824
#endif
 
825
        long            sysval;
802
826
 
803
827
        /* Update our PATH to include /sbin  */
804
828
        if (oldpath) {
815
839
        tmp = getenv("MKE2FS_SYNC");
816
840
        if (tmp)
817
841
                sync_kludge = atoi(tmp);
 
842
 
 
843
        /* Determine the system page size if possible */
 
844
#ifdef HAVE_SYSCONF
 
845
#if (!defined(_SC_PAGESIZE) && defined(_SC_PAGE_SIZE))
 
846
#define _SC_PAGESIZE _SC_PAGE_SIZE
 
847
#endif
 
848
#ifdef _SC_PAGESIZE
 
849
        sysval = sysconf(_SC_PAGESIZE);
 
850
        if (sysval > 0)
 
851
                sys_page_size = sysval;
 
852
#endif /* _SC_PAGESIZE */
 
853
#endif /* HAVE_SYSCONF */
818
854
        
819
855
        setbuf(stdout, NULL);
820
856
        setbuf(stderr, NULL);
823
859
        param.s_rev_level = 1;  /* Create revision 1 filesystems now */
824
860
        param.s_feature_incompat |= EXT2_FEATURE_INCOMPAT_FILETYPE;
825
861
        param.s_feature_ro_compat |= EXT2_FEATURE_RO_COMPAT_SPARSE_SUPER;
826
 
                
 
862
#if 0
 
863
        param.s_feature_compat |= EXT2_FEATURE_COMPAT_DIR_INDEX;
 
864
#endif
 
865
 
827
866
#ifdef __linux__
828
867
        if (uname(&ut)) {
829
868
                perror("uname");
838
877
                param.s_feature_ro_compat = 0;
839
878
        }
840
879
#endif
841
 
        fprintf (stderr, "mke2fs %s (%s)\n",
842
 
                 E2FSPROGS_VERSION, E2FSPROGS_DATE);
843
880
 
844
881
        if (argc && *argv) {
845
882
                program_name = get_progname(*argv);
853
890
                    "b:cf:g:i:jl:m:no:qr:R:s:tvI:J:ST:FL:M:N:O:V")) != EOF)
854
891
                switch (c) {
855
892
                case 'b':
856
 
                        blocksize = strtoul(optarg, &tmp, 0);
857
 
                        if (blocksize < 1024 || blocksize > 4096 || *tmp) {
 
893
                        blocksize = strtol(optarg, &tmp, 0);
 
894
                        b = (blocksize > 0) ? blocksize : -blocksize;
 
895
                        if (b < EXT2_MIN_BLOCK_SIZE ||
 
896
                            b > EXT2_MAX_BLOCK_SIZE || *tmp) {
858
897
                                com_err(program_name, 0,
859
898
                                        _("bad block size - %s"), optarg);
860
899
                                exit(1);
861
900
                        }
862
 
                        param.s_log_block_size =
863
 
                                int_log2(blocksize >> EXT2_MIN_BLOCK_LOG_SIZE);
864
 
                        group_blk_max = blocksize * 8;
 
901
                        if (blocksize > 4096)
 
902
                                fprintf(stderr, _("Warning: blocksize %d not "
 
903
                                                  "usable on most systems.\n"),
 
904
                                        blocksize);
 
905
                        if (blocksize > 0) 
 
906
                                param.s_log_block_size =
 
907
                                        int_log2(blocksize >>
 
908
                                                 EXT2_MIN_BLOCK_LOG_SIZE);
865
909
                        break;
866
910
                case 'c':       /* Check for bad blocks */
867
911
                case 't':       /* deprecated */
869
913
                        break;
870
914
                case 'f':
871
915
                        size = strtoul(optarg, &tmp, 0);
872
 
                        if (size < 1024 || size > 4096 || *tmp) {
 
916
                        if (size < EXT2_MIN_BLOCK_SIZE ||
 
917
                            size > EXT2_MAX_BLOCK_SIZE || *tmp) {
873
918
                                com_err(program_name, 0,
874
919
                                        _("bad fragment size - %s"),
875
920
                                        optarg);
895
940
                        break;
896
941
                case 'i':
897
942
                        inode_ratio = strtoul(optarg, &tmp, 0);
898
 
                        if (inode_ratio < 1024 || inode_ratio > 4096 * 1024 ||
 
943
                        if (inode_ratio < EXT2_MIN_BLOCK_SIZE ||
 
944
                            inode_ratio > EXT2_MAX_BLOCK_SIZE * 1024 ||
899
945
                            *tmp) {
900
946
                                com_err(program_name, 0,
901
 
                                        _("bad inode ratio - %s"), optarg);
 
947
                                        _("bad inode ratio %s (min %d/max %d"),
 
948
                                        optarg, EXT2_MIN_BLOCK_SIZE,
 
949
                                        EXT2_MAX_BLOCK_SIZE);
902
950
                                exit(1);
903
951
                        }
904
952
                        break;
953
1001
                        break;
954
1002
#ifdef EXT2_DYNAMIC_REV
955
1003
                case 'I':
956
 
                        param.s_inode_size = atoi(optarg);
 
1004
                        inode_size = strtoul(optarg, &tmp, 0);
 
1005
                        if (*tmp) {
 
1006
                                com_err(program_name, 0,
 
1007
                                        _("bad inode size - %s"), optarg);
 
1008
                                exit(1);
 
1009
                        }
957
1010
                        break;
958
1011
#endif
959
1012
                case 'N':
1002
1055
                        break;
1003
1056
                case 'V':
1004
1057
                        /* Print version number and exit */
1005
 
                        fprintf(stderr, _("\tUsing %s\n"),
1006
 
                                error_message(EXT2_ET_BASE));
1007
 
                        exit(0);
 
1058
                        show_version_only++;
 
1059
                        break;
1008
1060
                default:
1009
1061
                        usage();
1010
1062
                }
1011
 
        if (optind == argc)
 
1063
        if ((optind == argc) && !show_version_only)
1012
1064
                usage();
1013
1065
        device_name = argv[optind];
1014
1066
        optind++;
1025
1077
        if (optind < argc)
1026
1078
                usage();
1027
1079
 
 
1080
        if (!quiet || show_version_only)
 
1081
                fprintf (stderr, "mke2fs %s (%s)\n", E2FSPROGS_VERSION, 
 
1082
                         E2FSPROGS_DATE);
 
1083
 
 
1084
        if (show_version_only) {
 
1085
                fprintf(stderr, _("\tUsing %s\n"), 
 
1086
                        error_message(EXT2_ET_BASE));
 
1087
                exit(0);
 
1088
        }
 
1089
 
1028
1090
        if (raid_opts)
1029
1091
                parse_raid_opts(raid_opts);
1030
1092
 
1032
1094
         * If there's no blocksize specified and there is a journal
1033
1095
         * device, use it to figure out the blocksize
1034
1096
         */
1035
 
        if (blocksize == 0 && journal_device) {
 
1097
        if (blocksize <= 0 && journal_device) {
1036
1098
                ext2_filsys     jfs;
 
1099
                io_manager      io_ptr;
1037
1100
 
 
1101
#ifdef CONFIG_TESTIO_DEBUG
 
1102
                io_ptr = test_io_manager;
 
1103
                test_io_backing_manager = unix_io_manager;
 
1104
#else
 
1105
                io_ptr = unix_io_manager;
 
1106
#endif
1038
1107
                retval = ext2fs_open(journal_device,
1039
1108
                                     EXT2_FLAG_JOURNAL_DEV_OK, 0,
1040
 
                                     0, unix_io_manager, &jfs);
 
1109
                                     0, io_ptr, &jfs);
1041
1110
                if (retval) {
1042
1111
                        com_err(program_name, retval,
1043
1112
                                _("while trying to open journal device %s\n"),
1044
1113
                                journal_device);
1045
1114
                        exit(1);
1046
1115
                }
 
1116
                if ((blocksize < 0) && (jfs->blocksize < (unsigned) (-blocksize))) {
 
1117
                        com_err(program_name, 0,
 
1118
                                _("Journal dev blocksize (%d) smaller than "
 
1119
                                  "minimum blocksize %d\n"), jfs->blocksize,
 
1120
                                -blocksize);
 
1121
                        exit(1);
 
1122
                }
1047
1123
                blocksize = jfs->blocksize;
1048
1124
                param.s_log_block_size =
1049
1125
                        int_log2(blocksize >> EXT2_MIN_BLOCK_LOG_SIZE);
1050
1126
                ext2fs_close(jfs);
1051
1127
        }
1052
1128
 
 
1129
        if (blocksize > sys_page_size) {
 
1130
                if (!force) {
 
1131
                        com_err(program_name, 0,
 
1132
                                _("%d-byte blocks too big for system (max %d)"),
 
1133
                                blocksize, sys_page_size);
 
1134
                        proceed_question();
 
1135
                }
 
1136
                fprintf(stderr, _("Warning: %d-byte blocks too big for system "
 
1137
                                  "(max %d), forced to continue\n"),
 
1138
                        blocksize, sys_page_size);
 
1139
        }
 
1140
        if ((blocksize > 4096) &&
 
1141
            (param.s_feature_compat & EXT3_FEATURE_COMPAT_HAS_JOURNAL))
 
1142
                fprintf(stderr, "\nWarning: some 2.4 kernels do not support "
 
1143
                        "blocksizes greater than 4096 \n\tusing ext3."
 
1144
                        "  Use -b 4096 if this is an issue for you.\n\n");
 
1145
 
1053
1146
        if (param.s_feature_incompat & EXT3_FEATURE_INCOMPAT_JOURNAL_DEV) {
1054
1147
                if (!fs_type)
1055
1148
                        fs_type = "journal";
1102
1195
                                exit(1);
1103
1196
                        }
1104
1197
                        param.s_blocks_count = dev_size;
 
1198
                        if (sys_page_size > EXT2_BLOCK_SIZE(&param))
 
1199
                                param.s_blocks_count &= ~((sys_page_size /
 
1200
                                                           EXT2_BLOCK_SIZE(&param))-1);
1105
1201
                }
1106
1202
                
1107
1203
        } else if (!force && (param.s_blocks_count > dev_size)) {
1108
1204
                com_err(program_name, 0,
1109
 
                        _("Filesystem larger than apparent filesystem size."));
 
1205
                        _("Filesystem larger than apparent device size."));
1110
1206
                proceed_question();
1111
1207
        }
1112
1208
 
1118
1214
            !journal_size)
1119
1215
                journal_size = -1;
1120
1216
 
1121
 
        set_fs_defaults(fs_type, &param, blocksize, &inode_ratio);
1122
 
 
 
1217
        /* Set first meta blockgroup via an environment variable */
 
1218
        /* (this is mostly for debugging purposes) */
 
1219
        if ((param.s_feature_incompat & EXT2_FEATURE_INCOMPAT_META_BG) &&
 
1220
            ((tmp = getenv("MKE2FS_FIRST_META_BG"))))
 
1221
                param.s_first_meta_bg = atoi(tmp);
 
1222
 
 
1223
        /* Get the hardware sector size, if available */
 
1224
        retval = ext2fs_get_device_sectsize(device_name, &sector_size);
 
1225
        if (retval) {
 
1226
                com_err(program_name, retval,
 
1227
                        _("while trying to determine hardware sector size"));
 
1228
                exit(1);
 
1229
        }
 
1230
 
 
1231
        if ((tmp = getenv("MKE2FS_DEVICE_SECTSIZE")) != NULL)
 
1232
                sector_size = atoi(tmp);
 
1233
        
 
1234
        set_fs_defaults(fs_type, &param, blocksize, sector_size, &inode_ratio);
 
1235
        blocksize = EXT2_BLOCK_SIZE(&param);
 
1236
        
1123
1237
        if (param.s_blocks_per_group) {
1124
1238
                if (param.s_blocks_per_group < 256 ||
1125
 
                    param.s_blocks_per_group > group_blk_max || *tmp) {
 
1239
                    param.s_blocks_per_group > 8 * (unsigned) blocksize) {
1126
1240
                        com_err(program_name, 0,
1127
1241
                                _("blocks per group count out of range"));
1128
1242
                        exit(1);
1129
1243
                }
1130
1244
        }
1131
1245
 
 
1246
        if (inode_size) {
 
1247
                if (inode_size < EXT2_GOOD_OLD_INODE_SIZE ||
 
1248
                    inode_size > EXT2_BLOCK_SIZE(&param) ||
 
1249
                    inode_size & (inode_size - 1)) {
 
1250
                        com_err(program_name, 0,
 
1251
                                _("bad inode size %d (min %d/max %d)"),
 
1252
                                inode_size, EXT2_GOOD_OLD_INODE_SIZE,
 
1253
                                blocksize);
 
1254
                        exit(1);
 
1255
                }
 
1256
                if (inode_size != EXT2_GOOD_OLD_INODE_SIZE)
 
1257
                        fprintf(stderr, _("Warning: %d-byte inodes not usable "
 
1258
                                "on most systems\n"),
 
1259
                                inode_size);
 
1260
                param.s_inode_size = inode_size;
 
1261
        }
 
1262
 
1132
1263
        /*
1133
1264
         * Calculate number of inodes based on the inode ratio
1134
1265
         */
1135
1266
        param.s_inodes_count = num_inodes ? num_inodes : 
1136
 
                ((__u64) param.s_blocks_count * EXT2_BLOCK_SIZE(&param))
 
1267
                ((__u64) param.s_blocks_count * blocksize)
1137
1268
                        / inode_ratio;
1138
1269
 
1139
1270
        /*
1149
1280
        ext2_filsys     fs;
1150
1281
        badblocks_list  bb_list = 0;
1151
1282
        int             journal_blocks;
1152
 
        int             i, val;
 
1283
        unsigned int    i;
 
1284
        int             val;
 
1285
        io_manager      io_ptr;
1153
1286
 
1154
1287
#ifdef ENABLE_NLS
1155
1288
        setlocale(LC_MESSAGES, "");
1159
1292
#endif
1160
1293
        PRS(argc, argv);
1161
1294
 
 
1295
#ifdef CONFIG_TESTIO_DEBUG
 
1296
        io_ptr = test_io_manager;
 
1297
        test_io_backing_manager = unix_io_manager;
 
1298
#else
 
1299
        io_ptr = unix_io_manager;
 
1300
#endif
 
1301
 
1162
1302
        /*
1163
1303
         * Initialize the superblock....
1164
1304
         */
1165
1305
        retval = ext2fs_initialize(device_name, 0, &param,
1166
 
                                   unix_io_manager, &fs);
 
1306
                                   io_ptr, &fs);
1167
1307
        if (retval) {
1168
1308
                com_err(device_name, retval, _("while setting up superblock"));
1169
1309
                exit(1);
1181
1321
        uuid_generate(fs->super->s_uuid);
1182
1322
 
1183
1323
        /*
 
1324
         * Initialize the directory index variables
 
1325
         */
 
1326
        fs->super->s_def_hash_version = EXT2_HASH_TEA;
 
1327
        uuid_generate((unsigned char *) fs->super->s_hash_seed);
 
1328
 
 
1329
        /*
1184
1330
         * Add "jitter" to the superblock's check interval so that we
1185
1331
         * don't check all the filesystems at the same time.  We use a
1186
1332
         * kludgy hack of using the UUID to derive a random jitter value.
1255
1401
                fs->flags &= ~(EXT2_FLAG_IB_DIRTY|EXT2_FLAG_BB_DIRTY);
1256
1402
        } else {
1257
1403
                /* rsv must be a power of two (64kB is MD RAID sb alignment) */
1258
 
                int rsv = 65536 / fs->blocksize;
 
1404
                unsigned int rsv = 65536 / fs->blocksize;
1259
1405
                unsigned long blocks = fs->super->s_blocks_count;
1260
1406
                unsigned long start;
1261
1407
                blk_t ret_blk;
1278
1424
 
1279
1425
                if (retval) {
1280
1426
                        com_err(program_name, retval,
1281
 
                                _("zeroing block %u at end of filesystem"),
 
1427
                                _("while zeroing block %u at end of filesystem"),
1282
1428
                                ret_blk);
1283
 
                        exit(1);
1284
1429
                }
1285
1430
                write_inode_tables(fs);
1286
1431
                create_root_dir(fs);
1356
1501
        }
1357
1502
        if (!quiet) {
1358
1503
                printf(_("done\n\n"));
1359
 
                print_check_message(fs);
 
1504
                if (!getenv("MKE2FS_SKIP_CHECK_MSG"))
 
1505
                        print_check_message(fs);
1360
1506
        }
1361
1507
        val = ext2fs_close(fs);
1362
1508
        return (retval || val) ? 1 : 0;