Whamcloud - gitweb
Many files:
authorTheodore Ts'o <tytso@mit.edu>
Mon, 27 Apr 1998 01:41:13 +0000 (01:41 +0000)
committerTheodore Ts'o <tytso@mit.edu>
Mon, 27 Apr 1998 01:41:13 +0000 (01:41 +0000)
  ext2fs.h, bitops.h: Add support for the Watcom C compiler to do inline
   functions.
  ext2fs.h, dosio.c: Use asm/types.h instead of linux/types.h to evade a
   potential problem with glibc's header files trying to spike out
   linux/types.h.
  ext2fs.h (ext2fs_resize_mem): Change the function prototype to include
   the old size of the memory, which is needed for some braindamaged
   memory allocation systems that don't support realloc().
  badblocks.c (ext2fs_badblocks_list_add):
  bb_inode.c (clear_bad_block_proc):
  dblist.c (ext2fs_add_dir_block):
  icount.c (insert_icount_el):
  irel_ma.c (ima_put):
  rs_bitmap.c (ext2fs_resize_generic_bitmap): Update functions to pass
   the old size of the memory to be resized to ext2fs_resize_mem().
ChangeLog, dirinfo.c:
  dirinfo.c (e2fsck_add_dir_info): Update function to pass the old size
   of the memory to be resized to ext2fs_resize_mem().
ChangeLog, extent.c, resize2fs.c:
  resize2fs.c (adjust_superblock):
  extent.c (ext2fs_add_extent_entry): Update functions to pass the old
   size of the memory to be resized to ext2fs_resize_mem().

15 files changed:
e2fsck/ChangeLog
e2fsck/dirinfo.c
lib/ext2fs/ChangeLog
lib/ext2fs/badblocks.c
lib/ext2fs/bb_inode.c
lib/ext2fs/bitops.h
lib/ext2fs/dblist.c
lib/ext2fs/dosio.c
lib/ext2fs/ext2fs.h
lib/ext2fs/icount.c
lib/ext2fs/irel_ma.c
lib/ext2fs/rs_bitmap.c
resize/ChangeLog
resize/extent.c
resize/resize2fs.c

index 7442f7a..298385e 100644 (file)
@@ -1,3 +1,8 @@
+1998-04-26  Theodore Ts'o  <tytso@rsts-11.mit.edu>
+
+       * dirinfo.c (e2fsck_add_dir_info): Update function to pass the old
+                 size of the memory to be resized to ext2fs_resize_mem().
+
 1998-03-30  Theodore Ts'o  <tytso@rsts-11.mit.edu>
 
        * Makefile.in: Change to use new installation directory variables
index c99b99e..fe8155f 100644 (file)
@@ -18,6 +18,7 @@ void e2fsck_add_dir_info(e2fsck_t ctx, ino_t ino, ino_t parent)
        int             i, j;
        ino_t           num_dirs;
        errcode_t       retval;
+       unsigned long   old_size;
 
 #if 0
        printf("add_dir_info for inode %lu...\n", ino);
@@ -35,8 +36,9 @@ void e2fsck_add_dir_info(e2fsck_t ctx, ino_t ino, ino_t parent)
        }
        
        if (ctx->dir_info_count >= ctx->dir_info_size) {
+               old_size = ctx->dir_info_size * sizeof(struct dir_info);
                ctx->dir_info_size += 10;
-               retval = ext2fs_resize_mem(ctx->dir_info_size *
+               retval = ext2fs_resize_mem(old_size, ctx->dir_info_size *
                                           sizeof(struct dir_info),
                                           (void **) &ctx->dir_info);
                if (retval) {
index 4bc5f21..9fcb3ce 100644 (file)
@@ -1,3 +1,26 @@
+1998-04-26  Theodore Ts'o  <tytso@rsts-11.mit.edu>
+
+       * ext2fs.h, bitops.h: Add support for the Watcom C compiler to do
+               inline functions.
+
+       * ext2fs.h, dosio.c: Use asm/types.h instead of linux/types.h to
+               evade a potential problem with glibc's header files trying
+               to spike out linux/types.h.
+
+       * ext2fs.h (ext2fs_resize_mem): Change the function prototype to
+               include the old size of the memory, which is needed for
+               some braindamaged memory allocation systems that don't
+               support realloc().
+
+       * badblocks.c (ext2fs_badblocks_list_add):
+         bb_inode.c (clear_bad_block_proc):
+         dblist.c (ext2fs_add_dir_block):
+         icount.c (insert_icount_el):
+         irel_ma.c (ima_put):
+         rs_bitmap.c (ext2fs_resize_generic_bitmap): Update functions to
+                 pass the old size of the memory to be resized to
+                 ext2fs_resize_mem(). 
+
 1998-03-30  Theodore Ts'o  <tytso@rsts-11.mit.edu>
 
        * Makefile.in: Change to use new installation directory variables
index 9d43444..3851ccd 100644 (file)
@@ -101,15 +101,19 @@ errcode_t ext2fs_badblocks_list_add(ext2_badblocks_list bb, blk_t blk)
 {
        errcode_t       retval;
        int             i, j;
+       unsigned long   old_size;
 
        EXT2_CHECK_MAGIC(bb, EXT2_ET_MAGIC_BADBLOCKS_LIST);
 
        if (bb->num >= bb->size) {
+               old_size = bb->size * sizeof(blk_t);
                bb->size += 10;
-               retval = ext2fs_resize_mem(bb->size * sizeof(blk_t),
+               retval = ext2fs_resize_mem(old_size, bb->size * sizeof(blk_t),
                                           (void **) &bb->list);
-               if (retval)
+               if (retval) {
+                       bb->size -= 10;
                        return retval;
+               }
        }
 
        j = bb->num;
index 995e3ba..38d1052 100644 (file)
@@ -174,6 +174,7 @@ static int clear_bad_block_proc(ext2_filsys fs, blk_t *block_nr,
                priv_data;
        errcode_t       retval;
        int             group;
+       unsigned long   old_size;
 
        if (!*block_nr)
                return 0;
@@ -189,11 +190,13 @@ static int clear_bad_block_proc(ext2_filsys fs, blk_t *block_nr,
 
        if (blockcnt < 0) {
                if (rec->ind_blocks_size >= rec->max_ind_blocks) {
+                       old_size = rec->max_ind_blocks * sizeof(blk_t);
                        rec->max_ind_blocks += 10;
-                       retval = ext2fs_resize_mem(rec->max_ind_blocks
-                                                  * sizeof(blk_t),
-                                                  (void **) &rec->ind_blocks);
+                       retval = ext2fs_resize_mem(old_size, 
+                                  rec->max_ind_blocks * sizeof(blk_t),
+                                  (void **) &rec->ind_blocks);
                        if (retval) {
+                               rec->max_ind_blocks -= 10;
                                rec->err = retval;
                                return BLOCK_ABORT;
                        }
index a3ea2e7..0361d9b 100644 (file)
@@ -98,7 +98,11 @@ extern void ext2fs_set_bitmap_padding(ext2fs_generic_bitmap map);
 #ifdef INCLUDE_INLINE_FUNCS
 #define _INLINE_ extern
 #else
+#ifdef __GNUC__
 #define _INLINE_ extern __inline__
+#else                          /* For Watcom C */
+#define _INLINE_ extern inline
+#endif
 #endif
 
 #if ((defined __GNUC__) && (defined(__i386__) || defined(__i486__) || \
index 5db0c4f..9683ef1 100644 (file)
@@ -160,12 +160,14 @@ errcode_t ext2fs_add_dir_block(ext2_dblist dblist, ino_t ino, blk_t blk,
 {
        struct ext2_db_entry    *new_entry;
        errcode_t               retval;
+       unsigned long           old_size;
        
        EXT2_CHECK_MAGIC(dblist, EXT2_ET_MAGIC_DBLIST);
 
        if (dblist->count >= dblist->size) {
+               old_size = dblist->size * sizeof(struct ext2_db_entry);
                dblist->size += 100;
-               retval = ext2fs_resize_mem((size_t) dblist->size *
+               retval = ext2fs_resize_mem(old_size, (size_t) dblist->size *
                                           sizeof(struct ext2_db_entry),
                                           (void **) &dblist->list);
                if (retval) {
index c6baddb..a1cbdc2 100644 (file)
@@ -17,7 +17,7 @@
 #include <errno.h>
 #endif
 
-#include <linux/types.h>
+#include <asm/types.h>
 #include "utils.h"
 #include "dosio.h"
 #include "et/com_err.h"
index 43ed653..6c84517 100644 (file)
@@ -15,7 +15,7 @@
 /*
  * Non-GNU C compilers won't necessarily understand inline
  */
-#ifndef __GNUC__
+#if (!defined(__GNUC__) && !defined(__WATCOMC__))
 #define NO_INLINE_FUNCS
 #endif
 
@@ -44,7 +44,7 @@
 #if EXT2_FLAT_INCLUDES
 #include "e2_types.h"
 #else
-#include <linux/types.h>
+#include <asm/types.h>
 #if (defined(__GNUC__) && defined(__STRICT_ANSI__) && ((~0UL) == 0xffffffff))
 typedef __signed__ long long __s64;
 typedef unsigned long long __u64;
@@ -783,7 +783,8 @@ extern int ext2fs_get_library_version(const char **ver_string,
 /* inline functions */
 extern errcode_t ext2fs_get_mem(unsigned long size, void **ptr);
 extern errcode_t ext2fs_free_mem(void **ptr);
-extern errcode_t ext2fs_resize_mem(unsigned long size, void **ptr);
+extern errcode_t ext2fs_resize_mem(unsigned long old_size,
+                                  unsigned long size, void **ptr);
 extern void ext2fs_mark_super_dirty(ext2_filsys fs);
 extern void ext2fs_mark_changed(ext2_filsys fs);
 extern int ext2fs_test_changed(ext2_filsys fs);
@@ -807,7 +808,11 @@ extern int ext2fs_group_of_ino(ext2_filsys fs, ino_t ino);
 #ifdef INCLUDE_INLINE_FUNCS
 #define _INLINE_ extern
 #else
+#ifdef __GNUC__
 #define _INLINE_ extern __inline__
+#else                          /* For Watcom C */
+#define _INLINE_ extern inline
+#endif
 #endif
 
 #ifndef EXT2_CUSTOM_MEMORY_ROUTINES
@@ -835,7 +840,8 @@ _INLINE_ errcode_t ext2fs_free_mem(void **ptr)
 /*
  *  Resize memory
  */
-_INLINE_ errcode_t ext2fs_resize_mem(unsigned long size, void **ptr)
+_INLINE_ errcode_t ext2fs_resize_mem(unsigned long old_size,
+                                    unsigned long size, void **ptr)
 {
        void *p;
 
index 4acb51e..543187c 100644 (file)
@@ -182,7 +182,9 @@ static struct ext2_icount_el *insert_icount_el(ext2_icount_t icount,
 #if 0
                printf("Reallocating icount %d entries...\n", new_size);
 #endif 
-               retval = ext2fs_resize_mem((size_t) new_size *
+               retval = ext2fs_resize_mem((size_t) icount->size *
+                                          sizeof(struct ext2_icount_el),
+                                          (size_t) new_size *
                                           sizeof(struct ext2_icount_el),
                                           (void **) &icount->list);
                if (retval)
index 97ab825..ee5caf1 100644 (file)
@@ -144,7 +144,7 @@ static errcode_t ima_put(ext2_irel irel, ino_t old,
        struct inode_reference_entry    *ref_ent;
        struct irel_ma                  *ma;
        errcode_t                       retval;
-       int                             size;
+       size_t                          size, old_size;
 
        ma = irel->priv_data;
        if (old > ma->max_inode)
@@ -166,7 +166,10 @@ static errcode_t ima_put(ext2_irel irel, ino_t old,
        if (ref_ent->refs && ent->max_refs !=
            ma->entries[(unsigned) old].max_refs) {
                size = (sizeof(struct ext2_inode_reference) * ent->max_refs);
-               retval = ext2fs_resize_mem(size, (void **) &ref_ent->refs);
+               old_size = (sizeof(struct ext2_inode_reference) *
+                           ma->entries[(unsigned) old].max_refs);
+               retval = ext2fs_resize_mem(old_size, size,
+                                          (void **) &ref_ent->refs);
                if (retval)
                        return retval;
        }
index 193039a..240994f 100644 (file)
@@ -62,9 +62,12 @@ errcode_t ext2fs_resize_generic_bitmap(__u32 new_end, __u32 new_real_end,
        size = ((bmap->real_end - bmap->start) / 8) + 1;
        new_size = ((new_real_end - bmap->start) / 8) + 1;
 
-       retval = ext2fs_resize_mem(new_size, (void **) &bmap->bitmap);
-       if (retval)
-               return retval;
+       if (size != new_size) {
+               retval = ext2fs_resize_mem(size, new_size,
+                                          (void **) &bmap->bitmap);
+               if (retval)
+                       return retval;
+       }
        if (new_size > size)
                memset(bmap->bitmap + size, 0, new_size - size);
 
index fea200e..4b85202 100644 (file)
@@ -1,3 +1,10 @@
+1998-04-26  Theodore Ts'o  <tytso@rsts-11.mit.edu>
+
+       * resize2fs.c (adjust_superblock): 
+       * extent.c (ext2fs_add_extent_entry): Update functions to
+                 pass the old size of the memory to be resized to
+                 ext2fs_resize_mem(). 
+
 1998-03-30  Theodore Ts'o  <tytso@rsts-11.mit.edu>
 
        * Makefile.in: Change to use new installation directory variables
index 56fb62a..b583baa 100644 (file)
@@ -84,6 +84,8 @@ errcode_t ext2fs_add_extent_entry(ext2_extent extent, __u32 old_loc, __u32 new_l
        if (extent->num >= extent->size) {
                newsize = extent->size + 100;
                retval = ext2fs_resize_mem(sizeof(struct ext2_extent_entry) * 
+                                          extent->size, 
+                                          sizeof(struct ext2_extent_entry) * 
                                           newsize, (void **) &extent->list);
                if (retval)
                        return retval;
index 4d85969..1818e02 100644 (file)
@@ -261,7 +261,9 @@ retry:
         * Reallocate the group descriptors as necessary.
         */
        if (rfs->old_fs->desc_blocks != fs->desc_blocks) {
-               retval = ext2fs_resize_mem(fs->desc_blocks * fs->blocksize,
+               retval = ext2fs_resize_mem(rfs->old_fs->desc_blocks *
+                                          fs->blocksize,
+                                          fs->desc_blocks * fs->blocksize,
                                           (void **) &fs->group_desc);
                if (retval)
                        goto errout;