]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
tools/bootconfig: Improve portability
authorMasami Hiramatsu (Google) <mhiramat@kernel.org>
Thu, 10 Jul 2025 02:24:02 +0000 (11:24 +0900)
committerMasami Hiramatsu (Google) <mhiramat@kernel.org>
Mon, 14 Jul 2025 02:55:42 +0000 (11:55 +0900)
Since 'stat' command and 'truncate' command are GNU extension,
use 'wc' and 'dd' commands instead.

Link: https://lore.kernel.org/all/175211424184.2591046.3523297993175066026.stgit@mhiramat.tok.corp.google.com/
Signed-off-by: Masami Hiramatsu (Google) <mhiramat@kernel.org>
tools/bootconfig/test-bootconfig.sh

index 32401bf6134090e74a9deecec9593523eb6730f5..aea302bd7c2a1e6fbcc893645c0923d3eb95a5e5 100755 (executable)
@@ -49,12 +49,12 @@ xpass $BOOTCONF -d $INITRD
 
 dd if=/dev/zero of=$INITRD bs=4096 count=1
 echo "key = value;" > $TEMPCONF
-bconf_size=$(stat -c %s $TEMPCONF)
-initrd_size=$(stat -c %s $INITRD)
+bconf_size=$(wc -c < $TEMPCONF)
+initrd_size=$(wc -c < $INITRD)
 
 echo "Apply command test"
 xpass $BOOTCONF -a $TEMPCONF $INITRD
-new_size=$(stat -c %s $INITRD)
+new_size=$(wc -c < $INITRD)
 
 echo "Show command test"
 xpass $BOOTCONF $INITRD
@@ -69,13 +69,13 @@ echo "Apply command repeat test"
 xpass $BOOTCONF -a $TEMPCONF $INITRD
 
 echo "File size check"
-xpass test $new_size -eq $(stat -c %s $INITRD)
+xpass test $new_size -eq $(wc -c < $INITRD)
 
 echo "Delete command check"
 xpass $BOOTCONF -d $INITRD
 
 echo "File size check"
-new_size=$(stat -c %s $INITRD)
+new_size=$(wc -c < $INITRD)
 xpass test $new_size -eq $initrd_size
 
 echo "No error messge while applying"
@@ -108,7 +108,8 @@ dd if=/dev/urandom bs=768 count=32 | base64 -w0 >> $TEMPCONF
 echo "\"" >> $TEMPCONF
 xfail $BOOTCONF -a $TEMPCONF $INITRD
 
-truncate -s 32764 $TEMPCONF
+dd if=$TEMPCONF of=$OUTFILE bs=1 count=32764
+cp $OUTFILE $TEMPCONF
 echo "\"" >> $TEMPCONF # add 2 bytes + terminal ('\"\n\0')
 xpass $BOOTCONF -a $TEMPCONF $INITRD