diff options
author | James Bottomley <James.Bottomley@HansenPartnership.com> | 2019-07-30 14:47:53 -0700 |
---|---|---|
committer | Helge Deller <deller@gmx.de> | 2019-07-31 09:36:22 +0200 |
commit | a50fe3358ae4bc4f23caa9aa6457bfdbc4556db8 (patch) | |
tree | 3dbd7fcadaec8596ec583661f98702add6555ba2 | |
parent | c17db9a93031c63028585b0200fc9ddeec4aeab1 (diff) | |
download | palo-a50fe3358ae4bc4f23caa9aa6457bfdbc4556db8.tar.gz |
Reduce size for .bss
Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com>
Signed-off-by: Helge Deller <deller@gmx.de>
-rw-r--r-- | ipl/ext2.c | 21 |
1 files changed, 15 insertions, 6 deletions
@@ -475,17 +475,26 @@ static int ext3_extent_node_find(struct ext2_inode *ip, static int ext3_extent_load_find(struct ext2_inode *ip, int leaf, int d, int blkoff) { - static char blockbuf[EXTENT_MAX_DEPTH][EXT2_MAX_BLOCK_SIZE]; + static char *blockbuf; static int cached_blockno[EXTENT_MAX_DEPTH]; struct ext3_extent_header *hdr; - hdr = (struct ext3_extent_header *)blockbuf[d]; + if (!blockbuf) { + blockbuf = malloc(EXTENT_MAX_DEPTH * EXT2_MAX_BLOCK_SIZE); + if (!blockbuf) { + printf("Failed to allocate memory for block buffer\n"); + return -1; + } + } + + hdr = (struct ext3_extent_header *) &blockbuf[d * EXT2_MAX_BLOCK_SIZE]; if (cached_blockno[d] != leaf) { - printf("load extent tree[%d] block at %d\n", d, leaf); + if (Debug) + printf("load extent tree[%d] block at %d\n", d, leaf); - if (cons_read(dev, blockbuf[d], sizeof(blockbuf[d]), + if (cons_read(dev, hdr, EXT2_MAX_BLOCK_SIZE, leaf * ext2_blocksize) != - sizeof(blockbuf[d])) { + EXT2_MAX_BLOCK_SIZE) { printf("ext3_extent_load_find: read error\n"); return -1; } @@ -504,7 +513,7 @@ static int ext3_extent_load_find(struct ext2_inode *ip, int leaf, int d, return -1; } if (sizeof(hdr) + sizeof(struct ext3_extent)*hdr->eh_entries > - sizeof(blockbuf[d])) { + EXT2_MAX_BLOCK_SIZE) { printf("ext3_extent_load_find: extent is larger than buffer\n"); return -1; } |