From ff5666bc460520aef6105e117d5431c05fd9f55b Mon Sep 17 00:00:00 2001 From: Robert Yang Date: Thu, 20 Mar 2014 17:37:41 +0800 Subject: genext2fs: remove it Remove genext2fs since we don't use it anymore, it can't support ext4 well, either. We have used "mke2fs -d" to instead of it. [YOCTO #6013] Signed-off-by: Robert Yang Signed-off-by: Richard Purdie --- meta/conf/distro/include/seperatebuilddir.inc | 3 - .../packagegroups/packagegroup-self-hosted.bb | 1 - ...01-Fix-warnings-remove-some-unused-macros.patch | 72 -- .../0002-Add-put_blk-and-put_nod-routines.patch | 1123 -------------------- .../0003-Add-get_blkmap-and-put_blkmap.patch | 222 ---- ...lker-for-walking-through-directory-entrie.patch | 357 ------- ...05-Make-filesystem-struct-not-an-overloay.patch | 374 ------- ...0006-Improve-the-efficiency-of-extend_blk.patch | 272 ----- ...ove-hdlinks-into-the-filesystem-structure.patch | 175 --- ...t-the-creation-of-the-filesystem-structur.patch | 95 -- ...e-byte-swapping-into-the-get-put-routines.patch | 421 -------- ...rt-over-to-keeping-the-filesystem-on-disk.patch | 839 --------------- ...les-into-the-filesystem-a-piece-at-a-time.patch | 103 -- ...upport-large-file-support-and-rework-hole.patch | 211 ---- .../0013-Add-volume-id-support.patch | 86 -- ...014-Remove-unneeded-setting-of-s_reserved.patch | 28 - ...-Rework-creating-the-lost-found-directory.patch | 57 - ...ix-the-documentation-for-the-new-L-option.patch | 29 - .../0017-Fix-file-same-comparison.patch | 30 - ...andle-files-changing-while-we-are-working.patch | 89 -- ...ke-sure-superblock-is-clear-on-allocation.patch | 42 - .../fix-memory-corruption-on-powerpc.patch | 76 -- .../genext2fs-1.4.1/fix-nbblocks-cast.patch | 37 - .../genext2fs/genext2fs-1.4.1/update_to_1.95.patch | 119 --- meta/recipes-devtools/genext2fs/genext2fs.inc | 16 - meta/recipes-devtools/genext2fs/genext2fs_1.4.1.bb | 29 - .../packagegroups/packagegroup-toolset-native.bb | 1 - 27 files changed, 4907 deletions(-) delete mode 100644 meta/recipes-devtools/genext2fs/genext2fs-1.4.1/0001-Fix-warnings-remove-some-unused-macros.patch delete mode 100644 meta/recipes-devtools/genext2fs/genext2fs-1.4.1/0002-Add-put_blk-and-put_nod-routines.patch delete mode 100644 meta/recipes-devtools/genext2fs/genext2fs-1.4.1/0003-Add-get_blkmap-and-put_blkmap.patch delete mode 100644 meta/recipes-devtools/genext2fs/genext2fs-1.4.1/0004-Add-a-dirwalker-for-walking-through-directory-entrie.patch delete mode 100644 meta/recipes-devtools/genext2fs/genext2fs-1.4.1/0005-Make-filesystem-struct-not-an-overloay.patch delete mode 100644 meta/recipes-devtools/genext2fs/genext2fs-1.4.1/0006-Improve-the-efficiency-of-extend_blk.patch delete mode 100644 meta/recipes-devtools/genext2fs/genext2fs-1.4.1/0007-Move-hdlinks-into-the-filesystem-structure.patch delete mode 100644 meta/recipes-devtools/genext2fs/genext2fs-1.4.1/0008-Separate-out-the-creation-of-the-filesystem-structur.patch delete mode 100644 meta/recipes-devtools/genext2fs/genext2fs-1.4.1/0009-Move-byte-swapping-into-the-get-put-routines.patch delete mode 100644 meta/recipes-devtools/genext2fs/genext2fs-1.4.1/0010-Convert-over-to-keeping-the-filesystem-on-disk.patch delete mode 100644 meta/recipes-devtools/genext2fs/genext2fs-1.4.1/0011-Copy-files-into-the-filesystem-a-piece-at-a-time.patch delete mode 100644 meta/recipes-devtools/genext2fs/genext2fs-1.4.1/0012-Add-rev-1-support-large-file-support-and-rework-hole.patch delete mode 100644 meta/recipes-devtools/genext2fs/genext2fs-1.4.1/0013-Add-volume-id-support.patch delete mode 100644 meta/recipes-devtools/genext2fs/genext2fs-1.4.1/0014-Remove-unneeded-setting-of-s_reserved.patch delete mode 100644 meta/recipes-devtools/genext2fs/genext2fs-1.4.1/0015-Rework-creating-the-lost-found-directory.patch delete mode 100644 meta/recipes-devtools/genext2fs/genext2fs-1.4.1/0016-Fix-the-documentation-for-the-new-L-option.patch delete mode 100644 meta/recipes-devtools/genext2fs/genext2fs-1.4.1/0017-Fix-file-same-comparison.patch delete mode 100644 meta/recipes-devtools/genext2fs/genext2fs-1.4.1/0018-Handle-files-changing-while-we-are-working.patch delete mode 100644 meta/recipes-devtools/genext2fs/genext2fs-1.4.1/0019-Make-sure-superblock-is-clear-on-allocation.patch delete mode 100644 meta/recipes-devtools/genext2fs/genext2fs-1.4.1/fix-memory-corruption-on-powerpc.patch delete mode 100644 meta/recipes-devtools/genext2fs/genext2fs-1.4.1/fix-nbblocks-cast.patch delete mode 100644 meta/recipes-devtools/genext2fs/genext2fs-1.4.1/update_to_1.95.patch delete mode 100644 meta/recipes-devtools/genext2fs/genext2fs.inc delete mode 100644 meta/recipes-devtools/genext2fs/genext2fs_1.4.1.bb diff --git a/meta/conf/distro/include/seperatebuilddir.inc b/meta/conf/distro/include/seperatebuilddir.inc index c6897a593a..cf90c10fe9 100644 --- a/meta/conf/distro/include/seperatebuilddir.inc +++ b/meta/conf/distro/include/seperatebuilddir.inc @@ -163,8 +163,6 @@ B_pn-gdbm = "${SEPB}" B_pn-gdbm-native = "${SEPB}" B_pn-gdk-pixbuf = "${SEPB}" B_pn-gdk-pixbuf-native = "${SEPB}" -B_pn-genext2fs = "${SEPB}" -B_pn-genext2fs-native = "${SEPB}" B_pn-gettext = "${SEPB}" B_pn-gettext-native = "${SEPB}" #checking for system lcms2 library... checking for cmsCreateXYZProfile in -llcms2... no @@ -483,7 +481,6 @@ B_pn-nativesdk-fixesproto = "${SEPB}" B_pn-nativesdk-flex = "${SEPB}" B_pn-nativesdk-gcc-runtime = "${SEPB}" B_pn-nativesdk-gdbm = "${SEPB}" -B_pn-nativesdk-genext2fs = "${SEPB}" B_pn-nativesdk-gettext = "${SEPB}" B_pn-nativesdk-glib-2.0 = "${SEPB}" B_pn-nativesdk-glproto = "${SEPB}" diff --git a/meta/recipes-core/packagegroups/packagegroup-self-hosted.bb b/meta/recipes-core/packagegroups/packagegroup-self-hosted.bb index 108e67890a..8e3b917c75 100644 --- a/meta/recipes-core/packagegroups/packagegroup-self-hosted.bb +++ b/meta/recipes-core/packagegroups/packagegroup-self-hosted.bb @@ -38,7 +38,6 @@ RDEPENDS_packagegroup-self-hosted-host-tools = "\ e2fsprogs-e2fsck \ e2fsprogs-mke2fs \ e2fsprogs-tune2fs \ - genext2fs \ hdparm \ iptables \ lsb \ diff --git a/meta/recipes-devtools/genext2fs/genext2fs-1.4.1/0001-Fix-warnings-remove-some-unused-macros.patch b/meta/recipes-devtools/genext2fs/genext2fs-1.4.1/0001-Fix-warnings-remove-some-unused-macros.patch deleted file mode 100644 index f981b449ba..0000000000 --- a/meta/recipes-devtools/genext2fs/genext2fs-1.4.1/0001-Fix-warnings-remove-some-unused-macros.patch +++ /dev/null @@ -1,72 +0,0 @@ -Upstream-Status: inappropriate - -From 1399df7672ec309523bcd067da24d72aa624f783 Mon Sep 17 00:00:00 2001 -From: Corey Minyard -Date: Wed, 1 Jun 2011 07:51:24 -0500 -Subject: [PATCH 01/19] Fix warnings, remove some unused macros. - -These are some annoying warnings with newer toolchains. And NAMLEN is -never used, so just get rid of it. ---- - genext2fs.c | 15 +++++++++------ - 1 files changed, 9 insertions(+), 6 deletions(-) - -diff --git a/genext2fs.c b/genext2fs.c -index f0d797d..284862d 100644 ---- a/genext2fs.c -+++ b/genext2fs.c -@@ -107,10 +107,8 @@ - - #if HAVE_DIRENT_H - # include --# define NAMLEN(dirent) strlen((dirent)->d_name) - #else - # define dirent direct --# define NAMLEN(dirent) (dirent)->d_namlen - # if HAVE_SYS_NDIR_H - # include - # endif -@@ -1441,7 +1439,8 @@ mkfile_fs(filesystem *fs, uint32 parent_nod, const char *name, uint32 mode, size - if(!(b = (uint8*)calloc(rndup(size, BLOCKSIZE), 1))) - error_msg_and_die("not enough mem to read file '%s'", name); - if(f) -- fread(b, size, 1, f); // FIXME: ugly. use mmap() ... -+ if (fread(b, size, 1, f) != 1) // FIXME: ugly. use mmap() ... -+ error_msg_and_die("fread failed"); - extend_blk(fs, nod, b, rndup(size, BLOCKSIZE) / BLOCKSIZE); - free(b); - } -@@ -1673,7 +1672,9 @@ add2fs_from_dir(filesystem *fs, uint32 this_nod, int squash_uids, int squash_per - if(chdir(dent->d_name) < 0) - perror_msg_and_die(dent->d_name); - add2fs_from_dir(fs, this_nod, squash_uids, squash_perms, fs_timestamp, stats); -- chdir(".."); -+ if (chdir("..") == -1) -+ perror_msg_and_die(".."); -+ - break; - default: - break; -@@ -1687,7 +1688,8 @@ add2fs_from_dir(filesystem *fs, uint32 this_nod, int squash_uids, int squash_per - if(chdir(dent->d_name) < 0) - perror_msg_and_die(name); - add2fs_from_dir(fs, nod, squash_uids, squash_perms, fs_timestamp, stats); -- chdir(".."); -+ if (chdir("..") == -1) -+ perror_msg_and_die(".."); - } - continue; - } -@@ -1733,7 +1735,8 @@ add2fs_from_dir(filesystem *fs, uint32 this_nod, int squash_uids, int squash_per - if(chdir(dent->d_name) < 0) - perror_msg_and_die(name); - add2fs_from_dir(fs, nod, squash_uids, squash_perms, fs_timestamp, stats); -- chdir(".."); -+ if (chdir("..") == -1) -+ perror_msg_and_die(".."); - break; - default: - error_msg("ignoring entry %s", name); --- -1.7.4.1 - diff --git a/meta/recipes-devtools/genext2fs/genext2fs-1.4.1/0002-Add-put_blk-and-put_nod-routines.patch b/meta/recipes-devtools/genext2fs/genext2fs-1.4.1/0002-Add-put_blk-and-put_nod-routines.patch deleted file mode 100644 index ddcd052edc..0000000000 --- a/meta/recipes-devtools/genext2fs/genext2fs-1.4.1/0002-Add-put_blk-and-put_nod-routines.patch +++ /dev/null @@ -1,1123 +0,0 @@ -Upstream-Status: inappropriate - -From 8dd6e604777ffeb4d30921592f199cd9bcc8a3e2 Mon Sep 17 00:00:00 2001 -From: Corey Minyard -Date: Sat, 4 Jun 2011 15:23:29 -0500 -Subject: [PATCH 02/19] Add put_blk and put_nod routines - -Add the routines to mark that we are done with a block or inode, and -add the info structures so that get and put will work. This doesn't -do anything functionally, just getting ready for future changes. - -Most of the changes are pretty straightforward. There were changes in -get_nod() because it could use a later block than the one actually -fetches. And walk_bw() needed some special handling to avoid using data -after the put routine. ---- - genext2fs.c | 480 ++++++++++++++++++++++++++++++++++++++++------------------- - 1 files changed, 330 insertions(+), 150 deletions(-) - -diff --git a/genext2fs.c b/genext2fs.c -index 284862d..bd06369 100644 ---- a/genext2fs.c -+++ b/genext2fs.c -@@ -236,18 +236,22 @@ struct stats { - (((fs)->sb.s_blocks_count - fs->sb.s_first_data_block + \ - (fs)->sb.s_blocks_per_group - 1) / (fs)->sb.s_blocks_per_group) - --// Get group block bitmap (bbm) given the group number --#define GRP_GET_GROUP_BBM(fs,grp) ( get_blk((fs),(fs)->gd[(grp)].bg_block_bitmap) ) -+// Get/put group block bitmap (bbm) given the group number -+#define GRP_GET_GROUP_BBM(fs,grp,bi) ( get_blk((fs),(fs)->gd[(grp)].bg_block_bitmap,(bi)) ) -+#define GRP_PUT_GROUP_BBM(bi) ( put_blk((bi)) ) - --// Get group inode bitmap (ibm) given the group number --#define GRP_GET_GROUP_IBM(fs,grp) ( get_blk((fs),(fs)->gd[(grp)].bg_inode_bitmap) ) -+// Get/put group inode bitmap (ibm) given the group number -+#define GRP_GET_GROUP_IBM(fs,grp,bi) ( get_blk((fs),(fs)->gd[(grp)].bg_inode_bitmap,(bi)) ) -+#define GRP_PUT_GROUP_IBM(bi) ( put_blk((bi)) ) - - // Given an inode number find the group it belongs to - #define GRP_GROUP_OF_INODE(fs,nod) ( ((nod)-1) / (fs)->sb.s_inodes_per_group) - --//Given an inode number get the inode bitmap that covers it --#define GRP_GET_INODE_BITMAP(fs,nod) \ -- ( GRP_GET_GROUP_IBM((fs),GRP_GROUP_OF_INODE((fs),(nod))) ) -+//Given an inode number get/put the inode bitmap that covers it -+#define GRP_GET_INODE_BITMAP(fs,nod,bi) \ -+ ( GRP_GET_GROUP_IBM((fs),GRP_GROUP_OF_INODE((fs),(nod)),(bi)) ) -+#define GRP_PUT_INODE_BITMAP(bi) \ -+ ( GRP_PUT_GROUP_IBM((bi)) ) - - //Given an inode number find its offset within the inode bitmap that covers it - #define GRP_IBM_OFFSET(fs,nod) \ -@@ -256,9 +260,11 @@ struct stats { - // Given a block number find the group it belongs to - #define GRP_GROUP_OF_BLOCK(fs,blk) ( ((blk)-1) / (fs)->sb.s_blocks_per_group) - --//Given a block number get the block bitmap that covers it --#define GRP_GET_BLOCK_BITMAP(fs,blk) \ -- ( GRP_GET_GROUP_BBM((fs),GRP_GROUP_OF_BLOCK((fs),(blk))) ) -+//Given a block number get/put the block bitmap that covers it -+#define GRP_GET_BLOCK_BITMAP(fs,blk,bi) \ -+ ( GRP_GET_GROUP_BBM((fs),GRP_GROUP_OF_BLOCK((fs),(blk)),(bi)) ) -+#define GRP_PUT_BLOCK_BITMAP(bi) \ -+ ( GRP_PUT_GROUP_BBM((bi)) ) - - //Given a block number find its offset within the block bitmap that covers it - #define GRP_BBM_OFFSET(fs,blk) \ -@@ -811,24 +817,59 @@ allocated(block b, uint32 item) - return b[(item-1) / 8] & (1 << ((item-1) % 8)); - } - --// return a given block from a filesystem -+// Used by get_blk/put_blk to hold information about a block owned -+// by the user. -+typedef struct -+{ -+ int dummy; -+} blk_info; -+ -+// Return a given block from a filesystem. Make sure to call -+// put_blk when you are done with it. - static inline uint8 * --get_blk(filesystem *fs, uint32 blk) -+get_blk(filesystem *fs, uint32 blk, blk_info **rbi) - { - return (uint8*)fs + blk*BLOCKSIZE; - } - --// return a given inode from a filesystem -+static inline void -+put_blk(blk_info *bi) -+{ -+} -+ -+// Used by get_nod/put_nod to hold information about an inode owned -+// by the user. -+typedef struct -+{ -+ blk_info *bi; -+} nod_info; -+ -+// Return a given inode from a filesystem. Make sure to call put_nod() -+// when you are done with the inode. - static inline inode * --get_nod(filesystem *fs, uint32 nod) -+get_nod(filesystem *fs, uint32 nod, nod_info **rni) - { -- int grp,offset; -+ int grp, offset, boffset; - inode *itab; -+ nod_info *ni; - -- offset = GRP_IBM_OFFSET(fs,nod); -+ offset = GRP_IBM_OFFSET(fs,nod) - 1; -+ boffset = offset / (BLOCKSIZE / sizeof(inode)); -+ offset %= BLOCKSIZE / sizeof(inode); - grp = GRP_GROUP_OF_INODE(fs,nod); -- itab = (inode *)get_blk(fs, fs->gd[grp].bg_inode_table); -- return itab+offset-1; -+ ni = malloc(sizeof(*ni)); -+ if (!ni) -+ error_msg_and_die("get_nod: out of memory"); -+ itab = (inode *)get_blk(fs, fs->gd[grp].bg_inode_table + boffset, &ni->bi); -+ *rni = ni; -+ return itab+offset; -+} -+ -+static inline void -+put_nod(nod_info *ni) -+{ -+ put_blk(ni->bi); -+ free(ni); - } - - // allocate a given block/inode in the bitmap -@@ -870,12 +911,17 @@ alloc_blk(filesystem *fs, uint32 nod) - { - uint32 bk=0; - uint32 grp,nbgroups; -+ blk_info *bi; - - grp = GRP_GROUP_OF_INODE(fs,nod); - nbgroups = GRP_NBGROUPS(fs); -- if(!(bk = allocate(get_blk(fs,fs->gd[grp].bg_block_bitmap), 0))) { -- for(grp=0;grpgd[grp].bg_block_bitmap),0); -+ bk = allocate(get_blk(fs, fs->gd[grp].bg_block_bitmap, &bi), 0); -+ put_blk(bi); -+ if (!bk) { -+ for (grp=0; grpgd[grp].bg_block_bitmap, &bi), 0); -+ put_blk(bi); -+ } - grp--; - } - if (!bk) -@@ -892,10 +938,12 @@ static void - free_blk(filesystem *fs, uint32 bk) - { - uint32 grp; -+ blk_info *bi; - - grp = bk / fs->sb.s_blocks_per_group; - bk %= fs->sb.s_blocks_per_group; -- deallocate(get_blk(fs,fs->gd[grp].bg_block_bitmap), bk); -+ deallocate(get_blk(fs, fs->gd[grp].bg_block_bitmap, &bi), bk); -+ put_blk(bi); - fs->gd[grp].bg_free_blocks_count++; - fs->sb.s_free_blocks_count++; - } -@@ -906,6 +954,7 @@ alloc_nod(filesystem *fs) - { - uint32 nod,best_group=0; - uint32 grp,nbgroups,avefreei; -+ blk_info *bi; - - nbgroups = GRP_NBGROUPS(fs); - -@@ -923,8 +972,10 @@ alloc_nod(filesystem *fs) - fs->gd[grp].bg_free_blocks_count > fs->gd[best_group].bg_free_blocks_count) - best_group = grp; - } -- if (!(nod = allocate(get_blk(fs,fs->gd[best_group].bg_inode_bitmap),0))) -+ if (!(nod = allocate(get_blk(fs, fs->gd[best_group].bg_inode_bitmap, -+ &bi), 0))) - error_msg_and_die("couldn't allocate an inode (no free inode)"); -+ put_blk(bi); - if(!(fs->gd[best_group].bg_free_inodes_count--)) - error_msg_and_die("group descr. free blocks count == 0 (corrupted fs?)"); - if(!(fs->sb.s_free_inodes_count--)) -@@ -968,24 +1019,35 @@ static uint32 - walk_bw(filesystem *fs, uint32 nod, blockwalker *bw, int32 *create, uint32 hole) - { - uint32 *bkref = 0; -+ uint32 bk = 0; - uint32 *b; - int extend = 0, reduce = 0; -+ inode *inod; -+ nod_info *ni; -+ uint32 *iblk; -+ blk_info *bi1 = NULL, *bi2 = NULL, *bi3 = NULL; -+ - if(create && (*create) < 0) - reduce = 1; -- if(bw->bnum >= get_nod(fs, nod)->i_blocks / INOBLK) -+ inod = get_nod(fs, nod, &ni); -+ if(bw->bnum >= inod->i_blocks / INOBLK) - { - if(create && (*create) > 0) - { - (*create)--; - extend = 1; - } -- else -+ else -+ { -+ put_nod(ni); - return WALK_END; -+ } - } -+ iblk = inod->i_block; - // first direct block - if(bw->bpdir == EXT2_INIT_BLOCK) - { -- bkref = &get_nod(fs, nod)->i_block[bw->bpdir = 0]; -+ bkref = &iblk[bw->bpdir = 0]; - if(extend) // allocate first block - *bkref = hole ? 0 : alloc_blk(fs,nod); - if(reduce) // free first block -@@ -994,7 +1056,7 @@ walk_bw(filesystem *fs, uint32 nod, blockwalker *bw, int32 *create, uint32 hole) - // direct block - else if(bw->bpdir < EXT2_NDIR_BLOCKS) - { -- bkref = &get_nod(fs, nod)->i_block[++bw->bpdir]; -+ bkref = &iblk[++bw->bpdir]; - if(extend) // allocate block - *bkref = hole ? 0 : alloc_blk(fs,nod); - if(reduce) // free block -@@ -1007,10 +1069,10 @@ walk_bw(filesystem *fs, uint32 nod, blockwalker *bw, int32 *create, uint32 hole) - bw->bpdir = EXT2_IND_BLOCK; - bw->bpind = 0; - if(extend) // allocate indirect block -- get_nod(fs, nod)->i_block[bw->bpdir] = alloc_blk(fs,nod); -+ iblk[bw->bpdir] = alloc_blk(fs,nod); - if(reduce) // free indirect block -- free_blk(fs, get_nod(fs, nod)->i_block[bw->bpdir]); -- b = (uint32*)get_blk(fs, get_nod(fs, nod)->i_block[bw->bpdir]); -+ free_blk(fs, iblk[bw->bpdir]); -+ b = (uint32*)get_blk(fs, iblk[bw->bpdir], &bi1); - bkref = &b[bw->bpind]; - if(extend) // allocate first block - *bkref = hole ? 0 : alloc_blk(fs,nod); -@@ -1021,7 +1083,7 @@ walk_bw(filesystem *fs, uint32 nod, blockwalker *bw, int32 *create, uint32 hole) - else if((bw->bpdir == EXT2_IND_BLOCK) && (bw->bpind < BLOCKSIZE/4 - 1)) - { - bw->bpind++; -- b = (uint32*)get_blk(fs, get_nod(fs, nod)->i_block[bw->bpdir]); -+ b = (uint32*)get_blk(fs, iblk[bw->bpdir], &bi1); - bkref = &b[bw->bpind]; - if(extend) // allocate block - *bkref = hole ? 0 : alloc_blk(fs,nod); -@@ -1036,15 +1098,15 @@ walk_bw(filesystem *fs, uint32 nod, blockwalker *bw, int32 *create, uint32 hole) - bw->bpind = 0; - bw->bpdind = 0; - if(extend) // allocate double indirect block -- get_nod(fs, nod)->i_block[bw->bpdir] = alloc_blk(fs,nod); -+ iblk[bw->bpdir] = alloc_blk(fs,nod); - if(reduce) // free double indirect block -- free_blk(fs, get_nod(fs, nod)->i_block[bw->bpdir]); -- b = (uint32*)get_blk(fs, get_nod(fs, nod)->i_block[bw->bpdir]); -+ free_blk(fs, iblk[bw->bpdir]); -+ b = (uint32*)get_blk(fs, iblk[bw->bpdir], &bi1); - if(extend) // allocate first indirect block - b[bw->bpind] = alloc_blk(fs,nod); - if(reduce) // free firstindirect block - free_blk(fs, b[bw->bpind]); -- b = (uint32*)get_blk(fs, b[bw->bpind]); -+ b = (uint32*)get_blk(fs, b[bw->bpind], &bi1); - bkref = &b[bw->bpdind]; - if(extend) // allocate first block - *bkref = hole ? 0 : alloc_blk(fs,nod); -@@ -1055,8 +1117,8 @@ walk_bw(filesystem *fs, uint32 nod, blockwalker *bw, int32 *create, uint32 hole) - else if((bw->bpdir == EXT2_DIND_BLOCK) && (bw->bpdind < BLOCKSIZE/4 - 1)) - { - bw->bpdind++; -- b = (uint32*)get_blk(fs, get_nod(fs, nod)->i_block[bw->bpdir]); -- b = (uint32*)get_blk(fs, b[bw->bpind]); -+ b = (uint32*)get_blk(fs, iblk[bw->bpdir], &bi1); -+ b = (uint32*)get_blk(fs, b[bw->bpind], &bi2); - bkref = &b[bw->bpdind]; - if(extend) // allocate block - *bkref = hole ? 0 : alloc_blk(fs,nod); -@@ -1069,12 +1131,12 @@ walk_bw(filesystem *fs, uint32 nod, blockwalker *bw, int32 *create, uint32 hole) - bw->bnum++; - bw->bpdind = 0; - bw->bpind++; -- b = (uint32*)get_blk(fs, get_nod(fs, nod)->i_block[bw->bpdir]); -+ b = (uint32*)get_blk(fs, iblk[bw->bpdir], &bi1); - if(extend) // allocate indirect block - b[bw->bpind] = alloc_blk(fs,nod); - if(reduce) // free indirect block - free_blk(fs, b[bw->bpind]); -- b = (uint32*)get_blk(fs, b[bw->bpind]); -+ b = (uint32*)get_blk(fs, b[bw->bpind], &bi2); - bkref = &b[bw->bpdind]; - if(extend) // allocate first block - *bkref = hole ? 0 : alloc_blk(fs,nod); -@@ -1094,20 +1156,20 @@ walk_bw(filesystem *fs, uint32 nod, blockwalker *bw, int32 *create, uint32 hole) - bw->bpdind = 0; - bw->bptind = 0; - if(extend) // allocate triple indirect block -- get_nod(fs, nod)->i_block[bw->bpdir] = alloc_blk(fs,nod); -+ iblk[bw->bpdir] = alloc_blk(fs,nod); - if(reduce) // free triple indirect block -- free_blk(fs, get_nod(fs, nod)->i_block[bw->bpdir]); -- b = (uint32*)get_blk(fs, get_nod(fs, nod)->i_block[bw->bpdir]); -+ free_blk(fs, iblk[bw->bpdir]); -+ b = (uint32*)get_blk(fs, iblk[bw->bpdir], &bi1); - if(extend) // allocate first double indirect block - b[bw->bpind] = alloc_blk(fs,nod); - if(reduce) // free first double indirect block - free_blk(fs, b[bw->bpind]); -- b = (uint32*)get_blk(fs, b[bw->bpind]); -+ b = (uint32*)get_blk(fs, b[bw->bpind], &bi2); - if(extend) // allocate first indirect block - b[bw->bpdind] = alloc_blk(fs,nod); - if(reduce) // free first indirect block - free_blk(fs, b[bw->bpind]); -- b = (uint32*)get_blk(fs, b[bw->bpdind]); -+ b = (uint32*)get_blk(fs, b[bw->bpdind], &bi3); - bkref = &b[bw->bptind]; - if(extend) // allocate first data block - *bkref = hole ? 0 : alloc_blk(fs,nod); -@@ -1121,9 +1183,9 @@ walk_bw(filesystem *fs, uint32 nod, blockwalker *bw, int32 *create, uint32 hole) - (bw->bptind < BLOCKSIZE/4 -1) ) - { - bw->bptind++; -- b = (uint32*)get_blk(fs, get_nod(fs, nod)->i_block[bw->bpdir]); -- b = (uint32*)get_blk(fs, b[bw->bpind]); -- b = (uint32*)get_blk(fs, b[bw->bpdind]); -+ b = (uint32*)get_blk(fs, iblk[bw->bpdir], &bi1); -+ b = (uint32*)get_blk(fs, b[bw->bpind], &bi2); -+ b = (uint32*)get_blk(fs, b[bw->bpdind], &bi3); - bkref = &b[bw->bptind]; - if(extend) // allocate data block - *bkref = hole ? 0 : alloc_blk(fs,nod); -@@ -1140,13 +1202,13 @@ walk_bw(filesystem *fs, uint32 nod, blockwalker *bw, int32 *create, uint32 hole) - bw->bnum++; - bw->bptind = 0; - bw->bpdind++; -- b = (uint32*)get_blk(fs, get_nod(fs, nod)->i_block[bw->bpdir]); -- b = (uint32*)get_blk(fs, b[bw->bpind]); -+ b = (uint32*)get_blk(fs, iblk[bw->bpdir], &bi1); -+ b = (uint32*)get_blk(fs, b[bw->bpind], &bi2); - if(extend) // allocate single indirect block - b[bw->bpdind] = alloc_blk(fs,nod); - if(reduce) // free indirect block - free_blk(fs, b[bw->bpind]); -- b = (uint32*)get_blk(fs, b[bw->bpdind]); -+ b = (uint32*)get_blk(fs, b[bw->bpdind], &bi3); - bkref = &b[bw->bptind]; - if(extend) // allocate first data block - *bkref = hole ? 0 : alloc_blk(fs,nod); -@@ -1163,17 +1225,17 @@ walk_bw(filesystem *fs, uint32 nod, blockwalker *bw, int32 *create, uint32 hole) - bw->bpdind = 0; - bw->bptind = 0; - bw->bpind++; -- b = (uint32*)get_blk(fs, get_nod(fs, nod)->i_block[bw->bpdir]); -+ b = (uint32*)get_blk(fs, iblk[bw->bpdir], &bi1); - if(extend) // allocate double indirect block - b[bw->bpind] = alloc_blk(fs,nod); - if(reduce) // free double indirect block - free_blk(fs, b[bw->bpind]); -- b = (uint32*)get_blk(fs, b[bw->bpind]); -+ b = (uint32*)get_blk(fs, b[bw->bpind], &bi2); - if(extend) // allocate single indirect block - b[bw->bpdind] = alloc_blk(fs,nod); - if(reduce) // free indirect block - free_blk(fs, b[bw->bpind]); -- b = (uint32*)get_blk(fs, b[bw->bpdind]); -+ b = (uint32*)get_blk(fs, b[bw->bpdind], &bi3); - bkref = &b[bw->bptind]; - if(extend) // allocate first block - *bkref = hole ? 0 : alloc_blk(fs,nod); -@@ -1184,15 +1246,28 @@ walk_bw(filesystem *fs, uint32 nod, blockwalker *bw, int32 *create, uint32 hole) - error_msg_and_die("file too big !"); - /* End change for walking triple indirection */ - -- if(*bkref) -+ bk = *bkref; -+ if (bi3) -+ put_blk(bi3); -+ if (bi2) -+ put_blk(bi2); -+ if (bi1) -+ put_blk(bi1); -+ -+ if(bk) - { -+ blk_info *bi; -+ uint8 *block; - bw->bnum++; -- if(!reduce && !allocated(GRP_GET_BLOCK_BITMAP(fs,*bkref), GRP_BBM_OFFSET(fs,*bkref))) -- error_msg_and_die("[block %d of inode %d is unallocated !]", *bkref, nod); -+ block = GRP_GET_BLOCK_BITMAP(fs,bk,&bi); -+ if(!reduce && !allocated(block, GRP_BBM_OFFSET(fs,bk))) -+ error_msg_and_die("[block %d of inode %d is unallocated !]", bk, nod); -+ GRP_PUT_BLOCK_BITMAP(bi); - } - if(extend) -- get_nod(fs, nod)->i_blocks = bw->bnum * INOBLK; -- return *bkref; -+ inod->i_blocks = bw->bnum * INOBLK; -+ put_nod(ni); -+ return bk; - } - - // add blocks to an inode (file/dir/etc...) -@@ -1202,15 +1277,19 @@ extend_blk(filesystem *fs, uint32 nod, block b, int amount) - int create = amount; - blockwalker bw, lbw; - uint32 bk; -+ nod_info *ni; -+ inode *inod; -+ -+ inod = get_nod(fs, nod, &ni); - init_bw(&bw); - if(amount < 0) - { - uint32 i; -- for(i = 0; i < get_nod(fs, nod)->i_blocks / INOBLK + amount; i++) -+ for(i = 0; i < inod->i_blocks / INOBLK + amount; i++) - walk_bw(fs, nod, &bw, 0, 0); - while(walk_bw(fs, nod, &bw, &create, 0) != WALK_END) - /*nop*/; -- get_nod(fs, nod)->i_blocks += amount * INOBLK; -+ inod->i_blocks += amount * INOBLK; - } - else - { -@@ -1232,8 +1311,11 @@ extend_blk(filesystem *fs, uint32 nod, block b, int amount) - } - if((bk = walk_bw(fs, nod, &bw, &create, !copyb)) == WALK_END) - break; -- if(copyb) -- memcpy(get_blk(fs, bk), b + BLOCKSIZE * (amount - create - 1), BLOCKSIZE); -+ if(copyb) { -+ blk_info *bi; -+ memcpy(get_blk(fs, bk, &bi), b + BLOCKSIZE * (amount - create - 1), BLOCKSIZE); -+ put_blk(bi); -+ } - } - } - } -@@ -1245,12 +1327,14 @@ add2dir(filesystem *fs, uint32 dnod, uint32 nod, const char* name) - blockwalker bw; - uint32 bk; - uint8 *b; -+ blk_info *bi; - directory *d; - int reclen, nlen; - inode *node; - inode *pnode; -+ nod_info *dni, *ni; - -- pnode = get_nod(fs, dnod); -+ pnode = get_nod(fs, dnod, &dni); - if((pnode->i_mode & FM_IFMT) != FM_IFDIR) - error_msg_and_die("can't add '%s' to a non-directory", name); - if(!*name) -@@ -1264,7 +1348,7 @@ add2dir(filesystem *fs, uint32 dnod, uint32 nod, const char* name) - init_bw(&bw); - while((bk = walk_bw(fs, dnod, &bw, 0, 0)) != WALK_END) // for all blocks in dir - { -- b = get_blk(fs, bk); -+ b = get_blk(fs, bk, &bi); - // for all dir entries in block - for(d = (directory*)b; (int8*)d + sizeof(*d) < (int8*)b + BLOCKSIZE; d = (directory*)((int8*)d + d->d_rec_len)) - { -@@ -1272,11 +1356,12 @@ add2dir(filesystem *fs, uint32 dnod, uint32 nod, const char* name) - if((!d->d_inode) && (d->d_rec_len >= reclen)) - { - d->d_inode = nod; -- node = get_nod(fs, nod); -+ node = get_nod(fs, nod, &ni); - node->i_links_count++; - d->d_name_len = nlen; - strncpy(d->d_name, name, nlen); -- return; -+ put_nod(ni); -+ goto out; - } - // if entry with enough room (last one?), shrink it & use it - if(d->d_rec_len >= (sizeof(directory) + rndup(d->d_name_len, 4) + reclen)) -@@ -1287,11 +1372,12 @@ add2dir(filesystem *fs, uint32 dnod, uint32 nod, const char* name) - d = (directory*) (((int8*)d) + d->d_rec_len); - d->d_rec_len = reclen; - d->d_inode = nod; -- node = get_nod(fs, nod); -+ node = get_nod(fs, nod, &ni); - node->i_links_count++; - d->d_name_len = nlen; - strncpy(d->d_name, name, nlen); -- return; -+ put_nod(ni); -+ goto out; - } - } - } -@@ -1300,14 +1386,17 @@ add2dir(filesystem *fs, uint32 dnod, uint32 nod, const char* name) - error_msg_and_die("get_workblk() failed."); - d = (directory*)b; - d->d_inode = nod; -- node = get_nod(fs, nod); -+ node = get_nod(fs, nod, &ni); - node->i_links_count++; -+ put_nod(ni); - d->d_rec_len = BLOCKSIZE; - d->d_name_len = nlen; - strncpy(d->d_name, name, nlen); - extend_blk(fs, dnod, b, 1); -- get_nod(fs, dnod)->i_size += BLOCKSIZE; -+ pnode->i_size += BLOCKSIZE; - free_workblk(b); -+out: -+ put_nod(dni); - } - - // find an entry in a directory -@@ -1316,16 +1405,20 @@ find_dir(filesystem *fs, uint32 nod, const char * name) - { - blockwalker bw; - uint32 bk; -+ blk_info *bi; - int nlen = strlen(name); - init_bw(&bw); - while((bk = walk_bw(fs, nod, &bw, 0, 0)) != WALK_END) - { - directory *d; - uint8 *b; -- b = get_blk(fs, bk); -+ b = get_blk(fs, bk, &bi); - for(d = (directory*)b; (int8*)d + sizeof(*d) < (int8*)b + BLOCKSIZE; d = (directory*)((int8*)d + d->d_rec_len)) -- if(d->d_inode && (nlen == d->d_name_len) && !strncmp(d->d_name, name, nlen)) -+ if(d->d_inode && (nlen == d->d_name_len) && !strncmp(d->d_name, name, nlen)) { -+ put_blk(bi); - return d->d_inode; -+ } -+ put_blk(bi); - } - return 0; - } -@@ -1361,10 +1454,12 @@ void - chmod_fs(filesystem *fs, uint32 nod, uint16 mode, uint16 uid, uint16 gid) - { - inode *node; -- node = get_nod(fs, nod); -+ nod_info *ni; -+ node = get_nod(fs, nod, &ni); - node->i_mode = (node->i_mode & ~FM_IMASK) | (mode & FM_IMASK); - node->i_uid = uid; - node->i_gid = gid; -+ put_nod(ni); - } - - // create a simple inode -@@ -1373,33 +1468,34 @@ mknod_fs(filesystem *fs, uint32 parent_nod, const char *name, uint16 mode, uint1 - { - uint32 nod; - inode *node; -+ nod_info *ni; -+ -+ nod = alloc_nod(fs); -+ node = get_nod(fs, nod, &ni); -+ node->i_mode = mode; -+ add2dir(fs, parent_nod, nod, name); -+ switch(mode & FM_IFMT) - { -- nod = alloc_nod(fs); -- node = get_nod(fs, nod); -- node->i_mode = mode; -- add2dir(fs, parent_nod, nod, name); -- switch(mode & FM_IFMT) -- { -- case FM_IFLNK: -- mode = FM_IFLNK | FM_IRWXU | FM_IRWXG | FM_IRWXO; -- break; -- case FM_IFBLK: -- case FM_IFCHR: -- ((uint8*)get_nod(fs, nod)->i_block)[0] = minor; -- ((uint8*)get_nod(fs, nod)->i_block)[1] = major; -- break; -- case FM_IFDIR: -- add2dir(fs, nod, nod, "."); -- add2dir(fs, nod, parent_nod, ".."); -- fs->gd[GRP_GROUP_OF_INODE(fs,nod)].bg_used_dirs_count++; -- break; -- } -+ case FM_IFLNK: -+ mode = FM_IFLNK | FM_IRWXU | FM_IRWXG | FM_IRWXO; -+ break; -+ case FM_IFBLK: -+ case FM_IFCHR: -+ ((uint8*)node->i_block)[0] = minor; -+ ((uint8*)node->i_block)[1] = major; -+ break; -+ case FM_IFDIR: -+ add2dir(fs, nod, nod, "."); -+ add2dir(fs, nod, parent_nod, ".."); -+ fs->gd[GRP_GROUP_OF_INODE(fs,nod)].bg_used_dirs_count++; -+ break; - } - node->i_uid = uid; - node->i_gid = gid; - node->i_atime = mtime; - node->i_ctime = ctime; - node->i_mtime = mtime; -+ put_nod(ni); - return nod; - } - -@@ -1416,14 +1512,19 @@ static uint32 - mklink_fs(filesystem *fs, uint32 parent_nod, const char *name, size_t size, uint8 *b, uid_t uid, gid_t gid, uint32 ctime, uint32 mtime) - { - uint32 nod = mknod_fs(fs, parent_nod, name, FM_IFLNK | FM_IRWXU | FM_IRWXG | FM_IRWXO, uid, gid, 0, 0, ctime, mtime); -- extend_blk(fs, nod, 0, - (int)get_nod(fs, nod)->i_blocks / INOBLK); -- get_nod(fs, nod)->i_size = size; -+ nod_info *ni; -+ inode *node = get_nod(fs, nod, &ni); -+ -+ extend_blk(fs, nod, 0, - (int)node->i_blocks / INOBLK); -+ node->i_size = size; - if(size <= 4 * (EXT2_TIND_BLOCK+1)) - { -- strncpy((char*)get_nod(fs, nod)->i_block, (char*)b, size); -+ strncpy((char *)node->i_block, (char *)b, size); -+ put_nod(ni); - return nod; - } - extend_blk(fs, nod, b, rndup(size, BLOCKSIZE) / BLOCKSIZE); -+ put_nod(ni); - return nod; - } - -@@ -1433,8 +1534,11 @@ mkfile_fs(filesystem *fs, uint32 parent_nod, const char *name, uint32 mode, size - { - uint8 * b; - uint32 nod = mknod_fs(fs, parent_nod, name, mode|FM_IFREG, uid, gid, 0, 0, ctime, mtime); -- extend_blk(fs, nod, 0, - (int)get_nod(fs, nod)->i_blocks / INOBLK); -- get_nod(fs, nod)->i_size = size; -+ nod_info *ni; -+ inode *node = get_nod(fs, nod, &ni); -+ -+ extend_blk(fs, nod, 0, - (int)node->i_blocks / INOBLK); -+ node->i_size = size; - if (size) { - if(!(b = (uint8*)calloc(rndup(size, BLOCKSIZE), 1))) - error_msg_and_die("not enough mem to read file '%s'", name); -@@ -1444,6 +1548,7 @@ mkfile_fs(filesystem *fs, uint32 parent_nod, const char *name, uint32 mode, size - extend_blk(fs, nod, b, rndup(size, BLOCKSIZE) / BLOCKSIZE); - free(b); - } -+ put_nod(ni); - return nod; - } - -@@ -1766,6 +1871,7 @@ swap_goodblocks(filesystem *fs, inode *nod) - uint32 i,j; - int done=0; - uint32 *b,*b2; -+ blk_info *bi, *bi2, *bi3; - - uint32 nblk = nod->i_blocks / INOBLK; - if((nod->i_size && !nblk) || ((nod->i_mode & FM_IFBLK) == FM_IFBLK) || ((nod->i_mode & FM_IFCHR) == FM_IFCHR)) -@@ -1773,7 +1879,8 @@ swap_goodblocks(filesystem *fs, inode *nod) - nod->i_block[i] = swab32(nod->i_block[i]); - if(nblk <= EXT2_IND_BLOCK) - return; -- swap_block(get_blk(fs, nod->i_block[EXT2_IND_BLOCK])); -+ swap_block(get_blk(fs, nod->i_block[EXT2_IND_BLOCK], &bi)); -+ put_blk(bi); - if(nblk <= EXT2_DIND_BLOCK + BLOCKSIZE/4) - return; - /* Currently this will fail b'cos the number of blocks as stored -@@ -1791,29 +1898,37 @@ swap_goodblocks(filesystem *fs, inode *nod) - // ths function needs to be fixed for the same reasons - Xav - assert(nod->i_block[EXT2_DIND_BLOCK] != 0); - for(i = 0; i < BLOCKSIZE/4; i++) -- if(nblk > EXT2_IND_BLOCK + BLOCKSIZE/4 + (BLOCKSIZE/4)*i ) -- swap_block(get_blk(fs, ((uint32*)get_blk(fs, nod->i_block[EXT2_DIND_BLOCK]))[i])); -- swap_block(get_blk(fs, nod->i_block[EXT2_DIND_BLOCK])); -+ if(nblk > EXT2_IND_BLOCK + BLOCKSIZE/4 + (BLOCKSIZE/4)*i ) { -+ swap_block(get_blk(fs, ((uint32*)get_blk(fs, nod->i_block[EXT2_DIND_BLOCK], &bi))[i], &bi2)); -+ put_blk(bi); -+ put_blk(bi2); -+ } -+ swap_block(get_blk(fs, nod->i_block[EXT2_DIND_BLOCK], &bi)); -+ put_blk(bi); - if(nblk <= EXT2_IND_BLOCK + BLOCKSIZE/4 + BLOCKSIZE/4 * BLOCKSIZE/4) - return; - /* Adding support for triple indirection */ -- b = (uint32*)get_blk(fs,nod->i_block[EXT2_TIND_BLOCK]); -+ b = (uint32*)get_blk(fs,nod->i_block[EXT2_TIND_BLOCK], &bi); - for(i=0;i < BLOCKSIZE/4 && !done ; i++) { -- b2 = (uint32*)get_blk(fs,b[i]); -+ b2 = (uint32*)get_blk(fs,b[i], &bi2); - for(j=0; j ( EXT2_IND_BLOCK + BLOCKSIZE/4 + - (BLOCKSIZE/4)*(BLOCKSIZE/4) + - i*(BLOCKSIZE/4)*(BLOCKSIZE/4) + -- j*(BLOCKSIZE/4)) ) -- swap_block(get_blk(fs,b2[j])); -+ j*(BLOCKSIZE/4)) ) { -+ swap_block(get_blk(fs,b2[j],&bi3)); -+ put_blk(bi3); -+ } - else { - done = 1; - break; - } - } - swap_block((uint8 *)b2); -+ put_blk(bi2); - } - swap_block((uint8 *)b); -+ put_blk(bi); - return; - } - -@@ -1823,6 +1938,7 @@ swap_badblocks(filesystem *fs, inode *nod) - uint32 i,j; - int done=0; - uint32 *b,*b2; -+ blk_info *bi, *bi2, *bi3; - - uint32 nblk = nod->i_blocks / INOBLK; - if((nod->i_size && !nblk) || ((nod->i_mode & FM_IFBLK) == FM_IFBLK) || ((nod->i_mode & FM_IFCHR) == FM_IFCHR)) -@@ -1830,35 +1946,44 @@ swap_badblocks(filesystem *fs, inode *nod) - nod->i_block[i] = swab32(nod->i_block[i]); - if(nblk <= EXT2_IND_BLOCK) - return; -- swap_block(get_blk(fs, nod->i_block[EXT2_IND_BLOCK])); -+ swap_block(get_blk(fs, nod->i_block[EXT2_IND_BLOCK], &bi)); -+ put_blk(bi); - if(nblk <= EXT2_DIND_BLOCK + BLOCKSIZE/4) - return; - /* See comment in swap_goodblocks */ - assert(nod->i_block[EXT2_DIND_BLOCK] != 0); -- swap_block(get_blk(fs, nod->i_block[EXT2_DIND_BLOCK])); -+ swap_block(get_blk(fs, nod->i_block[EXT2_DIND_BLOCK], &bi)); -+ put_blk(bi); - for(i = 0; i < BLOCKSIZE/4; i++) -- if(nblk > EXT2_IND_BLOCK + BLOCKSIZE/4 + (BLOCKSIZE/4)*i ) -- swap_block(get_blk(fs, ((uint32*)get_blk(fs, nod->i_block[EXT2_DIND_BLOCK]))[i])); -+ if(nblk > EXT2_IND_BLOCK + BLOCKSIZE/4 + (BLOCKSIZE/4)*i ) { -+ swap_block(get_blk(fs, ((uint32*)get_blk(fs, nod->i_block[EXT2_DIND_BLOCK],&bi))[i], &bi2)); -+ put_blk(bi); -+ put_blk(bi2); -+ } - if(nblk <= EXT2_IND_BLOCK + BLOCKSIZE/4 + BLOCKSIZE/4 * BLOCKSIZE/4) - return; - /* Adding support for triple indirection */ -- b = (uint32*)get_blk(fs,nod->i_block[EXT2_TIND_BLOCK]); -+ b = (uint32*)get_blk(fs,nod->i_block[EXT2_TIND_BLOCK],&bi); - swap_block((uint8 *)b); - for(i=0;i < BLOCKSIZE/4 && !done ; i++) { -- b2 = (uint32*)get_blk(fs,b[i]); -+ b2 = (uint32*)get_blk(fs,b[i],&bi2); - swap_block((uint8 *)b2); - for(j=0; j ( EXT2_IND_BLOCK + BLOCKSIZE/4 + - (BLOCKSIZE/4)*(BLOCKSIZE/4) + - i*(BLOCKSIZE/4)*(BLOCKSIZE/4) + -- j*(BLOCKSIZE/4)) ) -- swap_block(get_blk(fs,b2[j])); -+ j*(BLOCKSIZE/4)) ) { -+ swap_block(get_blk(fs,b2[j],&bi3)); -+ put_blk(bi3); -+ } - else { - done = 1; - break; - } - } -+ put_blk(bi2); - } -+ put_blk(bi); - return; - } - -@@ -1867,9 +1992,11 @@ static void - swap_goodfs(filesystem *fs) - { - uint32 i; -+ nod_info *ni; -+ - for(i = 1; i < fs->sb.s_inodes_count; i++) - { -- inode *nod = get_nod(fs, i); -+ inode *nod = get_nod(fs, i, &ni); - if(nod->i_mode & FM_IFDIR) - { - blockwalker bw; -@@ -1879,13 +2006,16 @@ swap_goodfs(filesystem *fs) - { - directory *d; - uint8 *b; -- b = get_blk(fs, bk); -+ blk_info *bi; -+ b = get_blk(fs, bk, &bi); - for(d = (directory*)b; (int8*)d + sizeof(*d) < (int8*)b + BLOCKSIZE; d = (directory*)((int8*)d + swab16(d->d_rec_len))) - swap_dir(d); -+ put_blk(bi); - } - } - swap_goodblocks(fs, nod); - swap_nod(nod); -+ put_nod(ni); - } - for(i=0;igd[i])); -@@ -1901,7 +2031,8 @@ swap_badfs(filesystem *fs) - swap_gd(&(fs->gd[i])); - for(i = 1; i < fs->sb.s_inodes_count; i++) - { -- inode *nod = get_nod(fs, i); -+ nod_info *ni; -+ inode *nod = get_nod(fs, i, &ni); - swap_nod(nod); - swap_badblocks(fs, nod); - if(nod->i_mode & FM_IFDIR) -@@ -1913,9 +2044,11 @@ swap_badfs(filesystem *fs) - { - directory *d; - uint8 *b; -- b = get_blk(fs, bk); -+ blk_info *bi; -+ b = get_blk(fs, bk, &bi); - for(d = (directory*)b; (int8*)d + sizeof(*d) < (int8*)b + BLOCKSIZE; d = (directory*)((int8*)d + d->d_rec_len)) - swap_dir(d); -+ put_blk(bi); - } - } - } -@@ -1936,6 +2069,8 @@ init_fs(int nbblocks, int nbinodes, int nbresrvd, int holes, uint32 fs_timestamp - uint32 j; - uint8 *bbm,*ibm; - inode *itab0; -+ blk_info *bi; -+ nod_info *ni; - - if(nbresrvd < 0) - error_msg_and_die("reserved blocks value is invalid. Note: options have changed, see --help or the man page."); -@@ -2014,9 +2149,8 @@ init_fs(int nbblocks, int nbinodes, int nbresrvd, int holes, uint32 fs_timestamp - /* Mark non-filesystem blocks and inodes as allocated */ - /* Mark system blocks and inodes as allocated */ - for(i = 0; igd[i].bg_block_bitmap); -+ bbm = get_blk(fs,fs->gd[i].bg_block_bitmap, &bi); - //non-filesystem blocks - for(j = fs->gd[i].bg_free_blocks_count - + overhead_per_group + 1; j <= BLOCKSIZE * 8; j++) -@@ -2024,9 +2158,10 @@ init_fs(int nbblocks, int nbinodes, int nbresrvd, int holes, uint32 fs_timestamp - //system blocks - for(j = 1; j <= overhead_per_group; j++) - allocate(bbm, j); -+ put_blk(bi); - - /* Inode bitmap */ -- ibm = get_blk(fs,fs->gd[i].bg_inode_bitmap); -+ ibm = get_blk(fs,fs->gd[i].bg_inode_bitmap, &bi); - //non-filesystem inodes - for(j = fs->sb.s_inodes_per_group+1; j <= BLOCKSIZE * 8; j++) - allocate(ibm, j); -@@ -2035,6 +2170,7 @@ init_fs(int nbblocks, int nbinodes, int nbresrvd, int holes, uint32 fs_timestamp - if(i == 0) - for(j = 1; j < EXT2_FIRST_INO; j++) - allocate(ibm, j); -+ put_blk(bi); - } - - // make root inode and directory -@@ -2042,13 +2178,14 @@ init_fs(int nbblocks, int nbinodes, int nbresrvd, int holes, uint32 fs_timestamp - /* Also increment the directory count for group 0 */ - fs->gd[0].bg_free_inodes_count--; - fs->gd[0].bg_used_dirs_count = 1; -- itab0 = (inode *)get_blk(fs,fs->gd[0].bg_inode_table); -- itab0[EXT2_ROOT_INO-1].i_mode = FM_IFDIR | FM_IRWXU | FM_IRGRP | FM_IROTH | FM_IXGRP | FM_IXOTH; -- itab0[EXT2_ROOT_INO-1].i_ctime = fs_timestamp; -- itab0[EXT2_ROOT_INO-1].i_mtime = fs_timestamp; -- itab0[EXT2_ROOT_INO-1].i_atime = fs_timestamp; -- itab0[EXT2_ROOT_INO-1].i_size = BLOCKSIZE; -- itab0[EXT2_ROOT_INO-1].i_links_count = 2; -+ itab0 = get_nod(fs, EXT2_ROOT_INO, &ni); -+ itab0->i_mode = FM_IFDIR | FM_IRWXU | FM_IRGRP | FM_IROTH | FM_IXGRP | FM_IXOTH; -+ itab0->i_ctime = fs_timestamp; -+ itab0->i_mtime = fs_timestamp; -+ itab0->i_atime = fs_timestamp; -+ itab0->i_size = BLOCKSIZE; -+ itab0->i_links_count = 2; -+ put_nod(ni); - - if(!(b = get_workblk())) - error_msg_and_die("get_workblk() failed."); -@@ -2067,6 +2204,8 @@ init_fs(int nbblocks, int nbinodes, int nbresrvd, int holes, uint32 fs_timestamp - // make lost+found directory and reserve blocks - if(fs->sb.s_r_blocks_count) - { -+ inode *node; -+ - nod = mkdir_fs(fs, EXT2_ROOT_INO, "lost+found", FM_IRWXU, 0, 0, fs_timestamp, fs_timestamp); - memset(b, 0, BLOCKSIZE); - ((directory*)b)->d_rec_len = BLOCKSIZE; -@@ -2077,7 +2216,9 @@ init_fs(int nbblocks, int nbinodes, int nbresrvd, int holes, uint32 fs_timestamp - fs->sb.s_r_blocks_count = fs->sb.s_blocks_count * MAX_RESERVED_BLOCKS; - for(i = 1; i < fs->sb.s_r_blocks_count; i++) - extend_blk(fs, nod, b, 1); -- get_nod(fs, nod)->i_size = fs->sb.s_r_blocks_count * BLOCKSIZE; -+ node = get_nod(fs, nod, &ni); -+ node->i_size = fs->sb.s_r_blocks_count * BLOCKSIZE; -+ put_nod(ni); - } - free_workblk(b); - -@@ -2153,16 +2294,23 @@ write_blocks(filesystem *fs, uint32 nod, FILE* f) - { - blockwalker bw; - uint32 bk; -- int32 fsize = get_nod(fs, nod)->i_size; -+ nod_info *ni; -+ inode *node = get_nod(fs, nod, &ni); -+ int32 fsize = node->i_size; -+ blk_info *bi; -+ - init_bw(&bw); - while((bk = walk_bw(fs, nod, &bw, 0, 0)) != WALK_END) - { - if(fsize <= 0) - error_msg_and_die("wrong size while saving inode %d", nod); -- if(fwrite(get_blk(fs, bk), (fsize > BLOCKSIZE) ? BLOCKSIZE : fsize, 1, f) != 1) -+ if(fwrite(get_blk(fs, bk, &bi), -+ (fsize > BLOCKSIZE) ? BLOCKSIZE : fsize, 1, f) != 1) - error_msg_and_die("error while saving inode %d", nod); -+ put_blk(bi); - fsize -= BLOCKSIZE; - } -+ put_nod(ni); - } - - -@@ -2171,8 +2319,11 @@ static void - print_dev(filesystem *fs, uint32 nod) - { - int minor, major; -- minor = ((uint8*)get_nod(fs, nod)->i_block)[0]; -- major = ((uint8*)get_nod(fs, nod)->i_block)[1]; -+ nod_info *ni; -+ inode *node = get_nod(fs, nod, &ni); -+ minor = ((uint8*)node->i_block)[0]; -+ major = ((uint8*)node->i_block)[1]; -+ put_nod(ni); - printf("major: %d, minor: %d\n", major, minor); - } - -@@ -2188,7 +2339,8 @@ print_dir(filesystem *fs, uint32 nod) - { - directory *d; - uint8 *b; -- b = get_blk(fs, bk); -+ blk_info *bi; -+ b = get_blk(fs, bk, &bi); - for(d = (directory*)b; (int8*)d + sizeof(*d) < (int8*)b + BLOCKSIZE; d = (directory*)((int8*)d + d->d_rec_len)) - if(d->d_inode) - { -@@ -2198,6 +2350,7 @@ print_dir(filesystem *fs, uint32 nod) - putchar(d->d_name[i]); - printf("' (inode %d): rec_len: %d (name_len: %d)\n", d->d_inode, d->d_rec_len, d->d_name_len); - } -+ put_blk(bi); - } - } - -@@ -2205,14 +2358,18 @@ print_dir(filesystem *fs, uint32 nod) - static void - print_link(filesystem *fs, uint32 nod) - { -- if(!get_nod(fs, nod)->i_blocks) -- printf("links to '%s'\n", (char*)get_nod(fs, nod)->i_block); -+ nod_info *ni; -+ inode *node = get_nod(fs, nod, &ni); -+ -+ if(!node->i_blocks) -+ printf("links to '%s'\n", (char*)node->i_block); - else - { - printf("links to '"); - write_blocks(fs, nod, stdout); - printf("'\n"); - } -+ put_nod(ni); - } - - // make a ls-like printout of permissions -@@ -2281,8 +2438,12 @@ print_inode(filesystem *fs, uint32 nod) - { - char *s; - char perms[11]; -- if(!get_nod(fs, nod)->i_mode) -- return; -+ nod_info *ni; -+ inode *node = get_nod(fs, nod, &ni); -+ blk_info *bi; -+ -+ if(!node->i_mode) -+ goto out; - switch(nod) - { - case EXT2_BAD_INO: -@@ -2304,15 +2465,18 @@ print_inode(filesystem *fs, uint32 nod) - default: - s = (nod >= EXT2_FIRST_INO) ? "normal" : "unknown reserved"; - } -- printf("inode %d (%s, %d links): ", nod, s, get_nod(fs, nod)->i_links_count); -- if(!allocated(GRP_GET_INODE_BITMAP(fs,nod), GRP_IBM_OFFSET(fs,nod))) -+ printf("inode %d (%s, %d links): ", nod, s, node->i_links_count); -+ if(!allocated(GRP_GET_INODE_BITMAP(fs,nod,&bi), GRP_IBM_OFFSET(fs,nod))) - { -+ GRP_PUT_INODE_BITMAP(bi); - printf("unallocated\n"); -- return; -+ goto out; - } -- make_perms(get_nod(fs, nod)->i_mode, perms); -- printf("%s, size: %d byte%s (%d block%s)\n", perms, plural(get_nod(fs, nod)->i_size), plural(get_nod(fs, nod)->i_blocks / INOBLK)); -- switch(get_nod(fs, nod)->i_mode & FM_IFMT) -+ GRP_PUT_INODE_BITMAP(bi); -+ make_perms(node->i_mode, perms); -+ printf("%s, size: %d byte%s (%d block%s)\n", perms, -+ plural(node->i_size), plural(node->i_blocks / INOBLK)); -+ switch(node->i_mode & FM_IFMT) - { - case FM_IFSOCK: - list_blocks(fs, nod); -@@ -2340,6 +2504,8 @@ print_inode(filesystem *fs, uint32 nod) - list_blocks(fs, nod); - } - printf("Done with inode %d\n",nod); -+out: -+ put_nod(ni); - } - - // describes various fields in a filesystem -@@ -2347,6 +2513,7 @@ static void - print_fs(filesystem *fs) - { - uint32 i; -+ blk_info *bi; - uint8 *ibm; - - printf("%d blocks (%d free, %d reserved), first data block: %d\n", -@@ -2369,13 +2536,16 @@ print_fs(filesystem *fs) - fs->gd[i].bg_block_bitmap, fs->gd[i].bg_inode_bitmap, - fs->gd[i].bg_inode_table); - printf("block bitmap allocation:\n"); -- print_bm(GRP_GET_GROUP_BBM(fs, i),fs->sb.s_blocks_per_group); -+ print_bm(GRP_GET_GROUP_BBM(fs, i, &bi), -+ fs->sb.s_blocks_per_group); -+ GRP_PUT_GROUP_BBM(bi); - printf("inode bitmap allocation:\n"); -- ibm = GRP_GET_GROUP_IBM(fs, i); -+ ibm = GRP_GET_GROUP_IBM(fs, i, &bi); - print_bm(ibm, fs->sb.s_inodes_per_group); - for (i = 1; i <= fs->sb.s_inodes_per_group; i++) - if (allocated(ibm, i)) - print_inode(fs, i); -+ GRP_PUT_GROUP_IBM(bi); - } - } - -@@ -2646,9 +2816,17 @@ main(int argc, char **argv) - - if(emptyval) { - uint32 b; -- for(b = 1; b < fs->sb.s_blocks_count; b++) -- if(!allocated(GRP_GET_BLOCK_BITMAP(fs,b),GRP_BBM_OFFSET(fs,b))) -- memset(get_blk(fs, b), emptyval, BLOCKSIZE); -+ for(b = 1; b < fs->sb.s_blocks_count; b++) { -+ blk_info *bi; -+ if(!allocated(GRP_GET_BLOCK_BITMAP(fs,b,&bi), -+ GRP_BBM_OFFSET(fs,b))) { -+ blk_info *bi2; -+ memset(get_blk(fs, b, &bi2), emptyval, -+ BLOCKSIZE); -+ put_blk(bi2); -+ } -+ GRP_PUT_BLOCK_BITMAP(bi); -+ } - } - if(verbose) - print_fs(fs); -@@ -2658,13 +2836,15 @@ main(int argc, char **argv) - char fname[MAX_FILENAME]; - char *p; - FILE *fh; -+ nod_info *ni; - if(!(nod = find_path(fs, EXT2_ROOT_INO, gopt[i]))) - error_msg_and_die("path %s not found in filesystem", gopt[i]); - while((p = strchr(gopt[i], '/'))) - *p = '_'; - SNPRINTF(fname, MAX_FILENAME-1, "%s.blk", gopt[i]); - fh = xfopen(fname, "wb"); -- fprintf(fh, "%d:", get_nod(fs, nod)->i_size); -+ fprintf(fh, "%d:", get_nod(fs, nod, &ni)->i_size); -+ put_nod(ni); - flist_blocks(fs, nod, fh); - fclose(fh); - } --- -1.7.4.1 - diff --git a/meta/recipes-devtools/genext2fs/genext2fs-1.4.1/0003-Add-get_blkmap-and-put_blkmap.patch b/meta/recipes-devtools/genext2fs/genext2fs-1.4.1/0003-Add-get_blkmap-and-put_blkmap.patch deleted file mode 100644 index 1442dfaaed..0000000000 --- a/meta/recipes-devtools/genext2fs/genext2fs-1.4.1/0003-Add-get_blkmap-and-put_blkmap.patch +++ /dev/null @@ -1,222 +0,0 @@ -Upstream-Status: inappropriate - -From c196bdeae7932c5d54bbdb7e7574d3cdae46ad02 Mon Sep 17 00:00:00 2001 -From: Corey Minyard -Date: Sat, 4 Jun 2011 22:04:24 -0500 -Subject: [PATCH 03/19] Add get_blkmap and put_blkmap. - -Add routines for getting an putting a block map. This does not do -anything functional, but is getting ready for when blockmaps are -byteswapped when being read and written. ---- - genext2fs.c | 84 ++++++++++++++++++++++++++++++++++++++++------------------- - 1 files changed, 57 insertions(+), 27 deletions(-) - -diff --git a/genext2fs.c b/genext2fs.c -index bd06369..0b5ba6f 100644 ---- a/genext2fs.c -+++ b/genext2fs.c -@@ -837,6 +837,36 @@ put_blk(blk_info *bi) - { - } - -+// Used by get_blkmap/put_blkmap to hold information about an block map -+// owned by the user. -+typedef struct -+{ -+ blk_info *bi; -+} blkmap_info; -+ -+// Return a given block map from a filesystem. Make sure to call -+// put_blkmap when you are done with it. -+static inline uint32 * -+get_blkmap(filesystem *fs, uint32 blk, blkmap_info **rbmi) -+{ -+ blkmap_info *bmi; -+ uint8 *b; -+ -+ bmi = malloc(sizeof(*bmi)); -+ if (!bmi) -+ error_msg_and_die("get_blkmap: out of memory"); -+ b = get_blk(fs, blk, &bmi->bi); -+ *rbmi = bmi; -+ return (uint32 *) b; -+} -+ -+static inline void -+put_blkmap(blkmap_info *bmi) -+{ -+ put_blk(bmi->bi); -+ free(bmi); -+} -+ - // Used by get_nod/put_nod to hold information about an inode owned - // by the user. - typedef struct -@@ -1020,12 +1050,12 @@ walk_bw(filesystem *fs, uint32 nod, blockwalker *bw, int32 *create, uint32 hole) - { - uint32 *bkref = 0; - uint32 bk = 0; -+ blkmap_info *bmi1 = NULL, *bmi2 = NULL, *bmi3 = NULL; - uint32 *b; - int extend = 0, reduce = 0; - inode *inod; - nod_info *ni; - uint32 *iblk; -- blk_info *bi1 = NULL, *bi2 = NULL, *bi3 = NULL; - - if(create && (*create) < 0) - reduce = 1; -@@ -1072,7 +1102,7 @@ walk_bw(filesystem *fs, uint32 nod, blockwalker *bw, int32 *create, uint32 hole) - iblk[bw->bpdir] = alloc_blk(fs,nod); - if(reduce) // free indirect block - free_blk(fs, iblk[bw->bpdir]); -- b = (uint32*)get_blk(fs, iblk[bw->bpdir], &bi1); -+ b = get_blkmap(fs, iblk[bw->bpdir], &bmi1); - bkref = &b[bw->bpind]; - if(extend) // allocate first block - *bkref = hole ? 0 : alloc_blk(fs,nod); -@@ -1083,7 +1113,7 @@ walk_bw(filesystem *fs, uint32 nod, blockwalker *bw, int32 *create, uint32 hole) - else if((bw->bpdir == EXT2_IND_BLOCK) && (bw->bpind < BLOCKSIZE/4 - 1)) - { - bw->bpind++; -- b = (uint32*)get_blk(fs, iblk[bw->bpdir], &bi1); -+ b = get_blkmap(fs, iblk[bw->bpdir], &bmi1); - bkref = &b[bw->bpind]; - if(extend) // allocate block - *bkref = hole ? 0 : alloc_blk(fs,nod); -@@ -1101,12 +1131,12 @@ walk_bw(filesystem *fs, uint32 nod, blockwalker *bw, int32 *create, uint32 hole) - iblk[bw->bpdir] = alloc_blk(fs,nod); - if(reduce) // free double indirect block - free_blk(fs, iblk[bw->bpdir]); -- b = (uint32*)get_blk(fs, iblk[bw->bpdir], &bi1); -+ b = get_blkmap(fs, iblk[bw->bpdir], &bmi1); - if(extend) // allocate first indirect block - b[bw->bpind] = alloc_blk(fs,nod); - if(reduce) // free firstindirect block - free_blk(fs, b[bw->bpind]); -- b = (uint32*)get_blk(fs, b[bw->bpind], &bi1); -+ b = get_blkmap(fs, b[bw->bpind], &bmi2); - bkref = &b[bw->bpdind]; - if(extend) // allocate first block - *bkref = hole ? 0 : alloc_blk(fs,nod); -@@ -1117,8 +1147,8 @@ walk_bw(filesystem *fs, uint32 nod, blockwalker *bw, int32 *create, uint32 hole) - else if((bw->bpdir == EXT2_DIND_BLOCK) && (bw->bpdind < BLOCKSIZE/4 - 1)) - { - bw->bpdind++; -- b = (uint32*)get_blk(fs, iblk[bw->bpdir], &bi1); -- b = (uint32*)get_blk(fs, b[bw->bpind], &bi2); -+ b = get_blkmap(fs, iblk[bw->bpdir], &bmi1); -+ b = get_blkmap(fs, b[bw->bpind], &bmi2); - bkref = &b[bw->bpdind]; - if(extend) // allocate block - *bkref = hole ? 0 : alloc_blk(fs,nod); -@@ -1131,12 +1161,12 @@ walk_bw(filesystem *fs, uint32 nod, blockwalker *bw, int32 *create, uint32 hole) - bw->bnum++; - bw->bpdind = 0; - bw->bpind++; -- b = (uint32*)get_blk(fs, iblk[bw->bpdir], &bi1); -+ b = get_blkmap(fs, iblk[bw->bpdir], &bmi1); - if(extend) // allocate indirect block - b[bw->bpind] = alloc_blk(fs,nod); - if(reduce) // free indirect block - free_blk(fs, b[bw->bpind]); -- b = (uint32*)get_blk(fs, b[bw->bpind], &bi2); -+ b = get_blkmap(fs, b[bw->bpind], &bmi2); - bkref = &b[bw->bpdind]; - if(extend) // allocate first block - *bkref = hole ? 0 : alloc_blk(fs,nod); -@@ -1159,17 +1189,17 @@ walk_bw(filesystem *fs, uint32 nod, blockwalker *bw, int32 *create, uint32 hole) - iblk[bw->bpdir] = alloc_blk(fs,nod); - if(reduce) // free triple indirect block - free_blk(fs, iblk[bw->bpdir]); -- b = (uint32*)get_blk(fs, iblk[bw->bpdir], &bi1); -+ b = get_blkmap(fs, iblk[bw->bpdir], &bmi1); - if(extend) // allocate first double indirect block - b[bw->bpind] = alloc_blk(fs,nod); - if(reduce) // free first double indirect block - free_blk(fs, b[bw->bpind]); -- b = (uint32*)get_blk(fs, b[bw->bpind], &bi2); -+ b = get_blkmap(fs, b[bw->bpind], &bmi2); - if(extend) // allocate first indirect block - b[bw->bpdind] = alloc_blk(fs,nod); - if(reduce) // free first indirect block - free_blk(fs, b[bw->bpind]); -- b = (uint32*)get_blk(fs, b[bw->bpdind], &bi3); -+ b = get_blkmap(fs, b[bw->bpdind], &bmi3); - bkref = &b[bw->bptind]; - if(extend) // allocate first data block - *bkref = hole ? 0 : alloc_blk(fs,nod); -@@ -1183,9 +1213,9 @@ walk_bw(filesystem *fs, uint32 nod, blockwalker *bw, int32 *create, uint32 hole) - (bw->bptind < BLOCKSIZE/4 -1) ) - { - bw->bptind++; -- b = (uint32*)get_blk(fs, iblk[bw->bpdir], &bi1); -- b = (uint32*)get_blk(fs, b[bw->bpind], &bi2); -- b = (uint32*)get_blk(fs, b[bw->bpdind], &bi3); -+ b = get_blkmap(fs, iblk[bw->bpdir], &bmi1); -+ b = get_blkmap(fs, b[bw->bpind], &bmi2); -+ b = get_blkmap(fs, b[bw->bpdind], &bmi3); - bkref = &b[bw->bptind]; - if(extend) // allocate data block - *bkref = hole ? 0 : alloc_blk(fs,nod); -@@ -1202,13 +1232,13 @@ walk_bw(filesystem *fs, uint32 nod, blockwalker *bw, int32 *create, uint32 hole) - bw->bnum++; - bw->bptind = 0; - bw->bpdind++; -- b = (uint32*)get_blk(fs, iblk[bw->bpdir], &bi1); -- b = (uint32*)get_blk(fs, b[bw->bpind], &bi2); -+ b = get_blkmap(fs, iblk[bw->bpdir], &bmi1); -+ b = get_blkmap(fs, b[bw->bpind], &bmi2); - if(extend) // allocate single indirect block - b[bw->bpdind] = alloc_blk(fs,nod); - if(reduce) // free indirect block - free_blk(fs, b[bw->bpind]); -- b = (uint32*)get_blk(fs, b[bw->bpdind], &bi3); -+ b = get_blkmap(fs, b[bw->bpdind], &bmi3); - bkref = &b[bw->bptind]; - if(extend) // allocate first data block - *bkref = hole ? 0 : alloc_blk(fs,nod); -@@ -1225,17 +1255,17 @@ walk_bw(filesystem *fs, uint32 nod, blockwalker *bw, int32 *create, uint32 hole) - bw->bpdind = 0; - bw->bptind = 0; - bw->bpind++; -- b = (uint32*)get_blk(fs, iblk[bw->bpdir], &bi1); -+ b = get_blkmap(fs, iblk[bw->bpdir], &bmi1); - if(extend) // allocate double indirect block - b[bw->bpind] = alloc_blk(fs,nod); - if(reduce) // free double indirect block - free_blk(fs, b[bw->bpind]); -- b = (uint32*)get_blk(fs, b[bw->bpind], &bi2); -+ b = get_blkmap(fs, b[bw->bpind], &bmi2); - if(extend) // allocate single indirect block - b[bw->bpdind] = alloc_blk(fs,nod); - if(reduce) // free indirect block - free_blk(fs, b[bw->bpind]); -- b = (uint32*)get_blk(fs, b[bw->bpdind], &bi3); -+ b = get_blkmap(fs, b[bw->bpdind], &bmi3); - bkref = &b[bw->bptind]; - if(extend) // allocate first block - *bkref = hole ? 0 : alloc_blk(fs,nod); -@@ -1247,12 +1277,12 @@ walk_bw(filesystem *fs, uint32 nod, blockwalker *bw, int32 *create, uint32 hole) - /* End change for walking triple indirection */ - - bk = *bkref; -- if (bi3) -- put_blk(bi3); -- if (bi2) -- put_blk(bi2); -- if (bi1) -- put_blk(bi1); -+ if (bmi3) -+ put_blkmap(bmi3); -+ if (bmi2) -+ put_blkmap(bmi2); -+ if (bmi1) -+ put_blkmap(bmi1); - - if(bk) - { --- -1.7.4.1 - diff --git a/meta/recipes-devtools/genext2fs/genext2fs-1.4.1/0004-Add-a-dirwalker-for-walking-through-directory-entrie.patch b/meta/recipes-devtools/genext2fs/genext2fs-1.4.1/0004-Add-a-dirwalker-for-walking-through-directory-entrie.patch deleted file mode 100644 index 014a69409f..0000000000 --- a/meta/recipes-devtools/genext2fs/genext2fs-1.4.1/0004-Add-a-dirwalker-for-walking-through-directory-entrie.patch +++ /dev/null @@ -1,357 +0,0 @@ -Upstream-Status: inappropriate - -From 3d47e37e21f6a2ced489d49e8bf5a5c24bb9baaf Mon Sep 17 00:00:00 2001 -From: Corey Minyard -Date: Sun, 5 Jun 2011 09:36:11 -0500 -Subject: [PATCH 04/19] Add a dirwalker for walking through directory entries - -The code to walk directory items was messy, to say the least. Write a -clean structure to do this. - -Also, remove d_name[0]. This is bad style, and newer compilers will -think it is really a zero-length array and will abort if trying to write -any data to it, since the compiler thinks it has no contents. ---- - genext2fs.c | 210 +++++++++++++++++++++++++++++++++++++++++++---------------- - 1 files changed, 154 insertions(+), 56 deletions(-) - -diff --git a/genext2fs.c b/genext2fs.c -index 0b5ba6f..03d1b27 100644 ---- a/genext2fs.c -+++ b/genext2fs.c -@@ -533,7 +533,6 @@ typedef struct - typedef struct - { - directory_decl -- char d_name[0]; - } directory; - - typedef uint8 block[BLOCKSIZE]; -@@ -795,6 +794,8 @@ static inline uint8 * - get_workblk(void) - { - unsigned char* b=calloc(1,BLOCKSIZE); -+ if (!b) -+ error_msg_and_die("get_workblk() failed, out of memory"); - return b; - } - static inline void -@@ -902,6 +903,126 @@ put_nod(nod_info *ni) - free(ni); - } - -+// Used to hold state information while walking a directory inode. -+typedef struct -+{ -+ directory d; -+ filesystem *fs; -+ uint32 nod; -+ directory *last_d; -+ uint8 *b; -+ blk_info *bi; -+} dirwalker; -+ -+// Start a directory walk on the given inode. You must pass in a -+// dirwalker structure, then use that dirwalker for future operations. -+// Call put_dir when you are done walking the directory. -+static inline directory * -+get_dir(filesystem *fs, uint32 nod, dirwalker *dw) -+{ -+ dw->fs = fs; -+ dw->b = get_blk(fs, nod, &dw->bi); -+ dw->nod = nod; -+ dw->last_d = (directory *) dw->b; -+ -+ memcpy(&dw->d, dw->last_d, sizeof(directory)); -+ return &dw->d; -+} -+ -+// Move to the next directory. -+static inline directory * -+next_dir(dirwalker *dw) -+{ -+ directory *next_d = (directory *)((int8*)dw->last_d + dw->d.d_rec_len); -+ -+ memcpy(dw->last_d, &dw->d, sizeof(directory)); -+ -+ if (((int8 *) next_d) >= ((int8 *) dw->b + BLOCKSIZE)) -+ return NULL; -+ -+ dw->last_d = next_d; -+ memcpy(&dw->d, next_d, sizeof(directory)); -+ return &dw->d; -+} -+ -+// Call then when you are done with the directory walk. -+static inline void -+put_dir(dirwalker *dw) -+{ -+ memcpy(dw->last_d, &dw->d, sizeof(directory)); -+ -+ if (dw->nod == 0) -+ free_workblk(dw->b); -+ else -+ put_blk(dw->bi); -+} -+ -+// Create a new directory block with the given inode as it's destination -+// and append it to the current dirwalker. -+static directory * -+new_dir(filesystem *fs, uint32 dnod, const char *name, int nlen, dirwalker *dw) -+{ -+ directory *d; -+ -+ dw->fs = fs; -+ dw->b = get_workblk(); -+ dw->nod = 0; -+ dw->last_d = (directory *) dw->b; -+ d = &dw->d; -+ d->d_inode = dnod; -+ d->d_rec_len = BLOCKSIZE; -+ d->d_name_len = nlen; -+ strncpy(((char *) dw->last_d) + sizeof(directory), name, nlen); -+ return d; -+} -+ -+// Shrink the current directory entry, make a new one with the free -+// space, and return the new directory entry (making it current). -+static inline directory * -+shrink_dir(dirwalker *dw, uint32 nod, const char *name, int nlen) -+{ -+ int reclen, preclen; -+ directory *d = &dw->d; -+ -+ reclen = d->d_rec_len; -+ d->d_rec_len = sizeof(directory) + rndup(d->d_name_len, 4); -+ preclen = d->d_rec_len; -+ reclen -= preclen; -+ memcpy(dw->last_d, &dw->d, sizeof(directory)); -+ -+ dw->last_d = (directory *) (((int8 *) dw->last_d) + preclen); -+ d->d_rec_len = reclen; -+ d->d_inode = nod; -+ d->d_name_len = nlen; -+ strncpy(((char *) dw->last_d) + sizeof(directory), name, nlen); -+ -+ return d; -+} -+ -+// Return the current block the directory is walking -+static inline uint8 * -+dir_data(dirwalker *dw) -+{ -+ return dw->b; -+} -+ -+// Return the pointer to the name for the current directory -+static inline char * -+dir_name(dirwalker *dw) -+{ -+ return ((char *) dw->last_d) + sizeof(directory); -+} -+ -+// Set the name for the current directory. Note that this doesn't -+// verify that there is space for the directory name, you must do -+// that yourself. -+static void -+dir_set_name(dirwalker *dw, const char *name, int nlen) -+{ -+ dw->d.d_name_len = nlen; -+ strncpy(((char *) dw->last_d) + sizeof(directory), name, nlen); -+} -+ - // allocate a given block/inode in the bitmap - // allocate first free if item == 0 - static uint32 -@@ -1354,11 +1475,10 @@ extend_blk(filesystem *fs, uint32 nod, block b, int amount) - static void - add2dir(filesystem *fs, uint32 dnod, uint32 nod, const char* name) - { -- blockwalker bw; -+ blockwalker bw, lbw; - uint32 bk; -- uint8 *b; -- blk_info *bi; - directory *d; -+ dirwalker dw; - int reclen, nlen; - inode *node; - inode *pnode; -@@ -1376,55 +1496,46 @@ add2dir(filesystem *fs, uint32 dnod, uint32 nod, const char* name) - if(reclen > BLOCKSIZE) - error_msg_and_die("bad name '%s' (too long)", name); - init_bw(&bw); -+ lbw = bw; - while((bk = walk_bw(fs, dnod, &bw, 0, 0)) != WALK_END) // for all blocks in dir - { -- b = get_blk(fs, bk, &bi); - // for all dir entries in block -- for(d = (directory*)b; (int8*)d + sizeof(*d) < (int8*)b + BLOCKSIZE; d = (directory*)((int8*)d + d->d_rec_len)) -+ for(d = get_dir(fs, bk, &dw); d; d = next_dir(&dw)) - { - // if empty dir entry, large enough, use it - if((!d->d_inode) && (d->d_rec_len >= reclen)) - { - d->d_inode = nod; - node = get_nod(fs, nod, &ni); -+ dir_set_name(&dw, name, nlen); -+ put_dir(&dw); - node->i_links_count++; -- d->d_name_len = nlen; -- strncpy(d->d_name, name, nlen); - put_nod(ni); - goto out; - } - // if entry with enough room (last one?), shrink it & use it - if(d->d_rec_len >= (sizeof(directory) + rndup(d->d_name_len, 4) + reclen)) - { -- reclen = d->d_rec_len; -- d->d_rec_len = sizeof(directory) + rndup(d->d_name_len, 4); -- reclen -= d->d_rec_len; -- d = (directory*) (((int8*)d) + d->d_rec_len); -- d->d_rec_len = reclen; -- d->d_inode = nod; - node = get_nod(fs, nod, &ni); -+ d = shrink_dir(&dw, nod, name, nlen); -+ put_dir(&dw); - node->i_links_count++; -- d->d_name_len = nlen; -- strncpy(d->d_name, name, nlen); - put_nod(ni); - goto out; - } - } -+ put_dir(&dw); -+ lbw = bw; - } - // we found no free entry in the directory, so we add a block -- if(!(b = get_workblk())) -- error_msg_and_die("get_workblk() failed."); -- d = (directory*)b; -- d->d_inode = nod; - node = get_nod(fs, nod, &ni); -+ d = new_dir(fs, nod, name, nlen, &dw); - node->i_links_count++; - put_nod(ni); -- d->d_rec_len = BLOCKSIZE; -- d->d_name_len = nlen; -- strncpy(d->d_name, name, nlen); -- extend_blk(fs, dnod, b, 1); -+ next_dir(&dw); // Force the data into the buffer -+ extend_blk(fs, dnod, dir_data(&dw), 1); -+ put_dir(&dw); - pnode->i_size += BLOCKSIZE; -- free_workblk(b); - out: - put_nod(dni); - } -@@ -1435,20 +1546,18 @@ find_dir(filesystem *fs, uint32 nod, const char * name) - { - blockwalker bw; - uint32 bk; -- blk_info *bi; - int nlen = strlen(name); - init_bw(&bw); - while((bk = walk_bw(fs, nod, &bw, 0, 0)) != WALK_END) - { - directory *d; -- uint8 *b; -- b = get_blk(fs, bk, &bi); -- for(d = (directory*)b; (int8*)d + sizeof(*d) < (int8*)b + BLOCKSIZE; d = (directory*)((int8*)d + d->d_rec_len)) -- if(d->d_inode && (nlen == d->d_name_len) && !strncmp(d->d_name, name, nlen)) { -- put_blk(bi); -+ dirwalker dw; -+ for (d = get_dir(fs, bk, &dw); d; d=next_dir(&dw)) -+ if(d->d_inode && (nlen == d->d_name_len) && !strncmp(dir_name(&dw), name, nlen)) { -+ put_dir(&dw); - return d->d_inode; - } -- put_blk(bi); -+ put_dir(&dw); - } - return 0; - } -@@ -2090,8 +2199,7 @@ init_fs(int nbblocks, int nbinodes, int nbresrvd, int holes, uint32 fs_timestamp - { - uint32 i; - filesystem *fs; -- directory *d; -- uint8 * b; -+ dirwalker dw; - uint32 nod, first_block; - uint32 nbgroups,nbinodes_per_group,overhead_per_group,free_blocks, - free_blocks_per_group,nbblocks_per_group,min_nbgroups; -@@ -2217,26 +2325,20 @@ init_fs(in