Whamcloud - gitweb
Merge branch 'maint' into next
authorTheodore Ts'o <tytso@mit.edu>
Sun, 9 Dec 2007 22:03:01 +0000 (17:03 -0500)
committerTheodore Ts'o <tytso@mit.edu>
Sun, 9 Dec 2007 22:03:01 +0000 (17:03 -0500)
Conflicts:

lib/ext2fs/closefs.c

79 files changed:
Makefile.in
configure
configure.in
debian/rules
debugfs/debugfs.c
debugfs/debugfs.h
debugfs/logdump.c
debugfs/set_fields.c
debugfs/util.c
doc/libext2fs.texinfo
e2fsck/Makefile.in
e2fsck/e2fsck.8.in
e2fsck/e2fsck.h
e2fsck/journal.c
e2fsck/pass1.c
e2fsck/pass2.c
e2fsck/pass3.c
e2fsck/pass4.c
e2fsck/pass5.c
e2fsck/rehash.c
e2fsck/super.c
e2fsck/swapfs.c [deleted file]
e2fsck/unix.c
e2fsck/util.c
ext2ed/doc/ext2ed-design.sgml
lib/blkid/blkid.pc.in
lib/blkid/devname.c
lib/blkid/getsize.c
lib/blkid/probe.c
lib/blkid/test_probe.in
lib/e2p/feature.c
lib/e2p/fgetflags.c
lib/e2p/fsetflags.c
lib/e2p/iod.c
lib/et/com_err.texinfo
lib/ext2fs/Makefile.in
lib/ext2fs/bitmaps.c
lib/ext2fs/bitops.c
lib/ext2fs/bitops.h
lib/ext2fs/bmap.c
lib/ext2fs/check_desc.c
lib/ext2fs/closefs.c
lib/ext2fs/cmp_bitmaps.c [deleted file]
lib/ext2fs/dirblock.c
lib/ext2fs/ext2_fs.h
lib/ext2fs/ext2_io.h
lib/ext2fs/ext2fs.h
lib/ext2fs/ext_attr.c
lib/ext2fs/freefs.c
lib/ext2fs/gen_bitmap.c
lib/ext2fs/imager.c
lib/ext2fs/ind_block.c
lib/ext2fs/initialize.c
lib/ext2fs/inode.c
lib/ext2fs/ismounted.c
lib/ext2fs/openfs.c
lib/ext2fs/rs_bitmap.c [deleted file]
lib/ext2fs/rw_bitmaps.c
lib/ext2fs/swapfs.c
lib/ext2fs/test_io.c
lib/ext2fs/unix_io.c
lib/ss/ss.pc.in
misc/Makefile.in
misc/badblocks.c
misc/chattr.1.in
misc/chattr.c
misc/dumpe2fs.c
misc/e2image.c
misc/mke2fs.c
misc/tune2fs.c
misc/util.c
misc/util.h
resize/resize2fs.c
tests/f_swapfs/debugfs.cmd [deleted file]
tests/f_swapfs/expect [deleted file]
tests/f_swapfs/image [deleted file]
tests/f_swapfs/image.gz [deleted file]
tests/f_swapfs/name [deleted file]
tests/f_swapfs/script [deleted file]

index f37640e..53ca526 100644 (file)
@@ -10,7 +10,7 @@ INSTALL = @INSTALL@
 @RESIZER_CMT@RESIZE_DIR= resize
 @DEBUGFS_CMT@DEBUGFS_DIR= debugfs
 
-LIB_SUBDIRS=lib/et lib/ss lib/e2p lib/ext2fs lib/uuid lib/blkid intl
+LIB_SUBDIRS=lib/et lib/ss lib/e2p lib/uuid lib/ext2fs lib/blkid intl
 PROG_SUBDIRS=e2fsck $(DEBUGFS_DIR) misc $(RESIZE_DIR) tests/progs po
 SUBDIRS=util $(LIB_SUBDIRS) $(PROG_SUBDIRS) tests
 
index 5c8448a..ee087b4 100755 (executable)
--- a/configure
+++ b/configure
@@ -684,7 +684,6 @@ CHECKER_CMT
 LIB_EXT
 STATIC_LIB_EXT
 PROFILED_LIB_EXT
-SWAPFS_CMT
 DEBUGFS_CMT
 IMAGER_CMT
 RESIZER_CMT
@@ -1368,7 +1367,6 @@ Optional Features:
   --enable-jbd-debug     enable journal debugging
   --enable-blkid-debug    enable blkid debugging
   --enable-testio-debug   enable the use of the test I/O manager for debugging
-  --disable-swapfs       disable support of legacy byte-swapped filesystems
   --disable-debugfs      disable support of debugfs program
   --disable-imager       disable support of e2image program
   --disable-resizer      disable support of e2resize program
@@ -3992,32 +3990,6 @@ else
 
 fi
 
-# Check whether --enable-swapfs was given.
-if test "${enable_swapfs+set}" = set; then
-  enableval=$enable_swapfs; if test "$enableval" = "no"
-then
-       SWAPFS_CMT=#
-       echo "Disabling swapfs support"
-else
-       SWAPFS_CMT=
-       cat >>confdefs.h <<\_ACEOF
-#define ENABLE_SWAPFS 1
-_ACEOF
-
-       echo "Enabling swapfs support"
-fi
-
-else
-  SWAPFS_CMT=
-echo "Enabling swapfs support by default"
-cat >>confdefs.h <<\_ACEOF
-#define ENABLE_SWAPFS 1
-_ACEOF
-
-
-fi
-
-
 # Check whether --enable-debugfs was given.
 if test "${enable_debugfs+set}" = set; then
   enableval=$enable_debugfs; if test "$enableval" = "no"
@@ -15694,11 +15666,11 @@ CHECKER_CMT!$CHECKER_CMT$ac_delim
 LIB_EXT!$LIB_EXT$ac_delim
 STATIC_LIB_EXT!$STATIC_LIB_EXT$ac_delim
 PROFILED_LIB_EXT!$PROFILED_LIB_EXT$ac_delim
-SWAPFS_CMT!$SWAPFS_CMT$ac_delim
 DEBUGFS_CMT!$DEBUGFS_CMT$ac_delim
 IMAGER_CMT!$IMAGER_CMT$ac_delim
 RESIZER_CMT!$RESIZER_CMT$ac_delim
 E2FSCK_TYPE!$E2FSCK_TYPE$ac_delim
+FSCK_PROG!$FSCK_PROG$ac_delim
 _ACEOF
 
   if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 76; then
@@ -15768,7 +15740,6 @@ _ACEOF
 ac_delim='%!_!# '
 for ac_last_try in false false false false false :; do
   cat >conf$$subs.sed <<_ACEOF
-FSCK_PROG!$FSCK_PROG$ac_delim
 FSCK_MAN!$FSCK_MAN$ac_delim
 E2INITRD_PROG!$E2INITRD_PROG$ac_delim
 E2INITRD_MAN!$E2INITRD_MAN$ac_delim
@@ -15851,7 +15822,7 @@ LIBOBJS!$LIBOBJS$ac_delim
 LTLIBOBJS!$LTLIBOBJS$ac_delim
 _ACEOF
 
-  if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 81; then
+  if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 80; then
     break
   elif $ac_last_try; then
     { { echo "$as_me:$LINENO: error: could not make $CONFIG_STATUS" >&5
index 011df1a..e434454 100644 (file)
@@ -361,26 +361,6 @@ fi
 echo "Disabling testio debugging by default"
 )
 dnl
-dnl handle --enable-swapfs
-dnl
-AC_ARG_ENABLE([swapfs],
-[  --disable-swapfs              disable support of legacy byte-swapped filesystems],
-if test "$enableval" = "no"
-then
-       SWAPFS_CMT=#
-       echo "Disabling swapfs support"
-else
-       SWAPFS_CMT=
-       AC_DEFINE(ENABLE_SWAPFS)
-       echo "Enabling swapfs support"
-fi
-,
-SWAPFS_CMT=
-echo "Enabling swapfs support by default"
-AC_DEFINE(ENABLE_SWAPFS)
-)
-AC_SUBST(SWAPFS_CMT)
-dnl
 dnl handle --enable-debugfs
 dnl
 AC_ARG_ENABLE([debugfs],
index 842965e..d3e2494 100755 (executable)
@@ -92,13 +92,11 @@ STD_CONF_FLAGS = --with-ccopts="${CCOPTS}" --enable-compression \
                --enable-blkid-devmapper
 
 BF_CONF_FLAGS = --with-ccopts="${CCOPTS} ${BF_CCOPTS}" \
-       --disable-nls --disable-swapfs --disable-imager \
+       --disable-nls --disable-imager \
        --disable-debugfs  --disable-e2initrd-helper
 
 MIPS_NOPIC_CONF_FLAGS = --with-ccopts="${CCOPTS}" \
-       --disable-nls \
-       --disable-swapfs --disable-imager \
-        --disable-resizer # --disable-debugfs
+       --disable-nls --disable-imager --disable-resizer # --disable-debugfs
 
 # we can't use those flags at configure time
 MIPS_CFLAGS= -G 0 -fno-pic -mno-abicalls
index 6635471..8261d18 100644 (file)
@@ -569,10 +569,6 @@ void internal_dump_inode(FILE *out, const char *prefix,
                frag = inode->osd2.hurd2.h_i_frag;
                fsize = inode->osd2.hurd2.h_i_fsize;
                break;
-           case EXT2_OS_MASIX:
-               frag = inode->osd2.masix2.m_i_frag;
-               fsize = inode->osd2.masix2.m_i_fsize;
-               break;
            default:
                frag = fsize = 0;
        }
@@ -789,7 +785,8 @@ static void modify_u8(char *com, const char *prompt,
 
        sprintf(buf, format, *val);
        printf("%30s    [%s] ", prompt, buf);
-       fgets(buf, sizeof(buf), stdin);
+       if (!fgets(buf, sizeof(buf), stdin))
+               return;
        if (buf[strlen (buf) - 1] == '\n')
                buf[strlen (buf) - 1] = '\0';
        if (!buf[0])
@@ -810,7 +807,8 @@ static void modify_u16(char *com, const char *prompt,
 
        sprintf(buf, format, *val);
        printf("%30s    [%s] ", prompt, buf);
-       fgets(buf, sizeof(buf), stdin);
+       if (!fgets(buf, sizeof(buf), stdin))
+               return;
        if (buf[strlen (buf) - 1] == '\n')
                buf[strlen (buf) - 1] = '\0';
        if (!buf[0])
@@ -831,7 +829,8 @@ static void modify_u32(char *com, const char *prompt,
 
        sprintf(buf, format, *val);
        printf("%30s    [%s] ", prompt, buf);
-       fgets(buf, sizeof(buf), stdin);
+       if (!fgets(buf, sizeof(buf), stdin))
+               return;
        if (buf[strlen (buf) - 1] == '\n')
                buf[strlen (buf) - 1] = '\0';
        if (!buf[0])
@@ -899,10 +898,6 @@ void do_modify_inode(int argc, char *argv[])
                frag = &inode.osd2.hurd2.h_i_frag;
                fsize = &inode.osd2.hurd2.h_i_fsize;
                break;
-           case EXT2_OS_MASIX:
-               frag = &inode.osd2.masix2.m_i_frag;
-               fsize = &inode.osd2.masix2.m_i_fsize;
-               break;
            default:
                frag = fsize = 0;
        }
@@ -1011,7 +1006,7 @@ static void make_link(char *sourcename, char *destname)
        struct ext2_inode inode;
        int             retval;
        ext2_ino_t      dir;
-       char            *dest, *cp, *basename;
+       char            *dest, *cp, *base_name;
 
        /*
         * Get the source inode
@@ -1019,17 +1014,17 @@ static void make_link(char *sourcename, char *destname)
        ino = string_to_inode(sourcename);
        if (!ino)
                return;
-       basename = strrchr(sourcename, '/');
-       if (basename)
-               basename++;
+       base_name = strrchr(sourcename, '/');
+       if (base_name)
+               base_name++;
        else
-               basename = sourcename;
+               base_name = sourcename;
        /*
         * Figure out the destination.  First see if it exists and is
         * a directory.  
         */
        if (! (retval=ext2fs_namei(current_fs, root, cwd, destname, &dir)))
-               dest = basename;
+               dest = base_name;
        else {
                /*
                 * OK, it doesn't exist.  See if it is
@@ -1123,19 +1118,19 @@ static void unlink_file_by_name(char *filename)
 {
        int             retval;
        ext2_ino_t      dir;
-       char            *basename;
+       char            *base_name;
        
-       basename = strrchr(filename, '/');
-       if (basename) {
-               *basename++ = '\0';
+       base_name = strrchr(filename, '/');
+       if (base_name) {
+               *base_name++ = '\0';
                dir = string_to_inode(filename);
                if (!dir)
                        return;
        } else {
                dir = cwd;
-               basename = filename;
+               base_name = filename;
        }
-       retval = ext2fs_unlink(current_fs, dir, basename, 0, 0);
+       retval = ext2fs_unlink(current_fs, dir, base_name, 0, 0);
        if (retval)
                com_err("unlink_file_by_name", retval, 0);
        return;
index d72c7ac..003c19a 100644 (file)
@@ -78,6 +78,7 @@ extern void do_ncheck(int argc, char **argv);
 /* set_fields.c */
 extern void do_set_super(int argc, char **);
 extern void do_set_inode(int argc, char **);
+extern void do_set_block_group_descriptor(int argc, char **);
 
 /* unused.c */
 extern void do_dump_unused(int argc, char **argv);
index 2bf67b5..cf3aae6 100644 (file)
@@ -36,11 +36,11 @@ extern char *optarg;
 
 enum journal_location {JOURNAL_IS_INTERNAL, JOURNAL_IS_EXTERNAL};
 
-#define ANY_BLOCK ((unsigned int) -1)
+#define ANY_BLOCK ((blk_t) -1)
 
 int            dump_all, dump_contents, dump_descriptors;
-unsigned int   block_to_dump, group_to_dump, bitmap_to_dump;
-unsigned int   inode_block_to_dump, inode_offset_to_dump, bitmap_to_dump;
+blk_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;
 
 struct journal_source 
@@ -350,7 +350,7 @@ static void dump_journal(char *cmdname, FILE *out_file,
 
        jsb = (journal_superblock_t *) buf;
        sb = (struct ext2_super_block *) (buf+1024);
-#ifdef ENABLE_SWAPFS
+#ifdef WORDS_BIGENDIAN
        if (sb->s_magic == ext2fs_swab16(EXT2_SUPER_MAGIC)) 
                ext2fs_swap_super(sb);
 #endif
@@ -365,8 +365,8 @@ static void dump_journal(char *cmdname, FILE *out_file,
                if (dump_all) {
                        fprintf(out_file, "\tuuid=%s\n", jsb_buffer);
                        fprintf(out_file, "\tblocksize=%d\n", blocksize);
-                       fprintf(out_file, "\tjournal data size %ld\n",
-                               (long) sb->s_blocks_count);
+                       fprintf(out_file, "\tjournal data size %lu\n",
+                               sb->s_blocks_count);
                }
        }
        
index b50ff7c..9ff7f8c 100644 (file)
@@ -22,6 +22,9 @@
 #ifdef HAVE_ERRNO_H
 #include <errno.h>
 #endif
+#if HAVE_STRINGS_H
+#include <strings.h>
+#endif
 #include <fcntl.h>
 #include <utime.h>
 
index a490d2c..7031850 100644 (file)
@@ -190,7 +190,7 @@ char *time_to_string(__u32 cl)
 {
        static int      do_gmt = -1;
        time_t          t = (time_t) cl;
-       char *          tz;
+       const char      *tz;
 
        if (do_gmt == -1) {
                /* The diet libc doesn't respect the TZ environemnt variable */
index 1277c3a..82661d0 100644 (file)
@@ -7,11 +7,9 @@
 
 @ifinfo
 @dircategory Development
-@format
-START-INFO-DIR-ENTRY
+@direntry
 * libext2fs: (libext2fs.info).                  The EXT2FS library.
-END-INFO-DIR-ENTRY
-@end format
+@end direntry
 @end ifinfo
 
 @c smallbook
index 95c4399..7750759 100644 (file)
@@ -62,7 +62,7 @@ COMPILE_ET=$(top_builddir)/lib/et/compile_et --build-tree
 #MCHECK= -DMCHECK
 
 OBJS= dict.o unix.o e2fsck.o super.o pass1.o pass1b.o pass2.o pass3.o pass4.o \
-       pass5.o journal.o swapfs.o badblocks.o util.o dirinfo.o dx_dirinfo.o \
+       pass5.o journal.o badblocks.o util.o dirinfo.o dx_dirinfo.o \
        ehandler.o problem.o message.o recovery.o region.o revoke.o \
        ea_refcount.o rehash.o profile.o prof_err.o $(MTRACE_OBJ)
 
@@ -71,7 +71,7 @@ PROFILED_OBJS= profiled/dict.o profiled/unix.o profiled/e2fsck.o \
        profiled/pass2.o profiled/pass3.o profiled/pass4.o profiled/pass5.o \
        profiled/journal.o profiled/badblocks.o profiled/util.o \
        profiled/dirinfo.o profiled/dx_dirinfo.o profiled/ehandler.o \
-       profiled/message.o profiled/problem.o profiled/swapfs.o \
+       profiled/message.o profiled/problem.o \
        profiled/recovery.o profiled/region.o profiled/revoke.o \
        profiled/ea_refcount.o profiled/rehash.o profiled/profile.o \
        profiled/prof_err.o
@@ -96,7 +96,6 @@ SRCS= $(srcdir)/e2fsck.c \
        $(srcdir)/ehandler.c \
        $(srcdir)/problem.c \
        $(srcdir)/message.c \
-       $(srcdir)/swapfs.c \
        $(srcdir)/ea_refcount.c \
        $(srcdir)/rehash.c \
        $(srcdir)/region.c \
@@ -382,13 +381,6 @@ message.o: $(srcdir)/message.c $(srcdir)/e2fsck.h \
  $(top_builddir)/lib/ext2fs/ext2_err.h $(top_srcdir)/lib/ext2fs/bitops.h \
  $(top_srcdir)/lib/blkid/blkid.h $(top_builddir)/lib/blkid/blkid_types.h \
  $(srcdir)/profile.h prof_err.h $(srcdir)/problem.h
-swapfs.o: $(srcdir)/swapfs.c $(top_srcdir)/lib/et/com_err.h \
- $(srcdir)/e2fsck.h $(top_srcdir)/lib/ext2fs/ext2_fs.h \
- $(top_builddir)/lib/ext2fs/ext2_types.h $(top_srcdir)/lib/ext2fs/ext2fs.h \
- $(top_srcdir)/lib/ext2fs/ext2_fs.h $(top_srcdir)/lib/ext2fs/ext2_io.h \
- $(top_builddir)/lib/ext2fs/ext2_err.h $(top_srcdir)/lib/ext2fs/bitops.h \
- $(top_srcdir)/lib/blkid/blkid.h $(top_builddir)/lib/blkid/blkid_types.h \
- $(srcdir)/profile.h prof_err.h
 ea_refcount.o: $(srcdir)/ea_refcount.c $(srcdir)/e2fsck.h \
  $(top_srcdir)/lib/ext2fs/ext2_fs.h $(top_builddir)/lib/ext2fs/ext2_types.h \
  $(top_srcdir)/lib/ext2fs/ext2fs.h $(top_srcdir)/lib/ext2fs/ext2_fs.h \
index c1e40c9..eb560bf 100644 (file)
@@ -8,7 +8,7 @@ e2fsck \- check a Linux ext2/ext3 file system
 .SH SYNOPSIS
 .B e2fsck
 [
-.B \-pacnyrdfkvstDFSV
+.B \-pacnyrdfkvtDFV
 ]
 [
 .B \-b
@@ -256,17 +256,6 @@ options.
 .B \-r
 This option does nothing at all; it is provided only for backwards
 compatibility.
-.TP 
-.B \-s
-This option will byte-swap the filesystem so that it is using the normalized, 
-standard byte-order (which is i386 or little endian).  If the filesystem is
-already in the standard byte-order, 
-.B e2fsck 
-will take no action.
-.TP
-.B \-S
-This option will byte-swap the filesystem, regardless of its current 
-byte-order.
 .TP
 .B \-t
 Print timing statistics for
index 5af82d5..9ccffd8 100644 (file)
@@ -135,6 +135,8 @@ struct resource_track {
        struct timeval user_start;
        struct timeval system_start;
        void    *brk_start;
+       unsigned long long bytes_read;
+       unsigned long long bytes_written;
 };
 #endif
 
@@ -456,9 +458,6 @@ void e2fsck_rehash_directories(e2fsck_t ctx);
 void check_super_block(e2fsck_t ctx);
 int check_backup_super_block(e2fsck_t ctx);
 
-/* swapfs.c */
-void swap_filesys(e2fsck_t ctx);
-
 /* util.c */
 extern void *e2fsck_allocate_memory(e2fsck_t ctx, unsigned int size,
                                    const char *description);
@@ -471,8 +470,10 @@ extern void preenhalt(e2fsck_t ctx);
 extern char *string_copy(e2fsck_t ctx, const char *str, int len);
 #ifdef RESOURCE_TRACK
 extern void print_resource_track(const char *desc,
-                                struct resource_track *track);
-extern void init_resource_track(struct resource_track *track);
+                                struct resource_track *track,
+                                io_channel channel);
+extern void init_resource_track(struct resource_track *track,
+                               io_channel channel);
 #endif
 extern int inode_has_valid_blocks(struct ext2_inode *inode);
 extern void e2fsck_read_inode(e2fsck_t ctx, unsigned long ino,
index dbe1bf1..f5f4647 100644 (file)
@@ -385,7 +385,7 @@ static errcode_t e2fsck_get_journal(e2fsck_t ctx, journal_t **ret_journal)
                memcpy(&jsuper, start ? bh->b_data :  bh->b_data + 1024,
                       sizeof(jsuper));
                brelse(bh);
-#ifdef EXT2FS_ENABLE_SWAPFS
+#ifdef WORDS_BIGENDIAN
                if (jsuper.s_magic == ext2fs_swab16(EXT2_SUPER_MAGIC)) 
                        ext2fs_swap_super(&jsuper);
 #endif
index b4db8ef..56218ae 100644 (file)
@@ -316,7 +316,7 @@ fix:
 
        /* simple remove all possible EA(s) */
        *((__u32 *)start) = 0UL;
-       e2fsck_write_inode_full(ctx, pctx->ino, (struct ext2_inode *) inode,
+       e2fsck_write_inode_full(ctx, pctx->ino, pctx->inode,
                                EXT2_INODE_SIZE(sb), "pass1");
 }
 
@@ -485,7 +485,7 @@ void e2fsck_pass1(e2fsck_t ctx)
        int             inode_size;
        
 #ifdef RESOURCE_TRACK
-       init_resource_track(&rtrack);
+       init_resource_track(&rtrack, ctx->fs->io);
 #endif
        clear_problem_context(&pctx);
 
@@ -834,10 +834,6 @@ void e2fsck_pass1(e2fsck_t ctx)
                        frag = inode->osd2.hurd2.h_i_frag;
                        fsize = inode->osd2.hurd2.h_i_fsize;
                        break;
-                   case EXT2_OS_MASIX:
-                       frag = inode->osd2.masix2.m_i_frag;
-                       fsize = inode->osd2.masix2.m_i_fsize;
-                       break;
                    default:
                        frag = fsize = 0;
                }
@@ -1013,7 +1009,7 @@ endit:
 #ifdef RESOURCE_TRACK
        if (ctx->options & E2F_OPT_TIME2) {
                e2fsck_clear_progbar(ctx);
-               print_resource_track(_("Pass 1"), &rtrack);
+               print_resource_track(_("Pass 1"), &rtrack, ctx->fs->io);
        }
 #endif
 }
index f58e5a9..4c80fb6 100644 (file)
@@ -102,7 +102,7 @@ void e2fsck_pass2(e2fsck_t ctx)
        int                     bad_dir;
 
 #ifdef RESOURCE_TRACK
-       init_resource_track(&rtrack);
+       init_resource_track(&rtrack, ctx->fs->io);
 #endif
 
        clear_problem_context(&cd.pctx);
@@ -289,7 +289,7 @@ void e2fsck_pass2(e2fsck_t ctx)
 #ifdef RESOURCE_TRACK
        if (ctx->options & E2F_OPT_TIME2) {
                e2fsck_clear_progbar(ctx);
-               print_resource_track(_("Pass 2"), &rtrack);
+               print_resource_track(_("Pass 2"), &rtrack, fs->io);
        }
 #endif
 }
@@ -1255,10 +1255,6 @@ extern int e2fsck_process_bad_inode(e2fsck_t ctx, ext2_ino_t dir,
                frag = &inode.osd2.hurd2.h_i_frag;
                fsize = &inode.osd2.hurd2.h_i_fsize;
                break;
-           case EXT2_OS_MASIX:
-               frag = &inode.osd2.masix2.m_i_frag;
-               fsize = &inode.osd2.masix2.m_i_fsize;
-               break;
            default:
                frag = fsize = 0;
        }
index b9c6edd..867cbf8 100644 (file)
@@ -61,7 +61,7 @@ void e2fsck_pass3(e2fsck_t ctx)
        unsigned long maxdirs, count;
 
 #ifdef RESOURCE_TRACK
-       init_resource_track(&rtrack);
+       init_resource_track(&rtrack, ctx->fs->io);
 #endif
 
        clear_problem_context(&pctx);
@@ -87,7 +87,8 @@ void e2fsck_pass3(e2fsck_t ctx)
 #ifdef RESOURCE_TRACK
        if (ctx->options & E2F_OPT_TIME) {
                e2fsck_clear_progbar(ctx);
-               print_resource_track(_("Peak memory"), &ctx->global_rtrack);
+               print_resource_track(_("Peak memory"), &ctx->global_rtrack,
+                                    NULL);
        }
 #endif
 
@@ -142,7 +143,7 @@ abort_exit:
 #ifdef RESOURCE_TRACK
        if (ctx->options & E2F_OPT_TIME2) {
                e2fsck_clear_progbar(ctx);
-               print_resource_track(_("Pass 3"), &rtrack);
+               print_resource_track(_("Pass 3"), &rtrack, ctx->fs->io);
        }
 #endif
 }
index dfb3a37..0fb8ee7 100644 (file)
@@ -93,7 +93,7 @@ void e2fsck_pass4(e2fsck_t ctx)
        int     group, maxgroup;
        
 #ifdef RESOURCE_TRACK
-       init_resource_track(&rtrack);
+       init_resource_track(&rtrack, ctx->fs->io);
 #endif
 
 #ifdef MTRACE
@@ -173,7 +173,7 @@ errout:
 #ifdef RESOURCE_TRACK
        if (ctx->options & E2F_OPT_TIME2) {
                e2fsck_clear_progbar(ctx);
-               print_resource_track(_("Pass 4"), &rtrack);
+               print_resource_track(_("Pass 4"), &rtrack, ctx->fs->io);
        }
 #endif
 }
index 56619c3..8e3794d 100644 (file)
@@ -30,7 +30,7 @@ void e2fsck_pass5(e2fsck_t ctx)
 #endif
 
 #ifdef RESOURCE_TRACK
-       init_resource_track(&rtrack);
+       init_resource_track(&rtrack, ctx->fs->io);
 #endif
        
        clear_problem_context(&pctx);
@@ -67,7 +67,7 @@ void e2fsck_pass5(e2fsck_t ctx)
 #ifdef RESOURCE_TRACK
        if (ctx->options & E2F_OPT_TIME2) {
                e2fsck_clear_progbar(ctx);
-               print_resource_track(_("Pass 5"), &rtrack);
+               print_resource_track(_("Pass 5"), &rtrack, ctx->fs->io);
        }
 #endif
 }
@@ -114,8 +114,8 @@ static void check_block_bitmaps(e2fsck_t ctx)
        blk_t   i, super;
        int     *free_array;
        int     group = 0;
-       unsigned int    blocks = 0;
-       unsigned int    free_blocks = 0;
+       blk_t   blocks = 0;
+       blk_t   free_blocks = 0;
        int     group_free = 0;
        int     actual, bitmap;
        struct problem_context  pctx;
@@ -563,7 +563,7 @@ static void check_block_end(e2fsck_t ctx)
 
        clear_problem_context(&pctx);
 
-       end = fs->block_map->start +
+       end = ext2fs_get_block_bitmap_start(fs->block_map) +
                (EXT2_BLOCKS_PER_GROUP(fs->super) * fs->group_desc_count) - 1;
        pctx.errcode = ext2fs_fudge_block_bitmap_end(fs->block_map, end,
                                                     &save_blocks_count);
index 3aa3c06..8c1459c 100644 (file)
@@ -778,7 +778,7 @@ void e2fsck_rehash_directories(e2fsck_t ctx)
        int                     cur, max, all_dirs, dir_index, first = 1;
 
 #ifdef RESOURCE_TRACK
-       init_resource_track(&rtrack);
+       init_resource_track(&rtrack, ctx->fs->io);
 #endif
 
        all_dirs = ctx->options & E2F_OPT_COMPRESS_DIRS;
@@ -847,7 +847,7 @@ void e2fsck_rehash_directories(e2fsck_t ctx)
 #ifdef RESOURCE_TRACK
        if (ctx->options & E2F_OPT_TIME2) {
                e2fsck_clear_progbar(ctx);
-               print_resource_track("Pass 3A", &rtrack);
+               print_resource_track("Pass 3A", &rtrack, ctx->fs->io);
        }
 #endif
 }
index a4835f7..dbd7b1a 100644 (file)
@@ -467,7 +467,8 @@ void check_super_block(e2fsck_t ctx)
        dgrp_t  i;
        blk_t   should_be;
        struct problem_context  pctx;
-       __u32   free_blocks = 0, free_inodes = 0;
+       blk_t   free_blocks = 0;
+       ino_t   free_inodes = 0;
 
        inodes_per_block = EXT2_INODES_PER_BLOCK(fs->super);
        ipg_max = inodes_per_block * (blocks_per_group - 4);
@@ -574,13 +575,17 @@ void check_super_block(e2fsck_t ctx)
        /*
         * Verify the group descriptors....
         */
-       first_block =  sb->s_first_data_block;
+       first_block = sb->s_first_data_block;
+       last_block = sb->s_blocks_count-1;
 
        for (i = 0, gd=fs->group_desc; i < fs->group_desc_count; i++, gd++) {
                pctx.group = i;
 
-               first_block = ext2fs_group_first_block(fs, i);
-               last_block = ext2fs_group_last_block(fs, i);
+               if (!EXT2_HAS_INCOMPAT_FEATURE(fs->super,
+                                              EXT4_FEATURE_INCOMPAT_FLEX_BG)) {
+                       first_block = ext2fs_group_first_block(fs, i);
+                       last_block = ext2fs_group_last_block(fs, i);
+               }
 
                if ((gd->bg_block_bitmap < first_block) ||
                    (gd->bg_block_bitmap > last_block)) {
diff --git a/e2fsck/swapfs.c b/e2fsck/swapfs.c
deleted file mode 100644 (file)
index fb7270c..0000000
+++ /dev/null
@@ -1,272 +0,0 @@
-/*
- * swapfs.c --- byte-swap an ext2 filesystem
- *
- * Copyright 1996, 1997 by Theodore Ts'o
- * 
- * %Begin-Header%
- * This file may be redistributed under the terms of the GNU Public
- * License.
- * %End-Header%
- * 
- */
-
-#ifdef HAVE_ERRNO_H
-#include <errno.h>
-#endif
-#include <et/com_err.h>
-#include "e2fsck.h"
-
-#ifdef ENABLE_SWAPFS
-
-struct swap_block_struct {
-       ext2_ino_t      ino;
-       int             isdir;
-       errcode_t       errcode;
-       char            *dir_buf;
-       struct ext2_inode *inode;
-};
-
-/*
- * This is a helper function for block_iterate.  We mark all of the
- * indirect and direct blocks as changed, so that block_iterate will
- * write them out.
- */
-static int swap_block(ext2_filsys fs, blk_t *block_nr, int blockcnt,
-                     void *priv_data)
-{
-       errcode_t       retval;
-       
-       struct swap_block_struct *sb = (struct swap_block_struct *) priv_data;
-
-       if (sb->isdir && (blockcnt >= 0) && *block_nr) {
-               retval = ext2fs_read_dir_block(fs, *block_nr, sb->dir_buf);
-               if (retval) {
-                       sb->errcode = retval;
-                       return BLOCK_ABORT;
-               }
-               retval = ext2fs_write_dir_block(fs, *block_nr, sb->dir_buf);
-               if (retval) {
-                       sb->errcode = retval;
-                       return BLOCK_ABORT;
-               }
-       }
-       if (blockcnt >= 0) {
-               if (blockcnt < EXT2_NDIR_BLOCKS)
-                       return 0;
-               return BLOCK_CHANGED;
-       }
-       if (blockcnt == BLOCK_COUNT_IND) {
-               if (*block_nr == sb->inode->i_block[EXT2_IND_BLOCK])
-                       return 0;
-               return BLOCK_CHANGED;
-       }
-       if (blockcnt == BLOCK_COUNT_DIND) {
-               if (*block_nr == sb->inode->i_block[EXT2_DIND_BLOCK])
-                       return 0;
-               return BLOCK_CHANGED;
-       }
-       if (blockcnt == BLOCK_COUNT_TIND) {
-               if (*block_nr == sb->inode->i_block[EXT2_TIND_BLOCK])
-                       return 0;
-               return BLOCK_CHANGED;
-       }
-       return BLOCK_CHANGED;
-}
-
-/*
- * This function is responsible for byte-swapping all of the indirect,
- * block pointers.  It is also responsible for byte-swapping directories.
- */
-static void swap_inode_blocks(e2fsck_t ctx, ext2_ino_t ino, char *block_buf,
-                             struct ext2_inode *inode)
-{
-       errcode_t                       retval;
-       struct swap_block_struct        sb;
-
-       sb.ino = ino;
-       sb.inode = inode;
-       sb.dir_buf = block_buf + ctx->fs->blocksize*3;
-       sb.errcode = 0;
-       sb.isdir = 0;
-       if (LINUX_S_ISDIR(inode->i_mode))
-               sb.isdir = 1;
-
-       retval = ext2fs_block_iterate(ctx->fs, ino, 0, block_buf,
-                                     swap_block, &sb);
-       if (retval) {
-               com_err("swap_inode_blocks", retval,
-                       _("while calling ext2fs_block_iterate"));
-               ctx->flags |= E2F_FLAG_ABORT;
-               return;
-       }
-       if (sb.errcode) {
-               com_err("swap_inode_blocks", sb.errcode,
-                       _("while calling iterator function"));
-               ctx->flags |= E2F_FLAG_ABORT;
-               return;
-       }
-}
-
-static void swap_inodes(e2fsck_t ctx)
-{
-       ext2_filsys fs = ctx->fs;
-       dgrp_t                  group;
-       unsigned int            i;
-       ext2_ino_t              ino = 1;
-       char                    *buf = NULL, *block_buf = NULL;
-       errcode_t               retval;
-       struct ext2_inode *     inode;
-
-       e2fsck_use_inode_shortcuts(ctx, 1);
-       
-       retval = ext2fs_get_mem(fs->blocksize * fs->inode_blocks_per_group,
-                               &buf);
-       if (retval) {
-               com_err("swap_inodes", retval,
-                       _("while allocating inode buffer"));
-               ctx->flags |= E2F_FLAG_ABORT;
-               goto errout;
-       }
-       block_buf = (char *) e2fsck_allocate_memory(ctx, fs->blocksize * 4,
-                                                   "block interate buffer");
-       for (group = 0; group < fs->group_desc_count; group++) {
-               retval = io_channel_read_blk(fs->io,
-                     fs->group_desc[group].bg_inode_table,
-                     fs->inode_blocks_per_group, buf);
-               if (retval) {
-                       com_err("swap_inodes", retval,
-                               _("while reading inode table (group %d)"),
-                               group);
-                       ctx->flags |= E2F_FLAG_ABORT;
-                       goto errout;
-               }
-               inode = (struct ext2_inode *) buf;
-               for (i=0; i < fs->super->s_inodes_per_group;
-                    i++, ino++, inode++) {
-                       ctx->stashed_ino = ino;
-                       ctx->stashed_inode = inode;
-                       
-                       if (fs->flags & EXT2_FLAG_SWAP_BYTES_READ)
-                               ext2fs_swap_inode(fs, inode, inode, 0);
-                       
-                       /*
-                        * Skip deleted files.
-                        */
-                       if (inode->i_links_count == 0)
-                               continue;
-                       
-                       if (LINUX_S_ISDIR(inode->i_mode) ||
-                           ((inode->i_block[EXT2_IND_BLOCK] ||
-                             inode->i_block[EXT2_DIND_BLOCK] ||
-                             inode->i_block[EXT2_TIND_BLOCK]) &&
-                            ext2fs_inode_has_valid_blocks(inode)))
-                               swap_inode_blocks(ctx, ino, block_buf, inode);
-
-                       if (ctx->flags & E2F_FLAG_SIGNAL_MASK)
-                               goto errout;
-                       
-                       if (fs->flags & EXT2_FLAG_SWAP_BYTES_WRITE)
-                               ext2fs_swap_inode(fs, inode, inode, 1);
-               }
-               retval = io_channel_write_blk(fs->io,
-                     fs->group_desc[group].bg_inode_table,
-                     fs->inode_blocks_per_group, buf);
-               if (retval) {
-                       com_err("swap_inodes", retval,
-                               _("while writing inode table (group %d)"),
-                               group);
-                       ctx->flags |= E2F_FLAG_ABORT;
-                       goto errout;
-               }
-       }
-errout:
-       if (buf)
-               ext2fs_free_mem(&buf);
-       if (block_buf)
-               ext2fs_free_mem(&block_buf);
-       e2fsck_use_inode_shortcuts(ctx, 0);
-       ext2fs_flush_icache(fs);
-}
-
-#if defined(__powerpc__) && defined(EXT2FS_ENABLE_SWAPFS)
-/*
- * On the PowerPC, the big-endian variant of the ext2 filesystem
- * has its bitmaps stored as 32-bit words with bit 0 as the LSB
- * of each word.  Thus a bitmap with only bit 0 set would be, as
- * a string of bytes, 00 00 00 01 00 ...
- * To cope with this, we byte-reverse each word of a bitmap if
- * we have a big-endian filesystem, that is, if we are *not*
- * byte-swapping other word-sized numbers.
- */
-#define EXT2_BIG_ENDIAN_BITMAPS
-#endif
-
-#ifdef EXT2_BIG_ENDIAN_BITMAPS
-static void ext2fs_swap_bitmap(ext2fs_generic_bitmap bmap)
-{
-       __u32 *p = (__u32 *) bmap->bitmap;
-       int n, nbytes = (bmap->end - bmap->start + 7) / 8;
-               
-       for (n = nbytes / sizeof(__u32); n > 0; --n, ++p)
-               *p = ext2fs_swab32(*p);
-}
-#endif
-
-
-void swap_filesys(e2fsck_t ctx)
-{
-       ext2_filsys fs = ctx->fs;
-#ifdef RESOURCE_TRACK
-       struct resource_track   rtrack;
-
-       init_resource_track(&rtrack);
-#endif
-
-       if (!(ctx->options & E2F_OPT_PREEN))
-               printf(_("Pass 0: Doing byte-swap of filesystem\n"));
-       
-#ifdef MTRACE
-       mtrace_print("Byte swap");
-#endif
-
-       if (fs->super->s_mnt_count) {
-               fprintf(stderr, _("%s: the filesystem must be freshly "
-                       "checked using fsck\n"
-                       "and not mounted before trying to "
-                       "byte-swap it.\n"), ctx->device_name);
-               ctx->flags |= E2F_FLAG_ABORT;
-               return;
-       }
-       if (fs->flags & EXT2_FLAG_SWAP_BYTES) {
-               fs->flags &= ~(EXT2_FLAG_SWAP_BYTES|
-                              EXT2_FLAG_SWAP_BYTES_WRITE);
-               fs->flags |= EXT2_FLAG_SWAP_BYTES_READ;
-       } else {
-               fs->flags &= ~EXT2_FLAG_SWAP_BYTES_READ;
-               fs->flags |= EXT2_FLAG_SWAP_BYTES_WRITE;
-       }
-       swap_inodes(ctx);
-       if (ctx->flags & E2F_FLAG_SIGNAL_MASK)
-               return;
-       if (fs->flags & EXT2_FLAG_SWAP_BYTES_WRITE)
-               fs->flags |= EXT2_FLAG_SWAP_BYTES;
-       fs->flags &= ~(EXT2_FLAG_SWAP_BYTES_READ|
-                      EXT2_FLAG_SWAP_BYTES_WRITE);
-
-#ifdef EXT2_BIG_ENDIAN_BITMAPS
-       e2fsck_read_bitmaps(ctx);
-       ext2fs_swap_bitmap(fs->inode_map);
-       ext2fs_swap_bitmap(fs->block_map);
-       fs->flags |= EXT2_FLAG_BB_DIRTY | EXT2_FLAG_IB_DIRTY;
-#endif
-       fs->flags &= ~EXT2_FLAG_MASTER_SB_ONLY;
-       ext2fs_flush(fs);
-       fs->flags |= EXT2_FLAG_MASTER_SB_ONLY;
-       
-#ifdef RESOURCE_TRACK
-       if (ctx->options & E2F_OPT_TIME2)
-               print_resource_track(_("Byte swap"), &rtrack);
-#endif
-}
-
-#endif
index 183116d..291ff85 100644 (file)
@@ -52,8 +52,6 @@ extern int optind;
 #include "../version.h"
 
 /* Command line options */
-static int swapfs;
-static int normalize_swapfs;
 static int cflag;              /* check disk */
 static int show_version_only;
 static int verbose;
@@ -71,7 +69,7 @@ int journal_enable_debug = -1;
 static void usage(e2fsck_t ctx)
 {
        fprintf(stderr,
-               _("Usage: %s [-panyrcdfvstDFSV] [-b superblock] [-B blocksize]\n"
+               _("Usage: %s [-panyrcdfvtDFV] [-b superblock] [-B blocksize]\n"
                "\t\t[-I inode_buffer_blocks] [-P process_inode_size]\n"
                "\t\t[-l|-L bad_blocks_file] [-C fd] [-j external_journal]\n"
                "\t\t[-E extended-options] device\n"),
@@ -268,8 +266,7 @@ static void check_if_skip(e2fsck_t ctx)
        if (!defer_check_on_battery)
                batt = 0;
 
-       if ((ctx->options & E2F_OPT_FORCE) || bad_blocks_file ||
-           cflag || swapfs)
+       if ((ctx->options & E2F_OPT_FORCE) || bad_blocks_file || cflag)
                return;
        
        lastcheck = fs->super->s_lastcheck;
@@ -735,20 +732,6 @@ static errcode_t PRS(int argc, char *argv[], e2fsck_t *ret_ctx)
                case 'N':
                        ctx->device_name = optarg;
                        break;
-#ifdef ENABLE_SWAPFS
-               case 's':
-                       normalize_swapfs = 1;
-               case 'S':
-                       swapfs = 1;
-                       break;
-#else
-               case 's':
-               case 'S':
-                       fprintf(stderr, _("Byte-swapping filesystems "
-                                         "not compiled in this version "
-                                         "of e2fsck\n"));
-                       exit(1);
-#endif
                case 'k':
                        keep_bad_blocks++;
                        break;
@@ -760,7 +743,7 @@ static errcode_t PRS(int argc, char *argv[], e2fsck_t *ret_ctx)
        if (optind != argc - 1)
                usage(ctx);
        if ((ctx->options & E2F_OPT_NO) && !bad_blocks_file &&
-           !cflag && !swapfs && !(ctx->options & E2F_OPT_COMPRESS_DIRS))
+           !cflag && !(ctx->options & E2F_OPT_COMPRESS_DIRS))
                ctx->options |= E2F_OPT_READONLY;
        ctx->io_options = strchr(argv[optind], '?');
        if (ctx->io_options) 
@@ -795,15 +778,6 @@ static errcode_t PRS(int argc, char *argv[], e2fsck_t *ret_ctx)
                }
                close(fd);
        }
-#ifdef ENABLE_SWAPFS
-       if (swapfs) {
-               if (cflag || bad_blocks_file) {
-                       fprintf(stderr, _("Incompatible options not "
-                                         "allowed when byte-swapping.\n"));
-                       exit(FSCK_USAGE);
-               }
-       }
-#endif
        if (cflag && bad_blocks_file) {
                fprintf(stderr, _("The -c and the -l/-L options may "
                                  "not be both used at the same time.\n"));
@@ -914,7 +888,7 @@ int main (int argc, char *argv[])
        reserve_stdio_fds();
        
 #ifdef RESOURCE_TRACK
-       init_resource_track(&ctx->global_rtrack);
+       init_resource_track(&ctx->global_rtrack, NULL);
 #endif
 
        if (!(ctx->options & E2F_OPT_PREEN) || show_version_only)
@@ -1204,21 +1178,6 @@ restart:
                read_bad_blocks_file(ctx, 0, !keep_bad_blocks); /* Test disk */
        if (ctx->flags & E2F_FLAG_SIGNAL_MASK)
                fatal_error(ctx, 0);
-#ifdef ENABLE_SWAPFS
-       if (normalize_swapfs) {
-               if ((fs->flags & EXT2_FLAG_SWAP_BYTES) ==
-                   ext2fs_native_flag()) {
-                       fprintf(stderr, _("%s: Filesystem byte order "
-                               "already normalized.\n"), ctx->device_name);
-                       fatal_error(ctx, 0);
-               }
-       }
-       if (swapfs) {
-               swap_filesys(ctx);
-               if (ctx->flags & E2F_FLAG_SIGNAL_MASK)
-                       fatal_error(ctx, 0);
-       }
-#endif
 
        /*
         * Mark the system as valid, 'til proven otherwise
@@ -1348,16 +1307,16 @@ no_journal:
        }
 
        e2fsck_write_bitmaps(ctx);
-       
+#ifdef RESOURCE_TRACK
+       io_channel_flush(ctx->fs->io);
+       if (ctx->options & E2F_OPT_TIME)
+               print_resource_track(NULL, &ctx->global_rtrack, ctx->fs->io);
+#endif
        ext2fs_close(fs);
        ctx->fs = NULL;
        free(ctx->filesystem_name);
        free(ctx->journal_name);
 
-#ifdef RESOURCE_TRACK
-       if (ctx->options & E2F_OPT_TIME)
-               print_resource_track(NULL, &ctx->global_rtrack);
-#endif
        e2fsck_free_context(ctx);
        remove_error_table(&et_ext2_error_table);
        remove_error_table(&et_prof_error_table);
index f761ebb..ba7ef4a 100644 (file)
@@ -276,11 +276,12 @@ void preenhalt(e2fsck_t ctx)
 }
 
 #ifdef RESOURCE_TRACK
-void init_resource_track(struct resource_track *track)
+void init_resource_track(struct resource_track *track, io_channel channel)
 {
 #ifdef HAVE_GETRUSAGE
        struct rusage r;
 #endif
+       io_stats io_start = 0;
        
        track->brk_start = sbrk(0);
        gettimeofday(&track->time_start, 0);
@@ -295,6 +296,14 @@ void init_resource_track(struct resource_track *track)
        track->user_start.tv_sec = track->user_start.tv_usec = 0;
        track->system_start.tv_sec = track->system_start.tv_usec = 0;
 #endif
+       track->bytes_read = 0;
+       track->bytes_written = 0;
+       if (channel && channel->manager && channel->manager->get_stats)
+               channel->manager->get_stats(channel, &io_start);
+       if (io_start) {
+               track->bytes_read = io_start->bytes_read;
+               track->bytes_written = io_start->bytes_written;
+       }
 }
 
 #ifdef __GNUC__
@@ -310,7 +319,8 @@ static _INLINE_ float timeval_subtract(struct timeval *tv1,
                ((float) (tv1->tv_usec - tv2->tv_usec)) / 1000000);
 }
 
-void print_resource_track(const char *desc, struct resource_track *track)
+void print_resource_track(const char *desc, struct resource_track *track,
+                         io_channel channel)
 {
 #ifdef HAVE_GETRUSAGE
        struct rusage r;
@@ -347,6 +357,26 @@ void print_resource_track(const char *desc, struct resource_track *track)
        printf(_("elapsed time: %6.3f\n"),
               timeval_subtract(&time_end, &track->time_start));
 #endif
+#define mbytes(x)      (((x) + 1048575) / 1048576)
+       if (channel && channel->manager && channel->manager->get_stats) {
+               io_stats delta = 0;
+               unsigned long long bytes_read = 0;
+               unsigned long long bytes_written = 0;
+
+               if (desc)
+                       printf("%s: ", desc);
+
+               channel->manager->get_stats(channel, &delta);
+               if (delta) {
+                       bytes_read = delta->bytes_read - track->bytes_read;
+                       bytes_written = delta->bytes_written - 
+                               track->bytes_written;
+               }
+               printf("I/O read: %lluMB, write: %lluMB, rate: %.2fMB/s\n",
+                      mbytes(bytes_read), mbytes(bytes_written),
+                      (double)mbytes(bytes_read + bytes_written) /
+                      timeval_subtract(&time_end, &track->time_start));
+       }
 }
 #endif /* RESOURCE_TRACK */
 
@@ -451,7 +481,7 @@ blk_t get_backup_sb(e2fsck_t ctx, ext2_filsys fs, const char *name,
                if (io_channel_read_blk(io, superblock,
                                        -SUPERBLOCK_SIZE, buf))
                        continue;
-#ifdef EXT2FS_ENABLE_SWAPFS
+#ifdef WORDS_BIGENDIAN
                if (sb->s_magic == ext2fs_swab16(EXT2_SUPER_MAGIC))
                        ext2fs_swap_super(sb);
 #endif
index 3eaca69..ad2df96 100644 (file)
@@ -2722,9 +2722,6 @@ struct ext2_inode {
                struct {
                        __u32  h_i_translator;
                } hurd1;
-               struct {
-                       __u32  m_i_reserved1;
-               } masix1;
        } osd1;                         /* OS dependent 1 */
        __u32   i_block[EXT2_N_BLOCKS]; /* Pointers to blocks */
        __u32   i_version;              /* File version (for NFS) */
@@ -2746,12 +2743,6 @@ struct ext2_inode {
                        __u16   h_i_gid_high;
                        __u32   h_i_author;
                } hurd2;
-               struct {
-                       __u8    m_i_frag;       /* Fragment number */
-                       __u8    m_i_fsize;      /* Fragment size */
-                       __u16   m_pad1;
-                       __u32   m_i_reserved2[2];
-               } masix2;
        } osd2;                         /* OS dependent 2 */
 };
 </ProgramListing>
index 510aa84..ff51782 100644 (file)
@@ -8,4 +8,5 @@ Description: Block device id library
 Version: @E2FSPROGS_VERSION@
 Requires: uuid @DEVMAPPER_REQ@
 Cflags: -I${includedir} 
-Libs: -L${libdir} -lblkid @DEVMAPPER_PC_LIBS@
+Libs: -L${libdir} -lblkid
+Libs.private: @DEVMAPPER_PC_LIBS@
index fd64696..0bcba44 100644 (file)
@@ -154,8 +154,10 @@ set_pri:
 }
 
 #ifdef HAVE_DEVMAPPER
-static void dm_quiet_log(int level, const char *file, int line,
-                        const char *f, ...)
+static void dm_quiet_log(int level __BLKID_ATTR((unused)), 
+                        const char *file __BLKID_ATTR((unused)), 
+                        int line __BLKID_ATTR((unused)),
+                        const char *f __BLKID_ATTR((unused)), ...)
 {
        return;
 }
@@ -168,7 +170,7 @@ static int dm_device_has_dep(const dev_t dev, const char *name)
        struct dm_task *task;
        struct dm_deps *deps;
        struct dm_info info;
-       int i;
+       unsigned int i;
 
        task = dm_task_create(DM_DEVICE_DEPS);
        if (!task)
@@ -224,7 +226,7 @@ static int dm_device_is_leaf(const dev_t dev)
 
        n = 0;
        do {
-               names = (void *)names + next;
+               names = (struct dm_names *) ((char *)names + next);
 
                if (dm_device_has_dep(dev, names->name))
                        ret = 0;
@@ -289,7 +291,7 @@ static void dm_probe_all(blkid_cache cache, int only_if_new)
                char *device = NULL;
                dev_t dev = 0;
 
-               names = (void *)names + next;
+               names = (struct dm_names *) ((char *)names + next);
 
                rc = asprintf(&device, "mapper/%s", names->name);
                if (rc < 0)
index 04a0cd8..876d682 100644 (file)
@@ -186,7 +186,7 @@ blkid_loff_t blkid_get_dev_size(int fd)
 #ifdef TEST_PROGRAM
 int main(int argc, char **argv)
 {
-       blkid_loff_t bytes;
+       long long bytes;
        int     fd;
 
        if (argc < 2) {
index a188d82..615cc38 100644 (file)
@@ -121,7 +121,7 @@ static int check_mdraid(int fd, unsigned char *ret_uuid)
        return 0;
 }
 
-static void set_uuid(blkid_dev dev, uuid_t uuid, char *tag)
+static void set_uuid(blkid_dev dev, uuid_t uuid, const char *tag)
 {
        char    str[37];
 
@@ -220,7 +220,7 @@ static int probe_jbd(struct blkid_probe *probe,
 #define FAT_ATTR_MASK                  0x3f
 #define FAT_ENTRY_FREE                 0xe5
 
-static char *no_name = "NO NAME    ";
+static const char *no_name = "NO NAME    ";
 
 static unsigned char *search_fat_label(struct vfat_dir_entry *dir, int count)
 {
@@ -582,10 +582,11 @@ static int probe_luks(struct blkid_probe *probe,
                       struct blkid_magic *id __BLKID_ATTR((unused)),
                       unsigned char *buf)
 {
-       unsigned char uuid[40];
+       char uuid[40];
+
        /* 168 is the offset to the 40 character uuid:
         * http://luks.endorphin.org/LUKS-on-disk-format.pdf */
-       strncpy(uuid, buf+168, 40);
+       strncpy(uuid, (char *) buf+168, 40);
        blkid_set_tag(probe->dev, "UUID", uuid, sizeof(uuid));
        return 0;
 }
index 02d42bb..ce8c42f 100644 (file)
@@ -8,7 +8,7 @@ if test "$TESTS"x = x ; then
        done
 fi
 
-mkdir -p tests
+mkdir -p tests/tmp
 
 for i in $TESTS
 do
@@ -19,9 +19,9 @@ do
                echo "non-existent"
                continue
        fi
-       bunzip2 < $SRCDIR/tests/$i.img.bz2 > /tmp/test.img.$$
-       ./tst_probe /tmp/test.img.$$ > tests/$i.out
-       /bin/rm -f /tmp/test.img.$$ tests/$i.ok tests/$i.failed
+       bunzip2 < $SRCDIR/tests/$i.img.bz2 > tests/tmp/test.img.$$
+       ./tst_probe tests/tmp/test.img.$$ > tests/$i.out
+       /bin/rm -f tests/tmp/test.img.$$ tests/$i.ok tests/$i.failed
        cmp -s tests/$i.out $SRCDIR/tests/$i.results
        if [ $? = 0 ];  then
                echo ok
index fe7e65a..4bf5630 100644 (file)
@@ -67,6 +67,8 @@ static struct feature feature_list[] = {
                        "extent" },
        {       E2P_FEATURE_INCOMPAT, EXT4_FEATURE_INCOMPAT_64BIT,
                        "64bit" },
+       {       E2P_FEATURE_INCOMPAT, EXT4_FEATURE_INCOMPAT_FLEX_BG,
+                        "flex_bg"},
        {       0, 0, 0 },
 };
 
index 0aed6c8..372304f 100644 (file)
@@ -65,7 +65,7 @@ int fgetflags (const char * name, unsigned long * flags)
 #if HAVE_EXT2_IOCTLS
        int fd, r, f, save_errno = 0;
 
-       if (!stat(name, &buf) &&
+       if (!lstat(name, &buf) &&
            !S_ISREG(buf.st_mode) && !S_ISDIR(buf.st_mode)) {
                goto notsupp;
        }
index 2f1277f..3a05324 100644 (file)
@@ -71,7 +71,7 @@ int fsetflags (const char * name, unsigned long flags)
 #if HAVE_EXT2_IOCTLS
        int fd, r, f, save_errno = 0;
 
-       if (!stat(name, &buf) &&
+       if (!lstat(name, &buf) &&
            !S_ISREG(buf.st_mode) && !S_ISDIR(buf.st_mode)) {
                goto notsupp;
        }
index 808d3a3..84c9709 100644 (file)
@@ -27,7 +27,7 @@ int iterate_on_dir (const char * dir_name,
 {
        DIR * dir;
        struct dirent *de, *dep;
-       int     max_len = -1, len;
+       int     max_len = -1, len, ret = 0;
 
 #if HAVE_PATHCONF && defined(_PC_NAME_MAX) 
        max_len = pathconf(dir_name, _PC_NAME_MAX);
@@ -64,9 +64,10 @@ int iterate_on_dir (const char * dir_name,
                        len = max_len;
 #endif
                memcpy(de, dep, len);
-               (*func) (dir_name, de, private);
+               if ((*func)(dir_name, de, private))
+                       ret++;
        }
        free(de);
        closedir(dir);
-       return 0;
+       return ret;
 }
index def088c..7a00ffe 100644 (file)
 
 @ifinfo
 @dircategory Development
-@format
-START-INFO-DIR-ENTRY
+@direntry
 * Com_err: (com_err).   A Common Error Description Library for UNIX.
-END-INFO-DIR-ENTRY
-@end format
+@end direntry
 @end ifinfo
 
 @iftex
index 199164a..ca65427 100644 (file)
@@ -7,10 +7,10 @@ INSTALL = @INSTALL@
 
 @MCONFIG@
 
-@DEBUGFS_CMT@DEBUGFS_LIB_OBJS = bb_compat.o cmp_bitmaps.o fileio.o \
+@DEBUGFS_CMT@DEBUGFS_LIB_OBJS = bb_compat.o fileio.o \
 @DEBUGFS_CMT@  inode_io.o namei.o write_bb_file.o 
 
-@RESIZER_CMT@RESIZE_LIB_OBJS = rs_bitmap.o dupfs.o test_io.o 
+@RESIZER_CMT@RESIZE_LIB_OBJS = dupfs.o test_io.o 
 
 @IMAGER_CMT@E2IMAGE_LIB_OBJS = imager.o
 
@@ -82,7 +82,6 @@ SRCS= ext2_err.c \
        $(srcdir)/bmap.c \
        $(srcdir)/check_desc.c \
        $(srcdir)/closefs.c \
-       $(srcdir)/cmp_bitmaps.c \
        $(srcdir)/dblist.c \
        $(srcdir)/dblist_dir.c \
        $(srcdir)/dirblock.c \
@@ -120,21 +119,20 @@ SRCS= ext2_err.c \
        $(srcdir)/read_bb.c \
        $(srcdir)/read_bb_file.c \
        $(srcdir)/res_gdt.c \
-       $(srcdir)/rs_bitmap.c \
        $(srcdir)/rw_bitmaps.c \
        $(srcdir)/swapfs.c \
        $(srcdir)/tdb.c \
        $(srcdir)/test_io.c \
-       $(srcdir)/unix_io.c \
-       $(srcdir)/unlink.c \
-       $(srcdir)/valid_blk.c \
-       $(srcdir)/version.c \
-       $(srcdir)/write_bb_file.c \
        $(srcdir)/tst_badblocks.c \
        $(srcdir)/tst_bitops.c \
        $(srcdir)/tst_byteswap.c \
        $(srcdir)/tst_getsize.c \
-       $(srcdir)/tst_iscan.c
+       $(srcdir)/tst_iscan.c \
+       $(srcdir)/unix_io.c \
+       $(srcdir)/unlink.c \
+       $(srcdir)/valid_blk.c \
+       $(srcdir)/version.c \
+       $(srcdir)/write_bb_file.c
 
 HFILES= bitops.h ext2fs.h ext2_io.h ext2_fs.h ext2_ext_attr.h ext3_extents.h \
        tdb.h
@@ -187,12 +185,12 @@ ext2fs.pc: $(srcdir)/ext2fs.pc.in $(top_builddir)/config.status
        @echo " CONFIG.STATUS $@"
        @cd $(top_builddir); CONFIG_FILES=lib/ext2fs/ext2fs.pc ./config.status
 
-tst_badblocks: tst_badblocks.o freefs.o \
+tst_badblocks: tst_badblocks.o freefs.o bitmaps.o rw_bitmaps.o \
                read_bb_file.o write_bb_file.o badblocks.o 
        @echo " LD $@"
        @$(CC) -o tst_badblocks tst_badblocks.o freefs.o \
-               read_bb_file.o write_bb_file.o badblocks.o \
-               inline.o bitops.o gen_bitmap.o $(LIBCOM_ERR)
+               read_bb_file.o write_bb_file.o badblocks.o rw_bitmaps.o \
+               inline.o bitops.o gen_bitmap.o bitmaps.o $(LIBCOM_ERR)
 
 tst_icount: icount.c initialize.o  $(STATIC_LIBEXT2FS)
        @echo " LD $@"
@@ -245,12 +243,10 @@ mkjournal: mkjournal.c $(STATIC_LIBEXT2FS)
        @echo " LD $@"
        @$(CC) -o mkjournal $(srcdir)/mkjournal.c -DDEBUG $(STATIC_LIBEXT2FS) $(LIBCOM_ERR) $(ALL_CFLAGS)
 
-check:: tst_bitops tst_badblocks tst_iscan @SWAPFS_CMT@ tst_byteswap \
-       tst_types tst_icount tst_super_size
+check:: tst_bitops tst_badblocks tst_iscan tst_types tst_icount tst_super_size
        LD_LIBRARY_PATH=$(LIB) DYLD_LIBRARY_PATH=$(LIB) ./tst_bitops
        LD_LIBRARY_PATH=$(LIB) DYLD_LIBRARY_PATH=$(LIB) ./tst_badblocks
        LD_LIBRARY_PATH=$(LIB) DYLD_LIBRARY_PATH=$(LIB) ./tst_iscan
-@SWAPFS_CMT@   LD_LIBRARY_PATH=$(LIB) DYLD_LIBRARY_PATH=$(LIB) ./tst_byteswap
        LD_LIBRARY_PATH=$(LIB) DYLD_LIBRARY_PATH=$(LIB) ./tst_types
        LD_LIBRARY_PATH=$(LIB) DYLD_LIBRARY_PATH=$(LIB) ./tst_icount
        LD_LIBRARY_PATH=$(LIB) DYLD_LIBRARY_PATH=$(LIB) ./tst_super_size
@@ -361,10 +357,6 @@ closefs.o: $(srcdir)/closefs.c $(srcdir)/ext2_fs.h \
  $(srcdir)/ext2fs.h $(srcdir)/ext2_fs.h $(srcdir)/ext3_extents.h \
  $(top_srcdir)/lib/et/com_err.h $(srcdir)/ext2_io.h \
  $(top_builddir)/lib/ext2fs/ext2_err.h $(srcdir)/bitops.h
-cmp_bitmaps.o: $(srcdir)/cmp_bitmaps.c $(srcdir)/ext2_fs.h \
- $(top_builddir)/lib/ext2fs/ext2_types.h $(srcdir)/ext2fs.h \
- $(srcdir)/ext2_fs.h $(srcdir)/ext3_extents.h $(top_srcdir)/lib/et/com_err.h \
- $(srcdir)/ext2_io.h $(top_builddir)/lib/ext2fs/ext2_err.h $(srcdir)/bitops.h
 dblist.o: $(srcdir)/dblist.c $(srcdir)/ext2_fs.h \
  $(top_builddir)/lib/ext2fs/ext2_types.h $(srcdir)/ext2fsP.h \
  $(srcdir)/ext2fs.h $(srcdir)/ext2_fs.h $(srcdir)/ext3_extents.h \
@@ -523,10 +515,6 @@ res_gdt.o: $(srcdir)/res_gdt.c $(srcdir)/ext2_fs.h \
  $(top_builddir)/lib/ext2fs/ext2_types.h $(srcdir)/ext2fs.h \
  $(srcdir)/ext2_fs.h $(srcdir)/ext3_extents.h $(top_srcdir)/lib/et/com_err.h \
  $(srcdir)/ext2_io.h $(top_builddir)/lib/ext2fs/ext2_err.h $(srcdir)/bitops.h
-rs_bitmap.o: $(srcdir)/rs_bitmap.c $(srcdir)/ext2_fs.h \
- $(top_builddir)/lib/ext2fs/ext2_types.h $(srcdir)/ext2fs.h \
- $(srcdir)/ext2_fs.h $(srcdir)/ext3_extents.h $(top_srcdir)/lib/et/com_err.h \
- $(srcdir)/ext2_io.h $(top_builddir)/lib/ext2fs/ext2_err.h $(srcdir)/bitops.h
 rw_bitmaps.o: $(srcdir)/rw_bitmaps.c $(srcdir)/ext2_fs.h \
  $(top_builddir)/lib/ext2fs/ext2_types.h $(srcdir)/ext2fs.h \
  $(srcdir)/ext2_fs.h $(srcdir)/ext3_extents.h $(top_srcdir)/lib/et/com_err.h \
index 696baad..b033fa3 100644 (file)
 #include "ext2_fs.h"
 #include "ext2fs.h"
 
-static errcode_t make_bitmap(__u32 start, __u32 end, __u32 real_end,
-                            const char *descr, char *init_map,
-                            ext2fs_generic_bitmap *ret)
-{
-       ext2fs_generic_bitmap   bitmap;
-       errcode_t               retval;
-       size_t                  size;
-
-       retval = ext2fs_get_mem(sizeof(struct ext2fs_struct_generic_bitmap), 
-                               &bitmap);
-       if (retval)
-               return retval;
-
-       bitmap->magic = EXT2_ET_MAGIC_GENERIC_BITMAP;
-       bitmap->fs = NULL;
-       bitmap->start = start;
-       bitmap->end = end;
-       bitmap->real_end = real_end;
-       bitmap->base_error_code = EXT2_ET_BAD_GENERIC_MARK;
-       if (descr) {
-               retval = ext2fs_get_mem(strlen(descr)+1, &bitmap->description);
-               if (retval) {
-                       ext2fs_free_mem(&bitmap);
-                       return retval;
-               }
-               strcpy(bitmap->description, descr);
-       } else
-               bitmap->description = 0;
-
-       size = (size_t) (((bitmap->real_end - bitmap->start) / 8) + 1);
-       retval = ext2fs_get_mem(size, &bitmap->bitmap);
-       if (retval) {
-               ext2fs_free_mem(&bitmap->description);
-               ext2fs_free_mem(&bitmap);
-               return retval;
-       }
-
-       if (init_map)
-               memcpy(bitmap->bitmap, init_map, size);
-       else
-               memset(bitmap->bitmap, 0, size);
-       *ret = bitmap;
-       return 0;
-}
-
-errcode_t ext2fs_allocate_generic_bitmap(__u32 start,
-                                        __u32 end,
-                                        __u32 real_end,
-                                        const char *descr,
-                                        ext2fs_generic_bitmap *ret)
-{
-       return make_bitmap(start, end, real_end, descr, 0, ret);
+void ext2fs_free_inode_bitmap(ext2fs_inode_bitmap bitmap)
+{
+       ext2fs_free_generic_bitmap(bitmap);
+}
+
+void ext2fs_free_block_bitmap(ext2fs_block_bitmap bitmap)
+{
+       ext2fs_free_generic_bitmap(bitmap);
 }
 
 errcode_t ext2fs_copy_bitmap(ext2fs_generic_bitmap src,
                             ext2fs_generic_bitmap *dest)
 {
-       errcode_t               retval;
-       ext2fs_generic_bitmap   new_map;
-
-       retval = make_bitmap(src->start, src->end, src->real_end,
-                            src->description, src->bitmap, &new_map);
-       if (retval)
-               return retval;
-       new_map->magic = src->magic;
-       new_map->fs = src->fs;
-       new_map->base_error_code = src->base_error_code;
-       *dest = new_map;
-       return 0;
+       return (ext2fs_copy_generic_bitmap(src, dest));
 }
 
 void ext2fs_set_bitmap_padding(ext2fs_generic_bitmap map)
 {
-       __u32   i, j;
-
-       /* Protect loop from wrap-around if map->real_end is maxed */
-       for (i=map->end+1, j = i - map->start; 
-            i <= map->real_end && i > map->end; 
-            i++, j++)
-               ext2fs_set_bit(j, map->bitmap);
-
-       return;
+       ext2fs_set_generic_bitmap_padding(map);
 }      
 
 errcode_t ext2fs_allocate_inode_bitmap(ext2_filsys fs,
                                       const char *descr,
                                       ext2fs_inode_bitmap *ret)
 {
-       ext2fs_inode_bitmap bitmap;
-       errcode_t       retval;
        __u32           start, end, real_end;
 
        EXT2_CHECK_MAGIC(fs, EXT2_ET_MAGIC_EXT2FS_FILSYS);
@@ -127,25 +62,15 @@ errcode_t ext2fs_allocate_inode_bitmap(ext2_filsys fs,
        end = fs->super->s_inodes_count;
        real_end = (EXT2_INODES_PER_GROUP(fs->super) * fs->group_desc_count);
 
-       retval = ext2fs_allocate_generic_bitmap(start, end, real_end,
-                                               descr, &bitmap);
-       if (retval)
-               return retval;
-       
-       bitmap->magic = EXT2_ET_MAGIC_INODE_BITMAP;
-       bitmap->fs = fs;
-       bitmap->base_error_code = EXT2_ET_BAD_INODE_MARK;
-       
-       *ret = bitmap;
-       return 0;
+       return (ext2fs_make_generic_bitmap(EXT2_ET_MAGIC_INODE_BITMAP, fs,
+                                          start, end, real_end,
+                                          descr, 0, ret));
 }
 
 errcode_t ext2fs_allocate_block_bitmap(ext2_filsys fs,
                                       const char *descr,
                                       ext2fs_block_bitmap *ret)
 {
-       ext2fs_block_bitmap bitmap;
-       errcode_t       retval;
        __u32           start, end, real_end;
 
        EXT2_CHECK_MAGIC(fs, EXT2_ET_MAGIC_EXT2FS_FILSYS);
@@ -157,59 +82,102 @@ errcode_t ext2fs_allocate_block_bitmap(ext2_filsys fs,
        real_end = (EXT2_BLOCKS_PER_GROUP(fs->super)  
                    * fs->group_desc_count)-1 + start;
        
-       retval = ext2fs_allocate_generic_bitmap(start, end, real_end,
-                                               descr, &bitmap);
-       if (retval)
-               return retval;
-
-       bitmap->magic = EXT2_ET_MAGIC_BLOCK_BITMAP;
-       bitmap->fs = fs;
-       bitmap->base_error_code = EXT2_ET_BAD_BLOCK_MARK;
-       
-       *ret = bitmap;
-       return 0;
+       return (ext2fs_make_generic_bitmap(EXT2_ET_MAGIC_BLOCK_BITMAP, fs,
+                                          start, end, real_end,
+                                          descr, 0, ret));
 }
 
 errcode_t ext2fs_fudge_inode_bitmap_end(ext2fs_inode_bitmap bitmap,
                                        ext2_ino_t end, ext2_ino_t *oend)
 {
-       EXT2_CHECK_MAGIC(bitmap, EXT2_ET_MAGIC_INODE_BITMAP);
-       
-       if (end > bitmap->real_end)
-               return EXT2_ET_FUDGE_INODE_BITMAP_END;
-       if (oend)
-               *oend = bitmap->end;
-       bitmap->end = end;
-       return 0;
+
+       return (ext2fs_fudge_generic_bitmap_end(bitmap,
+                                               EXT2_ET_MAGIC_INODE_BITMAP,
+                                               EXT2_ET_FUDGE_INODE_BITMAP_END,
+                                               end, oend));
 }
 
 errcode_t ext2fs_fudge_block_bitmap_end(ext2fs_block_bitmap bitmap,
                                        blk_t end, blk_t *oend)
 {
-       EXT2_CHECK_MAGIC(bitmap, EXT2_ET_MAGIC_BLOCK_BITMAP);
-       
-       if (end > bitmap->real_end)
-               return EXT2_ET_FUDGE_BLOCK_BITMAP_END;
-       if (oend)
-               *oend = bitmap->end;
-       bitmap->end = end;
-       return 0;
+       return (ext2fs_fudge_generic_bitmap_end(bitmap,
+                                               EXT2_ET_MAGIC_BLOCK_BITMAP,
+                                               EXT2_ET_FUDGE_BLOCK_BITMAP_END,
+                                               end, oend));
 }
 
 void ext2fs_clear_inode_bitmap(ext2fs_inode_bitmap bitmap)
 {
-       if (!bitmap || (bitmap->magic != EXT2_ET_MAGIC_INODE_BITMAP))
-               return;
-
-       memset(bitmap->bitmap, 0,
-              (size_t) (((bitmap->real_end - bitmap->start) / 8) + 1));
+       ext2fs_clear_generic_bitmap(bitmap);
 }
 
 void ext2fs_clear_block_bitmap(ext2fs_block_bitmap bitmap)
 {
-       if (!bitmap || (bitmap->magic != EXT2_ET_MAGIC_BLOCK_BITMAP))
-               return;
+       ext2fs_clear_generic_bitmap(bitmap);
+}
 
-       memset(bitmap->bitmap, 0,
-              (size_t) (((bitmap->real_end - bitmap->start) / 8) + 1));
+errcode_t ext2fs_resize_inode_bitmap(__u32 new_end, __u32 new_real_end,
+                                    ext2fs_inode_bitmap bmap)
+{
+       return (ext2fs_resize_generic_bitmap(EXT2_ET_MAGIC_INODE_BITMAP,
+                                            new_end, new_real_end, bmap));
+}
+
+errcode_t ext2fs_resize_block_bitmap(__u32 new_end, __u32 new_real_end,
+                                    ext2fs_block_bitmap bmap)
+{
+       return (ext2fs_resize_generic_bitmap(EXT2_ET_MAGIC_BLOCK_BITMAP,
+                                            new_end, new_real_end, bmap));
+}
+
+errcode_t ext2fs_compare_block_bitmap(ext2fs_block_bitmap bm1,
+                                     ext2fs_block_bitmap bm2)
+{
+       return (ext2fs_compare_generic_bitmap(EXT2_ET_MAGIC_BLOCK_BITMAP,
+                                             EXT2_ET_NEQ_BLOCK_BITMAP,
+                                             bm1, bm2));
+}
+
+errcode_t ext2fs_compare_inode_bitmap(ext2fs_inode_bitmap bm1,
+                                     ext2fs_inode_bitmap bm2)
+{
+       return (ext2fs_compare_generic_bitmap(EXT2_ET_MAGIC_INODE_BITMAP,
+                                             EXT2_ET_NEQ_INODE_BITMAP,
+                                             bm1, bm2));
+}
+
+errcode_t ext2fs_set_inode_bitmap_range(ext2fs_inode_bitmap bmap,
+                                       ext2_ino_t start, unsigned int num,
+                                       void *in)
+{
+       return (ext2fs_set_generic_bitmap_range(bmap,
+                                               EXT2_ET_MAGIC_INODE_BITMAP,
+                                               start, num, in));
+}
+
+errcode_t ext2fs_get_inode_bitmap_range(ext2fs_inode_bitmap bmap,
+                                       ext2_ino_t start, unsigned int num,
+                                       void *out)
+{
+       return (ext2fs_get_generic_bitmap_range(bmap,
+                                               EXT2_ET_MAGIC_INODE_BITMAP,
+                                               start, num, out));
+}
+
+errcode_t ext2fs_set_block_bitmap_range(ext2fs_block_bitmap bmap,
+                                       blk_t start, unsigned int num,
+                                       void *in)
+{
+       return (ext2fs_set_generic_bitmap_range(bmap, 
+                                               EXT2_ET_MAGIC_BLOCK_BITMAP,
+                                               start, num, in));
+}
+
+errcode_t ext2fs_get_block_bitmap_range(ext2fs_block_bitmap bmap,
+                                       blk_t start, unsigned int num,
+                                       void *out)
+{
+       return (ext2fs_get_generic_bitmap_range(bmap,
+                                               EXT2_ET_MAGIC_BLOCK_BITMAP,
+                                               start, num, out));
 }
index 78632c6..9c34847 100644 (file)
@@ -76,16 +76,3 @@ void ext2fs_warn_bitmap(errcode_t errcode, unsigned long arg,
                com_err(0, errcode, "#%lu", arg);
 #endif
 }
-
-void ext2fs_warn_bitmap2(ext2fs_generic_bitmap bitmap,
-                           int code, unsigned long arg)
-{
-#ifndef OMIT_COM_ERR
-       if (bitmap->description)
-               com_err(0, bitmap->base_error_code+code,
-                       "#%lu for %s", arg, bitmap->description);
-       else
-               com_err(0, bitmap->base_error_code + code, "#%lu", arg);
-#endif
-}
-
index 76f902d..d83ce8e 100644 (file)
@@ -104,11 +104,18 @@ extern int ext2fs_fast_test_block_bitmap_range(ext2fs_block_bitmap bitmap,
                                               blk_t block, int num);
 extern void ext2fs_set_bitmap_padding(ext2fs_generic_bitmap map);
 
-/* These two routines moved to gen_bitmap.c */
+/* These routines moved to gen_bitmap.c */
 extern int ext2fs_mark_generic_bitmap(ext2fs_generic_bitmap bitmap,
                                         __u32 bitno);
 extern int ext2fs_unmark_generic_bitmap(ext2fs_generic_bitmap bitmap,
                                           blk_t bitno);
+extern int ext2fs_test_generic_bitmap(ext2fs_generic_bitmap bitmap,
+                                     blk_t bitno);
+extern int ext2fs_test_block_bitmap_range(ext2fs_block_bitmap bitmap,
+                                         blk_t block, int num);
+extern __u32 ext2fs_get_generic_bitmap_start(ext2fs_generic_bitmap bitmap);
+extern __u32 ext2fs_get_generic_bitmap_end(ext2fs_generic_bitmap bitmap);
+
 /*
  * The inline routines themselves...
  * 
@@ -267,36 +274,6 @@ _INLINE_ int ext2fs_find_next_bit_set (void * addr, int size, int offset)
 }
 #endif
 
-#ifdef EXT2FS_ENABLE_SWAPFS
-_INLINE_ __u32 ext2fs_swab32(__u32 val)
-{
-#ifdef EXT2FS_REQUIRE_486
-       __asm__("bswap %0" : "=r" (val) : "0" (val));
-#else
-       __asm__("xchgb %b0,%h0\n\t"     /* swap lower bytes     */
-               "rorl $16,%0\n\t"       /* swap words           */
-               "xchgb %b0,%h0"         /* swap higher bytes    */
-               :"=q" (val)
-               : "0" (val));
-#endif
-       return val;
-}
-
-_INLINE_ __u16 ext2fs_swab16(__u16 val)
-{
-       __asm__("xchgb %b0,%h0"         /* swap bytes           */ \
-               : "=q" (val) \
-               :  "0" (val)); \
-               return val;
-}
-
-_INLINE_ __u64 ext2fs_swab64(__u64 val)
-{
-       return (ext2fs_swab32(val >> 32) |
-               (((__u64)ext2fs_swab32(val & 0xFFFFFFFFUL)) << 32));
-}
-#endif
-
 #undef EXT2FS_ADDR
 
 #endif /* i386 */
@@ -339,7 +316,7 @@ _INLINE_ int ext2fs_test_bit(unsigned int nr, const void * addr)
 #endif /* __mc68000__ */
 
 
-#if !defined(_EXT2_HAVE_ASM_SWAB_) && defined(EXT2FS_ENABLE_SWAPFS)
+#if !defined(_EXT2_HAVE_ASM_SWAB_) && defined(WORDS_BIGENDIAN)
 
 _INLINE_ __u16 ext2fs_swab16(__u16 val)
 {
@@ -401,24 +378,10 @@ _INLINE_ int ext2fs_find_next_bit_set (void * addr, int size, int offset)
 }
 #endif 
 
-_INLINE_ int ext2fs_test_generic_bitmap(ext2fs_generic_bitmap bitmap,
-                                       blk_t bitno);
-
-_INLINE_ int ext2fs_test_generic_bitmap(ext2fs_generic_bitmap bitmap,
-                                       blk_t bitno)
-{
-       if ((bitno < bitmap->start) || (bitno > bitmap->end)) {
-               ext2fs_warn_bitmap2(bitmap, EXT2FS_TEST_ERROR, bitno);
-               return 0;
-       }
-       return ext2fs_test_bit(bitno - bitmap->start, bitmap->bitmap);
-}
-
 _INLINE_ int ext2fs_mark_block_bitmap(ext2fs_block_bitmap bitmap,
                                       blk_t block)
 {
-       return ext2fs_mark_generic_bitmap((ext2fs_generic_bitmap)
-                                      bitmap,
+       return ext2fs_mark_generic_bitmap((ext2fs_generic_bitmap) bitmap,
                                          block);
 }
 
@@ -460,197 +423,77 @@ _INLINE_ int ext2fs_test_inode_bitmap(ext2fs_inode_bitmap bitmap,
 _INLINE_ void ext2fs_fast_mark_block_bitmap(ext2fs_block_bitmap bitmap,
                                            blk_t block)
 {
-#ifdef EXT2FS_DEBUG_FAST_OPS
-       if ((block < bitmap->start) || (block > bitmap->end)) {
-               ext2fs_warn_bitmap(EXT2_ET_BAD_BLOCK_MARK, block,
-                                  bitmap->description);
-               return;
-       }
-#endif 
-       ext2fs_fast_set_bit(block - bitmap->start, bitmap->bitmap);
+       ext2fs_mark_generic_bitmap((ext2fs_generic_bitmap) bitmap, block);
 }
 
 _INLINE_ void ext2fs_fast_unmark_block_bitmap(ext2fs_block_bitmap bitmap,
                                              blk_t block)
 {
-#ifdef EXT2FS_DEBUG_FAST_OPS
-       if ((block < bitmap->start) || (block > bitmap->end)) {
-               ext2fs_warn_bitmap(EXT2_ET_BAD_BLOCK_UNMARK,
-                                  block, bitmap->description);
-               return;
-       }
-#endif
-       ext2fs_fast_clear_bit(block - bitmap->start, bitmap->bitmap);
+       ext2fs_unmark_generic_bitmap((ext2fs_generic_bitmap) bitmap, block);
 }
 
 _INLINE_ int ext2fs_fast_test_block_bitmap(ext2fs_block_bitmap bitmap,
                                            blk_t block)
 {
-#ifdef EXT2FS_DEBUG_FAST_OPS
-       if ((block < bitmap->start) || (block > bitmap->end)) {
-               ext2fs_warn_bitmap(EXT2_ET_BAD_BLOCK_TEST,
-                                  block, bitmap->description);
-               return 0;
-       }
-#endif
-       return ext2fs_test_bit(block - bitmap->start, bitmap->bitmap);
+       return ext2fs_test_generic_bitmap((ext2fs_generic_bitmap) bitmap, 
+                                         block);
 }
 
 _INLINE_ void ext2fs_fast_mark_inode_bitmap(ext2fs_inode_bitmap bitmap,
                                            ext2_ino_t inode)
 {
-#ifdef EXT2FS_DEBUG_FAST_OPS
-       if ((inode < bitmap->start) || (inode > bitmap->end)) {
-               ext2fs_warn_bitmap(EXT2_ET_BAD_INODE_MARK,
-                                  inode, bitmap->description);
-               return;
-       }
-#endif
-       ext2fs_fast_set_bit(inode - bitmap->start, bitmap->bitmap);
+       ext2fs_mark_generic_bitmap((ext2fs_generic_bitmap) bitmap, inode);
 }
 
 _INLINE_ void ext2fs_fast_unmark_inode_bitmap(ext2fs_inode_bitmap bitmap,
                                              ext2_ino_t inode)
 {
-#ifdef EXT2FS_DEBUG_FAST_OPS
-       if ((inode < bitmap->start) || (inode > bitmap->end)) {
-               ext2fs_warn_bitmap(EXT2_ET_BAD_INODE_UNMARK,
-                                  inode, bitmap->description);
-               return;
-       }
-#endif
-       ext2fs_fast_clear_bit(inode - bitmap->start, bitmap->bitmap);
+       ext2fs_unmark_generic_bitmap((ext2fs_generic_bitmap) bitmap, inode);
 }
 
 _INLINE_ int ext2fs_fast_test_inode_bitmap(ext2fs_inode_bitmap bitmap,
                                           ext2_ino_t inode)
 {
-#ifdef EXT2FS_DEBUG_FAST_OPS
-       if ((inode < bitmap->start) || (inode > bitmap->end)) {
-               ext2fs_warn_bitmap(EXT2_ET_BAD_INODE_TEST,
-                                  inode, bitmap->description);
-               return 0;
-       }
-#endif
-       return ext2fs_test_bit(inode - bitmap->start, bitmap->bitmap);
+       return ext2fs_test_generic_bitmap((ext2fs_generic_bitmap) bitmap, 
+                                         inode);
 }
 
 _INLINE_ blk_t ext2fs_get_block_bitmap_start(ext2fs_block_bitmap bitmap)
 {
-       return bitmap->start;
+       return ext2fs_get_generic_bitmap_start((ext2fs_generic_bitmap) bitmap);
 }
 
 _INLINE_ ext2_ino_t ext2fs_get_inode_bitmap_start(ext2fs_inode_bitmap bitmap)
 {
-       return bitmap->start;
+       return ext2fs_get_generic_bitmap_start((ext2fs_generic_bitmap) bitmap);
 }
 
 _INLINE_ blk_t ext2fs_get_block_bitmap_end(ext2fs_block_bitmap bitmap)
 {
-       return bitmap->end;
+       return ext2fs_get_generic_bitmap_end((ext2fs_generic_bitmap) bitmap);
 }
 
 _INLINE_ ext2_ino_t ext2fs_get_inode_bitmap_end(ext2fs_inode_bitmap bitmap)
 {
-       return bitmap->end;
-}
-
-_INLINE_ int ext2fs_test_block_bitmap_range(ext2fs_block_bitmap bitmap,
-                                           blk_t block, int num)
-{
-       int     i;
-
-       if ((block < bitmap->start) || (block+num-1 > bitmap->end)) {
-               ext2fs_warn_bitmap(EXT2_ET_BAD_BLOCK_TEST,
-                                  block, bitmap->description);
-               return 0;
-       }
-       for (i=0; i < num; i++) {
-               if (ext2fs_fast_test_block_bitmap(bitmap, block+i))
-                       return 0;
-       }
-       return 1;
+       return ext2fs_get_generic_bitmap_end((ext2fs_generic_bitmap) bitmap);
 }
 
 _INLINE_ int ext2fs_fast_test_block_bitmap_range(ext2fs_block_bitmap bitmap,
                                                 blk_t block, int num)
 {
-       int     i;
-
-#ifdef EXT2FS_DEBUG_FAST_OPS
-       if ((block < bitmap->start) || (block+num-1 > bitmap->end)) {
-               ext2fs_warn_bitmap(EXT2_ET_BAD_BLOCK_TEST,
-                                  block, bitmap->description);
-               return 0;
-       }
-#endif
-       for (i=0; i < num; i++) {
-               if (ext2fs_fast_test_block_bitmap(bitmap, block+i))
-                       return 0;
-       }
-       return 1;
-}
-
-_INLINE_ void ext2fs_mark_block_bitmap_range(ext2fs_block_bitmap bitmap,
-                                            blk_t block, int num)
-{
-       int     i;
-       
-       if ((block < bitmap->start) || (block+num-1 > bitmap->end)) {
-               ext2fs_warn_bitmap(EXT2_ET_BAD_BLOCK_MARK, block,
-                                  bitmap->description);
-               return;
-       }
-       for (i=0; i < num; i++)
-               ext2fs_fast_set_bit(block + i - bitmap->start, bitmap->bitmap);
+       return ext2fs_test_block_bitmap_range(bitmap, block, num);
 }
 
 _INLINE_ void ext2fs_fast_mark_block_bitmap_range(ext2fs_block_bitmap bitmap,
                                                  blk_t block, int num)
 {
-       int     i;
-       
-#ifdef EXT2FS_DEBUG_FAST_OPS
-       if ((block < bitmap->start) || (block+num-1 > bitmap->end)) {
-               ext2fs_warn_bitmap(EXT2_ET_BAD_BLOCK_MARK, block,
-                                  bitmap->description);
-               return;
-       }
-#endif 
-       for (i=0; i < num; i++)
-               ext2fs_fast_set_bit(block + i - bitmap->start, bitmap->bitmap);
-}
-
-_INLINE_ void ext2fs_unmark_block_bitmap_range(ext2fs_block_bitmap bitmap,
-                                              blk_t block, int num)
-{
-       int     i;
-       
-       if ((block < bitmap->start) || (block+num-1 > bitmap->end)) {
-               ext2fs_warn_bitmap(EXT2_ET_BAD_BLOCK_UNMARK, block,
-                                  bitmap->description);
-               return;
-       }
-       for (i=0; i < num; i++)
-               ext2fs_fast_clear_bit(block + i - bitmap->start, 
-                                     bitmap->bitmap);
+       ext2fs_mark_block_bitmap_range(bitmap, block, num);
 }
 
 _INLINE_ void ext2fs_fast_unmark_block_bitmap_range(ext2fs_block_bitmap bitmap,
                                                    blk_t block, int num)
 {
-       int     i;
-       
-#ifdef EXT2FS_DEBUG_FAST_OPS
-       if ((block < bitmap->start) || (block+num-1 > bitmap->end)) {
-               ext2fs_warn_bitmap(EXT2_ET_BAD_BLOCK_UNMARK, block,
-                                  bitmap->description);
-               return;
-       }
-#endif 
-       for (i=0; i < num; i++)
-               ext2fs_fast_clear_bit(block + i - bitmap->start, 
-                                     bitmap->bitmap);
+       ext2fs_unmark_block_bitmap_range(bitmap, block, num);
 }
 #undef _INLINE_
 #endif
index 754fc49..76cac3f 100644 (file)
@@ -51,10 +51,8 @@ static _BMAP_INLINE_ errcode_t block_ind_bmap(ext2_filsys fs, int flags,
 
        if (flags & BMAP_SET) {
                b = *ret_blk;
-#ifdef EXT2FS_ENABLE_SWAPFS
-               if ((fs->flags & EXT2_FLAG_SWAP_BYTES) ||
-                   (fs->flags & EXT2_FLAG_SWAP_BYTES_WRITE))
-                       b = ext2fs_swab32(b);
+#ifdef WORDS_BIGENDIAN
+               b = ext2fs_swab32(b);
 #endif
                ((blk_t *) block_buf)[nr] = b;
                return io_channel_write_blk(fs->io, ind, 1, block_buf);
@@ -62,10 +60,8 @@ static _BMAP_INLINE_ errcode_t block_ind_bmap(ext2_filsys fs, int flags,
 
        b = ((blk_t *) block_buf)[nr];
 
-#ifdef EXT2FS_ENABLE_SWAPFS
-       if ((fs->flags & EXT2_FLAG_SWAP_BYTES) ||
-           (fs->flags & EXT2_FLAG_SWAP_BYTES_READ))
-               b = ext2fs_swab32(b);
+#ifdef WORDS_BIGENDIAN
+       b = ext2fs_swab32(b);
 #endif
 
        if (!b && (flags & BMAP_ALLOC)) {
@@ -75,13 +71,11 @@ static _BMAP_INLINE_ errcode_t block_ind_bmap(ext2_filsys fs, int flags,
                if (retval)
                        return retval;
 
-#ifdef EXT2FS_ENABLE_SWAPFS
-               if ((fs->flags & EXT2_FLAG_SWAP_BYTES) ||
-                   (fs->flags & EXT2_FLAG_SWAP_BYTES_WRITE))
-                       ((blk_t *) block_buf)[nr] = ext2fs_swab32(b);
-               else
+#ifdef WORDS_BIGENDIAN
+               ((blk_t *) block_buf)[nr] = ext2fs_swab32(b);
+#else
+               ((blk_t *) block_buf)[nr] = b;
 #endif
-                       ((blk_t *) block_buf)[nr] = b;
 
                retval = io_channel_write_blk(fs->io, ind, 1, block_buf);
                if (retval)
@@ -167,10 +161,8 @@ errcode_t ext2fs_bmap(ext2_filsys fs, ext2_ino_t ino, struct ext2_inode *inode,
        if (block < EXT2_NDIR_BLOCKS) {
                if (bmap_flags & BMAP_SET) {
                        b = *phys_blk;
-#ifdef EXT2FS_ENABLE_SWAPFS
-                       if ((fs->flags & EXT2_FLAG_SWAP_BYTES) ||
-                           (fs->flags & EXT2_FLAG_SWAP_BYTES_READ))
-                               b = ext2fs_swab32(b);
+#ifdef WORDS_BIGENDIAN
+                       b = ext2fs_swab32(b);
 #endif
                        inode_bmap(inode, block) = b;
                        inode_dirty++;
index 146f9e5..900b179 100644 (file)
@@ -33,13 +33,16 @@ errcode_t ext2fs_check_desc(ext2_filsys fs)
 {
        dgrp_t i;
        blk_t first_block = fs->super->s_first_data_block;
-       blk_t last_block;
+       blk_t last_block = fs->super->s_blocks_count-1;
 
        EXT2_CHECK_MAGIC(fs, EXT2_ET_MAGIC_EXT2FS_FILSYS);
 
        for (i = 0; i < fs->group_desc_count; i++) {
-               first_block = ext2fs_group_first_block(fs, i);
-               last_block = ext2fs_group_last_block(fs, i);
+               if (!EXT2_HAS_INCOMPAT_FEATURE(fs->super,
+                                              EXT4_FEATURE_INCOMPAT_FLEX_BG)) {
+                       first_block = ext2fs_group_first_block(fs, i);
+                       last_block = ext2fs_group_last_block(fs, i);
+               }
 
                /*
                 * Check to make sure block bitmap for group is
index f3fe533..0f97704 100644 (file)
@@ -54,11 +54,10 @@ int ext2fs_super_and_bgd_loc(ext2_filsys fs,
 {
        blk_t   group_block, super_blk = 0, old_desc_blk = 0, new_desc_blk = 0;
        unsigned int meta_bg, meta_bg_size;
-       int     numblocks, has_super;
-       int     old_desc_blocks;
+       blk_t   numblocks, old_desc_blocks;
+       int     has_super;
 
-       group_block = fs->super->s_first_data_block +
-               (group * fs->super->s_blocks_per_group);
+       group_block = ext2fs_group_first_block(fs, group);
 
        if (fs->super->s_feature_incompat & EXT2_FEATURE_INCOMPAT_META_BG)
                old_desc_blocks = fs->super->s_first_meta_bg;
@@ -81,7 +80,7 @@ int ext2fs_super_and_bgd_loc(ext2_filsys fs,
                super_blk = group_block;
                numblocks--;
        }
-       meta_bg_size = (fs->blocksize / sizeof (struct ext2_group_desc));
+       meta_bg_size = EXT2_DESC_PER_BLOCK(fs->super);
        meta_bg = group / meta_bg_size;
 
        if (!(fs->super->s_feature_incompat & EXT2_FEATURE_INCOMPAT_META_BG) ||
@@ -191,12 +190,11 @@ static errcode_t write_backup_super(ext2_filsys fs, dgrp_t group,
        
        if (sgrp > ((1 << 16) - 1))
                sgrp = (1 << 16) - 1;
-#ifdef EXT2FS_ENABLE_SWAPFS
-       if (fs->flags & EXT2_FLAG_SWAP_BYTES)
-               super_shadow->s_block_group_nr = ext2fs_swab16(sgrp);
-       else
+#ifdef WORDS_BIGENDIAN
+       super_shadow->s_block_group_nr = ext2fs_swab16(sgrp);
+#else
+       fs->super->s_block_group_nr = sgrp;
 #endif
-               fs->super->s_block_group_nr = sgrp;
 
        return io_channel_write_blk(fs->io, group_block, -SUPERBLOCK_SIZE, 
                                    super_shadow);
@@ -220,28 +218,23 @@ errcode_t ext2fs_flush(ext2_filsys fs)
 
        fs->super->s_wtime = fs->now ? fs->now : time(NULL);
        fs->super->s_block_group_nr = 0;
-#ifdef EXT2FS_ENABLE_SWAPFS
-       if (fs->flags & EXT2_FLAG_SWAP_BYTES) {
-               retval = EXT2_ET_NO_MEMORY;
-               retval = ext2fs_get_mem(SUPERBLOCK_SIZE, &super_shadow);
-               if (retval)
-                       goto errout;
-               retval = ext2fs_get_array(fs->blocksize, fs->desc_blocks,
-                                       &group_shadow);
-               if (retval)
-                       goto errout;
-               memset(group_shadow, 0, (size_t) fs->blocksize *
-                      fs->desc_blocks);
-
-               /* swap the group descriptors */
-               for (j=0, s=fs->group_desc, t=group_shadow;
-                    j < fs->group_desc_count; j++, t++, s++) {
-                       *t = *s;
-                       ext2fs_swap_group_desc(t);
-               }
-       } else {
-               super_shadow = fs->super;
-               group_shadow = fs->group_desc;
+#ifdef WORDS_BIGENDIAN
+       retval = EXT2_ET_NO_MEMORY;
+       retval = ext2fs_get_mem(SUPERBLOCK_SIZE, &super_shadow);
+       if (retval)
+               goto errout;
+       retval = ext2fs_get_array(fs->desc_blocks, fs->blocksize, 
+                                 &group_shadow);
+       if (retval)
+               goto errout;
+       memset(group_shadow, 0, (size_t) fs->blocksize *
+              fs->desc_blocks);
+       
+       /* swap the group descriptors */
+       for (j=0, s=fs->group_desc, t=group_shadow;
+            j < fs->group_desc_count; j++, t++, s++) {
+               *t = *s;
+               ext2fs_swap_group_desc(t);
        }
 #else
        super_shadow = fs->super;
@@ -254,11 +247,9 @@ errcode_t ext2fs_flush(ext2_filsys fs)
         * we write out the backup superblocks.)
         */
        fs->super->s_state &= ~EXT2_VALID_FS;
-#ifdef EXT2FS_ENABLE_SWAPFS
-       if (fs->flags & EXT2_FLAG_SWAP_BYTES) {
-               *super_shadow = *fs->super;
-               ext2fs_swap_super(super_shadow);
-       }
+#ifdef WORDS_BIGENDIAN
+       *super_shadow = *fs->super;
+       ext2fs_swap_super(super_shadow);
 #endif
 
        /*
@@ -332,11 +323,9 @@ write_primary_superblock_only:
 
        fs->super->s_block_group_nr = 0;
        fs->super->s_state = fs_state;
-#ifdef EXT2FS_ENABLE_SWAPFS
-       if (fs->flags & EXT2_FLAG_SWAP_BYTES) {
-               *super_shadow = *fs->super;
-               ext2fs_swap_super(super_shadow);
-       }
+#ifdef WORDS_BIGENDIAN
+       *super_shadow = *fs->super;
+       ext2fs_swap_super(super_shadow);
 #endif
 
        retval = io_channel_flush(fs->io);
@@ -349,12 +338,12 @@ write_primary_superblock_only:
        retval = io_channel_flush(fs->io);
 errout:
        fs->super->s_state = fs_state;
-       if (fs->flags & EXT2_FLAG_SWAP_BYTES) {
-               if (super_shadow)
-                       ext2fs_free_mem(&super_shadow);
-               if (group_shadow)
-                       ext2fs_free_mem(&group_shadow);
-       }
+#ifdef WORDS_BIGENDIAN
+       if (super_shadow)
+               ext2fs_free_mem(&super_shadow);
+       if (group_shadow)
+               ext2fs_free_mem(&group_shadow);
+#endif
        return retval;
 }
 
diff --git a/lib/ext2fs/cmp_bitmaps.c b/lib/ext2fs/cmp_bitmaps.c
deleted file mode 100644 (file)
index 51cc3d0..0000000
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- * cmp_bitmaps.c --- routines to compare inode and block bitmaps.
- *
- * Copyright (C) 1995 Theodore Ts'o.
- *
- * %Begin-Header%
- * This file may be redistributed under the terms of the GNU Public
- * License.
- * %End-Header%
- */
-
-#include <stdio.h>
-#include <string.h>
-#if HAVE_UNISTD_H
-#include <unistd.h>
-#endif
-#include <fcntl.h>
-#include <time.h>
-#if HAVE_SYS_STAT_H
-#include <sys/stat.h>
-#endif
-#if HAVE_SYS_TYPES_H
-#include <sys/types.h>
-#endif
-
-#include "ext2_fs.h"
-#include "ext2fs.h"
-
-errcode_t ext2fs_compare_block_bitmap(ext2fs_block_bitmap bm1,
-                                     ext2fs_block_bitmap bm2)
-{
-       blk_t   i;
-       
-       EXT2_CHECK_MAGIC(bm1, EXT2_ET_MAGIC_BLOCK_BITMAP);
-       EXT2_CHECK_MAGIC(bm2, EXT2_ET_MAGIC_BLOCK_BITMAP);
-
-       if ((bm1->start != bm2->start) ||
-           (bm1->end != bm2->end) ||
-           (memcmp(bm1->bitmap, bm2->bitmap,
-                   (size_t) (bm1->end - bm1->start)/8)))
-               return EXT2_ET_NEQ_BLOCK_BITMAP;
-
-       for (i = bm1->end - ((bm1->end - bm1->start) % 8); i <= bm1->end; i++)
-               if (ext2fs_fast_test_block_bitmap(bm1, i) !=
-                   ext2fs_fast_test_block_bitmap(bm2, i))
-                       return EXT2_ET_NEQ_BLOCK_BITMAP;
-
-       return 0;
-}
-
-errcode_t ext2fs_compare_inode_bitmap(ext2fs_inode_bitmap bm1,
-                                     ext2fs_inode_bitmap bm2)
-{
-       ext2_ino_t      i;
-       
-       EXT2_CHECK_MAGIC(bm1, EXT2_ET_MAGIC_INODE_BITMAP);
-       EXT2_CHECK_MAGIC(bm2, EXT2_ET_MAGIC_INODE_BITMAP);
-
-       if ((bm1->start != bm2->start) ||
-           (bm1->end != bm2->end) ||
-           (memcmp(bm1->bitmap, bm2->bitmap,
-                   (size_t) (bm1->end - bm1->start)/8)))
-               return EXT2_ET_NEQ_INODE_BITMAP;
-
-       for (i = bm1->end - ((bm1->end - bm1->start) % 8); i <= bm1->end; i++)
-               if (ext2fs_fast_test_inode_bitmap(bm1, i) !=
-                   ext2fs_fast_test_inode_bitmap(bm2, i))
-                       return EXT2_ET_NEQ_INODE_BITMAP;
-
-       return 0;
-}
-
index ebfc72c..fb20fa0 100644 (file)
@@ -25,26 +25,21 @@ errcode_t ext2fs_read_dir_block2(ext2_filsys fs, blk_t block,
        errcode_t       retval;
        char            *p, *end;
        struct ext2_dir_entry *dirent;
-       unsigned int    name_len, rec_len, do_swap;
+       unsigned int    name_len, rec_len;
        
 
        retval = io_channel_read_blk(fs->io, block, 1, buf);
        if (retval)
                return retval;
-#ifdef EXT2FS_ENABLE_SWAPFS
-       do_swap = (fs->flags & (EXT2_FLAG_SWAP_BYTES|
-                               EXT2_FLAG_SWAP_BYTES_READ)) != 0;
-#endif
+
        p = (char *) buf;
        end = (char *) buf + fs->blocksize;
        while (p < end-8) {
                dirent = (struct ext2_dir_entry *) p;
-#ifdef EXT2FS_ENABLE_SWAPFS
-               if (do_swap) {
-                       dirent->inode = ext2fs_swab32(dirent->inode);
-                       dirent->rec_len = ext2fs_swab16(dirent->rec_len);
-                       dirent->name_len = ext2fs_swab16(dirent->name_len);
-               }
+#ifdef WORDS_BIGENDIAN
+               dirent->inode = ext2fs_swab32(dirent->inode);
+               dirent->rec_len = ext2fs_swab16(dirent->rec_len);
+               dirent->name_len = ext2fs_swab16(dirent->name_len);
 #endif
                name_len = dirent->name_len;
 #ifdef WORDS_BIGENDIAN
@@ -73,22 +68,12 @@ errcode_t ext2fs_read_dir_block(ext2_filsys fs, blk_t block,
 errcode_t ext2fs_write_dir_block2(ext2_filsys fs, blk_t block,
                                  void *inbuf, int flags EXT2FS_ATTR((unused)))
 {
-#ifdef EXT2FS_ENABLE_SWAPFS
-       int             do_swap = 0;
+#ifdef WORDS_BIGENDIAN
        errcode_t       retval;
        char            *p, *end;
        char            *buf = 0;
        struct ext2_dir_entry *dirent;
 
-       if ((fs->flags & EXT2_FLAG_SWAP_BYTES) ||
-           (fs->flags & EXT2_FLAG_SWAP_BYTES_WRITE))
-               do_swap = 1;
-
-#ifndef WORDS_BIGENDIAN
-       if (!do_swap)
-               return io_channel_write_blk(fs->io, block, 1, (char *) inbuf);
-#endif
-
        retval = ext2fs_get_mem(fs->blocksize, &buf);
        if (retval)
                return retval;
@@ -103,15 +88,12 @@ errcode_t ext2fs_write_dir_block2(ext2_filsys fs, blk_t block,
                        return (EXT2_ET_DIR_CORRUPTED);
                }
                p += dirent->rec_len;
-               if (do_swap) {
-                       dirent->inode = ext2fs_swab32(dirent->inode);
-                       dirent->rec_len = ext2fs_swab16(dirent->rec_len);
-                       dirent->name_len = ext2fs_swab16(dirent->name_len);
-               }
-#ifdef WORDS_BIGENDIAN 
+               dirent->inode = ext2fs_swab32(dirent->inode);
+               dirent->rec_len = ext2fs_swab16(dirent->rec_len);
+               dirent->name_len = ext2fs_swab16(dirent->name_len);
+
                if (flags & EXT2_DIRBLOCK_V2_STRUCT)
                        dirent->name_len = ext2fs_swab16(dirent->name_len);
-#endif
        }
        retval = io_channel_write_blk(fs->io, block, 1, buf);
        ext2fs_free_mem(&buf);
index a316665..a11e6be 100644 (file)
@@ -217,6 +217,13 @@ struct ext2_dx_countlimit {
 /*
  * Macro-instructions used to manage group descriptors
  */
+#define EXT2_MIN_DESC_SIZE             32
+#define EXT2_MIN_DESC_SIZE_64BIT       64
+#define EXT2_MAX_DESC_SIZE             EXT2_MIN_BLOCK_SIZE
+#define EXT2_DESC_SIZE(s)                                                \
+       ((EXT2_SB(s)->s_feature_incompat & EXT4_FEATURE_INCOMPAT_64BIT) ? \
+       (s)->s_desc_size : EXT2_MIN_DESC_SIZE)
+
 #define EXT2_BLOCKS_PER_GROUP(s)       (EXT2_SB(s)->s_blocks_per_group)
 #define EXT2_INODES_PER_GROUP(s)       (EXT2_SB(s)->s_inodes_per_group)
 #define EXT2_INODES_PER_BLOCK(s)       (EXT2_BLOCK_SIZE(s)/EXT2_INODE_SIZE(s))
@@ -227,7 +234,7 @@ struct ext2_dx_countlimit {
 #define EXT2_DESC_PER_BLOCK(s)         (EXT2_SB(s)->s_desc_per_block)
 #define EXT2_DESC_PER_BLOCK_BITS(s)    (EXT2_SB(s)->s_desc_per_block_bits)
 #else
-#define EXT2_DESC_PER_BLOCK(s)         (EXT2_BLOCK_SIZE(s) / sizeof (struct ext2_group_desc))
+#define EXT2_DESC_PER_BLOCK(s)         (EXT2_BLOCK_SIZE(s) / EXT2_DESC_SIZE(s))
 #endif
 
 /*
@@ -315,9 +322,6 @@ struct ext2_inode {
                struct {
                        __u32  h_i_translator;
                } hurd1;
-               struct {
-                       __u32  m_i_reserved1;
-               } masix1;
        } osd1;                         /* OS dependent 1 */
        __u32   i_block[EXT2_N_BLOCKS];/* Pointers to blocks */
        __u32   i_generation;   /* File version (for NFS) */
@@ -340,12 +344,6 @@ struct ext2_inode {
                        __u16   h_i_gid_high;
                        __u32   h_i_author;
                } hurd2;
-               struct {
-                       __u8    m_i_frag;       /* Fragment number */
-                       __u8    m_i_fsize;      /* Fragment size */
-                       __u16   m_pad1;
-                       __u32   m_i_reserved2[2];
-               } masix2;
        } osd2;                         /* OS dependent 2 */
 };
 
@@ -371,9 +369,6 @@ struct ext2_inode_large {
                struct {
                        __u32  h_i_translator;
                } hurd1;
-               struct {
-                       __u32  m_i_reserved1;
-               } masix1;
        } osd1;                         /* OS dependent 1 */
        __u32   i_block[EXT2_N_BLOCKS];/* Pointers to blocks */
        __u32   i_generation;   /* File version (for NFS) */
@@ -396,12 +391,6 @@ struct ext2_inode_large {
                        __u16   h_i_gid_high;
                        __u32   h_i_author;
                } hurd2;
-               struct {
-                       __u8    m_i_frag;       /* Fragment number */
-                       __u8    m_i_fsize;      /* Fragment size */
-                       __u16   m_pad1;
-                       __u32   m_i_reserved2[2];
-               } masix2;
        } osd2;                         /* OS dependent 2 */
        __u16   i_extra_isize;
        __u16   i_pad1;
@@ -437,17 +426,6 @@ struct ext2_inode_large {
 #define inode_uid(inode)       ((inode).i_uid | (inode).i_uid_high << 16)
 #define inode_gid(inode)       ((inode).i_gid | (inode).i_gid_high << 16)
 
-#else
-#if defined(__masix__)
-
-#define i_reserved1    osd1.masix1.m_i_reserved1
-#define i_frag         osd2.masix2.m_i_frag
-#define i_fsize                osd2.masix2.m_i_fsize
-#define i_reserved2    osd2.masix2.m_i_reserved2
-#define inode_uid(inode)       ((inode).i_uid)
-#define inode_gid(inode)       ((inode).i_gid)
-
-#endif  /* __masix__ */
 #endif  /* __GNU__ */
 #endif /* defined(__KERNEL__) || defined(__linux__) */
 
@@ -585,7 +563,7 @@ struct ext2_super_block {
  */
 #define EXT2_OS_LINUX          0
 #define EXT2_OS_HURD           1
-#define EXT2_OS_MASIX          2
+#define EXT2_OBSO_OS_MASIX     2
 #define EXT2_OS_FREEBSD                3
 #define EXT2_OS_LITES          4
 
@@ -640,6 +618,7 @@ struct ext2_super_block {
 #define EXT3_FEATURE_INCOMPAT_EXTENTS          0x0040
 #define EXT4_FEATURE_INCOMPAT_64BIT            0x0080
 #define EXT4_FEATURE_INCOMPAT_MMP              0x0100
+#define EXT4_FEATURE_INCOMPAT_FLEX_BG          0x0200
 
 
 #define EXT2_FEATURE_COMPAT_SUPP       0
index eada278..bee75a6 100644 (file)
@@ -26,6 +26,7 @@ ext2_loff_t ext2fs_llseek (int, ext2_loff_t, int);
 
 typedef struct struct_io_manager *io_manager;
 typedef struct struct_io_channel *io_channel;
+typedef struct struct_io_stats *io_stats;
 
 #define CHANNEL_FLAGS_WRITETHROUGH     0x01
 
@@ -55,6 +56,13 @@ struct struct_io_channel {
        void            *app_data;
 };
 
+struct struct_io_stats {
+       int                     num_fields;
+       int                     reserved;
+       unsigned long long      bytes_read;
+       unsigned long long      bytes_written;
+};
+
 struct struct_io_manager {
        errcode_t magic;
        const char *name;
@@ -70,6 +78,7 @@ struct struct_io_manager {
                                int count, const void *data);
        errcode_t (*set_option)(io_channel channel, const char *option, 
                                const char *arg);
+       errcode_t (*get_stats)(io_channel channel, io_stats *io_stats);
        int             reserved[14];
 };
 
index 06ba9a2..1232592 100644 (file)
@@ -30,15 +30,6 @@ extern "C" {
 #endif
 
 /*
- * Build in support for byte-swapping filesystems if we the feature
- * has been configured or if we're being built on a CPU architecture
- * with a non-native byte order.
- */
-#if defined(ENABLE_SWAPFS) || defined(WORDS_BIGENDIAN)
-#define EXT2FS_ENABLE_SWAPFS
-#endif
-
-/*
  * Where the master copy of the superblock is located, and how big
  * superblocks are supposed to be.  We define SUPERBLOCK_SIZE because
  * the size of the superblock structure is not necessarily trustworthy
@@ -74,6 +65,7 @@ extern "C" {
 
 typedef __u32          ext2_ino_t;
 typedef __u32          blk_t;
+typedef __u64          blk64_t;
 typedef __u32          dgrp_t;
 typedef __u32          ext2_off_t;
 typedef __s64          e2_blkcnt_t;
@@ -100,17 +92,6 @@ typedef __u32               ext2_dirhash_t;
 
 typedef struct struct_ext2_filsys *ext2_filsys;
 
-struct ext2fs_struct_generic_bitmap {
-       errcode_t       magic;
-       ext2_filsys     fs;
-       __u32           start, end;
-       __u32           real_end;
-       char    *       description;
-       char    *       bitmap;
-       errcode_t       base_error_code;
-       __u32           reserved[7];
-};
-
 #define EXT2FS_MARK_ERROR      0
 #define EXT2FS_UNMARK_ERROR    1
 #define EXT2FS_TEST_ERROR      2
@@ -426,7 +407,7 @@ typedef struct ext2_icount *ext2_icount_t;
 /*
  * For ext2 compression support
  */
-#define EXT2FS_COMPRESSED_BLKADDR ((blk_t) 0xffffffff)
+#define EXT2FS_COMPRESSED_BLKADDR ((blk_t) -1)
 #define HOLE_BLKADDR(_b) ((_b) == 0 || (_b) == EXT2FS_COMPRESSED_BLKADDR)
 
 /*
@@ -452,12 +433,14 @@ typedef struct ext2_icount *ext2_icount_t;
                                         EXT2_FEATURE_INCOMPAT_COMPRESSION|\
                                         EXT3_FEATURE_INCOMPAT_JOURNAL_DEV|\
                                         EXT2_FEATURE_INCOMPAT_META_BG|\
-                                        EXT3_FEATURE_INCOMPAT_RECOVER)
+                                        EXT3_FEATURE_INCOMPAT_RECOVER|\
+                                        EXT4_FEATURE_INCOMPAT_FLEX_BG)
 #else
 #define EXT2_LIB_FEATURE_INCOMPAT_SUPP (EXT2_FEATURE_INCOMPAT_FILETYPE|\
                                         EXT3_FEATURE_INCOMPAT_JOURNAL_DEV|\
                                         EXT2_FEATURE_INCOMPAT_META_BG|\
-                                        EXT3_FEATURE_INCOMPAT_RECOVER)
+                                        EXT3_FEATURE_INCOMPAT_RECOVER|\
+                                        EXT4_FEATURE_INCOMPAT_FLEX_BG)
 #endif
 #define EXT2_LIB_FEATURE_RO_COMPAT_SUPP        (EXT2_FEATURE_RO_COMPAT_SPARSE_SUPER|\
                                         EXT2_FEATURE_RO_COMPAT_LARGE_FILE)
@@ -551,15 +534,14 @@ extern errcode_t ext2fs_update_bb_inode(ext2_filsys fs,
                                        ext2_badblocks_list bb_list);
 
 /* bitmaps.c */
+extern void ext2fs_free_block_bitmap(ext2fs_block_bitmap bitmap);
+extern void ext2fs_free_inode_bitmap(ext2fs_inode_bitmap bitmap);
+extern errcode_t ext2fs_copy_bitmap(ext2fs_generic_bitmap src,
+                                   ext2fs_generic_bitmap *dest);
 extern errcode_t ext2fs_write_inode_bitmap(ext2_filsys fs);
 extern errcode_t ext2fs_write_block_bitmap (ext2_filsys fs);
 extern errcode_t ext2fs_read_inode_bitmap (ext2_filsys fs);
 extern errcode_t ext2fs_read_block_bitmap(ext2_filsys fs);
-extern errcode_t ext2fs_allocate_generic_bitmap(__u32 start,
-                                               __u32 end,
-                                               __u32 real_end,
-                                               const char *descr,
-                                               ext2fs_generic_bitmap *ret);
 extern errcode_t ext2fs_allocate_block_bitmap(ext2_filsys fs,
                                              const char *descr,
                                              ext2fs_block_bitmap *ret);
@@ -574,6 +556,27 @@ extern void ext2fs_clear_inode_bitmap(ext2fs_inode_bitmap bitmap);
 extern void ext2fs_clear_block_bitmap(ext2fs_block_bitmap bitmap);
 extern errcode_t ext2fs_read_bitmaps(ext2_filsys fs);
 extern errcode_t ext2fs_write_bitmaps(ext2_filsys fs);
+extern errcode_t ext2fs_resize_inode_bitmap(__u32 new_end, __u32 new_real_end,
+                                           ext2fs_inode_bitmap bmap);
+extern errcode_t ext2fs_resize_block_bitmap(__u32 new_end, __u32 new_real_end,
+                                           ext2fs_block_bitmap bmap);
+extern errcode_t ext2fs_compare_block_bitmap(ext2fs_block_bitmap bm1,
+                                            ext2fs_block_bitmap bm2);
+extern errcode_t ext2fs_compare_inode_bitmap(ext2fs_inode_bitmap bm1,
+                                            ext2fs_inode_bitmap bm2);
+extern errcode_t ext2fs_set_inode_bitmap_range(ext2fs_inode_bitmap bmap,
+                                       ext2_ino_t start, unsigned int num,
+                                       void *in);
+extern errcode_t ext2fs_get_inode_bitmap_range(ext2fs_inode_bitmap bmap,
+                                       ext2_ino_t start, unsigned int num,
+                                       void *out);
+extern errcode_t ext2fs_set_block_bitmap_range(ext2fs_block_bitmap bmap,
+                                       blk_t start, unsigned int num,
+                                       void *in);
+extern errcode_t ext2fs_get_block_bitmap_range(ext2fs_block_bitmap bmap,
+                                       blk_t start, unsigned int num,
+                                       void *out);
+
 
 /* block.c */
 extern errcode_t ext2fs_block_iterate(ext2_filsys fs,
@@ -627,12 +630,6 @@ extern int ext2fs_super_and_bgd_loc(ext2_filsys fs,
                                    int *ret_meta_bg);
 extern void ext2fs_update_dynamic_rev(ext2_filsys fs);
 
-/* cmp_bitmaps.c */
-extern errcode_t ext2fs_compare_block_bitmap(ext2fs_block_bitmap bm1,
-                                            ext2fs_block_bitmap bm2);
-extern errcode_t ext2fs_compare_inode_bitmap(ext2fs_inode_bitmap bm1,
-                                            ext2fs_inode_bitmap bm2);
-
 /* dblist.c */
 
 extern errcode_t ext2fs_get_num_dirs(ext2_filsys fs, ext2_ino_t *ret_num_dirs);
@@ -750,13 +747,47 @@ extern errcode_t ext2fs_sync_device(int fd, int flushb);
 
 /* freefs.c */
 extern void ext2fs_free(ext2_filsys fs);
-extern void ext2fs_free_generic_bitmap(ext2fs_inode_bitmap bitmap);
-extern void ext2fs_free_block_bitmap(ext2fs_block_bitmap bitmap);
-extern void ext2fs_free_inode_bitmap(ext2fs_inode_bitmap bitmap);
 extern void ext2fs_free_dblist(ext2_dblist dblist);
 extern void ext2fs_badblocks_list_free(ext2_badblocks_list bb);
 extern void ext2fs_u32_list_free(ext2_u32_list bb);
 
+/* gen_bitmap.c */
+extern void ext2fs_free_generic_bitmap(ext2fs_inode_bitmap bitmap);
+extern errcode_t ext2fs_make_generic_bitmap(errcode_t magic, ext2_filsys fs, 
+                                           __u32 start, __u32 end, 
+                                           __u32 real_end,
+                                           const char *descr, char *init_map,
+                                           ext2fs_generic_bitmap *ret);
+extern errcode_t ext2fs_allocate_generic_bitmap(__u32 start,
+                                               __u32 end,
+                                               __u32 real_end,
+                                               const char *descr,
+                                               ext2fs_generic_bitmap *ret);
+extern errcode_t ext2fs_copy_generic_bitmap(ext2fs_generic_bitmap src,
+                                           ext2fs_generic_bitmap *dest);
+extern void ext2fs_clear_generic_bitmap(ext2fs_generic_bitmap bitmap);
+extern errcode_t ext2fs_fudge_generic_bitmap_end(ext2fs_inode_bitmap bitmap,
+                                                errcode_t magic, 
+                                                errcode_t neq,
+                                                ext2_ino_t end, 
+                                                ext2_ino_t *oend);
+extern void ext2fs_set_generic_bitmap_padding(ext2fs_generic_bitmap map);
+extern errcode_t ext2fs_resize_generic_bitmap(errcode_t magic,
+                                             __u32 new_end,
+                                             __u32 new_real_end,
+                                             ext2fs_generic_bitmap bmap);
+extern errcode_t ext2fs_compare_generic_bitmap(errcode_t magic, errcode_t neq,
+                                              ext2fs_generic_bitmap bm1,
+                                              ext2fs_generic_bitmap bm2);
+extern errcode_t ext2fs_get_generic_bitmap_range(ext2fs_generic_bitmap bmap,
+                                                errcode_t magic,
+                                                __u32 start, __u32 num,
+                                                void *out);
+extern errcode_t ext2fs_set_generic_bitmap_range(ext2fs_generic_bitmap bmap,
+                                                errcode_t magic,
+                                                __u32 start, __u32 num,
+                                                void *in);
+
 /* getsize.c */
 extern errcode_t ext2fs_get_device_size(const char *file, int blocksize,
                                        blk_t *retblocks);
@@ -927,17 +958,6 @@ extern errcode_t ext2fs_read_bb_FILE(ext2_filsys fs, FILE *f,
 /* res_gdt.c */
 extern errcode_t ext2fs_create_resize_inode(ext2_filsys fs);
 
-/* rs_bitmap.c */
-extern errcode_t ext2fs_resize_generic_bitmap(__u32 new_end,
-                                             __u32 new_real_end,
-                                             ext2fs_generic_bitmap bmap);
-extern errcode_t ext2fs_resize_inode_bitmap(__u32 new_end, __u32 new_real_end,
-                                           ext2fs_inode_bitmap bmap);
-extern errcode_t ext2fs_resize_block_bitmap(__u32 new_end, __u32 new_real_end,
-                                           ext2fs_block_bitmap bmap);
-extern errcode_t ext2fs_copy_bitmap(ext2fs_generic_bitmap src,
-                                   ext2fs_generic_bitmap *dest);
-
 /* swapfs.c */
 extern void ext2fs_swap_ext_attr(char *to, char *from, int bufsize, 
                                 int has_header);
index 08211c3..ee5fe16 100644 (file)
@@ -30,10 +30,8 @@ errcode_t ext2fs_read_ext_attr(ext2_filsys fs, blk_t block, void *buf)
        retval = io_channel_read_blk(fs->io, block, 1, buf);
        if (retval)
                return retval;
-#ifdef EXT2FS_ENABLE_SWAPFS
-       if ((fs->flags & (EXT2_FLAG_SWAP_BYTES|
-                         EXT2_FLAG_SWAP_BYTES_READ)) != 0)
-               ext2fs_swap_ext_attr(buf, buf, fs->blocksize, 1);
+#ifdef WORDS_BIGENDIAN
+       ext2fs_swap_ext_attr(buf, buf, fs->blocksize, 1);
 #endif
        return 0;
 }
@@ -44,17 +42,15 @@ errcode_t ext2fs_write_ext_attr(ext2_filsys fs, blk_t block, void *inbuf)
        char            *write_buf;
        char            *buf = NULL;
 
-#ifdef EXT2FS_ENABLE_SWAPFS
-       if ((fs->flags & EXT2_FLAG_SWAP_BYTES) ||
-           (fs->flags & EXT2_FLAG_SWAP_BYTES_WRITE)) {
-               retval = ext2fs_get_mem(fs->blocksize, &buf);
-               if (retval)
-                       return retval;
-               write_buf = buf;
-               ext2fs_swap_ext_attr(buf, inbuf, fs->blocksize, 1);
-       } else
+#ifdef WORDS_BIGENDIAN
+       retval = ext2fs_get_mem(fs->blocksize, &buf);
+       if (retval)
+               return retval;
+       write_buf = buf;
+       ext2fs_swap_ext_attr(buf, inbuf, fs->blocksize, 1);
+#else
+       write_buf = (char *) inbuf;
 #endif
-               write_buf = (char *) inbuf;
        retval = io_channel_write_blk(fs->io, block, 1, write_buf);
        if (buf)
                ext2fs_free_mem(&buf);
index 029ffaa..d6ac901 100644 (file)
@@ -58,41 +58,6 @@ void ext2fs_free(ext2_filsys fs)
        ext2fs_free_mem(&fs);
 }
 
-void ext2fs_free_generic_bitmap(ext2fs_inode_bitmap bitmap)
-{
-       if (!bitmap || (bitmap->magic != EXT2_ET_MAGIC_GENERIC_BITMAP))
-               return;
-
-       bitmap->magic = 0;
-       if (bitmap->description) {
-               ext2fs_free_mem(&bitmap->description);
-               bitmap->description = 0;
-       }
-       if (bitmap->bitmap) {
-               ext2fs_free_mem(&bitmap->bitmap);
-               bitmap->bitmap = 0;
-       }
-       ext2fs_free_mem(&bitmap);
-}
-
-void ext2fs_free_inode_bitmap(ext2fs_inode_bitmap bitmap)
-{
-       if (!bitmap || (bitmap->magic != EXT2_ET_MAGIC_INODE_BITMAP))
-               return;
-
-       bitmap->magic = EXT2_ET_MAGIC_GENERIC_BITMAP;
-       ext2fs_free_generic_bitmap(bitmap);
-}
-
-void ext2fs_free_block_bitmap(ext2fs_block_bitmap bitmap)
-{
-       if (!bitmap || (bitmap->magic != EXT2_ET_MAGIC_BLOCK_BITMAP))
-               return;
-
-       bitmap->magic = EXT2_ET_MAGIC_GENERIC_BITMAP;
-       ext2fs_free_generic_bitmap(bitmap);
-}
-
 /*
  * Free the inode cache structure
  */
index 700affa..66172e5 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * gen_bitmap.c --- Generic bitmap routines that used to be inlined.
+ * gen_bitmap.c --- Generic (32-bit) bitmap routines
  * 
  * Copyright (C) 2001 Theodore Ts'o.
  *
 #include "ext2_fs.h"
 #include "ext2fs.h"
 
+struct ext2fs_struct_generic_bitmap {
+       errcode_t       magic;
+       ext2_filsys     fs;
+       __u32           start, end;
+       __u32           real_end;
+       char    *       description;
+       char    *       bitmap;
+       errcode_t       base_error_code;
+       __u32           reserved[7];
+};
+
+/* 
+ * Used by previously inlined function, so we have to export this and
+ * not change the function signature
+ */
+void ext2fs_warn_bitmap2(ext2fs_generic_bitmap bitmap,
+                           int code, unsigned long arg)
+{
+#ifndef OMIT_COM_ERR
+       if (bitmap->description)
+               com_err(0, bitmap->base_error_code+code,
+                       "#%lu for %s", arg, bitmap->description);
+       else
+               com_err(0, bitmap->base_error_code + code, "#%lu", arg);
+#endif
+}
+
+static errcode_t check_magic(ext2fs_generic_bitmap bitmap)
+{
+       if (!bitmap || !((bitmap->magic == EXT2_ET_MAGIC_GENERIC_BITMAP) ||
+                        (bitmap->magic == EXT2_ET_MAGIC_INODE_BITMAP) ||
+                        (bitmap->magic == EXT2_ET_MAGIC_BLOCK_BITMAP)))
+               return EXT2_ET_MAGIC_GENERIC_BITMAP;
+       return 0;
+}
+
+errcode_t ext2fs_make_generic_bitmap(errcode_t magic, ext2_filsys fs, 
+                                    __u32 start, __u32 end, __u32 real_end,
+                                    const char *descr, char *init_map,
+                                    ext2fs_generic_bitmap *ret)
+{
+       ext2fs_generic_bitmap   bitmap;
+       errcode_t               retval;
+       size_t                  size;
+
+       retval = ext2fs_get_mem(sizeof(struct ext2fs_struct_generic_bitmap), 
+                               &bitmap);
+       if (retval)
+               return retval;
+
+       bitmap->magic = magic;
+       bitmap->fs = fs;
+       bitmap->start = start;
+       bitmap->end = end;
+       bitmap->real_end = real_end;
+       switch (magic) {
+       case EXT2_ET_MAGIC_INODE_BITMAP:
+               bitmap->base_error_code = EXT2_ET_BAD_INODE_MARK;
+               break;
+       case EXT2_ET_MAGIC_BLOCK_BITMAP:
+               bitmap->base_error_code = EXT2_ET_BAD_BLOCK_MARK;
+               break;
+       default:
+               bitmap->base_error_code = EXT2_ET_BAD_GENERIC_MARK;
+       }
+       if (descr) {
+               retval = ext2fs_get_mem(strlen(descr)+1, &bitmap->description);
+               if (retval) {
+                       ext2fs_free_mem(&bitmap);
+                       return retval;
+               }
+               strcpy(bitmap->description, descr);
+       } else
+               bitmap->description = 0;
+
+       size = (size_t) (((bitmap->real_end - bitmap->start) / 8) + 1);
+       retval = ext2fs_get_mem(size, &bitmap->bitmap);
+       if (retval) {
+               ext2fs_free_mem(&bitmap->description);
+               ext2fs_free_mem(&bitmap);
+               return retval;
+       }
+
+       if (init_map)
+               memcpy(bitmap->bitmap, init_map, size);
+       else
+               memset(bitmap->bitmap, 0, size);
+       *ret = bitmap;
+       return 0;
+}
+
+errcode_t ext2fs_allocate_generic_bitmap(__u32 start,
+                                        __u32 end,
+                                        __u32 real_end,
+                                        const char *descr,
+                                        ext2fs_generic_bitmap *ret)
+{
+       return ext2fs_make_generic_bitmap(EXT2_ET_MAGIC_GENERIC_BITMAP, 0, 
+                                         start, end, real_end, descr, 0, ret);
+}
+
+errcode_t ext2fs_copy_generic_bitmap(ext2fs_generic_bitmap src,
+                                    ext2fs_generic_bitmap *dest)
+{
+       return (ext2fs_make_generic_bitmap(src->magic, src->fs,
+                                          src->start, src->end, 
+                                          src->real_end,
+                                          src->description, src->bitmap,
+                                          dest));
+}
+
+void ext2fs_free_generic_bitmap(ext2fs_inode_bitmap bitmap)
+{
+       if (check_magic(bitmap))
+               return;
+
+       bitmap->magic = 0;
+       if (bitmap->description) {
+               ext2fs_free_mem(&bitmap->description);
+               bitmap->description = 0;
+       }
+       if (bitmap->bitmap) {
+               ext2fs_free_mem(&bitmap->bitmap);
+               bitmap->bitmap = 0;
+       }
+       ext2fs_free_mem(&bitmap);
+}
+
+int ext2fs_test_generic_bitmap(ext2fs_generic_bitmap bitmap,
+                                       blk_t bitno)
+{
+       if ((bitno < bitmap->start) || (bitno > bitmap->end)) {
+               ext2fs_warn_bitmap2(bitmap, EXT2FS_TEST_ERROR, bitno);
+               return 0;
+       }
+       return ext2fs_test_bit(bitno - bitmap->start, bitmap->bitmap);
+}
+
 int ext2fs_mark_generic_bitmap(ext2fs_generic_bitmap bitmap,
                                         __u32 bitno)
 {
@@ -46,3 +184,191 @@ int ext2fs_unmark_generic_bitmap(ext2fs_generic_bitmap bitmap,
        }
        return ext2fs_clear_bit(bitno - bitmap->start, bitmap->bitmap);
 }
+
+__u32 ext2fs_get_generic_bitmap_start(ext2fs_generic_bitmap bitmap)
+{
+       return bitmap->start;
+}
+
+__u32 ext2fs_get_generic_bitmap_end(ext2fs_generic_bitmap bitmap)
+{
+       return bitmap->end;
+}
+
+void ext2fs_clear_generic_bitmap(ext2fs_generic_bitmap bitmap)
+{
+       if (check_magic(bitmap))
+               return;
+
+       memset(bitmap->bitmap, 0,
+              (size_t) (((bitmap->real_end - bitmap->start) / 8) + 1));
+}
+
+errcode_t ext2fs_fudge_generic_bitmap_end(ext2fs_inode_bitmap bitmap,
+                                         errcode_t magic, errcode_t neq,
+                                         ext2_ino_t end, ext2_ino_t *oend)
+{
+       EXT2_CHECK_MAGIC(bitmap, magic);
+       
+       if (end > bitmap->real_end)
+               return neq;
+       if (oend)
+               *oend = bitmap->end;
+       bitmap->end = end;
+       return 0;
+}
+
+errcode_t ext2fs_resize_generic_bitmap(errcode_t magic,
+                                      __u32 new_end, __u32 new_real_end,
+                                      ext2fs_generic_bitmap bmap)
+{
+       errcode_t       retval;
+       size_t          size, new_size;
+       __u32           bitno;
+
+       if (!bmap || (bmap->magic != magic))
+               return magic;
+
+       /*
+        * If we're expanding the bitmap, make sure all of the new
+        * parts of the bitmap are zero.
+        */
+       if (new_end > bmap->end) {
+               bitno = bmap->real_end;
+               if (bitno > new_end)
+                       bitno = new_end;
+               for (; bitno > bmap->end; bitno--)
+                       ext2fs_clear_bit(bitno - bmap->start, bmap->bitmap);
+       }
+       if (new_real_end == bmap->real_end) {
+               bmap->end = new_end;
+               return 0;
+       }
+       
+       size = ((bmap->real_end - bmap->start) / 8) + 1;
+       new_size = ((new_real_end - bmap->start) / 8) + 1;
+
+       if (size != new_size) {
+               retval = ext2fs_resize_mem(size, new_size, &bmap->bitmap);
+               if (retval)
+                       return retval;
+       }
+       if (new_size > size)
+               memset(bmap->bitmap + size, 0, new_size - size);
+
+       bmap->end = new_end;
+       bmap->real_end = new_real_end;
+       return 0;
+}
+
+errcode_t ext2fs_compare_generic_bitmap(errcode_t magic, errcode_t neq,
+                                       ext2fs_generic_bitmap bm1,
+                                       ext2fs_generic_bitmap bm2)
+{
+       blk_t   i;
+       
+       if (!bm1 || bm1->magic != magic)
+               return magic;
+       if (!bm2 || bm2->magic != magic)
+               return magic;
+
+       if ((bm1->start != bm2->start) ||
+           (bm1->end != bm2->end) ||
+           (memcmp(bm1->bitmap, bm2->bitmap,
+                   (size_t) (bm1->end - bm1->start)/8)))
+               return neq;
+
+       for (i = bm1->end - ((bm1->end - bm1->start) % 8); i <= bm1->end; i++)
+               if (ext2fs_fast_test_block_bitmap(bm1, i) !=
+                   ext2fs_fast_test_block_bitmap(bm2, i))
+                       return neq;
+
+       return 0;
+}
+
+void ext2fs_set_generic_bitmap_padding(ext2fs_generic_bitmap map)
+{
+       __u32   i, j;
+
+       /* Protect loop from wrap-around if map->real_end is maxed */
+       for (i=map->end+1, j = i - map->start; 
+            i <= map->real_end && i > map->end; 
+            i++, j++)
+               ext2fs_set_bit(j, map->bitmap);
+}
+
+errcode_t ext2fs_get_generic_bitmap_range(ext2fs_generic_bitmap bmap,
+                                         errcode_t magic,
+                                         __u32 start, __u32 num,
+                                         void *out)
+{
+       if (!bmap || (bmap->magic != magic))
+               return magic;
+
+       if ((start < bmap->start) || (start+num-1 > bmap->real_end))
+               return EXT2_ET_INVALID_ARGUMENT;
+
+       memcpy(out, bmap->bitmap + (start >> 3), (num+7) >> 3);
+       return 0;
+}
+
+errcode_t ext2fs_set_generic_bitmap_range(ext2fs_generic_bitmap bmap,
+                                         errcode_t magic,
+                                         __u32 start, __u32 num,
+                                         void *in)
+{
+       if (!bmap || (bmap->magic != magic))
+               return magic;
+
+       if ((start < bmap->start) || (start+num-1 > bmap->real_end))
+               return EXT2_ET_INVALID_ARGUMENT;
+
+       memcpy(bmap->bitmap + (start >> 3), in, (num+7) >> 3);
+       return 0;
+}
+
+int ext2fs_test_block_bitmap_range(ext2fs_block_bitmap bitmap,
+                                  blk_t block, int num)
+{
+       int     i;
+
+       if ((block < bitmap->start) || (block+num-1 > bitmap->real_end)) {
+               ext2fs_warn_bitmap(EXT2_ET_BAD_BLOCK_TEST,
+                                  block, bitmap->description);
+               return 0;
+       }
+       for (i=0; i < num; i++) {
+               if (ext2fs_fast_test_block_bitmap(bitmap, block+i))
+                       return 0;
+       }
+       return 1;
+}
+
+void ext2fs_mark_block_bitmap_range(ext2fs_block_bitmap bitmap,
+                                   blk_t block, int num)
+{
+       int     i;
+       
+       if ((block < bitmap->start) || (block+num-1 > bitmap->end)) {
+               ext2fs_warn_bitmap(EXT2_ET_BAD_BLOCK_MARK, block,
+                                  bitmap->description);
+               return;
+       }
+       for (i=0; i < num; i++)
+               ext2fs_fast_set_bit(block + i - bitmap->start, bitmap->bitmap);
+}
+
+void ext2fs_unmark_block_bitmap_range(ext2fs_block_bitmap bitmap,
+                                              blk_t block, int num)
+{
+       int     i;
+       
+       if ((block < bitmap->start) || (block+num-1 > bitmap->end)) {
+               ext2fs_warn_bitmap(EXT2_ET_BAD_BLOCK_UNMARK, block,
+                                  bitmap->description);
+               return;
+       }
+       for (i=0; i < num; i++)
+               ext2fs_fast_clear_bit(block + i - bitmap->start, 
+                                     bitmap->bitmap);
+}
index ac8309c..9f7534a 100644 (file)
@@ -277,11 +277,12 @@ errout:
  */
 errcode_t ext2fs_image_bitmap_write(ext2_filsys fs, int fd, int flags)
 {
-       char            *ptr;
-       int             c, size;
-       char            zero_buf[1024];
-       ssize_t         actual;
-       errcode_t       retval;
+       ext2fs_generic_bitmap   bmap;
+       errcode_t               err, retval;
+       ssize_t                 actual;
+       __u32                   itr, cnt, size;
+       int                     c, total_size;
+       char                    buf[1024];
 
        if (flags & IMAGER_FLAG_INODEMAP) {
                if (!fs->inode_map) {
@@ -289,7 +290,10 @@ errcode_t ext2fs_image_bitmap_write(ext2_filsys fs, int fd, int flags)
                        if (retval)
                                return retval;
                }
-               ptr = fs->inode_map->bitmap;
+               bmap = fs->inode_map;
+               err = EXT2_ET_MAGIC_INODE_BITMAP;
+               itr = 1;
+               cnt = EXT2_INODES_PER_GROUP(fs->super) * fs->group_desc_count;
                size = (EXT2_INODES_PER_GROUP(fs->super) / 8);
        } else {
                if (!fs->block_map) {
@@ -297,43 +301,51 @@ errcode_t ext2fs_image_bitmap_write(ext2_filsys fs, int fd, int flags)
                        if (retval)
                                return retval;
                }
-               ptr = fs->block_map->bitmap;
+               bmap = fs->block_map;
+               err = EXT2_ET_MAGIC_BLOCK_BITMAP;
+               itr = fs->super->s_first_data_block;
+               cnt = EXT2_BLOCKS_PER_GROUP(fs->super) * fs->group_desc_count;
                size = EXT2_BLOCKS_PER_GROUP(fs->super) / 8;
        }
-       size = size * fs->group_desc_count;
-
-       actual = write(fd, ptr, size);
-       if (actual == -1) {
-               retval = errno;
-               goto errout;
-       }
-       if (actual != size) {
-               retval = EXT2_ET_SHORT_WRITE;
-               goto errout;
+       total_size = size * fs->group_desc_count;
+
+       while (cnt > 0) {
+               size = sizeof(buf);
+               if (size > (cnt >> 3))
+                       size = (cnt >> 3);
+
+               retval = ext2fs_get_generic_bitmap_range(bmap, 
+                                err, itr, size << 3, buf);
+               if (retval)
+                       return retval;
+
+               actual = write(fd, buf, size);
+               if (actual == -1)
+                       return errno;
+               if (actual != (int) size)
+                       return EXT2_ET_SHORT_READ;
+               
+               itr += size << 3;
+               cnt -= size << 3;
        }
-       size = size % fs->blocksize;
-       memset(zero_buf, 0, sizeof(zero_buf));
+
+       size = total_size % fs->blocksize;
+       memset(buf, 0, sizeof(buf));
        if (size) {
                size = fs->blocksize - size;
                while (size) {
                        c = size;
-                       if (c > (int) sizeof(zero_buf))
-                               c = sizeof(zero_buf);
-                       actual = write(fd, zero_buf, c);
-                       if (actual == -1) {
-                               retval = errno;
-                               goto errout;
-                       }
-                       if (actual != c) {
-                               retval = EXT2_ET_SHORT_WRITE;
-                               goto errout;
-                       }
+                       if (c > (int) sizeof(buf))
+                               c = sizeof(buf);
+                       actual = write(fd, buf, c);
+                       if (actual == -1)
+                               return errno;
+                       if (actual != c)
+                               return EXT2_ET_SHORT_WRITE;
                        size -= c;
                }
        }
-       retval = 0;
-errout:
-       return (retval);
+       return 0;
 }
 
 
@@ -342,10 +354,12 @@ errout:
  */
 errcode_t ext2fs_image_bitmap_read(ext2_filsys fs, int fd, int flags)
 {
-       char            *ptr, *buf = 0;
-       int             size;
-       ssize_t         actual;
-       errcode_t       retval;
+       ext2fs_generic_bitmap   bmap;
+       errcode_t               err, retval;
+       __u32                   itr, cnt;
+       char                    buf[1024];
+       unsigned int            size;
+       ssize_t                 actual;
 
        if (flags & IMAGER_FLAG_INODEMAP) {
                if (!fs->inode_map) {
@@ -353,7 +367,10 @@ errcode_t ext2fs_image_bitmap_read(ext2_filsys fs, int fd, int flags)
                        if (retval)
                                return retval;
                }
-               ptr = fs->inode_map->bitmap;
+               bmap = fs->inode_map;
+               err = EXT2_ET_MAGIC_INODE_BITMAP;
+               itr = 1;
+               cnt = EXT2_INODES_PER_GROUP(fs->super) * fs->group_desc_count;
                size = (EXT2_INODES_PER_GROUP(fs->super) / 8);
        } else {
                if (!fs->block_map) {
@@ -361,29 +378,31 @@ errcode_t ext2fs_image_bitmap_read(ext2_filsys fs, int fd, int flags)
                        if (retval)
                                return retval;
                }
-               ptr = fs->block_map->bitmap;
+               bmap = fs->block_map;
+               err = EXT2_ET_MAGIC_BLOCK_BITMAP;
+               itr = fs->super->s_first_data_block;
+               cnt = EXT2_BLOCKS_PER_GROUP(fs->super) * fs->group_desc_count;
                size = EXT2_BLOCKS_PER_GROUP(fs->super) / 8;
        }
-       size = size * fs->group_desc_count;
 
-       buf = malloc(size);
-       if (!buf)
-               return ENOMEM;
+       while (cnt > 0) {
+               size = sizeof(buf);
+               if (size > (cnt >> 3))
+                       size = (cnt >> 3);
 
-       actual = read(fd, buf, size);
-       if (actual == -1) {
-               retval = errno;
-               goto errout;
-       }
-       if (actual != size) {
-               retval = EXT2_ET_SHORT_WRITE;
-               goto errout;
+               actual = read(fd, buf, size);
+               if (actual == -1)
+                       return errno;
+               if (actual != (int) size)
+                       return EXT2_ET_SHORT_READ;
+
+               retval = ext2fs_set_generic_bitmap_range(bmap, 
+                                err, itr, size << 3, buf);
+               if (retval)
+                       return retval;
+
+               itr += size << 3;
+               cnt -= size << 3;
        }
-       memcpy(ptr, buf, size);
-       
-       retval = 0;
-errout:
-       if (buf)
-               free(buf);
-       return (retval);
+       return 0;
 }
index 3519048..9baa37f 100644 (file)
@@ -34,12 +34,10 @@ errcode_t ext2fs_read_ind_block(ext2_filsys fs, blk_t blk, void *buf)
                if (retval)
                        return retval;
        }
-#ifdef EXT2FS_ENABLE_SWAPFS
-       if (fs->flags & (EXT2_FLAG_SWAP_BYTES | EXT2_FLAG_SWAP_BYTES_READ)) {
-               block_nr = (blk_t *) buf;
-               for (i = 0; i < limit; i++, block_nr++)
-                       *block_nr = ext2fs_swab32(*block_nr);
-       }
+#ifdef WORDS_BIGENDIAN
+       block_nr = (blk_t *) buf;
+       for (i = 0; i < limit; i++, block_nr++)
+               *block_nr = ext2fs_swab32(*block_nr);
 #endif
        return 0;
 }
@@ -53,12 +51,10 @@ errcode_t ext2fs_write_ind_block(ext2_filsys fs, blk_t blk, void *buf)
        if (fs->flags & EXT2_FLAG_IMAGE_FILE)
                return 0;
 
-#ifdef EXT2FS_ENABLE_SWAPFS
-       if (fs->flags & (EXT2_FLAG_SWAP_BYTES | EXT2_FLAG_SWAP_BYTES_WRITE)) {
-               block_nr = (blk_t *) buf;
-               for (i = 0; i < limit; i++, block_nr++)
-                       *block_nr = ext2fs_swab32(*block_nr);
-       }
+#ifdef WORDS_BIGENDIAN
+       block_nr = (blk_t *) buf;
+       for (i = 0; i < limit; i++, block_nr++)
+               *block_nr = ext2fs_swab32(*block_nr);
 #endif
        return io_channel_write_blk(fs->io, blk, 1, buf);
 }
index c8f48b9..69bbcf3 100644 (file)
@@ -67,7 +67,7 @@ static unsigned int calc_reserved_gdt_blocks(ext2_filsys fs)
 {
        struct ext2_super_block *sb = fs->super;
        unsigned long bpg = sb->s_blocks_per_group;
-       unsigned int gdpb = fs->blocksize / sizeof(struct ext2_group_desc);
+       unsigned int gdpb = EXT2_DESC_PER_BLOCK(sb);
        unsigned long max_blocks = 0xffffffff;
        unsigned long rsv_groups;
        unsigned int rsv_gdb;
index 7a0cf4e..818abc9 100644 (file)
@@ -453,32 +453,28 @@ errcode_t ext2fs_get_next_inode_full(ext2_inode_scan scan, ext2_ino_t *ino,
                scan->ptr += scan->inode_size - extra_bytes;
                scan->bytes_left -= scan->inode_size - extra_bytes;
 
-#ifdef EXT2FS_ENABLE_SWAPFS
+#ifdef WORDS_BIGENDIAN
                memset(inode, 0, bufsize);
-               if ((scan->fs->flags & EXT2_FLAG_SWAP_BYTES) ||
-                   (scan->fs->flags & EXT2_FLAG_SWAP_BYTES_READ))
-                       ext2fs_swap_inode_full(scan->fs, 
-                               (struct ext2_inode_large *) inode,
-                               (struct ext2_inode_large *) scan->temp_buffer, 
-                               0, bufsize);
-               else
+               ext2fs_swap_inode_full(scan->fs, 
+                              (struct ext2_inode_large *) inode,
+                              (struct ext2_inode_large *) scan->temp_buffer, 
+                              0, bufsize);
+#else
+               *inode = *((struct ext2_inode *) scan->temp_buffer);
 #endif
-                       *inode = *((struct ext2_inode *) scan->temp_buffer);
                if (scan->scan_flags & EXT2_SF_BAD_EXTRA_BYTES)
                        retval = EXT2_ET_BAD_BLOCK_IN_INODE_TABLE;
                scan->scan_flags &= ~EXT2_SF_BAD_EXTRA_BYTES;
        } else {
-#ifdef EXT2FS_ENABLE_SWAPFS
+#ifdef WORDS_BIGENDIAN
                memset(inode, 0, bufsize);
-               if ((scan->fs->flags & EXT2_FLAG_SWAP_BYTES) ||
-                   (scan->fs->flags & EXT2_FLAG_SWAP_BYTES_READ))
-                       ext2fs_swap_inode_full(scan->fs, 
+               ext2fs_swap_inode_full(scan->fs, 
                                (struct ext2_inode_large *) inode,
                                (struct ext2_inode_large *) scan->ptr,
                                0, bufsize);
-               else
+#else
+               memcpy(inode, scan->ptr, bufsize);
 #endif
-                       memcpy(inode, scan->ptr, bufsize);
                scan->ptr += scan->inode_size;
                scan->bytes_left -= scan->inode_size;
                if (scan->scan_flags & EXT2_SF_BAD_INODE_BLK)
@@ -583,12 +579,10 @@ errcode_t ext2fs_read_inode_full(ext2_filsys fs, ext2_ino_t ino,
                block_nr++;
        }
 
-#ifdef EXT2FS_ENABLE_SWAPFS
-       if ((fs->flags & EXT2_FLAG_SWAP_BYTES) ||
-           (fs->flags & EXT2_FLAG_SWAP_BYTES_READ))
-               ext2fs_swap_inode_full(fs, (struct ext2_inode_large *) inode, 
-                                      (struct ext2_inode_large *) inode, 
-                                      0, bufsize);
+#ifdef WORDS_BIGENDIAN
+       ext2fs_swap_inode_full(fs, (struct ext2_inode_large *) inode, 
+                              (struct ext2_inode_large *) inode, 
+                              0, bufsize);
 #endif
 
        /* Update the inode cache */
@@ -657,16 +651,14 @@ errcode_t ext2fs_write_inode_full(ext2_filsys fs, ext2_ino_t ino,
                w_inode = &temp_inode;
        memset(w_inode, 0, length);
 
-#ifdef EXT2FS_ENABLE_SWAPFS
-       if ((fs->flags & EXT2_FLAG_SWAP_BYTES) ||
-           (fs->flags & EXT2_FLAG_SWAP_BYTES_WRITE))
-               ext2fs_swap_inode_full(fs, w_inode, 
-                                      (struct ext2_inode_large *) inode, 
-                                      1, bufsize);
-       else
+#ifdef WORDS_BIGENDIAN
+       ext2fs_swap_inode_full(fs, w_inode, 
+                              (struct ext2_inode_large *) inode, 
+                              1, bufsize);
+#else
+       memcpy(w_inode, inode, bufsize);
 #endif
-               memcpy(w_inode, inode, bufsize);
-       
+
        group = (ino - 1) / EXT2_INODES_PER_GROUP(fs->super);
        offset = ((ino - 1) % EXT2_INODES_PER_GROUP(fs->super)) *
                EXT2_INODE_SIZE(fs->super);
index 684e91e..d6573ad 100644 (file)
@@ -251,10 +251,8 @@ static int is_swap_device(const char *file)
        if (!(f = fopen("/proc/swaps", "r")))
                return 0;
        /* Skip the first line */
-       fgets(buf, sizeof(buf), f);
-       while (!feof(f)) {
-               if (!fgets(buf, sizeof(buf), f))
-                       break;
+       if (fgets(buf, sizeof(buf), f))
+       while (fgets(buf, sizeof(buf), f)) {
                if ((cp = strchr(buf, ' ')) != NULL)
                        *cp = 0;
                if ((cp = strchr(buf, '\t')) != NULL)
index 947675e..cb683ee 100644 (file)
@@ -39,11 +39,10 @@ blk_t ext2fs_descriptor_block_loc(ext2_filsys fs, blk_t group_block, dgrp_t i)
            (i < fs->super->s_first_meta_bg))
                return (group_block + i + 1);
 
-       bg = (fs->blocksize / sizeof (struct ext2_group_desc)) * i;
+       bg = EXT2_DESC_PER_BLOCK(fs->super) * i;
        if (ext2fs_bg_has_super(fs, bg))
                has_super = 1;
-       ret_blk = (fs->super->s_first_data_block + has_super + 
-                  (bg * fs->super->s_blocks_per_group));
+       ret_blk = ext2fs_group_first_block(fs, bg) + has_super;
        /*
         * If group_block is not the normal value, we're trying to use
         * the backup group descriptors and superblock --- so use the
@@ -178,12 +177,13 @@ errcode_t ext2fs_open2(const char *name, const char *io_options,
        if (fs->orig_super)
                memcpy(fs->orig_super, fs->super, SUPERBLOCK_SIZE);
 
-#ifdef EXT2FS_ENABLE_SWAPFS
-       if ((fs->super->s_magic == ext2fs_swab16(EXT2_SUPER_MAGIC)) ||
-           (fs->flags & EXT2_FLAG_SWAP_BYTES)) {
-               fs->flags |= EXT2_FLAG_SWAP_BYTES;
-
-               ext2fs_swap_super(fs->super);
+#ifdef WORDS_BIGENDIAN
+       fs->flags |= EXT2_FLAG_SWAP_BYTES;
+       ext2fs_swap_super(fs->super);
+#else
+       if (fs->flags & EXT2_FLAG_SWAP_BYTES) {
+               retval = EXT2_ET_UNIMPLEMENTED;
+               goto cleanup;
        }
 #endif
        
@@ -287,18 +287,16 @@ errcode_t ext2fs_open2(const char *name, const char *io_options,
        if (!group_block)
                group_block = fs->super->s_first_data_block;
        dest = (char *) fs->group_desc;
-       groups_per_block = fs->blocksize / sizeof(struct ext2_group_desc);
+       groups_per_block = EXT2_DESC_PER_BLOCK(fs->super);
        for (i=0 ; i < fs->desc_blocks; i++) {
                blk = ext2fs_descriptor_block_loc(fs, group_block, i);
                retval = io_channel_read_blk(fs->io, blk, 1, dest);
                if (retval)
                        goto cleanup;
-#ifdef EXT2FS_ENABLE_SWAPFS
-               if (fs->flags & EXT2_FLAG_SWAP_BYTES) {
-                       gdp = (struct ext2_group_desc *) dest;
-                       for (j=0; j < groups_per_block; j++)
-                               ext2fs_swap_group_desc(gdp++);
-               }
+#ifdef WORDS_BIGENDIAN
+               gdp = (struct ext2_group_desc *) dest;
+               for (j=0; j < groups_per_block; j++)
+                       ext2fs_swap_group_desc(gdp++);
 #endif
                dest += fs->blocksize;
        }
diff --git a/lib/ext2fs/rs_bitmap.c b/lib/ext2fs/rs_bitmap.c
deleted file mode 100644 (file)
index 46653f0..0000000
+++ /dev/null
@@ -1,106 +0,0 @@
-/*
- * rs_bitmap.c --- routine for changing the size of a bitmap
- *
- * Copyright (C) 1996, 1997 Theodore Ts'o.
- *
- * %Begin-Header%
- * This file may be redistributed under the terms of the GNU Public
- * License.
- * %End-Header%
- */
-
-#include <stdio.h>
-#include <string.h>
-#if HAVE_UNISTD_H
-#include <unistd.h>
-#endif
-#include <fcntl.h>
-#include <time.h>
-#ifdef HAVE_SYS_STAT_H
-#include <sys/stat.h>
-#endif
-#ifdef HAVE_SYS_TYPES_H
-#include <sys/types.h>
-#endif
-
-#include "ext2_fs.h"
-#include "ext2fs.h"
-
-errcode_t ext2fs_resize_generic_bitmap(__u32 new_end, __u32 new_real_end,
-                                      ext2fs_generic_bitmap bmap)
-{
-       errcode_t       retval;
-       size_t          size, new_size;
-       __u32           bitno;
-
-       if (!bmap)
-               return EXT2_ET_INVALID_ARGUMENT;
-
-       EXT2_CHECK_MAGIC(bmap, EXT2_ET_MAGIC_GENERIC_BITMAP);
-
-       /*
-        * If we're expanding the bitmap, make sure all of the new
-        * parts of the bitmap are zero.
-        */
-       if (new_end > bmap->end) {
-               bitno = bmap->real_end;
-               if (bitno > new_end)
-                       bitno = new_end;
-               for (; bitno > bmap->end; bitno--)
-                       ext2fs_clear_bit(bitno - bmap->start, bmap->bitmap);
-       }
-       if (new_real_end == bmap->real_end) {
-               bmap->end = new_end;
-               return 0;
-       }
-       
-       size = ((bmap->real_end - bmap->start) / 8) + 1;
-       new_size = ((new_real_end - bmap->start) / 8) + 1;
-
-       if (size != new_size) {
-               retval = ext2fs_resize_mem(size, new_size, &bmap->bitmap);
-               if (retval)
-                       return retval;
-       }
-       if (new_size > size)
-               memset(bmap->bitmap + size, 0, new_size - size);
-
-       bmap->end = new_end;
-       bmap->real_end = new_real_end;
-       return 0;
-}
-
-errcode_t ext2fs_resize_inode_bitmap(__u32 new_end, __u32 new_real_end,
-                                    ext2fs_inode_bitmap bmap)
-{
-       errcode_t       retval;
-       
-       if (!bmap)
-               return EXT2_ET_INVALID_ARGUMENT;
-
-       EXT2_CHECK_MAGIC(bmap, EXT2_ET_MAGIC_INODE_BITMAP);
-
-       bmap->magic = EXT2_ET_MAGIC_GENERIC_BITMAP;
-       retval = ext2fs_resize_generic_bitmap(new_end, new_real_end,
-                                             bmap);
-       bmap->magic = EXT2_ET_MAGIC_INODE_BITMAP;
-       return retval;
-}
-
-errcode_t ext2fs_resize_block_bitmap(__u32 new_end, __u32 new_real_end,
-                                    ext2fs_block_bitmap bmap)
-{
-       errcode_t       retval;
-       
-       if (!bmap)
-               return EXT2_ET_INVALID_ARGUMENT;
-
-       EXT2_CHECK_MAGIC(bmap, EXT2_ET_MAGIC_BLOCK_BITMAP);
-
-       bmap->magic = EXT2_ET_MAGIC_GENERIC_BITMAP;
-       retval = ext2fs_resize_generic_bitmap(new_end, new_real_end,
-                                             bmap);
-       bmap->magic = EXT2_ET_MAGIC_BLOCK_BITMAP;
-       return retval;
-}
-
index cb470b8..1897ec3 100644 (file)
 #include "ext2fs.h"
 #include "e2image.h"
 
-#if defined(__powerpc__) && defined(EXT2FS_ENABLE_SWAPFS)
-/*
- * On the PowerPC, the big-endian variant of the ext2 filesystem
- * has its bitmaps stored as 32-bit words with bit 0 as the LSB
- * of each word.  Thus a bitmap with only bit 0 set would be, as
- * a string of bytes, 00 00 00 01 00 ...
- * To cope with this, we byte-reverse each word of a bitmap if
- * we have a big-endian filesystem, that is, if we are *not*
- * byte-swapping other word-sized numbers.
- */
-#define EXT2_BIG_ENDIAN_BITMAPS
-#endif
-
-#ifdef EXT2_BIG_ENDIAN_BITMAPS
-static void ext2fs_swap_bitmap(ext2_filsys fs, char *bitmap, int nbytes)
-{
-       __u32 *p = (__u32 *) bitmap;
-       int n;
-               
-       for (n = nbytes / sizeof(__u32); n > 0; --n, ++p)
-               *p = ext2fs_swab32(*p);
-}
-#endif
-
 static errcode_t write_bitmaps(ext2_filsys fs, int do_inode, int do_block)
 {
        dgrp_t          i;
@@ -58,10 +34,11 @@ static errcode_t write_bitmaps(ext2_filsys fs, int do_inode, int do_block)
        int             block_nbytes, inode_nbytes;
        unsigned int    nbits;
        errcode_t       retval;
-       char            *block_bitmap, *inode_bitmap;
        char            *block_buf, *inode_buf;
        int             lazy_flag = 0;
        blk_t           blk;
+       blk_t           blk_itr = fs->super->s_first_data_block;
+       ext2_ino_t      ino_itr = 1;
 
        EXT2_CHECK_MAGIC(fs, EXT2_ET_MAGIC_EXT2FS_FILSYS);
 
@@ -71,9 +48,7 @@ static errcode_t write_bitmaps(ext2_filsys fs, int do_inode, int do_block)
                                    EXT2_FEATURE_COMPAT_LAZY_BG))
                lazy_flag = 1;
        inode_nbytes = block_nbytes = 0;
-       block_bitmap = inode_bitmap = 0;
        if (do_block) {
-               block_bitmap = fs->block_map->bitmap;
                block_nbytes = EXT2_BLOCKS_PER_GROUP(fs->super) / 8;
                retval = ext2fs_get_mem(fs->blocksize, &block_buf);
                if (retval)
@@ -81,7 +56,6 @@ static errcode_t write_bitmaps(ext2_filsys fs, int do_inode, int do_block)
                memset(block_buf, 0xff, fs->blocksize);
        }
        if (do_inode) {
-               inode_bitmap = fs->inode_map->bitmap;
                inode_nbytes = (size_t) 
                        ((EXT2_INODES_PER_GROUP(fs->super)+7) / 8);
                retval = ext2fs_get_mem(fs->blocksize, &inode_buf);
@@ -91,14 +65,18 @@ static errcode_t write_bitmaps(ext2_filsys fs, int do_inode, int do_block)
        }
 
        for (i = 0; i < fs->group_desc_count; i++) {
-               if (!block_bitmap || !do_block)
+               if (!do_block)
                        goto skip_block_bitmap;
 
                if (lazy_flag && fs->group_desc[i].bg_flags &
                    EXT2_BG_BLOCK_UNINIT) 
                        goto skip_this_block_bitmap;
  
-               memcpy(block_buf, block_bitmap, block_nbytes);
+               retval = ext2fs_get_block_bitmap_range(fs->block_map, 
+                               blk_itr, block_nbytes << 3, block_buf);
+               if (retval)
+                       return retval;
+
                if (i == fs->group_desc_count - 1) {
                        /* Force bitmap padding for the last group */
                        nbits = ((fs->super->s_blocks_count
@@ -110,44 +88,36 @@ static errcode_t write_bitmaps(ext2_filsys fs, int do_inode, int do_block)
                }
                blk = fs->group_desc[i].bg_block_bitmap;
                if (blk) {
-#ifdef EXT2_BIG_ENDIAN_BITMAPS
-                       if (!((fs->flags & EXT2_FLAG_SWAP_BYTES) ||
-                             (fs->flags & EXT2_FLAG_SWAP_BYTES_WRITE)))
-                               ext2fs_swap_bitmap(fs, block_buf, 
-                                                  block_nbytes);
-#endif
                        retval = io_channel_write_blk(fs->io, blk, 1,
                                                      block_buf);
                        if (retval)
                                return EXT2_ET_BLOCK_BITMAP_WRITE;
                }
        skip_this_block_bitmap:
-               block_bitmap += block_nbytes;
+               blk_itr += block_nbytes << 3;
        skip_block_bitmap:
 
-               if (!inode_bitmap || !do_inode)
+               if (!do_inode)
                        continue;
 
                if (lazy_flag && fs->group_desc[i].bg_flags &
                    EXT2_BG_INODE_UNINIT) 
                        goto skip_this_inode_bitmap;
  
-               memcpy(inode_buf, inode_bitmap, inode_nbytes);
+               retval = ext2fs_get_inode_bitmap_range(fs->inode_map, 
+                               ino_itr, inode_nbytes << 3, inode_buf);
+               if (retval)
+                       return retval;
+
                blk = fs->group_desc[i].bg_inode_bitmap;
                if (blk) {
-#ifdef EXT2_BIG_ENDIAN_BITMAPS
-                       if (!((fs->flags & EXT2_FLAG_SWAP_BYTES) ||
-                             (fs->flags & EXT2_FLAG_SWAP_BYTES_WRITE)))
-                               ext2fs_swap_bitmap(fs, inode_buf, 
-                                                  inode_nbytes);
-#endif
                        retval = io_channel_write_blk(fs->io, blk, 1,
                                                      inode_buf);
                        if (retval)
                                return EXT2_ET_INODE_BITMAP_WRITE;
                }
        skip_this_inode_bitmap:
-               inode_bitmap += inode_nbytes;
+               ino_itr += inode_nbytes << 3;
 
        }
        if (do_block) {
@@ -167,10 +137,16 @@ static errcode_t read_bitmaps(ext2_filsys fs, int do_inode, int do_block)
        char *block_bitmap = 0, *inode_bitmap = 0;
        char *buf;
        errcode_t retval;
-       int block_nbytes = (int) EXT2_BLOCKS_PER_GROUP(fs->super) / 8;
-       int inode_nbytes = (int) EXT2_INODES_PER_GROUP(fs->super) / 8;
+       unsigned int block_nbytes = EXT2_BLOCKS_PER_GROUP(fs->super) / 8;
+       unsigned inode_nbytes = EXT2_INODES_PER_GROUP(fs->super) / 8;
        int lazy_flag = 0;
+       int do_image = fs->flags & EXT2_FLAG_IMAGE_FILE;
+       unsigned int    cnt;
        blk_t   blk;
+       blk_t   blk_itr = fs->super->s_first_data_block;
+       blk_t   blk_cnt;
+       ext2_ino_t ino_itr = 1;
+       ext2_ino_t ino_cnt;
 
        EXT2_CHECK_MAGIC(fs, EXT2_ET_MAGIC_EXT2FS_FILSYS);
 
@@ -190,8 +166,12 @@ static errcode_t read_bitmaps(ext2_filsys fs, int do_inode, int do_block)
                retval = ext2fs_allocate_block_bitmap(fs, buf, &fs->block_map);
                if (retval)
                        goto cleanup;
-               block_bitmap = fs->block_map->bitmap;
-       }
+               retval = ext2fs_get_mem(do_image ? fs->blocksize : 
+                                       block_nbytes, &block_bitmap);
+               if (retval)
+                       goto cleanup;
+       } else
+               block_nbytes = 0;
        if (do_inode) {
                if (fs->inode_map)
                        ext2fs_free_inode_bitmap(fs->inode_map);
@@ -199,30 +179,54 @@ static errcode_t read_bitmaps(ext2_filsys fs, int do_inode, int do_block)
                retval = ext2fs_allocate_inode_bitmap(fs, buf, &fs->inode_map);
                if (retval)
                        goto cleanup;
-               inode_bitmap = fs->inode_map->bitmap;
-       }
+               retval = ext2fs_get_mem(do_image ? fs->blocksize : 
+                                       inode_nbytes, &inode_bitmap);
+               if (retval)
+                       goto cleanup;
+       } else
+               inode_nbytes = 0;
        ext2fs_free_mem(&buf);
 
        if (fs->flags & EXT2_FLAG_IMAGE_FILE) {
-               if (inode_bitmap) {
-                       blk = (fs->image_header->offset_inodemap /
-                              fs->blocksize);
-                       retval = io_channel_read_blk(fs->image_io, blk,
-                            -(inode_nbytes * fs->group_desc_count),
-                            inode_bitmap);
+               blk = (fs->image_header->offset_inodemap / fs->blocksize);
+               ino_cnt = fs->super->s_inodes_count;
+               while (inode_nbytes > 0) {
+                       retval = io_channel_read_blk(fs->image_io, blk++,
+                                                    1, inode_bitmap);
                        if (retval)
                                goto cleanup;
+                       cnt = fs->blocksize << 3;
+                       if (cnt > ino_cnt)
+                               cnt = ino_cnt;
+                       retval = ext2fs_set_inode_bitmap_range(fs->inode_map, 
+                                              ino_itr, cnt, inode_bitmap);
+                       if (retval)
+                               goto cleanup;
+                       ino_itr += fs->blocksize << 3;
+                       ino_cnt -= fs->blocksize << 3;
+                       inode_nbytes -= fs->blocksize;
                }
-               if (block_bitmap) {
-                       blk = (fs->image_header->offset_blockmap /
-                              fs->blocksize);
-                       retval = io_channel_read_blk(fs->image_io, blk, 
-                            -(block_nbytes * fs->group_desc_count),
-                            block_bitmap);
+               blk = (fs->image_header->offset_blockmap /
+                      fs->blocksize);
+               blk_cnt = EXT2_BLOCKS_PER_GROUP(fs->super) * 
+                       fs->group_desc_count;
+               while (block_nbytes > 0) {
+                       retval = io_channel_read_blk(fs->image_io, blk++,
+                                                    1, block_bitmap);
                        if (retval)
                                goto cleanup;
+                       cnt = fs->blocksize << 3;
+                       if (cnt > blk_cnt)
+                               cnt = blk_cnt;
+                       retval = ext2fs_set_block_bitmap_range(fs->block_map, 
+                                      blk_itr, cnt, block_bitmap);
+                       if (retval)
+                               goto cleanup;
+                       blk_itr += fs->blocksize << 3;
+                       blk_cnt -= fs->blocksize << 3;
+                       block_nbytes -= fs->blocksize;
                }
-               return 0;
+               goto success_cleanup;
        }
 
        for (i = 0; i < fs->group_desc_count; i++) {
@@ -238,14 +242,14 @@ static errcode_t read_bitmaps(ext2_filsys fs, int do_inode, int do_block)
                                        retval = EXT2_ET_BLOCK_BITMAP_READ;
                                        goto cleanup;
                                }
-#ifdef EXT2_BIG_ENDIAN_BITMAPS
-                               if (!((fs->flags & EXT2_FLAG_SWAP_BYTES) ||
-                                     (fs->flags & EXT2_FLAG_SWAP_BYTES_READ)))
-                                       ext2fs_swap_bitmap(fs, block_bitmap, block_nbytes);
-#endif
                        } else
                                memset(block_bitmap, 0xff, block_nbytes);
-                       block_bitmap += block_nbytes;
+                       cnt = block_nbytes << 3;
+                       retval = ext2fs_set_block_bitmap_range(fs->block_map, 
+                                              blk_itr, cnt, block_bitmap);
+                       if (retval)
+                               goto cleanup;
+                       blk_itr += block_nbytes << 3;
                }
                if (inode_bitmap) {
                        blk = fs->group_desc[i].bg_inode_bitmap;
@@ -259,16 +263,21 @@ static errcode_t read_bitmaps(ext2_filsys fs, int do_inode, int do_block)
                                        retval = EXT2_ET_INODE_BITMAP_READ;
                                        goto cleanup;
                                }
-#ifdef EXT2_BIG_ENDIAN_BITMAPS
-                               if (!((fs->flags & EXT2_FLAG_SWAP_BYTES) ||
-                                     (fs->flags & EXT2_FLAG_SWAP_BYTES_READ)))
-                                       ext2fs_swap_bitmap(fs, inode_bitmap, inode_nbytes);
-#endif
                        } else
                                memset(inode_bitmap, 0xff, inode_nbytes);
-                       inode_bitmap += inode_nbytes;
+                       cnt = inode_nbytes << 3;
+                       retval = ext2fs_set_inode_bitmap_range(fs->inode_map, 
+                                              ino_itr, cnt, inode_bitmap);
+                       if (retval)
+                               goto cleanup;
+                       ino_itr += inode_nbytes << 3;
                }
        }
+success_cleanup:
+       if (inode_bitmap)
+               ext2fs_free_mem(&inode_bitmap);
+       if (block_bitmap)
+               ext2fs_free_mem(&block_bitmap);
        return 0;
        
 cleanup:
@@ -280,6 +289,10 @@ cleanup:
                ext2fs_free_mem(&fs->inode_map);
                fs->inode_map = 0;
        }
+       if (inode_bitmap)
+               ext2fs_free_mem(&inode_bitmap);
+       if (block_bitmap)
+               ext2fs_free_mem(&block_bitmap);
        if (buf)
                ext2fs_free_mem(&buf);
        return retval;
index 6576c59..040e3dd 100644 (file)
@@ -20,7 +20,7 @@
 #include "ext2fs.h"
 #include <ext2fs/ext2_ext_attr.h>
 
-#ifdef EXT2FS_ENABLE_SWAPFS
+#ifdef WORDS_BIGENDIAN
 void ext2fs_swap_super(struct ext2_super_block * sb)
 {
        int i;
@@ -198,16 +198,7 @@ void ext2fs_swap_inode_full(ext2_filsys fs, struct ext2_inode_large *t,
                t->osd2.hurd2.h_i_author =
                  ext2fs_swab32 (f->osd2.hurd2.h_i_author);
                break;
-       case EXT2_OS_MASIX:
-               t->osd1.masix1.m_i_reserved1 =
-                       ext2fs_swab32(f->osd1.masix1.m_i_reserved1);
-               t->osd2.masix2.m_i_frag = f->osd2.masix2.m_i_frag;
-               t->osd2.masix2.m_i_fsize = f->osd2.masix2.m_i_fsize;
-               t->osd2.masix2.m_pad1 = ext2fs_swab16(f->osd2.masix2.m_pad1);
-               t->osd2.masix2.m_i_reserved2[0] =
-                       ext2fs_swab32(f->osd2.masix2.m_i_reserved2[0]);
-               t->osd2.masix2.m_i_reserved2[1] =
-                       ext2fs_swab32(f->osd2.masix2.m_i_reserved2[1]);
+       default:
                break;
        }
 
index 03d63ce..2fe10d2 100644 (file)
@@ -66,6 +66,8 @@ static errcode_t test_write_byte(io_channel channel, unsigned long offset,
                                 int count, const void *buf);
 static errcode_t test_set_option(io_channel channel, const char *option, 
                                 const char *arg);
+static errcode_t test_get_stats(io_channel channel, io_stats *stats);
+
 
 static struct struct_io_manager struct_test_manager = {
        EXT2_ET_MAGIC_IO_MANAGER,
@@ -77,7 +79,8 @@ static struct struct_io_manager struct_test_manager = {
        test_write_blk,
        test_flush,
        test_write_byte,
-       test_set_option
+       test_set_option,
+       test_get_stats,
 };
 
 io_manager test_io_manager = &struct_test_manager;
@@ -409,3 +412,18 @@ static errcode_t test_set_option(io_channel channel, const char *option,
        }
        return retval;
 }
+
+static errcode_t test_get_stats(io_channel channel, io_stats *stats)
+{
+       struct test_private_data *data;
+       errcode_t       retval = 0;
+
+       EXT2_CHECK_MAGIC(channel, EXT2_ET_MAGIC_IO_CHANNEL);
+       data = (struct test_private_data *) channel->private_data;
+       EXT2_CHECK_MAGIC(data, EXT2_ET_MAGIC_TEST_IO_CHANNEL);
+
+       if (data->real && data->real->manager->get_stats) {
+               retval = (data->real->manager->get_stats)(data->real, stats);
+       }
+       return retval;
+}
index 4ede000..8497a41 100644 (file)
@@ -70,6 +70,7 @@ struct unix_private_data {
        int     access_time;
        ext2_loff_t offset;
        struct unix_cache cache[CACHE_SIZE];
+       struct struct_io_stats io_stats;
 };
 
 static errcode_t unix_open(const char *name, int flags, io_channel *channel);
@@ -84,7 +85,8 @@ static errcode_t unix_write_byte(io_channel channel, unsigned long offset,
                                int size, const void *data);
 static errcode_t unix_set_option(io_channel channel, const char *option, 
                                 const char *arg);
-
+static errcode_t unix_get_stats(io_channel channel, io_stats *stats)
+;
 static void reuse_cache(io_channel channel, struct unix_private_data *data,
                 struct unix_cache *cache, unsigned long block);
 
@@ -110,11 +112,28 @@ static struct struct_io_manager struct_unix_manager = {
 #else
        unix_write_byte,
 #endif
-       unix_set_option
+       unix_set_option,
+       unix_get_stats,
 };
 
 io_manager unix_io_manager = &struct_unix_manager;
 
+static errcode_t unix_get_stats(io_channel channel, io_stats *stats)
+{
+       errcode_t       retval = 0;
+
+       struct unix_private_data *data;
+
+       EXT2_CHECK_MAGIC(channel, EXT2_ET_MAGIC_IO_CHANNEL);
+       data = (struct unix_private_data *) channel->private_data;
+       EXT2_CHECK_MAGIC(data, EXT2_ET_MAGIC_UNIX_IO_CHANNEL);
+
+       if (stats)
+               *stats = &data->io_stats;
+
+       return retval;
+}
+
 /*
  * Here are the raw I/O functions
  */
@@ -130,6 +149,7 @@ static errcode_t raw_read_blk(io_channel channel,
        int             actual = 0;
 
        size = (count < 0) ? -count : count * channel->block_size;
+       data->io_stats.bytes_read += size;
        location = ((ext2_loff_t) block * channel->block_size) + data->offset;
        if (ext2fs_llseek(data->dev, location, SEEK_SET) != location) {
                retval = errno ? errno : EXT2_ET_LLSEEK_FAILED;
@@ -168,6 +188,7 @@ static errcode_t raw_read_blk(io_channel channel,
        char            sector[BLOCKALIGN];
 
        size = (count < 0) ? -count : count * channel->block_size;
+       data->io_stats.bytes_read += size;
        location = ((ext2_loff_t) block * channel->block_size) + data->offset;
 #ifdef DEBUG
        printf("count=%d, size=%d, block=%lu, blk_size=%d, location=%llx\n",
@@ -224,6 +245,7 @@ static errcode_t raw_write_blk(io_channel channel,
                else
                        size = count * channel->block_size;
        }
+       data->io_stats.bytes_written += size;
 
        location = ((ext2_loff_t) block * channel->block_size) + data->offset;
        if (ext2fs_llseek(data->dev, location, SEEK_SET) != location) {
@@ -407,6 +429,7 @@ static errcode_t unix_open(const char *name, int flags, io_channel *channel)
 
        memset(data, 0, sizeof(struct unix_private_data));
        data->magic = EXT2_ET_MAGIC_UNIX_IO_CHANNEL;
+       data->io_stats.num_fields = 2;
 
        if ((retval = alloc_cache(io, data)))
                goto cleanup;
index 0218fd5..ce284fc 100644 (file)
@@ -8,4 +8,5 @@ Description: Subsystem command parsing library
 Version: @E2FSPROGS_VERSION@
 Requires: com_err
 Cflags: -I${includedir} 
-Libs: -L${libdir} -lss @DLOPEN_LIB@
+Libs: -L${libdir} -lss
+Libs.private: @DLOPEN_LIB@
index db18985..baae053 100644 (file)
@@ -76,7 +76,7 @@ prof_err.c prof_err.h: $(srcdir)/../e2fsck/prof_err.et
 
 default_profile.c: $(srcdir)/mke2fs.conf $(srcdir)/profile-to-c.awk
        @echo " PROFILE_TO_C mke2fs.conf"
-       $(AWK) -f $(srcdir)/profile-to-c.awk < $(srcdir)/mke2fs.conf \
+       @$(AWK) -f $(srcdir)/profile-to-c.awk < $(srcdir)/mke2fs.conf \
                >  default_profile.c
 profile.o:
        @echo " CC $<"
index 88c5a74..709effe 100644 (file)
@@ -67,13 +67,13 @@ static int s_flag = 0;                      /* show progress of test */
 static int force = 0;                  /* force check of mounted device */
 static int t_flag = 0;                 /* number of test patterns */
 static int t_max = 0;                  /* allocated test patterns */
-static unsigned long *t_patts = NULL;  /* test patterns */
+static unsigned int *t_patts = NULL;   /* test patterns */
 static int current_O_DIRECT = 0;       /* Current status of O_DIRECT flag */
 static int exclusive_ok = 0;
 
 #define T_INC 32
 
-int sys_page_size = 4096;
+unsigned int sys_page_size = 4096;
 
 static void usage(void)
 {
@@ -90,8 +90,8 @@ static void exclusive_usage(void)
        exit(1);
 }
 
-static unsigned long currently_testing = 0;
-static unsigned long num_blocks = 0;
+static blk_t currently_testing = 0;
+static blk_t num_blocks = 0;
 static ext2_badblocks_list bb_list = NULL;
 static FILE *out;
 static blk_t next_bad = 0;
@@ -124,14 +124,14 @@ static void *allocate_buffer(size_t size)
  * This routine reports a new bad block.  If the bad block has already
  * been seen before, then it returns 0; otherwise it returns 1.
  */
-static int bb_output (unsigned long bad)
+static int bb_output (blk_t bad)
 {
        errcode_t errcode;
 
        if (ext2fs_badblocks_list_test(bb_list, bad))
                return 0;
 
-       fprintf(out, "%lu\n", bad);
+       fprintf(out, "%lu\n", (unsigned long) bad);
        fflush(out);
 
        errcode = ext2fs_badblocks_list_add (bb_list, bad);
@@ -151,7 +151,8 @@ static int bb_output (unsigned long bad)
 
 static void print_status(void)
 {
-       fprintf(stderr, "%15ld/%15ld", currently_testing, num_blocks);
+       fprintf(stderr, "%15lu/%15lu", (unsigned long) currently_testing, 
+               (unsigned long) num_blocks);
        fputs("\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b", stderr);
        fflush (stderr);
 }
@@ -197,7 +198,7 @@ static void uncapture_terminate(void)
 }
 
 static void set_o_direct(int dev, unsigned char *buffer, size_t size,
-                        unsigned long current_block)
+                        blk_t current_block)
 {
 #ifdef O_DIRECT
        int new_flag = O_DIRECT;
@@ -221,13 +222,13 @@ static void set_o_direct(int dev, unsigned char *buffer, size_t size,
 }
 
 
-static void pattern_fill(unsigned char *buffer, unsigned long pattern,
+static void pattern_fill(unsigned char *buffer, unsigned int pattern,
                         size_t n)
 {
        unsigned int    i, nb;
        unsigned char   bpattern[sizeof(pattern)], *ptr;
        
-       if (pattern == (unsigned long) ~0) {
+       if (pattern == (unsigned int) ~0) {
                for (ptr = buffer; ptr < buffer + n; ptr++) {
                        (*ptr) = random() % (1 << (8 * sizeof(char)));
                }
@@ -262,8 +263,8 @@ static void pattern_fill(unsigned char *buffer, unsigned long pattern,
  * Perform a read of a sequence of blocks; return the number of blocks
  *    successfully sequentially read.
  */
-static long do_read (int dev, unsigned char * buffer, int try, int block_size,
-                    unsigned long current_block)
+static int do_read (int dev, unsigned char * buffer, int try, int block_size,
+                   blk_t current_block)
 {
        long got;
 
@@ -291,8 +292,8 @@ static long do_read (int dev, unsigned char * buffer, int try, int block_size,
  * Perform a write of a sequence of blocks; return the number of blocks
  *    successfully sequentially written.
  */
-static long do_write (int dev, unsigned char * buffer, int try, int block_size,
-                    unsigned long current_block)
+static int do_write(int dev, unsigned char * buffer, int try, int block_size,
+                   unsigned long current_block)
 {
        long got;
 
@@ -327,13 +328,13 @@ static void flush_bufs(void)
                com_err(program_name, retval, _("during ext2fs_sync_device"));
 }
 
-static unsigned int test_ro (int dev, unsigned long last_block,
-                            int block_size, unsigned long from_count,
-                            unsigned long blocks_at_once)
+static unsigned int test_ro (int dev, blk_t last_block,
+                            int block_size, blk_t from_count,
+                            unsigned int blocks_at_once)
 {
        unsigned char * blkbuf;
        int try;
-       long got;
+       int got;
        unsigned int bb_count = 0;
        errcode_t errcode;
 
@@ -358,8 +359,9 @@ static unsigned int test_ro (int dev, unsigned long last_block,
                exit (1);
        }
        if (v_flag) {
-           fprintf (stderr, _("Checking blocks %lu to %lu\n"), from_count,
-                    last_block - 1);
+               fprintf (stderr, _("Checking blocks %lu to %lu\n"), 
+                        (unsigned long) from_count, 
+                        (unsigned long) last_block - 1);
        }
        if (t_flag) {
                fputs(_("Checking for bad blocks in read-only mode\n"), stderr);
@@ -404,7 +406,7 @@ static unsigned int test_ro (int dev, unsigned long last_block,
                if (got == try) {
                        try = blocks_at_once;
                        /* recover page-aligned offset for O_DIRECT */
-                       if ( blocks_at_once >= (unsigned long) (sys_page_size >> 9)
+                       if ( (blocks_at_once >= sys_page_size >> 9)
                             && (currently_testing % (sys_page_size >> 9)!= 0))
                                try -= (sys_page_size >> 9)
                                        - (currently_testing 
@@ -430,13 +432,13 @@ static unsigned int test_ro (int dev, unsigned long last_block,
        return bb_count;
 }
 
-static unsigned int test_rw (int dev, unsigned long last_block,
-                            int block_size, unsigned long from_count,
-                            unsigned long blocks_at_once)
+static unsigned int test_rw (int dev, blk_t last_block,
+                            int block_size, blk_t from_count,
+                            unsigned int blocks_at_once)
 {
        unsigned char *buffer, *read_buffer;
-       const unsigned long patterns[] = {0xaa, 0x55, 0xff, 0x00};
-       const unsigned long *pattern;
+       const unsigned int patterns[] = {0xaa, 0x55, 0xff, 0x00};
+       const unsigned int *pattern;
        int i, try, got, nr_pattern, pat_idx;
        unsigned int bb_count = 0;
 
@@ -454,7 +456,8 @@ static unsigned int test_rw (int dev, unsigned long last_block,
                fputs(_("Checking for bad blocks in read-write mode\n"), 
                      stderr);
                fprintf(stderr, _("From block %lu to %lu\n"),
-                        from_count, last_block);
+                       (unsigned long) from_count, 
+                       (unsigned long) last_block);
        }
        if (t_flag) {
                pattern = t_patts;
@@ -484,7 +487,7 @@ static unsigned int test_rw (int dev, unsigned long last_block,
                        if (got == try) {
                                try = blocks_at_once;
                                /* recover page-aligned offset for O_DIRECT */
-                               if ( blocks_at_once >= (unsigned long) (sys_page_size >> 9)
+                               if ( (blocks_at_once >= sys_page_size >> 9)
                                     && (currently_testing % 
                                         (sys_page_size >> 9)!= 0))
                                        try -= (sys_page_size >> 9)
@@ -528,7 +531,7 @@ static unsigned int test_rw (int dev, unsigned long last_block,
                        }
                        currently_testing += got;
                        /* recover page-aligned offset for O_DIRECT */
-                       if ( blocks_at_once >= (unsigned long) (sys_page_size >> 9)
+                       if ( (blocks_at_once >= sys_page_size >> 9)
                             && (currently_testing % (sys_page_size >> 9)!= 0))
                                try = blocks_at_once - (sys_page_size >> 9)
                                        - (currently_testing 
@@ -555,17 +558,18 @@ struct saved_blk_record {
        int     num;
 };
 
-static unsigned int test_nd (int dev, unsigned long last_block,
-                            int block_size, unsigned long from_count,
-                            unsigned long blocks_at_once)
+static unsigned int test_nd (int dev, blk_t last_block,
+                            int block_size, blk_t from_count,
+                            unsigned int blocks_at_once)
 {
        unsigned char *blkbuf, *save_ptr, *test_ptr, *read_ptr;
        unsigned char *test_base, *save_base, *read_base;
        int try, i;
-       const unsigned long patterns[] = { ~0 };
-       const unsigned long *pattern;
+       const unsigned int patterns[] = { ~0 };
+       const unsigned int *pattern;
        int nr_pattern, pat_idx;
-       long got, used2, written, save_currently_testing;
+       int got, used2, written;
+       blk_t save_currently_testing;
        struct saved_blk_record *test_record;
        /* This is static to prevent being clobbered by the longjmp */
        static int num_saved;
@@ -601,7 +605,8 @@ static unsigned int test_nd (int dev, unsigned long last_block,
        flush_bufs();
        if (v_flag) {
            fputs(_("Checking for bad blocks in non-destructive read-write mode\n"), stderr);
-           fprintf (stderr, _("From block %lu to %lu\n"), from_count, last_block);
+           fprintf (stderr, _("From block %lu to %lu\n"), 
+                    (unsigned long) from_count, (unsigned long) last_block);
        }
        if (s_flag || v_flag > 1) {
                fputs(_("Checking for bad blocks (non-destructive read-write test)\n"), stderr);
@@ -682,7 +687,8 @@ static unsigned int test_nd (int dev, unsigned long last_block,
                        if (written != got)
                                com_err (program_name, errno,
                                         _("during test data write, block %lu"),
-                                        currently_testing + written);
+                                        (unsigned long) currently_testing + 
+                                        written);
 
                        buf_used += got;
                        save_ptr += got * block_size;
@@ -813,27 +819,43 @@ static void check_mount(char *device_name)
 
 }
 
+/*
+ * This function will convert a string to an unsigned long, printing
+ * an error message if it fails, and returning success or failure in err.
+ */
+static unsigned int parse_uint(const char *str, const char *descr)
+{
+       char            *tmp;
+       unsigned long   ret;
+       
+       ret = strtoul(str, &tmp, 0);
+       if (*tmp || errno || (ret > UINT_MAX) ||
+           (ret == ULONG_MAX && errno == ERANGE)) {
+               com_err (program_name, 0, _("invalid %s - %s"), descr, str);
+               exit (1);
+       }
+       return ret;
+}
 
 int main (int argc, char ** argv)
 {
        int c;
-       char * tmp;
        char * device_name;
        char * host_device_name = NULL;
        char * input_file = NULL;
        char * output_file = NULL;
        FILE * in = NULL;
        int block_size = 1024;
-       unsigned long blocks_at_once = 64;
+       unsigned int blocks_at_once = 64;
        blk_t last_block, from_count;
        int num_passes = 0;
        int passes_clean = 0;
        int dev;
        errcode_t errcode;
-       unsigned long pattern;
-       unsigned int (*test_func)(int, unsigned long,
-                                 int, unsigned long,
-                                 unsigned long);
+       unsigned int pattern;
+       unsigned int (*test_func)(int, blk_t,
+                                 int, blk_t,
+                                 unsigned int);
        int open_flag = 0;
        long sysval;
 
@@ -865,8 +887,8 @@ int main (int argc, char ** argv)
        while ((c = getopt (argc, argv, "b:fi:o:svwnc:p:h:t:X")) != EOF) {
                switch (c) {
                case 'b':
-                       block_size = strtoul (optarg, &tmp, 0);
-                       if (*tmp || block_size > 4096) {
+                       block_size = parse_uint(optarg, "block size");
+                       if (block_size > 4096) {
                                com_err (program_name, 0,
                                         _("bad block size - %s"), optarg);
                                exit (1);
@@ -900,27 +922,18 @@ int main (int argc, char ** argv)
                        w_flag = 2;
                        break;
                case 'c':
-                       blocks_at_once = strtoul (optarg, &tmp, 0);
-                       if (*tmp) {
-                               com_err (program_name, 0,
-                                        "bad simultaneous block count - %s", optarg);
-                               exit (1);
-                       }
+                       blocks_at_once = parse_uint(optarg, "blocks at once");
                        break;
                case 'p':
-                       num_passes = strtoul (optarg, &tmp, 0);
-                       if (*tmp) {
-                               com_err (program_name, 0,
-                                   "bad number of clean passes - %s", optarg);
-                               exit (1);
-                       }
+                       num_passes = parse_uint(optarg, 
+                                               "number of clean passes");
                        break;
                case 'h':
                        host_device_name = optarg;
                        break;
                case 't':
                        if (t_flag + 1 > t_max) {
-                               unsigned long *t_patts_new;
+                               unsigned int *t_patts_new;
 
                                t_patts_new = realloc(t_patts, t_max + T_INC);
                                if (!t_patts_new) {
@@ -936,14 +949,8 @@ int main (int argc, char ** argv)
                        if (!strcmp(optarg, "r") || !strcmp(optarg,"random")) {
                                t_patts[t_flag++] = ~0;
                        } else {
-                               pattern = strtoul(optarg, &tmp, 0);
-                               if (*tmp) {
-                                       com_err(program_name, 0,
-                                       _("invalid test_pattern: %s\n"),
-                                               optarg);
-                                       exit(1);
-                               }
-                               if (pattern == (unsigned long) ~0)
+                               pattern = parse_uint(optarg, "test pattern");
+                               if (pattern == (unsigned int) ~0)
                                        pattern = 0xffff;
                                t_patts[t_flag++] = pattern;
                        }
@@ -962,7 +969,7 @@ int main (int argc, char ** argv)
                          "in read-only mode"));
                        exit(1);
                }
-               if (t_patts && (t_patts[0] == (unsigned long) ~0)) {
+               if (t_patts && (t_patts[0] == (unsigned int) ~0)) {
                        com_err(program_name, 0,
                        _("Random test_pattern is not allowed "
                          "in read-only mode"));
@@ -989,30 +996,18 @@ int main (int argc, char ** argv)
                }
        } else {
                errno = 0;
-               last_block = strtoul (argv[optind], &tmp, 0);
+               last_block = parse_uint(argv[optind], "last block");
                printf("last_block = %d (%s)\n", last_block, argv[optind]);
-               if (*tmp || errno || 
-                   (last_block == ULONG_MAX && errno == ERANGE)) {
-                       com_err (program_name, 0, _("invalid blocks count - %s"),
-                                argv[optind]);
-                       exit (1);
-               }
                last_block++;
                optind++;
        }
        if (optind <= argc-1) {
                errno = 0;
-               from_count = strtoul (argv[optind], &tmp, 0);
+               from_count = parse_uint(argv[optind], "start block");
                printf("from_count = %d\n", from_count);
-               if (*tmp || errno ||
-                   (from_count == ULONG_MAX && errno == ERANGE)) {
-                       com_err (program_name, 0, _("invalid starting block - %s"),
-                                argv[optind]);
-                       exit (1);
-               }
        } else from_count = 0;
        if (from_count >= last_block) {
-           com_err (program_name, 0, _("invalid starting block (%d): must be less than %lu"),
+           com_err (program_name, 0, _("invalid starting block (%lu): must be less than %lu"),
                     (unsigned long) from_count, (unsigned long) last_block);
            exit (1);
        }
index 2b48fb0..2334675 100644 (file)
@@ -5,7 +5,7 @@ chattr \- change file attributes on a Linux second extended file system
 .SH SYNOPSIS
 .B chattr
 [
-.B \-RV
+.B \-RVf
 ]
 [
 .B \-v
@@ -34,12 +34,13 @@ synchronous updates (S), and top of directory hierarchy (T).
 .TP
 .B \-R
 Recursively change attributes of directories and their contents.
-Symbolic links encountered during recursive directory traversals are
-ignored.
 .TP
 .B \-V
 Be verbose with chattr's output and print the program version.
 .TP
+.B \-f
+Suppress most error messages.
+.TP
 .BI \-v " version"
 Set the file's version/generation number.
 .SH ATTRIBUTES
index c6d8d9f..efaa559 100644 (file)
@@ -65,6 +65,7 @@ static unsigned long version;
 
 static int recursive;
 static int verbose;
+static int silent;
 
 static unsigned long af;
 static unsigned long rf;
@@ -80,8 +81,8 @@ static unsigned long sf;
 
 static void usage(void)
 {
-       fprintf(stderr, 
-               _("Usage: %s [-RV] [-+=AacDdijsSu] [-v version] files...\n"),
+       fprintf(stderr,
+               _("Usage: %s [-RVf] [-+=AacDdijsSu] [-v version] files...\n"),
                program_name);
        exit(1);
 }
@@ -137,6 +138,10 @@ static int decode_arg (int * i, int argc, char ** argv)
                                verbose = 1;
                                continue;
                        }
+                       if (*p == 'f') {
+                               silent = 1;
+                               continue;
+                       }
                        if (*p == 'v') {
                                (*i)++;
                                if (*i >= argc)
@@ -144,7 +149,7 @@ static int decode_arg (int * i, int argc, char ** argv)
                                version = strtol (argv[*i], &tmp, 0);
                                if (*tmp) {
                                        com_err (program_name, 0,
-                                                _("bad version - %s\n"), 
+                                                _("bad version - %s\n"),
                                                 argv[*i]);
                                        usage ();
                                }
@@ -182,26 +187,17 @@ static int decode_arg (int * i, int argc, char ** argv)
 
 static int chattr_dir_proc (const char *, struct dirent *, void *);
 
-static void change_attributes (const char * name)
+static int change_attributes (const char * name, int cmdline)
 {
        unsigned long flags;
        STRUCT_STAT     st;
 
        if (LSTAT (name, &st) == -1) {
-               com_err (program_name, errno, _("while trying to stat %s"), 
-                        name);
-               return;
+               if (!silent)
+                       com_err (program_name, errno,
+                                _("while trying to stat %s"), name);
+               return -1;
        }
-       if (S_ISLNK(st.st_mode) && recursive)
-               return;
-
-       /* Don't try to open device files, fifos etc.  We probably
-           ought to display an error if the file was explicitly given
-           on the command line (whether or not recursive was
-           requested).  */
-       if (!S_ISREG(st.st_mode) && !S_ISLNK(st.st_mode) &&
-           !S_ISDIR(st.st_mode))
-               return;
 
        if (set) {
                if (verbose) {
@@ -212,10 +208,12 @@ static void change_attributes (const char * name)
                if (fsetflags (name, sf) == -1)
                        perror (name);
        } else {
-               if (fgetflags (name, &flags) == -1)
-                       com_err (program_name, errno,
-                                _("while reading flags on %s"), name);
-               else {
+               if (fgetflags (name, &flags) == -1) {
+                       if (!silent)
+                               com_err (program_name, errno,
+                                        _("while reading flags on %s"), name);
+                       return -1;
+               } else {
                        if (rem)
                                flags &= ~rf;
                        if (add)
@@ -227,25 +225,36 @@ static void change_attributes (const char * name)
                        }
                        if (!S_ISDIR(st.st_mode))
                                flags &= ~EXT2_DIRSYNC_FL;
-                       if (fsetflags (name, flags) == -1)
-                               com_err (program_name, errno,
-                                        _("while setting flags on %s"), name);
+                       if (fsetflags (name, flags) == -1) {
+                               if (!silent)
+                                       com_err(program_name, errno,
+                                               _("while setting flags on %s"),
+                                               name);
+                               return -1;
+                       }
                }
        }
        if (set_version) {
                if (verbose)
                        printf (_("Version of %s set as %lu\n"), name, version);
-               if (fsetversion (name, version) == -1)
-                       com_err (program_name, errno,
-                                _("while setting version on %s"), name);
+               if (fsetversion (name, version) == -1) {
+                       if (!silent)
+                               com_err (program_name, errno,
+                                        _("while setting version on %s"),
+                                        name);
+                       return -1;
+               }
        }
        if (S_ISDIR(st.st_mode) && recursive)
-               iterate_on_dir (name, chattr_dir_proc, NULL);
+               return iterate_on_dir (name, chattr_dir_proc, NULL);
+       return 0;
 }
 
 static int chattr_dir_proc (const char * dir_name, struct dirent * de,
                            void * private EXT2FS_ATTR((unused)))
 {
+       int ret = 0;
+
        if (strcmp (de->d_name, ".") && strcmp (de->d_name, "..")) {
                char *path;
 
@@ -253,19 +262,20 @@ static int chattr_dir_proc (const char * dir_name, struct dirent * de,
                if (!path) {
                        fprintf(stderr, _("Couldn't allocate path variable "
                                          "in chattr_dir_proc"));
-                       exit(1);
+                       return -1;
                }
-               sprintf (path, "%s/%s", dir_name, de->d_name);
-               change_attributes (path);
+               sprintf(path, "%s/%s", dir_name, de->d_name);
+               ret = change_attributes(path, 0);
                free(path);
        }
-       return 0;
+       return ret;
 }
 
 int main (int argc, char ** argv)
 {
        int i, j;
        int end_arg = 0;
+       int err, retval = 0;
 
 #ifdef ENABLE_NLS
        setlocale(LC_MESSAGES, "");
@@ -303,7 +313,10 @@ int main (int argc, char ** argv)
        if (verbose)
                fprintf (stderr, "chattr %s (%s)\n",
                         E2FSPROGS_VERSION, E2FSPROGS_DATE);
-       for (j = i; j < argc; j++)
-               change_attributes (argv[j]);
-       exit(0);
+       for (j = i; j < argc; j++) {
+               err = change_attributes (argv[j], 1);
+               if (err)
+                       retval = 1;
+       }
+       exit(retval);
 }
index fcae0f0..d4d95bb 100644 (file)
@@ -134,12 +134,18 @@ static void list_desc (ext2_filsys fs)
        blk_t   super_blk, old_desc_blk, new_desc_blk;
        char *block_bitmap=NULL, *inode_bitmap=NULL;
        int inode_blocks_per_group, old_desc_blocks, reserved_gdt;
+       int             block_nbytes, inode_nbytes;
        int has_super;
+       blk_t           blk_itr = fs->super->s_first_data_block;
+       ext2_ino_t      ino_itr = 1;
+
+       block_nbytes = EXT2_BLOCKS_PER_GROUP(fs->super) / 8;
+       inode_nbytes = EXT2_INODES_PER_GROUP(fs->super) / 8;
 
        if (fs->block_map)
-               block_bitmap = fs->block_map->bitmap;
+               block_bitmap = malloc(block_nbytes);
        if (fs->inode_map)
-               inode_bitmap = fs->inode_map->bitmap;
+               inode_bitmap = malloc(inode_nbytes);
 
        inode_blocks_per_group = ((fs->super->s_inodes_per_group *
                                   EXT2_INODE_SIZE(fs->super)) +
@@ -211,18 +217,22 @@ static void list_desc (ext2_filsys fs)
                        fs->group_desc[i].bg_used_dirs_count);
                if (block_bitmap) {
                        fputs(_("  Free blocks: "), stdout);
+                       ext2fs_get_block_bitmap_range(fs->block_map, 
+                                blk_itr, block_nbytes << 3, block_bitmap);
                        print_free (i, block_bitmap,
                                    fs->super->s_blocks_per_group,
                                    fs->super->s_first_data_block);
                        fputc('\n', stdout);
-                       block_bitmap += fs->super->s_blocks_per_group / 8;
+                       blk_itr += fs->super->s_blocks_per_group;
                }
                if (inode_bitmap) {
                        fputs(_("  Free inodes: "), stdout);
+                       ext2fs_get_inode_bitmap_range(fs->inode_map, 
+                                ino_itr, inode_nbytes << 3, inode_bitmap);
                        print_free (i, inode_bitmap,
                                    fs->super->s_inodes_per_group, 1);
                        fputc('\n', stdout);
-                       inode_bitmap += fs->super->s_inodes_per_group / 8;
+                       ino_itr += fs->super->s_inodes_per_group;
                }
        }
 }
@@ -334,7 +344,6 @@ int main (int argc, char ** argv)
        int             force = 0;
        int             flags;
        int             header_only = 0;
-       int             big_endian;
        int             c;
 
 #ifdef ENABLE_NLS
@@ -405,12 +414,6 @@ int main (int argc, char ** argv)
        if (print_badblocks) {
                list_bad_blocks(fs, 1);
        } else {
-               big_endian = ((fs->flags & EXT2_FLAG_SWAP_BYTES) != 0);
-#ifdef WORDS_BIGENDIAN
-               big_endian = !big_endian;
-#endif
-               if (big_endian)
-                       printf(_("Note: This is a byte-swapped filesystem\n"));
                list_super (fs->super);
                if (fs->super->s_feature_incompat &
                      EXT3_FEATURE_INCOMPAT_JOURNAL_DEV) {
index b4836ea..d53679b 100644 (file)
@@ -126,8 +126,7 @@ static void write_image_file(ext2_filsys fs, int fd)
        hdr.magic_number = EXT2_ET_MAGIC_E2IMAGE;
        strcpy(hdr.magic_descriptor, "Ext2 Image 1.0");
        gethostname(hdr.fs_hostname, sizeof(hdr.fs_hostname));
-       strncat(hdr.fs_device_name, device_name, sizeof(hdr.fs_device_name));
-       hdr.fs_device_name[sizeof(hdr.fs_device_name) - 1] = 0;
+       strncat(hdr.fs_device_name, device_name, sizeof(hdr.fs_device_name) - 1);
        hdr.fs_blocksize = fs->blocksize;
        
        if (stat(device_name, &st) == 0)
@@ -346,9 +345,8 @@ static void scramble_dir_block(ext2_filsys fs, blk_t blk, char *buf)
        for (p = buf; p < end-8; p += rec_len) {
                dirent = (struct ext2_dir_entry_2 *) p;
                rec_len = dirent->rec_len;
-#ifdef EXT2FS_ENABLE_SWAPFS
-               if (fs->flags & EXT2_FLAG_SWAP_BYTES) 
-                       rec_len = ext2fs_swab16(rec_len);
+#ifdef WORDS_BIGENDIAN
+               rec_len = ext2fs_swab16(rec_len);
 #endif
 #if 0
                printf("rec_len = %d, name_len = %d\n", rec_len, dirent->name_len);
@@ -359,8 +357,7 @@ static void scramble_dir_block(ext2_filsys fs, blk_t blk, char *buf)
                               "bad rec_len (%d)\n", (unsigned long) blk, 
                               rec_len);
                        rec_len = end - p;
-#ifdef EXT2FS_ENABLE_SWAPFS
-                       if (fs->flags & EXT2_FLAG_SWAP_BYTES) 
+#ifdef WORDS_BIGENDIAN
                                dirent->rec_len = ext2fs_swab16(rec_len);
 #endif
                        continue;
index 3795790..44f45aa 100644 (file)
@@ -693,8 +693,7 @@ static void show_stats(ext2_filsys fs)
        if (s->s_reserved_gdt_blocks)
                printf(_("Maximum filesystem blocks=%lu\n"),
                       (s->s_reserved_gdt_blocks + fs->desc_blocks) *
-                      (fs->blocksize / sizeof(struct ext2_group_desc)) *
-                      s->s_blocks_per_group);
+                      EXT2_DESC_PER_BLOCK(s) * s->s_blocks_per_group);
        if (fs->group_desc_count > 1)
                printf(_("%u block groups\n"), fs->group_desc_count);
        else
@@ -740,8 +739,6 @@ static int set_os(struct ext2_super_block *sb, char *os)
                sb->s_creator_os = EXT2_OS_LINUX;
        else if (strcasecmp(os, "GNU") == 0 || strcasecmp(os, "hurd") == 0)
                sb->s_creator_os = EXT2_OS_HURD;
-       else if (strcasecmp(os, "masix") == 0)
-               sb->s_creator_os = EXT2_OS_MASIX;
        else if (strcasecmp(os, "freebsd") == 0)
                sb->s_creator_os = EXT2_OS_FREEBSD;
        else if (strcasecmp(os, "lites") == 0)
@@ -826,7 +823,7 @@ static void parse_extended_opts(struct ext2_super_block *param,
                        bpg = param->s_blocks_per_group;
                        if (!bpg)
                                bpg = blocksize * 8;
-                       gdpb = blocksize / sizeof(struct ext2_group_desc);
+                       gdpb = EXT2_DESC_PER_BLOCK(param);
                        group_desc_count = 
                                ext2fs_div_ceil(param->s_blocks_count, bpg);
                        desc_blocks = (group_desc_count +
@@ -873,7 +870,8 @@ static __u32 ok_features[3] = {
                EXT2_FEATURE_COMPAT_LAZY_BG,    /* Compat */
        EXT2_FEATURE_INCOMPAT_FILETYPE|         /* Incompat */
                EXT3_FEATURE_INCOMPAT_JOURNAL_DEV|
-               EXT2_FEATURE_INCOMPAT_META_BG,
+               EXT2_FEATURE_INCOMPAT_META_BG|
+               EXT4_FEATURE_INCOMPAT_FLEX_BG,
        EXT2_FEATURE_RO_COMPAT_SPARSE_SUPER     /* R/O compat */
 };
 
@@ -1526,7 +1524,7 @@ int main (int argc, char *argv[])
        errcode_t       retval = 0;
        ext2_filsys     fs;
        badblocks_list  bb_list = 0;
-       int             journal_blocks;
+       unsigned int    journal_blocks;
        unsigned int    i;
        int             val;
        io_manager      io_ptr;
@@ -1734,7 +1732,7 @@ int main (int argc, char *argv[])
                        goto no_journal;
                }
                if (!quiet) {
-                       printf(_("Creating journal (%d blocks): "),
+                       printf(_("Creating journal (%u blocks): "),
                               journal_blocks);
                        fflush(stdout);
                }
index 833b994..f64e997 100644 (file)
@@ -97,7 +97,8 @@ static void usage(void)
 static __u32 ok_features[3] = {
        EXT3_FEATURE_COMPAT_HAS_JOURNAL |
                EXT2_FEATURE_COMPAT_DIR_INDEX,  /* Compat */
-       EXT2_FEATURE_INCOMPAT_FILETYPE,         /* Incompat */
+       EXT2_FEATURE_INCOMPAT_FILETYPE|         /* Incompat */
+               EXT4_FEATURE_INCOMPAT_FLEX_BG,
        EXT2_FEATURE_RO_COMPAT_SPARSE_SUPER     /* R/O compat */
 };
 
@@ -283,6 +284,7 @@ static void update_feature_set(ext2_filsys fs, char *features)
 {
        int sparse, old_sparse, filetype, old_filetype;
        int journal, old_journal, dxdir, old_dxdir;
+       int flex_bg, old_flex_bg;
        struct ext2_super_block *sb= fs->super;
        __u32   old_compat, old_incompat, old_ro_compat;
 
@@ -294,6 +296,8 @@ static void update_feature_set(ext2_filsys fs, char *features)
                EXT2_FEATURE_RO_COMPAT_SPARSE_SUPER;
        old_filetype = sb->s_feature_incompat &
                EXT2_FEATURE_INCOMPAT_FILETYPE;
+       old_flex_bg = sb->s_feature_incompat &
+               EXT4_FEATURE_INCOMPAT_FLEX_BG;
        old_journal = sb->s_feature_compat &
                EXT3_FEATURE_COMPAT_HAS_JOURNAL;
        old_dxdir = sb->s_feature_compat &
@@ -308,6 +312,8 @@ static void update_feature_set(ext2_filsys fs, char *features)
                EXT2_FEATURE_RO_COMPAT_SPARSE_SUPER;
        filetype = sb->s_feature_incompat &
                EXT2_FEATURE_INCOMPAT_FILETYPE;
+       flex_bg = sb->s_feature_incompat &
+               EXT4_FEATURE_INCOMPAT_FLEX_BG;
        journal = sb->s_feature_compat &
                EXT3_FEATURE_COMPAT_HAS_JOURNAL;
        dxdir = sb->s_feature_compat &
@@ -352,6 +358,14 @@ static void update_feature_set(ext2_filsys fs, char *features)
                if (uuid_is_null((unsigned char *) sb->s_hash_seed))
                        uuid_generate((unsigned char *) sb->s_hash_seed);
        }
+       if (!flex_bg && old_flex_bg) {
+               if (ext2fs_check_desc(fs)) {
+                       fputs(_("Clearing the flex_bg flag would "
+                               "cause the the filesystem to be\n"
+                               "inconsistent.\n"), stderr);
+                       exit(1);
+               }
+       }
 
        if (sb->s_rev_level == EXT2_GOOD_OLD_REV &&
            (sb->s_feature_compat || sb->s_feature_ro_compat ||
index 7522e9b..7c99a2a 100644 (file)
@@ -71,8 +71,8 @@ void proceed_question(void)
        fflush(stderr);
        fputs(_("Proceed anyway? (y,n) "), stdout);
        buf[0] = 0;
-       fgets(buf, sizeof(buf), stdin);
-       if (strchr(short_yes, buf[0]) == 0)
+       if (!fgets(buf, sizeof(buf), stdin) ||
+           strchr(short_yes, buf[0]) == 0)
                exit(1);
 }
 
@@ -249,7 +249,7 @@ void parse_journal_opts(const char *opts)
  * in the filesystem.  For very small filesystems, it is not reasonable to
  * have a journal that fills more than half of the filesystem.
  */
-int figure_journal_size(int size, ext2_filsys fs)
+unsigned int figure_journal_size(int size, ext2_filsys fs)
 {
        int j_blocks;
 
@@ -269,7 +269,7 @@ int figure_journal_size(int size, ext2_filsys fs)
                                j_blocks);
                        exit(1);
                }
-               if (j_blocks > fs->super->s_free_blocks_count / 2) {
+               if ((unsigned) j_blocks > fs->super->s_free_blocks_count / 2) {
                        fputs(_("\nJournal size too big for filesystem.\n"),
                              stderr);
                        exit(1);
index 3b6a881..0df2aac 100644 (file)
@@ -22,5 +22,5 @@ extern void proceed_question(void);
 extern void check_plausibility(const char *device);
 extern void parse_journal_opts(const char *opts);
 extern void check_mount(const char *device, int force, const char *type);
-extern int figure_journal_size(int size, ext2_filsys fs);
+extern unsigned int figure_journal_size(int size, ext2_filsys fs);
 extern void print_check_message(ext2_filsys fs);
index 0d6a082..12bdd89 100644 (file)
@@ -383,8 +383,7 @@ retry:
                        ext2fs_mark_block_bitmap(fs->block_map, group_block);
                        adjblocks++;
                }
-               meta_bg_size = (fs->blocksize /
-                               sizeof (struct ext2_group_desc));
+               meta_bg_size = EXT2_DESC_PER_BLOCK(fs->super);
                meta_bg = i / meta_bg_size;
                if (!(fs->super->s_feature_incompat &
                      EXT2_FEATURE_INCOMPAT_META_BG) ||
@@ -550,7 +549,7 @@ static errcode_t mark_table_blocks(ext2_filsys fs,
        unsigned long           meta_bg_size;
        unsigned int            old_desc_blocks;
 
-       meta_bg_size = (fs->blocksize / sizeof (struct ext2_group_desc));
+       meta_bg_size = EXT2_DESC_PER_BLOCK(fs->super);
        if (fs->super->s_feature_incompat & EXT2_FEATURE_INCOMPAT_META_BG)
                old_desc_blocks = fs->super->s_first_meta_bg;
        else
@@ -717,7 +716,7 @@ static errcode_t blocks_to_move(ext2_resize_t rfs)
         * If we're increasing the number of descriptor blocks, life
         * gets interesting....  
         */
-       meta_bg_size = (fs->blocksize / sizeof (struct ext2_group_desc));
+       meta_bg_size = EXT2_DESC_PER_BLOCK(fs->super);
        for (i = 0; i < max_groups; i++) {
                has_super = ext2fs_bg_has_super(fs, i);
                if (has_super)
diff --git a/tests/f_swapfs/debugfs.cmd b/tests/f_swapfs/debugfs.cmd
deleted file mode 100644 (file)
index df583b2..0000000
+++ /dev/null
@@ -1,5 +0,0 @@
-ls
-stat sym
-stat double-indirect-test
-cat fluff
-quit
diff --git a/tests/f_swapfs/expect b/tests/f_swapfs/expect
deleted file mode 100644 (file)
index ecbb990..0000000
+++ /dev/null
@@ -1,133 +0,0 @@
-Swapfs test
-e2fsck -yf -N test_filesys
-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: 25/256 files (0.0% non-contiguous), 418/1024 blocks
-Exit status is 0
-e2fsck -Sy -N test_filesys
-Pass 0: Doing byte-swap of filesystem
-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: 25/256 files (0.0% non-contiguous), 418/1024 blocks
-Exit status is 0
-Running debugfs....
-debugfs: ls
- 2  (12) .    2  (12) ..    11  (20) lost+found    12  (16) fluff   
- 13  (28) indirect-fluff-test    14  (28) double-indirect-test   
- 15  (20) sym    16  (24) long-sym-test    17  (864) dir-test   
-debugfs: stat sym
-Inode: 15   Type: symlink    Mode:  0777   Flags: 0x0   Generation: 1
-User:     0   Group:     0   Size: 5
-File ACL: 0    Directory ACL: 0
-Links: 1   Blockcount: 0
-Fragment:  Address: 0    Number: 0    Size: 0
-ctime: 0x322737e2 -- Fri Aug 30 18:50:10 1996
-atime: 0x322737e2 -- Fri Aug 30 18:50:10 1996
-mtime: 0x322737e2 -- Fri Aug 30 18:50:10 1996
-Fast_link_dest: fluff
-debugfs: stat double-indirect-test
-Inode: 14   Type: regular    Mode:  0644   Flags: 0x0   Generation: 1
-User:     0   Group:     0   Size: 348960
-File ACL: 0    Directory ACL: 0
-Links: 1   Blockcount: 688
-Fragment:  Address: 0    Number: 0    Size: 0
-ctime: 0x322488cf -- Wed Aug 28 17:58:39 1996
-atime: 0x322488cf -- Wed Aug 28 17:58:39 1996
-mtime: 0x322488cf -- Wed Aug 28 17:58:39 1996
-BLOCKS:
-(0-11):70-81, (IND):82, (12-267):83-338, (DIND):339, (IND):340, (268-340):341-413
-TOTAL: 344
-
-debugfs: cat fluff
-yabba dabba doo.  cocka doodle doo.  yabba dabba doo.  cocka doodle doo. yipyip
-yabba dabba doo.  cocka doodle doo.  yabba dabba doo.  cocka doodle doo. yipyip
-yabba dabba doo.  cocka doodle doo.  yabba dabba doo.  cocka doodle doo. yipyip
-yabba dabba doo.  cocka doodle doo.  yabba dabba doo.  cocka doodle doo. yipyip
-yabba dabba doo.  cocka doodle doo.  yabba dabba doo.  cocka doodle doo. yipyip
-yabba dabba doo.  cocka doodle doo.  yabba dabba doo.  cocka doodle doo. yipyip
-yabba dabba doo.  cocka doodle doo.  yabba dabba doo.  cocka doodle doo. yipyip
-yabba dabba doo.  cocka doodle doo.  yabba dabba doo.  cocka doodle doo. yipyip
-yabba dabba doo.  cocka doodle doo.  yabba dabba doo.  cocka doodle doo. yipyip
-yabba dabba doo.  cocka doodle doo.  yabba dabba doo.  cocka doodle doo. yipyip
-yabba dabba doo.  cocka doodle doo.  yabba dabba doo.  cocka doodle doo. yipyip
-yabba dabba doo.  cocka doodle doo.  yabba dabba doo.  cocka doodle doo. yipyip
-yabba dabba doo.  cocka doodle doo.  yabba dabba doo.  cocka doodle doo. yipyip
-
-debugfs: quit
-Exit status is 0
-e2fsck -yf -N test_filesys
-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: 25/256 files (0.0% non-contiguous), 418/1024 blocks
-Exit status is 0
-e2fsck -sy -N test_filesys
-Pass 0: Doing byte-swap of filesystem
-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: 25/256 files (0.0% non-contiguous), 418/1024 blocks
-Exit status is 0
-Running debugfs....
-debugfs: ls
- 2  (12) .    2  (12) ..    11  (20) lost+found    12  (16) fluff   
- 13  (28) indirect-fluff-test    14  (28) double-indirect-test   
- 15  (20) sym    16  (24) long-sym-test    17  (864) dir-test   
-debugfs: stat sym
-Inode: 15   Type: symlink    Mode:  0777   Flags: 0x0   Generation: 1
-User:     0   Group:     0   Size: 5
-File ACL: 0    Directory ACL: 0
-Links: 1   Blockcount: 0
-Fragment:  Address: 0    Number: 0    Size: 0
-ctime: 0x322737e2 -- Fri Aug 30 18:50:10 1996
-atime: 0x322737e2 -- Fri Aug 30 18:50:10 1996
-mtime: 0x322737e2 -- Fri Aug 30 18:50:10 1996
-Fast_link_dest: fluff
-debugfs: stat double-indirect-test
-Inode: 14   Type: regular    Mode:  0644   Flags: 0x0   Generation: 1
-User:     0   Group:     0   Size: 348960
-File ACL: 0    Directory ACL: 0
-Links: 1   Blockcount: 688
-Fragment:  Address: 0    Number: 0    Size: 0
-ctime: 0x322488cf -- Wed Aug 28 17:58:39 1996
-atime: 0x322488cf -- Wed Aug 28 17:58:39 1996
-mtime: 0x322488cf -- Wed Aug 28 17:58:39 1996
-BLOCKS:
-(0-11):70-81, (IND):82, (12-267):83-338, (DIND):339, (IND):340, (268-340):341-413
-TOTAL: 344
-
-debugfs: cat fluff
-yabba dabba doo.  cocka doodle doo.  yabba dabba doo.  cocka doodle doo. yipyip
-yabba dabba doo.  cocka doodle doo.  yabba dabba doo.  cocka doodle doo. yipyip
-yabba dabba doo.  cocka doodle doo.  yabba dabba doo.  cocka doodle doo. yipyip
-yabba dabba doo.  cocka doodle doo.  yabba dabba doo.  cocka doodle doo. yipyip
-yabba dabba doo.  cocka doodle doo.  yabba dabba doo.  cocka doodle doo. yipyip
-yabba dabba doo.  cocka doodle doo.  yabba dabba doo.  cocka doodle doo. yipyip
-yabba dabba doo.  cocka doodle doo.  yabba dabba doo.  cocka doodle doo. yipyip
-yabba dabba doo.  cocka doodle doo.  yabba dabba doo.  cocka doodle doo. yipyip
-yabba dabba doo.  cocka doodle doo.  yabba dabba doo.  cocka doodle doo. yipyip
-yabba dabba doo.  cocka doodle doo.  yabba dabba doo.  cocka doodle doo. yipyip
-yabba dabba doo.  cocka doodle doo.  yabba dabba doo.  cocka doodle doo. yipyip
-yabba dabba doo.  cocka doodle doo.  yabba dabba doo.  cocka doodle doo. yipyip
-yabba dabba doo.  cocka doodle doo.  yabba dabba doo.  cocka doodle doo. yipyip
-
-debugfs: quit
-Exit status is 0
-e2fsck -yf -N test_filesys
-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: 25/256 files (0.0% non-contiguous), 418/1024 blocks
-Exit status is 0
diff --git a/tests/f_swapfs/image b/tests/f_swapfs/image
deleted file mode 100644 (file)
index e7b24b9..0000000
Binary files a/tests/f_swapfs/image and /dev/null differ
diff --git a/tests/f_swapfs/image.gz b/tests/f_swapfs/image.gz
deleted file mode 100644 (file)
index 852231b..0000000
Binary files a/tests/f_swapfs/image.gz and /dev/null differ
diff --git a/tests/f_swapfs/name b/tests/f_swapfs/name
deleted file mode 100644 (file)
index b4520ba..0000000
+++ /dev/null
@@ -1 +0,0 @@
-checking the e2fsck swapfs functionality
diff --git a/tests/f_swapfs/script b/tests/f_swapfs/script
deleted file mode 100644 (file)
index 75f9fb4..0000000
+++ /dev/null
@@ -1,79 +0,0 @@
-if $FSCK -SV > /dev/null 2>&1 ; then
-    IMAGE=$test_dir/image.gz
-    VERIFY_FSCK_OPT=-yf
-    SWAP_FSCK_OPT=-Sy
-    NATIVE_FSCK_OPT=-sy
-    OUT=$test_name.log
-    EXP=$test_dir/expect
-    
-    gunzip < $IMAGE > $TMPFILE
-    
-    echo "Swapfs test" > $OUT
-    
-    echo e2fsck $VERIFY_FSCK_OPT -N test_filesys > $OUT.new
-    $FSCK $VERIFY_FSCK_OPT -N test_filesys $TMPFILE >> $OUT.new 2>&1
-    status=$?
-    echo Exit status is $status >> $OUT.new
-    sed -e '2d' $OUT.new >> $OUT
-    
-    echo e2fsck $SWAP_FSCK_OPT -N test_filesys > $OUT.new
-    $FSCK $SWAP_FSCK_OPT -N test_filesys $TMPFILE >> $OUT.new 2>&1
-    status=$?
-    echo Exit status is $status >> $OUT.new
-    sed -e '2d' $OUT.new >> $OUT
-    
-    echo Running debugfs.... >> $OUT
-    $DEBUGFS -f $test_dir/debugfs.cmd $TMPFILE > $OUT.new 2>&1 
-    status=$?
-    echo Exit status is $status >> $OUT.new
-    sed -e '1d' $OUT.new >> $OUT
-    
-    echo e2fsck $VERIFY_FSCK_OPT -N test_filesys > $OUT.new
-    $FSCK $VERIFY_FSCK_OPT -N test_filesys $TMPFILE >> $OUT.new 2>&1
-    status=$?
-    echo Exit status is $status >> $OUT.new
-    sed -e '2d' $OUT.new >> $OUT
-    
-    echo e2fsck $NATIVE_FSCK_OPT -N test_filesys > $OUT.new
-    $FSCK $NATIVE_FSCK_OPT -N test_filesys $TMPFILE >> $OUT.new 2>&1
-    status=$?
-    echo Exit status is $status >> $OUT.new
-    sed -e '2d' $OUT.new >> $OUT
-    
-    echo Running debugfs.... >> $OUT
-    $DEBUGFS -f $test_dir/debugfs.cmd $TMPFILE > $OUT.new 2>&1 
-    status=$?
-    echo Exit status is $status >> $OUT.new
-    sed -e '1d' $OUT.new >> $OUT
-    
-    echo e2fsck $VERIFY_FSCK_OPT -N test_filesys > $OUT.new
-    $FSCK $VERIFY_FSCK_OPT -N test_filesys $TMPFILE >> $OUT.new 2>&1
-    status=$?
-    echo Exit status is $status >> $OUT.new
-    sed -e '2d' $OUT.new >> $OUT
-    rm -f $OUT.new
-    
-    rm $TMPFILE
-    
-    #
-    # Do the verification
-    #
-    
-    rm -f $test_name.ok $test_name.failed
-    cmp -s $OUT $EXP
-    status=$?
-    
-    if [ "$status" = 0 ] ; then
-           echo "ok"
-           touch $test_name.ok
-    else
-           echo "failed"
-           diff $DIFF_OPTS $EXP $OUT > $test_name.failed
-    fi
-    
-    unset IMAGE VERIFY_FSCK_OPT SWAP_FSCK_OPT NATIVE_FSCK_OPT OUT EXP 
-
-else
-    rm -f $test_name.ok $test_name.failed
-    echo "skipped"
-fi