2 * mke2fs.c - Make a ext2fs filesystem.
4 * Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
5 * 2003, 2004, 2005 by Theodore Ts'o.
8 * This file may be redistributed under the terms of the GNU Public
13 /* Usage: mke2fs [options] device
15 * The device may be a block device or a image of one, but this isn't
16 * enforced (but it's not much fun on a character device :-).
19 #define _XOPEN_SOURCE 600 /* for inclusion of PATH_MAX in Solaris */
29 #include <sys/utsname.h>
46 #include <sys/ioctl.h>
47 #include <sys/types.h>
51 #include <blkid/blkid.h>
53 #include "ext2fs/ext2_fs.h"
54 #include "ext2fs/ext2fsP.h"
55 #include "et/com_err.h"
56 #include "uuid/uuid.h"
58 #include "ext2fs/ext2fs.h"
62 #include "../version.h"
63 #include "nls-enable.h"
64 #include "quota/mkquota.h"
66 #define STRIDE_LENGTH 8
68 #define MAX_32_NUM ((((unsigned long long) 1) << 32) - 1)
74 #define DISCARD_STEP_MB (2048)
76 extern int isatty(int);
77 extern FILE *fpopen(const char *cmd, const char *mode);
79 const char * program_name = "mke2fs";
80 const char * device_name /* = NULL */;
82 /* Command line options */
87 int discard = 1; /* attempt to discard device before fs creation */
96 char *bad_blocks_filename;
98 int quotatype = -1; /* Initialize both user and group quotas by default */
100 struct ext2_super_block fs_param;
101 char *fs_uuid = NULL;
105 char *journal_device;
106 int sync_kludge; /* Set using the MKE2FS_SYNC env. option */
111 int sys_page_size = 4096;
112 int linux_version_code = 0;
114 static void usage(void)
116 fprintf(stderr, _("Usage: %s [-c|-l filename] [-b block-size] "
117 "[-C cluster-size]\n\t[-i bytes-per-inode] [-I inode-size] "
118 "[-J journal-options]\n"
119 "\t[-G flex-group-size] [-N number-of-inodes]\n"
120 "\t[-m reserved-blocks-percentage] [-o creator-os]\n"
121 "\t[-g blocks-per-group] [-L volume-label] "
122 "[-M last-mounted-directory]\n\t[-O feature[,...]] "
123 "[-r fs-revision] [-E extended-option[,...]]\n"
124 "\t[-t fs-type] [-T usage-type ] [-U UUID] "
125 "[-jnqvDFKSV] device [blocks-count]\n"),
130 static int int_log2(unsigned long long arg)
142 static int int_log10(unsigned long long arg)
152 static int parse_version_number(const char *s)
154 int major, minor, rev;
160 major = strtol(cp, &endptr, 10);
161 if (cp == endptr || *endptr != '.')
164 minor = strtol(cp, &endptr, 10);
165 if (cp == endptr || *endptr != '.')
168 rev = strtol(cp, &endptr, 10);
171 return ((((major * 256) + minor) * 256) + rev);
176 * Helper function for read_bb_file and test_disk
178 static void invalid_block(ext2_filsys fs EXT2FS_ATTR((unused)), blk_t blk)
180 fprintf(stderr, _("Bad block %u out of range; ignored.\n"), blk);
185 * Reads the bad blocks list from a file
187 static void read_bb_file(ext2_filsys fs, badblocks_list *bb_list,
188 const char *bad_blocks_file)
193 f = fopen(bad_blocks_file, "r");
195 com_err("read_bad_blocks_file", errno,
196 _("while trying to open %s"), bad_blocks_file);
199 retval = ext2fs_read_bb_FILE(fs, f, bb_list, invalid_block);
202 com_err("ext2fs_read_bb_FILE", retval,
203 _("while reading in list of bad blocks from file"));
209 * Runs the badblocks program to test the disk
211 static void test_disk(ext2_filsys fs, badblocks_list *bb_list)
217 sprintf(buf, "badblocks -b %d -X %s%s%s %llu", fs->blocksize,
218 quiet ? "" : "-s ", (cflag > 1) ? "-w " : "",
219 fs->device_name, ext2fs_blocks_count(fs->super)-1);
221 printf(_("Running command: %s\n"), buf);
224 com_err("popen", errno,
225 _("while trying to run '%s'"), buf);
228 retval = ext2fs_read_bb_FILE(fs, f, bb_list, invalid_block);
231 com_err("ext2fs_read_bb_FILE", retval,
232 _("while processing list of bad blocks from program"));
237 static void handle_bad_blocks(ext2_filsys fs, badblocks_list bb_list)
241 unsigned must_be_good;
243 badblocks_iterate bb_iter;
253 * The primary superblock and group descriptors *must* be
254 * good; if not, abort.
256 must_be_good = fs->super->s_first_data_block + 1 + fs->desc_blocks;
257 for (i = fs->super->s_first_data_block; i <= must_be_good; i++) {
258 if (ext2fs_badblocks_list_test(bb_list, i)) {
259 fprintf(stderr, _("Block %d in primary "
260 "superblock/group descriptor area bad.\n"), i);
261 fprintf(stderr, _("Blocks %u through %u must be good "
262 "in order to build a filesystem.\n"),
263 fs->super->s_first_data_block, must_be_good);
264 fputs(_("Aborting....\n"), stderr);
270 * See if any of the bad blocks are showing up in the backup
271 * superblocks and/or group descriptors. If so, issue a
272 * warning and adjust the block counts appropriately.
274 group_block = fs->super->s_first_data_block +
275 fs->super->s_blocks_per_group;
277 for (i = 1; i < fs->group_desc_count; i++) {
279 for (j=0; j < fs->desc_blocks+1; j++) {
280 if (ext2fs_badblocks_list_test(bb_list,
284 _("Warning: the backup superblock/group descriptors at block %u contain\n"
288 group = ext2fs_group_of_blk2(fs, group_block+j);
289 ext2fs_bg_free_blocks_count_set(fs, group, ext2fs_bg_free_blocks_count(fs, group) + 1);
290 ext2fs_group_desc_csum_set(fs, group);
291 ext2fs_free_blocks_count_add(fs->super, 1);
294 group_block += fs->super->s_blocks_per_group;
298 * Mark all the bad blocks as used...
300 retval = ext2fs_badblocks_list_iterate_begin(bb_list, &bb_iter);
302 com_err("ext2fs_badblocks_list_iterate_begin", retval,
303 _("while marking bad blocks as used"));
306 while (ext2fs_badblocks_list_iterate(bb_iter, &blk))
307 ext2fs_mark_block_bitmap2(fs->block_map, EXT2FS_B2C(fs, blk));
308 ext2fs_badblocks_list_iterate_end(bb_iter);
311 static void write_inode_tables(ext2_filsys fs, int lazy_flag, int itable_zeroed)
317 struct ext2fs_numeric_progress_struct progress;
319 ext2fs_numeric_progress_init(fs, &progress,
320 _("Writing inode tables: "),
321 fs->group_desc_count);
323 for (i = 0; i < fs->group_desc_count; i++) {
324 ext2fs_numeric_progress_update(fs, &progress, i);
326 blk = ext2fs_inode_table_loc(fs, i);
327 num = fs->inode_blocks_per_group;
330 num = ext2fs_div_ceil((fs->super->s_inodes_per_group -
331 ext2fs_bg_itable_unused(fs, i)) *
332 EXT2_INODE_SIZE(fs->super),
333 EXT2_BLOCK_SIZE(fs->super));
334 if (!lazy_flag || itable_zeroed) {
335 /* The kernel doesn't need to zero the itable blocks */
336 ext2fs_bg_flags_set(fs, i, EXT2_BG_INODE_ZEROED);
337 ext2fs_group_desc_csum_set(fs, i);
339 retval = ext2fs_zero_blocks2(fs, blk, num, &blk, &num);
341 fprintf(stderr, _("\nCould not write %d "
342 "blocks in inode table starting at %llu: %s\n"),
343 num, blk, error_message(retval));
347 if (sync_kludge == 1)
349 else if ((i % sync_kludge) == 0)
353 ext2fs_zero_blocks2(0, 0, 0, 0, 0);
354 ext2fs_numeric_progress_close(fs, &progress,
358 static void create_root_dir(ext2_filsys fs)
361 struct ext2_inode inode;
364 retval = ext2fs_mkdir(fs, EXT2_ROOT_INO, EXT2_ROOT_INO, 0);
366 com_err("ext2fs_mkdir", retval, _("while creating root dir"));
369 if (root_uid != 0 || root_gid != 0) {
370 retval = ext2fs_read_inode(fs, EXT2_ROOT_INO, &inode);
372 com_err("ext2fs_read_inode", retval,
373 _("while reading root inode"));
377 inode.i_uid = root_uid;
378 ext2fs_set_i_uid_high(inode, root_uid >> 16);
379 inode.i_gid = root_gid;
380 ext2fs_set_i_gid_high(inode, root_gid >> 16);
382 retval = ext2fs_write_new_inode(fs, EXT2_ROOT_INO, &inode);
384 com_err("ext2fs_write_inode", retval,
385 _("while setting root inode ownership"));
391 static void create_lost_and_found(ext2_filsys fs)
393 unsigned int lpf_size = 0;
396 const char *name = "lost+found";
400 retval = ext2fs_mkdir(fs, EXT2_ROOT_INO, 0, name);
402 com_err("ext2fs_mkdir", retval,
403 _("while creating /lost+found"));
407 retval = ext2fs_lookup(fs, EXT2_ROOT_INO, name, strlen(name), 0, &ino);
409 com_err("ext2_lookup", retval,
410 _("while looking up /lost+found"));
414 for (i=1; i < EXT2_NDIR_BLOCKS; i++) {
415 /* Ensure that lost+found is at least 2 blocks, so we always
416 * test large empty blocks for big-block filesystems. */
417 if ((lpf_size += fs->blocksize) >= 16*1024 &&
418 lpf_size >= 2 * fs->blocksize)
420 retval = ext2fs_expand_dir(fs, ino);
422 com_err("ext2fs_expand_dir", retval,
423 _("while expanding /lost+found"));
429 static void create_bad_block_inode(ext2_filsys fs, badblocks_list bb_list)
433 ext2fs_mark_inode_bitmap2(fs->inode_map, EXT2_BAD_INO);
434 ext2fs_inode_alloc_stats2(fs, EXT2_BAD_INO, +1, 0);
435 retval = ext2fs_update_bb_inode(fs, bb_list);
437 com_err("ext2fs_update_bb_inode", retval,
438 _("while setting bad block inode"));
444 static void reserve_inodes(ext2_filsys fs)
448 for (i = EXT2_ROOT_INO + 1; i < EXT2_FIRST_INODE(fs->super); i++)
449 ext2fs_inode_alloc_stats2(fs, i, +1, 0);
450 ext2fs_mark_ib_dirty(fs);
453 #define BSD_DISKMAGIC (0x82564557UL) /* The disk magic number */
454 #define BSD_MAGICDISK (0x57455682UL) /* The disk magic number reversed */
455 #define BSD_LABEL_OFFSET 64
457 static void zap_sector(ext2_filsys fs, int sect, int nsect)
463 buf = malloc(512*nsect);
465 printf(_("Out of memory erasing sectors %d-%d\n"),
466 sect, sect + nsect - 1);
471 /* Check for a BSD disklabel, and don't erase it if so */
472 retval = io_channel_read_blk64(fs->io, 0, -512, buf);
475 _("Warning: could not read block 0: %s\n"),
476 error_message(retval));
478 magic = (unsigned int *) (buf + BSD_LABEL_OFFSET);
479 if ((*magic == BSD_DISKMAGIC) ||
480 (*magic == BSD_MAGICDISK))
485 memset(buf, 0, 512*nsect);
486 io_channel_set_blksize(fs->io, 512);
487 retval = io_channel_write_blk64(fs->io, sect, -512*nsect, buf);
488 io_channel_set_blksize(fs->io, fs->blocksize);
491 fprintf(stderr, _("Warning: could not erase sector %d: %s\n"),
492 sect, error_message(retval));
495 static void create_journal_dev(ext2_filsys fs)
497 struct ext2fs_numeric_progress_struct progress;
500 blk64_t blk, err_blk;
501 int c, count, err_count;
503 retval = ext2fs_create_journal_superblock(fs,
504 ext2fs_blocks_count(fs->super), 0, &buf);
506 com_err("create_journal_dev", retval,
507 _("while initializing journal superblock"));
511 if (journal_flags & EXT2_MKJOURNAL_LAZYINIT)
512 goto write_superblock;
514 ext2fs_numeric_progress_init(fs, &progress,
515 _("Zeroing journal device: "),
516 ext2fs_blocks_count(fs->super));
518 count = ext2fs_blocks_count(fs->super);
524 retval = ext2fs_zero_blocks2(fs, blk, c, &err_blk, &err_count);
526 com_err("create_journal_dev", retval,
527 _("while zeroing journal device "
528 "(block %llu, count %d)"),
534 ext2fs_numeric_progress_update(fs, &progress, blk);
536 ext2fs_zero_blocks2(0, 0, 0, 0, 0);
538 ext2fs_numeric_progress_close(fs, &progress, NULL);
540 retval = io_channel_write_blk64(fs->io,
541 fs->super->s_first_data_block+1,
544 com_err("create_journal_dev", retval,
545 _("while writing journal superblock"));
550 static void show_stats(ext2_filsys fs)
552 struct ext2_super_block *s = fs->super;
559 if (ext2fs_blocks_count(&fs_param) != ext2fs_blocks_count(s))
560 fprintf(stderr, _("warning: %llu blocks unused.\n\n"),
561 ext2fs_blocks_count(&fs_param) - ext2fs_blocks_count(s));
563 memset(buf, 0, sizeof(buf));
564 strncpy(buf, s->s_volume_name, sizeof(s->s_volume_name));
565 printf(_("Filesystem label=%s\n"), buf);
566 os = e2p_os2string(fs->super->s_creator_os);
568 printf(_("OS type: %s\n"), os);
570 printf(_("Block size=%u (log=%u)\n"), fs->blocksize,
571 s->s_log_block_size);
572 if (EXT2_HAS_RO_COMPAT_FEATURE(fs->super,
573 EXT4_FEATURE_RO_COMPAT_BIGALLOC))
574 printf(_("Cluster size=%u (log=%u)\n"),
575 fs->blocksize << fs->cluster_ratio_bits,
576 s->s_log_cluster_size);
578 printf(_("Fragment size=%u (log=%u)\n"), EXT2_CLUSTER_SIZE(s),
579 s->s_log_cluster_size);
580 printf(_("Stride=%u blocks, Stripe width=%u blocks\n"),
581 s->s_raid_stride, s->s_raid_stripe_width);
582 printf(_("%u inodes, %llu blocks\n"), s->s_inodes_count,
583 ext2fs_blocks_count(s));
584 printf(_("%llu blocks (%2.2f%%) reserved for the super user\n"),
585 ext2fs_r_blocks_count(s),
586 100.0 * ext2fs_r_blocks_count(s) / ext2fs_blocks_count(s));
587 printf(_("First data block=%u\n"), s->s_first_data_block);
588 if (root_uid != 0 || root_gid != 0)
589 printf(_("Root directory owner=%u:%u\n"), root_uid, root_gid);
590 if (s->s_reserved_gdt_blocks)
591 printf(_("Maximum filesystem blocks=%lu\n"),
592 (s->s_reserved_gdt_blocks + fs->desc_blocks) *
593 EXT2_DESC_PER_BLOCK(s) * s->s_blocks_per_group);
594 if (fs->group_desc_count > 1)
595 printf(_("%u block groups\n"), fs->group_desc_count);
597 printf(_("%u block group\n"), fs->group_desc_count);
598 if (EXT2_HAS_RO_COMPAT_FEATURE(fs->super,
599 EXT4_FEATURE_RO_COMPAT_BIGALLOC))
600 printf(_("%u blocks per group, %u clusters per group\n"),
601 s->s_blocks_per_group, s->s_clusters_per_group);
603 printf(_("%u blocks per group, %u fragments per group\n"),
604 s->s_blocks_per_group, s->s_clusters_per_group);
605 printf(_("%u inodes per group\n"), s->s_inodes_per_group);
607 if (fs->group_desc_count == 1) {
612 printf(_("Superblock backups stored on blocks: "));
613 group_block = s->s_first_data_block;
615 for (i = 1; i < fs->group_desc_count; i++) {
616 group_block += s->s_blocks_per_group;
617 if (!ext2fs_bg_has_super(fs, i))
621 need = int_log10(group_block) + 2;
622 if (need > col_left) {
627 printf("%llu", group_block);
633 * Set the S_CREATOR_OS field. Return true if OS is known,
636 static int set_os(struct ext2_super_block *sb, char *os)
639 sb->s_creator_os = atoi (os);
640 else if (strcasecmp(os, "linux") == 0)
641 sb->s_creator_os = EXT2_OS_LINUX;
642 else if (strcasecmp(os, "GNU") == 0 || strcasecmp(os, "hurd") == 0)
643 sb->s_creator_os = EXT2_OS_HURD;
644 else if (strcasecmp(os, "freebsd") == 0)
645 sb->s_creator_os = EXT2_OS_FREEBSD;
646 else if (strcasecmp(os, "lites") == 0)
647 sb->s_creator_os = EXT2_OS_LITES;
653 #define PATH_SET "PATH=/sbin"
655 static void parse_extended_opts(struct ext2_super_block *param,
658 char *buf, *token, *next, *p, *arg, *badopt = 0;
666 _("Couldn't allocate memory to parse options!\n"));
670 for (token = buf; token && *token; token = next) {
671 p = strchr(token, ',');
677 arg = strchr(token, '=');
682 if (strcmp(token, "mmp_update_interval") == 0) {
688 param->s_mmp_update_interval = strtoul(arg, &p, 0);
691 _("Invalid mmp_update_interval: %s\n"),
696 } else if (strcmp(token, "stride") == 0) {
702 param->s_raid_stride = strtoul(arg, &p, 0);
705 _("Invalid stride parameter: %s\n"),
710 } else if (strcmp(token, "stripe-width") == 0 ||
711 strcmp(token, "stripe_width") == 0) {
717 param->s_raid_stripe_width = strtoul(arg, &p, 0);
720 _("Invalid stripe-width parameter: %s\n"),
725 } else if (!strcmp(token, "resize")) {
727 unsigned long bpg, rsv_groups;
728 unsigned long group_desc_count, desc_blocks;
729 unsigned int gdpb, blocksize;
738 resize = parse_num_blocks2(arg,
739 param->s_log_block_size);
743 _("Invalid resize parameter: %s\n"),
748 if (resize <= ext2fs_blocks_count(param)) {
750 _("The resize maximum must be greater "
751 "than the filesystem size.\n"));
756 blocksize = EXT2_BLOCK_SIZE(param);
757 bpg = param->s_blocks_per_group;
760 gdpb = EXT2_DESC_PER_BLOCK(param);
761 group_desc_count = (__u32) ext2fs_div64_ceil(
762 ext2fs_blocks_count(param), bpg);
763 desc_blocks = (group_desc_count +
765 rsv_groups = ext2fs_div64_ceil(resize, bpg);
766 rsv_gdb = ext2fs_div_ceil(rsv_groups, gdpb) -
768 if (rsv_gdb > (int) EXT2_ADDR_PER_BLOCK(param))
769 rsv_gdb = EXT2_ADDR_PER_BLOCK(param);
772 if (param->s_rev_level == EXT2_GOOD_OLD_REV) {
774 _("On-line resizing not supported with revision 0 filesystems\n"));
778 param->s_feature_compat |=
779 EXT2_FEATURE_COMPAT_RESIZE_INODE;
781 param->s_reserved_gdt_blocks = rsv_gdb;
783 } else if (!strcmp(token, "test_fs")) {
784 param->s_flags |= EXT2_FLAGS_TEST_FILESYS;
785 } else if (!strcmp(token, "lazy_itable_init")) {
787 lazy_itable_init = strtoul(arg, &p, 0);
789 lazy_itable_init = 1;
790 } else if (!strcmp(token, "lazy_journal_init")) {
792 journal_flags |= strtoul(arg, &p, 0) ?
793 EXT2_MKJOURNAL_LAZYINIT : 0;
795 journal_flags |= EXT2_MKJOURNAL_LAZYINIT;
796 } else if (!strcmp(token, "root_owner")) {
798 root_uid = strtoul(arg, &p, 0);
801 _("Invalid root_owner: '%s'\n"),
807 root_gid = strtoul(p, &p, 0);
810 _("Invalid root_owner: '%s'\n"),
819 } else if (!strcmp(token, "discard")) {
821 } else if (!strcmp(token, "nodiscard")) {
823 } else if (!strcmp(token, "quotatype")) {
829 if (!strncmp(arg, "usr", 3)) {
831 } else if (!strncmp(arg, "grp", 3)) {
835 _("Invalid quotatype parameter: %s\n"),
846 fprintf(stderr, _("\nBad option(s) specified: %s\n\n"
847 "Extended options are separated by commas, "
848 "and may take an argument which\n"
849 "\tis set off by an equals ('=') sign.\n\n"
850 "Valid extended options are:\n"
851 "\tstride=<RAID per-disk data chunk in blocks>\n"
852 "\tstripe-width=<RAID stride * data disks in blocks>\n"
853 "\tresize=<resize maximum size in blocks>\n"
854 "\tlazy_itable_init=<0 to disable, 1 to enable>\n"
855 "\tlazy_journal_init=<0 to disable, 1 to enable>\n"
856 "\troot_uid=<uid of root directory>\n"
857 "\troot_gid=<gid of root directory>\n"
861 "\tquotatype=<usr OR grp>\n\n"),
862 badopt ? badopt : "");
866 if (param->s_raid_stride &&
867 (param->s_raid_stripe_width % param->s_raid_stride) != 0)
868 fprintf(stderr, _("\nWarning: RAID stripe-width %u not an even "
869 "multiple of stride %u.\n\n"),
870 param->s_raid_stripe_width, param->s_raid_stride);
875 static __u32 ok_features[3] = {
877 EXT3_FEATURE_COMPAT_HAS_JOURNAL |
878 EXT2_FEATURE_COMPAT_RESIZE_INODE |
879 EXT2_FEATURE_COMPAT_DIR_INDEX |
880 EXT2_FEATURE_COMPAT_EXT_ATTR,
882 EXT2_FEATURE_INCOMPAT_FILETYPE|
883 EXT3_FEATURE_INCOMPAT_EXTENTS|
884 EXT3_FEATURE_INCOMPAT_JOURNAL_DEV|
885 EXT2_FEATURE_INCOMPAT_META_BG|
886 EXT4_FEATURE_INCOMPAT_FLEX_BG|
887 EXT4_FEATURE_INCOMPAT_MMP |
888 EXT4_FEATURE_INCOMPAT_64BIT,
890 EXT2_FEATURE_RO_COMPAT_LARGE_FILE|
891 EXT4_FEATURE_RO_COMPAT_HUGE_FILE|
892 EXT4_FEATURE_RO_COMPAT_DIR_NLINK|
893 EXT4_FEATURE_RO_COMPAT_EXTRA_ISIZE|
894 EXT2_FEATURE_RO_COMPAT_SPARSE_SUPER|
895 EXT4_FEATURE_RO_COMPAT_GDT_CSUM|
896 EXT4_FEATURE_RO_COMPAT_BIGALLOC|
898 EXT4_FEATURE_RO_COMPAT_QUOTA|
904 static void syntax_err_report(const char *filename, long err, int line_num)
907 _("Syntax error in mke2fs config file (%s, line #%d)\n\t%s\n"),
908 filename, line_num, error_message(err));
912 static const char *config_fn[] = { ROOT_SYSCONFDIR "/mke2fs.conf", 0 };
914 static void edit_feature(const char *str, __u32 *compat_array)
919 if (e2p_edit_feature(str, compat_array, ok_features)) {
920 fprintf(stderr, _("Invalid filesystem option set: %s\n"),
926 static void edit_mntopts(const char *str, __u32 *mntopts)
931 if (e2p_edit_mntopts(str, mntopts, ~0)) {
932 fprintf(stderr, _("Invalid mount option set: %s\n"),
944 static errcode_t init_list(struct str_list *sl)
948 sl->list = malloc((sl->max+1) * sizeof(char *));
955 static errcode_t push_string(struct str_list *sl, const char *str)
959 if (sl->num >= sl->max) {
961 new_list = realloc(sl->list, (sl->max+1) * sizeof(char *));
966 sl->list[sl->num] = malloc(strlen(str)+1);
967 if (sl->list[sl->num] == 0)
969 strcpy(sl->list[sl->num], str);
971 sl->list[sl->num] = 0;
975 static void print_str_list(char **list)
979 for (cpp = list; *cpp; cpp++) {
980 printf("'%s'", *cpp);
988 * Return TRUE if the profile has the given subsection
990 static int profile_has_subsection(profile_t prof, const char *section,
991 const char *subsection)
994 const char *names[4];
999 names[1] = subsection;
1002 if (profile_iterator_create(prof, names,
1003 PROFILE_ITER_LIST_SECTION |
1004 PROFILE_ITER_RELATIONS_ONLY, &state))
1007 if ((profile_iterator(&state, &name, 0) == 0) && name) {
1012 profile_iterator_free(&state);
1016 static char **parse_fs_type(const char *fs_type,
1017 const char *usage_types,
1018 struct ext2_super_block *sb,
1019 blk64_t fs_blocks_count,
1022 const char *ext_type = 0;
1024 char *profile_type = 0;
1026 const char *size_type;
1027 struct str_list list;
1028 unsigned long long meg;
1031 if (init_list(&list))
1034 if (creator_os && (!strcasecmp(creator_os, "GNU") ||
1035 !strcasecmp(creator_os, "hurd")))
1042 else if (!strcmp(program_name, "mke3fs"))
1044 else if (!strcmp(program_name, "mke4fs"))
1046 else if (progname) {
1047 ext_type = strrchr(progname, '/');
1051 ext_type = progname;
1053 if (!strncmp(ext_type, "mkfs.", 5)) {
1055 if (ext_type[0] == 0)
1062 profile_get_string(profile, "defaults", "fs_type", 0,
1063 "ext2", &profile_type);
1064 ext_type = profile_type;
1065 if (!strcmp(ext_type, "ext2") && (journal_size != 0))
1070 if (!profile_has_subsection(profile, "fs_types", ext_type) &&
1071 strcmp(ext_type, "ext2")) {
1072 printf(_("\nYour mke2fs.conf file does not define the "
1073 "%s filesystem type.\n"), ext_type);
1074 if (!strcmp(ext_type, "ext3") || !strcmp(ext_type, "ext4") ||
1075 !strcmp(ext_type, "ext4dev")) {
1076 printf(_("You probably need to install an updated "
1077 "mke2fs.conf file.\n\n"));
1080 printf(_("Aborting...\n"));
1085 meg = (1024 * 1024) / EXT2_BLOCK_SIZE(sb);
1086 if (fs_blocks_count < 3 * meg)
1087 size_type = "floppy";
1088 else if (fs_blocks_count < 512 * meg)
1089 size_type = "small";
1090 else if (fs_blocks_count < 4 * 1024 * 1024 * meg)
1091 size_type = "default";
1092 else if (fs_blocks_count < 16 * 1024 * 1024 * meg)
1098 usage_types = size_type;
1100 parse_str = malloc(strlen(usage_types)+1);
1105 strcpy(parse_str, usage_types);
1108 push_string(&list, ext_type);
1111 t = strchr(cp, ',');
1116 if (profile_has_subsection(profile, "fs_types", cp))
1117 push_string(&list, cp);
1118 else if (strcmp(cp, "default") != 0)
1120 _("\nWarning: the fs_type %s is not "
1121 "defined in mke2fs.conf\n\n"),
1132 push_string(&list, "hurd");
1136 static char *get_string_from_profile(char **types, const char *opt,
1137 const char *def_val)
1142 for (i=0; types[i]; i++);
1143 for (i-=1; i >=0 ; i--) {
1144 profile_get_string(profile, "fs_types", types[i],
1149 profile_get_string(profile, "defaults", opt, 0, def_val, &ret);
1153 static int get_int_from_profile(char **types, const char *opt, int def_val)
1158 profile_get_integer(profile, "defaults", opt, 0, def_val, &ret);
1159 for (cpp = types; *cpp; cpp++)
1160 profile_get_integer(profile, "fs_types", *cpp, opt, ret, &ret);
1164 static double get_double_from_profile(char **types, const char *opt,
1170 profile_get_double(profile, "defaults", opt, 0, def_val, &ret);
1171 for (cpp = types; *cpp; cpp++)
1172 profile_get_double(profile, "fs_types", *cpp, opt, ret, &ret);
1176 static int get_bool_from_profile(char **types, const char *opt, int def_val)
1181 profile_get_boolean(profile, "defaults", opt, 0, def_val, &ret);
1182 for (cpp = types; *cpp; cpp++)
1183 profile_get_boolean(profile, "fs_types", *cpp, opt, ret, &ret);
1187 extern const char *mke2fs_default_profile;
1188 static const char *default_files[] = { "<default>", 0 };
1190 #ifdef HAVE_BLKID_PROBE_GET_TOPOLOGY
1192 * Sets the geometry of a device (stripe/stride), and returns the
1193 * device's alignment offset, if any, or a negative error.
1195 static int get_device_geometry(const char *file,
1196 struct ext2_super_block *fs_param,
1203 unsigned long min_io;
1204 unsigned long opt_io;
1205 struct stat statbuf;
1207 /* Nothing to do for a regular file */
1208 if (!stat(file, &statbuf) && S_ISREG(statbuf.st_mode))
1211 pr = blkid_new_probe_from_filename(file);
1215 tp = blkid_probe_get_topology(pr);
1219 min_io = blkid_topology_get_minimum_io_size(tp);
1220 opt_io = blkid_topology_get_optimal_io_size(tp);
1221 blocksize = EXT2_BLOCK_SIZE(fs_param);
1222 if ((min_io == 0) && (psector_size > blocksize))
1223 min_io = psector_size;
1224 if ((opt_io == 0) && min_io)
1226 if ((opt_io == 0) && (psector_size > blocksize))
1227 opt_io = psector_size;
1229 /* setting stripe/stride to blocksize is pointless */
1230 if (min_io > blocksize)
1231 fs_param->s_raid_stride = min_io / blocksize;
1232 if (opt_io > blocksize)
1233 fs_param->s_raid_stripe_width = opt_io / blocksize;
1235 rc = blkid_topology_get_alignment_offset(tp);
1237 blkid_free_probe(pr);
1242 static void PRS(int argc, char *argv[])
1245 int cluster_size = 0;
1248 int inode_ratio = 0;
1250 unsigned long flex_bg_size = 0;
1251 double reserved_ratio = -1.0;
1252 int lsector_size = 0, psector_size = 0;
1253 int show_version_only = 0;
1254 unsigned long long num_inodes = 0; /* unsigned long long to catch too-large input */
1256 char * oldpath = getenv("PATH");
1257 char * extended_opts = 0;
1259 char * usage_types = 0;
1261 blk64_t fs_blocks_count = 0;
1266 int s_opt = -1, r_opt = -1;
1267 char *fs_features = 0;
1270 int pathlen = sizeof(PATH_SET) + 1;
1273 pathlen += strlen(oldpath);
1274 newpath = malloc(pathlen);
1276 fprintf(stderr, _("Couldn't allocate memory for new PATH.\n"));
1279 strcpy(newpath, PATH_SET);
1281 /* Update our PATH to include /sbin */
1283 strcat (newpath, ":");
1284 strcat (newpath, oldpath);
1288 tmp = getenv("MKE2FS_SYNC");
1290 sync_kludge = atoi(tmp);
1292 /* Determine the system page size if possible */
1294 #if (!defined(_SC_PAGESIZE) && defined(_SC_PAGE_SIZE))
1295 #define _SC_PAGESIZE _SC_PAGE_SIZE
1298 sysval = sysconf(_SC_PAGESIZE);
1300 sys_page_size = sysval;
1301 #endif /* _SC_PAGESIZE */
1302 #endif /* HAVE_SYSCONF */
1304 if ((tmp = getenv("MKE2FS_CONFIG")) != NULL)
1306 profile_set_syntax_err_cb(syntax_err_report);
1307 retval = profile_init(config_fn, &profile);
1308 if (retval == ENOENT) {
1309 retval = profile_init(default_files, &profile);
1312 retval = profile_set_default(profile, mke2fs_default_profile);
1315 } else if (retval) {
1317 fprintf(stderr, _("Couldn't init profile successfully"
1318 " (error: %ld).\n"), retval);
1322 setbuf(stdout, NULL);
1323 setbuf(stderr, NULL);
1324 add_error_table(&et_ext2_error_table);
1325 add_error_table(&et_prof_error_table);
1326 memset(&fs_param, 0, sizeof(struct ext2_super_block));
1327 fs_param.s_rev_level = 1; /* Create revision 1 filesystems now */
1334 linux_version_code = parse_version_number(ut.release);
1335 if (linux_version_code && linux_version_code < (2*65536 + 2*256))
1336 fs_param.s_rev_level = 0;
1339 if (argc && *argv) {
1340 program_name = get_progname(*argv);
1342 /* If called as mkfs.ext3, create a journal inode */
1343 if (!strcmp(program_name, "mkfs.ext3") ||
1344 !strcmp(program_name, "mke3fs"))
1348 while ((c = getopt (argc, argv,
1349 "b:cg:i:jl:m:no:qr:s:t:vC:DE:FG:I:J:KL:M:N:O:R:ST:U:V")) != EOF) {
1352 blocksize = parse_num_blocks2(optarg, -1);
1353 b = (blocksize > 0) ? blocksize : -blocksize;
1354 if (b < EXT2_MIN_BLOCK_SIZE ||
1355 b > EXT2_MAX_BLOCK_SIZE) {
1356 com_err(program_name, 0,
1357 _("invalid block size - %s"), optarg);
1360 if (blocksize > 4096)
1361 fprintf(stderr, _("Warning: blocksize %d not "
1362 "usable on most systems.\n"),
1365 fs_param.s_log_block_size =
1366 int_log2(blocksize >>
1367 EXT2_MIN_BLOCK_LOG_SIZE);
1369 case 'c': /* Check for bad blocks */
1373 cluster_size = parse_num_blocks2(optarg, -1);
1374 if (cluster_size <= EXT2_MIN_CLUSTER_SIZE ||
1375 cluster_size > EXT2_MAX_CLUSTER_SIZE) {
1376 com_err(program_name, 0,
1377 _("invalid cluster size - %s"),
1386 com_err(program_name, 0,
1387 _("'-R' is deprecated, use '-E' instead"));
1390 extended_opts = optarg;
1396 fs_param.s_blocks_per_group = strtoul(optarg, &tmp, 0);
1398 com_err(program_name, 0,
1399 _("Illegal number for blocks per group"));
1402 if ((fs_param.s_blocks_per_group % 8) != 0) {
1403 com_err(program_name, 0,
1404 _("blocks per group must be multiple of 8"));
1409 flex_bg_size = strtoul(optarg, &tmp, 0);
1411 com_err(program_name, 0,
1412 _("Illegal number for flex_bg size"));
1415 if (flex_bg_size < 1 ||
1416 (flex_bg_size & (flex_bg_size-1)) != 0) {
1417 com_err(program_name, 0,
1418 _("flex_bg size must be a power of 2"));
1423 inode_ratio = strtoul(optarg, &tmp, 0);
1424 if (inode_ratio < EXT2_MIN_BLOCK_SIZE ||
1425 inode_ratio > EXT2_MAX_BLOCK_SIZE * 1024 ||
1427 com_err(program_name, 0,
1428 _("invalid inode ratio %s (min %d/max %d)"),
1429 optarg, EXT2_MIN_BLOCK_SIZE,
1430 EXT2_MAX_BLOCK_SIZE * 1024);
1435 inode_size = strtoul(optarg, &tmp, 0);
1437 com_err(program_name, 0,
1438 _("invalid inode size - %s"), optarg);
1447 parse_journal_opts(optarg);
1450 fprintf(stderr, _("Warning: -K option is deprecated and "
1451 "should not be used anymore. Use "
1452 "\'-E nodiscard\' extended option "
1457 bad_blocks_filename = malloc(strlen(optarg)+1);
1458 if (!bad_blocks_filename) {
1459 com_err(program_name, ENOMEM,
1460 _("in malloc for bad_blocks_filename"));
1463 strcpy(bad_blocks_filename, optarg);
1466 volume_label = optarg;
1469 reserved_ratio = strtod(optarg, &tmp);
1470 if ( *tmp || reserved_ratio > 50 ||
1471 reserved_ratio < 0) {
1472 com_err(program_name, 0,
1473 _("invalid reserved blocks percent - %s"),
1485 num_inodes = strtoul(optarg, &tmp, 0);
1487 com_err(program_name, 0,
1488 _("bad num inodes - %s"), optarg);
1493 creator_os = optarg;
1496 fs_features = optarg;
1502 r_opt = strtoul(optarg, &tmp, 0);
1504 com_err(program_name, 0,
1505 _("bad revision level - %s"), optarg);
1508 fs_param.s_rev_level = r_opt;
1510 case 's': /* deprecated */
1511 s_opt = atoi(optarg);
1518 com_err(program_name, 0,
1519 _("The -t option may only be used once"));
1522 fs_type = strdup(optarg);
1526 com_err(program_name, 0,
1527 _("The -T option may only be used once"));
1530 usage_types = strdup(optarg);
1539 /* Print version number and exit */
1540 show_version_only++;
1546 if ((optind == argc) && !show_version_only)
1548 device_name = argv[optind++];
1550 if (!quiet || show_version_only)
1551 fprintf (stderr, "mke2fs %s (%s)\n", E2FSPROGS_VERSION,
1554 if (show_version_only) {
1555 fprintf(stderr, _("\tUsing %s\n"),
1556 error_message(EXT2_ET_BASE));
1561 * If there's no blocksize specified and there is a journal
1562 * device, use it to figure out the blocksize
1564 if (blocksize <= 0 && journal_device) {
1568 #ifdef CONFIG_TESTIO_DEBUG
1569 if (getenv("TEST_IO_FLAGS") || getenv("TEST_IO_BLOCK")) {
1570 io_ptr = test_io_manager;
1571 test_io_backing_manager = unix_io_manager;
1574 io_ptr = unix_io_manager;
1575 retval = ext2fs_open(journal_device,
1576 EXT2_FLAG_JOURNAL_DEV_OK, 0,
1579 com_err(program_name, retval,
1580 _("while trying to open journal device %s\n"),
1584 if ((blocksize < 0) && (jfs->blocksize < (unsigned) (-blocksize))) {
1585 com_err(program_name, 0,
1586 _("Journal dev blocksize (%d) smaller than "
1587 "minimum blocksize %d\n"), jfs->blocksize,
1591 blocksize = jfs->blocksize;
1592 printf(_("Using journal device's blocksize: %d\n"), blocksize);
1593 fs_param.s_log_block_size =
1594 int_log2(blocksize >> EXT2_MIN_BLOCK_LOG_SIZE);
1598 if (optind < argc) {
1599 fs_blocks_count = parse_num_blocks2(argv[optind++],
1600 fs_param.s_log_block_size);
1601 if (!fs_blocks_count) {
1602 com_err(program_name, 0,
1603 _("invalid blocks '%s' on device '%s'"),
1604 argv[optind - 1], device_name);
1612 check_plausibility(device_name);
1613 check_mount(device_name, force, _("filesystem"));
1615 /* Determine the size of the device (if possible) */
1616 if (noaction && fs_blocks_count) {
1617 dev_size = fs_blocks_count;
1620 retval = ext2fs_get_device_size2(device_name,
1621 EXT2_BLOCK_SIZE(&fs_param),
1624 if (retval && (retval != EXT2_ET_UNIMPLEMENTED)) {
1625 com_err(program_name, retval,
1626 _("while trying to determine filesystem size"));
1629 if (!fs_blocks_count) {
1630 if (retval == EXT2_ET_UNIMPLEMENTED) {
1631 com_err(program_name, 0,
1632 _("Couldn't determine device size; you "
1633 "must specify\nthe size of the "
1637 if (dev_size == 0) {
1638 com_err(program_name, 0,
1639 _("Device size reported to be zero. "
1640 "Invalid partition specified, or\n\t"
1641 "partition table wasn't reread "
1642 "after running fdisk, due to\n\t"
1643 "a modified partition being busy "
1644 "and in use. You may need to reboot\n\t"
1645 "to re-read your partition table.\n"
1649 fs_blocks_count = dev_size;
1650 if (sys_page_size > EXT2_BLOCK_SIZE(&fs_param))
1651 fs_blocks_count &= ~((blk64_t) ((sys_page_size /
1652 EXT2_BLOCK_SIZE(&fs_param))-1));
1654 } else if (!force && (fs_blocks_count > dev_size)) {
1655 com_err(program_name, 0,
1656 _("Filesystem larger than apparent device size."));
1661 profile_get_string(profile, "devices", device_name,
1662 "fs_type", 0, &fs_type);
1664 profile_get_string(profile, "devices", device_name,
1665 "usage_types", 0, &usage_types);
1668 * We have the file system (or device) size, so we can now
1669 * determine the appropriate file system types so the fs can
1670 * be appropriately configured.
1672 fs_types = parse_fs_type(fs_type, usage_types, &fs_param,
1673 fs_blocks_count ? fs_blocks_count : dev_size,
1676 fprintf(stderr, _("Failed to parse fs types list\n"));
1680 /* Figure out what features should be enabled */
1683 if (fs_param.s_rev_level != EXT2_GOOD_OLD_REV) {
1684 tmp = get_string_from_profile(fs_types, "base_features",
1685 "sparse_super,filetype,resize_inode,dir_index");
1686 edit_feature(tmp, &fs_param.s_feature_compat);
1689 /* And which mount options as well */
1690 tmp = get_string_from_profile(fs_types, "default_mntopts",
1692 edit_mntopts(tmp, &fs_param.s_default_mount_opts);
1696 for (cpp = fs_types; *cpp; cpp++) {
1698 profile_get_string(profile, "fs_types", *cpp,
1699 "features", "", &tmp);
1701 edit_feature(tmp, &fs_param.s_feature_compat);
1705 tmp = get_string_from_profile(fs_types, "default_features",
1708 edit_feature(fs_features ? fs_features : tmp,
1709 &fs_param.s_feature_compat);
1714 * We now need to do a sanity check of fs_blocks_count for
1715 * 32-bit vs 64-bit block number support.
1717 if ((fs_blocks_count > MAX_32_NUM) && (blocksize == 0)) {
1718 fs_blocks_count /= 4; /* Try using a 4k blocksize */
1720 fs_param.s_log_block_size = 2;
1722 if ((fs_blocks_count > MAX_32_NUM) &&
1723 !(fs_param.s_feature_incompat & EXT4_FEATURE_INCOMPAT_64BIT) &&
1724 get_bool_from_profile(fs_types, "auto_64-bit_support", 0)) {
1725 fs_param.s_feature_incompat |= EXT4_FEATURE_INCOMPAT_64BIT;
1726 fs_param.s_feature_compat &= ~EXT2_FEATURE_COMPAT_RESIZE_INODE;
1728 if ((fs_blocks_count > MAX_32_NUM) &&
1729 !(fs_param.s_feature_incompat & EXT4_FEATURE_INCOMPAT_64BIT)) {
1730 fprintf(stderr, _("%s: Size of device (0x%llx blocks) %s "
1731 "too big to be expressed\n\t"
1732 "in 32 bits using a blocksize of %d.\n"),
1733 program_name, fs_blocks_count, device_name,
1734 EXT2_BLOCK_SIZE(&fs_param));
1738 ext2fs_blocks_count_set(&fs_param, fs_blocks_count);
1740 if (fs_param.s_feature_incompat & EXT3_FEATURE_INCOMPAT_JOURNAL_DEV) {
1741 fs_types[0] = strdup("journal");
1746 fputs(_("fs_types for mke2fs.conf resolution: "), stdout);
1747 print_str_list(fs_types);
1750 if (r_opt == EXT2_GOOD_OLD_REV &&
1751 (fs_param.s_feature_compat || fs_param.s_feature_incompat ||
1752 fs_param.s_feature_ro_compat)) {
1753 fprintf(stderr, _("Filesystem features not supported "
1754 "with revision 0 filesystems\n"));
1759 if (r_opt == EXT2_GOOD_OLD_REV) {
1760 fprintf(stderr, _("Sparse superblocks not supported "
1761 "with revision 0 filesystems\n"));
1764 fs_param.s_feature_ro_compat |=
1765 EXT2_FEATURE_RO_COMPAT_SPARSE_SUPER;
1766 } else if (s_opt == 0)
1767 fs_param.s_feature_ro_compat &=
1768 ~EXT2_FEATURE_RO_COMPAT_SPARSE_SUPER;
1770 if (journal_size != 0) {
1771 if (r_opt == EXT2_GOOD_OLD_REV) {
1772 fprintf(stderr, _("Journals not supported "
1773 "with revision 0 filesystems\n"));
1776 fs_param.s_feature_compat |=
1777 EXT3_FEATURE_COMPAT_HAS_JOURNAL;
1780 /* Get reserved_ratio from profile if not specified on cmd line. */
1781 if (reserved_ratio < 0.0) {
1782 reserved_ratio = get_double_from_profile(
1783 fs_types, "reserved_ratio", 5.0);
1784 if (reserved_ratio > 50 || reserved_ratio < 0) {
1785 com_err(program_name, 0,
1786 _("invalid reserved blocks percent - %lf"),
1792 if (fs_param.s_feature_incompat &
1793 EXT3_FEATURE_INCOMPAT_JOURNAL_DEV) {
1795 fs_param.s_feature_incompat = EXT3_FEATURE_INCOMPAT_JOURNAL_DEV;
1796 fs_param.s_feature_compat = 0;
1797 fs_param.s_feature_ro_compat = 0;
1800 /* Check the user's mkfs options for 64bit */
1801 if ((fs_param.s_feature_incompat & EXT4_FEATURE_INCOMPAT_64BIT) &&
1802 !(fs_param.s_feature_incompat & EXT3_FEATURE_INCOMPAT_EXTENTS)) {
1803 printf(_("Extents MUST be enabled for a 64-bit filesystem. "
1804 "Pass -O extents to rectify.\n"));
1808 /* Set first meta blockgroup via an environment variable */
1809 /* (this is mostly for debugging purposes) */
1810 if ((fs_param.s_feature_incompat & EXT2_FEATURE_INCOMPAT_META_BG) &&
1811 ((tmp = getenv("MKE2FS_FIRST_META_BG"))))
1812 fs_param.s_first_meta_bg = atoi(tmp);
1814 /* Get the hardware sector sizes, if available */
1815 retval = ext2fs_get_device_sectsize(device_name, &lsector_size);
1817 com_err(program_name, retval,
1818 _("while trying to determine hardware sector size"));
1821 retval = ext2fs_get_device_phys_sectsize(device_name, &psector_size);
1823 com_err(program_name, retval,
1824 _("while trying to determine physical sector size"));
1828 if ((tmp = getenv("MKE2FS_DEVICE_SECTSIZE")) != NULL)
1829 lsector_size = atoi(tmp);
1830 if ((tmp = getenv("MKE2FS_DEVICE_PHYS_SECTSIZE")) != NULL)
1831 psector_size = atoi(tmp);
1833 /* Older kernels may not have physical/logical distinction */
1835 psector_size = lsector_size;
1837 if (blocksize <= 0) {
1838 use_bsize = get_int_from_profile(fs_types, "blocksize", 4096);
1840 if (use_bsize == -1) {
1841 use_bsize = sys_page_size;
1842 if ((linux_version_code < (2*65536 + 6*256)) &&
1846 if (lsector_size && use_bsize < lsector_size)
1847 use_bsize = lsector_size;
1848 if ((blocksize < 0) && (use_bsize < (-blocksize)))
1849 use_bsize = -blocksize;
1850 blocksize = use_bsize;
1851 ext2fs_blocks_count_set(&fs_param,
1852 ext2fs_blocks_count(&fs_param) /
1853 (blocksize / 1024));
1855 if (blocksize < lsector_size) { /* Impossible */
1856 com_err(program_name, EINVAL,
1857 _("while setting blocksize; too small "
1860 } else if ((blocksize < psector_size) &&
1861 (psector_size <= sys_page_size)) { /* Suboptimal */
1862 fprintf(stderr, _("Warning: specified blocksize %d is "
1863 "less than device physical sectorsize %d\n"),
1864 blocksize, psector_size);
1868 fs_param.s_log_block_size =
1869 int_log2(blocksize >> EXT2_MIN_BLOCK_LOG_SIZE);
1870 if (fs_param.s_feature_ro_compat & EXT4_FEATURE_RO_COMPAT_BIGALLOC) {
1872 cluster_size = get_int_from_profile(fs_types,
1875 fs_param.s_log_cluster_size =
1876 int_log2(cluster_size >> EXT2_MIN_CLUSTER_LOG_SIZE);
1877 if (fs_param.s_log_cluster_size &&
1878 fs_param.s_log_cluster_size < fs_param.s_log_block_size) {
1879 com_err(program_name, 0,
1880 _("The cluster size may not be "
1881 "smaller than the block size.\n"));
1884 } else if (cluster_size) {
1885 com_err(program_name, 0,
1886 _("specifying a cluster size requires the "
1887 "bigalloc feature"));
1890 fs_param.s_log_cluster_size = fs_param.s_log_block_size;
1892 if (inode_ratio == 0) {
1893 inode_ratio = get_int_from_profile(fs_types, "inode_ratio",
1895 if (inode_ratio < blocksize)
1896 inode_ratio = blocksize;
1897 if (inode_ratio < EXT2_CLUSTER_SIZE(&fs_param))
1898 inode_ratio = EXT2_CLUSTER_SIZE(&fs_param);
1901 #ifdef HAVE_BLKID_PROBE_GET_TOPOLOGY
1902 retval = get_device_geometry(device_name, &fs_param, psector_size);
1905 _("warning: Unable to get device geometry for %s\n"),
1907 } else if (retval) {
1908 printf(_("%s alignment is offset by %lu bytes.\n"),
1909 device_name, retval);
1910 printf(_("This may result in very poor performance, "
1911 "(re)-partitioning suggested.\n"));
1915 blocksize = EXT2_BLOCK_SIZE(&fs_param);
1918 * Initialize s_desc_size so that the parse_extended_opts()
1919 * can correctly handle "-E resize=NNN" if the 64-bit option
1922 if (fs_param.s_feature_incompat & EXT4_FEATURE_INCOMPAT_64BIT)
1923 fs_param.s_desc_size = EXT2_MIN_DESC_SIZE_64BIT;
1925 /* This check should happen beyond the last assignment to blocksize */
1926 if (blocksize > sys_page_size) {
1928 com_err(program_name, 0,
1929 _("%d-byte blocks too big for system (max %d)"),
1930 blocksize, sys_page_size);
1933 fprintf(stderr, _("Warning: %d-byte blocks too big for system "
1934 "(max %d), forced to continue\n"),
1935 blocksize, sys_page_size);
1938 lazy_itable_init = 0;
1939 if (access("/sys/fs/ext4/features/lazy_itable_init", R_OK) == 0)
1940 lazy_itable_init = 1;
1942 lazy_itable_init = get_bool_from_profile(fs_types,
1945 discard = get_bool_from_profile(fs_types, "discard" , discard);
1946 journal_flags |= get_bool_from_profile(fs_types,
1947 "lazy_journal_init", 0) ?
1948 EXT2_MKJOURNAL_LAZYINIT : 0;
1949 journal_flags |= EXT2_MKJOURNAL_NO_MNT_CHECK;
1951 /* Get options from profile */
1952 for (cpp = fs_types; *cpp; cpp++) {
1954 profile_get_string(profile, "fs_types", *cpp, "options", "", &tmp);
1956 parse_extended_opts(&fs_param, tmp);
1961 parse_extended_opts(&fs_param, extended_opts);
1963 /* Can't support bigalloc feature without extents feature */
1964 if ((fs_param.s_feature_ro_compat & EXT4_FEATURE_RO_COMPAT_BIGALLOC) &&
1965 !(fs_param.s_feature_incompat & EXT3_FEATURE_INCOMPAT_EXTENTS)) {
1966 com_err(program_name, 0,
1967 _("Can't support bigalloc feature without "
1968 "extents feature"));
1972 if ((fs_param.s_feature_incompat & EXT2_FEATURE_INCOMPAT_META_BG) &&
1973 (fs_param.s_feature_compat & EXT2_FEATURE_COMPAT_RESIZE_INODE)) {
1974 fprintf(stderr, _("The resize_inode and meta_bg features "
1975 "are not compatible.\n"
1976 "They can not be both enabled "
1977 "simultaneously.\n"));
1982 (fs_param.s_feature_ro_compat & EXT4_FEATURE_RO_COMPAT_BIGALLOC))
1983 fprintf(stderr, _("\nWarning: the bigalloc feature is still "
1984 "under development\n"
1985 "See https://ext4.wiki.kernel.org/"
1986 "index.php/Bigalloc for more information\n\n"));
1989 (fs_param.s_feature_ro_compat & EXT4_FEATURE_RO_COMPAT_QUOTA))
1990 fprintf(stderr, _("\nWarning: the quota feature is still "
1991 "under development\n"
1992 "See https://ext4.wiki.kernel.org/"
1993 "index.php/Quota for more information\n\n"));
1995 /* Since sparse_super is the default, we would only have a problem
1996 * here if it was explicitly disabled.
1998 if ((fs_param.s_feature_compat & EXT2_FEATURE_COMPAT_RESIZE_INODE) &&
1999 !(fs_param.s_feature_ro_compat&EXT2_FEATURE_RO_COMPAT_SPARSE_SUPER)) {
2000 com_err(program_name, 0,
2001 _("reserved online resize blocks not supported "
2002 "on non-sparse filesystem"));
2006 if (fs_param.s_blocks_per_group) {
2007 if (fs_param.s_blocks_per_group < 256 ||
2008 fs_param.s_blocks_per_group > 8 * (unsigned) blocksize) {
2009 com_err(program_name, 0,
2010 _("blocks per group count out of range"));
2016 * If the bigalloc feature is enabled, then the -g option will
2017 * specify the number of clusters per group.
2019 if (fs_param.s_feature_ro_compat & EXT4_FEATURE_RO_COMPAT_BIGALLOC) {
2020 fs_param.s_clusters_per_group = fs_param.s_blocks_per_group;
2021 fs_param.s_blocks_per_group = 0;
2024 if (inode_size == 0)
2025 inode_size = get_int_from_profile(fs_types, "inode_size", 0);
2026 if (!flex_bg_size && (fs_param.s_feature_incompat &
2027 EXT4_FEATURE_INCOMPAT_FLEX_BG))
2028 flex_bg_size = get_int_from_profile(fs_types,
2029 "flex_bg_size", 16);
2031 if (!(fs_param.s_feature_incompat &
2032 EXT4_FEATURE_INCOMPAT_FLEX_BG)) {
2033 com_err(program_name, 0,
2034 _("Flex_bg feature not enabled, so "
2035 "flex_bg size may not be specified"));
2038 fs_param.s_log_groups_per_flex = int_log2(flex_bg_size);
2041 if (inode_size && fs_param.s_rev_level >= EXT2_DYNAMIC_REV) {
2042 if (inode_size < EXT2_GOOD_OLD_INODE_SIZE ||
2043 inode_size > EXT2_BLOCK_SIZE(&fs_param) ||
2044 inode_size & (inode_size - 1)) {
2045 com_err(program_name, 0,
2046 _("invalid inode size %d (min %d/max %d)"),
2047 inode_size, EXT2_GOOD_OLD_INODE_SIZE,
2051 fs_param.s_inode_size = inode_size;
2054 /* Make sure number of inodes specified will fit in 32 bits */
2055 if (num_inodes == 0) {
2056 unsigned long long n;
2057 n = ext2fs_blocks_count(&fs_param) * blocksize / inode_ratio;
2058 if (n > MAX_32_NUM) {
2059 if (fs_param.s_feature_incompat &
2060 EXT4_FEATURE_INCOMPAT_64BIT)
2061 num_inodes = MAX_32_NUM;
2063 com_err(program_name, 0,
2064 _("too many inodes (%llu), raise "
2065 "inode ratio?"), n);
2069 } else if (num_inodes > MAX_32_NUM) {
2070 com_err(program_name, 0,
2071 _("too many inodes (%llu), specify < 2^32 inodes"),
2076 * Calculate number of inodes based on the inode ratio
2078 fs_param.s_inodes_count = num_inodes ? num_inodes :
2079 (ext2fs_blocks_count(&fs_param) * blocksize) / inode_ratio;
2081 if ((((unsigned long long)fs_param.s_inodes_count) *
2082 (inode_size ? inode_size : EXT2_GOOD_OLD_INODE_SIZE)) >=
2083 ((ext2fs_blocks_count(&fs_param)) *
2084 EXT2_BLOCK_SIZE(&fs_param))) {
2085 com_err(program_name, 0, _("inode_size (%u) * inodes_count "
2086 "(%u) too big for a\n\t"
2087 "filesystem with %llu blocks, "
2088 "specify higher inode_ratio (-i)\n\t"
2089 "or lower inode count (-N).\n"),
2090 inode_size ? inode_size : EXT2_GOOD_OLD_INODE_SIZE,
2091 fs_param.s_inodes_count,
2092 (unsigned long long) ext2fs_blocks_count(&fs_param));
2097 * Calculate number of blocks to reserve
2099 ext2fs_r_blocks_count_set(&fs_param, reserved_ratio *
2100 ext2fs_blocks_count(&fs_param) / 100.0);
2106 static int should_do_undo(const char *name)
2111 struct ext2_super_block super;
2112 io_manager manager = unix_io_manager;
2113 int csum_flag, force_undo;
2115 csum_flag = EXT2_HAS_RO_COMPAT_FEATURE(&fs_param,
2116 EXT4_FEATURE_RO_COMPAT_GDT_CSUM);
2117 force_undo = get_int_from_profile(fs_types, "force_undo", 0);
2118 if (!force_undo && (!csum_flag || !lazy_itable_init))
2121 retval = manager->open(name, IO_FLAG_EXCLUSIVE, &channel);
2124 * We don't handle error cases instead we
2125 * declare that the file system doesn't exist
2126 * and let the rest of mke2fs take care of
2133 io_channel_set_blksize(channel, SUPERBLOCK_OFFSET);
2134 retval = io_channel_read_blk64(channel, 1, -SUPERBLOCK_SIZE, &super);
2140 #if defined(WORDS_BIGENDIAN)
2141 s_magic = ext2fs_swab16(super.s_magic);
2143 s_magic = super.s_magic;
2146 if (s_magic == EXT2_SUPER_MAGIC)
2150 io_channel_close(channel);
2157 static int mke2fs_setup_tdb(const char *name, io_manager *io_ptr)
2159 errcode_t retval = ENOMEM;
2160 char *tdb_dir = NULL, *tdb_file = NULL;
2161 char *dev_name, *tmp_name;
2162 int free_tdb_dir = 0;
2165 * Configuration via a conf file would be
2168 tdb_dir = getenv("E2FSPROGS_UNDO_DIR");
2170 profile_get_string(profile, "defaults",
2171 "undo_dir", 0, "/var/lib/e2fsprogs",
2176 if (!strcmp(tdb_dir, "none") || (tdb_dir[0] == 0) ||
2177 access(tdb_dir, W_OK))
2180 tmp_name = strdup(name);
2183 dev_name = basename(tmp_name);
2184 tdb_file = malloc(strlen(tdb_dir) + 8 + strlen(dev_name) + 7 + 1);
2189 sprintf(tdb_file, "%s/mke2fs-%s.e2undo", tdb_dir, dev_name);
2192 if (!access(tdb_file, F_OK)) {
2193 if (unlink(tdb_file) < 0) {
2199 set_undo_io_backing_manager(*io_ptr);
2200 *io_ptr = undo_io_manager;
2201 retval = set_undo_io_backup_file(tdb_file);
2204 printf(_("Overwriting existing filesystem; this can be undone "
2205 "using the command:\n"
2206 " e2undo %s %s\n\n"), tdb_file, name);
2217 com_err(program_name, retval,
2218 _("while trying to setup undo file\n"));
2222 static int mke2fs_discard_device(ext2_filsys fs)
2224 struct ext2fs_numeric_progress_struct progress;
2225 blk64_t blocks = ext2fs_blocks_count(fs->super);
2226 blk64_t count = DISCARD_STEP_MB;
2231 * Let's try if discard really works on the device, so
2232 * we do not print numeric progress resulting in failure
2235 retval = io_channel_discard(fs->io, 0, fs->blocksize);
2238 cur = fs->blocksize;
2240 count *= (1024 * 1024);
2241 count /= fs->blocksize;
2243 ext2fs_numeric_progress_init(fs, &progress,
2244 _("Discarding device blocks: "),
2246 while (cur < blocks) {
2247 ext2fs_numeric_progress_update(fs, &progress, cur);
2249 if (cur + count > blocks)
2250 count = blocks - cur;
2252 retval = io_channel_discard(fs->io, cur, count);
2259 ext2fs_numeric_progress_close(fs, &progress,
2262 printf("%s\n",error_message(retval));
2264 ext2fs_numeric_progress_close(fs, &progress,
2270 static void fix_cluster_bg_counts(ext2_filsys fs)
2272 blk64_t cluster, num_clusters, tot_free;
2274 int grp_free, num_free, group;
2276 num_clusters = EXT2FS_B2C(fs, ext2fs_blocks_count(fs->super));
2277 tot_free = num_free = group = grp_free = 0;
2278 for (cluster = EXT2FS_B2C(fs, fs->super->s_first_data_block);
2279 cluster < num_clusters; cluster++) {
2280 if (!ext2fs_test_block_bitmap2(fs->block_map,
2281 EXT2FS_C2B(fs, cluster))) {
2286 if ((num == fs->super->s_clusters_per_group) ||
2287 (cluster == num_clusters-1)) {
2288 ext2fs_bg_free_blocks_count_set(fs, group, grp_free);
2289 ext2fs_group_desc_csum_set(fs, group);
2295 ext2fs_free_blocks_count_set(fs->super, EXT2FS_C2B(fs, tot_free));
2298 static int create_quota_inodes(ext2_filsys fs)
2302 quota_init_context(&qctx, fs, -1);
2303 quota_compute_usage(qctx);
2304 quota_write_inode(qctx, quotatype);
2305 quota_release_context(&qctx);
2310 int main (int argc, char *argv[])
2312 errcode_t retval = 0;
2314 badblocks_list bb_list = 0;
2315 unsigned int journal_blocks;
2316 unsigned int i, checkinterval;
2322 char tdb_string[40];
2324 int itable_zeroed = 0;
2327 setlocale(LC_MESSAGES, "");
2328 setlocale(LC_CTYPE, "");
2329 bindtextdomain(NLS_CAT_NAME, LOCALEDIR);
2330 textdomain(NLS_CAT_NAME);
2331 set_com_err_gettext(gettext);
2335 #ifdef CONFIG_TESTIO_DEBUG
2336 if (getenv("TEST_IO_FLAGS") || getenv("TEST_IO_BLOCK")) {
2337 io_ptr = test_io_manager;
2338 test_io_backing_manager = unix_io_manager;
2341 io_ptr = unix_io_manager;
2343 if (should_do_undo(device_name)) {
2344 retval = mke2fs_setup_tdb(device_name, &io_ptr);
2350 * Initialize the superblock....
2352 flags = EXT2_FLAG_EXCLUSIVE;
2354 flags |= EXT2_FLAG_DIRECT_IO;
2355 profile_get_boolean(profile, "options", "old_bitmaps", 0, 0,
2358 flags |= EXT2_FLAG_64BITS;
2360 * By default, we print how many inode tables or block groups
2361 * or whatever we've written so far. The quiet flag disables
2362 * this, along with a lot of other output.
2365 flags |= EXT2_FLAG_PRINT_PROGRESS;
2366 retval = ext2fs_initialize(device_name, flags, &fs_param, io_ptr, &fs);
2368 com_err(device_name, retval, _("while setting up superblock"));
2372 /* Calculate journal blocks */
2373 if (!journal_device && ((journal_size) ||
2374 (fs_param.s_feature_compat &
2375 EXT3_FEATURE_COMPAT_HAS_JOURNAL)))
2376 journal_blocks = figure_journal_size(journal_size, fs);
2378 /* Can't undo discard ... */
2379 if (!noaction && discard && (io_ptr != undo_io_manager)) {
2380 retval = mke2fs_discard_device(fs);
2381 if (!retval && io_channel_discard_zeroes_data(fs->io)) {
2383 printf(_("Discard succeeded and will return 0s "
2384 " - skipping inode table wipe\n"));
2385 lazy_itable_init = 1;
2390 sprintf(tdb_string, "tdb_data_size=%d", fs->blocksize <= 4096 ?
2391 32768 : fs->blocksize * 8);
2392 io_channel_set_options(fs->io, tdb_string);
2394 if (fs_param.s_flags & EXT2_FLAGS_TEST_FILESYS)
2395 fs->super->s_flags |= EXT2_FLAGS_TEST_FILESYS;
2397 if ((fs_param.s_feature_incompat &
2398 (EXT3_FEATURE_INCOMPAT_EXTENTS|EXT4_FEATURE_INCOMPAT_FLEX_BG)) ||
2399 (fs_param.s_feature_ro_compat &
2400 (EXT4_FEATURE_RO_COMPAT_HUGE_FILE|EXT4_FEATURE_RO_COMPAT_GDT_CSUM|
2401 EXT4_FEATURE_RO_COMPAT_DIR_NLINK|
2402 EXT4_FEATURE_RO_COMPAT_EXTRA_ISIZE)))
2403 fs->super->s_kbytes_written = 1;
2406 * Wipe out the old on-disk superblock
2409 zap_sector(fs, 2, 6);
2412 * Parse or generate a UUID for the filesystem
2415 if (uuid_parse(fs_uuid, fs->super->s_uuid) !=0) {
2416 com_err(device_name, 0, "could not parse UUID: %s\n",
2421 uuid_generate(fs->super->s_uuid);
2424 * Initialize the directory index variables
2426 hash_alg_str = get_string_from_profile(fs_types, "hash_alg",
2428 hash_alg = e2p_string2hash(hash_alg_str);
2430 fs->super->s_def_hash_version = (hash_alg >= 0) ? hash_alg :
2432 uuid_generate((unsigned char *) fs->super->s_hash_seed);
2435 * Periodic checks can be enabled/disabled via config file.
2436 * Note we override the kernel include file's idea of what the default
2437 * check interval (never) should be. It's a good idea to check at
2438 * least *occasionally*, specially since servers will never rarely get
2439 * to reboot, since Linux is so robust these days. :-)
2441 * 180 days (six months) seems like a good value.
2443 #ifdef EXT2_DFL_CHECKINTERVAL
2444 #undef EXT2_DFL_CHECKINTERVAL
2446 #define EXT2_DFL_CHECKINTERVAL (86400L * 180L)
2448 if (get_bool_from_profile(fs_types, "enable_periodic_fsck", 0)) {
2449 fs->super->s_checkinterval = EXT2_DFL_CHECKINTERVAL;
2450 fs->super->s_max_mnt_count = EXT2_DFL_MAX_MNT_COUNT;
2452 * Add "jitter" to the superblock's check interval so that we
2453 * don't check all the filesystems at the same time. We use a
2454 * kludgy hack of using the UUID to derive a random jitter value
2456 for (i = 0, val = 0 ; i < sizeof(fs->super->s_uuid); i++)
2457 val += fs->super->s_uuid[i];
2458 fs->super->s_max_mnt_count += val % EXT2_DFL_MAX_MNT_COUNT;
2460 fs->super->s_max_mnt_count = -1;
2463 * Override the creator OS, if applicable
2465 if (creator_os && !set_os(fs->super, creator_os)) {
2466 com_err (program_name, 0, _("unknown os - %s"), creator_os);
2471 * For the Hurd, we will turn off filetype since it doesn't
2474 if (fs->super->s_creator_os == EXT2_OS_HURD)
2475 fs->super->s_feature_incompat &=
2476 ~EXT2_FEATURE_INCOMPAT_FILETYPE;
2479 * Set the volume label...
2482 memset(fs->super->s_volume_name, 0,
2483 sizeof(fs->super->s_volume_name));
2484 strncpy(fs->super->s_volume_name, volume_label,
2485 sizeof(fs->super->s_volume_name));
2489 * Set the last mount directory
2492 memset(fs->super->s_last_mounted, 0,
2493 sizeof(fs->super->s_last_mounted));
2494 strncpy(fs->super->s_last_mounted, mount_dir,
2495 sizeof(fs->super->s_last_mounted));
2498 if (!quiet || noaction)
2504 if (fs->super->s_feature_incompat &
2505 EXT3_FEATURE_INCOMPAT_JOURNAL_DEV) {
2506 create_journal_dev(fs);
2507 exit(ext2fs_close(fs) ? 1 : 0);
2510 if (bad_blocks_filename)
2511 read_bb_file(fs, &bb_list, bad_blocks_filename);
2513 test_disk(fs, &bb_list);
2515 handle_bad_blocks(fs, bb_list);
2516 fs->stride = fs_stride = fs->super->s_raid_stride;
2518 printf(_("Allocating group tables: "));
2519 retval = ext2fs_allocate_tables(fs);
2521 com_err(program_name, retval,
2522 _("while trying to allocate filesystem tables"));
2526 printf(_("done \n"));
2528 retval = ext2fs_convert_subcluster_bitmap(fs, &fs->block_map);
2530 com_err(program_name, retval,
2531 _("\n\twhile converting subcluster bitmap"));
2536 fs->super->s_state |= EXT2_ERROR_FS;
2537 fs->flags &= ~(EXT2_FLAG_IB_DIRTY|EXT2_FLAG_BB_DIRTY);
2539 * The command "mke2fs -S" is used to recover
2540 * corrupted file systems, so do not mark any of the
2541 * inodes as unused; we want e2fsck to consider all
2542 * inodes as potentially containing recoverable data.
2544 if (fs->super->s_feature_ro_compat &
2545 EXT4_FEATURE_RO_COMPAT_GDT_CSUM) {
2546 for (i = 0; i < fs->group_desc_count; i++)
2547 ext2fs_bg_itable_unused_set(fs, i, 0);
2550 /* rsv must be a power of two (64kB is MD RAID sb alignment) */
2551 blk64_t rsv = 65536 / fs->blocksize;
2552 blk64_t blocks = ext2fs_blocks_count(fs->super);
2556 #ifdef ZAP_BOOTBLOCK
2557 zap_sector(fs, 0, 2);
2561 * Wipe out any old MD RAID (or other) metadata at the end
2562 * of the device. This will also verify that the device is
2563 * as large as we think. Be careful with very small devices.
2565 start = (blocks & ~(rsv - 1));
2569 retval = ext2fs_zero_blocks2(fs, start, blocks - start,
2573 com_err(program_name, retval,
2574 _("while zeroing block %llu at end of filesystem"),
2577 write_inode_tables(fs, lazy_itable_init, itable_zeroed);
2578 create_root_dir(fs);
2579 create_lost_and_found(fs);
2581 create_bad_block_inode(fs, bb_list);
2582 if (fs->super->s_feature_compat &
2583 EXT2_FEATURE_COMPAT_RESIZE_INODE) {
2584 retval = ext2fs_create_resize_inode(fs);
2586 com_err("ext2fs_create_resize_inode", retval,
2587 _("while reserving blocks for online resize"));
2593 if (journal_device) {
2597 check_plausibility(journal_device);
2598 check_mount(journal_device, force, _("journal"));
2600 retval = ext2fs_open(journal_device, EXT2_FLAG_RW|
2601 EXT2_FLAG_JOURNAL_DEV_OK, 0,
2602 fs->blocksize, unix_io_manager, &jfs);
2604 com_err(program_name, retval,
2605 _("while trying to open journal device %s\n"),
2610 printf(_("Adding journal to device %s: "),
2614 retval = ext2fs_add_journal_device(fs, jfs);
2616 com_err (program_name, retval,
2617 _("\n\twhile trying to add journal to device %s"),
2622 printf(_("done\n"));
2624 free(journal_device);
2625 } else if ((journal_size) ||
2626 (fs_param.s_feature_compat &
2627 EXT3_FEATURE_COMPAT_HAS_JOURNAL)) {
2629 printf(_("Skipping journal creation in super-only mode\n"));
2630 fs->super->s_journal_inum = EXT2_JOURNAL_INO;
2634 if (!journal_blocks) {
2635 fs->super->s_feature_compat &=
2636 ~EXT3_FEATURE_COMPAT_HAS_JOURNAL;
2640 printf(_("Creating journal (%u blocks): "),
2644 retval = ext2fs_add_journal_inode(fs, journal_blocks,
2647 com_err (program_name, retval,
2648 _("\n\twhile trying to create journal"));
2652 printf(_("done\n"));
2656 fs->super->s_feature_incompat & EXT4_FEATURE_INCOMPAT_MMP) {
2657 retval = ext2fs_mmp_init(fs);
2659 fprintf(stderr, _("\nError while enabling multiple "
2660 "mount protection feature."));
2664 printf(_("Multiple mount protection is enabled "
2665 "with update interval %d seconds.\n"),
2666 fs->super->s_mmp_update_interval);
2669 if (EXT2_HAS_RO_COMPAT_FEATURE(&fs_param,
2670 EXT4_FEATURE_RO_COMPAT_BIGALLOC))
2671 fix_cluster_bg_counts(fs);
2672 if (EXT2_HAS_RO_COMPAT_FEATURE(&fs_param,
2673 EXT4_FEATURE_RO_COMPAT_QUOTA))
2674 create_quota_inodes(fs);
2677 printf(_("Writing superblocks and "
2678 "filesystem accounting information: "));
2679 checkinterval = fs->super->s_checkinterval;
2680 max_mnt_count = fs->super->s_max_mnt_count;
2681 retval = ext2fs_close(fs);
2684 _("\nWarning, had trouble writing out superblocks."));
2685 } else if (!quiet) {
2686 printf(_("done\n\n"));
2687 if (!getenv("MKE2FS_SKIP_CHECK_MSG"))
2688 print_check_message(max_mnt_count, checkinterval);
2691 remove_error_table(&et_ext2_error_table);
2692 remove_error_table(&et_prof_error_table);
2693 profile_release(profile);
2694 for (i=0; fs_types[i]; i++)