Whamcloud - gitweb
Merge branch 'maint' into next
[tools/e2fsprogs.git] / misc / mke2fs.c
index c1cbcaa..4075099 100644 (file)
@@ -199,7 +199,7 @@ static void read_bb_file(ext2_filsys fs, badblocks_list *bb_list,
        retval = ext2fs_read_bb_FILE(fs, f, bb_list, invalid_block);
        fclose (f);
        if (retval) {
-               com_err("ext2fs_read_bb_FILE", retval,
+               com_err("ext2fs_read_bb_FILE", retval, "%s",
                        _("while reading in list of bad blocks from file"));
                exit(1);
        }
@@ -228,7 +228,7 @@ static void test_disk(ext2_filsys fs, badblocks_list *bb_list)
        retval = ext2fs_read_bb_FILE(fs, f, bb_list, invalid_block);
        pclose(f);
        if (retval) {
-               com_err("ext2fs_read_bb_FILE", retval,
+               com_err("ext2fs_read_bb_FILE", retval, "%s",
                        _("while processing list of bad blocks from program"));
                exit(1);
        }
@@ -299,7 +299,7 @@ _("Warning: the backup superblock/group descriptors at block %u contain\n"
         */
        retval = ext2fs_badblocks_list_iterate_begin(bb_list, &bb_iter);
        if (retval) {
-               com_err("ext2fs_badblocks_list_iterate_begin", retval,
+               com_err("ext2fs_badblocks_list_iterate_begin", retval, "%s",
                        _("while marking bad blocks as used"));
                exit(1);
        }
@@ -386,17 +386,17 @@ static void create_root_dir(ext2_filsys fs)
 {
        errcode_t               retval;
        struct ext2_inode       inode;
-       __u32                   uid, gid;
 
        retval = ext2fs_mkdir(fs, EXT2_ROOT_INO, EXT2_ROOT_INO, 0);
        if (retval) {
-               com_err("ext2fs_mkdir", retval, _("while creating root dir"));
+               com_err("ext2fs_mkdir", retval, "%s",
+                       _("while creating root dir"));
                exit(1);
        }
        if (root_uid != 0 || root_gid != 0) {
                retval = ext2fs_read_inode(fs, EXT2_ROOT_INO, &inode);
                if (retval) {
-                       com_err("ext2fs_read_inode", retval,
+                       com_err("ext2fs_read_inode", retval, "%s",
                                _("while reading root inode"));
                        exit(1);
                }
@@ -408,7 +408,7 @@ static void create_root_dir(ext2_filsys fs)
 
                retval = ext2fs_write_new_inode(fs, EXT2_ROOT_INO, &inode);
                if (retval) {
-                       com_err("ext2fs_write_inode", retval,
+                       com_err("ext2fs_write_inode", retval, "%s",
                                _("while setting root inode ownership"));
                        exit(1);
                }
@@ -426,14 +426,14 @@ static void create_lost_and_found(ext2_filsys fs)
        fs->umask = 077;
        retval = ext2fs_mkdir(fs, EXT2_ROOT_INO, 0, name);
        if (retval) {
-               com_err("ext2fs_mkdir", retval,
+               com_err("ext2fs_mkdir", retval, "%s",
                        _("while creating /lost+found"));
                exit(1);
        }
 
        retval = ext2fs_lookup(fs, EXT2_ROOT_INO, name, strlen(name), 0, &ino);
        if (retval) {
-               com_err("ext2_lookup", retval,
+               com_err("ext2_lookup", retval, "%s",
                        _("while looking up /lost+found"));
                exit(1);
        }
@@ -446,7 +446,7 @@ static void create_lost_and_found(ext2_filsys fs)
                        break;
                retval = ext2fs_expand_dir(fs, ino);
                if (retval) {
-                       com_err("ext2fs_expand_dir", retval,
+                       com_err("ext2fs_expand_dir", retval, "%s",
                                _("while expanding /lost+found"));
                        exit(1);
                }
@@ -461,7 +461,7 @@ static void create_bad_block_inode(ext2_filsys fs, badblocks_list bb_list)
        ext2fs_inode_alloc_stats2(fs, EXT2_BAD_INO, +1, 0);
        retval = ext2fs_update_bb_inode(fs, bb_list);
        if (retval) {
-               com_err("ext2fs_update_bb_inode", retval,
+               com_err("ext2fs_update_bb_inode", retval, "%s",
                        _("while setting bad block inode"));
                exit(1);
        }
@@ -530,7 +530,7 @@ static void create_journal_dev(ext2_filsys fs)
        retval = ext2fs_create_journal_superblock(fs,
                                  ext2fs_blocks_count(fs->super), 0, &buf);
        if (retval) {
-               com_err("create_journal_dev", retval,
+               com_err("create_journal_dev", retval, "%s",
                        _("while initializing journal superblock"));
                exit(1);
        }
@@ -568,7 +568,7 @@ write_superblock:
                                        fs->super->s_first_data_block+1,
                                        1, buf);
        if (retval) {
-               com_err("create_journal_dev", retval,
+               com_err("create_journal_dev", retval, "%s",
                        _("while writing journal superblock"));
                exit(1);
        }
@@ -636,7 +636,7 @@ static void show_stats(ext2_filsys fs)
                return;
        }
 
-       printf(_("Superblock backups stored on blocks: "));
+       printf("%s", _("Superblock backups stored on blocks: "));
        group_block = s->s_first_data_block;
        col_left = 0;
        for (i = 1; i < fs->group_desc_count; i++) {
@@ -706,7 +706,7 @@ static void parse_extended_opts(struct ext2_super_block *param,
        len = strlen(opts);
        buf = malloc(len+1);
        if (!buf) {
-               fprintf(stderr,
+               fprintf(stderr, "%s",
                        _("Couldn't allocate memory to parse options!\n"));
                exit(1);
        }
@@ -790,7 +790,7 @@ static void parse_extended_opts(struct ext2_super_block *param,
                                continue;
                        }
                        if (resize <= ext2fs_blocks_count(param)) {
-                               fprintf(stderr,
+                               fprintf(stderr, "%s",
                                        _("The resize maximum must be greater "
                                          "than the filesystem size.\n"));
                                r_usage++;
@@ -814,7 +814,7 @@ static void parse_extended_opts(struct ext2_super_block *param,
 
                        if (rsv_gdb > 0) {
                                if (param->s_rev_level == EXT2_GOOD_OLD_REV) {
-                                       fprintf(stderr,
+                                       fprintf(stderr, "%s",
        _("On-line resizing not supported with revision 0 filesystems\n"));
                                        free(buf);
                                        exit(1);
@@ -1113,11 +1113,11 @@ static char **parse_fs_type(const char *fs_type,
                         "%s filesystem type.\n"), ext_type);
                if (!strcmp(ext_type, "ext3") || !strcmp(ext_type, "ext4") ||
                    !strcmp(ext_type, "ext4dev")) {
-                       printf(_("You probably need to install an updated "
-                                "mke2fs.conf file.\n\n"));
+                       printf("%s", _("You probably need to install an "
+                                      "updated mke2fs.conf file.\n\n"));
                }
                if (!force) {
-                       printf(_("Aborting...\n"));
+                       printf("%s", _("Aborting...\n"));
                        exit(1);
                }
        }
@@ -1329,7 +1329,8 @@ static void PRS(int argc, char *argv[])
                pathlen += strlen(oldpath);
        newpath = malloc(pathlen);
        if (!newpath) {
-               fprintf(stderr, _("Couldn't allocate memory for new PATH.\n"));
+               fprintf(stderr, "%s",
+                       _("Couldn't allocate memory for new PATH.\n"));
                exit(1);
        }
        strcpy(newpath, PATH_SET);
@@ -1439,7 +1440,7 @@ profile_error:
                        direct_io = 1;
                        break;
                case 'R':
-                       com_err(program_name, 0,
+                       com_err(program_name, 0, "%s",
                                _("'-R' is deprecated, use '-E' instead"));
                        /* fallthrough */
                case 'E':
@@ -1451,12 +1452,12 @@ profile_error:
                case 'g':
                        fs_param.s_blocks_per_group = strtoul(optarg, &tmp, 0);
                        if (*tmp) {
-                               com_err(program_name, 0,
-                                       _("Illegal number for blocks per group"));
+                               com_err(program_name, 0, "%s",
+                               _("Illegal number for blocks per group"));
                                exit(1);
                        }
                        if ((fs_param.s_blocks_per_group % 8) != 0) {
-                               com_err(program_name, 0,
+                               com_err(program_name, 0, "%s",
                                _("blocks per group must be multiple of 8"));
                                exit(1);
                        }
@@ -1464,13 +1465,13 @@ profile_error:
                case 'G':
                        flex_bg_size = strtoul(optarg, &tmp, 0);
                        if (*tmp) {
-                               com_err(program_name, 0,
+                               com_err(program_name, 0, "%s",
                                        _("Illegal number for flex_bg size"));
                                exit(1);
                        }
                        if (flex_bg_size < 1 ||
                            (flex_bg_size & (flex_bg_size-1)) != 0) {
-                               com_err(program_name, 0,
+                               com_err(program_name, 0, "%s",
                                        _("flex_bg size must be a power of 2"));
                                exit(1);
                        }
@@ -1503,17 +1504,18 @@ profile_error:
                        parse_journal_opts(optarg);
                        break;
                case 'K':
-                       fprintf(stderr, _("Warning: -K option is deprecated and "
-                                         "should not be used anymore. Use "
-                                         "\'-E nodiscard\' extended option "
-                                         "instead!\n"));
+                       fprintf(stderr, "%s",
+                               _("Warning: -K option is deprecated and "
+                                 "should not be used anymore. Use "
+                                 "\'-E nodiscard\' extended option "
+                                 "instead!\n"));
                        discard = 0;
                        break;
                case 'l':
                        bad_blocks_filename = realloc(bad_blocks_filename,
                                                      strlen(optarg) + 1);
                        if (!bad_blocks_filename) {
-                               com_err(program_name, ENOMEM,
+                               com_err(program_name, ENOMEM, "%s",
                                        _("in malloc for bad_blocks_filename"));
                                exit(1);
                        }
@@ -1572,7 +1574,7 @@ profile_error:
                        break;
                case 't':
                        if (fs_type) {
-                               com_err(program_name, 0,
+                               com_err(program_name, 0, "%s",
                                    _("The -t option may only be used once"));
                                exit(1);
                        }
@@ -1580,7 +1582,7 @@ profile_error:
                        break;
                case 'T':
                        if (usage_types) {
-                               com_err(program_name, 0,
+                               com_err(program_name, 0, "%s",
                                    _("The -T option may only be used once"));
                                exit(1);
                        }
@@ -1679,20 +1681,20 @@ profile_error:
                                                 &dev_size);
 
        if (retval && (retval != EXT2_ET_UNIMPLEMENTED)) {
-               com_err(program_name, retval,
+               com_err(program_name, retval, "%s",
                        _("while trying to determine filesystem size"));
                exit(1);
        }
        if (!fs_blocks_count) {
                if (retval == EXT2_ET_UNIMPLEMENTED) {
-                       com_err(program_name, 0,
+                       com_err(program_name, 0, "%s",
                                _("Couldn't determine device size; you "
                                "must specify\nthe size of the "
                                "filesystem\n"));
                        exit(1);
                } else {
                        if (dev_size == 0) {
-                               com_err(program_name, 0,
+                               com_err(program_name, 0, "%s",
                                _("Device size reported to be zero.  "
                                  "Invalid partition specified, or\n\t"
                                  "partition table wasn't reread "
@@ -1709,7 +1711,7 @@ profile_error:
                                             EXT2_BLOCK_SIZE(&fs_param))-1));
                }
        } else if (!force && (fs_blocks_count > dev_size)) {
-               com_err(program_name, 0,
+               com_err(program_name, 0, "%s",
                        _("Filesystem larger than apparent device size."));
                proceed_question();
        }
@@ -1730,7 +1732,7 @@ profile_error:
                                 fs_blocks_count ? fs_blocks_count : dev_size,
                                 argv[0]);
        if (!fs_types) {
-               fprintf(stderr, _("Failed to parse fs types list\n"));
+               fprintf(stderr, "%s", _("Failed to parse fs types list\n"));
                exit(1);
        }
 
@@ -1800,13 +1802,13 @@ profile_error:
        /* Get the hardware sector sizes, if available */
        retval = ext2fs_get_device_sectsize(device_name, &lsector_size);
        if (retval) {
-               com_err(program_name, retval,
+               com_err(program_name, retval, "%s",
                        _("while trying to determine hardware sector size"));
                exit(1);
        }
        retval = ext2fs_get_device_phys_sectsize(device_name, &psector_size);
        if (retval) {
-               com_err(program_name, retval,
+               com_err(program_name, retval, "%s",
                        _("while trying to determine physical sector size"));
                exit(1);
        }
@@ -1839,7 +1841,7 @@ profile_error:
                fs_blocks_count /= (blocksize / 1024);
        } else {
                if (blocksize < lsector_size) {                 /* Impossible */
-                       com_err(program_name, EINVAL,
+                       com_err(program_name, EINVAL, "%s",
                                _("while setting blocksize; too small "
                                  "for device\n"));
                        exit(1);
@@ -1889,14 +1891,15 @@ profile_error:
        if (r_opt == EXT2_GOOD_OLD_REV &&
            (fs_param.s_feature_compat || fs_param.s_feature_incompat ||
             fs_param.s_feature_ro_compat)) {
-               fprintf(stderr, _("Filesystem features not supported "
-                                 "with revision 0 filesystems\n"));
+               fprintf(stderr, "%s", _("Filesystem features not supported "
+                                       "with revision 0 filesystems\n"));
                exit(1);
        }
 
        if (s_opt > 0) {
                if (r_opt == EXT2_GOOD_OLD_REV) {
-                       fprintf(stderr, _("Sparse superblocks not supported "
+                       fprintf(stderr, "%s",
+                               _("Sparse superblocks not supported "
                                  "with revision 0 filesystems\n"));
                        exit(1);
                }
@@ -1908,8 +1911,8 @@ profile_error:
 
        if (journal_size != 0) {
                if (r_opt == EXT2_GOOD_OLD_REV) {
-                       fprintf(stderr, _("Journals not supported "
-                                 "with revision 0 filesystems\n"));
+                       fprintf(stderr, "%s", _("Journals not supported with "
+                                               "revision 0 filesystems\n"));
                        exit(1);
                }
                fs_param.s_feature_compat |=
@@ -1939,8 +1942,8 @@ profile_error:
        /* Check the user's mkfs options for 64bit */
        if ((fs_param.s_feature_incompat & EXT4_FEATURE_INCOMPAT_64BIT) &&
            !(fs_param.s_feature_incompat & EXT3_FEATURE_INCOMPAT_EXTENTS)) {
-               printf(_("Extents MUST be enabled for a 64-bit filesystem.  "
-                        "Pass -O extents to rectify.\n"));
+               printf("%s", _("Extents MUST be enabled for a 64-bit "
+                              "filesystem.  Pass -O extents to rectify.\n"));
                exit(1);
        }
 
@@ -1958,13 +1961,13 @@ profile_error:
                        int_log2(cluster_size >> EXT2_MIN_CLUSTER_LOG_SIZE);
                if (fs_param.s_log_cluster_size &&
                    fs_param.s_log_cluster_size < fs_param.s_log_block_size) {
-                       com_err(program_name, 0,
+                       com_err(program_name, 0, "%s",
                                _("The cluster size may not be "
                                  "smaller than the block size.\n"));
                        exit(1);
                }
        } else if (cluster_size) {
-               com_err(program_name, 0,
+               com_err(program_name, 0, "%s",
                        _("specifying a cluster size requires the "
                          "bigalloc feature"));
                exit(1);
@@ -2052,7 +2055,7 @@ profile_error:
        /* Can't support bigalloc feature without extents feature */
        if ((fs_param.s_feature_ro_compat & EXT4_FEATURE_RO_COMPAT_BIGALLOC) &&
            !(fs_param.s_feature_incompat & EXT3_FEATURE_INCOMPAT_EXTENTS)) {
-               com_err(program_name, 0,
+               com_err(program_name, 0, "%s",
                        _("Can't support bigalloc feature without "
                          "extents feature"));
                exit(1);
@@ -2060,24 +2063,24 @@ profile_error:
 
        if ((fs_param.s_feature_incompat & EXT2_FEATURE_INCOMPAT_META_BG) &&
            (fs_param.s_feature_compat & EXT2_FEATURE_COMPAT_RESIZE_INODE)) {
-               fprintf(stderr, _("The resize_inode and meta_bg features "
-                                 "are not compatible.\n"
-                                 "They can not be both enabled "
-                                 "simultaneously.\n"));
+               fprintf(stderr, "%s", _("The resize_inode and meta_bg "
+                                       "features are not compatible.\n"
+                                       "They can not be both enabled "
+                                       "simultaneously.\n"));
                exit(1);
        }
 
        if (!quiet &&
            (fs_param.s_feature_ro_compat & EXT4_FEATURE_RO_COMPAT_BIGALLOC))
-               fprintf(stderr, _("\nWarning: the bigalloc feature is still "
-                                 "under development\n"
+               fprintf(stderr, "%s", _("\nWarning: the bigalloc feature is "
+                                 "still under development\n"
                                  "See https://ext4.wiki.kernel.org/"
                                  "index.php/Bigalloc for more information\n\n"));
 
        if (!quiet &&
            (fs_param.s_feature_ro_compat & EXT4_FEATURE_RO_COMPAT_QUOTA))
-               fprintf(stderr, _("\nWarning: the quota feature is still "
-                                 "under development\n"
+               fprintf(stderr, "%s", _("\nWarning: the quota feature is "
+                                 "still under development\n"
                                  "See https://ext4.wiki.kernel.org/"
                                  "index.php/Quota for more information\n\n"));
 
@@ -2086,7 +2089,7 @@ profile_error:
         */
        if ((fs_param.s_feature_compat & EXT2_FEATURE_COMPAT_RESIZE_INODE) &&
            !(fs_param.s_feature_ro_compat&EXT2_FEATURE_RO_COMPAT_SPARSE_SUPER)) {
-               com_err(program_name, 0,
+               com_err(program_name, 0, "%s",
                        _("reserved online resize blocks not supported "
                          "on non-sparse filesystem"));
                exit(1);
@@ -2095,7 +2098,7 @@ profile_error:
        if (fs_param.s_blocks_per_group) {
                if (fs_param.s_blocks_per_group < 256 ||
                    fs_param.s_blocks_per_group > 8 * (unsigned) blocksize) {
-                       com_err(program_name, 0,
+                       com_err(program_name, 0, "%s",
                                _("blocks per group count out of range"));
                        exit(1);
                }
@@ -2119,7 +2122,7 @@ profile_error:
        if (flex_bg_size) {
                if (!(fs_param.s_feature_incompat &
                      EXT4_FEATURE_INCOMPAT_FLEX_BG)) {
-                       com_err(program_name, 0,
+                       com_err(program_name, 0, "%s",
                                _("Flex_bg feature not enabled, so "
                                  "flex_bg size may not be specified"));
                        exit(1);
@@ -2307,7 +2310,7 @@ errout:
        if (free_tdb_dir)
                free(tdb_dir);
        free(tdb_file);
-       com_err(program_name, retval,
+       com_err(program_name, retval, "%s",
                _("while trying to setup undo file\n"));
        return retval;
 }
@@ -2458,7 +2461,8 @@ int main (int argc, char *argv[])
                flags |= EXT2_FLAG_PRINT_PROGRESS;
        retval = ext2fs_initialize(device_name, flags, &fs_param, io_ptr, &fs);
        if (retval) {
-               com_err(device_name, retval, _("while setting up superblock"));
+               com_err(device_name, retval, "%s",
+                       _("while setting up superblock"));
                exit(1);
        }
        fs->progress_ops = &ext2fs_numeric_progress_ops;
@@ -2493,8 +2497,9 @@ int main (int argc, char *argv[])
                retval = mke2fs_discard_device(fs);
                if (!retval && io_channel_discard_zeroes_data(fs->io)) {
                        if (verbose)
-                               printf(_("Discard succeeded and will return 0s "
-                                        " - skipping inode table wipe\n"));
+                               printf("%s",
+                                      _("Discard succeeded and will return "
+                                        "0s - skipping inode table wipe\n"));
                        lazy_itable_init = 1;
                        itable_zeroed = 1;
                }
@@ -2634,19 +2639,19 @@ int main (int argc, char *argv[])
        handle_bad_blocks(fs, bb_list);
        fs->stride = fs_stride = fs->super->s_raid_stride;
        if (!quiet)
-               printf(_("Allocating group tables: "));
+               printf("%s", _("Allocating group tables: "));
        retval = ext2fs_allocate_tables(fs);
        if (retval) {
-               com_err(program_name, retval,
+               com_err(program_name, retval, "%s",
                        _("while trying to allocate filesystem tables"));
                exit(1);
        }
        if (!quiet)
-               printf(_("done                            \n"));
+               printf("%s", _("done                            \n"));
 
        retval = ext2fs_convert_subcluster_bitmap(fs, &fs->block_map);
        if (retval) {
-               com_err(program_name, retval,
+               com_err(program_name, retval, "%s",
                        _("\n\twhile converting subcluster bitmap"));
                exit(1);
        }
@@ -2702,6 +2707,7 @@ int main (int argc, char *argv[])
                        retval = ext2fs_create_resize_inode(fs);
                        if (retval) {
                                com_err("ext2fs_create_resize_inode", retval,
+                                       "%s",
                                _("while reserving blocks for online resize"));
                                exit(1);
                        }
@@ -2737,14 +2743,14 @@ int main (int argc, char *argv[])
                        exit(1);
                }
                if (!quiet)
-                       printf(_("done\n"));
+                       printf("%s", _("done\n"));
                ext2fs_close(jfs);
                free(journal_device);
        } else if ((journal_size) ||
                   (fs_param.s_feature_compat &
                    EXT3_FEATURE_COMPAT_HAS_JOURNAL)) {
                if (super_only) {
-                       printf(_("Skipping journal creation in super-only mode\n"));
+                       printf("%s", _("Skipping journal creation in super-only mode\n"));
                        fs->super->s_journal_inum = EXT2_JOURNAL_INO;
                        goto no_journal;
                }
@@ -2762,20 +2768,21 @@ int main (int argc, char *argv[])
                retval = ext2fs_add_journal_inode(fs, journal_blocks,
                                                  journal_flags);
                if (retval) {
-                       com_err (program_name, retval,
-                                _("\n\twhile trying to create journal"));
+                       com_err(program_name, retval, "%s",
+                               _("\n\twhile trying to create journal"));
                        exit(1);
                }
                if (!quiet)
-                       printf(_("done\n"));
+                       printf("%s", _("done\n"));
        }
 no_journal:
        if (!super_only &&
            fs->super->s_feature_incompat & EXT4_FEATURE_INCOMPAT_MMP) {
                retval = ext2fs_mmp_init(fs);
                if (retval) {
-                       fprintf(stderr, _("\nError while enabling multiple "
-                                         "mount protection feature."));
+                       fprintf(stderr, "%s",
+                               _("\nError while enabling multiple "
+                                 "mount protection feature."));
                        exit(1);
                }
                if (!quiet)
@@ -2792,16 +2799,16 @@ no_journal:
                create_quota_inodes(fs);
 
        if (!quiet)
-               printf(_("Writing superblocks and "
+               printf("%s", _("Writing superblocks and "
                       "filesystem accounting information: "));
        checkinterval = fs->super->s_checkinterval;
        max_mnt_count = fs->super->s_max_mnt_count;
        retval = ext2fs_close(fs);
        if (retval) {
-               fprintf(stderr,
+               fprintf(stderr, "%s",
                        _("\nWarning, had trouble writing out superblocks."));
        } else if (!quiet) {
-               printf(_("done\n\n"));
+               printf("%s", _("done\n\n"));
                if (!getenv("MKE2FS_SKIP_CHECK_MSG"))
                        print_check_message(max_mnt_count, checkinterval);
        }