Whamcloud - gitweb
Merge branch 'maint' into next
authorTheodore Ts'o <tytso@mit.edu>
Thu, 26 Dec 2013 05:30:56 +0000 (00:30 -0500)
committerTheodore Ts'o <tytso@mit.edu>
Thu, 26 Dec 2013 05:30:56 +0000 (00:30 -0500)
Conflicts:
lib/ext2fs/csum.c

78 files changed:
debugfs/debugfs.8.in
debugfs/debugfs.c
debugfs/debugfs.h
debugfs/extent_inode.c
debugfs/logdump.c
debugfs/set_fields.c
debugfs/util.c
e2fsck/dirinfo.c
e2fsck/e2fsck.c
e2fsck/ea_refcount.c
e2fsck/iscan.c
e2fsck/pass1.c
e2fsck/pass2.c
e2fsck/pass3.c
e2fsck/super.c
e2fsck/unix.c
e2fsck/util.c
lib/e2p/ls.c
lib/et/com_err.c
lib/et/error_message.c
lib/et/error_table.h
lib/et/et_name.c
lib/ext2fs/Makefile.in
lib/ext2fs/blknum.c
lib/ext2fs/bmap.c
lib/ext2fs/check_desc.c
lib/ext2fs/closefs.c
lib/ext2fs/csum.c
lib/ext2fs/dblist.c
lib/ext2fs/dir_iterate.c
lib/ext2fs/e2image.h
lib/ext2fs/ext2_fs.h
lib/ext2fs/extent.c
lib/ext2fs/fileio.c
lib/ext2fs/initialize.c
lib/ext2fs/mmp.c
lib/ext2fs/openfs.c
lib/ext2fs/punch.c
lib/ext2fs/swapfs.c
lib/ss/error.c
lib/ss/execute_cmd.c
lib/ss/help.c
lib/ss/invocation.c
lib/ss/pager.c
lib/ss/parse.c
lib/ss/request_tbl.c
lib/ss/ss_internal.h
misc/Makefile.in
misc/badblocks.c
misc/dumpe2fs.8.in
misc/dumpe2fs.c
misc/e2image.8.in
misc/e2image.c
misc/e2initrd_helper.c
misc/e2undo.c
misc/e4defrag.c
misc/ext4.5.in [new file with mode: 0644]
misc/fsck.c
misc/logsave.c
misc/mke2fs.8.in
misc/mke2fs.c
misc/tune2fs.8.in
resize/main.c
resize/resize2fs.c
resize/resize2fs.h
tests/f_desc_size_128/expect.1 [new file with mode: 0644]
tests/f_desc_size_128/expect.2 [new file with mode: 0644]
tests/f_desc_size_128/image.gz [new file with mode: 0644]
tests/f_desc_size_128/name [new file with mode: 0644]
tests/f_desc_size_bad/expect.1 [new file with mode: 0644]
tests/f_desc_size_bad/expect.2 [new file with mode: 0644]
tests/f_desc_size_bad/script [new file with mode: 0644]
tests/f_extent_oobounds/script
tests/i_e2image/script
tests/m_desc_size_128/expect.1 [new file with mode: 0644]
tests/m_desc_size_128/script [new file with mode: 0644]
tests/scripts/resize_test
util/subst.c

index 7ff4155..3373c1d 100644 (file)
@@ -711,4 +711,5 @@ was written by Theodore Ts'o <tytso@mit.edu>.
 .BR dumpe2fs (8),
 .BR tune2fs (8),
 .BR e2fsck (8),
-.BR mke2fs (8)
+.BR mke2fs (8),
+.BR ext4 (5)
index 578d577..179dd9a 100644 (file)
@@ -1738,7 +1738,7 @@ void do_write(int argc, char *argv[])
                eh = (struct ext3_extent_header *) &inode.i_block[0];
                eh->eh_depth = 0;
                eh->eh_entries = 0;
-               eh->eh_magic = EXT3_EXT_MAGIC;
+               eh->eh_magic = ext2fs_cpu_to_le16(EXT3_EXT_MAGIC);
                i = (sizeof(inode.i_block) - sizeof(*eh)) /
                        sizeof(struct ext3_extent);
                eh->eh_max = ext2fs_cpu_to_le16(i);
@@ -2479,10 +2479,8 @@ int main(int argc, char **argv)
                        break;
                case 's':
                        retval = strtoblk(argv[0], optarg, &superblock);
-                       if (retval) {
-                               com_err(argv[0], retval, 0, debug_prog_name);
+                       if (retval)
                                return 1;
-                       }
                        break;
                case 'c':
                        catastrophic = 1;
index 45175cf..6b4f6ef 100644 (file)
@@ -170,6 +170,9 @@ extern void do_set_mmp_value(int argc, char **argv);
 extern void do_freefrag(int argc, char **argv);
 extern void do_filefrag(int argc, char *argv[]);
 
+/* util.c */
+extern time_t string_to_time(const char *arg);
+
 /* zap.c */
 extern void do_zap_block(int argc, char **argv);
 extern void do_block_dump(int argc, char **argv);
index 75e328c..b3c55f9 100644 (file)
@@ -25,8 +25,8 @@ extern char *optarg;
 
 #include "debugfs.h"
 
-ext2_ino_t     current_ino;
-ext2_extent_handle_t current_handle;
+static ext2_ino_t      current_ino;
+static ext2_extent_handle_t current_handle;
 
 static void dbg_print_extent(char *desc, struct ext2fs_extent *extent)
 {
index db085cb..3034736 100644 (file)
@@ -39,10 +39,10 @@ enum journal_location {JOURNAL_IS_INTERNAL, JOURNAL_IS_EXTERNAL};
 
 #define ANY_BLOCK ((blk64_t) -1)
 
-int            dump_all, dump_contents, dump_descriptors;
-blk64_t                block_to_dump, bitmap_to_dump, inode_block_to_dump;
-unsigned int   group_to_dump, inode_offset_to_dump;
-ext2_ino_t     inode_to_dump;
+static int             dump_all, dump_contents, dump_descriptors;
+static blk64_t         block_to_dump, bitmap_to_dump, inode_block_to_dump;
+static unsigned int    group_to_dump, inode_offset_to_dump;
+static ext2_ino_t      inode_to_dump;
 
 struct journal_source
 {
index 1e57277..d46ba27 100644 (file)
@@ -704,11 +704,14 @@ void do_set_block_group_descriptor(int argc, char *argv[])
        int                     size;
 
        /*
-        *Determine whether we are editing an ext2 or ext4 block
-        * group descriptor
+        * Determine whether we are editing an ext2 or ext4 block group
+        * descriptor.  Descriptors larger than ext4_group_desc cannot
+        * have their fields edited yet, because they do not have any
+        * names assigned.  When that happens, this function needs to
+        * be updated for the new descriptor struct and fields.
         */
-       if (current_fs && current_fs->super->s_feature_incompat &
-           EXT4_FEATURE_INCOMPAT_64BIT) {
+       if (current_fs &&
+           EXT2_DESC_SIZE(current_fs->super) >= EXT2_MIN_DESC_SIZE_64BIT) {
                table = ext4_bg_fields;
                edit = &set_gd4;
                size = sizeof(set_gd4);
index 09088e0..aafbc56 100644 (file)
@@ -211,7 +211,7 @@ char *time_to_string(__u32 cl)
  * Parse a string as a time.  Return ((time_t)-1) if the string
  * doesn't appear to be a sane time.
  */
-extern time_t string_to_time(const char *arg)
+time_t string_to_time(const char *arg)
 {
        struct  tm      ts;
        time_t          ret;
index c81777a..dc08f90 100644 (file)
@@ -320,7 +320,7 @@ int e2fsck_get_num_dirinfo(e2fsck_t ctx)
        return ctx->dir_info ? ctx->dir_info->count : 0;
 }
 
-extern struct dir_info_iter *e2fsck_dir_info_iter_begin(e2fsck_t ctx)
+struct dir_info_iter *e2fsck_dir_info_iter_begin(e2fsck_t ctx)
 {
        struct dir_info_iter *iter;
        struct dir_info_db *db = ctx->dir_info;
@@ -334,8 +334,8 @@ extern struct dir_info_iter *e2fsck_dir_info_iter_begin(e2fsck_t ctx)
        return iter;
 }
 
-extern void e2fsck_dir_info_iter_end(e2fsck_t ctx EXT2FS_ATTR((unused)),
-                                    struct dir_info_iter *iter)
+void e2fsck_dir_info_iter_end(e2fsck_t ctx EXT2FS_ATTR((unused)),
+                             struct dir_info_iter *iter)
 {
        free(iter->tdb_iter.dptr);
        ext2fs_free_mem(&iter);
index 994f80e..0ec1540 100644 (file)
@@ -199,7 +199,7 @@ void e2fsck_free_context(e2fsck_t ctx)
  */
 typedef void (*pass_t)(e2fsck_t ctx);
 
-pass_t e2fsck_passes[] = {
+static pass_t e2fsck_passes[] = {
        e2fsck_pass1, e2fsck_pass2, e2fsck_pass3, e2fsck_pass4,
        e2fsck_pass5, 0 };
 
index 3836c5d..fcfaf49 100644 (file)
@@ -310,7 +310,8 @@ errcode_t ea_refcount_validate(ext2_refcount_t refcount, FILE *out)
        }
        for (i=1; i < refcount->count; i++) {
                if (refcount->list[i-1].ea_blk >= refcount->list[i].ea_blk) {
-                       fprintf(out, "%s: list[%d].blk=%u, list[%d].blk=%u\n",
+                       fprintf(out,
+                               "%s: list[%d].blk=%llu, list[%d].blk=%llu\n",
                                bad, i-1, refcount->list[i-1].ea_blk,
                                i, refcount->list[i].ea_blk);
                        ret = EXT2_ET_INVALID_ARGUMENT;
@@ -396,20 +397,20 @@ int main(int argc, char **argv)
                case BCODE_STORE:
                        blk = (blk_t) bcode_program[i++];
                        arg = bcode_program[i++];
-                       printf("Storing blk %u with value %d\n", blk, arg);
+                       printf("Storing blk %llu with value %d\n", blk, arg);
                        retval = ea_refcount_store(refcount, blk, arg);
                        if (retval)
                                com_err("ea_refcount_store", retval,
-                                       "while storing blk %u", blk);
+                                       "while storing blk %llu", blk);
                        break;
                case BCODE_FETCH:
                        blk = (blk_t) bcode_program[i++];
                        retval = ea_refcount_fetch(refcount, blk, &arg);
                        if (retval)
                                com_err("ea_refcount_fetch", retval,
-                                       "while fetching blk %u", blk);
+                                       "while fetching blk %llu", blk);
                        else
-                               printf("bcode_fetch(%u) returns %d\n",
+                               printf("bcode_fetch(%llu) returns %d\n",
                                       blk, arg);
                        break;
                case BCODE_INCR:
@@ -417,9 +418,9 @@ int main(int argc, char **argv)
                        retval = ea_refcount_increment(refcount, blk, &arg);
                        if (retval)
                                com_err("ea_refcount_increment", retval,
-                                       "while incrementing blk %u", blk);
+                                       "while incrementing blk %llu", blk);
                        else
-                               printf("bcode_increment(%u) returns %d\n",
+                               printf("bcode_increment(%llu) returns %d\n",
                                       blk, arg);
                        break;
                case BCODE_DECR:
@@ -427,9 +428,9 @@ int main(int argc, char **argv)
                        retval = ea_refcount_decrement(refcount, blk, &arg);
                        if (retval)
                                com_err("ea_refcount_decrement", retval,
-                                       "while decrementing blk %u", blk);
+                                       "while decrementing blk %llu", blk);
                        else
-                               printf("bcode_decrement(%u) returns %d\n",
+                               printf("bcode_decrement(%llu) returns %d\n",
                                       blk, arg);
                        break;
                case BCODE_VALIDATE:
@@ -446,7 +447,7 @@ int main(int argc, char **argv)
                                blk = ea_refcount_intr_next(refcount, &arg);
                                if (!blk)
                                        break;
-                               printf("\tblk=%u, count=%d\n", blk, arg);
+                               printf("\tblk=%llu, count=%d\n", blk, arg);
                        }
                        break;
                case BCODE_COLLAPSE:
index e23d2ad..52cad11 100644 (file)
@@ -107,7 +107,7 @@ int main (int argc, char *argv[])
        retval = ext2fs_open(device_name, 0,
                             0, 0, unix_io_manager, &fs);
        if (retval) {
-               com_err(program_name, retval, _("while trying to open %s"),
+               com_err(program_name, retval, _("while trying to open '%s'"),
                        device_name);
                exit(1);
        }
index 821239e..bd89b96 100644 (file)
@@ -509,8 +509,8 @@ static void check_is_really_dir(e2fsck_t ctx, struct problem_context *pctx,
        }
 }
 
-extern void e2fsck_setup_tdb_icount(e2fsck_t ctx, int flags,
-                                   ext2_icount_t *ret)
+void e2fsck_setup_tdb_icount(e2fsck_t ctx, int flags,
+                            ext2_icount_t *ret)
 {
        unsigned int            threshold;
        ext2_ino_t              num_dirs;
index 804770b..5a2745a 100644 (file)
@@ -1353,8 +1353,8 @@ static void clear_htree(e2fsck_t ctx, ext2_ino_t ino)
 }
 
 
-extern int e2fsck_process_bad_inode(e2fsck_t ctx, ext2_ino_t dir,
-                                   ext2_ino_t ino, char *buf)
+int e2fsck_process_bad_inode(e2fsck_t ctx, ext2_ino_t dir,
+                            ext2_ino_t ino, char *buf)
 {
        ext2_filsys fs = ctx->fs;
        struct ext2_inode       inode;
index c57aab8..aaf177c 100644 (file)
@@ -112,7 +112,7 @@ void e2fsck_pass3(e2fsck_t ctx)
        /*
         * Force the creation of /lost+found if not present
         */
-       if ((ctx->flags & E2F_OPT_READONLY) == 0)
+       if ((ctx->options & E2F_OPT_READONLY) == 0)
                e2fsck_get_lost_and_found(ctx, 1);
 
        /*
index dcfd247..59c1f97 100644 (file)
@@ -22,6 +22,7 @@
 
 #define MIN_CHECK 1
 #define MAX_CHECK 2
+#define LOG2_CHECK 4
 
 static void check_super_value(e2fsck_t ctx, const char *descr,
                              unsigned long value, int flags,
@@ -30,7 +31,8 @@ static void check_super_value(e2fsck_t ctx, const char *descr,
        struct          problem_context pctx;
 
        if (((flags & MIN_CHECK) && (value < min_val)) ||
-           ((flags & MAX_CHECK) && (value > max_val))) {
+           ((flags & MAX_CHECK) && (value > max_val)) ||
+           ((flags & LOG2_CHECK) && (value & (value - 1) != 0))) {
                clear_problem_context(&pctx);
                pctx.num = value;
                pctx.str = descr;
@@ -527,14 +529,17 @@ void check_super_block(e2fsck_t ctx)
                          MAX_CHECK, 0, ext2fs_blocks_count(sb) / 2);
        check_super_value(ctx, "reserved_gdt_blocks",
                          sb->s_reserved_gdt_blocks, MAX_CHECK, 0,
-                         fs->blocksize/4);
+                         fs->blocksize / sizeof(__u32));
+       check_super_value(ctx, "desc_size",
+                         sb->s_desc_size, MAX_CHECK | LOG2_CHECK, 0,
+                         EXT2_MAX_DESC_SIZE);
        if (sb->s_rev_level > EXT2_GOOD_OLD_REV)
                check_super_value(ctx, "first_ino", sb->s_first_ino,
                                  MIN_CHECK | MAX_CHECK,
                                  EXT2_GOOD_OLD_FIRST_INO, sb->s_inodes_count);
        inode_size = EXT2_INODE_SIZE(sb);
        check_super_value(ctx, "inode_size",
-                         inode_size, MIN_CHECK | MAX_CHECK,
+                         inode_size, MIN_CHECK | MAX_CHECK | LOG2_CHECK,
                          EXT2_GOOD_OLD_INODE_SIZE, fs->blocksize);
        if (sb->s_blocks_per_group != (sb->s_clusters_per_group *
                                       EXT2FS_CLUSTER_RATIO(fs))) {
@@ -544,13 +549,6 @@ void check_super_block(e2fsck_t ctx)
                ctx->flags |= E2F_FLAG_ABORT; /* never get here! */
                return;
        }
-       if (inode_size & (inode_size - 1)) {
-               pctx.num = inode_size;
-               pctx.str = "inode_size";
-               fix_problem(ctx, PR_0_MISC_CORRUPT_SUPER, &pctx);
-               ctx->flags |= E2F_FLAG_ABORT; /* never get here! */
-               return;
-       }
 
        if ((ctx->flags & E2F_FLAG_GOT_DEVSIZE) &&
            (ctx->num_blocks < ext2fs_blocks_count(sb))) {
index 281da5a..429f1cd 100644 (file)
@@ -464,7 +464,7 @@ struct percent_tbl {
        int     max_pass;
        int     table[32];
 };
-struct percent_tbl e2fsck_tbl = {
+static struct percent_tbl e2fsck_tbl = {
        5, { 0, 70, 90, 92,  95, 100 }
 };
 static char bar[128], spaces[128];
@@ -483,7 +483,7 @@ static float calc_percent(struct percent_tbl *tbl, int pass, int curr,
                + tbl->table[pass-1]);
 }
 
-extern void e2fsck_clear_progbar(e2fsck_t ctx)
+void e2fsck_clear_progbar(e2fsck_t ctx)
 {
        if (!(ctx->flags & E2F_FLAG_PROG_BAR))
                return;
index 15e97b9..e7e8704 100644 (file)
@@ -465,9 +465,9 @@ void e2fsck_read_inode_full(e2fsck_t ctx, unsigned long ino,
        }
 }
 
-extern void e2fsck_write_inode_full(e2fsck_t ctx, unsigned long ino,
-                              struct ext2_inode * inode, int bufsize,
-                              const char *proc)
+void e2fsck_write_inode_full(e2fsck_t ctx, unsigned long ino,
+                            struct ext2_inode * inode, int bufsize,
+                            const char *proc)
 {
        errcode_t retval;
 
@@ -479,8 +479,8 @@ extern void e2fsck_write_inode_full(e2fsck_t ctx, unsigned long ino,
        }
 }
 
-extern void e2fsck_write_inode(e2fsck_t ctx, unsigned long ino,
-                              struct ext2_inode * inode, const char *proc)
+void e2fsck_write_inode(e2fsck_t ctx, unsigned long ino,
+                       struct ext2_inode * inode, const char *proc)
 {
        errcode_t retval;
 
index d2e84eb..401c01b 100644 (file)
@@ -269,6 +269,8 @@ void list_super2(struct ext2_super_block * sb, FILE *f)
        else
                fprintf(f, "Fragment size:            %u\n",
                        EXT2_CLUSTER_SIZE(sb));
+       if (sb->s_feature_incompat & EXT4_FEATURE_INCOMPAT_64BIT)
+               fprintf(f, "Group descriptor size:    %u\n", sb->s_desc_size);
        if (sb->s_reserved_gdt_blocks)
                fprintf(f, "Reserved GDT blocks:      %u\n",
                        sb->s_reserved_gdt_blocks);
index 4ea52de..d38998a 100644 (file)
@@ -85,8 +85,7 @@ void com_err (const char *whoami,
     va_end(pvar);
 }
 
-errf set_com_err_hook (new_proc)
-    errf new_proc;
+errf set_com_err_hook(errf new_proc)
 {
     errf x = com_err_hook;
 
@@ -98,7 +97,7 @@ errf set_com_err_hook (new_proc)
     return x;
 }
 
-errf reset_com_err_hook () {
+errf reset_com_err_hook(void) {
     errf x = com_err_hook;
     com_err_hook = default_com_err_proc;
     return x;
index 92509e6..5d8d242 100644 (file)
@@ -105,8 +105,7 @@ typedef char *(*gettextf) (const char *);
 
 static gettextf com_err_gettext = NULL;
 
-gettextf set_com_err_gettext (new_proc)
-    gettextf new_proc;
+gettextf set_com_err_gettext(gettextf new_proc)
 {
     gettextf x = com_err_gettext;
 
index 4f10991..24e4762 100644 (file)
@@ -18,7 +18,7 @@ struct et_list {
     struct et_list *next;
     const struct error_table *table;
 };
-extern struct et_list * _et_list;
+extern struct et_list *_et_list, *_et_dynamic_list;
 
 #define        ERRCODE_RANGE   8       /* # of bits to shift table number */
 #define        BITS_PER_CHAR   6       /* # bits to shift per character in name */
index 6b59edd..d9a3e87 100644 (file)
@@ -21,8 +21,7 @@ static const char char_set[] =
 
 static char buf[6];
 
-const char * error_table_name(num)
-    errcode_t num;
+const char * error_table_name(errcode_t num)
 {
     int ch;
     int i;
index e1e6216..5552e0e 100644 (file)
@@ -308,7 +308,7 @@ extent_cmds.c extent_cmds.h: $(top_srcdir)/debugfs/extent_cmds.ct
 
 DEBUG_OBJS= debug_cmds.o debugfs.o util.o ncheck.o icheck.o ls.o \
        lsdel.o dump.o set_fields.o logdump.o htree.o unused.o \
-       e2freefrag.o filefrag.o extent_inode.o extent_cmds.o
+       e2freefrag.o filefrag.o extent_inode.o extent_cmds.o zap.o
 
 debugfs.o: $(top_srcdir)/debugfs/debugfs.c
        $(E) "  CC $<"
@@ -358,6 +358,10 @@ unused.o: $(top_srcdir)/debugfs/unused.c
        $(E) "  CC $<"
        $(Q) $(CC) $(ALL_CFLAGS) -c $< -o $@
 
+zap.o: $(top_srcdir)/debugfs/zap.c
+       $(E) "  CC $<"
+       $(Q) $(CC) $(ALL_CFLAGS) -c $< -o $@
+
 e2freefrag.o: $(top_srcdir)/misc/e2freefrag.c
        $(E) "  CC $<"
        $(Q) $(CC) $(ALL_CFLAGS) -DDEBUGFS -I$(top_srcdir)/debugfs -c $< -o $@
index b3eef6c..aced897 100644 (file)
@@ -187,11 +187,8 @@ struct ext2_group_desc *ext2fs_group_desc(ext2_filsys fs,
                                          struct opaque_ext2_group_desc *gdp,
                                          dgrp_t group)
 {
-       if (fs->super->s_desc_size >= EXT2_MIN_DESC_SIZE_64BIT)
-               return (struct ext2_group_desc *)
-                       ((struct ext4_group_desc *) gdp + group);
-       else
-               return (struct ext2_group_desc *) gdp + group;
+       return (struct ext2_group_desc *)((char *)gdp +
+                                         group * EXT2_DESC_SIZE(fs->super));
 }
 
 /* Do the same but as an ext4 group desc for internal use here */
index 3a18d76..b944c27 100644 (file)
@@ -18,7 +18,7 @@
 #include <errno.h>
 
 #include "ext2_fs.h"
-#include "ext2fs.h"
+#include "ext2fsP.h"
 
 #if defined(__GNUC__) && !defined(NO_INLINE_FUNCS)
 #define _BMAP_INLINE_  __inline__
index a6fcc45..1a768f9 100644 (file)
@@ -42,6 +42,9 @@ errcode_t ext2fs_check_desc(ext2_filsys fs)
 
        EXT2_CHECK_MAGIC(fs, EXT2_ET_MAGIC_EXT2FS_FILSYS);
 
+       if (EXT2_DESC_SIZE(fs->super) & (EXT2_DESC_SIZE(fs->super) - 1))
+               return EXT2_ET_BAD_DESC_SIZE;
+
        retval = ext2fs_allocate_subcluster_bitmap(fs, "check_desc map", &bmap);
        if (retval)
                return retval;
index db05637..0483e05 100644 (file)
@@ -324,7 +324,7 @@ errcode_t ext2fs_flush2(ext2_filsys fs, int flags)
               fs->desc_blocks);
 
        /* swap the group descriptors */
-       for (j=0; j < fs->group_desc_count; j++) {
+       for (j = 0; j < fs->group_desc_count; j++) {
                gdp = ext2fs_group_desc(fs, group_shadow, j);
                ext2fs_swap_group_desc2(fs, gdp);
        }
index 607f74a..9f08c38 100644 (file)
@@ -721,29 +721,23 @@ errcode_t ext2fs_inode_csum_set(ext2_filsys fs, ext2_ino_t inum,
 
 __u16 ext2fs_group_desc_csum(ext2_filsys fs, dgrp_t group)
 {
+       struct ext2_group_desc *desc = ext2fs_group_desc(fs, fs->group_desc,
+                                                        group);
+       size_t size = EXT2_DESC_SIZE(fs->super);
+       size_t offset;
        __u16 crc = 0;
-       struct ext2_group_desc *desc;
-       size_t size;
-
-       size = fs->super->s_desc_size;
-       if (size < EXT2_MIN_DESC_SIZE)
-               size = EXT2_MIN_DESC_SIZE;
-       if (size > sizeof(struct ext4_group_desc)) {
-               /* This should never happen, but cap it for safety's sake */
-               size = sizeof(struct ext4_group_desc);
-       }
-
-       desc = ext2fs_group_desc(fs, fs->group_desc, group);
-
 #ifdef WORDS_BIGENDIAN
        struct ext4_group_desc swabdesc;
+       size_t save_size = size;
+       const size_t ext4_bg_size = sizeof(struct ext4_group_desc);
+       struct ext2_group_desc *save_desc = desc;
 
        /* Have to swab back to little-endian to do the checksum */
+       if (size > ext4_bg_size)
+               size = ext4_bg_size;
        memcpy(&swabdesc, desc, size);
-       ext2fs_swap_group_desc2(fs,
-                               (struct ext2_group_desc *) &swabdesc);
+       ext2fs_swap_group_desc2(fs, (struct ext2_group_desc *) &swabdesc);
        desc = (struct ext2_group_desc *) &swabdesc;
-
        group = ext2fs_swab32(group);
 #endif
 
@@ -760,13 +754,18 @@ __u16 ext2fs_group_desc_csum(ext2_filsys fs, dgrp_t group)
                crc32 = ext2fs_crc32c_le(crc32, (unsigned char *)desc,
                                         size);
                desc->bg_checksum = old_crc;
-
+#ifdef WORDS_BIGENDIAN
+               if (save_size > ext4_bg_size)
+                       crc32 = ext2fs_crc32c_le(crc32,
+                                          (char *)save_desc + ext4_bg_size,
+                                          save_size - ext4_bg_size);
+#endif
                crc = crc32 & 0xFFFF;
                goto out;
        }
 
        /* old crc16 code */
-       size_t offset = offsetof(struct ext2_group_desc, bg_checksum);
+       offset = offsetof(struct ext2_group_desc, bg_checksum);
        crc = ext2fs_crc16(~0, fs->super->s_uuid,
                           sizeof(fs->super->s_uuid));
        crc = ext2fs_crc16(crc, &group, sizeof(group));
@@ -777,6 +776,16 @@ __u16 ext2fs_group_desc_csum(ext2_filsys fs, dgrp_t group)
                crc = ext2fs_crc16(crc, (char *)desc + offset,
                                   size - offset);
        }
+#ifdef WORDS_BIGENDIAN
+       /*
+        * If the size of the bg descriptor is greater than 64
+        * bytes, which is the size of the traditional ext4 bg
+        * descriptor, checksum the rest of the descriptor here
+        */
+       if (save_size > ext4_bg_size)
+               crc = ext2fs_crc16(crc, (char *)save_desc + ext4_bg_size,
+                                  save_size - ext4_bg_size);
+#endif
 
 out:
        return crc;
@@ -870,22 +879,22 @@ void print_csum(const char *msg, ext2_filsys fs, dgrp_t group)
 {
        __u16 crc1, crc2, crc3;
        dgrp_t swabgroup;
-       struct ext2_group_desc *desc;
-       size_t size;
+       struct ext2_group_desc *desc = ext2fs_group_desc(fs, fs->group_desc,
+                                                        group);
+       size_t size = EXT2_DESC_SIZE(fs->super);
        struct ext2_super_block *sb = fs->super;
        int offset = offsetof(struct ext2_group_desc, bg_checksum);
 #ifdef WORDS_BIGENDIAN
        struct ext4_group_desc swabdesc;
+       struct ext2_group_desc *save_desc = desc;
+       const size_t ext4_bg_size = sizeof(struct ext4_group_desc);
+       size_t save_size = size;
 #endif
 
-       desc = ext2fs_group_desc(fs, fs->group_desc, group);
-       size = fs->super->s_desc_size;
-       if (size < EXT2_MIN_DESC_SIZE)
-               size = EXT2_MIN_DESC_SIZE;
-       if (size > sizeof(struct ext4_group_desc))
-               size = sizeof(struct ext4_group_desc);
 #ifdef WORDS_BIGENDIAN
        /* Have to swab back to little-endian to do the checksum */
+       if (size > ext4_bg_size)
+               size = ext4_bg_size;
        memcpy(&swabdesc, desc, size);
        ext2fs_swap_group_desc2(fs, (struct ext2_group_desc *) &swabdesc);
        desc = (struct ext2_group_desc *) &swabdesc;
@@ -902,6 +911,11 @@ void print_csum(const char *msg, ext2_filsys fs, dgrp_t group)
        /* for checksum of struct ext4_group_desc do the rest...*/
        if (offset < size)
                crc3 = ext2fs_crc16(crc3, (char *)desc + offset, size - offset);
+#ifdef WORDS_BIGENDIAN
+       if (save_size > ext4_bg_size)
+               crc3 = ext2fs_crc16(crc3, (char *)save_desc + ext4_bg_size,
+                                   save_size - ext4_bg_size);
+#endif
 
        printf("%s UUID %s=%04x, grp %u=%04x: %04x=%04x\n",
               msg, e2p_uuid2str(sb->s_uuid), crc1, group, crc2, crc3,
@@ -921,6 +935,11 @@ int main(int argc, char **argv)
 
        memset(&param, 0, sizeof(param));
        ext2fs_blocks_count_set(&param, 32768);
+#if 0
+       param.s_feature_incompat |= EXT4_FEATURE_INCOMPAT_64BIT;
+       param.s_desc_size = 128;
+       csum_known = 0x5b6e;
+#endif
 
        retval = ext2fs_initialize("test fs", EXT2_FLAG_64BITS, &param,
                                   test_io_manager, &fs);
index 3503615..942c4f0 100644 (file)
@@ -365,10 +365,11 @@ int ext2fs_dblist_count(ext2_dblist dblist)
 errcode_t ext2fs_dblist_get_last(ext2_dblist dblist,
                                 struct ext2_db_entry **entry)
 {
-       EXT2_CHECK_MAGIC(dblist, EXT2_ET_MAGIC_DBLIST);
        static struct ext2_db_entry ret_entry;
        struct ext2_db_entry2 *last;
 
+       EXT2_CHECK_MAGIC(dblist, EXT2_ET_MAGIC_DBLIST);
+
        if (dblist->count == 0)
                return EXT2_ET_DBLIST_EMPTY;
 
index 8be0ac2..306ffb0 100644 (file)
@@ -151,16 +151,16 @@ static int xlate_func(ext2_ino_t dir EXT2FS_ATTR((unused)),
        return (*xl->func)(dirent, offset, blocksize, buf, xl->real_private);
 }
 
-extern errcode_t ext2fs_dir_iterate(ext2_filsys fs,
-                             ext2_ino_t dir,
-                             int flags,
-                             char *block_buf,
-                             int (*func)(struct ext2_dir_entry *dirent,
-                                         int   offset,
-                                         int   blocksize,
-                                         char  *buf,
-                                         void  *priv_data),
-                             void *priv_data)
+errcode_t ext2fs_dir_iterate(ext2_filsys fs,
+                            ext2_ino_t dir,
+                            int flags,
+                            char *block_buf,
+                            int (*func)(struct ext2_dir_entry *dirent,
+                                        int    offset,
+                                        int    blocksize,
+                                        char   *buf,
+                                        void   *priv_data),
+                            void *priv_data)
 {
        struct xlate xl;
 
index 5537980..53b20cc 100644 (file)
  * %End-Header%
  */
 
-/* Image types */
-#define E2IMAGE_RAW    1
-#define E2IMAGE_QCOW2  2
-
-/* Image flags */
-#define E2IMAGE_INSTALL_FLAG   1
-#define E2IMAGE_SCRAMBLE_FLAG  2
-#define E2IMAGE_IS_QCOW2_FLAG  4
-
 struct ext2_image_hdr {
        __u32   magic_number;   /* This must be EXT2_ET_MAGIC_E2IMAGE */
        char    magic_descriptor[16]; /* "Ext2 Image 1.0", w/ null padding */
index 6a28d55..deb97aa 100644 (file)
@@ -159,7 +159,7 @@ struct ext2_group_desc
        __u16   bg_block_bitmap_csum_lo;/* crc32c(s_uuid+grp_num+bitmap) LSB */
        __u16   bg_inode_bitmap_csum_lo;/* crc32c(s_uuid+grp_num+bitmap) LSB */
        __u16   bg_itable_unused;       /* Unused inodes count */
-       __u16   bg_checksum;            /* crc16(s_uuid+grouo_num+group_desc)*/
+       __u16   bg_checksum;            /* crc16(s_uuid+group_num+group_desc)*/
 };
 
 /*
index fbb0a74..2928695 100644 (file)
@@ -160,7 +160,7 @@ errcode_t ext2fs_extent_header_verify(void *ptr, int size)
 /*
  * Begin functions to handle an inode's extent information
  */
-extern void ext2fs_extent_free(ext2_extent_handle_t handle)
+void ext2fs_extent_free(ext2_extent_handle_t handle)
 {
        int                     i;
 
@@ -177,13 +177,13 @@ extern void ext2fs_extent_free(ext2_extent_handle_t handle)
        ext2fs_free_mem(&handle);
 }
 
-extern errcode_t ext2fs_extent_open(ext2_filsys fs, ext2_ino_t ino,
+errcode_t ext2fs_extent_open(ext2_filsys fs, ext2_ino_t ino,
                                    ext2_extent_handle_t *ret_handle)
 {
        return ext2fs_extent_open2(fs, ino, NULL, ret_handle);
 }
 
-extern errcode_t ext2fs_extent_open2(ext2_filsys fs, ext2_ino_t ino,
+errcode_t ext2fs_extent_open2(ext2_filsys fs, ext2_ino_t ino,
                                    struct ext2_inode *inode,
                                    ext2_extent_handle_t *ret_handle)
 {
index 7732804..5a39c32 100644 (file)
@@ -395,7 +395,8 @@ ext2_off_t ext2fs_file_get_size(ext2_file_t file)
 }
 
 /* Zero the parts of the last block that are past EOF. */
-errcode_t ext2fs_file_zero_past_offset(ext2_file_t file, ext2_off64_t offset)
+static errcode_t ext2fs_file_zero_past_offset(ext2_file_t file,
+                                             ext2_off64_t offset)
 {
        ext2_filsys fs = file->fs;
        char *b = NULL;
index 62a19b3..8a6273a 100644 (file)
@@ -272,8 +272,9 @@ retry:
                goto cleanup;
        }
 
-       if (super->s_feature_incompat & EXT4_FEATURE_INCOMPAT_64BIT)
-               super->s_desc_size = EXT2_MIN_DESC_SIZE_64BIT;
+       set_field(s_desc_size,
+                 super->s_feature_incompat & EXT4_FEATURE_INCOMPAT_64BIT ?
+                 EXT2_MIN_DESC_SIZE_64BIT : 0);
 
        fs->desc_blocks = ext2fs_div_ceil(fs->group_desc_count,
                                          EXT2_DESC_PER_BLOCK(super));
index 12bfc0f..afb825c 100644 (file)
@@ -144,7 +144,7 @@ errcode_t ext2fs_mmp_write(ext2_filsys fs, blk64_t mmp_blk, void *buf)
 #define rand()         random()
 #endif
 
-unsigned ext2fs_mmp_new_seq()
+unsigned ext2fs_mmp_new_seq(void)
 {
 #ifdef CONFIG_MMP
        unsigned new_seq;
index b2a8abb..cc8a90d 100644 (file)
@@ -289,7 +289,7 @@ errcode_t ext2fs_open2(const char *name, const char *io_options,
 
        /* Enforce the block group descriptor size */
        if (fs->super->s_feature_incompat & EXT4_FEATURE_INCOMPAT_64BIT) {
-               if (fs->super->s_desc_size != EXT2_MIN_DESC_SIZE_64BIT) {
+               if (fs->super->s_desc_size < EXT2_MIN_DESC_SIZE_64BIT) {
                        retval = EXT2_ET_BAD_DESC_SIZE;
                        goto cleanup;
                }
index 9fff704..25d7953 100644 (file)
@@ -410,10 +410,10 @@ errout:
  * Deallocate all logical blocks starting at start to end, inclusive.
  * If end is ~0, then this is effectively truncate.
  */
-extern errcode_t ext2fs_punch(ext2_filsys fs, ext2_ino_t ino,
-                             struct ext2_inode *inode,
-                             char *block_buf, blk64_t start,
-                             blk64_t end)
+errcode_t ext2fs_punch(ext2_filsys fs, ext2_ino_t ino,
+                      struct ext2_inode *inode,
+                      char *block_buf, blk64_t start,
+                      blk64_t end)
 {
        errcode_t               retval;
        struct ext2_inode       inode_buf;
index 1295e81..c308095 100644 (file)
@@ -103,6 +103,8 @@ void ext2fs_swap_super(struct ext2_super_block * sb)
 
 void ext2fs_swap_group_desc2(ext2_filsys fs, struct ext2_group_desc *gdp)
 {
+       struct ext4_group_desc *gdp4 = (struct ext4_group_desc *)gdp;
+
        /* Do the 32-bit parts first */
        gdp->bg_block_bitmap = ext2fs_swab32(gdp->bg_block_bitmap);
        gdp->bg_inode_bitmap = ext2fs_swab32(gdp->bg_inode_bitmap);
@@ -119,12 +121,10 @@ void ext2fs_swap_group_desc2(ext2_filsys fs, struct ext2_group_desc *gdp)
        gdp->bg_itable_unused = ext2fs_swab16(gdp->bg_itable_unused);
        gdp->bg_checksum = ext2fs_swab16(gdp->bg_checksum);
        /* If we're 32-bit, we're done */
-       if (fs && (!fs->super->s_desc_size ||
-                  (fs->super->s_desc_size < EXT2_MIN_DESC_SIZE_64BIT)))
+       if (fs == NULL || EXT2_DESC_SIZE(fs->super) < EXT2_MIN_DESC_SIZE_64BIT)
                return;
 
        /* Swap the 64-bit parts */
-       struct ext4_group_desc *gdp4 = (struct ext4_group_desc *) gdp;
        gdp4->bg_block_bitmap_hi = ext2fs_swab32(gdp4->bg_block_bitmap_hi);
        gdp4->bg_inode_bitmap_hi = ext2fs_swab32(gdp4->bg_inode_bitmap_hi);
        gdp4->bg_inode_table_hi = ext2fs_swab32(gdp4->bg_inode_table_hi);
index 781ba82..8d345a9 100644 (file)
@@ -20,8 +20,7 @@
 
 #include <stdarg.h>
 
-char * ss_name(sci_idx)
-    int sci_idx;
+char *ss_name(int sci_idx)
 {
     register char *ret_val;
     register ss_data *infop;
@@ -70,10 +69,7 @@ void ss_error (int sci_idx, long code, const char * fmt, ...)
     va_end(pvar);
 }
 
-void ss_perror (sci_idx, code, msg) /* for compatibility */
-    int sci_idx;
-    long code;
-    char const *msg;
+void ss_perror(int sci_idx, long code, char const *msg) /* for compatibility */
 {
     ss_error (sci_idx, code, "%s", msg);
 }
index 53c10c9..d443a46 100644 (file)
@@ -82,11 +82,8 @@ static struct _ss_request_entry * get_request (tbl, idx)
  * Notes:
  */
 
-static int check_request_table (rqtbl, argc, argv, sci_idx)
-    register ss_request_table *rqtbl;
-    int argc;
-    char *argv[];
-    int sci_idx;
+static int check_request_table(register ss_request_table *rqtbl, int argc,
+                              char *argv[], int sci_idx)
 {
 #ifdef __SABER__
     struct _ss_request_entry *request;
@@ -135,10 +132,7 @@ static int check_request_table (rqtbl, argc, argv, sci_idx)
  * Notes:
  */
 
-static int really_execute_command (sci_idx, argc, argv)
-    int sci_idx;
-    int argc;
-    char **argv[];
+static int really_execute_command(int sci_idx, int argc, char **argv[])
 {
     register ss_request_table **rqtbl;
     register ss_data *info;
@@ -168,9 +162,7 @@ static int really_execute_command (sci_idx, argc, argv)
  * Notes:
  */
 
-int ss_execute_command(sci_idx, argv)
-       int sci_idx;
-       register char *argv[];
+int ss_execute_command(int sci_idx, register char *argv[])
 {
        register int i, argc;
        char **argp;
@@ -202,9 +194,7 @@ int ss_execute_command(sci_idx, argv)
  * Notes:
  */
 
-int ss_execute_line (sci_idx, line_ptr)
-    int sci_idx;
-    char *line_ptr;
+int ss_execute_line(int sci_idx, char *line_ptr)
 {
     char **argv;
     int argc, ret;
index 5278c95..5204401 100644 (file)
@@ -36,11 +36,7 @@ extern int errno;
 #endif
 #include "ss_internal.h"
 
-void ss_help (argc, argv, sci_idx, info_ptr)
-    int argc;
-    char const * const *argv;
-    int sci_idx;
-    pointer info_ptr;
+void ss_help(int argc, char const * const *argv, int sci_idx, pointer info_ptr)
 {
     char *buffer;
     char const *request_name;
@@ -117,7 +113,7 @@ void ss_help (argc, argv, sci_idx, info_ptr)
        ss_page_stdin();
     default:
        (void) close(fd); /* what can we do if it fails? */
-       while (wait(0) != child) {
+       while (wait(NULL) != child) {
            /* do nothing if wrong pid */
        };
     }
@@ -129,10 +125,7 @@ void ss_help (argc, argv, sci_idx, info_ptr)
 #include <dirent.h>
 #endif
 
-void ss_add_info_dir(sci_idx, info_dir, code_ptr)
-    int sci_idx;
-    char *info_dir;
-    int *code_ptr;
+void ss_add_info_dir(int sci_idx, char *info_dir, int *code_ptr)
 {
     register ss_data *info;
     DIR *d;
@@ -166,10 +159,7 @@ void ss_add_info_dir(sci_idx, info_dir, code_ptr)
     *code_ptr = 0;
 }
 
-void ss_delete_info_dir(sci_idx, info_dir, code_ptr)
-    int sci_idx;
-    char *info_dir;
-    int *code_ptr;
+void ss_delete_info_dir(int sci_idx, char *info_dir, int *code_ptr)
 {
     register char **i_d;
     register char **info_dirs;
index 08b66f2..61c2e35 100644 (file)
 #endif
 #include <errno.h>
 
-int ss_create_invocation(subsystem_name, version_string, info_ptr,
-                        request_table_ptr, code_ptr)
-       const char *subsystem_name, *version_string;
-       void *info_ptr;
-       ss_request_table *request_table_ptr;
-       int *code_ptr;
+int ss_create_invocation(const char *subsystem_name, const char *version_string,
+                        void *info_ptr, ss_request_table *request_table_ptr,
+                        int *code_ptr)
 {
        register int sci_idx;
        register ss_data *new_table;
@@ -90,8 +87,7 @@ int ss_create_invocation(subsystem_name, version_string, info_ptr,
 }
 
 void
-ss_delete_invocation(sci_idx)
-       int sci_idx;
+ss_delete_invocation(int sci_idx)
 {
        register ss_data *t;
        int ignored_code;
index 8b54dd1..330249e 100644 (file)
@@ -42,7 +42,6 @@ extern int errno;
 #endif
 
 static char MORE[] = "more";
-extern char *_ss_pager_name;
 extern char *getenv PROTOTYPE((const char *));
 
 char *ss_safe_getenv(const char *arg)
@@ -131,7 +130,7 @@ static int write_all(int fd, char *buf, size_t count)
        return c;
 }
 
-void ss_page_stdin()
+void ss_page_stdin(void)
 {
        int i;
        sigset_t mask;
index baded66..e2928e2 100644 (file)
@@ -43,10 +43,7 @@ enum parse_mode { WHITESPACE, TOKEN, QUOTED_STRING };
 #define NEW_ARGV(old,n) (char **)realloc((char *)old,\
                                         (unsigned)(n+2)*sizeof(char*))
 
-char **ss_parse (sci_idx, line_ptr, argc_ptr)
-    int sci_idx;
-    register char *line_ptr;
-    int *argc_ptr;
+char **ss_parse(int sci_idx, register char *line_ptr, int *argc_ptr)
 {
     register char **argv, *cp;
     register int argc;
index efdabfa..135cb28 100644 (file)
 
 #define ssrt ss_request_table  /* for some readable code... */
 
-void ss_add_request_table(sci_idx, rqtbl_ptr, position, code_ptr)
-       int sci_idx;
-       ssrt *rqtbl_ptr;
-       int position;           /* 1 -> becomes second... */
-       int *code_ptr;
+void ss_add_request_table(int sci_idx, ssrt *rqtbl_ptr, int position, int *code_ptr)
 {
        register ss_data *info;
        register int i, size;
@@ -53,10 +49,7 @@ void ss_add_request_table(sci_idx, rqtbl_ptr, position, code_ptr)
        *code_ptr = 0;
 }
 
-void ss_delete_request_table(sci_idx, rqtbl_ptr, code_ptr)
-     int sci_idx;
-     ssrt *rqtbl_ptr;
-     int *code_ptr;
+void ss_delete_request_table(int sci_idx, ssrt *rqtbl_ptr, int *code_ptr)
 {
      register ss_data *info;
      register ssrt **rt1, **rt2;
index 15d618e..19a6be7 100644 (file)
@@ -94,6 +94,7 @@ char **ss_rl_completion(const char *text, int start, int end);
 
 extern ss_data **_ss_table;
 extern char *ss_et_msgs[];
+extern char *_ss_pager_name;
 
 #ifdef USE_SIGPROCMASK
 /* fake sigmask, sigblock, sigsetmask */
index a798f96..553c361 100644 (file)
@@ -33,7 +33,7 @@ SMANPAGES=    tune2fs.8 mklost+found.8 mke2fs.8 dumpe2fs.8 badblocks.8 \
                        e2label.8 $(FINDFS_MAN) $(BLKID_MAN) $(E2IMAGE_MAN) \
                        logsave.8 filefrag.8 e2freefrag.8 e2undo.8 \
                        $(UUIDD_MAN) $(E4DEFRAG_MAN) @FSCK_MAN@
-FMANPAGES=     mke2fs.conf.5
+FMANPAGES=     mke2fs.conf.5 ext4.5
 
 UPROGS=                chattr lsattr @UUID_CMT@ uuidgen
 UMANPAGES=     chattr.1 lsattr.1 @UUID_CMT@ uuidgen.1
@@ -356,6 +356,10 @@ mke2fs.conf.5: $(DEP_SUBSTITUTE) $(srcdir)/mke2fs.conf.5.in
        $(E) "  SUBST $@"
        $(Q) $(SUBSTITUTE_UPTIME) $(srcdir)/mke2fs.conf.5.in mke2fs.conf.5
 
+ext4.5: $(DEP_SUBSTITUTE) $(srcdir)/ext4.5.in
+       $(E) "  SUBST $@"
+       $(Q) $(SUBSTITUTE_UPTIME) $(srcdir)/$@.in $@
+
 e2label.8: $(DEP_SUBSTITUTE) $(srcdir)/e2label.8.in
        $(E) "  SUBST $@"
        $(Q) $(SUBSTITUTE_UPTIME) $(srcdir)/e2label.8.in e2label.8
@@ -489,6 +493,11 @@ install: all $(SMANPAGES) $(UMANPAGES) installdirs
                $(ES) " INSTALL_DATA $(man5dir)/$$i"; \
                $(INSTALL_DATA) $$i $(DESTDIR)$(man5dir)/$$i; \
        done
+       $(Q) for i in ext2 ext3; do \
+               $(ES) " LINK $$i.5"; \
+               (cd $(DESTDIR)$(man5dir); \
+                       $(LN) $(LINK_INSTALL_FLAGS) ext4.5 $$i.5); \
+       done
        $(Q) if test -f $(DESTDIR)$(root_sysconfdir)/mke2fs.conf; then \
                if cmp -s $(DESTDIR)$(root_sysconfdir)/mke2fs.conf \
                        mke2fs.conf; then \
@@ -551,7 +560,12 @@ uninstall:
        $(RM) -f $(DESTDIR)$(man8dir)/mkfs.ext2.8 \
                $(DESTDIR)$(man8dir)/mkfs.ext3.8 \
                $(DESTDIR)$(man8dir)/mkfs.ext4.8 \
-               $(DESTDIR)$(man8dir)/mkfs.ext4dev.8
+               $(DESTDIR)$(man8dir)/mkfs.ext4dev.8 \
+               $(DESTDIR)$(man8dir)/fsck.ext2.8 \
+               $(DESTDIR)$(man8dir)/fsck.ext3.8 \
+               $(DESTDIR)$(man8dir)/fsck.ext4.8 \
+               $(DESTDIR)$(man8dir)/fsck.ext4dev.8
+
        for i in $(UMANPAGES); do \
                $(RM) -f $(DESTDIR)$(man1dir)/$$i; \
        done
@@ -561,6 +575,10 @@ uninstall:
        for i in $(FMANPAGES); do \
                $(RM) -f $(DESTDIR)$(man5dir)/$$i; \
        done
+       $(Q) for i in ext2 ext3; do \
+               $(ES) " LINK $$i.5"; \
+               $(RM) -f $(DESTDIR)$(man5dir)/$$i.5; \
+       done
        if cmp -s mke2fs.conf $(DESTDIR)/$(root_sysconfdir)/mke2fs.conf; then \
                $(RM) $(DESTDIR)/$(root_sysconfdir)/mke2fs.conf; \
        fi
index 89f2439..912ef28 100644 (file)
 #define _GNU_SOURCE /* for O_DIRECT */
 #endif
 
-#ifndef O_LARGEFILE
-#define O_LARGEFILE 0
-#endif
-
 #include "config.h"
 #include <errno.h>
 #include <fcntl.h>
@@ -65,8 +61,12 @@ extern int optind;
 #include "ext2fs/ext2fs.h"
 #include "nls-enable.h"
 
-const char * program_name = "badblocks";
-const char * done_string = N_("done                                                 \n");
+#ifndef O_LARGEFILE
+#define O_LARGEFILE 0
+#endif
+
+static const char * program_name = "badblocks";
+static const char * done_string = N_("done                                                 \n");
 
 static int v_flag;                     /* verbose */
 static int w_flag;                     /* do r/w test: 0=no, 1=yes,
@@ -84,7 +84,7 @@ static struct timeval time_start;
 
 #define T_INC 32
 
-unsigned int sys_page_size = 4096;
+static unsigned int sys_page_size = 4096;
 
 static void usage(void)
 {
index a493789..befaf94 100644 (file)
@@ -82,5 +82,6 @@ http://e2fsprogs.sourceforge.net.
 .SH SEE ALSO
 .BR e2fsck (8),
 .BR mke2fs (8),
-.BR tune2fs (8)
+.BR tune2fs (8).
+.BR ext4 (5)
 
index 73555a9..ae54f8a 100644 (file)
@@ -45,10 +45,10 @@ extern int optind;
 
 #define in_use(m, x)   (ext2fs_test_bit ((x), (m)))
 
-const char * program_name = "dumpe2fs";
-char * device_name = NULL;
-int hex_format = 0;
-int blocks64 = 0;
+static const char * program_name = "dumpe2fs";
+static char * device_name = NULL;
+static int hex_format = 0;
+static int blocks64 = 0;
 
 static void usage(void)
 {
@@ -355,6 +355,8 @@ static void print_inline_journal_information(ext2_filsys fs)
        __u32                   *mask_ptr, mask, m;
        int                     i, j, size, printed = 0;
 
+       if (fs->flags & EXT2_FLAG_IMAGE_FILE)
+               return;
        retval = ext2fs_read_inode(fs, ino,  &inode);
        if (retval) {
                com_err(program_name, retval, "%s",
index 78f0682..71ada46 100644 (file)
@@ -8,7 +8,15 @@ e2image \- Save critical ext2/ext3/ext4 filesystem metadata to a file
 .SH SYNOPSIS
 .B e2image
 [
-.B \-rsIQa
+.B \-acfnprsIQ
+]
+[
+.B \-o
+.I source_offset
+]
+[
+.B \-O
+.I dest_offset
 ]
 .I device
 .I image-file
@@ -37,7 +45,7 @@ or
 options, the filesystem must be unmounted or be mounted read/only, in order
 for the image file to be in a consistent state.  This requirement can be
 overriden using the
-.B -f
+.B \-f
 option, but the resulting image file is very likely not going to be useful.
 .PP
 If
@@ -199,8 +207,53 @@ only includes fs metadata, not regular file data.  The
 option can be specified to include all data.  This will
 give an image that is suitable to use to clone the entire FS or
 for backup purposes.  Note that this option only works with the
-raw or QCOW2 formats.
+raw or QCOW2 formats.  The
+.B \-p
+switch may be given to show progress.  If the file system is being
+cloned to a flash-based storage device (where reads are very fast and
+where it is desirable to avoid unnecessary writes to reduce write wear
+on the device), the
+.B \-c
+option which cause e2image to try reading a block from the destination
+to see if it is identical to the block which
+.B e2image
+is about to copy.  If the block is already the same, the write can be
+skipped.  The
+.B \-n
+option will cause all of the writes to be no-ops, and print the blocks
+that would have been written.
+.PP
+.SH OFFSETS
+Normally a filesystem starts at the beginning of a partition, and
+.B e2image
+is run on the partition.  When working with image files, you don't
+have the option of using the partition device, so you can specify
+the offset where the filesystem starts directly with the
+.B \-o
+option.  Similarly the
+.B \-O
+option specifies the offset that should be seeked to in the destination
+before writing the filesystem.
+.PP
+For example, if you have a
+.B dd
+image of a whole hard drive that contains an ext2 fs in a partition
+starting at 1 MiB, you can clone that fs with:
+.PP
+.br
+\      \fBe2image \-aro 1048576 img /dev/sda1\fR
+.br
+.PP
+Or you can clone a fs into an image file, leaving room in the first
+MiB for a partition table with:
+.PP
+.br
+\      \fBe2image -arO 1048576 /dev/sda1 img\fR
+.br
 .PP
+If you specify at least one offset, and only one file, an in-place
+move will be performed, allowing you to safely move the filesystem
+from one offset to another.
 .SH AUTHOR
 .B e2image
 was written by Theodore Ts'o (tytso@mit.edu).
index 1bbe9c5..178d374 100644 (file)
@@ -35,6 +35,7 @@ extern int optind;
 #include <sys/stat.h>
 #include <sys/types.h>
 #include <assert.h>
+#include <signal.h>
 
 #include "ext2fs/ext2_fs.h"
 #include "ext2fs/ext2fs.h"
@@ -48,23 +49,33 @@ extern int optind;
 #include "nls-enable.h"
 
 #define QCOW_OFLAG_COPIED     (1LL << 63)
-
-
-const char * program_name = "e2image";
-char * device_name = NULL;
-char all_data;
-char output_is_blk;
+#define NO_BLK ((blk64_t) -1)
+
+/* Image types */
+#define E2IMAGE_RAW    1
+#define E2IMAGE_QCOW2  2
+
+/* Image flags */
+#define E2IMAGE_INSTALL_FLAG   1
+#define E2IMAGE_SCRAMBLE_FLAG  2
+#define E2IMAGE_IS_QCOW2_FLAG  4
+#define E2IMAGE_CHECK_ZERO_FLAG        8
+
+static const char * program_name = "e2image";
+static char * device_name = NULL;
+static char all_data;
+static char output_is_blk;
+static char nop_flag;
 /* writing to blk device: don't skip zeroed blocks */
+static blk64_t source_offset, dest_offset;
+static char move_mode;
+static char show_progress;
+static char *check_buf;
+static int skipped_blocks;
 
-static void lseek_error_and_exit(int errnum)
-{
-       fprintf(stderr, "seek: %s\n", error_message(errnum));
-       exit(1);
-}
-
-static blk64_t align_offset(blk64_t offset, int n)
+static blk64_t align_offset(blk64_t offset, unsigned int n)
 {
-       return (offset + n - 1) & ~(n - 1);
+       return (offset + n - 1) & ~((blk64_t) n - 1);
 }
 
 static int get_bits_from_size(size_t size)
@@ -87,11 +98,58 @@ static int get_bits_from_size(size_t size)
 
 static void usage(void)
 {
-       fprintf(stderr, _("Usage: %s [-rsIQaf] device image_file\n"),
+       fprintf(stderr, _("Usage: %s [-acfnprsIQ] [-o src_offset] "
+                         "[-O dest_offset] \\\n\tdevice image_file\n"),
                program_name);
        exit (1);
 }
 
+static ext2_loff_t seek_relative(int fd, int offset)
+{
+       ext2_loff_t ret = ext2fs_llseek(fd, offset, SEEK_CUR);
+       if (ret < 0) {
+               perror("seek_relative");
+               exit(1);
+       }
+       return ret;
+}
+
+static ext2_loff_t seek_set(int fd, ext2_loff_t offset)
+{
+       ext2_loff_t ret = ext2fs_llseek(fd, offset, SEEK_SET);
+       if (ret < 0) {
+               perror("seek_set");
+               exit(1);
+       }
+       return ret;
+}
+
+/*
+ * Returns true if the block we are about to write is identical to
+ * what is already on the disk.
+ */
+static int check_block(int fd, void *buf, void *cbuf, int blocksize)
+{
+       char *cp = cbuf;
+       int count = blocksize, ret;
+
+       if (cbuf == NULL)
+               return 0;
+
+       while (count > 0) {
+               ret = read(fd, cp, count);
+               if (ret < 0) {
+                       perror("check_block");
+                       exit(1);
+               }
+               count -= ret;
+               cp += ret;
+       }
+       ret = memcmp(buf, cbuf, blocksize);
+       seek_relative(fd, -blocksize);
+       return (ret == 0) ? 1 : 0;
+}
+
 static void generic_write(int fd, void *buf, int blocksize, blk64_t block)
 {
        int count, free_buf = 0;
@@ -104,11 +162,16 @@ static void generic_write(int fd, void *buf, int blocksize, blk64_t block)
                free_buf = 1;
                err = ext2fs_get_arrayzero(1, blocksize, &buf);
                if (err) {
-                       com_err(program_name, err, "while allocating buffer");
+                       com_err(program_name, err,
+                               _("while allocating buffer"));
                        exit(1);
                }
        }
-
+       if (nop_flag) {
+               printf(_("Writing block %llu\n"), (unsigned long long) block);
+               seek_relative(fd, blocksize);
+               return;
+       }
        count = write(fd, buf, blocksize);
        if (count != blocksize) {
                if (count == -1)
@@ -117,10 +180,10 @@ static void generic_write(int fd, void *buf, int blocksize, blk64_t block)
                        err = 0;
 
                if (block)
-                       com_err(program_name, err, "error writing block %llu",
-                               block);
+                       com_err(program_name, err,
+                               _("error writing block %llu"), block);
                else
-                       com_err(program_name, err, "error in write()");
+                       com_err(program_name, err, _("error in write()"));
 
                exit(1);
        }
@@ -145,16 +208,13 @@ static void write_header(int fd, void *hdr, int hdr_size, int wrt_size)
                exit(1);
        }
 
-       if (ext2fs_llseek(fd, 0, SEEK_SET) < 0) {
-               perror("ext2fs_llseek while writing header");
-               exit(1);
-       }
+       seek_set(fd, 0);
        memset(header_buf, 0, wrt_size);
 
        if (hdr)
                memcpy(header_buf, hdr, hdr_size);
 
-       generic_write(fd, header_buf, wrt_size, 0);
+       generic_write(fd, header_buf, wrt_size, NO_BLK);
 
        ext2fs_free_mem(&header_buf);
 }
@@ -168,7 +228,7 @@ static void write_image_file(ext2_filsys fs, int fd)
        write_header(fd, NULL, sizeof(struct ext2_image_hdr), fs->blocksize);
        memset(&hdr, 0, sizeof(struct ext2_image_hdr));
 
-       hdr.offset_super = ext2fs_llseek(fd, 0, SEEK_CUR);
+       hdr.offset_super = seek_relative(fd, 0);
        retval = ext2fs_image_super_write(fs, fd, 0);
        if (retval) {
                com_err(program_name, retval, "%s",
@@ -176,7 +236,7 @@ static void write_image_file(ext2_filsys fs, int fd)
                exit(1);
        }
 
-       hdr.offset_inode = ext2fs_llseek(fd, 0, SEEK_CUR);
+       hdr.offset_inode = seek_relative(fd, 0);
        retval = ext2fs_image_inode_write(fs, fd,
                                  (fd != 1) ? IMAGER_FLAG_SPARSEWRITE : 0);
        if (retval) {
@@ -185,7 +245,7 @@ static void write_image_file(ext2_filsys fs, int fd)
                exit(1);
        }
 
-       hdr.offset_blockmap = ext2fs_llseek(fd, 0, SEEK_CUR);
+       hdr.offset_blockmap = seek_relative(fd, 0);
        retval = ext2fs_image_bitmap_write(fs, fd, 0);
        if (retval) {
                com_err(program_name, retval, "%s",
@@ -193,7 +253,7 @@ static void write_image_file(ext2_filsys fs, int fd)
                exit(1);
        }
 
-       hdr.offset_inodemap = ext2fs_llseek(fd, 0, SEEK_CUR);
+       hdr.offset_inodemap = seek_relative(fd, 0);
        retval = ext2fs_image_bitmap_write(fs, fd, IMAGER_FLAG_INODEMAP);
        if (retval) {
                com_err(program_name, retval, "%s",
@@ -224,9 +284,9 @@ static void write_image_file(ext2_filsys fs, int fd)
 /*
  * These set of functions are used to write a RAW image file.
  */
-ext2fs_block_bitmap meta_block_map;
-ext2fs_block_bitmap scramble_block_map;        /* Directory blocks to be scrambled */
-blk64_t meta_blocks_count;
+static ext2fs_block_bitmap meta_block_map;
+static ext2fs_block_bitmap scramble_block_map; /* Directory blocks to be scrambled */
+static blk64_t meta_blocks_count;
 
 struct process_block_struct {
        ext2_ino_t      ino;
@@ -404,20 +464,7 @@ static int check_zero_block(char *buf, int blocksize)
        return 1;
 }
 
-static void write_block(int fd, char *buf, int sparse_offset,
-                       int blocksize, blk64_t block)
-{
-       ext2_loff_t     ret = 0;
-
-       if (sparse_offset)
-               ret = ext2fs_llseek(fd, sparse_offset, SEEK_CUR);
-
-       if (ret < 0)
-               lseek_error_and_exit(errno);
-       generic_write(fd, buf, blocksize, block);
-}
-
-int name_id[256];
+static int name_id[256];
 
 #define EXT4_MAX_REC_LEN               ((1<<16)-1)
 
@@ -444,9 +491,9 @@ static void scramble_dir_block(ext2_filsys fs, blk64_t blk, char *buf)
 #endif
                if (rec_len < 8 || (rec_len % 4) ||
                    (p+rec_len > end)) {
-                       printf("Corrupt directory block %lu: "
-                              "bad rec_len (%d)\n", (unsigned long) blk,
-                              rec_len);
+                       printf(_("Corrupt directory block %llu: "
+                                "bad rec_len (%d)\n"),
+                              (unsigned long long) blk, rec_len);
                        rec_len = end - p;
                        (void) ext2fs_set_rec_len(fs, rec_len,
                                        (struct ext2_dir_entry *) dirent);
@@ -456,9 +503,9 @@ static void scramble_dir_block(ext2_filsys fs, blk64_t blk, char *buf)
                        continue;
                }
                if (dirent->name_len + 8U > rec_len) {
-                       printf("Corrupt directory block %lu: "
-                              "bad name_len (%d)\n", (unsigned long) blk,
-                              dirent->name_len);
+                       printf(_("Corrupt directory block %llu: "
+                                "bad name_len (%d)\n"),
+                              (unsigned long long) blk, dirent->name_len);
                        dirent->name_len = rec_len - 8;
                        continue;
                }
@@ -483,64 +530,203 @@ static void scramble_dir_block(ext2_filsys fs, blk64_t blk, char *buf)
        }
 }
 
-static void output_meta_data_blocks(ext2_filsys fs, int fd)
+static char got_sigint;
+
+static void sigint_handler(int unused EXT2FS_ATTR((unused)))
+{
+       got_sigint = 1;
+       signal (SIGINT, SIG_DFL);
+}
+
+static void output_meta_data_blocks(ext2_filsys fs, int fd, int flags)
 {
        errcode_t       retval;
        blk64_t         blk;
        char            *buf, *zero_buf;
        int             sparse = 0;
+       blk64_t         start = 0;
+       blk64_t         distance = 0;
+       blk64_t         end = ext2fs_blocks_count(fs->super);
+       time_t          last_update = 0;
+       time_t          start_time = 0;
+       blk64_t         total_written = 0;
+       int             bscount = 0;
 
        retval = ext2fs_get_mem(fs->blocksize, &buf);
        if (retval) {
-               com_err(program_name, retval, "while allocating buffer");
+               com_err(program_name, retval, _("while allocating buffer"));
                exit(1);
        }
        retval = ext2fs_get_memzero(fs->blocksize, &zero_buf);
        if (retval) {
-               com_err(program_name, retval, "while allocating buffer");
+               com_err(program_name, retval, _("while allocating buffer"));
                exit(1);
        }
-       for (blk = 0; blk < ext2fs_blocks_count(fs->super); blk++) {
+       if (show_progress) {
+               printf(_("Copying "));
+               bscount = printf(_("%llu / %llu blocks (%llu%%)"),
+                                total_written,
+                                meta_blocks_count,
+                                (total_written + 50) / ((meta_blocks_count + 50) / 100));
+               fflush(stdout);
+               last_update = time(NULL);
+               start_time = time(NULL);
+       }
+       /* when doing an in place move to the right, you can't start
+          at the beginning or you will overwrite data, so instead
+          divide the fs up into distance size chunks and write them
+          in reverse. */
+       if (move_mode && dest_offset > source_offset) {
+               distance = (dest_offset - source_offset) / fs->blocksize;
+               if (distance < ext2fs_blocks_count(fs->super))
+                       start = ext2fs_blocks_count(fs->super) - distance;
+       }
+       if (move_mode)
+               signal (SIGINT, sigint_handler);
+more_blocks:
+       if (distance)
+               seek_set(fd, (start * fs->blocksize) + dest_offset);
+       for (blk = start; blk < end; blk++) {
+               if (got_sigint) {
+                       if (distance) {
+                               /* moving to the right */
+                               if (distance >= ext2fs_blocks_count(fs->super) ||
+                                   start == ext2fs_blocks_count(fs->super) - distance)
+                                       kill (getpid(), SIGINT);
+                       } else {
+                               /* moving to the left */
+                               if (blk < (source_offset - dest_offset) / fs->blocksize)
+                                       kill (getpid(), SIGINT);
+                       }
+                       if (show_progress)
+                               printf ("\r");
+                       printf(_("Stopping now will destroy the filesystem, "
+                                "interrupt again if you are sure\n"));
+                       if (show_progress) {
+                               printf(_("Copying "));
+                               bscount = printf(_("%llu / %llu blocks (%llu%%)"),
+                                                total_written,
+                                                meta_blocks_count,
+                                                (total_written + 50) / ((meta_blocks_count + 50)
+                                                                        / 100));
+                               fflush(stdout);
+                       }
+
+                       got_sigint = 0;
+               }
+               if (show_progress && last_update != time(NULL)) {
+                       time_t duration;
+                       last_update = time(NULL);
+                       while (bscount--)
+                               printf("\b");
+                       bscount = printf(_("%llu / %llu blocks (%llu%%)"),
+                                        total_written,
+                                        meta_blocks_count,
+                                        (total_written + 50) /
+                                        ((meta_blocks_count + 50) / 100));
+                       duration = time(NULL) - start_time;
+                       if (duration > 5) {
+                               time_t est = (duration *
+                                             meta_blocks_count / total_written) -
+                                       (duration);
+                               char buff[30];
+                               strftime(buff, 30, "%T", gmtime(&est));
+                               bscount += printf(_(" %s remaining at %.2f MB/s"),
+                                                 buff,
+                                                 ((float)total_written /
+                                                  ((1024 * 1024) / fs->blocksize)) /
+                                                 duration);
+                       }
+                       fflush (stdout);
+               }
                if ((blk >= fs->super->s_first_data_block) &&
                    ext2fs_test_block_bitmap2(meta_block_map, blk)) {
                        retval = io_channel_read_blk64(fs->io, blk, 1, buf);
                        if (retval) {
                                com_err(program_name, retval,
-                                       "error reading block %llu", blk);
+                                       _("error reading block %llu"), blk);
                        }
+                       total_written++;
                        if (scramble_block_map &&
                            ext2fs_test_block_bitmap2(scramble_block_map, blk))
                                scramble_dir_block(fs, blk, buf);
-                       if ((fd != 1) && check_zero_block(buf, fs->blocksize))
+                       if ((flags & E2IMAGE_CHECK_ZERO_FLAG) &&
+                           check_zero_block(buf, fs->blocksize))
                                goto sparse_write;
-                       write_block(fd, buf, sparse, fs->blocksize, blk);
+                       if (sparse)
+                               seek_relative(fd, sparse);
                        sparse = 0;
+                       if (check_block(fd, buf, check_buf, fs->blocksize)) {
+                               seek_relative(fd, fs->blocksize);
+                               skipped_blocks++;
+                       } else
+                               generic_write(fd, buf, fs->blocksize, blk);
                } else {
                sparse_write:
                        if (fd == 1) {
-                               write_block(fd, zero_buf, 0,
-                                           fs->blocksize, blk);
+                               generic_write(fd, zero_buf, fs->blocksize, blk);
                                continue;
                        }
                        sparse += fs->blocksize;
                        if (sparse > 1024*1024) {
-                               write_block(fd, 0, 1024*1024, 0, 0);
+                               seek_relative(fd, 1024*1024);
                                sparse -= 1024*1024;
                        }
                }
        }
+       if (distance && start) {
+               if (start < distance) {
+                       end = start;
+                       start = 0;
+               } else {
+                       end -= distance;
+                       start -= distance;
+                       if (end < distance) {
+                               /* past overlap, do rest in one go */
+                               end = start;
+                               start = 0;
+                       }
+               }
+               sparse = 0;
+               goto more_blocks;
+       }
+       signal (SIGINT, SIG_DFL);
+       if (show_progress) {
+               time_t duration = time(NULL) - start_time;
+               char buff[30];
+               while (bscount--)
+                       printf("\b");
+               strftime(buff, 30, "%T", gmtime(&duration));
+               printf(_("\b\b\b\b\b\b\b\bCopied %llu / %llu blocks (%llu%%) "
+                        "in %s at %.2f MB/s       \n"),
+                      total_written,
+                      meta_blocks_count,
+                      (total_written + 50) / ((meta_blocks_count + 50) / 100),
+                      buff,
+                      ((float)total_written /
+                       ((1024 * 1024) / fs->blocksize)) /
+                      duration);
+
+       }
 #ifdef HAVE_FTRUNCATE64
        if (sparse) {
-               ext2_loff_t offset = ext2fs_llseek(fd, sparse, SEEK_CUR);
+               ext2_loff_t offset;
+               if (distance)
+                       offset = seek_set(fd,
+                                         fs->blocksize * ext2fs_blocks_count(fs->super) + dest_offset);
+               else
+                       offset = seek_relative(fd, sparse);
 
-               if (offset < 0)
-                       lseek_error_and_exit(errno);
-               if (ftruncate64(fd, offset) < 0)
-                       write_block(fd, zero_buf, -1, 1, -1);
+               if (ftruncate64(fd, offset) < 0) {
+                       seek_relative(fd, -1);
+                       generic_write(fd, zero_buf, 1, NO_BLK);
+               }
        }
 #else
-       if (sparse)
-               write_block(fd, zero_buf, sparse-1, 1, -1);
+       if (sparse && !distance) {
+               seek_relative(fd, sparse-1);
+               generic_write(fd, zero_buf, 1, NO_BLK);
+       }
 #endif
        ext2fs_free_mem(&zero_buf);
        ext2fs_free_mem(&buf);
@@ -553,7 +739,7 @@ static void init_l1_table(struct ext2_qcow2_image *image)
 
        ret = ext2fs_get_arrayzero(image->l1_size, sizeof(__u64), &l1_table);
        if (ret) {
-               com_err(program_name, ret, "while allocating l1 table");
+               com_err(program_name, ret, _("while allocating l1 table"));
                exit(1);
        }
 
@@ -598,7 +784,7 @@ static void init_l2_cache(struct ext2_qcow2_image *image)
        return;
 
 alloc_err:
-       com_err(program_name, ret, "while allocating l2 cache");
+       com_err(program_name, ret, _("while allocating l2 cache"));
        exit(1);
 }
 
@@ -621,9 +807,9 @@ again:
        }
 
        if (cache->free != cache->count) {
-               fprintf(stderr, "Warning: There are still tables in the "
-                               "cache while putting the cache, data will "
-                               "be lost so the image may not be valid.\n");
+               fprintf(stderr, _("Warning: There are still tables in the "
+                                 "cache while putting the cache, data will "
+                                 "be lost so the image may not be valid.\n"));
                table = cache->used_head;
                cache->used_head = NULL;
                goto again;
@@ -795,25 +981,23 @@ static void flush_l2_cache(struct ext2_qcow2_image *image)
        int fd = image->fd;
 
        /* Store current position */
-       if ((offset = ext2fs_llseek(fd, 0, SEEK_CUR)) < 0)
-               lseek_error_and_exit(errno);
+       offset = seek_relative(fd, 0);
 
        assert(table);
        while (cache->free < cache->count) {
                if (seek != table->offset) {
-                       if (ext2fs_llseek(fd, table->offset, SEEK_SET) < 0)
-                               lseek_error_and_exit(errno);
+                       seek_set(fd, table->offset);
                        seek = table->offset;
                }
 
-               generic_write(fd, (char *)table->data, image->cluster_size , 0);
+               generic_write(fd, (char *)table->data, image->cluster_size,
+                             NO_BLK);
                put_used_table(image, &table);
                seek += image->cluster_size;
        }
 
        /* Restore previous position */
-       if (ext2fs_llseek(fd, offset, SEEK_SET) < 0)
-               lseek_error_and_exit(errno);
+       seek_set(fd, offset);
 }
 
 /**
@@ -890,11 +1074,10 @@ static int update_refcount(int fd, struct ext2_qcow2_image *img,
         */
        if (table_index != ref->refcount_table_index) {
 
-               if (ext2fs_llseek(fd, ref->refcount_block_offset, SEEK_SET) < 0)
-                       lseek_error_and_exit(errno);
+               seek_set(fd, ref->refcount_block_offset);
 
                generic_write(fd, (char *)ref->refcount_block,
-                             img->cluster_size, 0);
+                             img->cluster_size, NO_BLK);
                memset(ref->refcount_block, 0, img->cluster_size);
 
                ref->refcount_table[ref->refcount_table_index] =
@@ -923,14 +1106,13 @@ static int sync_refcount(int fd, struct ext2_qcow2_image *img)
 
        ref->refcount_table[ref->refcount_table_index] =
                ext2fs_cpu_to_be64(ref->refcount_block_offset);
-       if (ext2fs_llseek(fd, ref->refcount_table_offset, SEEK_SET) < 0)
-               lseek_error_and_exit(errno);
+       seek_set(fd, ref->refcount_table_offset);
        generic_write(fd, (char *)ref->refcount_table,
-               ref->refcount_table_clusters << img->cluster_bits, 0);
+               ref->refcount_table_clusters << img->cluster_bits, NO_BLK);
 
-       if (ext2fs_llseek(fd, ref->refcount_block_offset, SEEK_SET) < 0)
-               lseek_error_and_exit(errno);
-       generic_write(fd, (char *)ref->refcount_block, img->cluster_size, 0);
+       seek_set(fd, ref->refcount_block_offset);
+       generic_write(fd, (char *)ref->refcount_block, img->cluster_size,
+                     NO_BLK);
        return 0;
 }
 
@@ -946,14 +1128,14 @@ static void output_qcow2_meta_data_blocks(ext2_filsys fs, int fd)
        retval = ext2fs_get_mem(sizeof(struct ext2_qcow2_image), &img);
        if (retval) {
                com_err(program_name, retval,
-                       "while allocating ext2_qcow2_image");
+                       _("while allocating ext2_qcow2_image"));
                exit(1);
        }
 
        retval = initialize_qcow2_image(fd, fs, img);
        if (retval) {
                com_err(program_name, retval,
-                       "while initializing ext2_qcow2_image");
+                       _("while initializing ext2_qcow2_image"));
                exit(1);
        }
        header_size = align_offset(sizeof(struct ext2_qcow2_hdr),
@@ -962,8 +1144,7 @@ static void output_qcow2_meta_data_blocks(ext2_filsys fs, int fd)
 
        /* Refcount all qcow2 related metadata up to refcount_block_offset */
        end = img->refcount.refcount_block_offset;
-       if (ext2fs_llseek(fd, end, SEEK_SET) < 0)
-               lseek_error_and_exit(errno);
+       seek_set(fd, end);
        blk = end + img->cluster_size;
        for (offset = 0; offset <= end; offset += img->cluster_size) {
                if (update_refcount(fd, img, offset, blk)) {
@@ -975,12 +1156,11 @@ static void output_qcow2_meta_data_blocks(ext2_filsys fs, int fd)
                        end += img->cluster_size;
                }
        }
-       if (ext2fs_llseek(fd, offset, SEEK_SET) < 0)
-               lseek_error_and_exit(errno);
+       seek_set(fd, offset);
 
        retval = ext2fs_get_mem(fs->blocksize, &buf);
        if (retval) {
-               com_err(program_name, retval, "while allocating buffer");
+               com_err(program_name, retval, _("while allocating buffer"));
                exit(1);
        }
        /* Write qcow2 data blocks */
@@ -990,7 +1170,7 @@ static void output_qcow2_meta_data_blocks(ext2_filsys fs, int fd)
                        retval = io_channel_read_blk64(fs->io, blk, 1, buf);
                        if (retval) {
                                com_err(program_name, retval,
-                                       "error reading block %llu", blk);
+                                       _("error reading block %llu"), blk);
                                continue;
                        }
                        if (scramble_block_map &&
@@ -1002,8 +1182,7 @@ static void output_qcow2_meta_data_blocks(ext2_filsys fs, int fd)
                        if (update_refcount(fd, img, offset, offset)) {
                                /* Make space for another refcount block */
                                offset += img->cluster_size;
-                               if (ext2fs_llseek(fd, offset, SEEK_SET) < 0)
-                                       lseek_error_and_exit(errno);
+                               seek_set(fd, offset);
                                /*
                                 * We have created the new refcount block, this
                                 * means that we need to refcount it as well.
@@ -1013,14 +1192,14 @@ static void output_qcow2_meta_data_blocks(ext2_filsys fs, int fd)
                                 * block should not be created!
                                 */
                                if (update_refcount(fd, img, offset, offset)) {
-                                       fprintf(stderr, "Programming error: "
+                                       fprintf(stderr, _("Programming error: "
                                                "multiple sequential refcount "
-                                               "blocks created!\n");
+                                               "blocks created!\n"));
                                        exit(1);
                                }
                        }
 
-                       generic_write(fd, buf, fs->blocksize, 0);
+                       generic_write(fd, buf, fs->blocksize, blk);
 
                        if (add_l2_item(img, blk, offset,
                                        offset + img->cluster_size)) {
@@ -1031,14 +1210,13 @@ static void output_qcow2_meta_data_blocks(ext2_filsys fs, int fd)
                                        if (update_refcount(fd, img, offset,
                                                            offset)) {
                                                fprintf(stderr,
-                       "Programming error: multiple sequential refcount "
-                       "blocks created!\n");
+                       _("Programming error: multiple sequential refcount "
+                         "blocks created!\n"));
                                                exit(1);
                                        }
                                }
                                offset += img->cluster_size;
-                               if (ext2fs_llseek(fd, offset, SEEK_SET) < 0)
-                                       lseek_error_and_exit(errno);
+                               seek_set(fd, offset);
                                continue;
                        }
 
@@ -1050,10 +1228,9 @@ static void output_qcow2_meta_data_blocks(ext2_filsys fs, int fd)
        sync_refcount(fd, img);
 
        /* Write l1_table*/
-       if (ext2fs_llseek(fd, img->l1_offset, SEEK_SET) < 0)
-               lseek_error_and_exit(errno);
+       seek_set(fd, img->l1_offset);
        size = img->l1_size * sizeof(__u64);
-       generic_write(fd, (char *)img->l1_table, size, 0);
+       generic_write(fd, (char *)img->l1_table, size, NO_BLK);
 
        ext2fs_free_mem(&buf);
        free_qcow2_image(img);
@@ -1069,10 +1246,11 @@ static void write_raw_image_file(ext2_filsys fs, int fd, int type, int flags)
        char *                          block_buf;
 
        meta_blocks_count = 0;
-       retval = ext2fs_allocate_block_bitmap(fs, "in-use block map",
+       retval = ext2fs_allocate_block_bitmap(fs, _("in-use block map"),
                                              &meta_block_map);
        if (retval) {
-               com_err(program_name, retval, "while allocating block bitmap");
+               com_err(program_name, retval,
+                       _("while allocating block bitmap"));
                exit(1);
        }
 
@@ -1081,12 +1259,14 @@ static void write_raw_image_file(ext2_filsys fs, int fd, int type, int flags)
                                                      &scramble_block_map);
                if (retval) {
                        com_err(program_name, retval,
-                               "while allocating scramble block bitmap");
+                               _("while allocating scramble block bitmap"));
                        exit(1);
                }
        }
 
        mark_table_blocks(fs);
+       if (show_progress)
+               printf(_("Scanning inodes...\n"));
 
        retval = ext2fs_open_inode_scan(fs, 0, &scan);
        if (retval) {
@@ -1137,7 +1317,7 @@ static void write_raw_image_file(ext2_filsys fs, int fd, int type, int flags)
                                        process_dir_block, &pb);
                        if (retval) {
                                com_err(program_name, retval,
-                                       "while iterating over inode %u",
+                                       _("while iterating over inode %u"),
                                        ino);
                                exit(1);
                        }
@@ -1151,7 +1331,7 @@ static void write_raw_image_file(ext2_filsys fs, int fd, int type, int flags)
                                       process_file_block, &pb);
                                if (retval) {
                                        com_err(program_name, retval,
-                                       "while iterating over inode %u", ino);
+                                       _("while iterating over inode %u"), ino);
                                        exit(1);
                                }
                        }
@@ -1162,7 +1342,7 @@ static void write_raw_image_file(ext2_filsys fs, int fd, int type, int flags)
        if (type & E2IMAGE_QCOW2)
                output_qcow2_meta_data_blocks(fs, fd);
        else
-               output_meta_data_blocks(fs, fd);
+               output_meta_data_blocks(fs, fd, flags);
 
        ext2fs_free_mem(&block_buf);
        ext2fs_close_inode_scan(scan);
@@ -1181,8 +1361,8 @@ static void install_image(char *device, char *image_fn, int type)
        io_channel      io;
 
        if (type) {
-               com_err(program_name, 0, "Raw and qcow2 images cannot"
-                       "be installed");
+               com_err(program_name, 0, _("Raw and qcow2 images cannot"
+                                          "be installed"));
                exit(1);
        }
 
@@ -1204,7 +1384,7 @@ static void install_image(char *device, char *image_fn, int type)
 
        retval = ext2fs_read_bitmaps (fs);
        if (retval) {
-               com_err(program_name, retval, "error reading bitmaps");
+               com_err(program_name, retval, _("error reading bitmaps"));
                exit(1);
        }
 
@@ -1216,16 +1396,13 @@ static void install_image(char *device, char *image_fn, int type)
 
        retval = io_ptr->open(device, IO_FLAG_RW, &io);
        if (retval) {
-               com_err(device, 0, "while opening device file");
+               com_err(device, 0, _("while opening device file"));
                exit(1);
        }
 
        ext2fs_rewrite_to_io(fs, io);
 
-       if (ext2fs_llseek(fd, fs->image_header->offset_inode, SEEK_SET) < 0) {
-               perror("ext2fs_llseek");
-               exit(1);
-       }
+       seek_set(fd, fs->image_header->offset_inode);
 
        retval = ext2fs_image_inode_read(fs, fd, 0);
        if (retval) {
@@ -1252,7 +1429,7 @@ int main (int argc, char ** argv)
        int c;
        errcode_t retval;
        ext2_filsys fs;
-       char *image_fn;
+       char *image_fn, offset_opt[64];
        struct ext2_qcow2_hdr *header = NULL;
        int open_flag = EXT2_FLAG_64BITS;
        int img_type = 0;
@@ -1262,6 +1439,7 @@ int main (int argc, char ** argv)
        int fd = 0;
        int ret = 0;
        int ignore_rw_mount = 0;
+       int check = 0;
        struct stat st;
 
 #ifdef ENABLE_NLS
@@ -1276,7 +1454,7 @@ int main (int argc, char ** argv)
        if (argc && *argv)
                program_name = *argv;
        add_error_table(&et_ext2_error_table);
-       while ((c = getopt(argc, argv, "rsIQaf")) != EOF)
+       while ((c = getopt(argc, argv, "nrsIQafo:O:pc")) != EOF)
                switch (c) {
                case 'I':
                        flags |= E2IMAGE_INSTALL_FLAG;
@@ -1300,35 +1478,69 @@ int main (int argc, char ** argv)
                case 'f':
                        ignore_rw_mount = 1;
                        break;
+               case 'n':
+                       nop_flag = 1;
+                       break;
+               case 'o':
+                       source_offset = strtoull(optarg, NULL, 0);
+                       break;
+               case 'O':
+                       dest_offset = strtoull(optarg, NULL, 0);
+                       break;
+               case 'p':
+                       show_progress = 1;
+                       break;
+               case 'c':
+                       check = 1;
+                       break;
                default:
                        usage();
                }
-       if (optind != argc - 2 )
+       if (optind == argc - 1 &&
+           (source_offset || dest_offset))
+                   move_mode = 1;
+       else if (optind != argc - 2 )
                usage();
 
        if (all_data && !img_type) {
-               com_err(program_name, 0, "-a option can only be used "
-                                        "with raw or QCOW2 images.");
+               com_err(program_name, 0, _("-a option can only be used "
+                                          "with raw or QCOW2 images."));
+               exit(1);
+       }
+       if ((source_offset || dest_offset) && img_type != E2IMAGE_RAW) {
+               com_err(program_name, 0,
+                       _("Offsets are only allowed with raw images."));
+               exit(1);
+       }
+       if (move_mode && img_type != E2IMAGE_RAW) {
+               com_err(program_name, 0,
+                       _("Move mode is only allowed with raw images."));
+               exit(1);
+       }
+       if (move_mode && !all_data) {
+               com_err(program_name, 0,
+                       _("Move mode requires all data mode."));
                exit(1);
        }
-
        device_name = argv[optind];
-       image_fn = argv[optind+1];
+       if (move_mode)
+               image_fn = device_name;
+       else image_fn = argv[optind+1];
 
        retval = ext2fs_check_if_mounted(device_name, &mount_flags);
        if (retval) {
-               com_err(program_name, retval, "checking if mounted");
+               com_err(program_name, retval, _("checking if mounted"));
                exit(1);
        }
 
        if (img_type && !ignore_rw_mount &&
            (mount_flags & EXT2_MF_MOUNTED) &&
           !(mount_flags & EXT2_MF_READONLY)) {
-               fprintf(stderr, "\nRunning e2image on a R/W mounted "
+               fprintf(stderr, _("\nRunning e2image on a R/W mounted "
                        "filesystem can result in an\n"
                        "inconsistent image which will not be useful "
                        "for debugging purposes.\n"
-                       "Use -f option if you really want to do that.\n");
+                       "Use -f option if you really want to do that.\n"));
                exit(1);
        }
 
@@ -1344,8 +1556,8 @@ int main (int argc, char ** argv)
                        goto skip_device;
                }
        }
-
-       retval = ext2fs_open (device_name, open_flag, 0, 0,
+       sprintf(offset_opt, "offset=%llu", source_offset);
+       retval = ext2fs_open2(device_name, offset_opt, open_flag, 0, 0,
                              unix_io_manager, &fs);
         if (retval) {
                com_err (program_name, retval, _("while trying to open %s"),
@@ -1358,17 +1570,25 @@ skip_device:
        if (strcmp(image_fn, "-") == 0)
                fd = 1;
        else {
-               fd = ext2fs_open_file(image_fn, O_CREAT|O_TRUNC|O_WRONLY, 0600);
+               int o_flags = O_CREAT|O_RDWR;
+
+               if (img_type != E2IMAGE_RAW)
+                       o_flags |= O_TRUNC;
+               if (access(image_fn, F_OK) != 0)
+                       flags |= E2IMAGE_CHECK_ZERO_FLAG;
+               fd = ext2fs_open_file(image_fn, o_flags, 0600);
                if (fd < 0) {
                        com_err(program_name, errno,
-                               _("while trying to open %s"), argv[optind+1]);
+                               _("while trying to open %s"), image_fn);
                        exit(1);
                }
        }
+       if (dest_offset)
+               seek_set(fd, dest_offset);
 
        if ((img_type & E2IMAGE_QCOW2) && (fd == 1)) {
-               com_err(program_name, 0, "QCOW2 image can not be written to "
-                                        "the stdout!\n");
+               com_err(program_name, 0, _("QCOW2 image can not be written to "
+                                          "the stdout!\n"));
                exit(1);
        }
        if (fd != 1) {
@@ -1383,19 +1603,37 @@ skip_device:
                ret = qcow2_write_raw_image(qcow2_fd, fd, header);
                if (ret) {
                        if (ret == -QCOW_COMPRESSED)
-                               fprintf(stderr, "Image (%s) is compressed\n",
+                               fprintf(stderr, _("Image (%s) is compressed\n"),
                                        image_fn);
                        if (ret == -QCOW_ENCRYPTED)
-                               fprintf(stderr, "Image (%s) is encrypted\n",
+                               fprintf(stderr, _("Image (%s) is encrypted\n"),
                                        image_fn);
                        com_err(program_name, ret,
                                _("while trying to convert qcow2 image"
-                               " (%s) into raw image (%s)"),
+                                 " (%s) into raw image (%s)"),
                                device_name, image_fn);
                }
                goto out;
        }
 
+       if (check) {
+               if (img_type != E2IMAGE_RAW) {
+                       fprintf(stderr, _("The -c option only supported "
+                                         "in raw mode\n"));
+                       exit(1);
+               }
+               if (fd == 1) {
+                       fprintf(stderr, _("The -c option is not supported "
+                                         "when writing to stdout\n"));
+                       exit(1);
+               }
+               retval = ext2fs_get_mem(fs->blocksize, &check_buf);
+               if (retval) {
+                       com_err(program_name, retval,
+                               _("while allocating check_buf"));
+                       exit(1);
+               }
+       }
 
        if (img_type)
                write_raw_image_file(fs, fd, img_type, flags);
@@ -1403,6 +1641,10 @@ skip_device:
                write_image_file(fs, fd);
 
        ext2fs_close (fs);
+       if (check)
+               printf(_("%d blocks already contained the data to be copied.\n"),
+                      skipped_blocks);
+
 out:
        if (header)
                free(header);
index aa97557..765716d 100644 (file)
@@ -39,8 +39,8 @@ extern char *optarg;
 #include "../version.h"
 #include "nls-enable.h"
 
-const char * program_name = "e2initrd_helper";
-char * device_name;
+static const char * program_name = "e2initrd_helper";
+static char * device_name;
 static int open_flag;
 static int root_type;
 static blkid_cache cache = NULL;
index a7402b3..a43c26f 100644 (file)
 #include "ext2fs/ext2fs.h"
 #include "nls-enable.h"
 
-unsigned char mtime_key[] = "filesystem MTIME";
-unsigned char uuid_key[] = "filesystem UUID";
-unsigned char blksize_key[] = "filesystem BLKSIZE";
+static unsigned char mtime_key[] = "filesystem MTIME";
+static unsigned char uuid_key[] = "filesystem UUID";
+static unsigned char blksize_key[] = "filesystem BLKSIZE";
 
-char *prg_name;
+static char *prg_name;
 
 static void usage(void)
 {
index 07d56d9..c6a5f0d 100644 (file)
@@ -164,23 +164,23 @@ struct frag_statistic_ino {
        char msg_buffer[PATH_MAX + 1];  /* pathname of the file */
 };
 
-char   lost_found_dir[PATH_MAX + 1];
-int    block_size;
-int    extents_before_defrag;
-int    extents_after_defrag;
-int    mode_flag;
-unsigned int   current_uid;
-unsigned int   defraged_file_count;
-unsigned int   frag_files_before_defrag;
-unsigned int   frag_files_after_defrag;
-unsigned int   regular_count;
-unsigned int   succeed_cnt;
-unsigned int   total_count;
-__u8 log_groups_per_flex;
-__u32 blocks_per_group;
-__u32 feature_incompat;
-ext4_fsblk_t   files_block_count;
-struct frag_statistic_ino      frag_rank[SHOW_FRAG_FILES];
+static char    lost_found_dir[PATH_MAX + 1];
+static int     block_size;
+static int     extents_before_defrag;
+static int     extents_after_defrag;
+static int     mode_flag;
+static unsigned int    current_uid;
+static unsigned int    defraged_file_count;
+static unsigned int    frag_files_before_defrag;
+static unsigned int    frag_files_after_defrag;
+static unsigned int    regular_count;
+static unsigned int    succeed_cnt;
+static unsigned int    total_count;
+static __u8 log_groups_per_flex;
+static __u32 blocks_per_group;
+static __u32 feature_incompat;
+static ext4_fsblk_t    files_block_count;
+static struct frag_statistic_ino       frag_rank[SHOW_FRAG_FILES];
 
 
 /* Local definitions of some syscalls glibc may not yet have */
@@ -1865,12 +1865,13 @@ int main(int argc, char *argv[])
                }
 
                switch (arg_type) {
+                       int mount_dir_len = 0;
+
                case DIRNAME:
                        if (!(mode_flag & STATISTIC))
                                printf("ext4 defragmentation "
                                        "for directory(%s)\n", argv[i]);
 
-                       int mount_dir_len = 0;
                        mount_dir_len = strnlen(lost_found_dir, PATH_MAX);
 
                        strncat(lost_found_dir, "/lost+found",
diff --git a/misc/ext4.5.in b/misc/ext4.5.in
new file mode 100644 (file)
index 0000000..98494ec
--- /dev/null
@@ -0,0 +1,257 @@
+.\" -*- nroff -*-
+.\" Copyright 1993, 1994, 1995 by Theodore Ts'o.  All Rights Reserved.
+.\" This file may be copied under the terms of the GNU Public License.
+.\"
+.TH EXT4 5 "@E2FSPROGS_MONTH@ @E2FSPROGS_YEAR@" "E2fsprogs version @E2FSPROGS_VERSION@"
+.SH NAME
+ext2 \- the second extended file system
+.br
+ext2 \- the third extended file system
+.br
+ext4 \- the fourth extended file system
+.SH DESCRIPTION
+The second, third, and fourth extended file systems, or ext2, ext3, and
+ext4 as they are commonly known, are Linux file systems that have
+historically been the default file system for many Linux distributions.
+They are general purpose file systems that have been designed for
+extensibility and backwards compatibility.  In particular, file systems
+previously intended for use with the ext2 and ext3 file systems can be
+mounted using the ext4 file system driver, and indeed in many modern
+Linux distributions, the ext4 file system driver has been configured
+handle mount requests for ext2 and ext3 file systems.
+.SH FILE SYSTEM FEATURES
+A file system formated for ext2, ext3, or ext4 can be have some
+collection of the follow file system feature flags enabled.  Some of
+these features are not supported by all implementations of the ext2,
+ext3, and ext4 file system drivers, depending on Linux kernel version in
+use.  On other operating systems, such as the GNU/HURD or FreeBSD, only
+a very restrictive set of file system features may be supported in their
+implementations of ext2.
+.RS 1.2i
+.TP
+.B 64bit
+.br
+Enables the file system to be larger than 2^32 blocks.  This feature is set
+automatically, as needed, but it can be useful to specify this feature
+explicitly if the file system might need to be resized larger than 2^32
+blocks, even if it was smaller than that threshold when it was
+originally created.  Note that some older kernels and older versions
+of e2fsprogs will not support file systems with this ext4 feature enabled.
+.TP
+.B bigalloc
+.br
+This ext4 feature enables clustered block allocation, so that the unit of
+allocation is a power of two number of blocks.  That is, each bit in the
+what had traditionally been known as the block allocation bitmap now
+indicates whether a cluster is in use or not, where a cluster is by
+default composed of 16 blocks.  This feature can decrease the time
+spent on doing block allocation and brings smaller fragmentation, especially
+for large files.  The size can be specified using the
+.B \-C option.
+.IP
+.B Warning:
+The bigalloc feature is still under development, and may not be fully
+supported with your kernel or may have various bugs.  Please see the web
+page http://ext4.wiki.kernel.org/index.php/Bigalloc for details.
+May clash with delayed allocation (see
+.BR nodelalloc mount option).
+.IP
+This feature requires that the
+.B extent
+features be enabled.
+.TP
+.B dir_index
+.br
+Use hashed b-trees to speed up name lookups in large directories.  This
+feature is supported by ext3 and ext4 file systems, and is ignored by
+ext2 file systems.
+.TP
+.B dir_nlink
+.br
+This ext4 feature allows more than 65000 subdirectories per directory.
+.TP
+.B extent
+.br
+This ext4 feature allows the mapping of logical block numbers for a
+particular inode to physical blocks on the storage device to be stored
+using an extent tree, which is a more efficient data structure than the
+traditional indirect block scheme used by the ext2 and ext3 file
+systems.  The use of the extent tree decreases metadata block overhead,
+improves file system performance, and decreases the needed to run
+.BR e2fsck (8)
+on the file system.
+(Note: both
+.B extent
+and
+.B extents
+are accepted as valid names for this feature for
+historical/backwards compatibility reasons.)
+.TP
+.B extra_isize
+.br
+This ext4 feature reserves a specific amount of space in each inode for
+extended metadata such as nanosecond timestamps and file creation time,
+even if the current kernel does not current need to reserve this much
+space.  Without this feature, the kernel will reserve the amount of
+space for features currently it currently needs, and the rest may be
+consumed by extended attributes.
+
+For this feature to be useful the inode size must be 256 bytes in size
+or larger.
+.TP
+.B ext_attr
+.br
+This feature enables the use of extended attributes.  This feature is
+supported by ext2, ext3, and ext4.
+.TP
+.B filetype
+.br
+This feature enables the storage file type information in directory
+entries.  This feature is supported by ext2, ext3, and ext4.
+.TP
+.TP
+.B flex_bg
+.br
+This ext4 feature allows the per-block group metadata (allocation
+bitmaps
+and inode tables)
+to be placed anywhere on the storage media.  In addition,
+.B mke2fs
+will place the per-block group metadata together starting at the first
+block group of each "flex_bg group".   The size of the flex_bg group
+can be specified using the
+.B \-G
+option.
+.TP
+.B has_journal
+.br
+Create a journal to ensure filesystem consistency even across unclean
+shutdowns.  Setting the filesystem feature is equivalent to using the
+.B \-j
+option.  This feature is supported by ext3 and ext4, and ignored by the
+ext2 file system driver.
+.TP
+.B huge_file
+.br
+This ext4 feature allows files to be larger than 2 terabytes in size.
+.TP
+.B journal_dev
+.br
+This feature is enabled on the superblock found on an external journal
+device.  The block size for the external journal must be the same as the
+file system which uses it.
+.IP
+The external journal device can be used by a file system by specifying
+the
+.B \-J
+.BR device= <external-device>
+option to
+.BR mke2fs (8)
+or
+.BR tune2fs(8).
+.TP
+.B large_file
+.br
+This feature flag is set automatically by modern kernels when a file
+larger than 2 gigabytes is created.  Very old kernels could not
+handle large files, so this feature flag was used to prohibit those
+kernels from mounting file systems that they could not understand.
+.\" .TP
+.\" .B metadata_csum
+.\" .br
+.\" This ext4 feature enables metadata checksumming.  This feature stores
+.\" checksums for all of the filesystem metadata (superblock, group
+.\" descriptor blocks, inode and block bitmaps, directories, and
+.\" extent tree blocks).  The checksum algorithm used for the metadata
+.\" blocks is different than the one used for group descriptors with the
+.\" .B uninit_bg
+.\" feature, these two features are incompatible and
+.\" .B metadata_csum
+.\" will be used preferentially instead of
+.\" .BR uninit_bg .
+.\" .br
+.\" .B Future feature, available in e2fsprogs 1.43-WIP
+.TP
+.B meta_bg
+.br
+This ext4 feature allows file systems to be resized on-line without explicitly
+needing to reserve space for growth in the size of the block group
+descriptors.  This scheme is also used to resize file systems which are
+larger than 2^32 blocks.  It is not recommended that this feature be set
+when a file system is created, since this alternate method of storing
+the block group descriptor will slow down the time needed to mount the
+file system, and newer kernels can automatically set this feature as
+necessary when doing an online resize and no more reserved space is
+available in the resize inode.
+.TP
+.B mmp
+.br
+This ext4 feature provides multiple mount protection (MMP).  MMP helps to
+protect the filesystem from being multiply mounted and is useful in
+shared storage environments.
+@QUOTA_MAN_COMMENT@.TP
+@QUOTA_MAN_COMMENT@.B quota
+@QUOTA_MAN_COMMENT@.br
+@QUOTA_MAN_COMMENT@Create quota inodes (inode #3 for userquota and inode
+@QUOTA_MAN_COMMENT@#4 for group quota) and set them in the superblock.
+@QUOTA_MAN_COMMENT@With this feature, the quotas will be enabled
+@QUOTA_MAN_COMMENT@automatically when the filesystem is mounted.
+@QUOTA_MAN_COMMENT@.IP
+@QUOTA_MAN_COMMENT@Causes the quota files (i.e., user.quota and
+@QUOTA_MAN_COMMENT@group.quota which existed
+@QUOTA_MAN_COMMENT@in the older quota design) to be hidden inodes.
+@QUOTA_MAN_COMMENT@.IP
+@QUOTA_MAN_COMMENT@.B Warning:
+@QUOTA_MAN_COMMENT@The quota feature is still under development,
+@QUOTA_MAN_COMMENT@and may not be fully supported with your kernel
+@QUOTA_MAN_COMMENT@or may have various bugs.  Please
+@QUOTA_MAN_COMMENT@see https://ext4.wiki.kernel.org/index.php/Quota
+@QUOTA_MAN_COMMENT@for more details.
+.TP
+.B resize_inode
+.br
+This file system feature indicates that space has been reserved so
+the block group descriptor table can be extended by the file system is
+resized while the file system is mounted.  The online resize operation
+is carried out by the kernel, triggered, by
+.BR resize2fs (8).
+By default
+.B mke2fs
+will attempt to reserve enough space so that the
+filesystem may grow to 1024 times its initial size.  This can be changed
+using the
+.B resize
+extended option.
+.IP
+This feature requires that the
+.B sparse_super
+feature be enabled.
+.TP
+.B sparse_super
+.br
+This file system feature is set on all modern ext2, ext3, and ext4 file
+system.  It indicates that backup copies of the superblock and block
+group descriptors be present only on a few block groups, and not all of
+them.
+.TP
+.B uninit_bg
+.br
+This ext4 file system feature indicates that the block group descriptors
+will be protected using checksums, making it safe for
+.BR mke2fs (8)
+to create a file system without initializing all of the block groups.
+The kernel will keep a high watermark of unused inodes, and initialize
+inode tables and block lazily.  This feature speeds up the time to check
+the file system using
+.BR e2fsck (8),
+and it also speeds up the time required for
+.BR mke2fs (8)
+to create the file system.
+.RE
+.SH SEE ALSO
+.BR mke2fs (8),
+.BR mke2fs.conf (5),
+.BR e2fsck (8),
+.BR dumpe2fs (8),
+.BR tune2fs (8),
+.BR debugfs (8)
index 19e0dfb..826aaeb 100644 (file)
@@ -97,32 +97,32 @@ static const char *really_wanted[] = {
 /*
  * Global variables for options
  */
-char *devices[MAX_DEVICES];
-char *args[MAX_ARGS];
-int num_devices, num_args;
-
-int verbose = 0;
-int doall = 0;
-int noexecute = 0;
-int serialize = 0;
-int skip_root = 0;
-int ignore_mounted = 0;
-int notitle = 0;
-int parallel_root = 0;
-int progress = 0;
-int progress_fd = 0;
-int force_all_parallel = 0;
-int num_running = 0;
-int max_running = 0;
-volatile int cancel_requested = 0;
-int kill_sent = 0;
-char *progname;
-char *fstype = NULL;
-struct fs_info *filesys_info = NULL, *filesys_last = NULL;
-struct fsck_instance *instance_list;
-const char *fsck_prefix_path = "/sbin:/sbin/fs.d:/sbin/fs:/etc/fs:/etc";
-char *fsck_path = 0;
-blkid_cache cache = NULL;
+static char *devices[MAX_DEVICES];
+static char *args[MAX_ARGS];
+static int num_devices, num_args;
+
+static int verbose = 0;
+static int doall = 0;
+static int noexecute = 0;
+static int serialize = 0;
+static int skip_root = 0;
+static int ignore_mounted = 0;
+static int notitle = 0;
+static int parallel_root = 0;
+static int progress = 0;
+static int progress_fd = 0;
+static int force_all_parallel = 0;
+static int num_running = 0;
+static int max_running = 0;
+static volatile int cancel_requested = 0;
+static int kill_sent = 0;
+static char *progname;
+static char *fstype = NULL;
+static struct fs_info *filesys_info = NULL, *filesys_last = NULL;
+static struct fsck_instance *instance_list;
+static const char *fsck_prefix_path = "/sbin:/sbin/fs.d:/sbin/fs:/etc/fs:/etc";
+static char *fsck_path = 0;
+static blkid_cache cache = NULL;
 
 static char *string_copy(const char *s)
 {
@@ -728,7 +728,7 @@ static void fsck_device(struct fs_info *fs, int interactive)
 /*
  * Deal with the fsck -t argument.
  */
-struct fs_type_compile {
+static struct fs_type_compile {
        char **list;
        int *type;
        int  negate;
index e783546..8612edf 100644 (file)
@@ -32,13 +32,13 @@ extern char *optarg;
 extern int optind;
 #endif
 
-int    outfd = -1;
-int    outbufsize = 0;
-void   *outbuf = 0;
-int    verbose = 0;
-int    do_skip = 0;
-int    skip_mode = 0;
-pid_t  child_pid = -1;
+static int     outfd = -1;
+static int     outbufsize = 0;
+static void    *outbuf = 0;
+static int     verbose = 0;
+static int     do_skip = 0;
+static int     skip_mode = 0;
+static pid_t   child_pid = -1;
 
 static void usage(char *progname)
 {
index df244de..c178628 100644 (file)
@@ -210,8 +210,8 @@ in earlier versions of
 .BR mke2fs .
 The
 .B \-R
-option is still accepted for backwards compatibility.   The
-following extended options are supported:
+option is still accepted for backwards compatibility, but is deprecated.
+The following extended options are supported:
 .RS 1.2i
 .TP
 .BI mmp_update_interval= interval
@@ -294,7 +294,7 @@ Do not attempt to discard blocks at mkfs time.
 @QUOTA_MAN_COMMENT@.TP
 @QUOTA_MAN_COMMENT@.BI quotatype
 @QUOTA_MAN_COMMENT@Specify which quota type ('usr' or 'grp') is to be
-@QUOTA_MAN_COMMENT@initialized. This option has effect only if
+@QUOTA_MAN_COMMENT@initialized. This option has effect only if the
 @QUOTA_MAN_COMMENT@.B quota
 @QUOTA_MAN_COMMENT@feature is set. Without this extended option, the default
 @QUOTA_MAN_COMMENT@behavior is to initialize both user and group quotas.
@@ -533,198 +533,12 @@ section of the configuration file.
 The filesystem feature set is comprised of a list of features, separated
 by commas, that are to be enabled.  To disable a feature, simply
 prefix the feature name with a  caret ('^') or a minus ('-') character.
-Features with dependents will not be removed successfully.
+Features with dependencies will not be removed successfully.
 The pseudo-filesystem feature "none" will clear all filesystem features.
-.RS 1.2i
-.TP
-.B 64bit
-.br
-Enables the file system to be larger than 2^32 blocks.  This feature is set
-automatically, as needed, but it can be useful to specify this feature
-explicitly if the file system might need to be resized larger than 2^32
-blocks, even if it was smaller than that threshold when it was
-originally created.  Note that some older kernels and older versions
-of e2fsprogs will not support file systems with this feature enabled.
-.TP
-.B bigalloc
-.br
-This feature enables clustered allocation, so that the unit of
-allocation is a power of two number of blocks.  That is, each bit in the
-what had traditionally been known as the block allocation bitmap now
-indicates whether a cluster is in use or not, where a cluster is by
-default composed of 16 blocks.  This feature can decrease the time
-spent on doing block allocation and brings smaller fragmentation, especially
-for large files.  The size can be specified using the
-.B \-C option.
-.IP
-.B Warning:
-The bigalloc feature is still under development, and may not be fully
-supported with your kernel or may have various bugs.  Please see the web
-page http://ext4.wiki.kernel.org/index.php/Bigalloc for details.
-May clash with delayed allocation (see
-.BR nodelalloc mount option).
-.IP
-This feature requires that the
-.B extent
-features be enabled.
-.TP
-.B dir_index
-.br
-Use hashed b-trees to speed up lookups in large directories.
-.TP
-.B dir_nlink
-.br
-Allow more than 65000 subdirectories per directory.
-.TP
-.B extent
-.br
-Instead of using the indirect block scheme for storing the location of
-data blocks in an inode, use extents instead.  This is a much more
-efficient encoding which speeds up filesystem access, especially for
-large files.  (Note: both
-.B extent
-and
-.B extents
-are accepted as valid names for this feature for
-historical/backwards compatibility reasons.)
-.TP
-.B extra_isize
-.br
-This feature enables storage of nanosecond timestamps and creation
-time, if the inode size is larger than 256 bytes or larger.
-.TP
-.B ext_attr
-.br
-This feature enables the use of extended attributes.
-.TP
-.B filetype
-.br
-This feature enables the storage file type information in directory
-entries.  It is normally enabled by default for all file system types.
-.TP
-.B flex_bg
-.br
-Allow the per-block group metadata (allocation bitmaps and inode tables)
-to be placed anywhere on the storage media.  In addition,
-.B mke2fs
-will place the per-block group metadata together starting at the first
-block group of each "flex_bg group".   The size of the flex_bg group
-can be specified using the 
-.B \-G
-option.
-.TP
-.B has_journal
-.br
-Create a journal to ensure filesystem consistency even across unclean
-shutdowns.  Setting the filesystem feature is equivalent to using the
-.B \-j
-option.
 .TP
-.B huge_file
-.br
-Allows files larger than 2TiB in size.
-.TP
-.B journal_dev
-.br
-Creates an external ext3 journal on the given device
-instead of a regular ext2 filesystem.
-Note that
-.I external-journal
-must be created with the same
-block size as the filesystems that will be using it.
-.IP
-Once ready, use
-.BR mke2fs (8)
-or
-.BR tune2fs(8)
-with
-.B \-J
-.BR device= <external-device>
-to direct a filesystem to the journaling device (see journal-options).
-.TP
-.B large_file
-.br
-Filesystem can contain files that are greater than 2GiB.  (Modern kernels
-set this feature automatically when a file > 2GiB is created.)
-.\" .TP
-.\" .B metadata_csum
-.\" .br
-.\" Filesystem supports metadata checksumming.  This feature enables a
-.\" superset of the functionality of the
-.\" .B uninit_bg
-.\" feature.
-.\" .br
-.\" .B Future feature, available in e2fsprogs 1.43-WIP
-.TP
-.B meta_bg
-.br
-This feature allows file systems to be resized on-line without explicitly
-needing to reserve space for growth in the size of the block group
-descriptors.  This scheme is also used to resize file systems which are
-larger than 2^32 blocks.  It is not recommended that this feature be set
-when a file system is created, since this alternate method of storing
-the block group descriptor will slow down the time needed to mount the
-file system, and newer kernels can automatically set this feature as
-necessary when doing an online resize and no more reserved space is
-available in the resize inode.
-.TP
-.B mmp
-.br
-Multiple mount protection (MMP) feature.  MMP helps to
-protect the filesystem from being multiply mounted and is useful in
-shared storage environments.
-@QUOTA_MAN_COMMENT@.TP
-@QUOTA_MAN_COMMENT@.B quota
-@QUOTA_MAN_COMMENT@.br
-@QUOTA_MAN_COMMENT@Create quota inodes (inode #3 for userquota and inode
-@QUOTA_MAN_COMMENT@#4 for group quota) and set them in the superblock.
-@QUOTA_MAN_COMMENT@With this feature, the quotas will be enabled
-@QUOTA_MAN_COMMENT@automatically when the filesystem is mounted.
-@QUOTA_MAN_COMMENT@.IP
-@QUOTA_MAN_COMMENT@Causes the quota files (i.e., user.quota and
-@QUOTA_MAN_COMMENT@group.quota which existed
-@QUOTA_MAN_COMMENT@in the older quota design) to be hidden inodes.
-@QUOTA_MAN_COMMENT@.IP
-@QUOTA_MAN_COMMENT@.B Not defined by default,
-@QUOTA_MAN_COMMENT@see https://ext4.wiki.kernel.org/index.php/Quota
-.TP
-.B resize_inode
-.br
-Reserve space so the block group descriptor table may grow in the future.
-Useful for online resizing using
-.BR resize2fs .
-By default
-.B mke2fs
-will attempt to reserve enough space so that the
-filesystem may grow to 1024 times its initial size.  This can be changed
-using the
-.B resize
-extended option.
-.IP
- This feature requires that the
-.B sparse_super
-feature be enabled.
-.TP
-.B sparse_super
-.br
-Create a filesystem with fewer superblock backup copies
-(saves space on large filesystems).  This feature is normally enabled by
-default for all file systems.
-.TP
-.B uninit_bg
-.br
-Create a filesystem without initializing all of the block groups.  This
-feature allows the kernel to initialize bitmaps and inode tables
-and keep a high watermark for the unused inodes in a filesystem, to reduce
-.BR e2fsck (8)
-time.  The result is that it can speed up filesystem creation time noticeably
-(if lazy_itable_init is enabled).
-.IP
-This first e2fsck run after enabling this feature will take the
-full time, but subsequent e2fsck runs will take only a fraction of the
-original time, depending on how full the file system is.
-It is only supported by the ext4 filesystem in recent Linux kernels.
-.RE
+For more information about the features which can be set, please see
+the manual page
+.BR ext4 (5).
 .TP
 .B \-q
 Quiet execution.  Useful if
@@ -870,4 +684,5 @@ http://e2fsprogs.sourceforge.net.
 .BR badblocks (8),
 .BR dumpe2fs (8),
 .BR e2fsck (8),
-.BR tune2fs (8)
+.BR tune2fs (8),
+.BR ext4 (5)
index 4075099..64d5a46 100644 (file)
@@ -76,40 +76,40 @@ extern int optind;
 extern int isatty(int);
 extern FILE *fpopen(const char *cmd, const char *mode);
 
-const char * program_name = "mke2fs";
-const char * device_name /* = NULL */;
+static const char * program_name = "mke2fs";
+static const char * device_name /* = NULL */;
 
 /* Command line options */
-int    cflag;
-int    verbose;
-int    quiet;
-int    super_only;
-int    discard = 1;    /* attempt to discard device before fs creation */
-int    direct_io;
-int    force;
-int    noaction;
-uid_t  root_uid;
-gid_t  root_gid;
+static int     cflag;
+static int     verbose;
+static int     quiet;
+static int     super_only;
+static int     discard = 1;    /* attempt to discard device before fs creation */
+static int     direct_io;
+static int     force;
+static int     noaction;
+static uid_t   root_uid;
+static gid_t   root_gid;
 int    journal_size;
 int    journal_flags;
-int    lazy_itable_init;
-char   *bad_blocks_filename = NULL;
-__u32  fs_stride;
-int    quotatype = -1;  /* Initialize both user and group quotas by default */
-
-struct ext2_super_block fs_param;
-char *fs_uuid = NULL;
-char *creator_os;
-char *volume_label;
-char *mount_dir;
+static int     lazy_itable_init;
+static char    *bad_blocks_filename = NULL;
+static __u32   fs_stride;
+static int     quotatype = -1;  /* Initialize both user and group quotas by default */
+
+static struct ext2_super_block fs_param;
+static char *fs_uuid = NULL;
+static char *creator_os;
+static char *volume_label;
+static char *mount_dir;
 char *journal_device;
-int sync_kludge;       /* Set using the MKE2FS_SYNC env. option */
-char **fs_types;
+static int sync_kludge;        /* Set using the MKE2FS_SYNC env. option */
+static char **fs_types;
 
-profile_t      profile;
+static profile_t       profile;
 
-int sys_page_size = 4096;
-int linux_version_code = 0;
+static int sys_page_size = 4096;
+static int linux_version_code = 0;
 
 static void usage(void)
 {
@@ -723,7 +723,38 @@ static void parse_extended_opts(struct ext2_super_block *param,
                        *arg = 0;
                        arg++;
                }
-               if (strcmp(token, "mmp_update_interval") == 0) {
+               if (strcmp(token, "desc-size") == 0 ||
+                   strcmp(token, "desc_size") == 0) {
+                       int desc_size;
+
+                       if (!(fs_param.s_feature_incompat &
+                             EXT4_FEATURE_INCOMPAT_64BIT)) {
+                               fprintf(stderr,
+                                       _("%s requires '-O 64bit'\n"), token);
+                               r_usage++;
+                               continue;
+                       }
+                       if (param->s_reserved_gdt_blocks != 0) {
+                               fprintf(stderr,
+                                       _("'%s' must be before 'resize=%u'\n"),
+                                       token, param->s_reserved_gdt_blocks);
+                               r_usage++;
+                               continue;
+                       }
+                       if (!arg) {
+                               r_usage++;
+                               badopt = token;
+                               continue;
+                       }
+                       desc_size = strtoul(arg, &p, 0);
+                       if (*p || (desc_size & (desc_size - 1))) {
+                               fprintf(stderr,
+                                       _("Invalid desc_size: '%s'\n"), arg);
+                               r_usage++;
+                               continue;
+                       }
+                       param->s_desc_size = desc_size;
+               } else if (strcmp(token, "mmp_update_interval") == 0) {
                        if (!arg) {
                                r_usage++;
                                badopt = token;
index 55c6dd9..da21080 100644 (file)
@@ -501,18 +501,26 @@ More than one filesystem feature can be cleared or set by separating
 features with commas.  Filesystem features prefixed with a 
 caret character ('^') will be cleared in the filesystem's superblock; 
 filesystem features without a prefix character or prefixed with a plus 
-character ('+') will be added to the filesystem.
+character ('+') will be added to the filesystem.  For a detailed
+description of the file system features, please see the man page
+.BR ext4 (5).
 .IP
 The following filesystem features can be set or cleared using
 .BR tune2fs :
 .RS 1.2i
 .TP
 .B dir_index
-Use hashed b-trees to speed up lookups in large directories.
+Use hashed b-trees to speed up lookups for large directories.
 .TP
 .B dir_nlink
 Allow more than 65000 subdirectories per directory.
 .TP
+.B extent
+Enable the use of extent trees to store the location of data blocks in inodes.
+.TP
+.B extra_isize
+Enable the extended inode fields used by ext4.
+.TP
 .B filetype
 Store file type information in directory entries.
 .TP
@@ -531,9 +539,11 @@ Setting the filesystem feature is equivalent to using the
 .B \-j
 option.
 .TP
+.B huge_file
+Support files larger than 2 terabytes in size.
+.TP
 .B large_file
-Filesystem can contain files that are greater than 2GB.  (Modern kernels
-set this feature automatically when a file > 2GB is created.)
+Filesystem can contain files that are greater than 2GB.
 .TP
 .B resize_inode
 Reserve space so the block group descriptor table may grow in the
@@ -542,16 +552,17 @@ future.
 only supports clearing this filesystem feature.
 .TP
 .B mmp
-Enable or disable multiple mount protection (MMP) feature.  MMP helps to
-protect the filesystem from being multiply mounted and is useful in
-shared storage environments.
+Enable or disable multiple mount protection (MMP) feature.
+@QUOTA_MAN_COMMENT@.TP
+@QUOTA_MAN_COMMENT@.B quota
+@QUOTA_MAN_COMMENT@Enable internal file system quota inodes.
 .TP
 .B sparse_super
 Limit the number of backup superblocks to save space on large filesystems.
 .TP
 .B uninit_bg
-Allow the kernel to initialize bitmaps and inode tables and keep a high
-watermark for the unused inodes in a filesystem, to reduce
+Allow the kernel to initialize bitmaps and inode tables lazily, and to
+keep a high watermark for the unused inodes in a filesystem, to reduce
 .BR e2fsck (8)
 time.  This first e2fsck run after enabling this feature will take the
 full time, but subsequent e2fsck runs will take only a fraction of the
@@ -681,4 +692,5 @@ http://e2fsprogs.sourceforge.net.
 .BR debugfs (8),
 .BR dumpe2fs (8),
 .BR e2fsck (8),
-.BR mke2fs (8)
+.BR mke2fs (8),
+.BR ext4 (5)
index 6f3954f..2b7abff 100644 (file)
@@ -36,7 +36,8 @@ extern int optind;
 
 #include "../version.h"
 
-char *program_name, *device_name, *io_options;
+char *program_name;
+static char *device_name, *io_options;
 
 static void usage (char *prog)
 {
index 62610f1..5f9f16b 100644 (file)
@@ -73,7 +73,7 @@ static errcode_t mark_table_blocks(ext2_filsys fs,
 #define GE_CLSTR(x, y) (B2C(x) >= B2C(y))
 #define GT_CLSTR(x, y) (B2C(x) >  B2C(y))
 
-int lazy_itable_init;
+static int lazy_itable_init;
 
 /*
  * This is the top-level routine which does the dirty deed....
@@ -1348,7 +1348,7 @@ errout:
  * take special care when mapping a source block number to its
  * destination block number.
  */
-__u64 extent_translate(ext2_filsys fs, ext2_extent extent, __u64 old_loc)
+static __u64 extent_translate(ext2_filsys fs, ext2_extent extent, __u64 old_loc)
 {
        __u64 new_block = C2B(ext2fs_extent_translate(extent, B2C(old_loc)));
 
index 52319b5..7aeab91 100644 (file)
@@ -160,6 +160,9 @@ extern void ext2fs_extent_dump(ext2_extent extent, FILE *out);
 extern errcode_t ext2fs_iterate_extent(ext2_extent extent, __u64 *old_loc,
                                       __u64 *new_loc, __u64 *size);
 
+/* main.c */
+extern char *program_name;
+
 /* online.c */
 extern errcode_t online_resize_fs(ext2_filsys fs, const char *mtpt,
                                  blk64_t *new_size, int flags);
diff --git a/tests/f_desc_size_128/expect.1 b/tests/f_desc_size_128/expect.1
new file mode 100644 (file)
index 0000000..a62f112
--- /dev/null
@@ -0,0 +1,7 @@
+Pass 1: Checking inodes, blocks, and sizes
+Pass 2: Checking directory structure
+Pass 3: Checking directory connectivity
+Pass 4: Checking reference counts
+Pass 5: Checking group summary information
+test_filesys: 11/256 files (0.0% non-contiguous), 150/8192 blocks
+Exit status is 0
diff --git a/tests/f_desc_size_128/expect.2 b/tests/f_desc_size_128/expect.2
new file mode 100644 (file)
index 0000000..a62f112
--- /dev/null
@@ -0,0 +1,7 @@
+Pass 1: Checking inodes, blocks, and sizes
+Pass 2: Checking directory structure
+Pass 3: Checking directory connectivity
+Pass 4: Checking reference counts
+Pass 5: Checking group summary information
+test_filesys: 11/256 files (0.0% non-contiguous), 150/8192 blocks
+Exit status is 0
diff --git a/tests/f_desc_size_128/image.gz b/tests/f_desc_size_128/image.gz
new file mode 100644 (file)
index 0000000..eda0cab
Binary files /dev/null and b/tests/f_desc_size_128/image.gz differ
diff --git a/tests/f_desc_size_128/name b/tests/f_desc_size_128/name
new file mode 100644 (file)
index 0000000..f09e003
--- /dev/null
@@ -0,0 +1 @@
+128-byte group descriptors
diff --git a/tests/f_desc_size_bad/expect.1 b/tests/f_desc_size_bad/expect.1
new file mode 100644 (file)
index 0000000..009ee04
--- /dev/null
@@ -0,0 +1,11 @@
+ext2fs_check_desc: Block group descriptor size incorrect
+../e2fsck/e2fsck: Group descriptors look bad... trying backup blocks...
+Pass 1: Checking inodes, blocks, and sizes
+Pass 2: Checking directory structure
+Pass 3: Checking directory connectivity
+Pass 4: Checking reference counts
+Pass 5: Checking group summary information
+
+test_filesys: ***** FILE SYSTEM WAS MODIFIED *****
+test_filesys: 11/32 files (0.0% non-contiguous), 801/2048 blocks
+Exit status is 1
diff --git a/tests/f_desc_size_bad/expect.2 b/tests/f_desc_size_bad/expect.2
new file mode 100644 (file)
index 0000000..d1429fd
--- /dev/null
@@ -0,0 +1,7 @@
+Pass 1: Checking inodes, blocks, and sizes
+Pass 2: Checking directory structure
+Pass 3: Checking directory connectivity
+Pass 4: Checking reference counts
+Pass 5: Checking group summary information
+test_filesys: 11/32 files (0.0% non-contiguous), 801/2048 blocks
+Exit status is 0
diff --git a/tests/f_desc_size_bad/script b/tests/f_desc_size_bad/script
new file mode 100644 (file)
index 0000000..5440328
--- /dev/null
@@ -0,0 +1,17 @@
+if ! test -x $DEBUGFS_EXE; then
+        echo "$test_name: $test_description: skipped"
+       return 0
+fi
+
+DESCRIPTION="bad superblock s_desc_size"
+SKIP_GUNZIP=true
+touch $TMPFILE
+$MKE2FS -F -o Linux -O 64bit,extents -N 32 -b 1024 -g 512 -E desc_size=128 $TMPFILE 2048 > $test_name.log 2>&1
+$DEBUGFS -R "ssv desc_size 129" -w $TMPFILE >> $test_name.log 2>&1
+
+E2FSCK_TIME=200704102100
+export E2FSCK_TIME
+
+. $cmd_dir/run_e2fsck
+
+unset E2FSCK_TIME
index 31ac6c9..b00b031 100644 (file)
@@ -4,8 +4,8 @@ SKIP_GUNZIP="true"
 TEST_DATA="$test_name.tmp"
 
 dd if=/dev/zero of=$TMPFILE bs=1k count=256 > /dev/null 2>&1
-mke2fs -Ft ext4 $TMPFILE > /dev/null 2>&1
-debugfs -w $TMPFILE << EOF  > /dev/null 2>&1
+$MKE2FS -Ft ext4 $TMPFILE > /dev/null 2>&1
+$DEBUGFS -w $TMPFILE << EOF  > /dev/null 2>&1
 write /dev/null testfile
 extent_open testfile
   insert_node 0 15 100
index 0315ae2..adf59a4 100644 (file)
@@ -20,6 +20,7 @@ for i in $ORIG_IMAGES; do
        bunzip2 < $SRCDIR/$ORIG_IMG.bz2 > $i
        md5sum $i >> $MD5_TMP
 
+       rm -f $RAW_IMG
        echo "e2image -r $ORIG_IMG $RAW_IMG"
        $E2IMAGE      -r $i $RAW_IMG
        md5sum $RAW_IMG >> $MD5_TMP
@@ -28,6 +29,7 @@ for i in $ORIG_IMAGES; do
        $E2IMAGE      -Q $i $QCOW2_IMG
        md5sum $QCOW2_IMG >> $MD5_TMP
 
+       rm -f $QCOW2_TO_RAW
        echo "e2image -r $QCOW2_IMG $QCOW2_TO_RAW"
        $E2IMAGE      -r $i $QCOW2_TO_RAW
        md5sum $QCOW2_TO_RAW >> $MD5_TMP
diff --git a/tests/m_desc_size_128/expect.1 b/tests/m_desc_size_128/expect.1
new file mode 100644 (file)
index 0000000..8f01591
--- /dev/null
@@ -0,0 +1,849 @@
+Filesystem label=
+OS type: Linux
+Block size=1024 (log=0)
+Fragment size=1024 (log=0)
+Stride=0 blocks, Stripe width=0 blocks
+8192 inodes, 131072 blocks
+6553 blocks (5.00%) reserved for the super user
+First data block=1
+Maximum filesystem blocks=2228224
+128 block groups
+1024 blocks per group, 1024 fragments per group
+64 inodes per group
+Superblock backups stored on blocks: 
+       1025, 3073, 5121, 7169, 9217, 25601, 27649, 50177, 82945, 128001
+
+Allocating group tables:        \b\b\b\b\b\b\bdone                            
+Writing inode tables:        \b\b\b\b\b\b\bdone                            
+Writing superblocks and filesystem accounting information:        \b\b\b\b\b\b\bdone
+
+Filesystem features: ext_attr resize_inode dir_index filetype extent 64bit sparse_super
+Pass 1: Checking inodes, blocks, and sizes
+Pass 2: Checking directory structure
+Pass 3: Checking directory connectivity
+Pass 4: Checking reference counts
+Pass 5: Checking group summary information
+test_filesys: 11/8192 files (0.0% non-contiguous), 4298/131072 blocks
+Exit status is 0
+Filesystem volume name:   <none>
+Last mounted on:          <not available>
+Filesystem magic number:  0xEF53
+Filesystem revision #:    1 (dynamic)
+Filesystem features:      ext_attr resize_inode dir_index filetype extent 64bit sparse_super
+Default mount options:    (none)
+Filesystem state:         clean
+Errors behavior:          Continue
+Filesystem OS type:       Linux
+Inode count:              8192
+Block count:              131072
+Reserved block count:     6553
+Free blocks:              126774
+Free inodes:              8181
+First block:              1
+Block size:               1024
+Fragment size:            1024
+Group descriptor size:    128
+Reserved GDT blocks:      256
+Blocks per group:         1024
+Fragments per group:      1024
+Inodes per group:         64
+Inode blocks per group:   8
+Mount count:              0
+Check interval:           15552000 (6 months)
+Reserved blocks uid:      0
+Reserved blocks gid:      0
+First inode:              11
+Inode size:              128
+Default directory hash:   half_md4
+
+
+Group 0: (Blocks 1-1024)
+  Primary superblock at 1, Group descriptors at 2-17
+  Reserved GDT blocks at 18-273
+  Block bitmap at 274 (+273), Inode bitmap at 275 (+274)
+  Inode table at 276-283 (+275)
+  727 free blocks, 53 free inodes, 2 directories
+  Free blocks: 298-1024
+  Free inodes: 12-64
+Group 1: (Blocks 1025-2048)
+  Backup superblock at 1025, Group descriptors at 1026-1041
+  Reserved GDT blocks at 1042-1297
+  Block bitmap at 1298 (+273), Inode bitmap at 1299 (+274)
+  Inode table at 1300-1307 (+275)
+  741 free blocks, 64 free inodes, 0 directories
+  Free blocks: 1308-2048
+  Free inodes: 65-128
+Group 2: (Blocks 2049-3072)
+  Block bitmap at 2049 (+0), Inode bitmap at 2050 (+1)
+  Inode table at 2051-2058 (+2)
+  1014 free blocks, 64 free inodes, 0 directories
+  Free blocks: 2059-3072
+  Free inodes: 129-192
+Group 3: (Blocks 3073-4096)
+  Backup superblock at 3073, Group descriptors at 3074-3089
+  Reserved GDT blocks at 3090-3345
+  Block bitmap at 3346 (+273), Inode bitmap at 3347 (+274)
+  Inode table at 3348-3355 (+275)
+  741 free blocks, 64 free inodes, 0 directories
+  Free blocks: 3356-4096
+  Free inodes: 193-256
+Group 4: (Blocks 4097-5120)
+  Block bitmap at 4097 (+0), Inode bitmap at 4098 (+1)
+  Inode table at 4099-4106 (+2)
+  1014 free blocks, 64 free inodes, 0 directories
+  Free blocks: 4107-5120
+  Free inodes: 257-320
+Group 5: (Blocks 5121-6144)
+  Backup superblock at 5121, Group descriptors at 5122-5137
+  Reserved GDT blocks at 5138-5393
+  Block bitmap at 5394 (+273), Inode bitmap at 5395 (+274)
+  Inode table at 5396-5403 (+275)
+  741 free blocks, 64 free inodes, 0 directories
+  Free blocks: 5404-6144
+  Free inodes: 321-384
+Group 6: (Blocks 6145-7168)
+  Block bitmap at 6145 (+0), Inode bitmap at 6146 (+1)
+  Inode table at 6147-6154 (+2)
+  1014 free blocks, 64 free inodes, 0 directories
+  Free blocks: 6155-7168
+  Free inodes: 385-448
+Group 7: (Blocks 7169-8192)
+  Backup superblock at 7169, Group descriptors at 7170-7185
+  Reserved GDT blocks at 7186-7441
+  Block bitmap at 7442 (+273), Inode bitmap at 7443 (+274)
+  Inode table at 7444-7451 (+275)
+  741 free blocks, 64 free inodes, 0 directories
+  Free blocks: 7452-8192
+  Free inodes: 449-512
+Group 8: (Blocks 8193-9216)
+  Block bitmap at 8193 (+0), Inode bitmap at 8194 (+1)
+  Inode table at 8195-8202 (+2)
+  1014 free blocks, 64 free inodes, 0 directories
+  Free blocks: 8203-9216
+  Free inodes: 513-576
+Group 9: (Blocks 9217-10240)
+  Backup superblock at 9217, Group descriptors at 9218-9233
+  Reserved GDT blocks at 9234-9489
+  Block bitmap at 9490 (+273), Inode bitmap at 9491 (+274)
+  Inode table at 9492-9499 (+275)
+  741 free blocks, 64 free inodes, 0 directories
+  Free blocks: 9500-10240
+  Free inodes: 577-640
+Group 10: (Blocks 10241-11264)
+  Block bitmap at 10241 (+0), Inode bitmap at 10242 (+1)
+  Inode table at 10243-10250 (+2)
+  1014 free blocks, 64 free inodes, 0 directories
+  Free blocks: 10251-11264
+  Free inodes: 641-704
+Group 11: (Blocks 11265-12288)
+  Block bitmap at 11265 (+0), Inode bitmap at 11266 (+1)
+  Inode table at 11267-11274 (+2)
+  1014 free blocks, 64 free inodes, 0 directories
+  Free blocks: 11275-12288
+  Free inodes: 705-768
+Group 12: (Blocks 12289-13312)
+  Block bitmap at 12289 (+0), Inode bitmap at 12290 (+1)
+  Inode table at 12291-12298 (+2)
+  1014 free blocks, 64 free inodes, 0 directories
+  Free blocks: 12299-13312
+  Free inodes: 769-832
+Group 13: (Blocks 13313-14336)
+  Block bitmap at 13313 (+0), Inode bitmap at 13314 (+1)
+  Inode table at 13315-13322 (+2)
+  1014 free blocks, 64 free inodes, 0 directories
+  Free blocks: 13323-14336
+  Free inodes: 833-896
+Group 14: (Blocks 14337-15360)
+  Block bitmap at 14337 (+0), Inode bitmap at 14338 (+1)
+  Inode table at 14339-14346 (+2)
+  1014 free blocks, 64 free inodes, 0 directories
+  Free blocks: 14347-15360
+  Free inodes: 897-960
+Group 15: (Blocks 15361-16384)
+  Block bitmap at 15361 (+0), Inode bitmap at 15362 (+1)
+  Inode table at 15363-15370 (+2)
+  1014 free blocks, 64 free inodes, 0 directories
+  Free blocks: 15371-16384
+  Free inodes: 961-1024
+Group 16: (Blocks 16385-17408)
+  Block bitmap at 16385 (+0), Inode bitmap at 16386 (+1)
+  Inode table at 16387-16394 (+2)
+  1014 free blocks, 64 free inodes, 0 directories
+  Free blocks: 16395-17408
+  Free inodes: 1025-1088
+Group 17: (Blocks 17409-18432)
+  Block bitmap at 17409 (+0), Inode bitmap at 17410 (+1)
+  Inode table at 17411-17418 (+2)
+  1014 free blocks, 64 free inodes, 0 directories
+  Free blocks: 17419-18432
+  Free inodes: 1089-1152
+Group 18: (Blocks 18433-19456)
+  Block bitmap at 18433 (+0), Inode bitmap at 18434 (+1)
+  Inode table at 18435-18442 (+2)
+  1014 free blocks, 64 free inodes, 0 directories
+  Free blocks: 18443-19456
+  Free inodes: 1153-1216
+Group 19: (Blocks 19457-20480)
+  Block bitmap at 19457 (+0), Inode bitmap at 19458 (+1)
+  Inode table at 19459-19466 (+2)
+  1014 free blocks, 64 free inodes, 0 directories
+  Free blocks: 19467-20480
+  Free inodes: 1217-1280
+Group 20: (Blocks 20481-21504)
+  Block bitmap at 20481 (+0), Inode bitmap at 20482 (+1)
+  Inode table at 20483-20490 (+2)
+  1014 free blocks, 64 free inodes, 0 directories
+  Free blocks: 20491-21504
+  Free inodes: 1281-1344
+Group 21: (Blocks 21505-22528)
+  Block bitmap at 21505 (+0), Inode bitmap at 21506 (+1)
+  Inode table at 21507-21514 (+2)
+  1014 free blocks, 64 free inodes, 0 directories
+  Free blocks: 21515-22528
+  Free inodes: 1345-1408
+Group 22: (Blocks 22529-23552)
+  Block bitmap at 22529 (+0), Inode bitmap at 22530 (+1)
+  Inode table at 22531-22538 (+2)
+  1014 free blocks, 64 free inodes, 0 directories
+  Free blocks: 22539-23552
+  Free inodes: 1409-1472
+Group 23: (Blocks 23553-24576)
+  Block bitmap at 23553 (+0), Inode bitmap at 23554 (+1)
+  Inode table at 23555-23562 (+2)
+  1014 free blocks, 64 free inodes, 0 directories
+  Free blocks: 23563-24576
+  Free inodes: 1473-1536
+Group 24: (Blocks 24577-25600)
+  Block bitmap at 24577 (+0), Inode bitmap at 24578 (+1)
+  Inode table at 24579-24586 (+2)
+  1014 free blocks, 64 free inodes, 0 directories
+  Free blocks: 24587-25600
+  Free inodes: 1537-1600
+Group 25: (Blocks 25601-26624)
+  Backup superblock at 25601, Group descriptors at 25602-25617
+  Reserved GDT blocks at 25618-25873
+  Block bitmap at 25874 (+273), Inode bitmap at 25875 (+274)
+  Inode table at 25876-25883 (+275)
+  741 free blocks, 64 free inodes, 0 directories
+  Free blocks: 25884-26624
+  Free inodes: 1601-1664
+Group 26: (Blocks 26625-27648)
+  Block bitmap at 26625 (+0), Inode bitmap at 26626 (+1)
+  Inode table at 26627-26634 (+2)
+  1014 free blocks, 64 free inodes, 0 directories
+  Free blocks: 26635-27648
+  Free inodes: 1665-1728
+Group 27: (Blocks 27649-28672)
+  Backup superblock at 27649, Group descriptors at 27650-27665
+  Reserved GDT blocks at 27666-27921
+  Block bitmap at 27922 (+273), Inode bitmap at 27923 (+274)
+  Inode table at 27924-27931 (+275)
+  741 free blocks, 64 free inodes, 0 directories
+  Free blocks: 27932-28672
+  Free inodes: 1729-1792
+Group 28: (Blocks 28673-29696)
+  Block bitmap at 28673 (+0), Inode bitmap at 28674 (+1)
+  Inode table at 28675-28682 (+2)
+  1014 free blocks, 64 free inodes, 0 directories
+  Free blocks: 28683-29696
+  Free inodes: 1793-1856
+Group 29: (Blocks 29697-30720)
+  Block bitmap at 29697 (+0), Inode bitmap at 29698 (+1)
+  Inode table at 29699-29706 (+2)
+  1014 free blocks, 64 free inodes, 0 directories
+  Free blocks: 29707-30720
+  Free inodes: 1857-1920
+Group 30: (Blocks 30721-31744)
+  Block bitmap at 30721 (+0), Inode bitmap at 30722 (+1)
+  Inode table at 30723-30730 (+2)
+  1014 free blocks, 64 free inodes, 0 directories
+  Free blocks: 30731-31744
+  Free inodes: 1921-1984
+Group 31: (Blocks 31745-32768)
+  Block bitmap at 31745 (+0), Inode bitmap at 31746 (+1)
+  Inode table at 31747-31754 (+2)
+  1014 free blocks, 64 free inodes, 0 directories
+  Free blocks: 31755-32768
+  Free inodes: 1985-2048
+Group 32: (Blocks 32769-33792)
+  Block bitmap at 32769 (+0), Inode bitmap at 32770 (+1)
+  Inode table at 32771-32778 (+2)
+  1014 free blocks, 64 free inodes, 0 directories
+  Free blocks: 32779-33792
+  Free inodes: 2049-2112
+Group 33: (Blocks 33793-34816)
+  Block bitmap at 33793 (+0), Inode bitmap at 33794 (+1)
+  Inode table at 33795-33802 (+2)
+  1014 free blocks, 64 free inodes, 0 directories
+  Free blocks: 33803-34816
+  Free inodes: 2113-2176
+Group 34: (Blocks 34817-35840)
+  Block bitmap at 34817 (+0), Inode bitmap at 34818 (+1)
+  Inode table at 34819-34826 (+2)
+  1014 free blocks, 64 free inodes, 0 directories
+  Free blocks: 34827-35840
+  Free inodes: 2177-2240
+Group 35: (Blocks 35841-36864)
+  Block bitmap at 35841 (+0), Inode bitmap at 35842 (+1)
+  Inode table at 35843-35850 (+2)
+  1014 free blocks, 64 free inodes, 0 directories
+  Free blocks: 35851-36864
+  Free inodes: 2241-2304
+Group 36: (Blocks 36865-37888)
+  Block bitmap at 36865 (+0), Inode bitmap at 36866 (+1)
+  Inode table at 36867-36874 (+2)
+  1014 free blocks, 64 free inodes, 0 directories
+  Free blocks: 36875-37888
+  Free inodes: 2305-2368
+Group 37: (Blocks 37889-38912)
+  Block bitmap at 37889 (+0), Inode bitmap at 37890 (+1)
+  Inode table at 37891-37898 (+2)
+  1014 free blocks, 64 free inodes, 0 directories
+  Free blocks: 37899-38912
+  Free inodes: 2369-2432
+Group 38: (Blocks 38913-39936)
+  Block bitmap at 38913 (+0), Inode bitmap at 38914 (+1)
+  Inode table at 38915-38922 (+2)
+  1014 free blocks, 64 free inodes, 0 directories
+  Free blocks: 38923-39936
+  Free inodes: 2433-2496
+Group 39: (Blocks 39937-40960)
+  Block bitmap at 39937 (+0), Inode bitmap at 39938 (+1)
+  Inode table at 39939-39946 (+2)
+  1014 free blocks, 64 free inodes, 0 directories
+  Free blocks: 39947-40960
+  Free inodes: 2497-2560
+Group 40: (Blocks 40961-41984)
+  Block bitmap at 40961 (+0), Inode bitmap at 40962 (+1)
+  Inode table at 40963-40970 (+2)
+  1014 free blocks, 64 free inodes, 0 directories
+  Free blocks: 40971-41984
+  Free inodes: 2561-2624
+Group 41: (Blocks 41985-43008)
+  Block bitmap at 41985 (+0), Inode bitmap at 41986 (+1)
+  Inode table at 41987-41994 (+2)
+  1014 free blocks, 64 free inodes, 0 directories
+  Free blocks: 41995-43008
+  Free inodes: 2625-2688
+Group 42: (Blocks 43009-44032)
+  Block bitmap at 43009 (+0), Inode bitmap at 43010 (+1)
+  Inode table at 43011-43018 (+2)
+  1014 free blocks, 64 free inodes, 0 directories
+  Free blocks: 43019-44032
+  Free inodes: 2689-2752
+Group 43: (Blocks 44033-45056)
+  Block bitmap at 44033 (+0), Inode bitmap at 44034 (+1)
+  Inode table at 44035-44042 (+2)
+  1014 free blocks, 64 free inodes, 0 directories
+  Free blocks: 44043-45056
+  Free inodes: 2753-2816
+Group 44: (Blocks 45057-46080)
+  Block bitmap at 45057 (+0), Inode bitmap at 45058 (+1)
+  Inode table at 45059-45066 (+2)
+  1014 free blocks, 64 free inodes, 0 directories
+  Free blocks: 45067-46080
+  Free inodes: 2817-2880
+Group 45: (Blocks 46081-47104)
+  Block bitmap at 46081 (+0), Inode bitmap at 46082 (+1)
+  Inode table at 46083-46090 (+2)
+  1014 free blocks, 64 free inodes, 0 directories
+  Free blocks: 46091-47104
+  Free inodes: 2881-2944
+Group 46: (Blocks 47105-48128)
+  Block bitmap at 47105 (+0), Inode bitmap at 47106 (+1)
+  Inode table at 47107-47114 (+2)
+  1014 free blocks, 64 free inodes, 0 directories
+  Free blocks: 47115-48128
+  Free inodes: 2945-3008
+Group 47: (Blocks 48129-49152)
+  Block bitmap at 48129 (+0), Inode bitmap at 48130 (+1)
+  Inode table at 48131-48138 (+2)
+  1014 free blocks, 64 free inodes, 0 directories
+  Free blocks: 48139-49152
+  Free inodes: 3009-3072
+Group 48: (Blocks 49153-50176)
+  Block bitmap at 49153 (+0), Inode bitmap at 49154 (+1)
+  Inode table at 49155-49162 (+2)
+  1014 free blocks, 64 free inodes, 0 directories
+  Free blocks: 49163-50176
+  Free inodes: 3073-3136
+Group 49: (Blocks 50177-51200)
+  Backup superblock at 50177, Group descriptors at 50178-50193
+  Reserved GDT blocks at 50194-50449
+  Block bitmap at 50450 (+273), Inode bitmap at 50451 (+274)
+  Inode table at 50452-50459 (+275)
+  741 free blocks, 64 free inodes, 0 directories
+  Free blocks: 50460-51200
+  Free inodes: 3137-3200
+Group 50: (Blocks 51201-52224)
+  Block bitmap at 51201 (+0), Inode bitmap at 51202 (+1)
+  Inode table at 51203-51210 (+2)
+  1014 free blocks, 64 free inodes, 0 directories
+  Free blocks: 51211-52224
+  Free inodes: 3201-3264
+Group 51: (Blocks 52225-53248)
+  Block bitmap at 52225 (+0), Inode bitmap at 52226 (+1)
+  Inode table at 52227-52234 (+2)
+  1014 free blocks, 64 free inodes, 0 directories
+  Free blocks: 52235-53248
+  Free inodes: 3265-3328
+Group 52: (Blocks 53249-54272)
+  Block bitmap at 53249 (+0), Inode bitmap at 53250 (+1)
+  Inode table at 53251-53258 (+2)
+  1014 free blocks, 64 free inodes, 0 directories
+  Free blocks: 53259-54272
+  Free inodes: 3329-3392
+Group 53: (Blocks 54273-55296)
+  Block bitmap at 54273 (+0), Inode bitmap at 54274 (+1)
+  Inode table at 54275-54282 (+2)
+  1014 free blocks, 64 free inodes, 0 directories
+  Free blocks: 54283-55296
+  Free inodes: 3393-3456
+Group 54: (Blocks 55297-56320)
+  Block bitmap at 55297 (+0), Inode bitmap at 55298 (+1)
+  Inode table at 55299-55306 (+2)
+  1014 free blocks, 64 free inodes, 0 directories
+  Free blocks: 55307-56320
+  Free inodes: 3457-3520
+Group 55: (Blocks 56321-57344)
+  Block bitmap at 56321 (+0), Inode bitmap at 56322 (+1)
+  Inode table at 56323-56330 (+2)
+  1014 free blocks, 64 free inodes, 0 directories
+  Free blocks: 56331-57344
+  Free inodes: 3521-3584
+Group 56: (Blocks 57345-58368)
+  Block bitmap at 57345 (+0), Inode bitmap at 57346 (+1)
+  Inode table at 57347-57354 (+2)
+  1014 free blocks, 64 free inodes, 0 directories
+  Free blocks: 57355-58368
+  Free inodes: 3585-3648
+Group 57: (Blocks 58369-59392)
+  Block bitmap at 58369 (+0), Inode bitmap at 58370 (+1)
+  Inode table at 58371-58378 (+2)
+  1014 free blocks, 64 free inodes, 0 directories
+  Free blocks: 58379-59392
+  Free inodes: 3649-3712
+Group 58: (Blocks 59393-60416)
+  Block bitmap at 59393 (+0), Inode bitmap at 59394 (+1)
+  Inode table at 59395-59402 (+2)
+  1014 free blocks, 64 free inodes, 0 directories
+  Free blocks: 59403-60416
+  Free inodes: 3713-3776
+Group 59: (Blocks 60417-61440)
+  Block bitmap at 60417 (+0), Inode bitmap at 60418 (+1)
+  Inode table at 60419-60426 (+2)
+  1014 free blocks, 64 free inodes, 0 directories
+  Free blocks: 60427-61440
+  Free inodes: 3777-3840
+Group 60: (Blocks 61441-62464)
+  Block bitmap at 61441 (+0), Inode bitmap at 61442 (+1)
+  Inode table at 61443-61450 (+2)
+  1014 free blocks, 64 free inodes, 0 directories
+  Free blocks: 61451-62464
+  Free inodes: 3841-3904
+Group 61: (Blocks 62465-63488)
+  Block bitmap at 62465 (+0), Inode bitmap at 62466 (+1)
+  Inode table at 62467-62474 (+2)
+  1014 free blocks, 64 free inodes, 0 directories
+  Free blocks: 62475-63488
+  Free inodes: 3905-3968
+Group 62: (Blocks 63489-64512)
+  Block bitmap at 63489 (+0), Inode bitmap at 63490 (+1)
+  Inode table at 63491-63498 (+2)
+  1014 free blocks, 64 free inodes, 0 directories
+  Free blocks: 63499-64512
+  Free inodes: 3969-4032
+Group 63: (Blocks 64513-65536)
+  Block bitmap at 64513 (+0), Inode bitmap at 64514 (+1)
+  Inode table at 64515-64522 (+2)
+  1014 free blocks, 64 free inodes, 0 directories
+  Free blocks: 64523-65536
+  Free inodes: 4033-4096
+Group 64: (Blocks 65537-66560)
+  Block bitmap at 65537 (+0), Inode bitmap at 65538 (+1)
+  Inode table at 65539-65546 (+2)
+  1014 free blocks, 64 free inodes, 0 directories
+  Free blocks: 65547-66560
+  Free inodes: 4097-4160
+Group 65: (Blocks 66561-67584)
+  Block bitmap at 66561 (+0), Inode bitmap at 66562 (+1)
+  Inode table at 66563-66570 (+2)
+  1014 free blocks, 64 free inodes, 0 directories
+  Free blocks: 66571-67584
+  Free inodes: 4161-4224
+Group 66: (Blocks 67585-68608)
+  Block bitmap at 67585 (+0), Inode bitmap at 67586 (+1)
+  Inode table at 67587-67594 (+2)
+  1014 free blocks, 64 free inodes, 0 directories
+  Free blocks: 67595-68608
+  Free inodes: 4225-4288
+Group 67: (Blocks 68609-69632)
+  Block bitmap at 68609 (+0), Inode bitmap at 68610 (+1)
+  Inode table at 68611-68618 (+2)
+  1014 free blocks, 64 free inodes, 0 directories
+  Free blocks: 68619-69632
+  Free inodes: 4289-4352
+Group 68: (Blocks 69633-70656)
+  Block bitmap at 69633 (+0), Inode bitmap at 69634 (+1)
+  Inode table at 69635-69642 (+2)
+  1014 free blocks, 64 free inodes, 0 directories
+  Free blocks: 69643-70656
+  Free inodes: 4353-4416
+Group 69: (Blocks 70657-71680)
+  Block bitmap at 70657 (+0), Inode bitmap at 70658 (+1)
+  Inode table at 70659-70666 (+2)
+  1014 free blocks, 64 free inodes, 0 directories
+  Free blocks: 70667-71680
+  Free inodes: 4417-4480
+Group 70: (Blocks 71681-72704)
+  Block bitmap at 71681 (+0), Inode bitmap at 71682 (+1)
+  Inode table at 71683-71690 (+2)
+  1014 free blocks, 64 free inodes, 0 directories
+  Free blocks: 71691-72704
+  Free inodes: 4481-4544
+Group 71: (Blocks 72705-73728)
+  Block bitmap at 72705 (+0), Inode bitmap at 72706 (+1)
+  Inode table at 72707-72714 (+2)
+  1014 free blocks, 64 free inodes, 0 directories
+  Free blocks: 72715-73728
+  Free inodes: 4545-4608
+Group 72: (Blocks 73729-74752)
+  Block bitmap at 73729 (+0), Inode bitmap at 73730 (+1)
+  Inode table at 73731-73738 (+2)
+  1014 free blocks, 64 free inodes, 0 directories
+  Free blocks: 73739-74752
+  Free inodes: 4609-4672
+Group 73: (Blocks 74753-75776)
+  Block bitmap at 74753 (+0), Inode bitmap at 74754 (+1)
+  Inode table at 74755-74762 (+2)
+  1014 free blocks, 64 free inodes, 0 directories
+  Free blocks: 74763-75776
+  Free inodes: 4673-4736
+Group 74: (Blocks 75777-76800)
+  Block bitmap at 75777 (+0), Inode bitmap at 75778 (+1)
+  Inode table at 75779-75786 (+2)
+  1014 free blocks, 64 free inodes, 0 directories
+  Free blocks: 75787-76800
+  Free inodes: 4737-4800
+Group 75: (Blocks 76801-77824)
+  Block bitmap at 76801 (+0), Inode bitmap at 76802 (+1)
+  Inode table at 76803-76810 (+2)
+  1014 free blocks, 64 free inodes, 0 directories
+  Free blocks: 76811-77824
+  Free inodes: 4801-4864
+Group 76: (Blocks 77825-78848)
+  Block bitmap at 77825 (+0), Inode bitmap at 77826 (+1)
+  Inode table at 77827-77834 (+2)
+  1014 free blocks, 64 free inodes, 0 directories
+  Free blocks: 77835-78848
+  Free inodes: 4865-4928
+Group 77: (Blocks 78849-79872)
+  Block bitmap at 78849 (+0), Inode bitmap at 78850 (+1)
+  Inode table at 78851-78858 (+2)
+  1014 free blocks, 64 free inodes, 0 directories
+  Free blocks: 78859-79872
+  Free inodes: 4929-4992
+Group 78: (Blocks 79873-80896)
+  Block bitmap at 79873 (+0), Inode bitmap at 79874 (+1)
+  Inode table at 79875-79882 (+2)
+  1014 free blocks, 64 free inodes, 0 directories
+  Free blocks: 79883-80896
+  Free inodes: 4993-5056
+Group 79: (Blocks 80897-81920)
+  Block bitmap at 80897 (+0), Inode bitmap at 80898 (+1)
+  Inode table at 80899-80906 (+2)
+  1014 free blocks, 64 free inodes, 0 directories
+  Free blocks: 80907-81920
+  Free inodes: 5057-5120
+Group 80: (Blocks 81921-82944)
+  Block bitmap at 81921 (+0), Inode bitmap at 81922 (+1)
+  Inode table at 81923-81930 (+2)
+  1014 free blocks, 64 free inodes, 0 directories
+  Free blocks: 81931-82944
+  Free inodes: 5121-5184
+Group 81: (Blocks 82945-83968)
+  Backup superblock at 82945, Group descriptors at 82946-82961
+  Reserved GDT blocks at 82962-83217
+  Block bitmap at 83218 (+273), Inode bitmap at 83219 (+274)
+  Inode table at 83220-83227 (+275)
+  741 free blocks, 64 free inodes, 0 directories
+  Free blocks: 83228-83968
+  Free inodes: 5185-5248
+Group 82: (Blocks 83969-84992)
+  Block bitmap at 83969 (+0), Inode bitmap at 83970 (+1)
+  Inode table at 83971-83978 (+2)
+  1014 free blocks, 64 free inodes, 0 directories
+  Free blocks: 83979-84992
+  Free inodes: 5249-5312
+Group 83: (Blocks 84993-86016)
+  Block bitmap at 84993 (+0), Inode bitmap at 84994 (+1)
+  Inode table at 84995-85002 (+2)
+  1014 free blocks, 64 free inodes, 0 directories
+  Free blocks: 85003-86016
+  Free inodes: 5313-5376
+Group 84: (Blocks 86017-87040)
+  Block bitmap at 86017 (+0), Inode bitmap at 86018 (+1)
+  Inode table at 86019-86026 (+2)
+  1014 free blocks, 64 free inodes, 0 directories
+  Free blocks: 86027-87040
+  Free inodes: 5377-5440
+Group 85: (Blocks 87041-88064)
+  Block bitmap at 87041 (+0), Inode bitmap at 87042 (+1)
+  Inode table at 87043-87050 (+2)
+  1014 free blocks, 64 free inodes, 0 directories
+  Free blocks: 87051-88064
+  Free inodes: 5441-5504
+Group 86: (Blocks 88065-89088)
+  Block bitmap at 88065 (+0), Inode bitmap at 88066 (+1)
+  Inode table at 88067-88074 (+2)
+  1014 free blocks, 64 free inodes, 0 directories
+  Free blocks: 88075-89088
+  Free inodes: 5505-5568
+Group 87: (Blocks 89089-90112)
+  Block bitmap at 89089 (+0), Inode bitmap at 89090 (+1)
+  Inode table at 89091-89098 (+2)
+  1014 free blocks, 64 free inodes, 0 directories
+  Free blocks: 89099-90112
+  Free inodes: 5569-5632
+Group 88: (Blocks 90113-91136)
+  Block bitmap at 90113 (+0), Inode bitmap at 90114 (+1)
+  Inode table at 90115-90122 (+2)
+  1014 free blocks, 64 free inodes, 0 directories
+  Free blocks: 90123-91136
+  Free inodes: 5633-5696
+Group 89: (Blocks 91137-92160)
+  Block bitmap at 91137 (+0), Inode bitmap at 91138 (+1)
+  Inode table at 91139-91146 (+2)
+  1014 free blocks, 64 free inodes, 0 directories
+  Free blocks: 91147-92160
+  Free inodes: 5697-5760
+Group 90: (Blocks 92161-93184)
+  Block bitmap at 92161 (+0), Inode bitmap at 92162 (+1)
+  Inode table at 92163-92170 (+2)
+  1014 free blocks, 64 free inodes, 0 directories
+  Free blocks: 92171-93184
+  Free inodes: 5761-5824
+Group 91: (Blocks 93185-94208)
+  Block bitmap at 93185 (+0), Inode bitmap at 93186 (+1)
+  Inode table at 93187-93194 (+2)
+  1014 free blocks, 64 free inodes, 0 directories
+  Free blocks: 93195-94208
+  Free inodes: 5825-5888
+Group 92: (Blocks 94209-95232)
+  Block bitmap at 94209 (+0), Inode bitmap at 94210 (+1)
+  Inode table at 94211-94218 (+2)
+  1014 free blocks, 64 free inodes, 0 directories
+  Free blocks: 94219-95232
+  Free inodes: 5889-5952
+Group 93: (Blocks 95233-96256)
+  Block bitmap at 95233 (+0), Inode bitmap at 95234 (+1)
+  Inode table at 95235-95242 (+2)
+  1014 free blocks, 64 free inodes, 0 directories
+  Free blocks: 95243-96256
+  Free inodes: 5953-6016
+Group 94: (Blocks 96257-97280)
+  Block bitmap at 96257 (+0), Inode bitmap at 96258 (+1)
+  Inode table at 96259-96266 (+2)
+  1014 free blocks, 64 free inodes, 0 directories
+  Free blocks: 96267-97280
+  Free inodes: 6017-6080
+Group 95: (Blocks 97281-98304)
+  Block bitmap at 97281 (+0), Inode bitmap at 97282 (+1)
+  Inode table at 97283-97290 (+2)
+  1014 free blocks, 64 free inodes, 0 directories
+  Free blocks: 97291-98304
+  Free inodes: 6081-6144
+Group 96: (Blocks 98305-99328)
+  Block bitmap at 98305 (+0), Inode bitmap at 98306 (+1)
+  Inode table at 98307-98314 (+2)
+  1014 free blocks, 64 free inodes, 0 directories
+  Free blocks: 98315-99328
+  Free inodes: 6145-6208
+Group 97: (Blocks 99329-100352)
+  Block bitmap at 99329 (+0), Inode bitmap at 99330 (+1)
+  Inode table at 99331-99338 (+2)
+  1014 free blocks, 64 free inodes, 0 directories
+  Free blocks: 99339-100352
+  Free inodes: 6209-6272
+Group 98: (Blocks 100353-101376)
+  Block bitmap at 100353 (+0), Inode bitmap at 100354 (+1)
+  Inode table at 100355-100362 (+2)
+  1014 free blocks, 64 free inodes, 0 directories
+  Free blocks: 100363-101376
+  Free inodes: 6273-6336
+Group 99: (Blocks 101377-102400)
+  Block bitmap at 101377 (+0), Inode bitmap at 101378 (+1)
+  Inode table at 101379-101386 (+2)
+  1014 free blocks, 64 free inodes, 0 directories
+  Free blocks: 101387-102400
+  Free inodes: 6337-6400
+Group 100: (Blocks 102401-103424)
+  Block bitmap at 102401 (+0), Inode bitmap at 102402 (+1)
+  Inode table at 102403-102410 (+2)
+  1014 free blocks, 64 free inodes, 0 directories
+  Free blocks: 102411-103424
+  Free inodes: 6401-6464
+Group 101: (Blocks 103425-104448)
+  Block bitmap at 103425 (+0), Inode bitmap at 103426 (+1)
+  Inode table at 103427-103434 (+2)
+  1014 free blocks, 64 free inodes, 0 directories
+  Free blocks: 103435-104448
+  Free inodes: 6465-6528
+Group 102: (Blocks 104449-105472)
+  Block bitmap at 104449 (+0), Inode bitmap at 104450 (+1)
+  Inode table at 104451-104458 (+2)
+  1014 free blocks, 64 free inodes, 0 directories
+  Free blocks: 104459-105472
+  Free inodes: 6529-6592
+Group 103: (Blocks 105473-106496)
+  Block bitmap at 105473 (+0), Inode bitmap at 105474 (+1)
+  Inode table at 105475-105482 (+2)
+  1014 free blocks, 64 free inodes, 0 directories
+  Free blocks: 105483-106496
+  Free inodes: 6593-6656
+Group 104: (Blocks 106497-107520)
+  Block bitmap at 106497 (+0), Inode bitmap at 106498 (+1)
+  Inode table at 106499-106506 (+2)
+  1014 free blocks, 64 free inodes, 0 directories
+  Free blocks: 106507-107520
+  Free inodes: 6657-6720
+Group 105: (Blocks 107521-108544)
+  Block bitmap at 107521 (+0), Inode bitmap at 107522 (+1)
+  Inode table at 107523-107530 (+2)
+  1014 free blocks, 64 free inodes, 0 directories
+  Free blocks: 107531-108544
+  Free inodes: 6721-6784
+Group 106: (Blocks 108545-109568)
+  Block bitmap at 108545 (+0), Inode bitmap at 108546 (+1)
+  Inode table at 108547-108554 (+2)
+  1014 free blocks, 64 free inodes, 0 directories
+  Free blocks: 108555-109568
+  Free inodes: 6785-6848
+Group 107: (Blocks 109569-110592)
+  Block bitmap at 109569 (+0), Inode bitmap at 109570 (+1)
+  Inode table at 109571-109578 (+2)
+  1014 free blocks, 64 free inodes, 0 directories
+  Free blocks: 109579-110592
+  Free inodes: 6849-6912
+Group 108: (Blocks 110593-111616)
+  Block bitmap at 110593 (+0), Inode bitmap at 110594 (+1)
+  Inode table at 110595-110602 (+2)
+  1014 free blocks, 64 free inodes, 0 directories
+  Free blocks: 110603-111616
+  Free inodes: 6913-6976
+Group 109: (Blocks 111617-112640)
+  Block bitmap at 111617 (+0), Inode bitmap at 111618 (+1)
+  Inode table at 111619-111626 (+2)
+  1014 free blocks, 64 free inodes, 0 directories
+  Free blocks: 111627-112640
+  Free inodes: 6977-7040
+Group 110: (Blocks 112641-113664)
+  Block bitmap at 112641 (+0), Inode bitmap at 112642 (+1)
+  Inode table at 112643-112650 (+2)
+  1014 free blocks, 64 free inodes, 0 directories
+  Free blocks: 112651-113664
+  Free inodes: 7041-7104
+Group 111: (Blocks 113665-114688)
+  Block bitmap at 113665 (+0), Inode bitmap at 113666 (+1)
+  Inode table at 113667-113674 (+2)
+  1014 free blocks, 64 free inodes, 0 directories
+  Free blocks: 113675-114688
+  Free inodes: 7105-7168
+Group 112: (Blocks 114689-115712)
+  Block bitmap at 114689 (+0), Inode bitmap at 114690 (+1)
+  Inode table at 114691-114698 (+2)
+  1014 free blocks, 64 free inodes, 0 directories
+  Free blocks: 114699-115712
+  Free inodes: 7169-7232
+Group 113: (Blocks 115713-116736)
+  Block bitmap at 115713 (+0), Inode bitmap at 115714 (+1)
+  Inode table at 115715-115722 (+2)
+  1014 free blocks, 64 free inodes, 0 directories
+  Free blocks: 115723-116736
+  Free inodes: 7233-7296
+Group 114: (Blocks 116737-117760)
+  Block bitmap at 116737 (+0), Inode bitmap at 116738 (+1)
+  Inode table at 116739-116746 (+2)
+  1014 free blocks, 64 free inodes, 0 directories
+  Free blocks: 116747-117760
+  Free inodes: 7297-7360
+Group 115: (Blocks 117761-118784)
+  Block bitmap at 117761 (+0), Inode bitmap at 117762 (+1)
+  Inode table at 117763-117770 (+2)
+  1014 free blocks, 64 free inodes, 0 directories
+  Free blocks: 117771-118784
+  Free inodes: 7361-7424
+Group 116: (Blocks 118785-119808)
+  Block bitmap at 118785 (+0), Inode bitmap at 118786 (+1)
+  Inode table at 118787-118794 (+2)
+  1014 free blocks, 64 free inodes, 0 directories
+  Free blocks: 118795-119808
+  Free inodes: 7425-7488
+Group 117: (Blocks 119809-120832)
+  Block bitmap at 119809 (+0), Inode bitmap at 119810 (+1)
+  Inode table at 119811-119818 (+2)
+  1014 free blocks, 64 free inodes, 0 directories
+  Free blocks: 119819-120832
+  Free inodes: 7489-7552
+Group 118: (Blocks 120833-121856)
+  Block bitmap at 120833 (+0), Inode bitmap at 120834 (+1)
+  Inode table at 120835-120842 (+2)
+  1014 free blocks, 64 free inodes, 0 directories
+  Free blocks: 120843-121856
+  Free inodes: 7553-7616
+Group 119: (Blocks 121857-122880)
+  Block bitmap at 121857 (+0), Inode bitmap at 121858 (+1)
+  Inode table at 121859-121866 (+2)
+  1014 free blocks, 64 free inodes, 0 directories
+  Free blocks: 121867-122880
+  Free inodes: 7617-7680
+Group 120: (Blocks 122881-123904)
+  Block bitmap at 122881 (+0), Inode bitmap at 122882 (+1)
+  Inode table at 122883-122890 (+2)
+  1014 free blocks, 64 free inodes, 0 directories
+  Free blocks: 122891-123904
+  Free inodes: 7681-7744
+Group 121: (Blocks 123905-124928)
+  Block bitmap at 123905 (+0), Inode bitmap at 123906 (+1)
+  Inode table at 123907-123914 (+2)
+  1014 free blocks, 64 free inodes, 0 directories
+  Free blocks: 123915-124928
+  Free inodes: 7745-7808
+Group 122: (Blocks 124929-125952)
+  Block bitmap at 124929 (+0), Inode bitmap at 124930 (+1)
+  Inode table at 124931-124938 (+2)
+  1014 free blocks, 64 free inodes, 0 directories
+  Free blocks: 124939-125952
+  Free inodes: 7809-7872
+Group 123: (Blocks 125953-126976)
+  Block bitmap at 125953 (+0), Inode bitmap at 125954 (+1)
+  Inode table at 125955-125962 (+2)
+  1014 free blocks, 64 free inodes, 0 directories
+  Free blocks: 125963-126976
+  Free inodes: 7873-7936
+Group 124: (Blocks 126977-128000)
+  Block bitmap at 126977 (+0), Inode bitmap at 126978 (+1)
+  Inode table at 126979-126986 (+2)
+  1014 free blocks, 64 free inodes, 0 directories
+  Free blocks: 126987-128000
+  Free inodes: 7937-8000
+Group 125: (Blocks 128001-129024)
+  Backup superblock at 128001, Group descriptors at 128002-128017
+  Reserved GDT blocks at 128018-128273
+  Block bitmap at 128274 (+273), Inode bitmap at 128275 (+274)
+  Inode table at 128276-128283 (+275)
+  741 free blocks, 64 free inodes, 0 directories
+  Free blocks: 128284-129024
+  Free inodes: 8001-8064
+Group 126: (Blocks 129025-130048)
+  Block bitmap at 129025 (+0), Inode bitmap at 129026 (+1)
+  Inode table at 129027-129034 (+2)
+  1014 free blocks, 64 free inodes, 0 directories
+  Free blocks: 129035-130048
+  Free inodes: 8065-8128
+Group 127: (Blocks 130049-131071)
+  Block bitmap at 130049 (+0), Inode bitmap at 130050 (+1)
+  Inode table at 130051-130058 (+2)
+  1013 free blocks, 64 free inodes, 0 directories
+  Free blocks: 130059-131071
+  Free inodes: 8129-8192
diff --git a/tests/m_desc_size_128/script b/tests/m_desc_size_128/script
new file mode 100644 (file)
index 0000000..de3def9
--- /dev/null
@@ -0,0 +1,4 @@
+DESCRIPTION="enable 128-byte group descriptor on mkfs"
+FS_SIZE=131072
+MKE2FS_OPTS="-b 1024 -O 64bit,extents -g 1024 -N 8192 -E desc_size=128"
+. $cmd_dir/run_mke2fs
index 30532a5..6a8b0e9 100755 (executable)
@@ -149,6 +149,7 @@ then
        return 1
 fi
 
+rm $TMPFILE
 return 0
 
 }
index 8544b6d..20dd6f2 100644 (file)
@@ -30,7 +30,7 @@ struct subst_entry {
        struct subst_entry *next;
 };
 
-struct subst_entry *subst_table = 0;
+static struct subst_entry *subst_table = 0;
 
 static int add_subst(char *name, char *value)
 {