diff options
author | Fernando Reyes (likewhoa) <design@missionaccomplish.com> | 2014-06-23 22:03:36 +0200 |
---|---|---|
committer | Rick Farina (Zero_Chaos) <zerochaos@gentoo.org> | 2015-08-11 14:21:16 -0400 |
commit | a6202ee3e4a2098fc17fd64ac3aad46353cff5dd (patch) | |
tree | 9057eb3eebf772c4c26c518529d33e1a4e11013e /defaults | |
parent | Coding style changes throughout all the AUFS related code. (diff) | |
download | genkernel-a6202ee3e4a2098fc17fd64ac3aad46353cff5dd.tar.gz genkernel-a6202ee3e4a2098fc17fd64ac3aad46353cff5dd.tar.bz2 genkernel-a6202ee3e4a2098fc17fd64ac3aad46353cff5dd.zip |
Introduced a new funtion to test for numeric values that that our changes_fs doesn't fail
when non-numeric values are given, also the styling of changes_fs was changed to
reflect new logic.
Diffstat (limited to 'defaults')
-rw-r--r-- | defaults/initrd.scripts | 21 |
1 files changed, 17 insertions, 4 deletions
diff --git a/defaults/initrd.scripts b/defaults/initrd.scripts index c258c00..02842bf 100644 --- a/defaults/initrd.scripts +++ b/defaults/initrd.scripts @@ -345,6 +345,18 @@ conf_rc_no_umounts() { fi } +# is_int "$A" ["$B"..] +# NOTE we consider a leading 0 false as it would be interpreted as octal +is_int(){ + local i + for i; do + case $i in + ''|*[!0-9]*|0?*) return 1 ;; + *) : + esac + done +} + # Function to create an ext2 fs on $CHANGESDEV, $CHANGESMNT mountpoint create_changefs() { local size @@ -352,11 +364,12 @@ create_changefs() { while :; do read -p '<< Size of file (Press Enter for default 256 Mb): ' size - [ -n "$size" ] || size=256 - - size=$size + size=${size:-256} - if [ 15 -ge "$size" ]; then + if ! is_int $size; then + bad_msg "Non numeric value given for size, try again" + continue + elif [ 15 -ge "$size" ]; then bad_msg "Please give a size of at least 16 Megabytes" else if dd if=/dev/zero "of=$CHANGESMNT$AUFS_CHANGESFILE" bs=1M count="$size" &>/dev/null; then |