]> glassweightruler.freedombox.rocks Git - Ventoy.git/blob - IMG/cpio/ventoy/hook/kiosk/ventoy-disk.sh
fix integer overflow issue for i386-pc
[Ventoy.git] / IMG / cpio / ventoy / hook / kiosk / ventoy-disk.sh
1 #!/ventoy/busybox/sh
2 #************************************************************************************
3 # Copyright (c) 2020, longpanda <admin@ventoy.net>
4 #
5 # This program is free software; you can redistribute it and/or
6 # modify it under the terms of the GNU General Public License as
7 # published by the Free Software Foundation; either version 3 of the
8 # License, or (at your option) any later version.
9 #
10 # This program is distributed in the hope that it will be useful, but
11 # WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 # General Public License for more details.
14 #
15 # You should have received a copy of the GNU General Public License
16 # along with this program; if not, see <http://www.gnu.org/licenses/>.
17 #
18 #************************************************************************************
19
20 . /ventoy/hook/ventoy-hook-lib.sh
21
22 VTPATH_OLD=$PATH; PATH=$BUSYBOX_PATH:$VTOY_PATH/tool:$PATH
23
24 ventoy_os_install_dmsetup_by_unsquashfs() {
25 vtlog "ventoy_os_install_dmsetup_by_unsquashfs $*"
26
27 vtKerVer=$(uname -r)
28 vtKoPo=$(ventoy_get_module_postfix)
29 vtlog "vtKerVer=$vtKerVer vtKoPo=$vtKoPo"
30
31 vtoydm -i -f $VTOY_PATH/ventoy_image_map -d $1 > $VTOY_PATH/iso_file_list
32
33 vtline=$(grep '[-][-] .*kernel.xzm ' $VTOY_PATH/iso_file_list)
34 sector=$(echo $vtline | awk '{print $(NF-1)}')
35 length=$(echo $vtline | awk '{print $NF}')
36
37 vtlog "vtline=$vtline sector=$sector length=$length"
38
39 vtoydm -e -f $VTOY_PATH/ventoy_image_map -d $1 -s $sector -l $length -o $VTOY_PATH/kernel.xzm
40 mkdir -p $VTOY_PATH/sqfs
41 mount $VTOY_PATH/kernel.xzm $VTOY_PATH/sqfs
42
43 dmModPath="/lib/modules/$vtKerVer/kernel/drivers/md/dm-mod.$vtKoPo"
44
45 if [ -e $VTOY_PATH/sqfs${dmModPath} ]; then
46 vtlog "success $VTOY_PATH/sqfs${dmModPath}"
47 insmod $VTOY_PATH/sqfs${dmModPath}
48 else
49 vterr "failed $VTOY_PATH/sqfs${dmModPath}"
50 false
51 fi
52
53 umount $VTOY_PATH/sqfs
54 rm -f $VTOY_PATH/kernel.xzm
55 }
56
57 wait_for_usb_disk_ready
58
59 vtdiskname=$(get_ventoy_disk_name)
60 if [ "$vtdiskname" = "unknown" ]; then
61 vtlog "ventoy disk not found"
62 PATH=$VTPATH_OLD
63 exit 0
64 fi
65
66 ventoy_os_install_dmsetup_by_unsquashfs $vtdiskname
67
68 ventoy_udev_disk_common_hook "${vtdiskname#/dev/}2" "noreplace"
69
70 PATH=$VTPATH_OLD