diff options
author | Peter Korsgaard <jacmet@sunsite.dk> | 2010-04-19 14:24:11 +0200 |
---|---|---|
committer | Peter Korsgaard <jacmet@sunsite.dk> | 2010-04-19 14:33:14 +0200 |
commit | fb951b93423356a7b648a8e268cd5af57d964f45 (patch) | |
tree | 52cedf70ce02752a76aeb683942097e2139f4668 /fs/ext2/genext2fs.sh | |
parent | f7f01e18e77dd43d535002783e9a40deedd2d924 (diff) |
fs/ext2: fix blocks/inodes calculation
With the ROOTFS_TARGET conversion, EXT2_OPTS gets evaluated very early
(before TARGET_DIR is populated with files), so the calculated
blocks/inodes numbers are wrong.
Fix it by moving the calculation to a shell script wrapper around
genext2fs, so it only gets executed just before genext2fs runs.
Signed-off-by: Peter Korsgaard <jacmet@sunsite.dk>
Diffstat (limited to 'fs/ext2/genext2fs.sh')
-rwxr-xr-x | fs/ext2/genext2fs.sh | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/fs/ext2/genext2fs.sh b/fs/ext2/genext2fs.sh new file mode 100755 index 000000000..b315ec30a --- /dev/null +++ b/fs/ext2/genext2fs.sh @@ -0,0 +1,39 @@ +#!/bin/sh +# genext2fs wrapper calculating needed blocks/inodes values if not specified + +export LC_ALL=C + +CALC_BLOCKS=1 +CALC_INODES=1 + +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 ;; + 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 + INODES=$(find $TARGET_DIR | wc -l) + INODES=$(expr $INODES + 400) + set -- $@ -N $INODES +fi + +exec genext2fs $@ |