From: Theodore Ts'o Date: Tue, 29 Apr 1997 17:32:42 +0000 (+0000) Subject: Many files: X-Git-Tag: E2FSPROGS-1_09~4 X-Git-Url: https://git.whamcloud.com/?a=commitdiff_plain;h=7fd86d2d5c8ecb51b973ab230a4d07a0d9da3fd6;p=tools%2Fe2fsprogs.git Many files: Files which shouldn't be here. --- diff --git a/relocate/Makefile.in b/relocate/Makefile.in deleted file mode 100644 index 01cfcf2..0000000 --- a/relocate/Makefile.in +++ /dev/null @@ -1,34 +0,0 @@ -# -# Relocation e2fsprogs prologue.... -# - -srcdir = @srcdir@ -top_srcdir = @top_srcdir@ -VPATH = @srcdir@ -top_builddir = .. -my_dir = relocate -INSTALL = @INSTALL@ - -@MCONFIG@ - -SRCS= $(srcdir)/resize2fs.c - -LIBS= $(LIBEXT2FS) $(LIBCOM_ERR) -DEPLIBS= $(LIBEXT2FS) $(LIBCOM_ERR) - -STATIC_LIBS= $(STATIC_LIBEXT2FS) $(STATIC_LIBCOM_ERR) -STATIC_DEPLIBS= $(STATIC_LIBEXT2FS) $(STATIC_LIBCOM_ERR) - -LIBS_E2P= $(LIBEXT2FS) $(LIBE2P) $(LIBCOM_ERR) -DEPLIBS_E2P= $(LIBEXT2FS) $(LIBE2P) $(LIBCOM_ERR) - -.c.o: - $(CC) -c $(ALL_CFLAGS) $< -o $@ - -all:: resize2fs - -resize2fs: resize2fs.o $(DEPLIBS) - $(CC) $(ALL_LDFLAGS) -o resize2fs resize2fs.o $(LIBS) - -clean:: - $(RM) -f resize2fs \#* *.s *.o *.a *~ core diff --git a/relocate/README b/relocate/README deleted file mode 100644 index 9c32d80..0000000 --- a/relocate/README +++ /dev/null @@ -1 +0,0 @@ -This directory is under construction still.... diff --git a/relocate/relocate.c b/relocate/relocate.c deleted file mode 100644 index 3ea47c0..0000000 --- a/relocate/relocate.c +++ /dev/null @@ -1,159 +0,0 @@ -/* - * relocate.c --- maintains the relocation table - * - * Copyright (C) 1996 Theodore Ts'o. This file may be redistributed - * under the terms of the GNU Public License. - */ - -#include - -/* - * This routine creates a relocation table - */ -errcode_t ext2fs_create_relocation_table(__u32 max, int size, - ext2_relocate_table *ret); -{ - ext2_relocate_table table; - - table = malloc(sizeof(struct ext2_relocate_struct)); - if (!table) - return -ENOMEM; - table->magic = 0; - table->count = 0; - table->size = size ? size : 30; - table->max = max; - table->entries = malloc(table->size * sizeof(ext2_relocate_entry)); - if (table->entries == 0) { - free(table); - return ENOMEM; - } - memset(table->entries, 0, table->size * sizeof(ext2_relocate_entry)); - *ret = table; - return 0; -} - -/* - * Free a relocation table - */ -void ext2fs_free_relocation_table(ext2_relocate_table table) -{ - free(table->entries); - table->count = 0; - table->size = 0; - table->magic = 0; - free(table); -} - -/* - * Add a relocation table entry - */ -errcode_t ext2fs_add_relocation(ext2_relocate_table table, __u32 old, - __u32 new, __u32 owner) -{ - struct ext2_relocate_entry *new; - - if (table->count >= table->size) { - table->size += 30; - new = realloc(table->entries, - table->size * sizeof(ext2_relocate_entry)); - if (!new) - return ENOMEM; - table->entries = new; - } - if (table->count && table->entries[table->count-1].old > old) { - for (i = table->count-1; i > 0; i--) - if (table->entries[i-1].old < old) - break; - new = &table->entries[i]; - if (new->old != old) - for (j = table->count++; j > i; j--) - table->entries[j] = table_entries[j-1]; - } else - new = &table->entries[table->coun++]; - - new->old = old; - new->new = new; - new->owner = owner; -} - -/* - * ext2fs_get_reloc_by_old() --- given the source of the relcation - * entry, find the entry for it. - */ -struct relocate_entry *ext2fs_get_reloc_by_old(ext2_relocate_table tbl, - __u32 old) -{ - int low, high, mid; - int i, j; - - low = 0; - high = tbl->count-1; - if (old == table->entries[low].old) - return &table->entries[low]; - if (old == table->entries[high].old) - return &table->entries[high]; - - while (low < high) { - mid = (low+high)/2; - if (mid == low || mid == high) - break; - if (old == table->entries[mid].old) - return &table->entries[mid]; - if (old < table->entries[mid].old) - high = mid; - else - low = mid; - } - return 0; -} - -/* - * ext2fs_get_reloc_by_new() --- given the destination of the relcation - * entry, find the entry for it. - * - * Note: this is currently very slow... - */ -struct relocate_entry *ext2fs_get_reloc_by_new(ext2_relocate_table tbl, - __u32 new) -{ - int i; - - for (i = 0; i < table->count; i++) { - if (tbl->entries[i].new == new) - return &table->entries[i]; - } - return 0; -} - -/* - * Find "loops" in the relocation tables - */ -{ - int i; - struct ext2_relocate_entry *ent, *next; - - - for (i=0, ent=table->entries; i < table->size; i++, ent++) { - /* - * If we know this inode is OK, then keep going. - */ - if (ext2fs_test_generic_bitmap(done_map, dir->old)) - continue; - ext2fs_clear_generic_bitmap(loop_detect); - while (1) { - ext2fs_mark_generic_bitmap(loop_detect, dir->old); - next = ext2fs_get_reloc_by_old(table, dir->new); - if (next == NULL) - break; - if (ext2fs_test_generic_bitmap(loop_detect, - dir->new)) - break_loop(table, dir); - ext2fs_mark_generic_bitmap(done_map, dir->old); - dir = next; - } - } -} - - - - diff --git a/relocate/relocate.h b/relocate/relocate.h deleted file mode 100644 index f1eec6d..0000000 --- a/relocate/relocate.h +++ /dev/null @@ -1,21 +0,0 @@ -/* - * relocate.h - * - * Copyright (C) 1996 Theodore Ts'o. This file may be redistributed - * under the terms of the GNU Public License. - */ - -struct ext2_relocate_entry { - __u32 new, old; - __u32 owner; -} - -struct ext2_relocate_struct { - int magic; - int count; - int size; - int max; - struct ext2_relocate_entry *entries; -}; - -typedef struct ext2_relocate_struct *ext2_relocate_table; diff --git a/relocate/resize2fs.c b/relocate/resize2fs.c deleted file mode 100644 index f5b5f24..0000000 --- a/relocate/resize2fs.c +++ /dev/null @@ -1,175 +0,0 @@ -/* - * resize2fs.c - Resize the ext2 filesystem. - * - * Copyright (C) 1996 Theodore Ts'o - * - * This file can be redistributed under the terms of the GNU General - * Public License - */ - -#ifdef HAVE_GETOPT_H -#include -#endif -#include -#include -#include -#include -#include - -#include - -#include "ext2fs/ext2fs.h" - -#include "../version.h" - -const char * program_name = "resize2fs"; -char * device_name = NULL; - -static volatile void usage (void) -{ - fprintf (stderr, "usage: %s device\n", program_name); - exit (1); -} - -errcode_t ext2fs_resize_inode_bitmap(ext2_filsys fs, - ext2fs_inode_bitmap ibmap) -{ - ino_t new_end, new_real_end; - size_t size, new_size; - char *new_bitmap, *old_bitmap; - - EXT2_CHECK_MAGIC(fs, EXT2_ET_MAGIC_EXT2FS_FILSYS); - EXT2_CHECK_MAGIC(ibmap, EXT2_ET_MAGIC_INODE_BITMAP); - - new_end = fs->super->s_inodes_count; - new_real_end = (EXT2_INODES_PER_GROUP(fs->super) - * fs->group_desc_count); - - if (new_real_end == ibmap->real_end) { - ibmap->end = new_end; - return 0; - } - - size = ((ibmap->real_end - ibmap->start) / 8) + 1; - new_size = ((new_real_end - ibmap->start) / 8) + 1; - - new_bitmap = malloc(size); - if (!new_bitmap) - return ENOMEM; - if (size > new_size) - size = new_size; - memcpy(new_bitmap, ibmap->bitmap, size); - if (new_size > size) - memset(new_bitmap + size, 0, new_size - size); - - old_bitmap = ibmap->bitmap; - ibmap->bitmap = new_bitmap; - free(old_bitmap); - ibmap->end = new_end; - ibmap->real_end = new_real_end; -} - -errcode_t ext2fs_resize_block_bitmap(ext2_filsys fs, - ext2fs_inode_bitmap bbmap) -{ - ino_t new_end, new_real_end; - size_t size, new_size; - char *new_bitmap, *old_bitmap; - - EXT2_CHECK_MAGIC(fs, EXT2_ET_MAGIC_EXT2FS_FILSYS); - EXT2_CHECK_MAGIC(bbmap, EXT2_ET_MAGIC_BLOCK_BITMAP); - - new_end = fs->super->s_inodes_count; - new_real_end = (EXT2_INODES_PER_GROUP(fs->super) - * fs->group_desc_count); - - if (new_real_end == bbmap->real_end) { - bbmap->end = new_end; - return 0; - } - - size = ((bbmap->real_end - bbmap->start) / 8) + 1; - new_size = ((new_real_end - bbmap->start) / 8) + 1; - - new_bitmap = malloc(size); - if (!new_bitmap) - return ENOMEM; - if (size > new_size) - size = new_size; - memcpy(new_bitmap, bbmap->bitmap, size); - if (new_size > size) - memset(new_bitmap + size, 0, new_size - size); - - old_bitmap = bbmap->bitmap; - bbmap->bitmap = new_bitmap; - free(old_bitmap); - bbmap->end = new_end; - bbmap->real_end = new_real_end; -} - - - -errcode_t ext2fs_resize(ext2_filsys fs, blk_t new_size) -{ - __u32 new_block_groups, new_desc_blocks; - - if (new_size = fs->super->s_blocks_count) - return 0; - - new_block_groups = (fs->super->s_blocks_count - - fs->super->s_first_data_block + - EXT2_BLOCKS_PER_GROUP(fs->super) - 1) - / EXT2_BLOCKS_PER_GROUP(fs->super); - if (new_block_groups == 0) - return EXT2_ET_TOOSMALL; - new_desc_blocks = (new_block_groups + - EXT2_DESC_PER_BLOCK(fs->super) - 1) - / EXT2_DESC_PER_BLOCK(fs->super); - -} - - - -void main (int argc, char ** argv) -{ - errcode_t retval; - ext2_filsys fs; - int c; - - fprintf (stderr, "resize2fs %s, %s for EXT2 FS %s, %s\n", - E2FSPROGS_VERSION, E2FSPROGS_DATE, - EXT2FS_VERSION, EXT2FS_DATE); - if (argc && *argv) - program_name = *argv; - - while ((c = getopt (argc, argv, "h")) != EOF) { - switch (c) { - case 'h': - usage(); - break; - default: - usage (); - } - } - if (optind > argc - 1) - usage (); - device_name = argv[optind++]; - initialize_ext2_error_table(); - retval = ext2fs_open (device_name, EXT2_FLAG_RW, 0, 0, - unix_io_manager, &fs); - if (retval) { - com_err (program_name, retval, "while trying to open %s", - device_name); - printf ("Couldn't find valid filesystem superblock.\n"); - exit (1); - } - retval = ext2fs_read_bitmaps (fs); - if (retval) { - com_err (program_name, retval, - "while trying to read the bitmaps", device_name); - ext2fs_close (fs); - exit (1); - } - ext2fs_close (fs); - exit (0); -}