Gentoo Archives: gentoo-commits

From: Richard Farina <zerochaos@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] proj/genkernel:aufs commit in: defaults/
Date: Fri, 05 Sep 2014 16:10:02
Message-Id: 1403565075.0e4c288f2435fca36705a6ea95f48edccefc6e26.zerochaos@gentoo
1 commit: 0e4c288f2435fca36705a6ea95f48edccefc6e26
2 Author: Fernando Reyes (likewhoa) <design <AT> missionaccomplish <DOT> com>
3 AuthorDate: Mon Jun 23 20:03:36 2014 +0000
4 Commit: Richard Farina <zerochaos <AT> gentoo <DOT> org>
5 CommitDate: Mon Jun 23 23:11:15 2014 +0000
6 URL: http://sources.gentoo.org/gitweb/?p=proj/genkernel.git;a=commit;h=0e4c288f
7
8 Introduced a new funtion to test for numeric values that that our changes_fs doesn't fail
9 when non-numeric values are given, also the styling of changes_fs was changed to
10 reflect new logic.
11
12 ---
13 defaults/initrd.scripts | 21 +++++++++++++++++----
14 1 file changed, 17 insertions(+), 4 deletions(-)
15
16 diff --git a/defaults/initrd.scripts b/defaults/initrd.scripts
17 index 5ca1203..26ed173 100644
18 --- a/defaults/initrd.scripts
19 +++ b/defaults/initrd.scripts
20 @@ -345,6 +345,18 @@ conf_rc_no_umounts() {
21 fi
22 }
23
24 +# is_int "$A" ["$B"..]
25 +# NOTE we consider a leading 0 false as it would be interpreted as octal
26 +is_int(){
27 + local i
28 + for i; do
29 + case $i in
30 + ''|*[!0-9]*|0?*) return 1 ;;
31 + *) :
32 + esac
33 + done
34 +}
35 +
36 # Function to create an ext2 fs on $CHANGESDEV, $CHANGESMNT mountpoint
37 create_changefs() {
38 local size
39 @@ -352,11 +364,12 @@ create_changefs() {
40 while :; do
41 read -p '<< Size of file (Press Enter for default 256 Mb): ' size
42
43 - [ -n "$size" ] || size=256
44 -
45 - size=$size
46 + size=${size:-256}
47
48 - if [ 15 -ge "$size" ]; then
49 + if ! is_int $size; then
50 + bad_msg "Non numeric value given for size, try again"
51 + continue
52 + elif [ 15 -ge "$size" ]; then
53 bad_msg "Please give a size of at least 16 Megabytes"
54 else
55 if dd if=/dev/zero "of=$CHANGESMNT$AUFS_CHANGESFILE" bs=1M count="$size" &>/dev/null; then