From 2acaff5c3fff25ddda0b539d2d65b7fa6d1868de Mon Sep 17 00:00:00 2001 From: PartialVolume <22084881+PartialVolume@users.noreply.github.com> Date: Thu, 22 Feb 2024 19:39:08 +0000 Subject: [PATCH] Multiple loop device test mode for developers & testers. The main purpose of this commit is to allow the developer or tester the ability to specify /dev/loop0 .. /dev/loopn on the kernel command line in /boot/grub/grub.cfg and /EFI/BOOT/grub.cfg where n is unlimited, although it is recommended that no more than 20-30 loop devices are specified. The loop devices are of a fixed size alternating between 500Kbytes and 1 MByte in size. Due to their small size you would typically select 500 or 1000 rounds when testing. To create loop devices append the following to grub.cfg nwipe_options='--nousb /dev/loop0 /dev/loop1 ... /dev/loopn' loop devices should be sequential starting at loop0, any break in the sequence will cause creation of loop devices to stop. This commit also includes a ffmpeg module +BR2_PACKAGE_FFMPEG_SWSCALE=y for creation of videos of the display. This may be useful for creating training material, youtube videos etc using the command ffmpeg -f fbdev -framerate 30 -i /dev/fb0 output.mp4 Initial work was started on excluding the boot disc if the following shredos_exclude_boot_disc is appended to the kernel command line. --- .../shredos/fsoverlay/usr/bin/nwipe_launcher | 76 ++++++++++++++----- configs/shredos_defconfig | 1 + 2 files changed, 56 insertions(+), 21 deletions(-) diff --git a/board/shredos/fsoverlay/usr/bin/nwipe_launcher b/board/shredos/fsoverlay/usr/bin/nwipe_launcher index da10687e25..ff57e2cad8 100755 --- a/board/shredos/fsoverlay/usr/bin/nwipe_launcher +++ b/board/shredos/fsoverlay/usr/bin/nwipe_launcher @@ -10,6 +10,12 @@ trap "echo" INT previous_sha1="" loop_count=0 +#Flag indicates whether boot disc should be excluded from wipe and display +exclude_boot_disc=0 + +# Flag indicates user specified drives to be excluded from list or autonuke +exclude_drives=0 + # countdown on screen from 30s with numeric digits, checking the sha1 of dmesg every 5 secs # will exit countdown before reaching zero if no USB activity for 5 seconds loop_count_total=30 @@ -75,6 +81,21 @@ if [ ! -d "exported" ]; then printf "[`date`] FAILED to create the /exported directory\n" 2>&1 | tee -a transfer.log fi fi +printf "nwipe_launcher: Searching for ShredOS/Ventoy exFAT/FAT32 boot drive that matches the booted ShredOS version.\n" +# From all the drives on the system, try to locate the ShredOS boot disc +drive=$(find_shredos_boot_disc.sh) + +if [ "$drive" == "" ]; then + printf "nwipe_launcher: No ShredOS/Ventoy exFAT/FAT32 boot drive found with matching version.\n" +else + printf "Found a ShredOS/Ventoy exFAT/FAT32 boot drive with the correct version of ShredOS $drive\n" +fi + +shredos_config_string=$(kernel_cmdline_extractor shredos_exclude_boot_disc) +if [ $? == 0 ] +then + exclude_boot_disc=1 +fi # ---- # Read the kernel command line for the option shredos_config @@ -289,32 +310,45 @@ then echo $nwipe_options_string > nwipe_options.txt sed -i 's/--autopoweroff/--nowait/g' nwipe_options.txt nwipe_options_string=`cat nwipe_options.txt` + rm nwipe_options.txt fi - # In addition, check whether user has specified a /dev/loop0 or /dev/loop1 - # device and if yes, create 1Mbyte loop devices. These are used for testing. + # Check whether user has specified a /dev/loop0 or /dev/loop1 etc + # device and if yes, create alternating 500K/1Mbyte loop devices. + # These are used for testing by devs. It is suggested a max of 20 devices be + # created but they must all be contiguous, i.e no gaps in the sequence + # As the loop will stop on the first non existant loop device. + # /dev/loop0, /dev/loop1, /dev/loop2, /dev/loop3 is good + # /dev/loop0, /dev/loop1, /dev/loop2, /dev/loop4 will create loops 0,1,2 only. + # The dev would specify these loop devices in the nwipe_options on + # the kernel command line in /boot/grub/grub.cfg and /EFI/BOOT/grub.cfg - case "$nwipe_options_string" in - */dev/loop0*) createloop0=1 ;; - * ) createloop0=0 ;; - esac + toggle_size=0 + loop_n=0 + while true; do + case "$nwipe_options_string" in + */dev/loop$loop_n*) createloop=1 ;; + * ) createloop=0 ;; + esac - if [ $createloop0 == 1 ] - then - truncate -s 1M loopback0.img - losetup -fP loopback0.img - fi + if [ $createloop == 1 ] + then + if [ $toggle_size == 0 ] + then + truncate -s 1M loopback$loop_n.img + losetup -fP loopback$loop_n.img + toggle_size=1 + else + truncate -s 500K loopback$loop_n.img + losetup -fP loopback$loop_n.img + toggle_size=0 + fi + else + break + fi + ((loop_n++)) - case "$nwipe_options_string" in - */dev/loop0*) createloop1=1 ;; - * ) createloop1=0 ;; - esac - - if [ $createloop1 == 1 ] - then - truncate -s 1M loopback1.img - losetup -fP loopback1.img - fi + done else nwipe_options_flag=0 diff --git a/configs/shredos_defconfig b/configs/shredos_defconfig index 85fc6bfabd..fe98236986 100644 --- a/configs/shredos_defconfig +++ b/configs/shredos_defconfig @@ -25,6 +25,7 @@ BR2_PACKAGE_LINUX_TOOLS_SELFTESTS=y BR2_PACKAGE_FFMPEG=y BR2_PACKAGE_FFMPEG_GPL=y BR2_PACKAGE_FFMPEG_NONFREE=y +BR2_PACKAGE_FFMPEG_SWSCALE=y BR2_PACKAGE_BZIP2=y BR2_PACKAGE_GZIP=y BR2_PACKAGE_UNZIP=y