diff options
author | Theodore Ts'o <tytso@mit.edu> | 1998-04-27 01:41:13 +0000 |
---|---|---|
committer | Theodore Ts'o <tytso@mit.edu> | 1998-04-27 01:41:13 +0000 |
commit | 76f875daa1c9c2cdc72f0c6f0f7be4bbc7f0fc07 (patch) | |
tree | 6fe26cebc11c665c56419240799c179706995c9d /lib | |
parent | 91b2c42bdbb91275026f08306720b2bef6e129f4 (diff) | |
download | e2fsprogs-76f875daa1c9c2cdc72f0c6f0f7be4bbc7f0fc07.tar.gz |
Many files:
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().
Diffstat (limited to 'lib')
-rw-r--r-- | lib/ext2fs/ChangeLog | 23 | ||||
-rw-r--r-- | lib/ext2fs/badblocks.c | 8 | ||||
-rw-r--r-- | lib/ext2fs/bb_inode.c | 9 | ||||
-rw-r--r-- | lib/ext2fs/bitops.h | 4 | ||||
-rw-r--r-- | lib/ext2fs/dblist.c | 4 | ||||
-rw-r--r-- | lib/ext2fs/dosio.c | 2 | ||||
-rw-r--r-- | lib/ext2fs/ext2fs.h | 14 | ||||
-rw-r--r-- | lib/ext2fs/icount.c | 4 | ||||
-rw-r--r-- | lib/ext2fs/irel_ma.c | 7 | ||||
-rw-r--r-- | lib/ext2fs/rs_bitmap.c | 9 |
10 files changed, 67 insertions, 17 deletions
diff --git a/lib/ext2fs/ChangeLog b/lib/ext2fs/ChangeLog index 4bc5f213..9fcb3ce2 100644 --- a/lib/ext2fs/ChangeLog +++ b/lib/ext2fs/ChangeLog @@ -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 diff --git a/lib/ext2fs/badblocks.c b/lib/ext2fs/badblocks.c index 9d43444a..3851ccd6 100644 --- a/lib/ext2fs/badblocks.c +++ b/lib/ext2fs/badblocks.c @@ -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; diff --git a/lib/ext2fs/bb_inode.c b/lib/ext2fs/bb_inode.c index 995e3baa..38d10526 100644 --- a/lib/ext2fs/bb_inode.c +++ b/lib/ext2fs/bb_inode.c @@ -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; } diff --git a/lib/ext2fs/bitops.h b/lib/ext2fs/bitops.h index a3ea2e71..0361d9bd 100644 --- a/lib/ext2fs/bitops.h +++ b/lib/ext2fs/bitops.h @@ -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__) || \ diff --git a/lib/ext2fs/dblist.c b/lib/ext2fs/dblist.c index 5db0c4f0..9683ef10 100644 --- a/lib/ext2fs/dblist.c +++ b/lib/ext2fs/dblist.c @@ -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) { diff --git a/lib/ext2fs/dosio.c b/lib/ext2fs/dosio.c index c6baddb8..a1cbdc2c 100644 --- a/lib/ext2fs/dosio.c +++ b/lib/ext2fs/dosio.c @@ -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" diff --git a/lib/ext2fs/ext2fs.h b/lib/ext2fs/ext2fs.h index 43ed653c..6c845170 100644 --- a/lib/ext2fs/ext2fs.h +++ b/lib/ext2fs/ext2fs.h @@ -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; diff --git a/lib/ext2fs/icount.c b/lib/ext2fs/icount.c index 4acb51ed..543187cd 100644 --- a/lib/ext2fs/icount.c +++ b/lib/ext2fs/icount.c @@ -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) diff --git a/lib/ext2fs/irel_ma.c b/lib/ext2fs/irel_ma.c index 97ab8259..ee5caf11 100644 --- a/lib/ext2fs/irel_ma.c +++ b/lib/ext2fs/irel_ma.c @@ -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; } diff --git a/lib/ext2fs/rs_bitmap.c b/lib/ext2fs/rs_bitmap.c index 193039a6..240994fe 100644 --- a/lib/ext2fs/rs_bitmap.c +++ b/lib/ext2fs/rs_bitmap.c @@ -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); |