diff options
author | Theodore Ts'o <tytso@mit.edu> | 1997-04-29 21:26:48 +0000 |
---|---|---|
committer | Theodore Ts'o <tytso@mit.edu> | 1997-04-29 21:26:48 +0000 |
commit | a29f4d30f24d68f1f1c75548e020689ede532c05 (patch) | |
tree | f74e57c6188bc586c912a79da833236ad28f7233 /lib/ext2fs | |
parent | ae85148246952016865e2792b49d6b68649b6063 (diff) | |
download | e2fsprogs-a29f4d30f24d68f1f1c75548e020689ede532c05.tar.gz |
Many files:
Checkin of e2fsprogs 1.10
Diffstat (limited to 'lib/ext2fs')
-rw-r--r-- | lib/ext2fs/ChangeLog | 81 | ||||
-rw-r--r-- | lib/ext2fs/Makefile.in | 185 | ||||
-rw-r--r-- | lib/ext2fs/alloc.c | 7 | ||||
-rw-r--r-- | lib/ext2fs/alloc_tables.c | 13 | ||||
-rw-r--r-- | lib/ext2fs/badblocks.c | 38 | ||||
-rw-r--r-- | lib/ext2fs/bitmaps.c | 39 | ||||
-rw-r--r-- | lib/ext2fs/block.c | 26 | ||||
-rw-r--r-- | lib/ext2fs/closefs.c | 30 | ||||
-rw-r--r-- | lib/ext2fs/dblist.c | 71 | ||||
-rw-r--r-- | lib/ext2fs/dll/jump.funcs | 8 | ||||
-rw-r--r-- | lib/ext2fs/dll/jump.params | 2 | ||||
-rw-r--r-- | lib/ext2fs/dupfs.c | 93 | ||||
-rw-r--r-- | lib/ext2fs/ext2fs.h | 48 | ||||
-rw-r--r-- | lib/ext2fs/ext2fsP.h | 16 | ||||
-rw-r--r-- | lib/ext2fs/freefs.c | 53 | ||||
-rw-r--r-- | lib/ext2fs/initialize.c | 16 | ||||
-rw-r--r-- | lib/ext2fs/inode.c | 149 | ||||
-rw-r--r-- | lib/ext2fs/io.h | 4 | ||||
-rw-r--r-- | lib/ext2fs/test_io.c | 4 | ||||
-rw-r--r-- | lib/ext2fs/unix_io.c | 4 |
20 files changed, 615 insertions, 272 deletions
diff --git a/lib/ext2fs/ChangeLog b/lib/ext2fs/ChangeLog index a30b2ba9..d48c3059 100644 --- a/lib/ext2fs/ChangeLog +++ b/lib/ext2fs/ChangeLog @@ -1,3 +1,84 @@ +Thu Apr 24 12:16:42 1997 Theodre Ts'o <tytso@localhost.mit.edu> + + * Release of E2fsprogs version 1.10 + +Thu Apr 24 10:13:42 1997 Theodre Ts'o <tytso@localhost.mit.edu> + + * alloc_tables.c (ext2fs_allocate_tables): Correctly place the + inode and block bitmaps based on the RAID 0 stride + parameter (which is passed by mke2fs). + + * ext2fs.h: Add "stride" parameter to ext2_filsys, to be used by + mke2fs to communicate the stride length to + ext2fs_allocate_tables() + +Wed Apr 23 21:50:42 1997 Theodre Ts'o <tytso@localhost.mit.edu> + + * initialize.c (ext2fs_initialize): Fix to compile under Linux 1.2 + systems. (We can't assume that the new filesystem types + are supported.) + +Wed Apr 23 18:40:53 1997 Theodore Ts'o <tytso@rsts-11.mit.edu> + + * alloc_tables.c (ext2fs_allocate_tables): Make sure that we + allocate the inode and block bitmaps inside block group at + all times. + +Mon Apr 21 00:06:28 1997 Theodore Ts'o <tytso@rsts-11.mit.edu> + + * alloc.c (ext2fs_new_block): Fix bug where if goal==0 and the + filesystem has no free blocks, ext2fs_new_block would loop + forever. + + * dupfs.c (ext2fs_dup_handle): Duplicate an ext2 filesystem handle + + * freefs.c (ext2fs_free_inode_cache): Decrement refcount and only + free if refcount goes to zero. + + * inode.c (create_icache): Initialize refcount to 1. + + * ext2fsP.h: Added refcount to ext2_inode_cache + + * dblist.c (ext2fs_copy_dblist): New function to copy a directory + block list. + + * badblocks.c (ext2fs_badblocks_copy): New function to copy a + badblocks structure. + +Sun Apr 20 23:19:51 1997 Theodore Ts'o <tytso@rsts-11.mit.edu> + + * bitmaps.c (ext2fs_copy_bitmap): New function to copy a bitmap. + + * unix_io.c, test_io.c (unix_open, test_open): Initialize the + refcount to 1. + (unix_close, test_close): Decrement the refcount and only + close the io_channel if the refcount goes to 0. + + * io.h: Add refcount to the io_channel structure. Add new macro + interface io_channel_bumpcount() to bump the refcount. + +Thu Apr 17 20:25:03 1997 Theodore Ts'o <tytso@rsts-11.mit.edu> + + * inode.c (ext2fs_read_inode, ext2fs_write_inode): Use the inode + cache in the filesystem handle, instead of the inode cache + in a static variable. + + * freefs.c: Added static function to free the inode cache (called by + ext2fs_free). + + * ext2fsP.h: Added definition of the ext2_inode_cache structures. + + * ext2fs.h: Added pointer to the inode_cache structure. + + * block.c (block_iterate_ind, block_iterate_dind, + block_iterate_tind): If there are holes in the indirect, + doubly indirect, or triply indirect blocks, increment the + block count field automatically. + +Thu Apr 17 12:23:38 1997 Theodore Ts'o <tytso@rsts-11.mit.edu> + + * Release of E2fsprogs version 1.09 + Mon Apr 14 20:38:56 1997 Theodore Ts'o <tytso@rsts-11.mit.edu> * version.c (ext2fs_parse_version_string): Check the passed in diff --git a/lib/ext2fs/Makefile.in b/lib/ext2fs/Makefile.in index 348d6221..4e220c60 100644 --- a/lib/ext2fs/Makefile.in +++ b/lib/ext2fs/Makefile.in @@ -24,6 +24,7 @@ OBJS= ext2_err.o \ dblist_dir.o \ dirblock.o \ dir_iterate.o \ + dupfs.o \ expanddir.o \ freefs.o \ get_pathname.o \ @@ -70,6 +71,7 @@ SRCS= ext2_err.c \ $(srcdir)/dblist_dir.c \ $(srcdir)/dirblock.c \ $(srcdir)/dir_iterate.c \ + $(srcdir)/dupfs.c \ $(srcdir)/expanddir.c \ $(srcdir)/freefs.c \ $(srcdir)/get_pathname.c \ @@ -197,155 +199,132 @@ distclean:: clean # the Makefile.in file # ext2_err.o: ext2_err.c -alloc.o: $(srcdir)/alloc.c \ - $(srcdir)/ext2fs.h $(top_srcdir)/lib/et/com_err.h \ - $(srcdir)/io.h $(top_builddir)/lib/ext2fs/ext2_err.h \ - $(srcdir)/bitops.h +alloc.o: $(srcdir)/alloc.c $(srcdir)/ext2fs.h \ + $(top_srcdir)/lib/et/com_err.h $(srcdir)/io.h \ + $(top_builddir)/lib/ext2fs/ext2_err.h $(srcdir)/bitops.h alloc_tables.o: $(srcdir)/alloc_tables.c $(srcdir)/ext2fs.h \ - $(top_srcdir)/lib/et/com_err.h \ - $(srcdir)/io.h $(top_builddir)/lib/ext2fs/ext2_err.h \ - $(srcdir)/bitops.h -badblocks.o: $(srcdir)/badblocks.c $(srcdir)/ext2fsP.h \ - $(srcdir)/ext2fs.h $(top_srcdir)/lib/et/com_err.h \ - $(srcdir)/io.h $(top_builddir)/lib/ext2fs/ext2_err.h \ - $(srcdir)/bitops.h -bb_compat.o: $(srcdir)/bb_compat.c $(srcdir)/ext2fsP.h \ - $(srcdir)/ext2fs.h $(top_srcdir)/lib/et/com_err.h \ - $(srcdir)/io.h $(top_builddir)/lib/ext2fs/ext2_err.h \ - $(srcdir)/bitops.h + $(top_srcdir)/lib/et/com_err.h $(srcdir)/bitops.h \ + $(srcdir)/io.h $(top_builddir)/lib/ext2fs/ext2_err.h +badblocks.o: $(srcdir)/badblocks.c $(srcdir)/ext2fsP.h $(srcdir)/ext2fs.h \ + $(top_srcdir)/lib/et/com_err.h $(srcdir)/io.h $(srcdir)/bitops.h \ + $(top_builddir)/lib/ext2fs/ext2_err.h +bb_compat.o: $(srcdir)/bb_compat.c $(srcdir)/ext2fsP.h $(srcdir)/ext2fs.h \ + $(top_srcdir)/lib/et/com_err.h $(srcdir)/bitops.h \ + $(srcdir)/io.h $(top_builddir)/lib/ext2fs/ext2_err.h bb_inode.o: $(srcdir)/bb_inode.c $(srcdir)/ext2fs.h \ - $(top_srcdir)/lib/et/com_err.h \ - $(srcdir)/io.h $(top_builddir)/lib/ext2fs/ext2_err.h \ - $(srcdir)/bitops.h + $(top_srcdir)/lib/et/com_err.h $(srcdir)/bitops.h \ + $(srcdir)/io.h $(top_builddir)/lib/ext2fs/ext2_err.h bitmaps.o: $(srcdir)/bitmaps.c $(srcdir)/ext2fs.h \ - $(top_srcdir)/lib/et/com_err.h \ - $(srcdir)/io.h $(top_builddir)/lib/ext2fs/ext2_err.h \ - $(srcdir)/bitops.h + $(top_srcdir)/lib/et/com_err.h $(srcdir)/bitops.h \ + $(srcdir)/io.h $(top_builddir)/lib/ext2fs/ext2_err.h bitops.o: $(srcdir)/bitops.c $(srcdir)/ext2fs.h \ - $(top_srcdir)/lib/et/com_err.h $(srcdir)/io.h \ - $(top_builddir)/lib/ext2fs/ext2_err.h $(srcdir)/bitops.h -block.o: $(srcdir)/block.c $(srcdir)/ext2fs.h \ - $(top_srcdir)/lib/et/com_err.h \ - $(srcdir)/io.h $(top_builddir)/lib/ext2fs/ext2_err.h \ - $(srcdir)/bitops.h + $(top_srcdir)/lib/et/com_err.h $(srcdir)/bitops.h \ + $(srcdir)/io.h $(top_builddir)/lib/ext2fs/ext2_err.h +block.o: $(srcdir)/block.c $(srcdir)/ext2fs.h $(top_srcdir)/lib/et/com_err.h \ + $(srcdir)/io.h $(top_builddir)/lib/ext2fs/ext2_err.h $(srcdir)/bitops.h brel_ma.o: $(srcdir)/brel_ma.c $(srcdir)/ext2fs.h \ - $(top_srcdir)/lib/et/com_err.h $(srcdir)/io.h \ - $(top_builddir)/lib/ext2fs/ext2_err.h $(srcdir)/bitops.h $(srcdir)/brel.h + $(top_srcdir)/lib/et/com_err.h $(srcdir)/io.h $(srcdir)/bitops.h \ + $(srcdir)/brel.h $(top_builddir)/lib/ext2fs/ext2_err.h check_desc.o: $(srcdir)/check_desc.c $(srcdir)/ext2fs.h \ - $(top_srcdir)/lib/et/com_err.h \ - $(srcdir)/io.h $(top_builddir)/lib/ext2fs/ext2_err.h \ - $(srcdir)/bitops.h -closefs.o: $(srcdir)/closefs.c $(srcdir)/ext2fsP.h \ - $(srcdir)/ext2fs.h $(top_srcdir)/lib/et/com_err.h \ - $(srcdir)/io.h $(top_builddir)/lib/ext2fs/ext2_err.h \ - $(srcdir)/bitops.h + $(top_srcdir)/lib/et/com_err.h $(srcdir)/bitops.h \ + $(srcdir)/io.h $(top_builddir)/lib/ext2fs/ext2_err.h +closefs.o: $(srcdir)/closefs.c $(srcdir)/ext2fsP.h $(srcdir)/ext2fs.h \ + $(top_srcdir)/lib/et/com_err.h $(srcdir)/bitops.h \ + $(srcdir)/io.h $(top_builddir)/lib/ext2fs/ext2_err.h cmp_bitmaps.o: $(srcdir)/cmp_bitmaps.c $(srcdir)/ext2fs.h \ - $(top_srcdir)/lib/et/com_err.h \ - $(srcdir)/io.h $(top_builddir)/lib/ext2fs/ext2_err.h \ - $(srcdir)/bitops.h -dblist.o: $(srcdir)/dblist.c $(srcdir)/ext2fsP.h \ - $(srcdir)/ext2fs.h $(top_srcdir)/lib/et/com_err.h \ - $(srcdir)/io.h $(top_builddir)/lib/ext2fs/ext2_err.h \ - $(srcdir)/bitops.h -dblist_dir.o: $(srcdir)/dblist_dir.c $(srcdir)/ext2fsP.h \ - $(srcdir)/ext2fs.h $(top_srcdir)/lib/et/com_err.h \ - $(srcdir)/io.h $(top_builddir)/lib/ext2fs/ext2_err.h \ - $(srcdir)/bitops.h + $(top_srcdir)/lib/et/com_err.h $(srcdir)/io.h \ + $(top_builddir)/lib/ext2fs/ext2_err.h $(srcdir)/bitops.h +dblist.o: $(srcdir)/dblist.c $(srcdir)/ext2fsP.h $(srcdir)/ext2fs.h \ + $(top_srcdir)/lib/et/com_err.h $(srcdir)/io.h $(srcdir)/bitops.h \ + $(top_builddir)/lib/ext2fs/ext2_err.h +dblist_dir.o: $(srcdir)/dblist_dir.c $(srcdir)/ext2fsP.h $(srcdir)/ext2fs.h \ + $(top_srcdir)/lib/et/com_err.h $(srcdir)/io.h $(srcdir)/bitops.h \ + $(top_builddir)/lib/ext2fs/ext2_err.h dirblock.o: $(srcdir)/dirblock.c $(srcdir)/ext2fs.h \ - $(top_srcdir)/lib/et/com_err.h \ - $(srcdir)/io.h $(top_builddir)/lib/ext2fs/ext2_err.h \ - $(srcdir)/bitops.h + $(top_srcdir)/lib/et/com_err.h $(srcdir)/io.h \ + $(top_builddir)/lib/ext2fs/ext2_err.h $(srcdir)/bitops.h dir_iterate.o: $(srcdir)/dir_iterate.c $(srcdir)/ext2fsP.h \ $(srcdir)/ext2fs.h $(top_srcdir)/lib/et/com_err.h \ - $(srcdir)/io.h $(top_builddir)/lib/ext2fs/ext2_err.h \ - $(srcdir)/bitops.h + $(srcdir)/io.h $(top_builddir)/lib/ext2fs/ext2_err.h $(srcdir)/bitops.h +dupfs.o: $(srcdir)/dupfs.c $(srcdir)/ext2fsP.h $(srcdir)/ext2fs.h \ + $(top_srcdir)/lib/et/com_err.h $(srcdir)/io.h \ + $(top_builddir)/lib/ext2fs/ext2_err.h $(srcdir)/bitops.h expanddir.o: $(srcdir)/expanddir.c $(srcdir)/ext2fs.h \ - $(top_srcdir)/lib/et/com_err.h \ - $(srcdir)/io.h $(top_builddir)/lib/ext2fs/ext2_err.h \ - $(srcdir)/bitops.h -freefs.o: $(srcdir)/freefs.c $(srcdir)/ext2fs.h \ $(top_srcdir)/lib/et/com_err.h $(srcdir)/io.h \ $(top_builddir)/lib/ext2fs/ext2_err.h $(srcdir)/bitops.h -get_pathname.o: $(srcdir)/get_pathname.c $(srcdir)/ext2fs.h \ +freefs.o: $(srcdir)/freefs.c $(srcdir)/ext2fsP.h $(srcdir)/ext2fs.h \ $(top_srcdir)/lib/et/com_err.h \ $(srcdir)/io.h $(top_builddir)/lib/ext2fs/ext2_err.h $(srcdir)/bitops.h +get_pathname.o: $(srcdir)/get_pathname.c $(srcdir)/ext2fs.h \ + $(top_srcdir)/lib/et/com_err.h $(srcdir)/io.h \ + $(top_builddir)/lib/ext2fs/ext2_err.h $(srcdir)/bitops.h getsize.o: $(srcdir)/getsize.c $(srcdir)/ext2fs.h \ - $(top_srcdir)/lib/et/com_err.h \ - $(srcdir)/io.h $(top_builddir)/lib/ext2fs/ext2_err.h $(srcdir)/bitops.h + $(top_srcdir)/lib/et/com_err.h $(srcdir)/io.h \ + $(top_builddir)/lib/ext2fs/ext2_err.h $(srcdir)/bitops.h icount.o: $(srcdir)/icount.c $(top_srcdir)/lib/et/com_err.h \ $(srcdir)/ext2fs.h $(srcdir)/io.h $(top_builddir)/lib/ext2fs/ext2_err.h \ $(srcdir)/bitops.h -initialize.o: $(srcdir)/initialize.c $(srcdir)/ext2fs.h \ - $(top_srcdir)/lib/et/com_err.h \ +initialize.o: $(srcdir)/initialize.c \ + $(srcdir)/ext2fs.h $(top_srcdir)/lib/et/com_err.h \ $(srcdir)/io.h $(top_builddir)/lib/ext2fs/ext2_err.h \ $(srcdir)/bitops.h inline.o: $(srcdir)/inline.c $(srcdir)/ext2fs.h \ - $(top_srcdir)/lib/et/com_err.h \ - $(srcdir)/io.h $(top_builddir)/lib/ext2fs/ext2_err.h \ - $(srcdir)/bitops.h + $(top_srcdir)/lib/et/com_err.h $(srcdir)/io.h \ + $(top_builddir)/lib/ext2fs/ext2_err.h $(srcdir)/bitops.h inode.o: $(srcdir)/inode.c $(srcdir)/ext2fsP.h \ $(srcdir)/ext2fs.h $(top_srcdir)/lib/et/com_err.h \ $(srcdir)/io.h $(top_builddir)/lib/ext2fs/ext2_err.h \ $(srcdir)/bitops.h irel_ma.o: $(srcdir)/irel_ma.c $(srcdir)/ext2fs.h \ $(top_srcdir)/lib/et/com_err.h $(srcdir)/io.h \ - $(top_builddir)/lib/ext2fs/ext2_err.h $(srcdir)/bitops.h $(srcdir)/irel.h + $(top_builddir)/lib/ext2fs/ext2_err.h \ + $(srcdir)/bitops.h $(srcdir)/irel.h ismounted.o: $(srcdir)/ismounted.c $(srcdir)/ext2fs.h \ - $(top_srcdir)/lib/et/com_err.h \ - $(srcdir)/io.h $(top_builddir)/lib/ext2fs/ext2_err.h \ - $(srcdir)/bitops.h + $(top_srcdir)/lib/et/com_err.h $(srcdir)/io.h \ + $(top_builddir)/lib/ext2fs/ext2_err.h $(srcdir)/bitops.h link.o: $(srcdir)/link.c $(srcdir)/ext2fs.h \ - $(top_srcdir)/lib/et/com_err.h \ - $(srcdir)/io.h $(top_builddir)/lib/ext2fs/ext2_err.h \ - $(srcdir)/bitops.h -llseek.o: $(srcdir)/llseek.c $(top_srcdir)/lib/et/com_err.h \ - $(srcdir)/io.h + $(top_srcdir)/lib/et/com_err.h $(srcdir)/io.h \ + $(top_builddir)/lib/ext2fs/ext2_err.h $(srcdir)/bitops.h +llseek.o: $(srcdir)/llseek.c $(top_srcdir)/lib/et/com_err.h $(srcdir)/io.h lookup.o: $(srcdir)/lookup.c $(srcdir)/ext2fs.h \ - $(top_srcdir)/lib/et/com_err.h \ - $(srcdir)/io.h $(top_builddir)/lib/ext2fs/ext2_err.h $(srcdir)/bitops.h -mkdir.o: $(srcdir)/mkdir.c $(srcdir)/ext2fs.h \ - $(top_srcdir)/lib/et/com_err.h \ + $(top_srcdir)/lib/et/com_err.h $(srcdir)/io.h \ + $(top_builddir)/lib/ext2fs/ext2_err.h $(srcdir)/bitops.h +mkdir.o: $(srcdir)/mkdir.c $(srcdir)/ext2fs.h $(top_srcdir)/lib/et/com_err.h \ $(srcdir)/io.h $(top_builddir)/lib/ext2fs/ext2_err.h $(srcdir)/bitops.h namei.o: $(srcdir)/namei.c $(srcdir)/ext2fs.h \ - $(top_srcdir)/lib/et/com_err.h \ - $(srcdir)/io.h $(top_builddir)/lib/ext2fs/ext2_err.h $(srcdir)/bitops.h + $(top_srcdir)/lib/et/com_err.h $(srcdir)/io.h \ + $(top_builddir)/lib/ext2fs/ext2_err.h $(srcdir)/bitops.h native.o: $(srcdir)/native.c $(srcdir)/ext2fs.h \ - $(top_srcdir)/lib/et/com_err.h \ - $(srcdir)/io.h $(top_builddir)/lib/ext2fs/ext2_err.h $(srcdir)/bitops.h + $(top_srcdir)/lib/et/com_err.h $(srcdir)/io.h \ + $(top_builddir)/lib/ext2fs/ext2_err.h $(srcdir)/bitops.h newdir.o: $(srcdir)/newdir.c $(srcdir)/ext2fs.h \ - $(top_srcdir)/lib/et/com_err.h \ - $(srcdir)/io.h $(top_builddir)/lib/ext2fs/ext2_err.h \ - $(srcdir)/bitops.h + $(top_srcdir)/lib/et/com_err.h $(srcdir)/io.h \ + $(top_builddir)/lib/ext2fs/ext2_err.h $(srcdir)/bitops.h openfs.o: $(srcdir)/openfs.c $(srcdir)/ext2fs.h \ - $(top_srcdir)/lib/et/com_err.h \ - $(srcdir)/io.h $(top_builddir)/lib/ext2fs/ext2_err.h \ - $(srcdir)/bitops.h + $(top_srcdir)/lib/et/com_err.h $(srcdir)/io.h \ + $(top_builddir)/lib/ext2fs/ext2_err.h $(srcdir)/bitops.h read_bb.o: $(srcdir)/read_bb.c $(srcdir)/ext2fs.h \ - $(top_srcdir)/lib/et/com_err.h \ - $(srcdir)/io.h $(top_builddir)/lib/ext2fs/ext2_err.h \ - $(srcdir)/bitops.h + $(top_srcdir)/lib/et/com_err.h $(srcdir)/io.h \ + $(top_builddir)/lib/ext2fs/ext2_err.h $(srcdir)/bitops.h read_bb_file.o: $(srcdir)/read_bb_file.c $(srcdir)/ext2fs.h \ - $(top_srcdir)/lib/et/com_err.h \ - $(srcdir)/io.h $(top_builddir)/lib/ext2fs/ext2_err.h \ - $(srcdir)/bitops.h + $(top_srcdir)/lib/et/com_err.h $(srcdir)/io.h \ + $(top_builddir)/lib/ext2fs/ext2_err.h $(srcdir)/bitops.h rs_bitmap.o: $(srcdir)/rs_bitmap.c $(srcdir)/ext2fs.h \ - $(top_srcdir)/lib/et/com_err.h \ - $(srcdir)/io.h $(top_builddir)/lib/ext2fs/ext2_err.h \ - $(srcdir)/bitops.h + $(top_srcdir)/lib/et/com_err.h $(srcdir)/io.h \ + $(top_builddir)/lib/ext2fs/ext2_err.h $(srcdir)/bitops.h rw_bitmaps.o: $(srcdir)/rw_bitmaps.c $(srcdir)/ext2fs.h \ - $(top_srcdir)/lib/et/com_err.h \ - $(srcdir)/io.h $(top_builddir)/lib/ext2fs/ext2_err.h \ - $(srcdir)/bitops.h + $(top_srcdir)/lib/et/com_err.h $(srcdir)/io.h \ + $(top_builddir)/lib/ext2fs/ext2_err.h $(srcdir)/bitops.h swapfs.o: $(srcdir)/swapfs.c $(srcdir)/ext2fs.h \ - $(top_srcdir)/lib/et/com_err.h \ - $(srcdir)/io.h $(top_builddir)/lib/ext2fs/ext2_err.h $(srcdir)/bitops.h + $(top_srcdir)/lib/et/com_err.h $(srcdir)/io.h \ + $(top_builddir)/lib/ext2fs/ext2_err.h $(srcdir)/bitops.h test_io.o: $(srcdir)/test_io.c $(top_srcdir)/lib/et/com_err.h \ $(top_builddir)/lib/ext2fs/ext2_err.h $(srcdir)/io.h unix_io.o: $(srcdir)/unix_io.c $(top_srcdir)/lib/et/com_err.h \ $(top_builddir)/lib/ext2fs/ext2_err.h $(srcdir)/io.h unlink.o: $(srcdir)/unlink.c $(srcdir)/ext2fs.h \ - $(top_srcdir)/lib/et/com_err.h \ - $(srcdir)/io.h $(top_builddir)/lib/ext2fs/ext2_err.h $(srcdir)/bitops.h + $(top_srcdir)/lib/et/com_err.h $(srcdir)/io.h \ + $(top_builddir)/lib/ext2fs/ext2_err.h $(srcdir)/bitops.h valid_blk.o: $(srcdir)/valid_blk.c $(srcdir)/ext2fs.h \ $(top_srcdir)/lib/et/com_err.h $(srcdir)/io.h \ $(top_builddir)/lib/ext2fs/ext2_err.h $(srcdir)/bitops.h diff --git a/lib/ext2fs/alloc.c b/lib/ext2fs/alloc.c index 0bc637db..50cee77c 100644 --- a/lib/ext2fs/alloc.c +++ b/lib/ext2fs/alloc.c @@ -73,7 +73,7 @@ errcode_t ext2fs_new_inode(ext2_filsys fs, ino_t dir, int mode, errcode_t ext2fs_new_block(ext2_filsys fs, blk_t goal, ext2fs_block_bitmap map, blk_t *ret) { - blk_t i = goal; + blk_t i; EXT2_CHECK_MAGIC(fs, EXT2_ET_MAGIC_EXT2FS_FILSYS); @@ -81,8 +81,9 @@ errcode_t ext2fs_new_block(ext2_filsys fs, blk_t goal, map = fs->block_map; if (!map) return EXT2_ET_NO_BLOCK_BITMAP; - if (!i) - i = fs->super->s_first_data_block; + if (!goal || (goal >= fs->super->s_blocks_count)) + goal = fs->super->s_first_data_block; + i = goal; do { if (!ext2fs_test_block_bitmap(map, i)) { *ret = i; diff --git a/lib/ext2fs/alloc_tables.c b/lib/ext2fs/alloc_tables.c index 65c129f8..6a60bf76 100644 --- a/lib/ext2fs/alloc_tables.c +++ b/lib/ext2fs/alloc_tables.c @@ -42,6 +42,8 @@ errcode_t ext2fs_allocate_tables(ext2_filsys fs) * Allocate the inode table */ start_blk = group_blk + 3 + fs->desc_blocks; + if (start_blk > last_blk) + start_blk = group_blk; retval = ext2fs_get_free_blocks(fs, start_blk, last_blk, fs->inode_blocks_per_group, fs->block_map, &new_blk); @@ -56,8 +58,15 @@ errcode_t ext2fs_allocate_tables(ext2_filsys fs) /* * Allocate the block and inode bitmaps */ - start_blk += fs->inode_blocks_per_group + - ((2 * i) % (last_blk - start_blk)); + if (fs->stride) { + start_blk += fs->inode_blocks_per_group; + start_blk += ((fs->stride * i) % + (last_blk - start_blk)); + if (start_blk > last_blk) + /* should never happen */ + start_blk = group_blk; + } else + start_blk = group_blk; retval = ext2fs_get_free_blocks(fs, start_blk, last_blk, 1, fs->block_map, &new_blk); if (retval) diff --git a/lib/ext2fs/badblocks.c b/lib/ext2fs/badblocks.c index 722af8d0..f8a562a5 100644 --- a/lib/ext2fs/badblocks.c +++ b/lib/ext2fs/badblocks.c @@ -26,26 +26,58 @@ #include "ext2fsP.h" /* - * This procedure create an empty badblocks list. + * Helper function for making a badblocks list */ -errcode_t ext2fs_badblocks_list_create(ext2_badblocks_list *ret, int size) +static errcode_t make_badblocks_list(int size, int num, blk_t *list, + ext2_badblocks_list *ret) { ext2_badblocks_list bb; - + bb = malloc(sizeof(struct ext2_struct_badblocks_list)); if (!bb) return ENOMEM; memset(bb, 0, sizeof(struct ext2_struct_badblocks_list)); bb->magic = EXT2_ET_MAGIC_BADBLOCKS_LIST; bb->size = size ? size : 10; + bb->num = num; bb->list = malloc(bb->size * sizeof(blk_t)); if (!bb->list) { free(bb); return ENOMEM; } + if (list) + memcpy(bb->list, list, bb->size * sizeof(blk_t)); + else + memset(bb->list, 0, bb->size * sizeof(blk_t)); *ret = bb; return 0; } + + +/* + * This procedure creates an empty badblocks list. + */ +errcode_t ext2fs_badblocks_list_create(ext2_badblocks_list *ret, int size) +{ + return make_badblocks_list(size, 0, 0, ret); +} + +/* + * This procedure copies a badblocks list + */ +errcode_t ext2fs_badblocks_copy(ext2_badblocks_list src, + ext2_badblocks_list *dest) +{ + errcode_t retval; + + retval = make_badblocks_list(src->size, src->num, src->list, + dest); + if (retval) + return retval; + (*dest)->badblocks_flags = src->badblocks_flags; + return 0; +} + /* * This procedure frees a badblocks list. diff --git a/lib/ext2fs/bitmaps.c b/lib/ext2fs/bitmaps.c index 3ef5666c..c3a778d5 100644 --- a/lib/ext2fs/bitmaps.c +++ b/lib/ext2fs/bitmaps.c @@ -26,11 +26,9 @@ #include "ext2fs.h" -errcode_t ext2fs_allocate_generic_bitmap(__u32 start, - __u32 end, - __u32 real_end, - const char *descr, - ext2fs_generic_bitmap *ret) +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; int size; @@ -63,11 +61,40 @@ errcode_t ext2fs_allocate_generic_bitmap(__u32 start, return ENOMEM; } - memset(bitmap->bitmap, 0, size); + 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); +} + +errcode_t ext2fs_copy_bitmap(ext2fs_generic_bitmap src, + ext2fs_generic_bitmap *dest) +{ + errcode_t retval; + ext2fs_generic_bitmap new; + + retval = make_bitmap(src->start, src->end, src->real_end, + src->description, src->bitmap, &new); + if (retval) + return retval; + new->magic = src->magic; + new->fs = src->fs; + new->base_error_code = src->base_error_code; + return 0; +} + + errcode_t ext2fs_allocate_inode_bitmap(ext2_filsys fs, const char *descr, ext2fs_inode_bitmap *ret) diff --git a/lib/ext2fs/block.c b/lib/ext2fs/block.c index 3552dab1..03bf5f36 100644 --- a/lib/ext2fs/block.c +++ b/lib/ext2fs/block.c @@ -46,13 +46,16 @@ static int block_iterate_ind(blk_t *ind_block, blk_t ref_block, int i, flags, limit, offset; blk_t *block_nr; + limit = ctx->fs->blocksize >> 2; if (!(ctx->flags & BLOCK_FLAG_DEPTH_TRAVERSE) && !(ctx->flags & BLOCK_FLAG_DATA_ONLY)) ret = (*ctx->func)(ctx->fs, ind_block, BLOCK_COUNT_IND, ref_block, ref_offset, ctx->private); - if (!*ind_block || (ret & BLOCK_ABORT)) + if (!*ind_block || (ret & BLOCK_ABORT)) { + ctx->bcount += limit; return ret; + } if (*ind_block >= ctx->fs->super->s_blocks_count || *ind_block < ctx->fs->super->s_first_data_block) { ctx->errcode = EXT2_ET_BAD_IND_BLOCK; @@ -65,7 +68,6 @@ static int block_iterate_ind(blk_t *ind_block, blk_t ref_block, ret |= BLOCK_ERROR; return ret; } - limit = ctx->fs->blocksize >> 2; if ((ctx->fs->flags & EXT2_FLAG_SWAP_BYTES) || (ctx->fs->flags & EXT2_FLAG_SWAP_BYTES_READ)) { block_nr = (blk_t *) ctx->ind_buf; @@ -129,13 +131,16 @@ static int block_iterate_dind(blk_t *dind_block, blk_t ref_block, int i, flags, limit, offset; blk_t *block_nr; + limit = ctx->fs->blocksize >> 2; if (!(ctx->flags & BLOCK_FLAG_DEPTH_TRAVERSE) && !(ctx->flags & BLOCK_FLAG_DATA_ONLY)) ret = (*ctx->func)(ctx->fs, dind_block, BLOCK_COUNT_DIND, ref_block, ref_offset, ctx->private); - if (!*dind_block || (ret & BLOCK_ABORT)) + if (!*dind_block || (ret & BLOCK_ABORT)) { + ctx->bcount += limit*limit; return ret; + } if (*dind_block >= ctx->fs->super->s_blocks_count || *dind_block < ctx->fs->super->s_first_data_block) { ctx->errcode = EXT2_ET_BAD_DIND_BLOCK; @@ -148,7 +153,6 @@ static int block_iterate_dind(blk_t *dind_block, blk_t ref_block, ret |= BLOCK_ERROR; return ret; } - limit = ctx->fs->blocksize >> 2; if ((ctx->fs->flags & EXT2_FLAG_SWAP_BYTES) || (ctx->fs->flags & EXT2_FLAG_SWAP_BYTES_READ)) { block_nr = (blk_t *) ctx->dind_buf; @@ -171,8 +175,10 @@ static int block_iterate_dind(blk_t *dind_block, blk_t ref_block, } } else { for (i = 0; i < limit; i++, block_nr++) { - if (*block_nr == 0) + if (*block_nr == 0) { + ctx->bcount += limit; continue; + } flags = block_iterate_ind(block_nr, *dind_block, offset, ctx); @@ -212,13 +218,16 @@ static int block_iterate_tind(blk_t *tind_block, blk_t ref_block, int i, flags, limit, offset; blk_t *block_nr; + limit = ctx->fs->blocksize >> 2; if (!(ctx->flags & BLOCK_FLAG_DEPTH_TRAVERSE) && !(ctx->flags & BLOCK_FLAG_DATA_ONLY)) ret = (*ctx->func)(ctx->fs, tind_block, BLOCK_COUNT_TIND, ref_block, ref_offset, ctx->private); - if (!*tind_block || (ret & BLOCK_ABORT)) + if (!*tind_block || (ret & BLOCK_ABORT)) { + ctx->bcount += limit*limit*limit; return ret; + } if (*tind_block >= ctx->fs->super->s_blocks_count || *tind_block < ctx->fs->super->s_first_data_block) { ctx->errcode = EXT2_ET_BAD_TIND_BLOCK; @@ -231,7 +240,6 @@ static int block_iterate_tind(blk_t *tind_block, blk_t ref_block, ret |= BLOCK_ERROR; return ret; } - limit = ctx->fs->blocksize >> 2; if ((ctx->fs->flags & EXT2_FLAG_SWAP_BYTES) || (ctx->fs->flags & EXT2_FLAG_SWAP_BYTES_READ)) { block_nr = (blk_t *) ctx->tind_buf; @@ -254,8 +262,10 @@ static int block_iterate_tind(blk_t *tind_block, blk_t ref_block, } } else { for (i = 0; i < limit; i++, block_nr++) { - if (*block_nr == 0) + if (*block_nr == 0) { + ctx->bcount += limit*limit; continue; + } flags = block_iterate_dind(block_nr, *tind_block, offset, ctx); diff --git a/lib/ext2fs/closefs.c b/lib/ext2fs/closefs.c index a61f8783..4678d9ee 100644 --- a/lib/ext2fs/closefs.c +++ b/lib/ext2fs/closefs.c @@ -190,33 +190,3 @@ errcode_t ext2fs_close(ext2_filsys fs) return 0; } -/* - * This procedure frees a badblocks list. - */ -void ext2fs_badblocks_list_free(ext2_badblocks_list bb) -{ - if (bb->magic != EXT2_ET_MAGIC_BADBLOCKS_LIST) - return; - - if (bb->list) - free(bb->list); - bb->list = 0; - free(bb); -} - -/* - * Close a directory block list - */ -void ext2fs_free_dblist(ext2_dblist dblist) -{ - if (!dblist || (dblist->magic != EXT2_ET_MAGIC_DBLIST)) - return; - - if (dblist->list) - free(dblist->list); - dblist->list = 0; - if (dblist->fs && dblist->fs->dblist == dblist) - dblist->fs->dblist = 0; - dblist->magic = 0; - free(dblist); -} diff --git a/lib/ext2fs/dblist.c b/lib/ext2fs/dblist.c index 76c847ff..f990c10d 100644 --- a/lib/ext2fs/dblist.c +++ b/lib/ext2fs/dblist.c @@ -47,12 +47,16 @@ errcode_t ext2fs_get_num_dirs(ext2_filsys fs, ino_t *ret_num_dirs) } /* - * Initialize a directory block list + * helper function for making a new directory block list (for + * initialize and copy). */ -errcode_t ext2fs_init_dblist(ext2_filsys fs, ext2_dblist *ret_dblist) +static errcode_t make_dblist(ext2_filsys fs, ino_t size, ino_t count, + struct ext2_db_entry *list, + ext2_dblist *ret_dblist) { ext2_dblist dblist; errcode_t retval; + size_t len; EXT2_CHECK_MAGIC(fs, EXT2_ET_MAGIC_EXT2FS_FILSYS); @@ -67,22 +71,25 @@ errcode_t ext2fs_init_dblist(ext2_filsys fs, ext2_dblist *ret_dblist) dblist->magic = EXT2_ET_MAGIC_DBLIST; dblist->fs = fs; - retval = ext2fs_get_num_dirs(fs, &dblist->size); - if (retval) - goto cleanup; - - dblist->count = 0; - dblist->sorted = 1; - dblist->list = malloc(sizeof(struct ext2_db_entry) * dblist->size); + if (size) + dblist->size = size; + else { + retval = ext2fs_get_num_dirs(fs, &dblist->size); + if (retval) + goto cleanup; + } + len = sizeof(struct ext2_db_entry) * dblist->size; + dblist->count = count; + dblist->list = malloc(len); if (dblist->list == NULL) { retval = ENOMEM; goto cleanup; } - if (ret_dblist) - *ret_dblist = dblist; + if (list) + memcpy(dblist->list, list, len); else - fs->dblist = dblist; - + memset(dblist->list, 0, len); + *ret_dblist = dblist; return 0; cleanup: if (dblist) @@ -91,6 +98,44 @@ cleanup: } /* + * Initialize a directory block list + */ +errcode_t ext2fs_init_dblist(ext2_filsys fs, ext2_dblist *ret_dblist) +{ + ext2_dblist dblist; + errcode_t retval; + + retval = make_dblist(fs, 0, 0, 0, &dblist); + if (retval) + return retval; + + dblist->sorted = 1; + if (ret_dblist) + *ret_dblist = dblist; + else + fs->dblist = dblist; + + return 0; +} + +/* + * Copy a directory block list + */ +errcode_t ext2fs_copy_dblist(ext2_dblist src, ext2_dblist *dest) +{ + ext2_dblist dblist; + errcode_t retval; + + retval = make_dblist(src->fs, src->size, src->count, src->list, + &dblist); + if (retval) + return retval; + dblist->sorted = src->sorted; + *dest = dblist; + return 0; +} + +/* * Close a directory block list * * (moved to closefs.c) diff --git a/lib/ext2fs/dll/jump.funcs b/lib/ext2fs/dll/jump.funcs index 60843721..680a64d7 100644 --- a/lib/ext2fs/dll/jump.funcs +++ b/lib/ext2fs/dll/jump.funcs @@ -142,3 +142,11 @@ 00000000 T _ext2fs_get_library_version libext2fs version 00000000 T _ext2fs_parse_version_string libext2fs version 00000000 T _ext2fs_set_dir_block libext2fs dblist +00000000 T _ext2fs_badblocks_copy libext2fs badblocks +00000000 T _ext2fs_copy_bitmap libext2fs bitmaps +00000000 T _ext2fs_bg_has_super libext2fs closefs +00000000 T _ext2fs_copy_dblist libext2fs dblist +00000000 T _ext2fs_dup_handle libext2fs dupfs +00000000 T _ext2fs_icount_validate libext2fs icount +00000000 T _ext2fs_resize_inode_bitmap libext2fs rs_bitmap +00000000 T _ext2fs_resize_block_bitmap libext2fs rs_bitmap diff --git a/lib/ext2fs/dll/jump.params b/lib/ext2fs/dll/jump.params index cc96847c..d4d1b338 100644 --- a/lib/ext2fs/dll/jump.params +++ b/lib/ext2fs/dll/jump.params @@ -3,4 +3,4 @@ Text=0x66900000 Data=0x00000000 Jump=0x00001000 GOT=0x00001000 -Version=1.1.0 +Version=1.2.0 diff --git a/lib/ext2fs/dupfs.c b/lib/ext2fs/dupfs.c new file mode 100644 index 00000000..b2eee0b7 --- /dev/null +++ b/lib/ext2fs/dupfs.c @@ -0,0 +1,93 @@ +/* + * dupfs.c --- duplicate a ext2 filesystem handle + * + * Copyright (C) 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 <unistd.h> +#include <stdlib.h> +#include <time.h> +#include <string.h> +#ifdef HAVE_ERRNO_H +#include <errno.h> +#endif + +#include <linux/ext2_fs.h> + +#include "ext2fsP.h" + +errcode_t ext2fs_dup_handle(ext2_filsys src, ext2_filsys *dest) +{ + ext2_filsys fs; + errcode_t retval; + + EXT2_CHECK_MAGIC(src, EXT2_ET_MAGIC_EXT2FS_FILSYS); + + fs = (ext2_filsys) malloc(sizeof(struct struct_ext2_filsys)); + if (!fs) + return ENOMEM; + + *fs = *src; + fs->device_name = 0; + fs->super = 0; + fs->group_desc = 0; + fs->inode_map = 0; + fs->block_map = 0; + fs->badblocks = 0; + fs->dblist = 0; + + io_channel_bumpcount(fs->io); + if (fs->icache) + fs->icache->refcount++; + + retval = ENOMEM; + fs->device_name = malloc(strlen(src->device_name)+1); + if (!fs->device_name) + goto errout; + strcpy(fs->device_name, src->device_name); + + fs->super = malloc(SUPERBLOCK_SIZE); + if (!fs->super) + goto errout; + memcpy(fs->super, src->super, SUPERBLOCK_SIZE); + + fs->group_desc = malloc(fs->desc_blocks * fs->blocksize); + if (!fs->group_desc) + goto errout; + memcpy(fs->group_desc, src->group_desc, + fs->desc_blocks * fs->blocksize); + + if (src->inode_map) { + retval = ext2fs_copy_bitmap(src->inode_map, &fs->inode_map); + if (retval) + goto errout; + } + if (src->block_map) { + retval = ext2fs_copy_bitmap(src->block_map, &fs->block_map); + if (retval) + goto errout; + } + if (src->badblocks) { + retval = ext2fs_badblocks_copy(src->badblocks, &fs->badblocks); + if (retval) + goto errout; + } + if (src->dblist) { + retval = ext2fs_copy_dblist(src->dblist, &fs->dblist); + if (retval) + goto errout; + } + *dest = fs; + return 0; +errout: + ext2fs_free(fs); + return retval; + +} + diff --git a/lib/ext2fs/ext2fs.h b/lib/ext2fs/ext2fs.h index 4e14fd61..2e68c4c7 100644 --- a/lib/ext2fs/ext2fs.h +++ b/lib/ext2fs/ext2fs.h @@ -141,16 +141,21 @@ struct struct_ext2_filsys { struct ext2_inode *inode); badblocks_list badblocks; ext2_dblist dblist; + __u32 stride; /* for mke2fs */ /* * Reserved for future expansion */ - __u32 reserved[12]; + __u32 reserved[11]; /* - * Not used by ext2fs library; reserved for the use of the - * calling application. + * Reserved for the use of the calling application. */ - void * private; + void * private; + + /* + * Inode cache + */ + struct ext2_inode_cache *icache; }; #include "ext2fs/bitops.h" @@ -374,7 +379,6 @@ errcode_t ext2fs_allocate_tables(ext2_filsys fs); /* badblocks.c */ extern errcode_t ext2fs_badblocks_list_create(ext2_badblocks_list *ret, int size); -extern void ext2fs_badblocks_list_free(ext2_badblocks_list bb); extern errcode_t ext2fs_badblocks_list_add(ext2_badblocks_list bb, blk_t blk); extern int ext2fs_badblocks_list_test(ext2_badblocks_list bb, @@ -385,16 +389,18 @@ extern errcode_t extern int ext2fs_badblocks_list_iterate(ext2_badblocks_iterate iter, blk_t *blk); extern void ext2fs_badblocks_list_iterate_end(ext2_badblocks_iterate iter); +extern errcode_t ext2fs_badblocks_copy(ext2_badblocks_list src, + ext2_badblocks_list *dest); /* bb_compat */ extern errcode_t badblocks_list_create(badblocks_list *ret, int size); -extern void badblocks_list_free(badblocks_list bb); extern errcode_t badblocks_list_add(badblocks_list bb, blk_t blk); extern int badblocks_list_test(badblocks_list bb, blk_t blk); extern errcode_t badblocks_list_iterate_begin(badblocks_list bb, badblocks_iterate *ret); extern int badblocks_list_iterate(badblocks_iterate iter, blk_t *blk); extern void badblocks_list_iterate_end(badblocks_iterate iter); +extern void badblocks_list_free(badblocks_list bb); /* bb_inode.c */ extern errcode_t ext2fs_update_bb_inode(ext2_filsys fs, @@ -464,18 +470,18 @@ extern errcode_t ext2fs_compare_inode_bitmap(ext2fs_inode_bitmap bm1, /* dblist.c */ -errcode_t ext2fs_get_num_dirs(ext2_filsys fs, ino_t *ret_num_dirs); -errcode_t ext2fs_init_dblist(ext2_filsys fs, ext2_dblist *ret_dblist); -void ext2fs_free_dblist(ext2_dblist dblist); -errcode_t ext2fs_add_dir_block(ext2_dblist dblist, ino_t ino, blk_t blk, - int blockcnt); -errcode_t ext2fs_dblist_iterate(ext2_dblist dblist, - int (*func)(ext2_filsys fs, - struct ext2_db_entry *db_info, - void *private), - void *private); -errcode_t ext2fs_set_dir_block(ext2_dblist dblist, ino_t ino, blk_t blk, - int blockcnt); +extern errcode_t ext2fs_get_num_dirs(ext2_filsys fs, ino_t *ret_num_dirs); +extern errcode_t ext2fs_init_dblist(ext2_filsys fs, ext2_dblist *ret_dblist); +extern errcode_t ext2fs_add_dir_block(ext2_dblist dblist, ino_t ino, + blk_t blk, int blockcnt); +extern errcode_t ext2fs_dblist_iterate(ext2_dblist dblist, + int (*func)(ext2_filsys fs, struct ext2_db_entry *db_info, + void *private), + void *private); +extern errcode_t ext2fs_set_dir_block(ext2_dblist dblist, ino_t ino, + blk_t blk, int blockcnt); +extern errcode_t ext2fs_copy_dblist(ext2_dblist src, + ext2_dblist *dest); /* dblist_dir.c */ extern errcode_t @@ -514,6 +520,8 @@ extern int ext2fs_process_dir_block(ext2_filsys fs, int blockcnt, void *private); +/* dupfs.c */ +extern errcode_t ext2fs_dup_handle(ext2_filsys src, ext2_filsys *dest); /* expanddir.c */ extern errcode_t ext2fs_expand_dir(ext2_filsys fs, ino_t dir); @@ -523,6 +531,8 @@ 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(badblocks_list bb); /* getsize.c */ extern errcode_t ext2fs_get_device_size(const char *file, int blocksize, @@ -631,6 +641,8 @@ 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_super(struct ext2_super_block * super); diff --git a/lib/ext2fs/ext2fsP.h b/lib/ext2fs/ext2fsP.h index 5cf83b5e..113a9b69 100644 --- a/lib/ext2fs/ext2fsP.h +++ b/lib/ext2fs/ext2fsP.h @@ -64,6 +64,22 @@ struct dir_context { errcode_t errcode; }; +/* + * Inode cache structure + */ +struct ext2_inode_cache { + void * buffer; + blk_t buffer_blk; + int cache_last; + int cache_size; + int refcount; + struct ext2_inode_cache_ent *cache; +}; + +struct ext2_inode_cache_ent { + ino_t ino; + struct ext2_inode inode; +}; /* Function prototypes */ diff --git a/lib/ext2fs/freefs.c b/lib/ext2fs/freefs.c index 215d1fbc..43331aba 100644 --- a/lib/ext2fs/freefs.c +++ b/lib/ext2fs/freefs.c @@ -15,7 +15,9 @@ #include <linux/ext2_fs.h> -#include "ext2fs.h" +#include "ext2fsP.h" + +static void ext2fs_free_inode_cache(struct ext2_inode_cache *icache); void ext2fs_free(ext2_filsys fs) { @@ -41,6 +43,9 @@ void ext2fs_free(ext2_filsys fs) if (fs->dblist) ext2fs_free_dblist(fs->dblist); + + if (fs->icache) + ext2fs_free_inode_cache(fs->icache); fs->magic = 0; @@ -82,3 +87,49 @@ void ext2fs_free_block_bitmap(ext2fs_block_bitmap bitmap) ext2fs_free_generic_bitmap(bitmap); } +/* + * Free the inode cache structure + */ +static void ext2fs_free_inode_cache(struct ext2_inode_cache *icache) +{ + if (--icache->refcount) + return; + if (icache->buffer) + free(icache->buffer); + if (icache->cache) + free(icache->cache); + icache->buffer_blk = 0; + free(icache); +} + +/* + * This procedure frees a badblocks list. + */ +void ext2fs_badblocks_list_free(ext2_badblocks_list bb) +{ + if (bb->magic != EXT2_ET_MAGIC_BADBLOCKS_LIST) + return; + + if (bb->list) + free(bb->list); + bb->list = 0; + free(bb); +} + +/* + * Free a directory block list + */ +void ext2fs_free_dblist(ext2_dblist dblist) +{ + if (!dblist || (dblist->magic != EXT2_ET_MAGIC_DBLIST)) + return; + + if (dblist->list) + free(dblist->list); + dblist->list = 0; + if (dblist->fs && dblist->fs->dblist == dblist) + dblist->fs->dblist = 0; + dblist->magic = 0; + free(dblist); +} + diff --git a/lib/ext2fs/initialize.c b/lib/ext2fs/initialize.c index 874b1180..f9e744b3 100644 --- a/lib/ext2fs/initialize.c +++ b/lib/ext2fs/initialize.c @@ -58,7 +58,6 @@ errcode_t ext2fs_initialize(const char *name, int flags, ext2_filsys fs; errcode_t retval; struct ext2_super_block *super; - struct ext2fs_sb *s; int frags_per_block; int rem; int overhead = 0; @@ -92,12 +91,9 @@ errcode_t ext2fs_initialize(const char *name, int flags, goto cleanup; } memset(super, 0, SUPERBLOCK_SIZE); - s = (struct ext2fs_sb *) super; #define set_field(field, default) (super->field = param->field ? \ param->field : (default)) -#define set_ext2_field(field, default) (s->field = param->field ? \ - param->field : (default)) super->s_magic = EXT2_SUPER_MAGIC; super->s_state = EXT2_VALID_FS; @@ -107,15 +103,15 @@ errcode_t ext2fs_initialize(const char *name, int flags, set_field(s_first_data_block, super->s_log_block_size ? 0 : 1); set_field(s_max_mnt_count, EXT2_DFL_MAX_MNT_COUNT); set_field(s_errors, EXT2_ERRORS_DEFAULT); - set_ext2_field(s_feature_compat, 0); - set_ext2_field(s_feature_incompat, 0); - set_ext2_field(s_feature_ro_compat, 0); - if (s->s_feature_incompat & ~EXT2_LIB_FEATURE_INCOMPAT_SUPP) +#ifdef EXT2_DYNAMIC_REV + set_field(s_feature_compat, 0); + set_field(s_feature_incompat, 0); + set_field(s_feature_ro_compat, 0); + if (super->s_feature_incompat & ~EXT2_LIB_FEATURE_INCOMPAT_SUPP) return EXT2_ET_UNSUPP_FEATURE; - if (s->s_feature_ro_compat & ~EXT2_LIB_FEATURE_RO_COMPAT_SUPP) + if (super->s_feature_ro_compat & ~EXT2_LIB_FEATURE_RO_COMPAT_SUPP) return EXT2_ET_RO_UNSUPP_FEATURE; -#ifdef EXT2_DYNAMIC_REV set_field(s_rev_level, EXT2_GOOD_OLD_REV); if (super->s_rev_level >= EXT2_DYNAMIC_REV) { set_field(s_first_ino, EXT2_GOOD_OLD_FIRST_INO); diff --git a/lib/ext2fs/inode.c b/lib/ext2fs/inode.c index 7194fb0c..be882ad5 100644 --- a/lib/ext2fs/inode.c +++ b/lib/ext2fs/inode.c @@ -46,6 +46,35 @@ struct ext2_struct_inode_scan { int reserved[6]; }; +static errcode_t create_icache(ext2_filsys fs) +{ + int i; + + if (fs->icache) + return 0; + fs->icache = malloc(sizeof(struct ext2_inode_cache)); + memset(fs->icache, 0, sizeof(struct ext2_inode_cache)); + fs->icache->buffer = malloc(fs->blocksize); + if (!fs->icache->buffer) { + free(fs->icache); + return ENOMEM; + } + fs->icache->buffer_blk = 0; + fs->icache->cache_last = -1; + fs->icache->cache_size = 4; + fs->icache->refcount = 1; + fs->icache->cache = malloc(sizeof(struct ext2_inode_cache_ent) + * fs->icache->cache_size); + if (!fs->icache->cache) { + free(fs->icache->buffer); + free(fs->icache); + return ENOMEM; + } + for (i=0; i < fs->icache->cache_size; i++) + fs->icache->cache[i].ino = 0; + return 0; +} + errcode_t ext2fs_open_inode_scan(ext2_filsys fs, int buffer_blocks, ext2_inode_scan *ret_scan) { @@ -377,19 +406,6 @@ errcode_t ext2fs_get_next_inode(ext2_inode_scan scan, ino_t *ino, /* * Functions to read and write a single inode. */ -static char *inode_buffer = 0; -static blk_t inode_buffer_block = 0; -static int inode_buffer_size = 0; -#define INODE_CACHE_SIZE 4 -#ifdef INODE_CACHE_SIZE -static int cache_last = -1; -static struct { - ino_t inode; - struct ext2_inode value; -} inode_cache[INODE_CACHE_SIZE]; -#endif - - errcode_t ext2fs_read_inode (ext2_filsys fs, ino_t ino, struct ext2_inode * inode) { @@ -406,32 +422,21 @@ errcode_t ext2fs_read_inode (ext2_filsys fs, ino_t ino, if (retval != EXT2_ET_CALLBACK_NOTHANDLED) return retval; } + /* Create inode cache if not present */ + if (!fs->icache) { + retval = create_icache(fs); + if (retval) + return retval; + } /* Check to see if it's in the inode cache */ -#ifdef INODE_CACHE_SIZE - if (cache_last == -1) { - for (i=0; i < INODE_CACHE_SIZE; i++) - inode_cache[i].inode = 0; - cache_last = INODE_CACHE_SIZE-1; - } else for (i=0; i < INODE_CACHE_SIZE; i++) { - if (inode_cache[i].inode == ino) { - *inode = inode_cache[i].value; + for (i=0; i < fs->icache->cache_size; i++) { + if (fs->icache->cache[i].ino == ino) { + *inode = fs->icache->cache[i].inode; return 0; } } -#endif if (ino > fs->super->s_inodes_count) return EXT2_ET_BAD_INODE_NUM; - if (inode_buffer_size != fs->blocksize) { - if (inode_buffer) - free(inode_buffer); - inode_buffer_size = 0; - inode_buffer = malloc(fs->blocksize); - if (!inode_buffer) - return ENOMEM; - inode_buffer_size = fs->blocksize; - inode_buffer_block = 0; - } - group = (ino - 1) / EXT2_INODES_PER_GROUP(fs->super); offset = ((ino - 1) % EXT2_INODES_PER_GROUP(fs->super)) * EXT2_INODE_SIZE(fs->super); @@ -439,15 +444,15 @@ errcode_t ext2fs_read_inode (ext2_filsys fs, ino_t ino, if (!fs->group_desc[group].bg_inode_table) return EXT2_ET_MISSING_INODE_TABLE; block_nr = fs->group_desc[group].bg_inode_table + block; - if (block_nr != inode_buffer_block) { + if (block_nr != fs->icache->buffer_blk) { retval = io_channel_read_blk(fs->io, block_nr, 1, - inode_buffer); + fs->icache->buffer); if (retval) return retval; - inode_buffer_block = block_nr; + fs->icache->buffer_blk = block_nr; } offset &= (EXT2_BLOCK_SIZE(fs->super) - 1); - ptr = ((char *) inode_buffer) + offset; + ptr = ((char *) fs->icache->buffer) + offset; memset(inode, 0, sizeof(struct ext2_inode)); length = EXT2_INODE_SIZE(fs->super); @@ -460,13 +465,15 @@ errcode_t ext2fs_read_inode (ext2_filsys fs, ino_t ino, length -= clen; retval = io_channel_read_blk(fs->io, block_nr+1, 1, - inode_buffer); - if (retval) + fs->icache->buffer); + if (retval) { + fs->icache->buffer_blk = 0; return retval; - inode_buffer_block = block_nr+1; + } + fs->icache->buffer_blk = block_nr+1; memcpy(((char *) inode) + clen, - inode_buffer, length); + fs->icache->buffer, length); } else memcpy((char *) inode, ptr, length); @@ -475,12 +482,11 @@ errcode_t ext2fs_read_inode (ext2_filsys fs, ino_t ino, ext2fs_swap_inode(fs, inode, inode, 0); /* Update the inode cache */ -#ifdef INODE_CACHE_SIZE - cache_last = (cache_last + 1) % INODE_CACHE_SIZE; - inode_cache[cache_last].inode = ino; - inode_cache[cache_last].value = *inode; -#endif - + fs->icache->cache_last = (fs->icache->cache_last + 1) % + fs->icache->cache_size; + fs->icache->cache[fs->icache->cache_last].ino = ino; + fs->icache->cache[fs->icache->cache_last].inode = *inode; + return 0; } @@ -501,31 +507,27 @@ errcode_t ext2fs_write_inode(ext2_filsys fs, ino_t ino, if (retval != EXT2_ET_CALLBACK_NOTHANDLED) return retval; } + /* Check to see if the inode cache needs to be updated */ -#ifdef INODE_CACHE_SIZE - for (i=0; i < INODE_CACHE_SIZE; i++) { - if (inode_cache[i].inode == ino) { - inode_cache[i].value = *inode; - break; + if (fs->icache) { + for (i=0; i < fs->icache->cache_size; i++) { + if (fs->icache->cache[i].ino == ino) { + fs->icache->cache[i].inode = *inode; + break; + } } + } else { + retval = create_icache(fs); + if (retval) + return retval; } -#endif + if (!(fs->flags & EXT2_FLAG_RW)) return EXT2_ET_RO_FILSYS; if (ino > fs->super->s_inodes_count) return EXT2_ET_BAD_INODE_NUM; - if (inode_buffer_size != fs->blocksize) { - if (inode_buffer) - free(inode_buffer); - inode_buffer_size = 0; - inode_buffer = malloc(fs->blocksize); - if (!inode_buffer) - return ENOMEM; - inode_buffer_size = fs->blocksize; - inode_buffer_block = 0; - } if ((fs->flags & EXT2_FLAG_SWAP_BYTES) || (fs->flags & EXT2_FLAG_SWAP_BYTES_WRITE)) ext2fs_swap_inode(fs, &temp_inode, inode, 1); @@ -540,19 +542,19 @@ errcode_t ext2fs_write_inode(ext2_filsys fs, ino_t ino, return EXT2_ET_MISSING_INODE_TABLE; block_nr = fs->group_desc[group].bg_inode_table + block; offset &= (EXT2_BLOCK_SIZE(fs->super) - 1); - ptr = (char *) inode_buffer + offset; + ptr = (char *) fs->icache->buffer + offset; length = EXT2_INODE_SIZE(fs->super); clen = length; if (length > sizeof(struct ext2_inode)) length = sizeof(struct ext2_inode); - if (inode_buffer_block != block_nr) { + if (fs->icache->buffer_blk != block_nr) { retval = io_channel_read_blk(fs->io, block_nr, 1, - inode_buffer); + fs->icache->buffer); if (retval) return retval; - inode_buffer_block = block_nr; + fs->icache->buffer_blk = block_nr; } if ((offset + length) > EXT2_BLOCK_SIZE(fs->super)) { @@ -562,22 +564,23 @@ errcode_t ext2fs_write_inode(ext2_filsys fs, ino_t ino, length = 0; } memcpy(ptr, &temp_inode, clen); - retval = io_channel_write_blk(fs->io, block_nr, 1, inode_buffer); + retval = io_channel_write_blk(fs->io, block_nr, 1, fs->icache->buffer); if (retval) return retval; if (length) { retval = io_channel_read_blk(fs->io, ++block_nr, 1, - inode_buffer); + fs->icache->buffer); if (retval) { - inode_buffer_block = 0; + fs->icache->buffer_blk = 0; return retval; } - inode_buffer_block = block_nr; - memcpy(inode_buffer, ((char *) &temp_inode) + clen, length); + fs->icache->buffer_blk = block_nr; + memcpy(fs->icache->buffer, ((char *) &temp_inode) + clen, + length); retval = io_channel_write_blk(fs->io, block_nr, 1, - inode_buffer); + fs->icache->buffer); if (retval) return retval; } diff --git a/lib/ext2fs/io.h b/lib/ext2fs/io.h index 6b28fee8..fcd1a01f 100644 --- a/lib/ext2fs/io.h +++ b/lib/ext2fs/io.h @@ -43,7 +43,8 @@ struct struct_io_channel { size_t size, int actual_bytes_written, errcode_t error); - int reserved[16]; + int refcount; + int reserved[15]; void *private_data; }; @@ -71,6 +72,7 @@ struct struct_io_manager { #define io_channel_read_blk(c,b,n,d) ((c)->manager->read_blk((c),b,n,d)) #define io_channel_write_blk(c,b,n,d) ((c)->manager->write_blk((c),b,n,d)) #define io_channel_flush(c) ((c)->manager->flush((c))) +#define io_channel_bumpcount(c) ((c)->refcount++) /* unix_io.c */ extern io_manager unix_io_manager; diff --git a/lib/ext2fs/test_io.c b/lib/ext2fs/test_io.c index 1bd09b1e..a82f0946 100644 --- a/lib/ext2fs/test_io.c +++ b/lib/ext2fs/test_io.c @@ -104,6 +104,7 @@ static errcode_t test_open(const char *name, int flags, io_channel *channel) io->block_size = 1024; io->read_error = 0; io->write_error = 0; + io->refcount = 1; memset(data, 0, sizeof(struct test_private_data)); data->magic = EXT2_ET_MAGIC_TEST_IO_CHANNEL; @@ -138,6 +139,9 @@ static errcode_t test_close(io_channel channel) data = (struct test_private_data *) channel->private_data; EXT2_CHECK_MAGIC(data, EXT2_ET_MAGIC_TEST_IO_CHANNEL); + if (--channel->refcount > 0) + return 0; + if (data->real) retval = io_channel_close(data->real); diff --git a/lib/ext2fs/unix_io.c b/lib/ext2fs/unix_io.c index 5083771f..ef00902d 100644 --- a/lib/ext2fs/unix_io.c +++ b/lib/ext2fs/unix_io.c @@ -94,6 +94,7 @@ static errcode_t unix_open(const char *name, int flags, io_channel *channel) io->block_size = 1024; io->read_error = 0; io->write_error = 0; + io->refcount = 1; memset(data, 0, sizeof(struct unix_private_data)); data->magic = EXT2_ET_MAGIC_UNIX_IO_CHANNEL; @@ -130,6 +131,9 @@ static errcode_t unix_close(io_channel channel) 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 (--channel->refcount > 0) + return 0; if (close(data->dev) < 0) retval = errno; |