Whamcloud - gitweb
Add manpage references to debugfs/tune2fs commands
[tools/e2fsprogs.git] / misc / mke2fs.c
index 0292a64..e16c5f0 100644 (file)
@@ -100,7 +100,7 @@ static void usage(void)
        "\t[-N number-of-inodes] [-m reserved-blocks-percentage] "
        "[-o creator-os]\n\t[-g blocks-per-group] [-L volume-label] "
        "[-M last-mounted-directory]\n\t[-O feature[,...]] "
-       "[-r fs-revision] [-R options] [-qvSV]\n\tdevice [blocks-count]\n"),
+       "[-r fs-revision] [-E extended-option[,...]] [-qvSV]\n\tdevice [blocks-count]\n"),
                program_name);
        exit(1);
 }
@@ -495,11 +495,11 @@ static void create_root_dir(ext2_filsys fs)
                }
                uid = getuid();
                inode.i_uid = uid;
-               inode.i_uid_high = uid >> 16;
+               ext2fs_set_i_uid_high(inode, uid >> 16);
                if (uid) {
                        gid = getgid();
                        inode.i_gid = gid;
-                       inode.i_gid_high = gid >> 16;
+                       ext2fs_set_i_gid_high(inode, gid >> 16);
                }
                retval = ext2fs_write_new_inode(fs, EXT2_ROOT_INO, &inode);
                if (retval) {
@@ -756,7 +756,7 @@ static int set_os(struct ext2_super_block *sb, char *os)
 static void parse_extended_opts(struct ext2_super_block *param, 
                                const char *opts)
 {
-       char    *buf, *token, *next, *p, *arg;
+       char    *buf, *token, *next, *p, *arg, *badopt = "";
        int     len;
        int     r_usage = 0;
 
@@ -783,16 +783,32 @@ static void parse_extended_opts(struct ext2_super_block *param,
                if (strcmp(token, "stride") == 0) {
                        if (!arg) {
                                r_usage++;
+                               badopt = token;
                                continue;
                        }
-                       fs_stride = strtoul(arg, &p, 0);
-                       if (*p || (fs_stride == 0)) {
+                       param->s_raid_stride = strtoul(arg, &p, 0);
+                       if (*p || (param->s_raid_stride == 0)) {
                                fprintf(stderr,
                                        _("Invalid stride parameter: %s\n"),
                                        arg);
                                r_usage++;
                                continue;
                        }
+               } else if (strcmp(token, "stripe-width") == 0 ||
+                          strcmp(token, "stripe_width") == 0) {
+                       if (!arg) {
+                               r_usage++;
+                               badopt = token;
+                               continue;
+                       }
+                       param->s_raid_stripe_width = strtoul(arg, &p, 0);
+                       if (*p || (param->s_raid_stripe_width == 0)) {
+                               fprintf(stderr,
+                                       _("Invalid stripe-width parameter: %s\n"),
+                                       arg);
+                               r_usage++;
+                               continue;
+                       }
                } else if (!strcmp(token, "resize")) {
                        unsigned long resize, bpg, rsv_groups;
                        unsigned long group_desc_count, desc_blocks;
@@ -801,6 +817,7 @@ static void parse_extended_opts(struct ext2_super_block *param,
 
                        if (!arg) {
                                r_usage++;
+                               badopt = token;
                                continue;
                        }
 
@@ -849,32 +866,50 @@ static void parse_extended_opts(struct ext2_super_block *param,
 
                                param->s_reserved_gdt_blocks = rsv_gdb;
                        }
-               } else
+               } else if (!strcmp(token, "test_fs")) {
+                       param->s_flags |= EXT2_FLAGS_TEST_FILESYS;
+               } else {
                        r_usage++;
+                       badopt = token;
+               }
        }
        if (r_usage) {
-               fprintf(stderr, _("\nBad options specified.\n\n"
+               fprintf(stderr, _("\nBad option(s) specified: %s\n\n"
                        "Extended options are separated by commas, "
                        "and may take an argument which\n"
                        "\tis set off by an equals ('=') sign.\n\n"
                        "Valid extended options are:\n"
-                       "\tstride=<stride length in blocks>\n"
-                       "\tresize=<resize maximum size in blocks>\n\n"));
+                       "\tstride=<RAID per-disk data chunk in blocks>\n"
+                       "\tstripe-width=<RAID stride * data disks in blocks>\n"
+                       "\tresize=<resize maximum size in blocks>\n\n"
+                       "\ttest_fs\n"),
+                       badopt);
                free(buf);
                exit(1);
        }
+       if (param->s_raid_stride &&
+           (param->s_raid_stripe_width % param->s_raid_stride) != 0)
+               fprintf(stderr, _("\nWarning: RAID stripe-width %u not an even "
+                                 "multiple of stride %u.\n\n"),
+                       param->s_raid_stripe_width, param->s_raid_stride);
+
        free(buf);
 }      
 
 static __u32 ok_features[3] = {
+       /* Compat */
        EXT3_FEATURE_COMPAT_HAS_JOURNAL |
                EXT2_FEATURE_COMPAT_RESIZE_INODE |
                EXT2_FEATURE_COMPAT_DIR_INDEX |
-               EXT2_FEATURE_COMPAT_LAZY_BG,    /* Compat */
-       EXT2_FEATURE_INCOMPAT_FILETYPE|         /* Incompat */
+               EXT2_FEATURE_COMPAT_LAZY_BG |
+               EXT2_FEATURE_COMPAT_EXT_ATTR,
+       /* Incompat */
+       EXT2_FEATURE_INCOMPAT_FILETYPE|
                EXT3_FEATURE_INCOMPAT_JOURNAL_DEV|
                EXT2_FEATURE_INCOMPAT_META_BG,
-       EXT2_FEATURE_RO_COMPAT_SPARSE_SUPER     /* R/O compat */
+       /* R/O compat */
+       EXT2_FEATURE_RO_COMPAT_LARGE_FILE|
+               EXT2_FEATURE_RO_COMPAT_SPARSE_SUPER
 };
 
 
@@ -900,6 +935,9 @@ static void edit_feature(const char *str, __u32 *compat_array)
        }
 }
 
+extern const char *mke2fs_default_profile;
+static const char *default_files[] = { "<default>", 0 };
+
 static void PRS(int argc, char *argv[])
 {
        int             b, c;
@@ -958,7 +996,11 @@ static void PRS(int argc, char *argv[])
        if ((tmp = getenv("MKE2FS_CONFIG")) != NULL)
                config_fn[0] = tmp;
        profile_set_syntax_err_cb(syntax_err_report);
-       profile_init(config_fn, &profile);
+       retval = profile_init(config_fn, &profile);
+       if (retval == ENOENT) {
+               profile_init(default_files, &profile);
+               profile_set_default(profile, mke2fs_default_profile);
+       }
        
        setbuf(stdout, NULL);
        setbuf(stderr, NULL);
@@ -1549,6 +1591,9 @@ int main (int argc, char *argv[])
                exit(1);
        }
 
+       if (fs_param.s_flags & EXT2_FLAGS_TEST_FILESYS)
+               fs->super->s_flags |= EXT2_FLAGS_TEST_FILESYS;
+
        /*
         * Wipe out the old on-disk superblock
         */
@@ -1629,7 +1674,7 @@ int main (int argc, char *argv[])
                test_disk(fs, &bb_list);
 
        handle_bad_blocks(fs, bb_list);
-       fs->stride = fs->super->s_raid_stride = fs_stride;
+       fs->stride = fs_stride = fs->super->s_raid_stride;
        retval = ext2fs_allocate_tables(fs);
        if (retval) {
                com_err(program_name, retval,