1 |
commit: 2eae1bbb0da75bec6d38b98c97a3de3a3365f901 |
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: Wed Apr 29 17:31:45 2015 +0000 |
6 |
URL: https://gitweb.gentoo.org/proj/genkernel.git/commit/?id=2eae1bbb |
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 |
defaults/initrd.scripts | 21 +++++++++++++++++---- |
13 |
1 file changed, 17 insertions(+), 4 deletions(-) |
14 |
|
15 |
diff --git a/defaults/initrd.scripts b/defaults/initrd.scripts |
16 |
index c258c00..02842bf 100644 |
17 |
--- a/defaults/initrd.scripts |
18 |
+++ b/defaults/initrd.scripts |
19 |
@@ -345,6 +345,18 @@ conf_rc_no_umounts() { |
20 |
fi |
21 |
} |
22 |
|
23 |
+# is_int "$A" ["$B"..] |
24 |
+# NOTE we consider a leading 0 false as it would be interpreted as octal |
25 |
+is_int(){ |
26 |
+ local i |
27 |
+ for i; do |
28 |
+ case $i in |
29 |
+ ''|*[!0-9]*|0?*) return 1 ;; |
30 |
+ *) : |
31 |
+ esac |
32 |
+ done |
33 |
+} |
34 |
+ |
35 |
# Function to create an ext2 fs on $CHANGESDEV, $CHANGESMNT mountpoint |
36 |
create_changefs() { |
37 |
local size |
38 |
@@ -352,11 +364,12 @@ create_changefs() { |
39 |
while :; do |
40 |
read -p '<< Size of file (Press Enter for default 256 Mb): ' size |
41 |
|
42 |
- [ -n "$size" ] || size=256 |
43 |
- |
44 |
- size=$size |
45 |
+ size=${size:-256} |
46 |
|
47 |
- if [ 15 -ge "$size" ]; then |
48 |
+ if ! is_int $size; then |
49 |
+ bad_msg "Non numeric value given for size, try again" |
50 |
+ continue |
51 |
+ elif [ 15 -ge "$size" ]; then |
52 |
bad_msg "Please give a size of at least 16 Megabytes" |
53 |
else |
54 |
if dd if=/dev/zero "of=$CHANGESMNT$AUFS_CHANGESFILE" bs=1M count="$size" &>/dev/null; then |