summaryrefslogtreecommitdiffstats
path: root/fs/ext2/genext2fs.sh
diff options
context:
space:
mode:
authorPeter Korsgaard <jacmet@sunsite.dk>2010-12-30 23:10:21 +0100
committerPeter Korsgaard <jacmet@sunsite.dk>2010-12-30 23:10:21 +0100
commiteeea3ea6a88a8f1c7511abf0b429297a562e7d30 (patch)
tree261405a6c1f2c42d9f876c7b473051fa2f58d8e6 /fs/ext2/genext2fs.sh
parentf3931ca1a159530026adc3964fbb173f8113aef6 (diff)
downloadbuildroot-novena-eeea3ea6a88a8f1c7511abf0b429297a562e7d30.tar.gz
buildroot-novena-eeea3ea6a88a8f1c7511abf0b429297a562e7d30.zip
genext2fs.sh: improve number of blocks calculation
Closes #2929 Instead of just adding a fixed amount to the blocks used, try to estimate the real space needed according to the filesystem structure (bitmaps, inodes, blocks). The side effect of this is that we no longer significantly overestimate the size needed for small file systems. Signed-off-by: Peter Korsgaard <jacmet@sunsite.dk>
Diffstat (limited to 'fs/ext2/genext2fs.sh')
-rwxr-xr-xfs/ext2/genext2fs.sh25
1 files changed, 11 insertions, 14 deletions
diff --git a/fs/ext2/genext2fs.sh b/fs/ext2/genext2fs.sh
index b315ec30a..7a518aea7 100755
--- a/fs/ext2/genext2fs.sh
+++ b/fs/ext2/genext2fs.sh
@@ -10,24 +10,11 @@ while getopts x:d:D:b:i:N:m:g:e:zfqUPhVv f
do
case $f in
b) CALC_BLOCKS=0 ;;
- N) CALC_INODES=0 ;;
+ N) CALC_INODES=0; INODES=$OPTARG ;;
d) TARGET_DIR=$OPTARG ;;
esac
done
-# calculate needed blocks
-if [ $CALC_BLOCKS -eq 1 ];
-then
- BLOCKS=$(du -s -c -k $TARGET_DIR | grep total | sed -e "s/total//")
- if [ $BLOCKS -ge 20000 ];
- then
- BLOCKS=$(expr $BLOCKS + 16384)
- else
- BLOCKS=$(expr $BLOCKS + 2400)
- fi
- set -- $@ -b $BLOCKS
-fi
-
# calculate needed inodes
if [ $CALC_INODES -eq 1 ];
then
@@ -36,4 +23,14 @@ then
set -- $@ -N $INODES
fi
+# calculate needed blocks
+if [ $CALC_BLOCKS -eq 1 ];
+then
+ # size ~= superblock, block+inode bitmaps, inodes (8 per block), blocks
+ # we scale inodes / blocks with 10% to compensate for bitmaps size + slack
+ BLOCKS=$(du -s -c -k $TARGET_DIR | grep total | sed -e "s/total//")
+ BLOCKS=$(expr 500 + \( $BLOCKS + $INODES / 8 \) \* 11 / 10)
+ set -- $@ -b $BLOCKS
+fi
+
exec genext2fs $@