mirror of
https://github.com/ventoy/Ventoy.git
synced 2026-06-29 14:38:12 +00:00
Compare commits
154 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2f66a309e4 | ||
|
|
aa75cdac7d | ||
|
|
ccf4f7234a | ||
|
|
c1cad99584 | ||
|
|
d9cab1cb33 | ||
|
|
18f4c8afcc | ||
|
|
aeb46cd3c8 | ||
|
|
475de1dada | ||
|
|
31648a0d4b | ||
|
|
d51e76daa9 | ||
|
|
f677d72e8d | ||
|
|
6418c2a09f | ||
|
|
c2a3f181c0 | ||
|
|
90e4f9db63 | ||
|
|
255e84dbab | ||
|
|
213ce02985 | ||
|
|
8c2a3b44da | ||
|
|
536545cd39 | ||
|
|
0f59e92a01 | ||
|
|
4b1e5ce89c | ||
|
|
1ed7bc9596 | ||
|
|
71ac855b36 | ||
|
|
4302854b8d | ||
|
|
036f7234ad | ||
|
|
26a394ce84 | ||
|
|
25369d5884 | ||
|
|
12387fff81 | ||
|
|
b54a7fe93b | ||
|
|
dba7530b21 | ||
|
|
e9b4c86082 | ||
|
|
dbcdf51950 | ||
|
|
de3e6c6d1d | ||
|
|
3c0df07b92 | ||
|
|
c1c27cd30c | ||
|
|
167c87402c | ||
|
|
d35b8431fe | ||
|
|
a1771bd9b8 | ||
|
|
ed61a955bf | ||
|
|
e7cf29fd9d | ||
|
|
b5d87d394a | ||
|
|
36da0e0f3d | ||
|
|
903fd7aa01 | ||
|
|
81728a817c | ||
|
|
f68d4a8076 | ||
|
|
f6c248e983 | ||
|
|
0906cd34fe | ||
|
|
d3b911d249 | ||
|
|
5c6e1c2446 | ||
|
|
3a97ab9165 | ||
|
|
6fe6231790 | ||
|
|
9564f125a7 | ||
|
|
e380575b91 | ||
|
|
0fd49126bd | ||
|
|
a466d787b8 | ||
|
|
ab5d00bafb | ||
|
|
450caa6654 | ||
|
|
ef93b55c91 | ||
|
|
4d7fcc26d4 | ||
|
|
3597f15814 | ||
|
|
f7e4a7a6ec | ||
|
|
65b88aabc5 | ||
|
|
c42abd33c2 | ||
|
|
af34df278f | ||
|
|
68fd17df5b | ||
|
|
628a72db2f | ||
|
|
a20ee878df | ||
|
|
3de3a36e9f | ||
|
|
06f164ef70 | ||
|
|
40fbc041ea | ||
|
|
935516ed49 | ||
|
|
a71d4513e4 | ||
|
|
82fef5314b | ||
|
|
052a0152e4 | ||
|
|
5fae0ca35f | ||
|
|
6482f2e7b3 | ||
|
|
bd8aebf166 | ||
|
|
3c05d55b8a | ||
|
|
92ed0c995e | ||
|
|
dc7e310828 | ||
|
|
67d7091255 | ||
|
|
2ab1474694 | ||
|
|
aa7a77df5a | ||
|
|
4790dedbb1 | ||
|
|
de085ba086 | ||
|
|
bb94ec6d6f | ||
|
|
b9892660b5 | ||
|
|
0e9d34422a | ||
|
|
c7c9c62ec7 | ||
|
|
9e13955af1 | ||
|
|
2dafe75509 | ||
|
|
6fbc08cfcb | ||
|
|
6034b25cba | ||
|
|
c5fd64d21c | ||
|
|
32fac72b5b | ||
|
|
022322c8fa | ||
|
|
96f11252d9 | ||
|
|
004ad27e0d | ||
|
|
9a8dc42d93 | ||
|
|
6166a813ea | ||
|
|
786a9ec678 | ||
|
|
0600576c78 | ||
|
|
72b722c86c | ||
|
|
bea5607ea5 | ||
|
|
b3c2bcf58f | ||
|
|
4e8d8b2e19 | ||
|
|
60d88cb7b1 | ||
|
|
f7e6bbc70c | ||
|
|
ee994a0569 | ||
|
|
966ed21de7 | ||
|
|
ff7ee9c10e | ||
|
|
f43461a16c | ||
|
|
377e3fb7bc | ||
|
|
f62bd1be14 | ||
|
|
b11c38779d | ||
|
|
f202542c62 | ||
|
|
279491a36a | ||
|
|
cb209f9b9e | ||
|
|
b7b2f6a5c1 | ||
|
|
3967fb5fb5 | ||
|
|
a2ad95792d | ||
|
|
791308d2ce | ||
|
|
0ffb1b15ef | ||
|
|
d6e1730ca0 | ||
|
|
4d55f505f9 | ||
|
|
30a61ac5c4 | ||
|
|
9b79831516 | ||
|
|
af2d6bc247 | ||
|
|
d8ae740427 | ||
|
|
b685157ae3 | ||
|
|
3f6ddb6fb6 | ||
|
|
b8838b305d | ||
|
|
00de8b932d | ||
|
|
1e49dbe957 | ||
|
|
580416facc | ||
|
|
75cf728fa9 | ||
|
|
8723aeb4cc | ||
|
|
dc9a99bb20 | ||
|
|
a40456d9d2 | ||
|
|
bdab55e8aa | ||
|
|
1b2483ec14 | ||
|
|
c16e76130b | ||
|
|
d672af4819 | ||
|
|
712f10e86a | ||
|
|
2be340d2e8 | ||
|
|
b77ef718b4 | ||
|
|
72f5710b88 | ||
|
|
ee7da60d88 | ||
|
|
44fb9f4564 | ||
|
|
3f65f0ef03 | ||
|
|
4faa5e4344 | ||
|
|
c7693d4ecd | ||
|
|
4527e1db79 | ||
|
|
757cacf274 | ||
|
|
39703cabb7 |
14
.github/workflows/ci.yml
vendored
14
.github/workflows/ci.yml
vendored
@@ -13,25 +13,25 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v3
|
||||||
- name: Run docker-compose up
|
- name: Run docker compose up
|
||||||
run: docker-compose up
|
run: docker compose up
|
||||||
- uses: actions/upload-artifact@v3
|
- uses: actions/upload-artifact@v4
|
||||||
with:
|
with:
|
||||||
name: ventoy-windows
|
name: ventoy-windows
|
||||||
path: INSTALL/ventoy-*windows*
|
path: INSTALL/ventoy-*windows*
|
||||||
- uses: actions/upload-artifact@v3
|
- uses: actions/upload-artifact@v4
|
||||||
with:
|
with:
|
||||||
name: ventoy-linux
|
name: ventoy-linux
|
||||||
path: INSTALL/ventoy-*linux*
|
path: INSTALL/ventoy-*linux*
|
||||||
- uses: actions/upload-artifact@v3
|
- uses: actions/upload-artifact@v4
|
||||||
with:
|
with:
|
||||||
name: ventoy-livecd
|
name: ventoy-livecd
|
||||||
path: INSTALL/ventoy-*livecd*
|
path: INSTALL/ventoy-*livecd*
|
||||||
- uses: actions/upload-artifact@v3
|
- uses: actions/upload-artifact@v4
|
||||||
with:
|
with:
|
||||||
name: SHA256SUM
|
name: SHA256SUM
|
||||||
path: INSTALL/sha256.txt
|
path: INSTALL/sha256.txt
|
||||||
- uses: actions/upload-artifact@v3
|
- uses: actions/upload-artifact@v4
|
||||||
with:
|
with:
|
||||||
name: xxx-build-log
|
name: xxx-build-log
|
||||||
path: DOC/build.log
|
path: DOC/build.log
|
||||||
|
|||||||
194
BLOB_List.md
Normal file
194
BLOB_List.md
Normal file
@@ -0,0 +1,194 @@
|
|||||||
|
|
||||||
|
<table>
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>BLOB</th>
|
||||||
|
<th>File Source</th>
|
||||||
|
<th>Desc</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<tr> <td>./BUSYBOX/chmod/vtchmod32</td> <td rowspan=5>build</td> <td rowspan=5>Build Instructions:<br/> ./BUSYBOX/chmod/build.sh</td> </tr>
|
||||||
|
<tr> <td>./BUSYBOX/chmod/vtchmod64</td> </tr>
|
||||||
|
<tr> <td>./BUSYBOX/chmod/vtchmod64_musl</td> </tr>
|
||||||
|
<tr> <td>./BUSYBOX/chmod/vtchmodaa64</td> </tr>
|
||||||
|
<tr> <td>./BUSYBOX/chmod/vtchmodm64e</td> </tr>
|
||||||
|
<tr> <td>./cryptsetup/veritysetup32</td> <td rowspan=2>build</td> <td rowspan=2>Build Instructions:<br/> ./cryptsetup/cryptsetup-build.txt</td> </tr>
|
||||||
|
<tr> <td>./cryptsetup/veritysetup64</td> </tr>
|
||||||
|
<tr> <td>./DMSETUP/dmsetup32</td> <td rowspan=4>build</td> <td rowspan=4>Build Instructions:<br/> ./DMSETUP/build.txt</td> </tr>
|
||||||
|
<tr> <td>./DMSETUP/dmsetup64</td> </tr>
|
||||||
|
<tr> <td>./DMSETUP/dmsetupaa64</td> </tr>
|
||||||
|
<tr> <td>./DMSETUP/dmsetupm64e</td> </tr>
|
||||||
|
<tr> <td>./FUSEISO/vtoy_fuse_iso_32</td> <td rowspan=3>build</td> <td rowspan=3>Build Instructions:<br/> ./FUSEISO/build.sh<br/>./FUSEISO/build_aarch64.sh<br/>./FUSEISO/build_libfuse.sh<br/>./FUSEISO/build_libfuse_aarch64.sh </td> </tr>
|
||||||
|
<tr> <td>./FUSEISO/vtoy_fuse_iso_64</td> </tr>
|
||||||
|
<tr> <td>./FUSEISO/vtoy_fuse_iso_aa64</td> </tr>
|
||||||
|
<tr> <td>./IMG/cpio_arm64/ventoy/busybox/a64</td> <td>build</td> <td>Build Instructions:<br/>./BUSYBOX/build.txt ash</td> </tr>
|
||||||
|
<tr> <td>./IMG/cpio_arm64/ventoy/busybox/vtchmodaa64</td> <td>build</td> <td>Same with ./BUSYBOX/chmod/vtchmodaa64<br/>Check the file hash to confirm</td> </tr>
|
||||||
|
<tr> <td>./IMG/cpio_arm64/ventoy/busybox/xzminidecaa64</td> <td>build</td> <td>Build Instructions:<br/>./DOC/BuildVentoyFromSource.txt 4.17</td> </tr>
|
||||||
|
<tr> <td>./IMG/cpio_arm64/ventoy/tool/lz4cataa64</td> <td>build</td> <td>Same with ./LZIP/lz4cataa64<br/>Check the file hash to confirm</td> </tr>
|
||||||
|
<tr> <td>./IMG/cpio_arm64/ventoy/tool/zstdcataa64</td> <td>build</td> <td>Same with ./ZSTD/zstdcataa64<br/>Check the file hash to confirm</td> </tr>
|
||||||
|
<tr> <td>./IMG/cpio_mips64/ventoy/busybox/m64</td> <td>build</td> <td>Build Instructions:<br/>./BUSYBOX/build.txt ash</td> </tr>
|
||||||
|
<tr> <td>./IMG/cpio_mips64/ventoy/busybox/vtchmodm64e</td> <td>build</td> <td>Same with ./BUSYBOX/chmod/vtchmodm64e<br/>Check the file hash to confirm</td> </tr>
|
||||||
|
<tr> <td>./IMG/cpio_mips64/ventoy/busybox/xzminidecm64e</td> <td>build</td> <td>Build Instructions:<br/>./DOC/BuildVentoyFromSource.txt 4.18</td> </tr>
|
||||||
|
<tr> <td>./IMG/cpio_mips64/ventoy/tool/lz4catm64e</td> <td>build</td> <td>Same with ./LZIP/lz4catm64e<br/>Check the file hash to confirm</td> </tr>
|
||||||
|
<tr> <td>./IMG/cpio_x86/ventoy/busybox/64h</td> <td>build</td> <td>Build Instructions:<br/>./BUSYBOX/build.txt ash</td> </tr>
|
||||||
|
<tr> <td>./IMG/cpio_x86/ventoy/busybox/ash</td> <td>upstream</td> <td>Download from BusyBox website.<br/>URL & File Hash documented in<br/> ./DOC/BuildVentoyFromSource.txt 5.4</td> </tr>
|
||||||
|
<tr> <td>./IMG/cpio_x86/ventoy/busybox/vtchmod32</td> <td>build</td> <td>Same with ./BUSYBOX/chmod/vtchmod32<br/>Check the file hash to confirm</td> </tr>
|
||||||
|
<tr> <td>./IMG/cpio_x86/ventoy/busybox/vtchmod64</td> <td>build</td> <td>Same with ./BUSYBOX/chmod/vtchmod64<br/>Check the file hash to confirm</td> </tr>
|
||||||
|
<tr> <td>./IMG/cpio_x86/ventoy/busybox/vtchmod64_musl</td> <td>build</td> <td>Same with ./BUSYBOX/chmod/vtchmod64_musl<br/>Check the file hash to confirm</td> </tr>
|
||||||
|
<tr> <td>./IMG/cpio_x86/ventoy/busybox/xzminidec32</td> <td>build</td> <td>Build Instructions:<br/>./DOC/BuildVentoyFromSource.txt 4.15</td> </tr>
|
||||||
|
<tr> <td>./IMG/cpio_x86/ventoy/busybox/xzminidec64</td> <td>build</td> <td>Build Instructions:<br/>./DOC/BuildVentoyFromSource.txt 4.16</td> </tr>
|
||||||
|
<tr> <td>./IMG/cpio_x86/ventoy/busybox/xzminidec64_musl</td> <td>build</td> <td>Build Instructions:<br/>./DOC/BuildVentoyFromSource.txt 4.16</td> </tr>
|
||||||
|
<tr> <td>./IMG/cpio_x86/ventoy/tool/ar</td> <td>upstream</td> <td>Download from BusyBox website.<br/>URL & File Hash documented in<br/> ./DOC/BuildVentoyFromSource.txt 5.2</td> </tr>
|
||||||
|
<tr> <td>./IMG/cpio_x86/ventoy/tool/inotifyd</td> <td>upstream</td> <td>Download from BusyBox website.<br/>URL & File Hash documented in<br/> ./DOC/BuildVentoyFromSource.txt 5.3</td> </tr>
|
||||||
|
<tr> <td>./IMG/cpio_x86/ventoy/tool/lz4cat</td> <td>upstream</td> <td>URL & File Hash documented in<br/> ./DOC/BuildVentoyFromSource.txt 5.1</td> </tr>
|
||||||
|
<tr> <td>./IMG/cpio_x86/ventoy/tool/lz4cat64</td> <td>build</td> <td>Build Instructions:<br/>./LZIP/buildlz4.txt</td> </tr>
|
||||||
|
<tr> <td>./IMG/cpio_x86/ventoy/tool/zstdcat</td> <td>build</td> <td>Same with ./ZSTD/zstdcat<br/>Check the file hash to confirm</td> </tr>
|
||||||
|
<tr> <td>./IMG/cpio_x86/ventoy/tool/zstdcat64</td> <td>build</td> <td>Same with ./ZSTD/zstdcat64<br/>Check the file hash to confirm</td> </tr>
|
||||||
|
<tr> <td>./INSTALL/EFI/BOOT/BOOTAA64.EFI</td> <td rowspan=4>build</td> <td rowspan=4>Build Instructions:<br/> ./DOC/BuildVentoyFromSource.txt 4.1-Build grub2</td> </tr>
|
||||||
|
<tr> <td>./INSTALL/EFI/BOOT/BOOTMIPS.EFI</td> </tr>
|
||||||
|
<tr> <td>./INSTALL/EFI/BOOT/grubia32_real.efi</td></tr>
|
||||||
|
<tr> <td>./INSTALL/EFI/BOOT/grubx64_real.efi</td></tr>
|
||||||
|
<tr> <td>./INSTALL/EFI/BOOT/BOOTIA32.EFI</td> <td rowspan=3>upstream</td> <td rowspan=3>https://github.com/ValdikSS/Super-UEFIinSecureBoot-Disk </td> </tr>
|
||||||
|
<tr> <td>./INSTALL/EFI/BOOT/grubia32.efi</td></tr>
|
||||||
|
<tr> <td>./INSTALL/EFI/BOOT/mmia32.efi</td></tr>
|
||||||
|
<tr> <td>./INSTALL/EFI/BOOT/BOOTX64.EFI</td> <td rowspan=2>upstream</td> <td rowspan=2>From Rocky Linux 9.8 x86_64 ISO file<br/>Check the file hash to confirm </td> </tr>
|
||||||
|
<tr> <td>./INSTALL/EFI/BOOT/mmx64.efi</td></tr>
|
||||||
|
<tr> <td>./INSTALL/tool/aarch64/ash</td> <td rowspan=12>build</td> <td rowspan=12>Build Instructions:<br/>./DOC/BUSYBOX/build.txt</td> </tr>
|
||||||
|
<tr> <td>./INSTALL/tool/aarch64/hexdump</td></tr>
|
||||||
|
<tr> <td>./INSTALL/tool/aarch64/xzcat</td></tr>
|
||||||
|
<tr> <td>./INSTALL/tool/i386/ash</td></tr>
|
||||||
|
<tr> <td>./INSTALL/tool/i386/hexdump</td></tr>
|
||||||
|
<tr> <td>./INSTALL/tool/i386/xzcat</td></tr>
|
||||||
|
<tr> <td>./INSTALL/tool/mips64el/ash</td></tr>
|
||||||
|
<tr> <td>./INSTALL/tool/mips64el/hexdump</td></tr>
|
||||||
|
<tr> <td>./INSTALL/tool/mips64el/xzcat</td></tr>
|
||||||
|
<tr> <td>./INSTALL/tool/x86_64/ash</td></tr>
|
||||||
|
<tr> <td>./INSTALL/tool/x86_64/hexdump</td></tr>
|
||||||
|
<tr> <td>./INSTALL/tool/x86_64/xzcat</td></tr>
|
||||||
|
<tr> <td>./INSTALL/tool/aarch64/Ventoy2Disk.gtk3</td> <td rowspan=6>build</td> <td rowspan=6>Build Instructions:<br/>./LinuxGUI/build_gtk.sh</td> </tr>
|
||||||
|
<tr> <td>./INSTALL/tool/i386/Ventoy2Disk.gtk3</td></tr>
|
||||||
|
<tr> <td>./INSTALL/tool/i386/Ventoy2Disk.gtk2</td></tr>
|
||||||
|
<tr> <td>./INSTALL/tool/mips64el/Ventoy2Disk.gtk3</td></tr>
|
||||||
|
<tr> <td>./INSTALL/tool/x86_64/Ventoy2Disk.gtk3</td></tr>
|
||||||
|
<tr> <td>./INSTALL/tool/x86_64/Ventoy2Disk.gtk2</td></tr>
|
||||||
|
<tr> <td>./INSTALL/tool/aarch64/Ventoy2Disk.qt5</td> <td rowspan=4>build</td> <td rowspan=4>Build Instructions:<br/>./LinuxGUI/build_qt.sh</td> </tr>
|
||||||
|
<tr> <td>./INSTALL/tool/i386/Ventoy2Disk.qt5</td></tr>
|
||||||
|
<tr> <td>./INSTALL/tool/mips64el/Ventoy2Disk.qt5</td></tr>
|
||||||
|
<tr> <td>./INSTALL/tool/x86_64/Ventoy2Disk.qt5</td></tr>
|
||||||
|
<tr> <td>./INSTALL/tool/aarch64/Plugson</td> <td rowspan=4>build</td> <td rowspan=4>Build Instructions:<br/>./Plugson/build.sh</td> </tr>
|
||||||
|
<tr> <td>./INSTALL/tool/i386/Plugson</td></tr>
|
||||||
|
<tr> <td>./INSTALL/tool/mips64el/Plugson</td></tr>
|
||||||
|
<tr> <td>./INSTALL/tool/x86_64/Plugson</td></tr>
|
||||||
|
<tr> <td>./INSTALL/tool/aarch64/V2DServer</td> <td rowspan=4>build</td> <td rowspan=4>Build Instructions:<br/>./LinuxGUI/build.sh</td> </tr>
|
||||||
|
<tr> <td>./INSTALL/tool/i386/V2DServer</td></tr>
|
||||||
|
<tr> <td>./INSTALL/tool/mips64el/V2DServer</td></tr>
|
||||||
|
<tr> <td>./INSTALL/tool/x86_64/V2DServer</td></tr>
|
||||||
|
<tr> <td>./INSTALL/tool/aarch64/mkexfatfs</td> <td rowspan=9>build</td> <td rowspan=8>Build Instructions:<br/>./DOC/BuildVentoyFromSource.txt 4.9<br/>./ExFAT/buidexfat.sh<br/>./ExFAT/buidexfat_aarch64.sh<br/>./ExFAT/buidlibfuse.sh<br/>./ExFAT/buidlibfuse_aarch64.sh<br/></td> </tr>
|
||||||
|
<tr> <td>./INSTALL/tool/aarch64/mount.exfat-fuse</td></tr>
|
||||||
|
<tr> <td>./INSTALL/tool/i386/mkexfatfs</td></tr>
|
||||||
|
<tr> <td>./INSTALL/tool/i386/mount.exfat-fuse</td></tr>
|
||||||
|
<tr> <td>./INSTALL/tool/mips64el/mkexfatfs</td></tr>
|
||||||
|
<tr> <td>./INSTALL/tool/mips64el/mount.exfat-fuse</td></tr>
|
||||||
|
<tr> <td>./INSTALL/tool/x86_64/mkexfatfs</td></tr>
|
||||||
|
<tr> <td>./INSTALL/tool/x86_64/mkexfatfs_static</td></tr>
|
||||||
|
<tr> <td>./INSTALL/tool/x86_64/mount.exfat-fuse</td> </tr>
|
||||||
|
<tr> <td>./INSTALL/tool/aarch64/vlnk</td> <td rowspan=4>build</td> <td rowspan=4>Build Instructions:<br/>./Vlnk/build.sh</td> </tr>
|
||||||
|
<tr> <td>./INSTALL/tool/i386/vlnk</td></tr>
|
||||||
|
<tr> <td>./INSTALL/tool/mips64el/vlnk</td></tr>
|
||||||
|
<tr> <td>./INSTALL/tool/x86_64/vlnk</td></tr>
|
||||||
|
<tr> <td>./INSTALL/tool/aarch64/vtoycli</td> <td rowspan=4>build</td> <td rowspan=4>Build Instructions:<br/>./vtoycli/build.sh</td> </tr>
|
||||||
|
<tr> <td>./INSTALL/tool/i386/vtoycli</td></tr>
|
||||||
|
<tr> <td>./INSTALL/tool/mips64el/vtoycli</td></tr>
|
||||||
|
<tr> <td>./INSTALL/tool/x86_64/vtoycli</td></tr>
|
||||||
|
<tr> <td>./INSTALL/ventoy/imdisk/32/imdisk.cpl</td> <td rowspan=6>upstream</td> <td rowspan=6>Download from imdisk project.<br/>URL & File Hash documented in<br/> ./DOC/BuildVentoyFromSource.txt 5.8</td> </tr>
|
||||||
|
<tr> <td>./INSTALL/ventoy/imdisk/32/imdisk.exe</td></tr>
|
||||||
|
<tr> <td>./INSTALL/ventoy/imdisk/32/imdisk.sys</td></tr>
|
||||||
|
<tr> <td>./INSTALL/ventoy/imdisk/64/imdisk.cpl</td></tr>
|
||||||
|
<tr> <td>./INSTALL/ventoy/imdisk/64/imdisk.exe</td></tr>
|
||||||
|
<tr> <td>./INSTALL/ventoy/imdisk/64/imdisk.sys</td></tr>
|
||||||
|
<tr> <td>./INSTALL/ventoy/iso9660_aa64.efi</td> <td rowspan=6>build</td> <td rowspan=6>Build Instructions:<br/>./DOC/BuildVentoyFromSource.txt 4.17</td> </tr>
|
||||||
|
<tr> <td>./INSTALL/ventoy/udf_aa64.efi</td></tr>
|
||||||
|
<tr> <td>./INSTALL/ventoy/iso9660_ia32.efi</td></tr>
|
||||||
|
<tr> <td>./INSTALL/ventoy/udf_ia32.efi</td></tr>
|
||||||
|
<tr> <td>./INSTALL/ventoy/iso9660_x64.efi</td></tr>
|
||||||
|
<tr> <td>./INSTALL/ventoy/udf_x64.efi</td></tr>
|
||||||
|
<tr> <td>./INSTALL/VentoyGUI.aarch64</td> <td rowspan=4>build</td> <td rowspan=4>Build Instructions:<br/>./LinuxGUI/build_gtk.sh</td> </tr>
|
||||||
|
<tr> <td>./INSTALL/VentoyGUI.i386</td></tr>
|
||||||
|
<tr> <td>./INSTALL/VentoyGUI.mips64el</td></tr>
|
||||||
|
<tr> <td>./INSTALL/VentoyGUI.x86_64</td></tr>
|
||||||
|
<tr> <td>./INSTALL/Ventoy2Disk.exe</td> <td rowspan=4>build</td> <td rowspan=4>Build Instructions:<br/>./Ventoy2Disk/Ventoy2Disk.sln</td> </tr>
|
||||||
|
<tr> <td>./INSTALL/Ventoy2Disk_ARM.exe</td></tr>
|
||||||
|
<tr> <td>./INSTALL/Ventoy2Disk_ARM64.exe</td></tr>
|
||||||
|
<tr> <td>./INSTALL/Ventoy2Disk_X64.exe</td></tr>
|
||||||
|
<tr> <td>./INSTALL/ventoy/vtoyjump32.exe</td> <td rowspan=2>build</td> <td rowspan=2>Build Instructions:<br/>./vtoyjump/vtoyjump.sln</td> </tr>
|
||||||
|
<tr> <td>./INSTALL/ventoy/vtoyjump64.exe</td></tr>
|
||||||
|
<tr> <td>./INSTALL/ventoy/ventoy_aa64.efi</td> <td rowspan=7>build</td> <td rowspan=7>Build Instructions:<br/>./EDK2/buildedk.sh</td> </tr>
|
||||||
|
<tr> <td>./INSTALL/ventoy/ventoy_ia32.efi</td></tr>
|
||||||
|
<tr> <td>./INSTALL/ventoy/ventoy_x64.efi</td></tr>
|
||||||
|
<tr> <td>./INSTALL/ventoy/vtoyutil_aa64.efi</td></tr>
|
||||||
|
<tr> <td>./INSTALL/ventoy/vtoyutil_ia32.efi</td></tr>
|
||||||
|
<tr> <td>./INSTALL/ventoy/vtoyutil_x64.efi</td></tr>
|
||||||
|
<tr> <td>./INSTALL/EFI/BOOT/fbx64.efi</td></tr>
|
||||||
|
<tr> <td>./INSTALL/ventoy/ipxe.krn</td> <td>build</td> <td>Build Instructions:<br/>./IPXE/buildipxe.sh</td> </tr>
|
||||||
|
<tr> <td>./INSTALL/ventoy/memdisk</td> <td>upstream</td> <td>Download from syslinux project.<br/>URL & File Hash documented in<br/> ./DOC/BuildVentoyFromSource.txt 5.9</td> </tr>
|
||||||
|
<tr> <td>./LiveCD/ISO/EFI/boot/vmlinuz64</td> <td>upstream</td> <td>Download from TinyLinux website.<br/>URL & File Hash documented in<br/> ./DOC/BuildVentoyFromSource.txt 5.14</td> </tr>
|
||||||
|
<tr> <td>./LiveCDGUI/EXT/busybox-x86_64</td> <td>build</td> <td>Same with ./IMG/cpio_x86/ventoy/busybox/busybox64<br/>Check the file hash to confirm</td> </tr>
|
||||||
|
<tr> <td>./LiveCDGUI/GRUB/bootx64.efi</td> <td rowspan=2>build</td> <td rowspan=2>./DOC/BuildVentoyFromSource.txt 4.1-Build grub2</td> </tr>
|
||||||
|
<tr> <td>./LiveCD/GRUB/bootx64.efi</td></tr>
|
||||||
|
<tr> <td>./LZIP/lunzip32</td> <td rowspan=3>build</td> <td rowspan=3>Build Instructions:<br/>./DOC/BuildVentoyFromSource.txt 4.19</td> </tr>
|
||||||
|
<tr> <td>./LZIP/lunzip64</td></tr>
|
||||||
|
<tr> <td>./LZIP/lunzipaa64</td></tr>
|
||||||
|
<tr> <td>./LZIP/lz4cat64</td> <td rowspan=3>build</td> <td rowspan=3>Build Instructions:<br/>./LZIP/buildlz4.txt</td> </tr>
|
||||||
|
<tr> <td>./LZIP/lz4cataa64</td></tr>
|
||||||
|
<tr> <td>./LZIP/lz4catm64e</td></tr>
|
||||||
|
<tr> <td>./Plugson/vs/VentoyPlugson/Release/VentoyPlugson.exe</td> <td rowspan=2>build</td> <td rowspan=2>Build Instructions:<br/>./Plugson/vs/VentoyPlugson/VentoyPlugson.sln</td> </tr>
|
||||||
|
<tr> <td>./Plugson/vs/VentoyPlugson/x64/Release/VentoyPlugson_X64.exe</td></tr>
|
||||||
|
<tr> <td>./SQUASHFS/unsquashfs_32</td> <td rowspan=3>build</td> <td rowspan=3>Build Instructions:<br/>./SQUASHFS/build.sh</td> </tr>
|
||||||
|
<tr> <td>./SQUASHFS/unsquashfs_64</td></tr>
|
||||||
|
<tr> <td>./SQUASHFS/unsquashfs_aa64</td></tr>
|
||||||
|
<tr> <td>./Unix/ventoy_unix/DragonFly/sbin/dmsetup</td> <td>upstream</td> <td>Get from DragonFly ISO.<br/>URL & File Hash documented in<br/> ./DOC/BuildVentoyFromSource.txt 5.13</td> </tr>
|
||||||
|
<tr> <td>./Unix/ventoy_unix/DragonFly/sbin/init</td> <td>build</td> <td>Build Instructions:<br/>./Unix/ventoy_unix_src/DragonFly/build.sh</td> </tr>
|
||||||
|
<tr> <td>./VBLADE/vblade-master/vblade_32</td> <td rowspan=3>build</td> <td rowspan=3>Build Instructions:<br/>./VBLADE/vblade-master/build.sh</td> </tr>
|
||||||
|
<tr> <td>./VBLADE/vblade-master/vblade_64</td></tr>
|
||||||
|
<tr> <td>./VBLADE/vblade-master/vblade_aa64</td></tr>
|
||||||
|
<tr> <td>./Vlnk/vs/VentoyVlnk/Release/VentoyVlnk.exe</td> <td>build</td> <td>Build Instructions:<br/>./Vlnk/vs/VentoyVlnk/VentoyVlnk.sln</td> </tr>
|
||||||
|
<tr> <td>./VtoyTool/vtoytool/00/vtoytool_32</td> <td rowspan=6>build</td> <td rowspan=6>Build Instructions:<br/>./VtoyTool/build.sh</td> </tr>
|
||||||
|
<tr> <td>./VtoyTool/vtoytool/00/vtoytool_64</td></tr>
|
||||||
|
<tr> <td>./VtoyTool/vtoytool/00/vtoytool_aa64</td></tr>
|
||||||
|
<tr> <td>./VtoyTool/vtoytool/00/vtoytool_m64e</td></tr>
|
||||||
|
<tr> <td>./VtoyTool/vtoytool/01/vtoytool_64</td></tr>
|
||||||
|
<tr> <td>./VtoyTool/vtoytool/02/vtoytool_64</td></tr>
|
||||||
|
<tr> <td>./ZSTD/zstdcat</td> <td rowspan=3>build</td> <td rowspan=3>Build Instructions:<br/>./ZSTD/build.txt</td> </tr>
|
||||||
|
<tr> <td>./ZSTD/zstdcat64</td></tr>
|
||||||
|
<tr> <td>./ZSTD/zstdcataa64</td></tr>
|
||||||
|
<tr> <td>./IMG/cpio_x86/ventoy/busybox/busybox32</td> <td rowspan=6>build</td> <td rowspan=6>Build Instructions:<br/>./BUSYBOX/build.txt full busybox</td> </tr>
|
||||||
|
<tr> <td>./IMG/cpio_x86/ventoy/busybox/busybox64</td></tr>
|
||||||
|
<tr> <td>./IMG/cpio_x86/ventoy/busybox/xzcat32_musl</td></tr>
|
||||||
|
<tr> <td>./IMG/cpio_x86/ventoy/busybox/xzcat64_musl</td></tr>
|
||||||
|
<tr> <td>./IMG/cpio_arm64/ventoy/busybox/busyboxaa64</td></tr>
|
||||||
|
<tr> <td>./IMG/cpio_mips64/ventoy/busybox/busyboxm64e</td> </tr>
|
||||||
|
<tr> <td>ISNTALL/ventoy/7z/64/7za.exe</td> <td rowspan=2>upstream</td> <td>Download from 7z project.<br/>URL & File Hash documented in<br/> ./DOC/BuildVentoyFromSource.txt 5.12</td> </tr>
|
||||||
|
<tr> <td>ISNTALL/ventoy/7z/32/7za.exe</td></tr>
|
||||||
|
<tr> <td>./INSTALL/ventoy/wimboot.i386.efi</td> <td rowspan=2>build</td> <td rowspan=2>Build Instructions:<br/>./wimboot/build.sh</td> </tr>
|
||||||
|
<tr> <td>./INSTALL/ventoy/wimboot.x86_64</td></tr>
|
||||||
|
<tr> <td> ./Unix/ventoy_unix/ClonOS/geom_ventoy_ko/13.x/64/geom_ventoy.ko</td> <td rowspan=18>build</td> <td rowspan=18>Build Instructions:<br/>./Unix/BuildUnixKmod.txt</td> </tr>
|
||||||
|
<tr> <td> ./Unix/ventoy_unix/FreeBSD/geom_ventoy_ko/10.x/32/geom_ventoy.ko</td></tr>
|
||||||
|
<tr> <td> ./Unix/ventoy_unix/FreeBSD/geom_ventoy_ko/10.x/64/geom_ventoy.ko</td></tr>
|
||||||
|
<tr> <td> ./Unix/ventoy_unix/FreeBSD/geom_ventoy_ko/11.x/32/geom_ventoy.ko</td></tr>
|
||||||
|
<tr> <td> ./Unix/ventoy_unix/FreeBSD/geom_ventoy_ko/11.x/64/geom_ventoy.ko</td></tr>
|
||||||
|
<tr> <td> ./Unix/ventoy_unix/FreeBSD/geom_ventoy_ko/12.x/32/geom_ventoy.ko</td></tr>
|
||||||
|
<tr> <td> ./Unix/ventoy_unix/FreeBSD/geom_ventoy_ko/12.x/64/geom_ventoy.ko</td></tr>
|
||||||
|
<tr> <td> ./Unix/ventoy_unix/FreeBSD/geom_ventoy_ko/13.x/32/geom_ventoy.ko</td></tr>
|
||||||
|
<tr> <td> ./Unix/ventoy_unix/FreeBSD/geom_ventoy_ko/13.x/64/geom_ventoy.ko</td></tr>
|
||||||
|
<tr> <td> ./Unix/ventoy_unix/FreeBSD/geom_ventoy_ko/14.x/32/geom_ventoy.ko</td></tr>
|
||||||
|
<tr> <td> ./Unix/ventoy_unix/FreeBSD/geom_ventoy_ko/14.x/64/geom_ventoy.ko</td></tr>
|
||||||
|
<tr> <td> ./Unix/ventoy_unix/FreeBSD/geom_ventoy_ko/9.x/32/geom_ventoy.ko</td></tr>
|
||||||
|
<tr> <td> ./Unix/ventoy_unix/FreeBSD/geom_ventoy_ko/9.x/64/geom_ventoy.ko</td></tr>
|
||||||
|
<tr> <td> ./Unix/ventoy_unix/MidnightBSD/geom_ventoy_ko/11.x/32/geom_ventoy.ko</td></tr>
|
||||||
|
<tr> <td> ./Unix/ventoy_unix/MidnightBSD/geom_ventoy_ko/11.x/64/geom_ventoy.ko</td></tr>
|
||||||
|
<tr> <td> ./Unix/ventoy_unix/MidnightBSD/geom_ventoy_ko/2.x/32/geom_ventoy.ko</td></tr>
|
||||||
|
<tr> <td> ./Unix/ventoy_unix/MidnightBSD/geom_ventoy_ko/2.x/64/geom_ventoy.ko</td></tr>
|
||||||
|
<tr> <td> ./Unix/ventoy_unix/pfSense/geom_ventoy_ko/14.x/64/geom_ventoy.ko</td></tr>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
@@ -1,7 +0,0 @@
|
|||||||
|
|
||||||
obj-m += dm_patch.o
|
|
||||||
|
|
||||||
EXTRA_CFLAGS := -Wall
|
|
||||||
|
|
||||||
dm_patch-objs := dmpatch.o
|
|
||||||
|
|
||||||
@@ -1,7 +0,0 @@
|
|||||||
|
|
||||||
obj-m += dm_patch_ibt.o
|
|
||||||
|
|
||||||
EXTRA_CFLAGS := -Wall -DVTOY_IBT -fcf-protection=branch -mindirect-branch-register
|
|
||||||
|
|
||||||
dm_patch_ibt-objs := dmpatch.o
|
|
||||||
|
|
||||||
@@ -1,393 +0,0 @@
|
|||||||
/******************************************************************************
|
|
||||||
* dmpatch.c ---- patch for device-mapper
|
|
||||||
*
|
|
||||||
* Copyright (c) 2021, longpanda <admin@ventoy.net>
|
|
||||||
*
|
|
||||||
* This program is free software; you can redistribute it and/or
|
|
||||||
* modify it under the terms of the GNU General Public License as
|
|
||||||
* published by the Free Software Foundation; either version 3 of the
|
|
||||||
* License, or (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful, but
|
|
||||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
||||||
* General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program; if not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <linux/init.h>
|
|
||||||
#include <linux/module.h>
|
|
||||||
#include <linux/kallsyms.h>
|
|
||||||
#include <linux/mutex.h>
|
|
||||||
#include <linux/mempool.h>
|
|
||||||
#include <linux/delay.h>
|
|
||||||
#include <linux/wait.h>
|
|
||||||
#include <linux/slab.h>
|
|
||||||
|
|
||||||
#define MAX_PATCH 4
|
|
||||||
|
|
||||||
#define magic_sig 0xB0, 0xB1, 0xB2, 0xB3, 0xB4, 0xB5, 0xB6, 0xB7, 0xB8, 0xB9, 0xBA, 0xBB, 0xBC, 0xBD, 0xBE, 0xBF
|
|
||||||
|
|
||||||
typedef int (*kprobe_reg_pf)(void *);
|
|
||||||
typedef void (*kprobe_unreg_pf)(void *);
|
|
||||||
typedef int (*printk_pf)(const char *fmt, ...);
|
|
||||||
typedef int (*set_memory_attr_pf)(unsigned long addr, int numpages);
|
|
||||||
|
|
||||||
#pragma pack(1)
|
|
||||||
typedef struct ko_param
|
|
||||||
{
|
|
||||||
unsigned char magic[16];
|
|
||||||
unsigned long struct_size;
|
|
||||||
unsigned long pgsize;
|
|
||||||
unsigned long printk_addr;
|
|
||||||
unsigned long ro_addr;
|
|
||||||
unsigned long rw_addr;
|
|
||||||
unsigned long reg_kprobe_addr;
|
|
||||||
unsigned long unreg_kprobe_addr;
|
|
||||||
unsigned long sym_get_addr;
|
|
||||||
unsigned long sym_get_size;
|
|
||||||
unsigned long sym_put_addr;
|
|
||||||
unsigned long sym_put_size;
|
|
||||||
unsigned long kv_major;
|
|
||||||
unsigned long ibt;
|
|
||||||
unsigned long padding[1];
|
|
||||||
}ko_param;
|
|
||||||
|
|
||||||
#pragma pack()
|
|
||||||
|
|
||||||
static printk_pf kprintf = NULL;
|
|
||||||
static set_memory_attr_pf set_mem_ro = NULL;
|
|
||||||
static set_memory_attr_pf set_mem_rw = NULL;
|
|
||||||
static kprobe_reg_pf reg_kprobe = NULL;
|
|
||||||
static kprobe_unreg_pf unreg_kprobe = NULL;
|
|
||||||
|
|
||||||
static volatile ko_param g_ko_param =
|
|
||||||
{
|
|
||||||
{ magic_sig },
|
|
||||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
|
|
||||||
};
|
|
||||||
|
|
||||||
#if defined(CONFIG_X86_64)
|
|
||||||
#define PATCH_OP_POS1 3
|
|
||||||
#define CODE_MATCH1(code, i) \
|
|
||||||
(code[i] == 0x40 && code[i + 1] == 0x80 && code[i + 2] == 0xce && code[i + 3] == 0x80)
|
|
||||||
|
|
||||||
#define PATCH_OP_POS2 1
|
|
||||||
#define CODE_MATCH2(code, i) \
|
|
||||||
(code[i] == 0x0C && code[i + 1] == 0x80 && code[i + 2] == 0x89 && code[i + 3] == 0xC6)
|
|
||||||
|
|
||||||
#define PATCH_OP_POS3 4
|
|
||||||
#define CODE_MATCH3(code, i) \
|
|
||||||
(code[i] == 0x44 && code[i + 1] == 0x89 && code[i + 2] == 0xe8 && code[i + 3] == 0x0c && code[i + 4] == 0x80)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#elif defined(CONFIG_X86_32)
|
|
||||||
#define PATCH_OP_POS1 2
|
|
||||||
#define CODE_MATCH1(code, i) \
|
|
||||||
(code[i] == 0x80 && code[i + 1] == 0xca && code[i + 2] == 0x80 && code[i + 3] == 0xe8)
|
|
||||||
|
|
||||||
#define PATCH_OP_POS2 PATCH_OP_POS1
|
|
||||||
#define CODE_MATCH2 CODE_MATCH1
|
|
||||||
#define PATCH_OP_POS3 PATCH_OP_POS1
|
|
||||||
#define CODE_MATCH3 CODE_MATCH1
|
|
||||||
|
|
||||||
|
|
||||||
#else
|
|
||||||
#error "unsupported arch"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef VTOY_IBT
|
|
||||||
#ifdef CONFIG_X86_64
|
|
||||||
/* Using 64-bit values saves one instruction clearing the high half of low */
|
|
||||||
#define DECLARE_ARGS(val, low, high) unsigned long low, high
|
|
||||||
#define EAX_EDX_VAL(val, low, high) ((low) | (high) << 32)
|
|
||||||
#define EAX_EDX_RET(val, low, high) "=a" (low), "=d" (high)
|
|
||||||
#else
|
|
||||||
#define DECLARE_ARGS(val, low, high) unsigned long long val
|
|
||||||
#define EAX_EDX_VAL(val, low, high) (val)
|
|
||||||
#define EAX_EDX_RET(val, low, high) "=A" (val)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define EX_TYPE_WRMSR 8
|
|
||||||
#define EX_TYPE_RDMSR 9
|
|
||||||
#define MSR_IA32_S_CET 0x000006a2 /* kernel mode cet */
|
|
||||||
#define CET_ENDBR_EN (1ULL << 2)
|
|
||||||
|
|
||||||
/* Exception table entry */
|
|
||||||
#ifdef __ASSEMBLY__
|
|
||||||
|
|
||||||
#define _ASM_EXTABLE_TYPE(from, to, type) \
|
|
||||||
.pushsection "__ex_table","a" ; \
|
|
||||||
.balign 4 ; \
|
|
||||||
.long (from) - . ; \
|
|
||||||
.long (to) - . ; \
|
|
||||||
.long type ; \
|
|
||||||
.popsection
|
|
||||||
|
|
||||||
#else /* ! __ASSEMBLY__ */
|
|
||||||
|
|
||||||
#define _ASM_EXTABLE_TYPE(from, to, type) \
|
|
||||||
" .pushsection \"__ex_table\",\"a\"\n" \
|
|
||||||
" .balign 4\n" \
|
|
||||||
" .long (" #from ") - .\n" \
|
|
||||||
" .long (" #to ") - .\n" \
|
|
||||||
" .long " __stringify(type) " \n" \
|
|
||||||
" .popsection\n"
|
|
||||||
|
|
||||||
#endif /* __ASSEMBLY__ */
|
|
||||||
#endif /* VTOY_IBT */
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#define vdebug(fmt, args...) if(kprintf) kprintf(KERN_ERR fmt, ##args)
|
|
||||||
|
|
||||||
static unsigned char *g_get_patch[MAX_PATCH] = { NULL };
|
|
||||||
static unsigned char *g_put_patch[MAX_PATCH] = { NULL };
|
|
||||||
|
|
||||||
static void notrace dmpatch_restore_code(unsigned char *opCode)
|
|
||||||
{
|
|
||||||
unsigned long align;
|
|
||||||
|
|
||||||
if (opCode)
|
|
||||||
{
|
|
||||||
align = (unsigned long)opCode / g_ko_param.pgsize * g_ko_param.pgsize;
|
|
||||||
set_mem_rw(align, 1);
|
|
||||||
*opCode = 0x80;
|
|
||||||
set_mem_ro(align, 1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static int notrace dmpatch_replace_code
|
|
||||||
(
|
|
||||||
int style,
|
|
||||||
unsigned long addr,
|
|
||||||
unsigned long size,
|
|
||||||
int expect,
|
|
||||||
const char *desc,
|
|
||||||
unsigned char **patch
|
|
||||||
)
|
|
||||||
{
|
|
||||||
int i = 0;
|
|
||||||
int cnt = 0;
|
|
||||||
unsigned long align;
|
|
||||||
unsigned char *opCode = (unsigned char *)addr;
|
|
||||||
|
|
||||||
vdebug("patch for %s style[%d] 0x%lx %d\n", desc, style, addr, (int)size);
|
|
||||||
|
|
||||||
for (i = 0; i < (int)size - 8; i++)
|
|
||||||
{
|
|
||||||
if (style == 1)
|
|
||||||
{
|
|
||||||
if (CODE_MATCH1(opCode, i) && cnt < MAX_PATCH)
|
|
||||||
{
|
|
||||||
patch[cnt] = opCode + i + PATCH_OP_POS1;
|
|
||||||
cnt++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (style == 2)
|
|
||||||
{
|
|
||||||
if (CODE_MATCH2(opCode, i) && cnt < MAX_PATCH)
|
|
||||||
{
|
|
||||||
patch[cnt] = opCode + i + PATCH_OP_POS2;
|
|
||||||
cnt++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (style == 3)
|
|
||||||
{
|
|
||||||
if (CODE_MATCH3(opCode, i) && cnt < MAX_PATCH)
|
|
||||||
{
|
|
||||||
patch[cnt] = opCode + i + PATCH_OP_POS3;
|
|
||||||
cnt++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if (cnt != expect || cnt >= MAX_PATCH)
|
|
||||||
{
|
|
||||||
vdebug("patch error: cnt=%d expect=%d\n", cnt, expect);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
for (i = 0; i < cnt; i++)
|
|
||||||
{
|
|
||||||
opCode = patch[i];
|
|
||||||
align = (unsigned long)opCode / g_ko_param.pgsize * g_ko_param.pgsize;
|
|
||||||
|
|
||||||
set_mem_rw(align, 1);
|
|
||||||
*opCode = 0;
|
|
||||||
set_mem_ro(align, 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef VTOY_IBT
|
|
||||||
static __always_inline unsigned long long dmpatch_rdmsr(unsigned int msr)
|
|
||||||
{
|
|
||||||
DECLARE_ARGS(val, low, high);
|
|
||||||
|
|
||||||
asm volatile("1: rdmsr\n"
|
|
||||||
"2:\n"
|
|
||||||
_ASM_EXTABLE_TYPE(1b, 2b, EX_TYPE_RDMSR)
|
|
||||||
: EAX_EDX_RET(val, low, high) : "c" (msr));
|
|
||||||
|
|
||||||
return EAX_EDX_VAL(val, low, high);
|
|
||||||
}
|
|
||||||
|
|
||||||
static __always_inline void dmpatch_wrmsr(unsigned int msr, u32 low, u32 high)
|
|
||||||
{
|
|
||||||
asm volatile("1: wrmsr\n"
|
|
||||||
"2:\n"
|
|
||||||
_ASM_EXTABLE_TYPE(1b, 2b, EX_TYPE_WRMSR)
|
|
||||||
: : "c" (msr), "a"(low), "d" (high) : "memory");
|
|
||||||
}
|
|
||||||
|
|
||||||
static u64 dmpatch_ibt_save(void)
|
|
||||||
{
|
|
||||||
u64 msr = 0;
|
|
||||||
u64 val = 0;
|
|
||||||
|
|
||||||
msr = dmpatch_rdmsr(MSR_IA32_S_CET);
|
|
||||||
val = msr & ~CET_ENDBR_EN;
|
|
||||||
dmpatch_wrmsr(MSR_IA32_S_CET, (u32)(val & 0xffffffffULL), (u32)(val >> 32));
|
|
||||||
|
|
||||||
return msr;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void dmpatch_ibt_restore(u64 save)
|
|
||||||
{
|
|
||||||
u64 msr;
|
|
||||||
|
|
||||||
msr = dmpatch_rdmsr(MSR_IA32_S_CET);
|
|
||||||
|
|
||||||
msr &= ~CET_ENDBR_EN;
|
|
||||||
msr |= (save & CET_ENDBR_EN);
|
|
||||||
|
|
||||||
dmpatch_wrmsr(MSR_IA32_S_CET, (u32)(msr & 0xffffffffULL), (u32)(msr >> 32));
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
static u64 dmpatch_ibt_save(void) { return 0; }
|
|
||||||
static void dmpatch_ibt_restore(u64 save) { (void)save; }
|
|
||||||
#endif
|
|
||||||
|
|
||||||
static int notrace dmpatch_init(void)
|
|
||||||
{
|
|
||||||
int r = 0;
|
|
||||||
int rc = 0;
|
|
||||||
u64 msr = 0;
|
|
||||||
|
|
||||||
if (g_ko_param.ibt == 0x8888)
|
|
||||||
{
|
|
||||||
msr = dmpatch_ibt_save();
|
|
||||||
}
|
|
||||||
|
|
||||||
kprintf = (printk_pf)(g_ko_param.printk_addr);
|
|
||||||
|
|
||||||
vdebug("dmpatch_init start pagesize=%lu ...\n", g_ko_param.pgsize);
|
|
||||||
|
|
||||||
if (g_ko_param.struct_size != sizeof(ko_param))
|
|
||||||
{
|
|
||||||
vdebug("Invalid struct size %d %d\n", (int)g_ko_param.struct_size, (int)sizeof(ko_param));
|
|
||||||
return -EINVAL;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (g_ko_param.sym_get_addr == 0 || g_ko_param.sym_put_addr == 0 ||
|
|
||||||
g_ko_param.ro_addr == 0 || g_ko_param.rw_addr == 0)
|
|
||||||
{
|
|
||||||
return -EINVAL;
|
|
||||||
}
|
|
||||||
|
|
||||||
set_mem_ro = (set_memory_attr_pf)(g_ko_param.ro_addr);
|
|
||||||
set_mem_rw = (set_memory_attr_pf)(g_ko_param.rw_addr);
|
|
||||||
reg_kprobe = (kprobe_reg_pf)g_ko_param.reg_kprobe_addr;
|
|
||||||
unreg_kprobe = (kprobe_unreg_pf)g_ko_param.unreg_kprobe_addr;
|
|
||||||
|
|
||||||
r = dmpatch_replace_code(1, g_ko_param.sym_get_addr, g_ko_param.sym_get_size, 2, "dm_get_table_device", g_get_patch);
|
|
||||||
if (r && g_ko_param.kv_major >= 5)
|
|
||||||
{
|
|
||||||
vdebug("new2 patch dm_get_table_device...\n");
|
|
||||||
r = dmpatch_replace_code(2, g_ko_param.sym_get_addr, g_ko_param.sym_get_size, 1, "dm_get_table_device", g_get_patch);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (r && g_ko_param.kv_major >= 5)
|
|
||||||
{
|
|
||||||
vdebug("new3 patch dm_get_table_device...\n");
|
|
||||||
r = dmpatch_replace_code(3, g_ko_param.sym_get_addr, g_ko_param.sym_get_size, 1, "dm_get_table_device", g_get_patch);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
if (r)
|
|
||||||
{
|
|
||||||
rc = -EINVAL;
|
|
||||||
goto out;
|
|
||||||
}
|
|
||||||
vdebug("patch dm_get_table_device success\n");
|
|
||||||
|
|
||||||
r = dmpatch_replace_code(1, g_ko_param.sym_put_addr, g_ko_param.sym_put_size, 1, "dm_put_table_device", g_put_patch);
|
|
||||||
if (r)
|
|
||||||
{
|
|
||||||
rc = -EINVAL;
|
|
||||||
goto out;
|
|
||||||
}
|
|
||||||
vdebug("patch dm_put_table_device success\n");
|
|
||||||
|
|
||||||
vdebug("#####################################\n");
|
|
||||||
vdebug("######## dm patch success ###########\n");
|
|
||||||
vdebug("#####################################\n");
|
|
||||||
|
|
||||||
if (g_ko_param.ibt == 0x8888)
|
|
||||||
{
|
|
||||||
dmpatch_ibt_restore(msr);
|
|
||||||
}
|
|
||||||
|
|
||||||
out:
|
|
||||||
|
|
||||||
return rc;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void notrace dmpatch_exit(void)
|
|
||||||
{
|
|
||||||
int i = 0;
|
|
||||||
u64 msr;
|
|
||||||
|
|
||||||
if (g_ko_param.ibt == 0x8888)
|
|
||||||
{
|
|
||||||
msr = dmpatch_ibt_save();
|
|
||||||
}
|
|
||||||
|
|
||||||
for (i = 0; i < MAX_PATCH; i++)
|
|
||||||
{
|
|
||||||
dmpatch_restore_code(g_get_patch[i]);
|
|
||||||
dmpatch_restore_code(g_put_patch[i]);
|
|
||||||
}
|
|
||||||
|
|
||||||
vdebug("dmpatch_exit success\n");
|
|
||||||
|
|
||||||
if (g_ko_param.ibt == 0x8888)
|
|
||||||
{
|
|
||||||
dmpatch_ibt_restore(msr);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
module_init(dmpatch_init);
|
|
||||||
module_exit(dmpatch_exit);
|
|
||||||
|
|
||||||
|
|
||||||
MODULE_DESCRIPTION("dmpatch driver");
|
|
||||||
MODULE_AUTHOR("longpanda <admin@ventoy.net>");
|
|
||||||
MODULE_LICENSE("GPL");
|
|
||||||
|
|
||||||
@@ -1,38 +0,0 @@
|
|||||||
1. install ubuntu 22.04 5.15.0-25
|
|
||||||
2. apt-get install build-essential flex libncurses-dev linux-headers-generic linux-source libssl-dev bison yacc vim libelf-dev ...... and so on
|
|
||||||
3. cp /lib/modules/5.15.0-25-generic/build/Module.symvers ./
|
|
||||||
4. /boot/config-5.15.0-25-generic as .config make oldconfig
|
|
||||||
5. make menuconfig
|
|
||||||
1. close CONFIG_STACKPROTECTOR
|
|
||||||
2. close CONFIG_RETPOLINE
|
|
||||||
3. close CONFIG_UBSAN_BOUNDS
|
|
||||||
4. close CONFIG_UBSAN_ENUM
|
|
||||||
|
|
||||||
6. modify ./scripts/mod/modpost.c
|
|
||||||
1. skip add_srcversion (just return)
|
|
||||||
2. force add_retpoline (#ifdef --> #ifndef)
|
|
||||||
3. force add_intree_flag
|
|
||||||
|
|
||||||
7. make modules_prepare LOCALVERSION=-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
|
|
||||||
|
|
||||||
8. Append padding at the end of struct module <include/linux/module.h>
|
|
||||||
struct module {
|
|
||||||
enum module_state state;
|
|
||||||
|
|
||||||
/* Member of list of modules */
|
|
||||||
struct list_head list;
|
|
||||||
|
|
||||||
/* Unique handle for this module */
|
|
||||||
char name[MODULE_NAME_LEN];
|
|
||||||
|
|
||||||
....
|
|
||||||
|
|
||||||
char padding[1024];
|
|
||||||
};
|
|
||||||
|
|
||||||
This is because struct module size is different in different kernel versions or with different CONFIG item.
|
|
||||||
|
|
||||||
|
|
||||||
9. make modules M=/home/dmpatch
|
|
||||||
10. strip --strip-debug /home/dmpatch/dm_patch.ko
|
|
||||||
|
|
||||||
@@ -1,65 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
|
|
||||||
FTPIP=192.168.44.1
|
|
||||||
FTPUSR='a:a'
|
|
||||||
|
|
||||||
rm -f dmpatch.c Makefile Makefile_IBT
|
|
||||||
|
|
||||||
for f in dmpatch.c Makefile Makefile_IBT; do
|
|
||||||
curl -s -u $FTPUSR ftp://$FTPIP/$f -o $f
|
|
||||||
if [ -f $f ]; then
|
|
||||||
echo "download $f OK ..."
|
|
||||||
else
|
|
||||||
echo "download $f FAILED ..."
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
rm -f *.ko
|
|
||||||
|
|
||||||
|
|
||||||
echo "build dm_patch.ko ..."
|
|
||||||
rm -rf ./aa
|
|
||||||
mkdir ./aa
|
|
||||||
|
|
||||||
cp -a *.c aa/
|
|
||||||
cp -a Makefile aa/
|
|
||||||
|
|
||||||
cd /home/panda/linux-source-5.15.0
|
|
||||||
make modules M=/home/panda/build/aa/
|
|
||||||
strip --strip-debug /home/panda/build/aa/dm_patch.ko
|
|
||||||
cd -
|
|
||||||
|
|
||||||
cp -a aa/dm_patch.ko ./
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
echo "build dm_patch_ibt.ko ..."
|
|
||||||
rm -rf ./aa
|
|
||||||
mkdir ./aa
|
|
||||||
|
|
||||||
cp -a *.c aa/
|
|
||||||
cp -a Makefile_IBT aa/Makefile
|
|
||||||
|
|
||||||
cd /home/panda/linux-source-5.15.0
|
|
||||||
make modules M=/home/panda/build/aa/
|
|
||||||
strip --strip-debug /home/panda/build/aa/dm_patch_ibt.ko
|
|
||||||
cd -
|
|
||||||
|
|
||||||
cp -a aa/dm_patch_ibt.ko ./
|
|
||||||
|
|
||||||
rm -rf ./aa
|
|
||||||
|
|
||||||
|
|
||||||
curl -s -T dm_patch.ko -u $FTPUSR ftp://$FTPIP/dm_patch_64.ko || exit 1
|
|
||||||
curl -s -T dm_patch_ibt.ko -u $FTPUSR ftp://$FTPIP/dm_patch_ibt_64.ko || exit 1
|
|
||||||
|
|
||||||
|
|
||||||
if [ -f ./dm_patch.ko -a -f ./dm_patch_ibt.ko ]; then
|
|
||||||
echo -e "\n\n=============== SUCCESS =============\n\n"
|
|
||||||
else
|
|
||||||
echo -e "\n\n=============== FAILED ==============\n\n"
|
|
||||||
fi
|
|
||||||
|
|
||||||
@@ -3,7 +3,7 @@
|
|||||||
1. Compile Environment
|
1. Compile Environment
|
||||||
==========================================
|
==========================================
|
||||||
My build environment is CentOS 7.8 x86_64. So here I first explain how to create the build environment from scratch.
|
My build environment is CentOS 7.8 x86_64. So here I first explain how to create the build environment from scratch.
|
||||||
Because Ventoy is based on many open source projects, so the environment is important. I suggest you test it on a virtual machine firstly.
|
Ventoy is based on many open source projects, so the build environment is important. I suggest you first test it on a virtual machine.
|
||||||
|
|
||||||
1.1 Install CentOS 7.8
|
1.1 Install CentOS 7.8
|
||||||
I use CentOS-7-x86_64-Everything-2003.iso and select Minimal install
|
I use CentOS-7-x86_64-Everything-2003.iso and select Minimal install
|
||||||
@@ -21,10 +21,10 @@
|
|||||||
==========================================
|
==========================================
|
||||||
2. Download Source Code
|
2. Download Source Code
|
||||||
==========================================
|
==========================================
|
||||||
2.1 Download Ventoy source code from github and decompress it.
|
2.1 Download Ventoy source code from GitHub and decompress it.
|
||||||
Next I assume that you have unzipped the code into the /home directory (check /home/Ventoy-master/README.md file for the directory layout).
|
Next I assume that you have unzipped the code into the /home directory (check /home/Ventoy-master/README.md file for the directory layout).
|
||||||
|
|
||||||
2.2 Download third-part source code and tool
|
2.2 Download third-party source code and tool
|
||||||
|
|
||||||
https://www.fefe.de/dietlibc/dietlibc-0.34.tar.xz ===> /home/Ventoy-master/DOC/dietlibc-0.34.tar.xz
|
https://www.fefe.de/dietlibc/dietlibc-0.34.tar.xz ===> /home/Ventoy-master/DOC/dietlibc-0.34.tar.xz
|
||||||
https://musl.libc.org/releases/musl-1.2.1.tar.gz ===> /home/Ventoy-master/DOC/musl-1.2.1.tar.gz
|
https://musl.libc.org/releases/musl-1.2.1.tar.gz ===> /home/Ventoy-master/DOC/musl-1.2.1.tar.gz
|
||||||
@@ -34,7 +34,7 @@
|
|||||||
https://codeload.github.com/libfuse/libfuse/zip/fuse-2.9.9 ===> /home/Ventoy-master/ExFAT/libfuse-fuse-2.9.9.zip
|
https://codeload.github.com/libfuse/libfuse/zip/fuse-2.9.9 ===> /home/Ventoy-master/ExFAT/libfuse-fuse-2.9.9.zip
|
||||||
https://releases.linaro.org/components/toolchain/binaries/7.4-2019.02/aarch64-linux-gnu/gcc-linaro-7.4.1-2019.02-x86_64_aarch64-linux-gnu.tar.xz ===> /opt/gcc-linaro-7.4.1-2019.02-x86_64_aarch64-linux-gnu.tar.xz
|
https://releases.linaro.org/components/toolchain/binaries/7.4-2019.02/aarch64-linux-gnu/gcc-linaro-7.4.1-2019.02-x86_64_aarch64-linux-gnu.tar.xz ===> /opt/gcc-linaro-7.4.1-2019.02-x86_64_aarch64-linux-gnu.tar.xz
|
||||||
https://toolchains.bootlin.com/downloads/releases/toolchains/aarch64/tarballs/aarch64--uclibc--stable-2020.08-1.tar.bz2 ===> /opt/aarch64--uclibc--stable-2020.08-1.tar.bz2
|
https://toolchains.bootlin.com/downloads/releases/toolchains/aarch64/tarballs/aarch64--uclibc--stable-2020.08-1.tar.bz2 ===> /opt/aarch64--uclibc--stable-2020.08-1.tar.bz2
|
||||||
http://ftp.loongnix.cn/toolchain/gcc/release/mips/gcc7/mips-loongson-gcc7.3-2019.06-29-linux-gnu.tar.gz ===> /opt/mips-loongson-gcc7.3-2019.06-29-linux-gnu.tar.gz
|
https://github.com/ventoy/vtoytoolchain/releases/download/1.0/mips-loongson-gcc7.3-2019.06-29-linux-gnu.tar.gz ===> /opt/mips-loongson-gcc7.3-2019.06-29-linux-gnu.tar.gz
|
||||||
https://github.com/ventoy/musl-cross-make/releases/download/latest/output.tar.bz2 ===> /opt/output.tar.bz2
|
https://github.com/ventoy/musl-cross-make/releases/download/latest/output.tar.bz2 ===> /opt/output.tar.bz2
|
||||||
|
|
||||||
|
|
||||||
@@ -42,7 +42,7 @@
|
|||||||
http://www.tinycorelinux.net/11.x/x86_64/release/distribution_files/corepure64.gz ===> /home/Ventoy-master/LiveCD/ISO/EFI/boot/corepure64.gz
|
http://www.tinycorelinux.net/11.x/x86_64/release/distribution_files/corepure64.gz ===> /home/Ventoy-master/LiveCD/ISO/EFI/boot/corepure64.gz
|
||||||
http://www.tinycorelinux.net/11.x/x86_64/release/distribution_files/modules64.gz ===> /home/Ventoy-master/LiveCD/ISO/EFI/boot/modules64.gz
|
http://www.tinycorelinux.net/11.x/x86_64/release/distribution_files/modules64.gz ===> /home/Ventoy-master/LiveCD/ISO/EFI/boot/modules64.gz
|
||||||
|
|
||||||
2.3 Prepare third-part tools
|
2.3 Prepare third-party tools
|
||||||
cd /home/Ventoy-master/DOC/
|
cd /home/Ventoy-master/DOC/
|
||||||
tar xf musl-1.2.1.tar.gz
|
tar xf musl-1.2.1.tar.gz
|
||||||
cd musl-1.2.1
|
cd musl-1.2.1
|
||||||
@@ -62,21 +62,21 @@
|
|||||||
==========================================
|
==========================================
|
||||||
3. All in one script
|
3. All in one script
|
||||||
==========================================
|
==========================================
|
||||||
I have made a all_in_one.sh, you can run this script to build and pack ventoy.
|
I have made an all-in-one script `all_in_one.sh`. You can run this script to build and pack ventoy.
|
||||||
If you want to compile a certain part separately, you can continue to refer to the later chapters of this text.
|
If you want to compile a certain part separately, you can continue to refer to the later chapters of this text.
|
||||||
|
|
||||||
cd /home/Ventoy-master/INSTALL
|
cd /home/Ventoy-master/INSTALL
|
||||||
sh all_in_one.sh
|
sh all_in_one.sh
|
||||||
|
|
||||||
It should be noted that:
|
It should be noted that:
|
||||||
1. Only grub2/EDK2/IPXE will be recompiled in all_in_one.sh. Other part contains the binaries and are few modified, so will no be recompiled everytime.
|
1. Only grub2/EDK2/IPXE will be recompiled in all_in_one.sh. Other parts contain binaries and are rarely modified, so will not be recompiled everytime.
|
||||||
You can rebuild these parts separately if you want.
|
You can rebuild these parts separately if you want.
|
||||||
|
|
||||||
2. some part of Ventoy has 32bit&64bit version (like 4.9 4.10 4.11 follows)
|
2. Some parts of Ventoy have a 32-bit and 64-bit version (like 4.9, 4.10, 4.11 follows)
|
||||||
all_in_one.sh only build 64bit version of them, if you want to rebuild the 32bit verison. You should create a 32bit CentOS environment and build them.
|
all_in_one.sh only builds the 64bit version of them. If you want to rebuild the 32bit verison, you should create a 32-bit CentOS environment and build them.
|
||||||
Fortunately these parts are few modified, you only need to build once or you can directly use the binary I have built.
|
Fortunately these parts are rarely modified, so you only need to build once or you can directly use the binaries I have built.
|
||||||
|
|
||||||
Besides, after a fully compile and pack, you can only build the part you modified (for example grub2) and run ventoy_pack.sh to generate the package.
|
Besides, after a full compile and packaging, you can only build the part you modified (for example grub2) and run ventoy_pack.sh to generate the package.
|
||||||
|
|
||||||
==========================================
|
==========================================
|
||||||
4. Build every part of Ventoy
|
4. Build every part of Ventoy
|
||||||
@@ -122,14 +122,14 @@
|
|||||||
After that, copy EXFAT/shared/mkexfatfs ===> /home/Ventoy-master/INSTALL/tool/mkexfatfs_64
|
After that, copy EXFAT/shared/mkexfatfs ===> /home/Ventoy-master/INSTALL/tool/mkexfatfs_64
|
||||||
After that, copy EXFAT/shared/mount.exfat-fuse ===> /home/Ventoy-master/INSTALL/tool/mount.exfat-fuse_64
|
After that, copy EXFAT/shared/mount.exfat-fuse ===> /home/Ventoy-master/INSTALL/tool/mount.exfat-fuse_64
|
||||||
|
|
||||||
Use the same build step to build exfat-util 32bit in a 32bit CentOS system and get mkexfatfs_32 and mount.exfat-fuse_32
|
Use the same build step to build exfat-util 32-bit in a 32-bit CentOS system and get mkexfatfs_32 and mount.exfat-fuse_32
|
||||||
|
|
||||||
4.10 == Build vtoy_fuse_iso_64/vtoy_fuse_iso_32 ==
|
4.10 == Build vtoy_fuse_iso_64/vtoy_fuse_iso_32 ==
|
||||||
cd /home/Ventoy-master/FUSEISO
|
cd /home/Ventoy-master/FUSEISO
|
||||||
sh build_libfuse.sh
|
sh build_libfuse.sh
|
||||||
sh build.sh
|
sh build.sh
|
||||||
|
|
||||||
Use the same build step to build in a 32bit CentOS system and get vtoy_fuse_iso_32
|
Use the same build step to build in a 32-bit CentOS system and get vtoy_fuse_iso_32
|
||||||
|
|
||||||
4.11 == Build unsquashfs_64/unsquashfs_32 ==
|
4.11 == Build unsquashfs_64/unsquashfs_32 ==
|
||||||
cd /home/Ventoy-master/SQUASHFS/SRC
|
cd /home/Ventoy-master/SQUASHFS/SRC
|
||||||
@@ -141,7 +141,7 @@
|
|||||||
cd /home/Ventoy-master/SQUASHFS/squashfs-tools-4.4/squashfs-tools
|
cd /home/Ventoy-master/SQUASHFS/squashfs-tools-4.4/squashfs-tools
|
||||||
sh build.sh
|
sh build.sh
|
||||||
|
|
||||||
Use the same build step to build in a 32bit CentOS system and get unsquashfs_32
|
Use the same build step to build in a 32-bit CentOS system and get unsquashfs_32
|
||||||
|
|
||||||
4.12 == Build vblade_64/vblade_32 ==
|
4.12 == Build vblade_64/vblade_32 ==
|
||||||
cd /home/Ventoy-master/VBLADE/vblade-master
|
cd /home/Ventoy-master/VBLADE/vblade-master
|
||||||
@@ -159,12 +159,12 @@
|
|||||||
make -f ventoy_makefile
|
make -f ventoy_makefile
|
||||||
strip --strip-all xzminidec
|
strip --strip-all xzminidec
|
||||||
|
|
||||||
4.16 == Build xzminidec64 ==
|
4.16 == Build xzminidec64/xzminidec64_musl ==
|
||||||
cd /home/Ventoy-master/Ventoy2Disk/Ventoy2Disk/xz-embedded-20130513/userspace
|
cd /home/Ventoy-master/Ventoy2Disk/Ventoy2Disk/xz-embedded-20130513/userspace
|
||||||
make -f ventoy_makefile64
|
make -f ventoy_makefile64 or make -f ventoy_makefile64_musl
|
||||||
strip --strip-all xzminidec
|
strip --strip-all xzminidec
|
||||||
|
|
||||||
4.17 == Build iso9660_x64.efi ==
|
4.17 == Build iso9660_x64.efi/udf_x64.efi/iso9660_ia32.efi/udf_ia32.efi/iso9660_aa64.efi/udf_aa64.efi/ ==
|
||||||
This efi driver is from https://github.com/pbatard/efifs
|
This efi driver is from https://github.com/pbatard/efifs
|
||||||
Follow all the build instructions in this project. I modified 3 files (the original and modified source are at /home/Ventoy-master/EDK2/efiffs)
|
Follow all the build instructions in this project. I modified 3 files (the original and modified source are at /home/Ventoy-master/EDK2/efiffs)
|
||||||
|
|
||||||
@@ -185,6 +185,16 @@
|
|||||||
make
|
make
|
||||||
aarch64-buildroot-linux-uclibc-strip --strip-all lunzip
|
aarch64-buildroot-linux-uclibc-strip --strip-all lunzip
|
||||||
|
|
||||||
|
4.17 == Build xzminidecaa64 ==
|
||||||
|
cd /home/Ventoy-master/Ventoy2Disk/Ventoy2Disk/xz-embedded-20130513/userspace
|
||||||
|
make -f ventoy_makefileaa64
|
||||||
|
strip --strip-all xzminidec
|
||||||
|
|
||||||
|
4.18 == Build xzminidecm64e ==
|
||||||
|
cd /home/Ventoy-master/Ventoy2Disk/Ventoy2Disk/xz-embedded-20130513/userspace
|
||||||
|
make -f ventoy_makefilem64e
|
||||||
|
strip --strip-all xzminidec
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
==========================================
|
==========================================
|
||||||
@@ -222,7 +232,7 @@
|
|||||||
SHA-256: cde08b6a2cf5ad914f05203e18e3f7c2ed6060a63604e3d75536f19b55e8e0af
|
SHA-256: cde08b6a2cf5ad914f05203e18e3f7c2ed6060a63604e3d75536f19b55e8e0af
|
||||||
|
|
||||||
5.8 imdisk
|
5.8 imdisk
|
||||||
download http://www.ltr-data.se/files/imdiskinst.exe and extract it by 7zip.
|
download http://static.ltr-data.se/files/imdiskinst_2.0.10.exe and extract it by 7zip.
|
||||||
|
|
||||||
INSTALL/ventoy/imdisk/64/imdisk.sys --> sys/amd64/imdisk.sys SHA-256: 6702202220268787e361f5a82dae53362c8e6c6dcd240bb01b44dd77ae0788da
|
INSTALL/ventoy/imdisk/64/imdisk.sys --> sys/amd64/imdisk.sys SHA-256: 6702202220268787e361f5a82dae53362c8e6c6dcd240bb01b44dd77ae0788da
|
||||||
INSTALL/ventoy/imdisk/64/imdisk.exe --> cli/amd64/imdisk.exe SHA-256: 9759175380af836869443e5f21ce2e33022125d154bc6b3d1c04dc36b190de04
|
INSTALL/ventoy/imdisk/64/imdisk.exe --> cli/amd64/imdisk.exe SHA-256: 9759175380af836869443e5f21ce2e33022125d154bc6b3d1c04dc36b190de04
|
||||||
@@ -256,5 +266,12 @@
|
|||||||
ISNTALL/ventoy/7z/64/7za.exe SHA-256: 8117e40ee7f824f63373a4f5625bb62749f69159d0c449b3ce2f35aad3b83549
|
ISNTALL/ventoy/7z/64/7za.exe SHA-256: 8117e40ee7f824f63373a4f5625bb62749f69159d0c449b3ce2f35aad3b83549
|
||||||
ISNTALL/ventoy/7z/32/7za.exe SHA-256: ea308c76a2f927b160a143d94072b0dce232e04b751f0c6432a94e05164e716d
|
ISNTALL/ventoy/7z/32/7za.exe SHA-256: ea308c76a2f927b160a143d94072b0dce232e04b751f0c6432a94e05164e716d
|
||||||
|
|
||||||
|
5.13 ./Ventoy/Unix/ventoy_unix/DragonFly/sbin/dmsetup
|
||||||
|
download from https://cdimage.debian.org/mirror/dragonflybsd.org/iso-images/dfly-x86_64-5.8.3_REL.iso.bz2
|
||||||
|
extract from the ISO file sbin/dmsetup
|
||||||
|
dmsetup SHA-256: bedcf26650e87edfe961e33bae20d832bce73efd4b6239f9a6a5785661e4e698
|
||||||
|
|
||||||
|
5.14 ./LiveCD/ISO/EFI/boot/vmlinuz64
|
||||||
|
download from http://www.tinycorelinux.net/11.x/x86_64/archive/11.0/distribution_files/vmlinuz64
|
||||||
|
vmlinuz64 SHA-256: 641077fc1f9914af244c248453005f56536ba9e7f54ba3e52402f26709ddb8a5
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,11 @@
|
|||||||
FROM centos:7
|
FROM centos:7
|
||||||
|
|
||||||
RUN yum -y -q install \
|
RUN sed -i \
|
||||||
|
-e 's/^mirrorlist/#mirrorlist/' \
|
||||||
|
-e 's/^#baseurl/baseurl/' \
|
||||||
|
-e 's/mirror\.centos\.org/vault.centos.org/' \
|
||||||
|
/etc/yum.repos.d/*.repo && \
|
||||||
|
yum -y -q install \
|
||||||
libXpm net-tools bzip2 wget vim gcc gcc-c++ samba dos2unix glibc-devel glibc.i686 glibc-devel.i686 \
|
libXpm net-tools bzip2 wget vim gcc gcc-c++ samba dos2unix glibc-devel glibc.i686 glibc-devel.i686 \
|
||||||
mpfr.i686 mpfr-devel.i686 rsync autogen autoconf automake libtool gettext* bison binutils \
|
mpfr.i686 mpfr-devel.i686 rsync autogen autoconf automake libtool gettext* bison binutils \
|
||||||
flex device-mapper-devel SDL libpciaccess libusb freetype freetype-devel gnu-free-* qemu-* virt-* \
|
flex device-mapper-devel SDL libpciaccess libusb freetype freetype-devel gnu-free-* qemu-* virt-* \
|
||||||
|
|||||||
113
EDK2/build_shim.sh
Normal file
113
EDK2/build_shim.sh
Normal file
@@ -0,0 +1,113 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
if [ -z "$1" ]; then
|
||||||
|
EDKARCH=X64
|
||||||
|
postfix=x64
|
||||||
|
elif [ "$1" = "ia32" ]; then
|
||||||
|
EDKARCH=IA32
|
||||||
|
postfix=ia32
|
||||||
|
shift
|
||||||
|
elif [ "$1" = "aa64" ]; then
|
||||||
|
EDKARCH=AARCH64
|
||||||
|
postfix=aa64
|
||||||
|
shift
|
||||||
|
fi
|
||||||
|
|
||||||
|
cd edk2-edk2-stable201911
|
||||||
|
|
||||||
|
rm -rf ./Conf/.cache
|
||||||
|
rm -f ./Conf/.AutoGenIdFile.txt
|
||||||
|
|
||||||
|
VTEFI_PATH=Build/MdeModule/RELEASE_GCC48/$EDKARCH/MdeModulePkg/Application/VtoyShim/VtoyShim/OUTPUT/VtoyShim.efi
|
||||||
|
DST_PATH=../../INSTALL/EFI/BOOT/fb${postfix}.efi
|
||||||
|
|
||||||
|
|
||||||
|
rm -f $VTEFI_PATH
|
||||||
|
rm -f $DST_PATH
|
||||||
|
|
||||||
|
unset WORKSPACE
|
||||||
|
source ./edksetup.sh
|
||||||
|
|
||||||
|
if [ "$EDKARCH" = "AARCH64" ]; then
|
||||||
|
PATH=$PATH:/opt/gcc-linaro-7.4.1-2019.02-x86_64_aarch64-linux-gnu/bin \
|
||||||
|
GCC48_AARCH64_PREFIX=aarch64-linux-gnu- \
|
||||||
|
build -p MdeModulePkg/MdeModulePkg.dsc -a $EDKARCH -b RELEASE -t GCC48 -m MdeModulePkg/Application/VtoyShim/VtoyShim.inf
|
||||||
|
else
|
||||||
|
build -p MdeModulePkg/MdeModulePkg.dsc -a $EDKARCH -b RELEASE -t GCC48 -m MdeModulePkg/Application/VtoyShim/VtoyShim.inf
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -e $VTEFI_PATH ]; then
|
||||||
|
|
||||||
|
objdump -h "$VTEFI_PATH"
|
||||||
|
echo ""
|
||||||
|
|
||||||
|
objcopy \
|
||||||
|
--add-section .sbat="MdeModulePkg/Application/VtoyShim/sbat.csv" \
|
||||||
|
--set-section-flags .sbat=alloc,load,readonly,data \
|
||||||
|
"$VTEFI_PATH" "$DST_PATH"
|
||||||
|
|
||||||
|
#find the right sbat section VMA
|
||||||
|
tmpfile=$(mktemp)
|
||||||
|
|
||||||
|
cnt1=$(objdump -h "$DST_PATH" | grep -P '^\s*[0-9][0-9]* \.' | wc -l)
|
||||||
|
cnt2=$(objdump -h "$DST_PATH" | grep -P 'ALLOC' | wc -l)
|
||||||
|
|
||||||
|
if [ $cnt1 -ne $cnt2 ]; then
|
||||||
|
echo "Section count mismatch $cnt1 $cnt2"
|
||||||
|
objdump -h "$DST_PATH"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
objdump -h "$DST_PATH" | grep -P '^\s*[0-9][0-9]* \.' > $tmpfile
|
||||||
|
sbat_size=$(stat -c '%s' MdeModulePkg/Application/VtoyShim/sbat.csv)
|
||||||
|
sbat_size_hex=$(printf '0x%08x' $sbat_size)
|
||||||
|
|
||||||
|
lmax='0000000000000000'
|
||||||
|
lsize='0000000000000000'
|
||||||
|
while read line; do
|
||||||
|
echo $line
|
||||||
|
lbase=$(echo $line | awk '{print $4}')
|
||||||
|
if expr "$lmax" \< "$lbase" > /dev/null; then
|
||||||
|
lmax=$lbase
|
||||||
|
lsize=$(echo $line | awk '{print $3}')
|
||||||
|
fi
|
||||||
|
echo "max=$lmax size=$lsize"
|
||||||
|
done < $tmpfile
|
||||||
|
rm -f $tmpfile
|
||||||
|
|
||||||
|
|
||||||
|
lvma=$((0x${lsize}+0x${lmax}))
|
||||||
|
lvma_align=`printf '0x%08x' $(( (lvma + 4095) / 4096 * 4096 ))`
|
||||||
|
echo "sbat section lvma_align=$lvma_align"
|
||||||
|
|
||||||
|
objcopy --adjust-section-vma .sbat=$lvma_align "$DST_PATH"
|
||||||
|
|
||||||
|
img_base=$(objdump -p "$DST_PATH" | grep ImageBase | awk '{print $2}')
|
||||||
|
size_img=0x$(objdump -p "$DST_PATH" | grep SizeOfImage | awk '{print $2}')
|
||||||
|
sbat_end=`printf '0x%08x' $(($lvma_align+$sbat_size_hex))`
|
||||||
|
|
||||||
|
if [ "$img_base" != "0000000000000000" ]; then
|
||||||
|
echo "#### ImageBase is not 0 $img_base"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "size_img=$size_img sbat_size=$sbat_size_hex sbat_range $lvma_align - $sbat_end"
|
||||||
|
|
||||||
|
if expr "$size_img" \< "$sbat_end" > /dev/null; then
|
||||||
|
echo "SizeOfImage $size_img less than sbat section addr $sbat_end"
|
||||||
|
exit 1
|
||||||
|
else
|
||||||
|
echo "SizeOfImage $size_img >= $sbat_end is OK"
|
||||||
|
fi
|
||||||
|
|
||||||
|
objdump -h "$DST_PATH"
|
||||||
|
|
||||||
|
echo -e '\n\n====================== SUCCESS ========================\n\n'
|
||||||
|
|
||||||
|
cd ..
|
||||||
|
else
|
||||||
|
echo -e '\n\n====================== FAILED ========================\n\n'
|
||||||
|
cd ..
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
@@ -19,3 +19,7 @@ sh ./build.sh aa64 || exit 1
|
|||||||
echo '======== build EDK2 for x86_64-efi ==============='
|
echo '======== build EDK2 for x86_64-efi ==============='
|
||||||
sh ./build.sh || exit 1
|
sh ./build.sh || exit 1
|
||||||
|
|
||||||
|
|
||||||
|
echo '======== build EDK2 for x86_64-efi ==============='
|
||||||
|
sh ./build_shim.sh || exit 1
|
||||||
|
|
||||||
|
|||||||
@@ -1231,6 +1231,65 @@ EFI_STATUS EFIAPI ventoy_boot(IN EFI_HANDLE ImageHandle)
|
|||||||
return EFI_SUCCESS;
|
return EFI_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if defined (MDE_CPU_X64)
|
||||||
|
|
||||||
|
STATIC BOOLEAN EFIAPI IsSecureBootEnabled(VOID)
|
||||||
|
{
|
||||||
|
UINT8 SecureBoot = 0;
|
||||||
|
UINTN DataSize;
|
||||||
|
EFI_STATUS Status;
|
||||||
|
|
||||||
|
DataSize = sizeof(SecureBoot);
|
||||||
|
Status = gST->RuntimeServices->GetVariable(L"SecureBoot", &gEfiGlobalVariableGuid, NULL,
|
||||||
|
&DataSize, &SecureBoot);
|
||||||
|
if (EFI_ERROR(Status))
|
||||||
|
{
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
return SecureBoot ? TRUE : FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
STATIC BOOLEAN EFIAPI IsSetupMode(VOID)
|
||||||
|
{
|
||||||
|
UINT8 SetupMode = 0;
|
||||||
|
UINTN DataSize;
|
||||||
|
EFI_STATUS Status;
|
||||||
|
|
||||||
|
DataSize = sizeof(SetupMode);
|
||||||
|
Status = gST->RuntimeServices->GetVariable(L"SetupMode", &gEfiGlobalVariableGuid, NULL,
|
||||||
|
&DataSize, &SetupMode);
|
||||||
|
if (EFI_ERROR(Status))
|
||||||
|
{
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
return SetupMode ? TRUE : FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
STATIC BOOLEAN EFIAPI CheckVtoyShim(VOID)
|
||||||
|
{
|
||||||
|
EFI_STATUS Status;
|
||||||
|
EFI_GUID Guid = VTOY_SHIM_POLICY_GUID;
|
||||||
|
VOID *Prot = NULL;
|
||||||
|
|
||||||
|
/* If secure boot is not enabled or in SetupMode, nothing needed */
|
||||||
|
if (!IsSecureBootEnabled() || IsSetupMode())
|
||||||
|
{
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
Status = gBS->LocateProtocol(&Guid, NULL, (VOID**)&Prot);
|
||||||
|
if (EFI_ERROR(Status))
|
||||||
|
{
|
||||||
|
VtoyDebug("Failed to locate Vtoy Shim Protocol %lx\r\n", Status);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
EFI_STATUS EFIAPI VentoyEfiMain
|
EFI_STATUS EFIAPI VentoyEfiMain
|
||||||
(
|
(
|
||||||
IN EFI_HANDLE ImageHandle,
|
IN EFI_HANDLE ImageHandle,
|
||||||
@@ -1240,6 +1299,15 @@ EFI_STATUS EFIAPI VentoyEfiMain
|
|||||||
EFI_STATUS Status = EFI_SUCCESS;
|
EFI_STATUS Status = EFI_SUCCESS;
|
||||||
EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *Protocol;
|
EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *Protocol;
|
||||||
|
|
||||||
|
#if defined (MDE_CPU_X64)
|
||||||
|
/* check that Ventoy Shim must exist */
|
||||||
|
if (!CheckVtoyShim())
|
||||||
|
{
|
||||||
|
sleep(5);
|
||||||
|
return EFI_NOT_FOUND;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
g_sector_flag_num = 512; /* initial value */
|
g_sector_flag_num = 512; /* initial value */
|
||||||
|
|
||||||
g_sector_flag = AllocatePool(g_sector_flag_num * sizeof(ventoy_sector_flag));
|
g_sector_flag = AllocatePool(g_sector_flag_num * sizeof(ventoy_sector_flag));
|
||||||
@@ -1263,6 +1331,11 @@ EFI_STATUS EFIAPI VentoyEfiMain
|
|||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (g_os_param_reserved[11])
|
||||||
|
{
|
||||||
|
ventoy_lock_res(g_os_param_reserved[11]);
|
||||||
|
}
|
||||||
|
|
||||||
ventoy_disable_ex_filesystem();
|
ventoy_disable_ex_filesystem();
|
||||||
|
|
||||||
if (gMemdiskMode)
|
if (gMemdiskMode)
|
||||||
@@ -1341,6 +1414,11 @@ EFI_STATUS EFIAPI VentoyEfiMain
|
|||||||
|
|
||||||
ventoy_enable_ex_filesystem();
|
ventoy_enable_ex_filesystem();
|
||||||
|
|
||||||
|
if (g_os_param_reserved[11])
|
||||||
|
{
|
||||||
|
ventoy_unlock_res();
|
||||||
|
}
|
||||||
|
|
||||||
return EFI_SUCCESS;
|
return EFI_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -23,6 +23,8 @@
|
|||||||
|
|
||||||
#define COMPILE_ASSERT(expr) extern char __compile_assert[(expr) ? 1 : -1]
|
#define COMPILE_ASSERT(expr) extern char __compile_assert[(expr) ? 1 : -1]
|
||||||
|
|
||||||
|
#define VTOY_SHIM_POLICY_GUID {0x90a29d14, 0x3968, 0x48fe, { 0x85, 0x81, 0x6b, 0x7f, 0x7d, 0xc4, 0x70, 0x55 }};
|
||||||
|
|
||||||
#define VENTOY_GUID { 0x77772020, 0x2e77, 0x6576, { 0x6e, 0x74, 0x6f, 0x79, 0x2e, 0x6e, 0x65, 0x74 }}
|
#define VENTOY_GUID { 0x77772020, 0x2e77, 0x6576, { 0x6e, 0x74, 0x6f, 0x79, 0x2e, 0x6e, 0x65, 0x74 }}
|
||||||
|
|
||||||
typedef enum ventoy_chain_type
|
typedef enum ventoy_chain_type
|
||||||
@@ -428,6 +430,8 @@ EFI_STATUS ventoy_hook_1st_cdrom_start(VOID);
|
|||||||
EFI_STATUS ventoy_hook_1st_cdrom_stop(VOID);
|
EFI_STATUS ventoy_hook_1st_cdrom_stop(VOID);
|
||||||
EFI_STATUS ventoy_disable_ex_filesystem(VOID);
|
EFI_STATUS ventoy_disable_ex_filesystem(VOID);
|
||||||
EFI_STATUS ventoy_enable_ex_filesystem(VOID);
|
EFI_STATUS ventoy_enable_ex_filesystem(VOID);
|
||||||
|
EFI_STATUS ventoy_lock_res(UINT8 LockType);
|
||||||
|
EFI_STATUS ventoy_unlock_res(VOID);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
@@ -25,6 +25,10 @@
|
|||||||
ENTRY_POINT = VentoyEfiMain
|
ENTRY_POINT = VentoyEfiMain
|
||||||
|
|
||||||
|
|
||||||
|
[BuildOptions]
|
||||||
|
# Force standard GNU ld to pack and align ELF segments to 4KB page boundaries
|
||||||
|
GCC:*_*_*_DLINK_FLAGS = -Wl,-z,common-page-size=0x1000 -Wl,-z,max-page-size=0x1000
|
||||||
|
|
||||||
[Sources]
|
[Sources]
|
||||||
Ventoy.h
|
Ventoy.h
|
||||||
Ventoy.c
|
Ventoy.c
|
||||||
|
|||||||
@@ -1797,3 +1797,176 @@ EFI_STATUS ventoy_hook_1st_cdrom_stop(VOID)
|
|||||||
return EFI_SUCCESS;
|
return EFI_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
/* For force highest resolution for Windows/WinPE */
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
STATIC UINT32 g_org_mode_num = 0;
|
||||||
|
STATIC EFI_GRAPHICS_OUTPUT_PROTOCOL_SET_MODE g_org_set_mode = NULL;
|
||||||
|
|
||||||
|
STATIC EFI_STATUS EFIAPI ventoy_set_mode
|
||||||
|
(
|
||||||
|
IN EFI_GRAPHICS_OUTPUT_PROTOCOL *This,
|
||||||
|
IN UINT32 ModeNumber
|
||||||
|
)
|
||||||
|
{
|
||||||
|
(void)This;
|
||||||
|
(void)ModeNumber;
|
||||||
|
|
||||||
|
/* Force highest resolution */
|
||||||
|
return EFI_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
STATIC EFI_STATUS EFIAPI ventoy_set_mode2
|
||||||
|
(
|
||||||
|
IN EFI_GRAPHICS_OUTPUT_PROTOCOL *This,
|
||||||
|
IN UINT32 ModeNumber
|
||||||
|
)
|
||||||
|
{
|
||||||
|
UINTN Size;
|
||||||
|
EFI_STATUS rc;
|
||||||
|
EFI_GRAPHICS_OUTPUT_MODE_INFORMATION *info = NULL;
|
||||||
|
|
||||||
|
/* Force >= 1024x768 */
|
||||||
|
rc = This->QueryMode(This, ModeNumber, &Size, &info);
|
||||||
|
if (rc == EFI_SUCCESS)
|
||||||
|
{
|
||||||
|
if (info->HorizontalResolution < 1024 || info->VerticalResolution < 768)
|
||||||
|
{
|
||||||
|
return EFI_SUCCESS;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return g_org_set_mode(This, ModeNumber);
|
||||||
|
}
|
||||||
|
|
||||||
|
EFI_STATUS ventoy_lock_res(UINT8 LockType)
|
||||||
|
{
|
||||||
|
UINT32 i = 0;
|
||||||
|
UINT32 x = 0;
|
||||||
|
UINT32 y = 0;
|
||||||
|
UINT32 SelMode = 0;
|
||||||
|
UINT32 CurMode = 0;
|
||||||
|
UINT32 Highest = 0;
|
||||||
|
UINT32 M1024_768 = MAX_UINT32;
|
||||||
|
UINTN Size;
|
||||||
|
EFI_STATUS rc;
|
||||||
|
EFI_GRAPHICS_OUTPUT_PROTOCOL *gop = NULL;
|
||||||
|
EFI_GRAPHICS_OUTPUT_MODE_INFORMATION *info = NULL;
|
||||||
|
|
||||||
|
/* already hook */
|
||||||
|
if (g_org_set_mode)
|
||||||
|
{
|
||||||
|
return EFI_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 1: Highest 2: 1024x768 3: >= 1024x768 */
|
||||||
|
if (LockType == 0 || LockType > 3)
|
||||||
|
{
|
||||||
|
return EFI_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
rc = gBS->LocateProtocol(&gEfiGraphicsOutputProtocolGuid, NULL, (void **)&gop);
|
||||||
|
if (rc != EFI_SUCCESS)
|
||||||
|
{
|
||||||
|
debug("Failed to locate GOP protocol");
|
||||||
|
return EFI_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if (LockType == 3)
|
||||||
|
{
|
||||||
|
g_org_mode_num = MAX_UINT32;
|
||||||
|
g_org_set_mode = gop->SetMode;
|
||||||
|
gop->SetMode = ventoy_set_mode2;
|
||||||
|
return EFI_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
CurMode = gop->Mode->Mode;
|
||||||
|
|
||||||
|
for (i = 0 ; i < gop->Mode->MaxMode ; i++)
|
||||||
|
{
|
||||||
|
/* Get mode information */
|
||||||
|
if (gop->QueryMode(gop, i, &Size, &info) == EFI_SUCCESS)
|
||||||
|
{
|
||||||
|
if (info->HorizontalResolution == 1024 && info->VerticalResolution == 768)
|
||||||
|
{
|
||||||
|
M1024_768 = i;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (x < info->HorizontalResolution ||
|
||||||
|
(x == info->HorizontalResolution && y < info->VerticalResolution))
|
||||||
|
{
|
||||||
|
Highest = i;
|
||||||
|
x = info->HorizontalResolution;
|
||||||
|
y = info->VerticalResolution;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if (LockType == 1)
|
||||||
|
{
|
||||||
|
SelMode = Highest;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (M1024_768 == MAX_UINT32)
|
||||||
|
{
|
||||||
|
SelMode = Highest;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
SelMode = M1024_768;
|
||||||
|
x = 1024;
|
||||||
|
y = 768;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (SelMode != CurMode)
|
||||||
|
{
|
||||||
|
gop->SetMode(gop, SelMode);
|
||||||
|
}
|
||||||
|
debug("Lock resolution to Mode:%d %d x %d", SelMode, x, y);
|
||||||
|
|
||||||
|
|
||||||
|
g_org_mode_num = CurMode;
|
||||||
|
g_org_set_mode = gop->SetMode;
|
||||||
|
gop->SetMode = ventoy_set_mode;
|
||||||
|
|
||||||
|
return EFI_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
EFI_STATUS ventoy_unlock_res(VOID)
|
||||||
|
{
|
||||||
|
EFI_STATUS rc;
|
||||||
|
EFI_GRAPHICS_OUTPUT_PROTOCOL *gop = NULL;
|
||||||
|
|
||||||
|
/* not hooked yet */
|
||||||
|
if (!g_org_set_mode)
|
||||||
|
{
|
||||||
|
return EFI_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
rc = gBS->LocateProtocol(&gEfiGraphicsOutputProtocolGuid, NULL, (void **)&gop);
|
||||||
|
if (rc != EFI_SUCCESS)
|
||||||
|
{
|
||||||
|
debug("Failed to locate GOP protocol");
|
||||||
|
return EFI_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (g_org_mode_num != MAX_UINT32)
|
||||||
|
{
|
||||||
|
g_org_set_mode(gop, g_org_mode_num);
|
||||||
|
}
|
||||||
|
|
||||||
|
gop->SetMode = g_org_set_mode;
|
||||||
|
g_org_set_mode = NULL;
|
||||||
|
return EFI_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,800 @@
|
|||||||
|
/******************************************************************************
|
||||||
|
* VtoyShim.c
|
||||||
|
*
|
||||||
|
* Copyright (c) 2017 - 2018, Intel Corporation. All rights reserved.<BR>
|
||||||
|
* SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <Uefi.h>
|
||||||
|
|
||||||
|
#include <Library/DebugLib.h>
|
||||||
|
#include <Library/PrintLib.h>
|
||||||
|
#include <Library/UefiLib.h>
|
||||||
|
#include <Library/BaseMemoryLib.h>
|
||||||
|
#include <Library/DevicePathLib.h>
|
||||||
|
#include <Library/MemoryAllocationLib.h>
|
||||||
|
#include <Library/UefiBootServicesTableLib.h>
|
||||||
|
#include <Library/UefiRuntimeServicesTableLib.h>
|
||||||
|
#include <Library/UefiApplicationEntryPoint.h>
|
||||||
|
#include <Library/PeCoffLib.h>
|
||||||
|
#include <Protocol/LoadedImage.h>
|
||||||
|
#include <Guid/FileInfo.h>
|
||||||
|
#include <Guid/FileSystemInfo.h>
|
||||||
|
#include <Protocol/BlockIo.h>
|
||||||
|
#include <Protocol/RamDisk.h>
|
||||||
|
#include <Protocol/SimpleFileSystem.h>
|
||||||
|
#include <Protocol/DevicePathToText.h>
|
||||||
|
#include <Protocol/DevicePathFromText.h>
|
||||||
|
#include <Protocol/LoadedImage.h>
|
||||||
|
#include <Protocol/Security.h>
|
||||||
|
#include <Protocol/Security2.h>
|
||||||
|
#include <IndustryStandard/PeImage.h>
|
||||||
|
#include <VtoyShim.h>
|
||||||
|
|
||||||
|
#define CUR_SBAT_VER 1
|
||||||
|
|
||||||
|
STATIC EFI_GUID gVtoySbatGUID = { 0xf755068a, 0xe04f, 0x452b, { 0x9d, 0x6d, 0x7c, 0x55, 0x96, 0xb3, 0xc0, 0x7d }};
|
||||||
|
STATIC EFI_GUID gShimLockGUID = SHIM_LOCK_GUID;
|
||||||
|
STATIC EFI_SECURITY_FILE_AUTHENTICATION_STATE gSysSecFileAuth = NULL;
|
||||||
|
STATIC EFI_SECURITY2_FILE_AUTHENTICATION gSysSec2FileAuth = NULL;
|
||||||
|
STATIC BOOLEAN gVtoyByPassSB = FALSE; /* must be FALSE by default for revoke */
|
||||||
|
STATIC VTOY_SHIM gVtoyShimProtocol;
|
||||||
|
STATIC EFI_HANDLE gVtoyShimProtHandle;
|
||||||
|
STATIC SHIM_LOCK gShimLock;
|
||||||
|
|
||||||
|
STATIC EFI_EXIT_BOOT_SERVICES gSysExitBootServices = NULL;
|
||||||
|
STATIC EFI_GET_VARIABLE gSysGetVariable = NULL;
|
||||||
|
|
||||||
|
STATIC VOID EFIAPI VtoyLog(CONST CHAR16 *Format, ...)
|
||||||
|
{
|
||||||
|
VA_LIST Marker;
|
||||||
|
CHAR16 Buffer[512];
|
||||||
|
UINTN BufLen = 0;
|
||||||
|
|
||||||
|
Buffer[0] = 0;
|
||||||
|
VA_START(Marker, Format);
|
||||||
|
BufLen = UnicodeVSPrint(Buffer, sizeof(Buffer), Format, Marker);
|
||||||
|
VA_END(Marker);
|
||||||
|
|
||||||
|
if (gST->ConOut && gST->ConOut->OutputString)
|
||||||
|
{
|
||||||
|
gST->ConOut->OutputString(gST->ConOut, Buffer);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
STATIC VOID EFIAPI DumpDevicePath(const EFI_DEVICE_PATH_PROTOCOL *DevicePath)
|
||||||
|
{
|
||||||
|
CHAR16 *DPStr = NULL;
|
||||||
|
|
||||||
|
DPStr = ConvertDevicePathToText(DevicePath, TRUE, TRUE);
|
||||||
|
if (DPStr)
|
||||||
|
{
|
||||||
|
vLog(L"%s", DPStr);
|
||||||
|
gBS->FreePool(DPStr);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
vLog(L"NULL");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
STATIC VOID EFIAPI ShowSBWarning(BOOLEAN Reboot, const EFI_DEVICE_PATH_PROTOCOL *DevicePath)
|
||||||
|
{
|
||||||
|
UINTN Index = 0;
|
||||||
|
|
||||||
|
vLog(L"\r\n=======================================================");
|
||||||
|
vLog(L"=======================================================\r\n");
|
||||||
|
|
||||||
|
DumpDevicePath(DevicePath);
|
||||||
|
|
||||||
|
vLog(L"\r\n####### Security Boot Violation ##########\r\n");
|
||||||
|
|
||||||
|
vLog(L"=======================================================");
|
||||||
|
vLog(L"=======================================================");
|
||||||
|
|
||||||
|
if (Reboot)
|
||||||
|
{
|
||||||
|
vLog(L"\r\n###### Press Enter to reboot... ######");
|
||||||
|
if (gST->ConIn)
|
||||||
|
{
|
||||||
|
gST->ConIn->Reset(gST->ConIn, FALSE);
|
||||||
|
gBS->WaitForEvent(1, &gST->ConIn->WaitForKey, &Index);
|
||||||
|
}
|
||||||
|
gRT->ResetSystem(EfiResetWarm, EFI_SECURITY_VIOLATION, 0, NULL);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
VtoySleep(5);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
STATIC VOID * EFIAPI FindShimFuncAddr(UINT64 FuncOffset)
|
||||||
|
{
|
||||||
|
EFI_STATUS Status;
|
||||||
|
SHIM_IMAGE_LOADER *ImgLoader = NULL;
|
||||||
|
EFI_GUID ShimImgLoaderGuid = SHIM_IMAGE_LOADER_GUID;
|
||||||
|
|
||||||
|
Status = gBS->LocateProtocol(&ShimImgLoaderGuid, NULL, (VOID **)&ImgLoader);
|
||||||
|
if (EFI_ERROR(Status) || !ImgLoader || !ImgLoader->LoadImage)
|
||||||
|
{
|
||||||
|
vLog(L"Failed to locate shim image loader protocol %lx %p", Status, ImgLoader);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (NM_SHIM_LOAD_IMAGE_OFFSET > FuncOffset)
|
||||||
|
{
|
||||||
|
return (UINT8 *)ImgLoader->LoadImage - (NM_SHIM_LOAD_IMAGE_OFFSET - FuncOffset);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return (UINT8 *)ImgLoader->LoadImage + (FuncOffset - NM_SHIM_LOAD_IMAGE_OFFSET);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
EFI_STATUS EFIAPI LaunchRealGrub(EFI_HANDLE ImageHandle, CONST CHAR16 *FileName)
|
||||||
|
{
|
||||||
|
EFI_STATUS Status;
|
||||||
|
UINTN BufferSize = 0;
|
||||||
|
CHAR16 *DevDpStr = NULL;
|
||||||
|
CHAR16 *NewDpStr = NULL;
|
||||||
|
EFI_HANDLE ChildHandle = NULL;
|
||||||
|
EFI_LOADED_IMAGE_PROTOCOL *Li = NULL;
|
||||||
|
EFI_DEVICE_PATH_PROTOCOL *DeviceDP = NULL;
|
||||||
|
EFI_DEVICE_PATH_PROTOCOL *TargetDp = NULL;
|
||||||
|
|
||||||
|
Status = gBS->HandleProtocol(ImageHandle, &gEfiLoadedImageProtocolGuid, (VOID**)&Li);
|
||||||
|
if (EFI_ERROR(Status))
|
||||||
|
{
|
||||||
|
vLog(L"Failed to locate loaded image protocol %lx", Status);
|
||||||
|
return Status;
|
||||||
|
}
|
||||||
|
|
||||||
|
DeviceDP = DevicePathFromHandle(Li->DeviceHandle);
|
||||||
|
if (!DeviceDP || !IsDevicePathValid(DeviceDP, 0))
|
||||||
|
{
|
||||||
|
vLog(L"Failed to get device path of device handle %p", Li->DeviceHandle);
|
||||||
|
Status = EFI_NOT_FOUND;
|
||||||
|
goto END;
|
||||||
|
}
|
||||||
|
|
||||||
|
DevDpStr = ConvertDevicePathToText(DeviceDP, FALSE, TRUE);
|
||||||
|
if (!DevDpStr)
|
||||||
|
{
|
||||||
|
vLog(L"Failed to convert device path to text");
|
||||||
|
Status = EFI_OUT_OF_RESOURCES;
|
||||||
|
goto END;
|
||||||
|
}
|
||||||
|
|
||||||
|
BufferSize = (StrLen(DevDpStr) + 64) * sizeof(CHAR16);
|
||||||
|
NewDpStr = (CHAR16 *)AllocatePool(BufferSize);
|
||||||
|
if (!NewDpStr)
|
||||||
|
{
|
||||||
|
vLog(L"Failed to alloc new device path string buffer size:%lu", BufferSize);
|
||||||
|
Status = EFI_OUT_OF_RESOURCES;
|
||||||
|
goto END;
|
||||||
|
}
|
||||||
|
|
||||||
|
UnicodeSPrint(NewDpStr, BufferSize, L"%s/EFI/BOOT/%s", DevDpStr, FileName);
|
||||||
|
|
||||||
|
TargetDp = ConvertTextToDevicePath(NewDpStr);
|
||||||
|
if (!TargetDp)
|
||||||
|
{
|
||||||
|
vLog(L"Failed to convert new text <%s> to device path", NewDpStr);
|
||||||
|
Status = EFI_NOT_FOUND;
|
||||||
|
goto END;
|
||||||
|
}
|
||||||
|
|
||||||
|
Status = gBS->LoadImage(FALSE, ImageHandle, TargetDp, NULL, 0, &ChildHandle);
|
||||||
|
if (EFI_ERROR(Status))
|
||||||
|
{
|
||||||
|
vLog(L"Failed to LoadImage %lx", Status);
|
||||||
|
goto END;
|
||||||
|
}
|
||||||
|
|
||||||
|
Status = gBS->StartImage(ChildHandle, NULL, NULL);
|
||||||
|
if (EFI_ERROR(Status))
|
||||||
|
{
|
||||||
|
vLog(L"Failed to StartImage %lx", Status);
|
||||||
|
gBS->UnloadImage(ChildHandle);
|
||||||
|
goto END;
|
||||||
|
}
|
||||||
|
|
||||||
|
END:
|
||||||
|
|
||||||
|
CheckFreePool(DevDpStr);
|
||||||
|
CheckFreePool(NewDpStr);
|
||||||
|
CheckFreePool(TargetDp);
|
||||||
|
|
||||||
|
return Status;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
STATIC EFI_STATUS EFIAPI ReadAuthFile
|
||||||
|
(
|
||||||
|
const EFI_DEVICE_PATH_PROTOCOL *DevicePathConst,
|
||||||
|
VOID **Buffer,
|
||||||
|
UINT32 *Size
|
||||||
|
)
|
||||||
|
{
|
||||||
|
EFI_STATUS Status;
|
||||||
|
UINTN TmpSize = 0;
|
||||||
|
CHAR16 *DpStr = NULL;
|
||||||
|
EFI_HANDLE Handle = NULL;
|
||||||
|
EFI_DEVICE_PATH *DevPath = NULL;
|
||||||
|
EFI_DEVICE_PATH *TmpPath = NULL;
|
||||||
|
EFI_FILE_IO_INTERFACE *FileIO = NULL;
|
||||||
|
EFI_FILE *File = NULL;
|
||||||
|
EFI_FILE *Root = NULL;
|
||||||
|
UINT8 *FileData = NULL;
|
||||||
|
EFI_FILE_INFO *FInfo = NULL;
|
||||||
|
UINT8 Buf[1024];
|
||||||
|
|
||||||
|
DevPath = TmpPath = DuplicateDevicePath(DevicePathConst);
|
||||||
|
if (!DevPath)
|
||||||
|
{
|
||||||
|
Status = EFI_OUT_OF_RESOURCES;
|
||||||
|
goto END;
|
||||||
|
}
|
||||||
|
|
||||||
|
Status = gBS->LocateDevicePath(&gEfiSimpleFileSystemProtocolGuid, &DevPath, &Handle);
|
||||||
|
if (EFI_ERROR(Status))
|
||||||
|
{
|
||||||
|
vLog(L"Failed to locate simple file protocol %lx", Status);
|
||||||
|
goto END;
|
||||||
|
}
|
||||||
|
|
||||||
|
DpStr = ConvertDevicePathToText(DevPath, FALSE, TRUE);
|
||||||
|
if (!DpStr)
|
||||||
|
{
|
||||||
|
Status = EFI_OUT_OF_RESOURCES;
|
||||||
|
goto END;
|
||||||
|
}
|
||||||
|
|
||||||
|
Status = gBS->HandleProtocol(Handle, &gEfiSimpleFileSystemProtocolGuid, (VOID **)&FileIO);
|
||||||
|
if (EFI_ERROR(Status))
|
||||||
|
{
|
||||||
|
vLog(L"Failed to handle simple file protocol %lx", Status);
|
||||||
|
goto END;
|
||||||
|
}
|
||||||
|
|
||||||
|
Status = FileIO->OpenVolume(Handle, &Root);
|
||||||
|
if (EFI_ERROR(Status))
|
||||||
|
{
|
||||||
|
vLog(L"Failed to open drive volume (%lx)\n", Status);
|
||||||
|
goto END;
|
||||||
|
}
|
||||||
|
|
||||||
|
Status = Root->Open(Root, &File, DpStr, EFI_FILE_MODE_READ, 0);
|
||||||
|
if (EFI_ERROR(Status))
|
||||||
|
{
|
||||||
|
vLog(L"Failed to open file (%s) (%lx)\n", DpStr, Status);
|
||||||
|
goto END;
|
||||||
|
}
|
||||||
|
|
||||||
|
FInfo = (EFI_FILE_INFO *)Buf;
|
||||||
|
TmpSize = sizeof(Buf);
|
||||||
|
ZeroMem(FInfo, sizeof(EFI_FILE_INFO));
|
||||||
|
|
||||||
|
Status = File->GetInfo(File, &gEfiFileInfoGuid, &TmpSize, FInfo);
|
||||||
|
if (EFI_ERROR(Status) || FInfo->FileSize == 0 || FInfo->FileSize >= 0xFFFFFFFFUL)
|
||||||
|
{
|
||||||
|
vLog(L"Failed to open file (%s) (%lx) Size(%ld)\n", DpStr, Status, (UINTN)FInfo->FileSize);
|
||||||
|
goto END;
|
||||||
|
}
|
||||||
|
|
||||||
|
FileData = AllocatePool(FInfo->FileSize);
|
||||||
|
if (!FileData)
|
||||||
|
{
|
||||||
|
Status = EFI_OUT_OF_RESOURCES;
|
||||||
|
goto END;
|
||||||
|
}
|
||||||
|
|
||||||
|
TmpSize = FInfo->FileSize;
|
||||||
|
Status = File->Read(File, &TmpSize, FileData);
|
||||||
|
if (EFI_ERROR(Status) || TmpSize != (UINTN)FInfo->FileSize)
|
||||||
|
{
|
||||||
|
vLog(L"Failed to read file (%lx) Read:%ld Size:%ld\n", Status, TmpSize, (UINTN)FInfo->FileSize);
|
||||||
|
goto END;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
END:
|
||||||
|
|
||||||
|
if (File)
|
||||||
|
{
|
||||||
|
File->Close(File);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Root)
|
||||||
|
{
|
||||||
|
Root->Close(Root);
|
||||||
|
}
|
||||||
|
|
||||||
|
CheckFreePool(TmpPath);
|
||||||
|
CheckFreePool(DpStr);
|
||||||
|
|
||||||
|
if (EFI_ERROR(Status))
|
||||||
|
{
|
||||||
|
CheckFreePool(FileData);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
*Buffer = FileData;
|
||||||
|
*Size = (UINT32)FInfo->FileSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
return Status;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
STATIC BOOLEAN VtoyCheckRevoke(VOID *Buffer, UINTN Size)
|
||||||
|
{
|
||||||
|
UINT32 uiVer = 0;
|
||||||
|
EFI_IMAGE_DOS_HEADER *DosHead = (EFI_IMAGE_DOS_HEADER *)Buffer;
|
||||||
|
|
||||||
|
if (Size > sizeof(EFI_IMAGE_DOS_HEADER) && DosHead->e_magic == 0x5A4D)
|
||||||
|
{
|
||||||
|
if (CompareMem(DosHead->e_res2, &gVtoySbatGUID, 16) == 0)
|
||||||
|
{
|
||||||
|
CopyMem(&uiVer, DosHead->e_res2 + 8, 4);
|
||||||
|
if (uiVer < CUR_SBAT_VER)
|
||||||
|
{
|
||||||
|
vLog(L"Ventoy EFI file revoke (%u < %u)", uiVer, CUR_SBAT_VER);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
STATIC EFI_STATUS EFIAPI SecurityPolicyAuth
|
||||||
|
(
|
||||||
|
const EFI_SECURITY_ARCH_PROTOCOL *This,
|
||||||
|
UINT32 AuthenticationStatus,
|
||||||
|
const EFI_DEVICE_PATH_PROTOCOL *DevicePathConst
|
||||||
|
)
|
||||||
|
{
|
||||||
|
EFI_STATUS Status;
|
||||||
|
BOOLEAN bRevokeChkOK = TRUE;
|
||||||
|
UINT32 Size = 0;
|
||||||
|
VOID *Buffer = NULL;
|
||||||
|
|
||||||
|
/* Just return OK if the user choose to bypass SB */
|
||||||
|
if (gVtoyByPassSB)
|
||||||
|
{
|
||||||
|
return EFI_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Step 1:
|
||||||
|
* Use original UEFI firmware auth API.
|
||||||
|
* If it's OK, it may be signed with Microsoft UEFI CA. (e.g. bootmgr/shim/...)
|
||||||
|
*/
|
||||||
|
if (gSysSecFileAuth)
|
||||||
|
{
|
||||||
|
Status = gSysSecFileAuth(This, AuthenticationStatus, DevicePathConst);
|
||||||
|
if (!EFI_ERROR(Status))
|
||||||
|
{
|
||||||
|
return EFI_SUCCESS;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Step 2:
|
||||||
|
* Use shim verify API.
|
||||||
|
* If it's OK, it may be signed with a MOK key. (e.g. Ventoy EFI files)
|
||||||
|
*/
|
||||||
|
if (gShimLock.Verify)
|
||||||
|
{
|
||||||
|
Status = ReadAuthFile(DevicePathConst, &Buffer, &Size);
|
||||||
|
if (!EFI_ERROR(Status))
|
||||||
|
{
|
||||||
|
Status = gShimLock.Verify(Buffer, Size);
|
||||||
|
if (!EFI_ERROR(Status))
|
||||||
|
{
|
||||||
|
bRevokeChkOK = VtoyCheckRevoke(Buffer, Size);
|
||||||
|
if (bRevokeChkOK)
|
||||||
|
{
|
||||||
|
FreePool(Buffer);
|
||||||
|
return EFI_SUCCESS;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
FreePool(Buffer);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ShowSBWarning(!bRevokeChkOK, DevicePathConst);
|
||||||
|
|
||||||
|
return EFI_SECURITY_VIOLATION;
|
||||||
|
}
|
||||||
|
|
||||||
|
STATIC EFI_STATUS EFIAPI Security2PolicyAuth
|
||||||
|
(
|
||||||
|
const EFI_SECURITY2_ARCH_PROTOCOL *This,
|
||||||
|
const EFI_DEVICE_PATH_PROTOCOL *DevicePath,
|
||||||
|
VOID *FileBuffer,
|
||||||
|
UINTN FileSize,
|
||||||
|
BOOLEAN BootPolicy
|
||||||
|
)
|
||||||
|
{
|
||||||
|
EFI_STATUS Status;
|
||||||
|
BOOLEAN bRevokeChkOK = TRUE;
|
||||||
|
|
||||||
|
/* Just return OK if the user choose to bypass SB */
|
||||||
|
if (gVtoyByPassSB)
|
||||||
|
{
|
||||||
|
return EFI_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Step 1:
|
||||||
|
* Use original UEFI firmware auth API.
|
||||||
|
* If it's OK, it may be signed with Microsoft UEFI CA. (e.g. bootmgr/shim/...)
|
||||||
|
*/
|
||||||
|
if (gSysSec2FileAuth)
|
||||||
|
{
|
||||||
|
Status = gSysSec2FileAuth(This, DevicePath, FileBuffer, FileSize, BootPolicy);
|
||||||
|
if (!EFI_ERROR(Status))
|
||||||
|
{
|
||||||
|
return EFI_SUCCESS;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Step 2:
|
||||||
|
* Use shim verify API.
|
||||||
|
* If it's OK, it may be signed with a MOK key. (e.g. Ventoy EFI files)
|
||||||
|
*/
|
||||||
|
if (gShimLock.Verify)
|
||||||
|
{
|
||||||
|
if (FileBuffer && FileSize > 0 && FileSize < 0xFFFFFFFFUL)
|
||||||
|
{
|
||||||
|
Status = gShimLock.Verify(FileBuffer, (UINT32)FileSize);
|
||||||
|
if (!EFI_ERROR(Status))
|
||||||
|
{
|
||||||
|
bRevokeChkOK = VtoyCheckRevoke(FileBuffer, FileSize);
|
||||||
|
if (bRevokeChkOK)
|
||||||
|
{
|
||||||
|
return EFI_SUCCESS;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ShowSBWarning(!bRevokeChkOK, DevicePath);
|
||||||
|
|
||||||
|
return EFI_SECURITY_VIOLATION;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
STATIC EFI_STATUS EFIAPI HookSecurityPolicy(VOID)
|
||||||
|
{
|
||||||
|
EFI_STATUS Status;
|
||||||
|
EFI_STATUS Status2;
|
||||||
|
EFI_SECURITY_ARCH_PROTOCOL *Security = NULL;
|
||||||
|
EFI_SECURITY2_ARCH_PROTOCOL *Security2 = NULL;
|
||||||
|
|
||||||
|
Status = gBS->LocateProtocol(&gEfiSecurityArchProtocolGuid, NULL, (VOID **)&Security);
|
||||||
|
Status2 = gBS->LocateProtocol(&gEfiSecurity2ArchProtocolGuid, NULL, (VOID **)&Security2);
|
||||||
|
if (EFI_ERROR(Status) && EFI_ERROR(Status2))
|
||||||
|
{
|
||||||
|
vLog(L"Failed to locate security or security2 protocol. %lx %lx %p %p",
|
||||||
|
Status, Status2, Security, Security2);
|
||||||
|
return EFI_NOT_FOUND;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Security2)
|
||||||
|
{
|
||||||
|
gSysSec2FileAuth = Security2->FileAuthentication;
|
||||||
|
Security2->FileAuthentication = Security2PolicyAuth;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Security)
|
||||||
|
{
|
||||||
|
gSysSecFileAuth = Security->FileAuthenticationState;
|
||||||
|
Security->FileAuthenticationState = SecurityPolicyAuth;
|
||||||
|
}
|
||||||
|
|
||||||
|
return EFI_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
STATIC VOID EFIAPI UnHookSecurityPolicy(VOID)
|
||||||
|
{
|
||||||
|
EFI_STATUS Status;
|
||||||
|
EFI_STATUS Status2;
|
||||||
|
EFI_SECURITY_ARCH_PROTOCOL *Security = NULL;
|
||||||
|
EFI_SECURITY2_ARCH_PROTOCOL *Security2 = NULL;
|
||||||
|
|
||||||
|
if (!gSysSec2FileAuth && !gSysSecFileAuth)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Status = gBS->LocateProtocol(&gEfiSecurityArchProtocolGuid, NULL, (VOID **)&Security);
|
||||||
|
Status2 = gBS->LocateProtocol(&gEfiSecurity2ArchProtocolGuid, NULL, (VOID **)&Security2);
|
||||||
|
if (EFI_ERROR(Status) && EFI_ERROR(Status2))
|
||||||
|
{
|
||||||
|
vLog(L"Failed to locate security or security2 protocol. %lx %lx %p %p",
|
||||||
|
Status, Status2, Security, Security2);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Security2 && gSysSec2FileAuth && Security2->FileAuthentication == Security2PolicyAuth)
|
||||||
|
{
|
||||||
|
Security2->FileAuthentication = gSysSec2FileAuth;
|
||||||
|
gSysSec2FileAuth = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Security && gSysSecFileAuth && Security->FileAuthenticationState == SecurityPolicyAuth)
|
||||||
|
{
|
||||||
|
Security->FileAuthenticationState = gSysSecFileAuth;
|
||||||
|
gSysSecFileAuth = NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
STATIC VOID EFIAPI VtoyByPassSB(VOID)
|
||||||
|
{
|
||||||
|
gVtoyByPassSB = TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
STATIC VOID EFIAPI VtoyCheckSB(VOID)
|
||||||
|
{
|
||||||
|
gVtoyByPassSB = FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
STATIC VOID EFIAPI UnInstallVtoyShimProtocol(VOID)
|
||||||
|
{
|
||||||
|
EFI_GUID Guid = VTOY_SHIM_POLICY_GUID;
|
||||||
|
|
||||||
|
if (gVtoyShimProtHandle)
|
||||||
|
{
|
||||||
|
gBS->UninstallProtocolInterface(gVtoyShimProtHandle, &Guid, &gVtoyShimProtocol);
|
||||||
|
gVtoyShimProtHandle = NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
STATIC EFI_STATUS EFIAPI InstallVtoyShimProtocol(VOID)
|
||||||
|
{
|
||||||
|
EFI_STATUS Status;
|
||||||
|
EFI_GUID Guid = VTOY_SHIM_POLICY_GUID;
|
||||||
|
VTOY_SHIM *Prot = NULL;
|
||||||
|
|
||||||
|
gVtoyShimProtocol.ByPassSB = VtoyByPassSB;
|
||||||
|
gVtoyShimProtocol.CheckSB = VtoyCheckSB;
|
||||||
|
|
||||||
|
Status = gBS->LocateProtocol(&Guid, NULL, (VOID**)&Prot);
|
||||||
|
if (!EFI_ERROR(Status))
|
||||||
|
{
|
||||||
|
vLog(L"Ventoy shim already loaded, cannot be nested.");
|
||||||
|
return EFI_ALREADY_STARTED;
|
||||||
|
}
|
||||||
|
|
||||||
|
Status = gBS->InstallProtocolInterface(&gVtoyShimProtHandle, &Guid,
|
||||||
|
EFI_NATIVE_INTERFACE, &gVtoyShimProtocol);
|
||||||
|
if (EFI_ERROR(Status))
|
||||||
|
{
|
||||||
|
vLog(L"Failed to install protocol %lx", Status);
|
||||||
|
}
|
||||||
|
|
||||||
|
return Status;
|
||||||
|
}
|
||||||
|
|
||||||
|
STATIC BOOLEAN EFIAPI IsSecureBootEnabled(VOID)
|
||||||
|
{
|
||||||
|
UINT8 SecureBoot = 0;
|
||||||
|
UINTN DataSize;
|
||||||
|
EFI_STATUS Status;
|
||||||
|
|
||||||
|
DataSize = sizeof(SecureBoot);
|
||||||
|
Status = gST->RuntimeServices->GetVariable(L"SecureBoot", &gEfiGlobalVariableGuid, NULL,
|
||||||
|
&DataSize, &SecureBoot);
|
||||||
|
if (EFI_ERROR(Status))
|
||||||
|
{
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
return SecureBoot ? TRUE : FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
STATIC BOOLEAN EFIAPI IsSetupMode(VOID)
|
||||||
|
{
|
||||||
|
UINT8 SetupMode = 0;
|
||||||
|
UINTN DataSize;
|
||||||
|
EFI_STATUS Status;
|
||||||
|
|
||||||
|
DataSize = sizeof(SetupMode);
|
||||||
|
Status = gST->RuntimeServices->GetVariable(L"SetupMode", &gEfiGlobalVariableGuid, NULL,
|
||||||
|
&DataSize, &SetupMode);
|
||||||
|
if (EFI_ERROR(Status))
|
||||||
|
{
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
return SetupMode ? TRUE : FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
STATIC EFI_STATUS EFIAPI ShimEfiMain
|
||||||
|
(
|
||||||
|
IN EFI_HANDLE ImageHandle,
|
||||||
|
IN EFI_SYSTEM_TABLE *SystemTable,
|
||||||
|
IN BOOLEAN IsSecureBoot,
|
||||||
|
IN BOOLEAN IsSetup
|
||||||
|
)
|
||||||
|
{
|
||||||
|
EFI_STATUS Status;
|
||||||
|
SHIM_LOCK *ShimLock = NULL;
|
||||||
|
shim_void_func_pf Func1 = NULL;
|
||||||
|
shim_void_func_pf Func2 = NULL;
|
||||||
|
|
||||||
|
/* If secure boot is not enabled or in SetupMode, nothing needed, just launch Ventoy grub */
|
||||||
|
if (!IsSecureBoot || IsSetup)
|
||||||
|
{
|
||||||
|
Status = LaunchRealGrub(ImageHandle, REAL_GRUB_FILE);
|
||||||
|
if (EFI_ERROR(Status))
|
||||||
|
{
|
||||||
|
vErr(L"Failed to launch %s", REAL_GRUB_FILE);
|
||||||
|
}
|
||||||
|
return Status;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* We must be launched by shim */
|
||||||
|
Status = gBS->LocateProtocol(&gShimLockGUID, NULL, (VOID**)&ShimLock);
|
||||||
|
if (EFI_ERROR(Status) || !ShimLock)
|
||||||
|
{
|
||||||
|
vErr(L"Failed to locate SHIM LOCK Protocol %lx", Status);
|
||||||
|
return Status;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Backup shim Lock because we will remove it later */
|
||||||
|
gShimLock.Verify = ShimLock->Verify;
|
||||||
|
gShimLock.Hash = ShimLock->Hash;
|
||||||
|
gShimLock.Context = ShimLock->Context;
|
||||||
|
|
||||||
|
Status = InstallVtoyShimProtocol();
|
||||||
|
if (EFI_ERROR(Status))
|
||||||
|
{
|
||||||
|
vErr(L"Failed to install ventoy shim protocol");
|
||||||
|
return Status;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* IMPORTANT: All recent shim implementations hook the UEFI Boot Services
|
||||||
|
* (e.g. LoadImage, StartImage) to enforce signature verification.
|
||||||
|
*
|
||||||
|
* We must restore the original system service pointers here. If we fail to do this,
|
||||||
|
* we will be unable to launch Ventoy-signed EFI binaries or any other unsigned
|
||||||
|
* EFI applications later, even when the user has explicitly opted to disable
|
||||||
|
* all Secure Boot validation checks.
|
||||||
|
*
|
||||||
|
* To the best of my knowledge, there is no official way to remove these hooks.
|
||||||
|
* This is a tricky hack that relies on shim's internal implementation details.
|
||||||
|
* It may break in future versions of shim, and a better approach may exist.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
Func1 = FindShimFuncAddr(NM_UNHOOK_SYSTEM_SERVICES_OFFSET);
|
||||||
|
Func2 = FindShimFuncAddr(NM_UNINSTALL_SHIM_PROTOCOLS_OFFSET);
|
||||||
|
if (!Func1 || !Func2)
|
||||||
|
{
|
||||||
|
vErr(L"Can not find shim func %p %p", Func1, Func2);
|
||||||
|
Status = EFI_NOT_FOUND;
|
||||||
|
goto END;
|
||||||
|
}
|
||||||
|
|
||||||
|
Func1(); /* call shim unhook_system_services() */
|
||||||
|
Func2(); /* call shim uninstall_shim_protocols() */
|
||||||
|
|
||||||
|
|
||||||
|
/* Hook the system security policy */
|
||||||
|
Status = HookSecurityPolicy();
|
||||||
|
if (EFI_ERROR(Status))
|
||||||
|
{
|
||||||
|
vErr(L"Failed to hook system security policy");
|
||||||
|
goto END;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Finally launch Ventoy grub */
|
||||||
|
Status = LaunchRealGrub(ImageHandle, REAL_GRUB_FILE);
|
||||||
|
if (EFI_ERROR(Status))
|
||||||
|
{
|
||||||
|
vErr(L"Failed to finally launch real grub %s", REAL_GRUB_FILE);
|
||||||
|
goto END;
|
||||||
|
}
|
||||||
|
|
||||||
|
END:
|
||||||
|
|
||||||
|
/* UnHook system security policy */
|
||||||
|
UnHookSecurityPolicy();
|
||||||
|
|
||||||
|
UnInstallVtoyShimProtocol();
|
||||||
|
|
||||||
|
return Status;
|
||||||
|
}
|
||||||
|
|
||||||
|
STATIC EFI_STATUS EFIAPI VtoyExitBootServices
|
||||||
|
(
|
||||||
|
IN EFI_HANDLE ImageHandle,
|
||||||
|
IN UINTN MapKey
|
||||||
|
)
|
||||||
|
{
|
||||||
|
UnHookSecurityPolicy();
|
||||||
|
UnInstallVtoyShimProtocol();
|
||||||
|
|
||||||
|
gST->RuntimeServices->GetVariable = gSysGetVariable;
|
||||||
|
gBS->ExitBootServices = gSysExitBootServices;
|
||||||
|
|
||||||
|
return gSysExitBootServices(ImageHandle, MapKey);
|
||||||
|
}
|
||||||
|
|
||||||
|
EFI_STATUS EFIAPI VtoyGetVariable
|
||||||
|
(
|
||||||
|
IN CHAR16 *VariableName,
|
||||||
|
IN EFI_GUID *VendorGuid,
|
||||||
|
OUT UINT32 *Attributes, OPTIONAL
|
||||||
|
IN OUT UINTN *DataSize,
|
||||||
|
OUT VOID *Data OPTIONAL
|
||||||
|
)
|
||||||
|
{
|
||||||
|
BOOLEAN bChk = FALSE;
|
||||||
|
EFI_STATUS Status;
|
||||||
|
|
||||||
|
if (gVtoyByPassSB && VariableName && VendorGuid && DataSize && Data && (*DataSize) > 0)
|
||||||
|
{
|
||||||
|
bChk = TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
Status = gSysGetVariable(VariableName, VendorGuid, Attributes, DataSize, Data);
|
||||||
|
if (bChk && (!EFI_ERROR(Status)))
|
||||||
|
{
|
||||||
|
if (CompareMem(&gShimLockGUID, VendorGuid, 16) == 0 &&
|
||||||
|
StrCmp(VariableName, L"MokSBState") == 0)
|
||||||
|
{
|
||||||
|
*(UINT8 *)Data = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return Status;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
EFI_STATUS EFIAPI VtoyShimEfiMain
|
||||||
|
(
|
||||||
|
IN EFI_HANDLE ImageHandle,
|
||||||
|
IN EFI_SYSTEM_TABLE *SystemTable
|
||||||
|
)
|
||||||
|
{
|
||||||
|
BOOLEAN IsSetup = FALSE;
|
||||||
|
BOOLEAN IsSecureBoot = FALSE;
|
||||||
|
EFI_STATUS Status;
|
||||||
|
|
||||||
|
IsSetup = IsSetupMode();
|
||||||
|
IsSecureBoot = IsSecureBootEnabled();
|
||||||
|
|
||||||
|
if (!IsSecureBoot || IsSetup)
|
||||||
|
{
|
||||||
|
Status = ShimEfiMain(ImageHandle, SystemTable, IsSecureBoot, IsSetup);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
gSysExitBootServices = gBS->ExitBootServices;
|
||||||
|
gBS->ExitBootServices = VtoyExitBootServices;
|
||||||
|
|
||||||
|
gSysGetVariable = gST->RuntimeServices->GetVariable;
|
||||||
|
gST->RuntimeServices->GetVariable = VtoyGetVariable;
|
||||||
|
|
||||||
|
Status = ShimEfiMain(ImageHandle, SystemTable, IsSecureBoot, IsSetup);
|
||||||
|
|
||||||
|
gBS->ExitBootServices = gSysExitBootServices;
|
||||||
|
gST->RuntimeServices->GetVariable = gSysGetVariable;
|
||||||
|
}
|
||||||
|
|
||||||
|
return Status;
|
||||||
|
}
|
||||||
|
|
||||||
@@ -0,0 +1,114 @@
|
|||||||
|
/******************************************************************************
|
||||||
|
* VtoyShim.h
|
||||||
|
*
|
||||||
|
* Copyright (c) 2017 - 2018, Intel Corporation. All rights reserved.<BR>
|
||||||
|
* SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef __VTOYSHIM_H__
|
||||||
|
#define __VTOYSHIM_H__
|
||||||
|
|
||||||
|
#if defined (MDE_CPU_IA32)
|
||||||
|
#define REAL_GRUB_FILE L"grubia32_real.efi"
|
||||||
|
#elif defined (MDE_CPU_X64)
|
||||||
|
#define REAL_GRUB_FILE L"grubx64_real.efi"
|
||||||
|
#elif defined (MDE_CPU_AARCH64)
|
||||||
|
#define REAL_GRUB_FILE L"grubaa64_real.efi"
|
||||||
|
#else
|
||||||
|
#error "Not supported now"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
/* The following definations are copied from shim source code */
|
||||||
|
|
||||||
|
#define SHIM_LOCK_GUID {0x605dab50, 0xe046, 0x4300, {0xab, 0xb6, 0x3d, 0xd8, 0x10, 0xdd, 0x8b, 0x23 } };
|
||||||
|
|
||||||
|
typedef
|
||||||
|
EFI_STATUS
|
||||||
|
(*EFI_SHIM_LOCK_VERIFY) (
|
||||||
|
IN VOID *buffer,
|
||||||
|
IN UINT32 size
|
||||||
|
);
|
||||||
|
|
||||||
|
typedef
|
||||||
|
EFI_STATUS
|
||||||
|
(*EFI_SHIM_LOCK_HASH) (
|
||||||
|
IN char *data,
|
||||||
|
IN int datasize,
|
||||||
|
PE_COFF_LOADER_IMAGE_CONTEXT *context,
|
||||||
|
UINT8 *sha256hash,
|
||||||
|
UINT8 *sha1hash
|
||||||
|
);
|
||||||
|
|
||||||
|
typedef
|
||||||
|
EFI_STATUS
|
||||||
|
(*EFI_SHIM_LOCK_CONTEXT) (
|
||||||
|
IN VOID *data,
|
||||||
|
IN unsigned int datasize,
|
||||||
|
PE_COFF_LOADER_IMAGE_CONTEXT *context
|
||||||
|
);
|
||||||
|
|
||||||
|
typedef struct _SHIM_LOCK {
|
||||||
|
EFI_SHIM_LOCK_VERIFY Verify;
|
||||||
|
EFI_SHIM_LOCK_HASH Hash;
|
||||||
|
EFI_SHIM_LOCK_CONTEXT Context;
|
||||||
|
} SHIM_LOCK;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#define SHIM_IMAGE_LOADER_GUID {0x1f492041, 0xfadb, 0x4e59, {0x9e, 0x57, 0x7c, 0xaf, 0xe7, 0x3a, 0x55, 0xab } }
|
||||||
|
|
||||||
|
typedef struct _SHIM_IMAGE_LOADER {
|
||||||
|
EFI_IMAGE_LOAD LoadImage;
|
||||||
|
EFI_IMAGE_START StartImage;
|
||||||
|
EFI_EXIT Exit;
|
||||||
|
EFI_IMAGE_UNLOAD UnloadImage;
|
||||||
|
} SHIM_IMAGE_LOADER;
|
||||||
|
|
||||||
|
typedef VOID (*shim_void_func_pf)(VOID);
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* The two offset here are extract from the shim file which used in Ventoy.
|
||||||
|
* nm BOOTX64.EFI | grep shim_load_image
|
||||||
|
* nm BOOTX64.EFI | grep unhook_system_services
|
||||||
|
* nm BOOTX64.EFI | grep uninstall_shim_protocols
|
||||||
|
*
|
||||||
|
* It means that they must be updated every time Ventoy update the shim file.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
#define NM_SHIM_LOAD_IMAGE_OFFSET 0x2dc12
|
||||||
|
#define NM_UNHOOK_SYSTEM_SERVICES_OFFSET 0x2e278
|
||||||
|
#define NM_UNINSTALL_SHIM_PROTOCOLS_OFFSET 0x26264
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#define VtoySleep(sec) gBS->Stall(1000000 * (sec))
|
||||||
|
#define vLog(fmt, ...) VtoyLog(fmt "\r\n", ##__VA_ARGS__)
|
||||||
|
#define vErr(fmt, ...) VtoyLog(fmt "\r\n", ##__VA_ARGS__); VtoySleep(5)
|
||||||
|
|
||||||
|
#define CheckFreePool(p) \
|
||||||
|
do { \
|
||||||
|
if (p) { \
|
||||||
|
FreePool(p); \
|
||||||
|
(p) = NULL; \
|
||||||
|
}\
|
||||||
|
} while (0)
|
||||||
|
|
||||||
|
|
||||||
|
#define VTOY_SHIM_POLICY_GUID {0x90a29d14, 0x3968, 0x48fe, { 0x85, 0x81, 0x6b, 0x7f, 0x7d, 0xc4, 0x70, 0x55 }};
|
||||||
|
|
||||||
|
|
||||||
|
typedef VOID (EFIAPI *VTOY_BYPASS_SB)(VOID);
|
||||||
|
typedef VOID (EFIAPI *VTOY_CHECK_SB)(VOID);
|
||||||
|
typedef struct _VTOY_SHIM{
|
||||||
|
VTOY_BYPASS_SB ByPassSB;
|
||||||
|
VTOY_BYPASS_SB CheckSB;
|
||||||
|
} VTOY_SHIM;
|
||||||
|
|
||||||
|
CONST UINT8 * ventoy_get_der_data(UINT32 *Len);
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
@@ -0,0 +1,83 @@
|
|||||||
|
#************************************************************************************
|
||||||
|
# Copyright (c) 2026, longpanda <admin@ventoy.net>
|
||||||
|
#
|
||||||
|
# This program is free software; you can redistribute it and/or
|
||||||
|
# modify it under the terms of the GNU General Public License as
|
||||||
|
# published by the Free Software Foundation; either version 3 of the
|
||||||
|
# License, or (at your option) any later version.
|
||||||
|
#
|
||||||
|
# This program is distributed in the hope that it will be useful, but
|
||||||
|
# WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
# General Public License for more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU General Public License
|
||||||
|
# along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||||
|
#
|
||||||
|
#************************************************************************************
|
||||||
|
|
||||||
|
[Defines]
|
||||||
|
INF_VERSION = 0x00010005
|
||||||
|
BASE_NAME = VtoyShim
|
||||||
|
FILE_GUID = 6d7c7406-b32c-461f-8454-ddaa5243d93d
|
||||||
|
MODULE_TYPE = UEFI_APPLICATION
|
||||||
|
VERSION_STRING = 1.0
|
||||||
|
ENTRY_POINT = VtoyShimEfiMain
|
||||||
|
|
||||||
|
[BuildOptions]
|
||||||
|
# Force standard GNU ld to pack and align ELF segments to 4KB page boundaries
|
||||||
|
GCC:*_*_*_DLINK_FLAGS = -Wl,-z,common-page-size=0x1000 -Wl,-z,max-page-size=0x1000
|
||||||
|
|
||||||
|
[Sources]
|
||||||
|
VtoyShim.h
|
||||||
|
VtoyShim.c
|
||||||
|
|
||||||
|
[Packages]
|
||||||
|
MdePkg/MdePkg.dec
|
||||||
|
MdeModulePkg/MdeModulePkg.dec
|
||||||
|
ShellPkg/ShellPkg.dec
|
||||||
|
|
||||||
|
[LibraryClasses]
|
||||||
|
UefiApplicationEntryPoint
|
||||||
|
UefiLib
|
||||||
|
DevicePathLib
|
||||||
|
DebugLib
|
||||||
|
|
||||||
|
[Guids]
|
||||||
|
gEfiGlobalVariableGuid
|
||||||
|
gShellVariableGuid
|
||||||
|
gEfiVirtualCdGuid
|
||||||
|
gEfiFileInfoGuid
|
||||||
|
|
||||||
|
[Protocols]
|
||||||
|
gEfiSecurityArchProtocolGuid
|
||||||
|
gEfiSecurity2ArchProtocolGuid
|
||||||
|
gEfiLoadedImageProtocolGuid
|
||||||
|
gEfiBlockIoProtocolGuid
|
||||||
|
gEfiDevicePathProtocolGuid
|
||||||
|
gEfiDevicePathToTextProtocolGuid
|
||||||
|
gEfiDevicePathFromTextProtocolGuid
|
||||||
|
gEfiSimpleFileSystemProtocolGuid
|
||||||
|
gEfiRamDiskProtocolGuid
|
||||||
|
gEfiAbsolutePointerProtocolGuid
|
||||||
|
gEfiAcpiTableProtocolGuid
|
||||||
|
gEfiBlockIo2ProtocolGuid
|
||||||
|
gEfiBusSpecificDriverOverrideProtocolGuid
|
||||||
|
gEfiComponentNameProtocolGuid
|
||||||
|
gEfiComponentName2ProtocolGuid
|
||||||
|
gEfiDriverBindingProtocolGuid
|
||||||
|
gEfiDiskIoProtocolGuid
|
||||||
|
gEfiDiskIo2ProtocolGuid
|
||||||
|
gEfiGraphicsOutputProtocolGuid
|
||||||
|
gEfiHiiConfigAccessProtocolGuid
|
||||||
|
gEfiHiiFontProtocolGuid
|
||||||
|
gEfiLoadFileProtocolGuid
|
||||||
|
gEfiLoadFile2ProtocolGuid
|
||||||
|
gEfiLoadedImageProtocolGuid
|
||||||
|
gEfiLoadedImageDevicePathProtocolGuid
|
||||||
|
gEfiPciIoProtocolGuid
|
||||||
|
gEfiSerialIoProtocolGuid
|
||||||
|
gEfiSimpleTextInProtocolGuid
|
||||||
|
gEfiSimpleTextInputExProtocolGuid
|
||||||
|
gEfiSimpleTextOutProtocolGuid
|
||||||
|
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
sbat,1,SBAT Version,sbat,1,https://github.com/rhboot/shim/blob/main/SBAT.md
|
||||||
|
ventoy-shim,1,Ventoy,ventoy-shim,1.0,https://www.ventoy.net/
|
||||||
|
@@ -145,6 +145,66 @@ STATIC EFI_STATUS ParseCmdline(IN EFI_HANDLE ImageHandle)
|
|||||||
return EFI_SUCCESS;
|
return EFI_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if defined (MDE_CPU_X64)
|
||||||
|
|
||||||
|
STATIC BOOLEAN EFIAPI IsSecureBootEnabled(VOID)
|
||||||
|
{
|
||||||
|
UINT8 SecureBoot = 0;
|
||||||
|
UINTN DataSize;
|
||||||
|
EFI_STATUS Status;
|
||||||
|
|
||||||
|
DataSize = sizeof(SecureBoot);
|
||||||
|
Status = gST->RuntimeServices->GetVariable(L"SecureBoot", &gEfiGlobalVariableGuid, NULL,
|
||||||
|
&DataSize, &SecureBoot);
|
||||||
|
if (EFI_ERROR(Status))
|
||||||
|
{
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
return SecureBoot ? TRUE : FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
STATIC BOOLEAN EFIAPI IsSetupMode(VOID)
|
||||||
|
{
|
||||||
|
UINT8 SetupMode = 0;
|
||||||
|
UINTN DataSize;
|
||||||
|
EFI_STATUS Status;
|
||||||
|
|
||||||
|
DataSize = sizeof(SetupMode);
|
||||||
|
Status = gST->RuntimeServices->GetVariable(L"SetupMode", &gEfiGlobalVariableGuid, NULL,
|
||||||
|
&DataSize, &SetupMode);
|
||||||
|
if (EFI_ERROR(Status))
|
||||||
|
{
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
return SetupMode ? TRUE : FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
STATIC BOOLEAN EFIAPI CheckVtoyShim(VOID)
|
||||||
|
{
|
||||||
|
EFI_STATUS Status;
|
||||||
|
EFI_GUID Guid = VTOY_SHIM_POLICY_GUID;
|
||||||
|
VOID *Prot = NULL;
|
||||||
|
|
||||||
|
/* If secure boot is not enabled or in SetupMode, nothing needed */
|
||||||
|
if (!IsSecureBootEnabled() || IsSetupMode())
|
||||||
|
{
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
Status = gBS->LocateProtocol(&Guid, NULL, (VOID**)&Prot);
|
||||||
|
if (EFI_ERROR(Status))
|
||||||
|
{
|
||||||
|
gST->ConOut->OutputString(gST->ConOut, L"Can not locate Vtoy Shim\r\n");
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
EFI_STATUS EFIAPI VtoyUtilEfiMain
|
EFI_STATUS EFIAPI VtoyUtilEfiMain
|
||||||
(
|
(
|
||||||
IN EFI_HANDLE ImageHandle,
|
IN EFI_HANDLE ImageHandle,
|
||||||
@@ -154,6 +214,15 @@ EFI_STATUS EFIAPI VtoyUtilEfiMain
|
|||||||
UINTN i;
|
UINTN i;
|
||||||
UINTN Len;
|
UINTN Len;
|
||||||
|
|
||||||
|
#if defined (MDE_CPU_X64)
|
||||||
|
/* check that Ventoy Shim must exist */
|
||||||
|
if (!CheckVtoyShim())
|
||||||
|
{
|
||||||
|
gBS->Stall(5 * 1000000);
|
||||||
|
return EFI_NOT_FOUND;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
ParseCmdline(ImageHandle);
|
ParseCmdline(ImageHandle);
|
||||||
|
|
||||||
for (i = 0; gCurFeature && i < ARRAY_SIZE(gFeatureList); i++)
|
for (i = 0; gCurFeature && i < ARRAY_SIZE(gFeatureList); i++)
|
||||||
|
|||||||
@@ -21,6 +21,8 @@
|
|||||||
#ifndef __VTOYUTIL_H__
|
#ifndef __VTOYUTIL_H__
|
||||||
#define __VTOYUTIL_H__
|
#define __VTOYUTIL_H__
|
||||||
|
|
||||||
|
#define VTOY_SHIM_POLICY_GUID {0x90a29d14, 0x3968, 0x48fe, { 0x85, 0x81, 0x6b, 0x7f, 0x7d, 0xc4, 0x70, 0x55 }};
|
||||||
|
|
||||||
#pragma pack(1)
|
#pragma pack(1)
|
||||||
|
|
||||||
typedef EFI_STATUS (*VTOY_UTIL_PROC_PF)(IN EFI_HANDLE ImageHandle, IN CONST CHAR16 *CmdLine);
|
typedef EFI_STATUS (*VTOY_UTIL_PROC_PF)(IN EFI_HANDLE ImageHandle, IN CONST CHAR16 *CmdLine);
|
||||||
|
|||||||
@@ -24,6 +24,9 @@
|
|||||||
VERSION_STRING = 1.0
|
VERSION_STRING = 1.0
|
||||||
ENTRY_POINT = VtoyUtilEfiMain
|
ENTRY_POINT = VtoyUtilEfiMain
|
||||||
|
|
||||||
|
[BuildOptions]
|
||||||
|
# Force standard GNU ld to pack and align ELF segments to 4KB page boundaries
|
||||||
|
GCC:*_*_*_DLINK_FLAGS = -Wl,-z,common-page-size=0x1000 -Wl,-z,max-page-size=0x1000
|
||||||
|
|
||||||
[Sources]
|
[Sources]
|
||||||
VtoyUtil.h
|
VtoyUtil.h
|
||||||
|
|||||||
@@ -205,6 +205,7 @@
|
|||||||
[Components]
|
[Components]
|
||||||
MdeModulePkg/Application/Ventoy/Ventoy.inf
|
MdeModulePkg/Application/Ventoy/Ventoy.inf
|
||||||
MdeModulePkg/Application/VtoyUtil/VtoyUtil.inf
|
MdeModulePkg/Application/VtoyUtil/VtoyUtil.inf
|
||||||
|
MdeModulePkg/Application/VtoyShim/VtoyShim.inf
|
||||||
MdeModulePkg/Application/VDiskChain/VDiskChain.inf
|
MdeModulePkg/Application/VDiskChain/VDiskChain.inf
|
||||||
MdeModulePkg/Application/HelloWorld/HelloWorld.inf
|
MdeModulePkg/Application/HelloWorld/HelloWorld.inf
|
||||||
MdeModulePkg/Application/DumpDynPcd/DumpDynPcd.inf
|
MdeModulePkg/Application/DumpDynPcd/DumpDynPcd.inf
|
||||||
|
|||||||
2282
GRUB2/MOD_SRC/grub-2.04/grub-core/fs/btrfs.c
Normal file
2282
GRUB2/MOD_SRC/grub-2.04/grub-core/fs/btrfs.c
Normal file
File diff suppressed because it is too large
Load Diff
@@ -103,6 +103,7 @@ GRUB_MOD_LICENSE ("GPLv3+");
|
|||||||
#define EXT4_FEATURE_INCOMPAT_64BIT 0x0080
|
#define EXT4_FEATURE_INCOMPAT_64BIT 0x0080
|
||||||
#define EXT4_FEATURE_INCOMPAT_MMP 0x0100
|
#define EXT4_FEATURE_INCOMPAT_MMP 0x0100
|
||||||
#define EXT4_FEATURE_INCOMPAT_FLEX_BG 0x0200
|
#define EXT4_FEATURE_INCOMPAT_FLEX_BG 0x0200
|
||||||
|
#define EXT4_FEATURE_INCOMPAT_CSUM_SEED 0x2000
|
||||||
#define EXT4_FEATURE_INCOMPAT_ENCRYPT 0x10000
|
#define EXT4_FEATURE_INCOMPAT_ENCRYPT 0x10000
|
||||||
|
|
||||||
/* The set of back-incompatible features this driver DOES support. Add (OR)
|
/* The set of back-incompatible features this driver DOES support. Add (OR)
|
||||||
@@ -123,9 +124,16 @@ GRUB_MOD_LICENSE ("GPLv3+");
|
|||||||
* mmp: Not really back-incompatible - was added as such to
|
* mmp: Not really back-incompatible - was added as such to
|
||||||
* avoid multiple read-write mounts. Safe to ignore for this
|
* avoid multiple read-write mounts. Safe to ignore for this
|
||||||
* RO driver.
|
* RO driver.
|
||||||
|
* checksum seed: Not really back-incompatible - was added to allow tools
|
||||||
|
* such as tune2fs to change the UUID on a mounted metadata
|
||||||
|
* checksummed filesystem. Safe to ignore for now since the
|
||||||
|
* driver doesn't support checksum verification. But it must
|
||||||
|
* be removed from this list if that support is added later.
|
||||||
|
*
|
||||||
*/
|
*/
|
||||||
#define EXT2_DRIVER_IGNORED_INCOMPAT ( EXT3_FEATURE_INCOMPAT_RECOVER \
|
#define EXT2_DRIVER_IGNORED_INCOMPAT ( EXT3_FEATURE_INCOMPAT_RECOVER \
|
||||||
| EXT4_FEATURE_INCOMPAT_MMP)
|
| EXT4_FEATURE_INCOMPAT_MMP \
|
||||||
|
| EXT4_FEATURE_INCOMPAT_CSUM_SEED)
|
||||||
|
|
||||||
|
|
||||||
#define EXT3_JOURNAL_MAGIC_NUMBER 0xc03b3998U
|
#define EXT3_JOURNAL_MAGIC_NUMBER 0xc03b3998U
|
||||||
@@ -723,10 +731,11 @@ grub_ext2_read_symlink (grub_fshelp_node_t node)
|
|||||||
if (! symlink)
|
if (! symlink)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
/* If the filesize of the symlink is bigger than
|
/*
|
||||||
60 the symlink is stored in a separate block,
|
* If the filesize of the symlink is equal to or bigger than 60 the symlink
|
||||||
otherwise it is stored in the inode. */
|
* is stored in a separate block, otherwise it is stored in the inode.
|
||||||
if (grub_le_to_cpu32 (diro->inode.size) <= sizeof (diro->inode.symlink))
|
*/
|
||||||
|
if (grub_le_to_cpu32 (diro->inode.size) < sizeof (diro->inode.symlink))
|
||||||
grub_memcpy (symlink,
|
grub_memcpy (symlink,
|
||||||
diro->inode.symlink,
|
diro->inode.symlink,
|
||||||
grub_le_to_cpu32 (diro->inode.size));
|
grub_le_to_cpu32 (diro->inode.size));
|
||||||
|
|||||||
@@ -23,11 +23,25 @@
|
|||||||
#include <grub/misc.h>
|
#include <grub/misc.h>
|
||||||
#include <grub/disk.h>
|
#include <grub/disk.h>
|
||||||
#include <grub/dl.h>
|
#include <grub/dl.h>
|
||||||
|
#include <grub/time.h>
|
||||||
#include <grub/types.h>
|
#include <grub/types.h>
|
||||||
#include <grub/fshelp.h>
|
#include <grub/fshelp.h>
|
||||||
|
|
||||||
GRUB_MOD_LICENSE ("GPLv3+");
|
GRUB_MOD_LICENSE ("GPLv3+");
|
||||||
|
|
||||||
|
#define NSEC_PER_SEC ((grub_int64_t) 1000000000)
|
||||||
|
|
||||||
|
// GRUB 2.04 doesn't have safemath.h
|
||||||
|
// #include <grub/safemath.h>
|
||||||
|
|
||||||
|
// gcc < 5.1 doesn't support __builtin_add_overflow and __builtin_mul_overflow
|
||||||
|
// #define grub_add(a, b, res) __builtin_add_overflow(a, b, res)
|
||||||
|
// #define grub_mul(a, b, res) __builtin_mul_overflow(a, b, res)
|
||||||
|
// Warning: This is unsafe!
|
||||||
|
#define grub_add(a, b, res) ({ *(res) = (a) + (b); 0; })
|
||||||
|
|
||||||
|
#define grub_mul(a, b, res) ({ *(res) = (a) * (b); 0; })
|
||||||
|
|
||||||
#define XFS_INODE_EXTENTS 9
|
#define XFS_INODE_EXTENTS 9
|
||||||
|
|
||||||
#define XFS_INODE_FORMAT_INO 1
|
#define XFS_INODE_FORMAT_INO 1
|
||||||
@@ -74,10 +88,22 @@ GRUB_MOD_LICENSE ("GPLv3+");
|
|||||||
XFS_SB_VERSION2_PROJID32BIT | \
|
XFS_SB_VERSION2_PROJID32BIT | \
|
||||||
XFS_SB_VERSION2_FTYPE)
|
XFS_SB_VERSION2_FTYPE)
|
||||||
|
|
||||||
|
/* Inode flags2 flags */
|
||||||
|
#define XFS_DIFLAG2_BIGTIME_BIT 3
|
||||||
|
#define XFS_DIFLAG2_BIGTIME (1 << XFS_DIFLAG2_BIGTIME_BIT)
|
||||||
|
#define XFS_DIFLAG2_NREXT64_BIT 4
|
||||||
|
#define XFS_DIFLAG2_NREXT64 (1 << XFS_DIFLAG2_NREXT64_BIT)
|
||||||
|
|
||||||
/* incompat feature flags */
|
/* incompat feature flags */
|
||||||
#define XFS_SB_FEAT_INCOMPAT_FTYPE (1 << 0) /* filetype in dirent */
|
#define XFS_SB_FEAT_INCOMPAT_FTYPE (1 << 0) /* filetype in dirent */
|
||||||
#define XFS_SB_FEAT_INCOMPAT_SPINODES (1 << 1) /* sparse inode chunks */
|
#define XFS_SB_FEAT_INCOMPAT_SPINODES (1 << 1) /* sparse inode chunks */
|
||||||
#define XFS_SB_FEAT_INCOMPAT_META_UUID (1 << 2) /* metadata UUID */
|
#define XFS_SB_FEAT_INCOMPAT_META_UUID (1 << 2) /* metadata UUID */
|
||||||
|
#define XFS_SB_FEAT_INCOMPAT_BIGTIME (1 << 3) /* large timestamps */
|
||||||
|
#define XFS_SB_FEAT_INCOMPAT_NEEDSREPAIR (1 << 4) /* needs xfs_repair */
|
||||||
|
#define XFS_SB_FEAT_INCOMPAT_NREXT64 (1 << 5) /* large extent counters */
|
||||||
|
#define XFS_SB_FEAT_INCOMPAT_EXCHRANGE (1 << 6) /* exchangerange supported */
|
||||||
|
#define XFS_SB_FEAT_INCOMPAT_PARENT (1 << 7) /* parent pointers */
|
||||||
|
#define XFS_SB_FEAT_INCOMPAT_METADIR (1 << 8) /* metadata dir tree */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Directory entries with ftype are explicitly handled by GRUB code.
|
* Directory entries with ftype are explicitly handled by GRUB code.
|
||||||
@@ -87,11 +113,26 @@ GRUB_MOD_LICENSE ("GPLv3+");
|
|||||||
*
|
*
|
||||||
* We do not currently verify metadata UUID, so it is safe to read filesystems
|
* We do not currently verify metadata UUID, so it is safe to read filesystems
|
||||||
* with the XFS_SB_FEAT_INCOMPAT_META_UUID feature.
|
* with the XFS_SB_FEAT_INCOMPAT_META_UUID feature.
|
||||||
|
*
|
||||||
|
* We do not currently replay the log, so it is safe to read filesystems
|
||||||
|
* with the XFS_SB_FEAT_INCOMPAT_EXCHRANGE feature.
|
||||||
|
*
|
||||||
|
* We do not currently read directory parent pointers, so it is safe to read
|
||||||
|
* filesystems with the XFS_SB_FEAT_INCOMPAT_PARENT feature.
|
||||||
|
*
|
||||||
|
* We do not currently look at realtime or quota metadata, so it is safe to
|
||||||
|
* read filesystems with the XFS_SB_FEAT_INCOMPAT_METADIR feature.
|
||||||
*/
|
*/
|
||||||
#define XFS_SB_FEAT_INCOMPAT_SUPPORTED \
|
#define XFS_SB_FEAT_INCOMPAT_SUPPORTED \
|
||||||
(XFS_SB_FEAT_INCOMPAT_FTYPE | \
|
(XFS_SB_FEAT_INCOMPAT_FTYPE | \
|
||||||
XFS_SB_FEAT_INCOMPAT_SPINODES | \
|
XFS_SB_FEAT_INCOMPAT_SPINODES | \
|
||||||
XFS_SB_FEAT_INCOMPAT_META_UUID)
|
XFS_SB_FEAT_INCOMPAT_META_UUID | \
|
||||||
|
XFS_SB_FEAT_INCOMPAT_BIGTIME | \
|
||||||
|
XFS_SB_FEAT_INCOMPAT_NEEDSREPAIR | \
|
||||||
|
XFS_SB_FEAT_INCOMPAT_NREXT64 | \
|
||||||
|
XFS_SB_FEAT_INCOMPAT_EXCHRANGE | \
|
||||||
|
XFS_SB_FEAT_INCOMPAT_PARENT | \
|
||||||
|
XFS_SB_FEAT_INCOMPAT_METADIR)
|
||||||
|
|
||||||
struct grub_xfs_sblock
|
struct grub_xfs_sblock
|
||||||
{
|
{
|
||||||
@@ -176,33 +217,49 @@ struct grub_xfs_btree_root
|
|||||||
grub_uint64_t keys[1];
|
grub_uint64_t keys[1];
|
||||||
} GRUB_PACKED;
|
} GRUB_PACKED;
|
||||||
|
|
||||||
struct grub_xfs_time
|
struct grub_xfs_time_legacy
|
||||||
{
|
{
|
||||||
grub_uint32_t sec;
|
grub_uint32_t sec;
|
||||||
grub_uint32_t nanosec;
|
grub_uint32_t nanosec;
|
||||||
} GRUB_PACKED;
|
} GRUB_PACKED;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* The struct grub_xfs_inode layout was taken from the
|
||||||
|
* struct xfs_dinode_core which is described here:
|
||||||
|
* https://mirrors.edge.kernel.org/pub/linux/utils/fs/xfs/docs/xfs_filesystem_structure.pdf
|
||||||
|
*/
|
||||||
struct grub_xfs_inode
|
struct grub_xfs_inode
|
||||||
{
|
{
|
||||||
grub_uint8_t magic[2];
|
grub_uint8_t magic[2];
|
||||||
grub_uint16_t mode;
|
grub_uint16_t mode;
|
||||||
grub_uint8_t version;
|
grub_uint8_t version;
|
||||||
grub_uint8_t format;
|
grub_uint8_t format;
|
||||||
grub_uint8_t unused2[26];
|
grub_uint8_t unused2[18];
|
||||||
struct grub_xfs_time atime;
|
grub_uint64_t nextents_big;
|
||||||
struct grub_xfs_time mtime;
|
grub_uint64_t atime;
|
||||||
struct grub_xfs_time ctime;
|
grub_uint64_t mtime;
|
||||||
|
grub_uint64_t ctime;
|
||||||
grub_uint64_t size;
|
grub_uint64_t size;
|
||||||
grub_uint64_t nblocks;
|
grub_uint64_t nblocks;
|
||||||
grub_uint32_t extsize;
|
grub_uint32_t extsize;
|
||||||
grub_uint32_t nextents;
|
grub_uint32_t nextents;
|
||||||
grub_uint16_t unused3;
|
grub_uint16_t unused3;
|
||||||
grub_uint8_t fork_offset;
|
grub_uint8_t fork_offset;
|
||||||
grub_uint8_t unused4[17];
|
grub_uint8_t unused4[17]; /* Last member of inode v2. */
|
||||||
|
grub_uint8_t unused5[20]; /* First member of inode v3. */
|
||||||
|
grub_uint64_t flags2;
|
||||||
|
grub_uint8_t unused6[48]; /* Last member of inode v3. */
|
||||||
} GRUB_PACKED;
|
} GRUB_PACKED;
|
||||||
|
|
||||||
#define XFS_V2_INODE_SIZE sizeof(struct grub_xfs_inode)
|
#define XFS_V3_INODE_SIZE sizeof(struct grub_xfs_inode)
|
||||||
#define XFS_V3_INODE_SIZE (XFS_V2_INODE_SIZE + 76)
|
/* Size of struct grub_xfs_inode v2, up to unused4 member included. */
|
||||||
|
#define XFS_V2_INODE_SIZE (XFS_V3_INODE_SIZE - 76)
|
||||||
|
|
||||||
|
struct grub_xfs_dir_leaf_entry
|
||||||
|
{
|
||||||
|
grub_uint32_t hashval;
|
||||||
|
grub_uint32_t address;
|
||||||
|
} GRUB_PACKED;
|
||||||
|
|
||||||
struct grub_xfs_dirblock_tail
|
struct grub_xfs_dirblock_tail
|
||||||
{
|
{
|
||||||
@@ -220,6 +277,7 @@ struct grub_fshelp_node
|
|||||||
|
|
||||||
struct grub_xfs_data
|
struct grub_xfs_data
|
||||||
{
|
{
|
||||||
|
grub_size_t data_size;
|
||||||
struct grub_xfs_sblock sblock;
|
struct grub_xfs_sblock sblock;
|
||||||
grub_disk_t disk;
|
grub_disk_t disk;
|
||||||
int pos;
|
int pos;
|
||||||
@@ -232,8 +290,6 @@ struct grub_xfs_data
|
|||||||
|
|
||||||
static grub_dl_t my_mod;
|
static grub_dl_t my_mod;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
static int grub_xfs_sb_hascrc(struct grub_xfs_data *data)
|
static int grub_xfs_sb_hascrc(struct grub_xfs_data *data)
|
||||||
{
|
{
|
||||||
return (data->sblock.version & grub_cpu_to_be16_compile_time(XFS_SB_VERSION_NUMBITS)) ==
|
return (data->sblock.version & grub_cpu_to_be16_compile_time(XFS_SB_VERSION_NUMBITS)) ==
|
||||||
@@ -296,9 +352,21 @@ static int grub_xfs_sb_valid(struct grub_xfs_data *data)
|
|||||||
}
|
}
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
grub_error (GRUB_ERR_BAD_FS, "unsupported XFS filesystem version");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
grub_xfs_sb_needs_repair (struct grub_xfs_data *data)
|
||||||
|
{
|
||||||
|
return ((data->sblock.version &
|
||||||
|
grub_cpu_to_be16_compile_time (XFS_SB_VERSION_NUMBITS)) ==
|
||||||
|
grub_cpu_to_be16_compile_time (XFS_SB_VERSION_5) &&
|
||||||
|
(data->sblock.sb_features_incompat &
|
||||||
|
grub_cpu_to_be32_compile_time (XFS_SB_FEAT_INCOMPAT_NEEDSREPAIR)));
|
||||||
|
}
|
||||||
|
|
||||||
/* Filetype information as used in inodes. */
|
/* Filetype information as used in inodes. */
|
||||||
#define FILETYPE_INO_MASK 0170000
|
#define FILETYPE_INO_MASK 0170000
|
||||||
#define FILETYPE_INO_REG 0100000
|
#define FILETYPE_INO_REG 0100000
|
||||||
@@ -354,7 +422,6 @@ GRUB_XFS_EXTENT_SIZE (struct grub_xfs_extent *exts, int ex)
|
|||||||
return (grub_be_to_cpu32 (exts[ex].raw[3]) & ((1 << 21) - 1));
|
return (grub_be_to_cpu32 (exts[ex].raw[3]) & ((1 << 21) - 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static inline grub_uint64_t
|
static inline grub_uint64_t
|
||||||
grub_xfs_inode_block (struct grub_xfs_data *data,
|
grub_xfs_inode_block (struct grub_xfs_data *data,
|
||||||
grub_uint64_t ino)
|
grub_uint64_t ino)
|
||||||
@@ -489,7 +556,7 @@ grub_xfs_read_inode (struct grub_xfs_data *data, grub_uint64_t ino,
|
|||||||
grub_uint64_t block = grub_xfs_inode_block (data, ino);
|
grub_uint64_t block = grub_xfs_inode_block (data, ino);
|
||||||
int offset = grub_xfs_inode_offset (data, ino);
|
int offset = grub_xfs_inode_offset (data, ino);
|
||||||
|
|
||||||
grub_dprintf("xfs", "Reading inode (%"PRIuGRUB_UINT64_T") - %"PRIuGRUB_UINT64_T", %d\n",
|
grub_dprintf("xfs", "Reading inode (%" PRIuGRUB_UINT64_T ") - %" PRIuGRUB_UINT64_T ", %d\n",
|
||||||
ino, block, offset);
|
ino, block, offset);
|
||||||
/* Read the inode. */
|
/* Read the inode. */
|
||||||
if (grub_disk_read (data->disk, block, offset, grub_xfs_inode_size(data),
|
if (grub_disk_read (data->disk, block, offset, grub_xfs_inode_size(data),
|
||||||
@@ -509,11 +576,26 @@ get_fsb (const void *keys, int idx)
|
|||||||
return grub_be_to_cpu64 (grub_get_unaligned64 (p));
|
return grub_be_to_cpu64 (grub_get_unaligned64 (p));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
grub_xfs_inode_has_large_extent_counts (const struct grub_xfs_inode *inode)
|
||||||
|
{
|
||||||
|
return inode->version >= 3 &&
|
||||||
|
(inode->flags2 & grub_cpu_to_be64_compile_time (XFS_DIFLAG2_NREXT64));
|
||||||
|
}
|
||||||
|
|
||||||
|
static grub_uint64_t
|
||||||
|
grub_xfs_get_inode_nextents (struct grub_xfs_inode *inode)
|
||||||
|
{
|
||||||
|
return (grub_xfs_inode_has_large_extent_counts (inode)) ?
|
||||||
|
grub_be_to_cpu64 (inode->nextents_big) :
|
||||||
|
grub_be_to_cpu32 (inode->nextents);
|
||||||
|
}
|
||||||
|
|
||||||
static grub_disk_addr_t
|
static grub_disk_addr_t
|
||||||
grub_xfs_read_block (grub_fshelp_node_t node, grub_disk_addr_t fileblock)
|
grub_xfs_read_block (grub_fshelp_node_t node, grub_disk_addr_t fileblock)
|
||||||
{
|
{
|
||||||
struct grub_xfs_btree_node *leaf = 0;
|
struct grub_xfs_btree_node *leaf = 0;
|
||||||
int ex, nrec;
|
grub_uint64_t ex, nrec;
|
||||||
struct grub_xfs_extent *exts;
|
struct grub_xfs_extent *exts;
|
||||||
grub_uint64_t ret = 0;
|
grub_uint64_t ret = 0;
|
||||||
|
|
||||||
@@ -538,7 +620,18 @@ grub_xfs_read_block (grub_fshelp_node_t node, grub_disk_addr_t fileblock)
|
|||||||
/ (2 * sizeof (grub_uint64_t));
|
/ (2 * sizeof (grub_uint64_t));
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
int i;
|
grub_uint64_t i;
|
||||||
|
grub_addr_t keys_end, data_end;
|
||||||
|
|
||||||
|
if (grub_mul (sizeof (grub_uint64_t), nrec, &keys_end) ||
|
||||||
|
grub_add ((grub_addr_t) keys, keys_end, &keys_end) ||
|
||||||
|
grub_add ((grub_addr_t) node->data, node->data->data_size, &data_end) ||
|
||||||
|
keys_end > data_end)
|
||||||
|
{
|
||||||
|
grub_error (GRUB_ERR_BAD_FS, "invalid number of XFS root keys");
|
||||||
|
grub_free (leaf);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
for (i = 0; i < nrec; i++)
|
for (i = 0; i < nrec; i++)
|
||||||
{
|
{
|
||||||
@@ -556,7 +649,10 @@ grub_xfs_read_block (grub_fshelp_node_t node, grub_disk_addr_t fileblock)
|
|||||||
if (grub_disk_read (node->data->disk,
|
if (grub_disk_read (node->data->disk,
|
||||||
GRUB_XFS_FSB_TO_BLOCK (node->data, get_fsb (keys, i - 1 + recoffset)) << (node->data->sblock.log2_bsize - GRUB_DISK_SECTOR_BITS),
|
GRUB_XFS_FSB_TO_BLOCK (node->data, get_fsb (keys, i - 1 + recoffset)) << (node->data->sblock.log2_bsize - GRUB_DISK_SECTOR_BITS),
|
||||||
0, node->data->bsize, leaf))
|
0, node->data->bsize, leaf))
|
||||||
return 0;
|
{
|
||||||
|
grub_free (leaf);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
if ((!node->data->hascrc &&
|
if ((!node->data->hascrc &&
|
||||||
grub_strncmp ((char *) leaf->magic, "BMAP", 4)) ||
|
grub_strncmp ((char *) leaf->magic, "BMAP", 4)) ||
|
||||||
@@ -579,8 +675,20 @@ grub_xfs_read_block (grub_fshelp_node_t node, grub_disk_addr_t fileblock)
|
|||||||
}
|
}
|
||||||
else if (node->inode.format == XFS_INODE_FORMAT_EXT)
|
else if (node->inode.format == XFS_INODE_FORMAT_EXT)
|
||||||
{
|
{
|
||||||
nrec = grub_be_to_cpu32 (node->inode.nextents);
|
grub_addr_t exts_end = 0;
|
||||||
|
grub_addr_t data_end = 0;
|
||||||
|
|
||||||
|
nrec = grub_xfs_get_inode_nextents (&node->inode);
|
||||||
exts = (struct grub_xfs_extent *) grub_xfs_inode_data(&node->inode);
|
exts = (struct grub_xfs_extent *) grub_xfs_inode_data(&node->inode);
|
||||||
|
|
||||||
|
if (grub_mul (sizeof (struct grub_xfs_extent), nrec, &exts_end) ||
|
||||||
|
grub_add ((grub_addr_t) node->data, exts_end, &exts_end) ||
|
||||||
|
grub_add ((grub_addr_t) node->data, node->data->data_size, &data_end) ||
|
||||||
|
exts_end > data_end)
|
||||||
|
{
|
||||||
|
grub_error (GRUB_ERR_BAD_FS, "invalid number of XFS extents");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -634,6 +742,7 @@ static char *
|
|||||||
grub_xfs_read_symlink (grub_fshelp_node_t node)
|
grub_xfs_read_symlink (grub_fshelp_node_t node)
|
||||||
{
|
{
|
||||||
grub_ssize_t size = grub_be_to_cpu64 (node->inode.size);
|
grub_ssize_t size = grub_be_to_cpu64 (node->inode.size);
|
||||||
|
grub_size_t sz;
|
||||||
|
|
||||||
if (size < 0)
|
if (size < 0)
|
||||||
{
|
{
|
||||||
@@ -655,7 +764,12 @@ grub_xfs_read_symlink (grub_fshelp_node_t node)
|
|||||||
if (node->data->hascrc)
|
if (node->data->hascrc)
|
||||||
off = 56;
|
off = 56;
|
||||||
|
|
||||||
symlink = grub_malloc (size + 1);
|
if (grub_add (size, 1, &sz))
|
||||||
|
{
|
||||||
|
grub_error (GRUB_ERR_OUT_OF_RANGE, N_("symlink size overflow"));
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
symlink = grub_malloc (sz);
|
||||||
if (!symlink)
|
if (!symlink)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
@@ -705,8 +819,15 @@ static int iterate_dir_call_hook (grub_uint64_t ino, const char *filename,
|
|||||||
{
|
{
|
||||||
struct grub_fshelp_node *fdiro;
|
struct grub_fshelp_node *fdiro;
|
||||||
grub_err_t err;
|
grub_err_t err;
|
||||||
|
grub_size_t sz;
|
||||||
|
|
||||||
fdiro = grub_malloc (grub_xfs_fshelp_size(ctx->diro->data) + 1);
|
if (grub_add (grub_xfs_fshelp_size(ctx->diro->data), 1, &sz))
|
||||||
|
{
|
||||||
|
grub_error (GRUB_ERR_OUT_OF_RANGE, N_("directory data size overflow"));
|
||||||
|
grub_print_error ();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
fdiro = grub_malloc (sz);
|
||||||
if (!fdiro)
|
if (!fdiro)
|
||||||
{
|
{
|
||||||
grub_print_error ();
|
grub_print_error ();
|
||||||
@@ -722,6 +843,7 @@ static int iterate_dir_call_hook (grub_uint64_t ino, const char *filename,
|
|||||||
if (err)
|
if (err)
|
||||||
{
|
{
|
||||||
grub_print_error ();
|
grub_print_error ();
|
||||||
|
grub_free (fdiro);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -764,12 +886,20 @@ grub_xfs_iterate_dir (grub_fshelp_node_t dir,
|
|||||||
if (iterate_dir_call_hook (parent, "..", &ctx))
|
if (iterate_dir_call_hook (parent, "..", &ctx))
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
for (i = 0; i < head->count; i++)
|
for (i = 0; i < head->count &&
|
||||||
|
(grub_uint8_t *) de < ((grub_uint8_t *) dir + grub_xfs_fshelp_size (dir->data)); i++)
|
||||||
{
|
{
|
||||||
grub_uint64_t ino;
|
grub_uint64_t ino;
|
||||||
grub_uint8_t *inopos = grub_xfs_inline_de_inopos(dir->data, de);
|
grub_uint8_t *inopos = grub_xfs_inline_de_inopos(dir->data, de);
|
||||||
grub_uint8_t c;
|
grub_uint8_t c;
|
||||||
|
|
||||||
|
if ((inopos + (smallino ? 4 : 8)) > (grub_uint8_t *) dir + grub_xfs_fshelp_size (dir->data))
|
||||||
|
{
|
||||||
|
grub_error (GRUB_ERR_BAD_FS, "invalid XFS inode");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/* inopos might be unaligned. */
|
/* inopos might be unaligned. */
|
||||||
if (smallino)
|
if (smallino)
|
||||||
ino = (((grub_uint32_t) inopos[0]) << 24)
|
ino = (((grub_uint32_t) inopos[0]) << 24)
|
||||||
@@ -824,24 +954,49 @@ grub_xfs_iterate_dir (grub_fshelp_node_t dir,
|
|||||||
{
|
{
|
||||||
struct grub_xfs_dir2_entry *direntry =
|
struct grub_xfs_dir2_entry *direntry =
|
||||||
grub_xfs_first_de(dir->data, dirblock);
|
grub_xfs_first_de(dir->data, dirblock);
|
||||||
int entries;
|
int entries = -1;
|
||||||
struct grub_xfs_dirblock_tail *tail =
|
char *end = dirblock + dirblk_size;
|
||||||
grub_xfs_dir_tail(dir->data, dirblock);
|
grub_uint32_t magic;
|
||||||
|
|
||||||
numread = grub_xfs_read_file (dir, 0, 0,
|
numread = grub_xfs_read_file (dir, 0, 0,
|
||||||
blk << dirblk_log2,
|
blk << dirblk_log2,
|
||||||
dirblk_size, dirblock, 0);
|
dirblk_size, dirblock, 0);
|
||||||
if (numread != dirblk_size)
|
if (numread != dirblk_size)
|
||||||
return 0;
|
{
|
||||||
|
grub_free (dirblock);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
entries = (grub_be_to_cpu32 (tail->leaf_count)
|
/*
|
||||||
- grub_be_to_cpu32 (tail->leaf_stale));
|
* If this data block isn't actually part of the extent list then
|
||||||
|
* grub_xfs_read_file() returns a block of zeros. So, if the magic
|
||||||
if (!entries)
|
* number field is all zeros then this block should be skipped.
|
||||||
|
*/
|
||||||
|
magic = *(grub_uint32_t *)(void *) dirblock;
|
||||||
|
if (!magic)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Leaf and tail information are only in the data block if the number
|
||||||
|
* of extents is 1.
|
||||||
|
*/
|
||||||
|
if (grub_xfs_get_inode_nextents (&dir->inode) == 1)
|
||||||
|
{
|
||||||
|
struct grub_xfs_dirblock_tail *tail = grub_xfs_dir_tail (dir->data, dirblock);
|
||||||
|
|
||||||
|
end = (char *) tail;
|
||||||
|
|
||||||
|
/* Subtract the space used by leaf nodes. */
|
||||||
|
end -= grub_be_to_cpu32 (tail->leaf_count) * sizeof (struct grub_xfs_dir_leaf_entry);
|
||||||
|
|
||||||
|
entries = grub_be_to_cpu32 (tail->leaf_count) - grub_be_to_cpu32 (tail->leaf_stale);
|
||||||
|
|
||||||
|
if (!entries)
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
/* Iterate over all entries within this block. */
|
/* Iterate over all entries within this block. */
|
||||||
while ((char *)direntry < (char *)tail)
|
while ((char *) direntry < (char *) end)
|
||||||
{
|
{
|
||||||
grub_uint8_t *freetag;
|
grub_uint8_t *freetag;
|
||||||
char *filename;
|
char *filename;
|
||||||
@@ -861,6 +1016,12 @@ grub_xfs_iterate_dir (grub_fshelp_node_t dir,
|
|||||||
}
|
}
|
||||||
|
|
||||||
filename = (char *)(direntry + 1);
|
filename = (char *)(direntry + 1);
|
||||||
|
if (filename + direntry->len + 1 > (char *) end)
|
||||||
|
{
|
||||||
|
grub_error (GRUB_ERR_BAD_FS, "invalid XFS directory entry");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
/* The byte after the filename is for the filetype, padding, or
|
/* The byte after the filename is for the filetype, padding, or
|
||||||
tag, which is not used by GRUB. So it can be overwritten. */
|
tag, which is not used by GRUB. So it can be overwritten. */
|
||||||
filename[direntry->len] = '\0';
|
filename[direntry->len] = '\0';
|
||||||
@@ -872,11 +1033,17 @@ grub_xfs_iterate_dir (grub_fshelp_node_t dir,
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Check if last direntry in this block is
|
/*
|
||||||
reached. */
|
* The expected number of directory entries is only tracked for the
|
||||||
entries--;
|
* single extent case.
|
||||||
if (!entries)
|
*/
|
||||||
break;
|
if (grub_xfs_get_inode_nextents (&dir->inode) == 1)
|
||||||
|
{
|
||||||
|
/* Check if last direntry in this block is reached. */
|
||||||
|
entries--;
|
||||||
|
if (!entries)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
/* Select the next directory entry. */
|
/* Select the next directory entry. */
|
||||||
direntry = grub_xfs_next_de(dir->data, direntry);
|
direntry = grub_xfs_next_de(dir->data, direntry);
|
||||||
@@ -899,11 +1066,14 @@ static struct grub_xfs_data *
|
|||||||
grub_xfs_mount (grub_disk_t disk)
|
grub_xfs_mount (grub_disk_t disk)
|
||||||
{
|
{
|
||||||
struct grub_xfs_data *data = 0;
|
struct grub_xfs_data *data = 0;
|
||||||
|
grub_size_t sz;
|
||||||
|
|
||||||
data = grub_zalloc (sizeof (struct grub_xfs_data));
|
data = grub_zalloc (sizeof (struct grub_xfs_data));
|
||||||
if (!data)
|
if (!data)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
data->data_size = sizeof (struct grub_xfs_data);
|
||||||
|
|
||||||
grub_dprintf("xfs", "Reading sb\n");
|
grub_dprintf("xfs", "Reading sb\n");
|
||||||
/* Read the superblock. */
|
/* Read the superblock. */
|
||||||
if (grub_disk_read (disk, 0, 0,
|
if (grub_disk_read (disk, 0, 0,
|
||||||
@@ -913,14 +1083,19 @@ grub_xfs_mount (grub_disk_t disk)
|
|||||||
if (!grub_xfs_sb_valid(data))
|
if (!grub_xfs_sb_valid(data))
|
||||||
goto fail;
|
goto fail;
|
||||||
|
|
||||||
data = grub_realloc (data,
|
if (grub_xfs_sb_needs_repair (data))
|
||||||
sizeof (struct grub_xfs_data)
|
grub_dprintf ("xfs", "XFS filesystem needs repair, boot may fail\n");
|
||||||
- sizeof (struct grub_xfs_inode)
|
|
||||||
+ grub_xfs_inode_size(data) + 1);
|
if (grub_add (grub_xfs_inode_size (data),
|
||||||
|
sizeof (struct grub_xfs_data) - sizeof (struct grub_xfs_inode) + 1, &sz))
|
||||||
|
goto fail;
|
||||||
|
|
||||||
|
data = grub_realloc (data, sz);
|
||||||
|
|
||||||
if (! data)
|
if (! data)
|
||||||
goto fail;
|
goto fail;
|
||||||
|
|
||||||
|
data->data_size = sz;
|
||||||
data->diropen.data = data;
|
data->diropen.data = data;
|
||||||
data->diropen.ino = grub_be_to_cpu64(data->sblock.rootino);
|
data->diropen.ino = grub_be_to_cpu64(data->sblock.rootino);
|
||||||
data->diropen.inode_read = 1;
|
data->diropen.inode_read = 1;
|
||||||
@@ -931,7 +1106,7 @@ grub_xfs_mount (grub_disk_t disk)
|
|||||||
|
|
||||||
data->disk = disk;
|
data->disk = disk;
|
||||||
data->pos = 0;
|
data->pos = 0;
|
||||||
grub_dprintf("xfs", "Reading root ino %"PRIuGRUB_UINT64_T"\n",
|
grub_dprintf("xfs", "Reading root ino %" PRIuGRUB_UINT64_T "\n",
|
||||||
grub_cpu_to_be64(data->sblock.rootino));
|
grub_cpu_to_be64(data->sblock.rootino));
|
||||||
|
|
||||||
grub_xfs_read_inode (data, data->diropen.ino, &data->diropen.inode);
|
grub_xfs_read_inode (data, data->diropen.ino, &data->diropen.inode);
|
||||||
@@ -939,7 +1114,7 @@ grub_xfs_mount (grub_disk_t disk)
|
|||||||
return data;
|
return data;
|
||||||
fail:
|
fail:
|
||||||
|
|
||||||
if (grub_errno == GRUB_ERR_OUT_OF_RANGE)
|
if (grub_errno == GRUB_ERR_OUT_OF_RANGE || grub_errno == GRUB_ERR_NONE)
|
||||||
grub_error (GRUB_ERR_BAD_FS, "not an XFS filesystem");
|
grub_error (GRUB_ERR_BAD_FS, "not an XFS filesystem");
|
||||||
|
|
||||||
grub_free (data);
|
grub_free (data);
|
||||||
@@ -947,7 +1122,6 @@ grub_xfs_mount (grub_disk_t disk)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* Context for grub_xfs_dir. */
|
/* Context for grub_xfs_dir. */
|
||||||
struct grub_xfs_dir_ctx
|
struct grub_xfs_dir_ctx
|
||||||
{
|
{
|
||||||
@@ -955,6 +1129,27 @@ struct grub_xfs_dir_ctx
|
|||||||
void *hook_data;
|
void *hook_data;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/* Bigtime inodes helpers. */
|
||||||
|
#define XFS_BIGTIME_EPOCH_OFFSET (-(grub_int64_t) GRUB_INT32_MIN)
|
||||||
|
|
||||||
|
static int grub_xfs_inode_has_bigtime (const struct grub_xfs_inode *inode)
|
||||||
|
{
|
||||||
|
return inode->version >= 3 &&
|
||||||
|
(inode->flags2 & grub_cpu_to_be64_compile_time (XFS_DIFLAG2_BIGTIME));
|
||||||
|
}
|
||||||
|
|
||||||
|
static grub_int64_t
|
||||||
|
grub_xfs_get_inode_time (struct grub_xfs_inode *inode)
|
||||||
|
{
|
||||||
|
struct grub_xfs_time_legacy *lts;
|
||||||
|
|
||||||
|
if (grub_xfs_inode_has_bigtime (inode))
|
||||||
|
return grub_divmod64 (grub_be_to_cpu64 (inode->mtime), NSEC_PER_SEC, NULL) - XFS_BIGTIME_EPOCH_OFFSET;
|
||||||
|
|
||||||
|
lts = (struct grub_xfs_time_legacy *) &inode->mtime;
|
||||||
|
return grub_be_to_cpu32 (lts->sec);
|
||||||
|
}
|
||||||
|
|
||||||
/* Helper for grub_xfs_dir. */
|
/* Helper for grub_xfs_dir. */
|
||||||
static int
|
static int
|
||||||
grub_xfs_dir_iter (const char *filename, enum grub_fshelp_filetype filetype,
|
grub_xfs_dir_iter (const char *filename, enum grub_fshelp_filetype filetype,
|
||||||
@@ -967,7 +1162,7 @@ grub_xfs_dir_iter (const char *filename, enum grub_fshelp_filetype filetype,
|
|||||||
if (node->inode_read)
|
if (node->inode_read)
|
||||||
{
|
{
|
||||||
info.mtimeset = 1;
|
info.mtimeset = 1;
|
||||||
info.mtime = grub_be_to_cpu32 (node->inode.mtime.sec);
|
info.mtime = grub_xfs_get_inode_time (&node->inode);
|
||||||
}
|
}
|
||||||
info.dir = ((filetype & GRUB_FSHELP_TYPE_MASK) == GRUB_FSHELP_DIR);
|
info.dir = ((filetype & GRUB_FSHELP_TYPE_MASK) == GRUB_FSHELP_DIR);
|
||||||
grub_free (node);
|
grub_free (node);
|
||||||
@@ -1132,8 +1327,6 @@ grub_xfs_uuid (grub_device_t device, char **uuid)
|
|||||||
return grub_errno;
|
return grub_errno;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
static struct grub_fs grub_xfs_fs =
|
static struct grub_fs grub_xfs_fs =
|
||||||
{
|
{
|
||||||
.name = "xfs",
|
.name = "xfs",
|
||||||
@@ -1152,6 +1345,7 @@ static struct grub_fs grub_xfs_fs =
|
|||||||
|
|
||||||
GRUB_MOD_INIT(xfs)
|
GRUB_MOD_INIT(xfs)
|
||||||
{
|
{
|
||||||
|
//grub_xfs_fs.mod = mod;
|
||||||
grub_fs_register (&grub_xfs_fs);
|
grub_fs_register (&grub_xfs_fs);
|
||||||
my_mod = mod;
|
my_mod = mod;
|
||||||
}
|
}
|
||||||
|
|||||||
195
GRUB2/MOD_SRC/grub-2.04/grub-core/kern/corecmd.c
Normal file
195
GRUB2/MOD_SRC/grub-2.04/grub-core/kern/corecmd.c
Normal file
@@ -0,0 +1,195 @@
|
|||||||
|
/* corecmd.c - critical commands which are registered in kernel */
|
||||||
|
/*
|
||||||
|
* GRUB -- GRand Unified Bootloader
|
||||||
|
* Copyright (C) 2009 Free Software Foundation, Inc.
|
||||||
|
*
|
||||||
|
* GRUB is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* GRUB is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with GRUB. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <grub/mm.h>
|
||||||
|
#include <grub/dl.h>
|
||||||
|
#include <grub/err.h>
|
||||||
|
#include <grub/env.h>
|
||||||
|
#include <grub/misc.h>
|
||||||
|
#include <grub/term.h>
|
||||||
|
#include <grub/file.h>
|
||||||
|
#include <grub/device.h>
|
||||||
|
#include <grub/command.h>
|
||||||
|
#include <grub/i18n.h>
|
||||||
|
|
||||||
|
/* set ENVVAR=VALUE */
|
||||||
|
static grub_err_t
|
||||||
|
grub_core_cmd_set (struct grub_command *cmd __attribute__ ((unused)),
|
||||||
|
int argc, char *argv[])
|
||||||
|
{
|
||||||
|
char *var;
|
||||||
|
char *val;
|
||||||
|
|
||||||
|
if (argc < 1)
|
||||||
|
{
|
||||||
|
struct grub_env_var *env;
|
||||||
|
FOR_SORTED_ENV (env)
|
||||||
|
grub_printf ("%s=%s\n", env->name, grub_env_get (env->name));
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
var = argv[0];
|
||||||
|
val = grub_strchr (var, '=');
|
||||||
|
if (! val)
|
||||||
|
return grub_error (GRUB_ERR_BAD_ARGUMENT, "not an assignment");
|
||||||
|
|
||||||
|
val[0] = 0;
|
||||||
|
grub_env_set (var, val + 1);
|
||||||
|
val[0] = '=';
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static grub_err_t
|
||||||
|
grub_core_cmd_unset (struct grub_command *cmd __attribute__ ((unused)),
|
||||||
|
int argc, char *argv[])
|
||||||
|
{
|
||||||
|
if (argc < 1)
|
||||||
|
return grub_error (GRUB_ERR_BAD_ARGUMENT,
|
||||||
|
N_("one argument expected"));
|
||||||
|
|
||||||
|
grub_env_unset (argv[0]);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* insmod MODULE */
|
||||||
|
static grub_err_t
|
||||||
|
grub_core_cmd_insmod (struct grub_command *cmd __attribute__ ((unused)),
|
||||||
|
int argc, char *argv[])
|
||||||
|
{
|
||||||
|
grub_dl_t mod;
|
||||||
|
|
||||||
|
if (argc == 0)
|
||||||
|
return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("one argument expected"));
|
||||||
|
|
||||||
|
/* For simple, just disable insmod when SecureBoot is enabled. */
|
||||||
|
if (g_sys_sb && g_sb_policy == VTOY_SB_POLICY_CHECK)
|
||||||
|
{
|
||||||
|
return grub_error (GRUB_ERR_BAD_SIGNATURE, "Cannot insmod when SecureBoot is enabled and Policy is check.");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (argv[0][0] == '/' || argv[0][0] == '(' || argv[0][0] == '+')
|
||||||
|
mod = grub_dl_load_file (argv[0]);
|
||||||
|
else
|
||||||
|
mod = grub_dl_load (argv[0]);
|
||||||
|
|
||||||
|
if (mod)
|
||||||
|
grub_dl_ref (mod);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
grub_mini_print_devices (const char *name, void *data __attribute__ ((unused)))
|
||||||
|
{
|
||||||
|
grub_printf ("(%s) ", name);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
grub_mini_print_files (const char *filename,
|
||||||
|
const struct grub_dirhook_info *info,
|
||||||
|
void *data __attribute__ ((unused)))
|
||||||
|
{
|
||||||
|
grub_printf ("%s%s ", filename, info->dir ? "/" : "");
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ls [ARG] */
|
||||||
|
static grub_err_t
|
||||||
|
grub_core_cmd_ls (struct grub_command *cmd __attribute__ ((unused)),
|
||||||
|
int argc, char *argv[])
|
||||||
|
{
|
||||||
|
if (argc < 1)
|
||||||
|
{
|
||||||
|
grub_device_iterate (grub_mini_print_devices, NULL);
|
||||||
|
grub_xputs ("\n");
|
||||||
|
grub_refresh ();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
char *device_name;
|
||||||
|
grub_device_t dev = 0;
|
||||||
|
grub_fs_t fs;
|
||||||
|
char *path;
|
||||||
|
|
||||||
|
device_name = grub_file_get_device_name (argv[0]);
|
||||||
|
if (grub_errno)
|
||||||
|
goto fail;
|
||||||
|
dev = grub_device_open (device_name);
|
||||||
|
if (! dev)
|
||||||
|
goto fail;
|
||||||
|
|
||||||
|
fs = grub_fs_probe (dev);
|
||||||
|
path = grub_strchr (argv[0], ')');
|
||||||
|
if (! path)
|
||||||
|
path = argv[0];
|
||||||
|
else
|
||||||
|
path++;
|
||||||
|
|
||||||
|
if (! *path && ! device_name)
|
||||||
|
{
|
||||||
|
grub_error (GRUB_ERR_BAD_ARGUMENT, "invalid argument");
|
||||||
|
goto fail;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (! *path)
|
||||||
|
{
|
||||||
|
if (grub_errno == GRUB_ERR_UNKNOWN_FS)
|
||||||
|
grub_errno = GRUB_ERR_NONE;
|
||||||
|
|
||||||
|
grub_printf ("(%s): Filesystem is %s.\n",
|
||||||
|
device_name, fs ? fs->name : "unknown");
|
||||||
|
}
|
||||||
|
else if (fs)
|
||||||
|
{
|
||||||
|
(fs->fs_dir) (dev, path, grub_mini_print_files, NULL);
|
||||||
|
grub_xputs ("\n");
|
||||||
|
grub_refresh ();
|
||||||
|
}
|
||||||
|
|
||||||
|
fail:
|
||||||
|
if (dev)
|
||||||
|
grub_device_close (dev);
|
||||||
|
|
||||||
|
grub_free (device_name);
|
||||||
|
}
|
||||||
|
|
||||||
|
return grub_errno;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
grub_register_core_commands (void)
|
||||||
|
{
|
||||||
|
grub_command_t cmd;
|
||||||
|
cmd = grub_register_command ("set", grub_core_cmd_set,
|
||||||
|
N_("[ENVVAR=VALUE]"),
|
||||||
|
N_("Set an environment variable."));
|
||||||
|
if (cmd)
|
||||||
|
cmd->flags |= GRUB_COMMAND_FLAG_EXTRACTOR;
|
||||||
|
grub_register_command ("unset", grub_core_cmd_unset,
|
||||||
|
N_("ENVVAR"),
|
||||||
|
N_("Remove an environment variable."));
|
||||||
|
grub_register_command ("ls", grub_core_cmd_ls,
|
||||||
|
N_("[ARG]"), N_("List devices or files."));
|
||||||
|
grub_register_command ("insmod", grub_core_cmd_insmod,
|
||||||
|
N_("MODULE"), N_("Insert a module."));
|
||||||
|
}
|
||||||
@@ -466,6 +466,37 @@ grub_err_t grub_disk_blocklist_read(void *chunklist, grub_uint64_t sector,
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
grub_err_t grub_disk_blocklist_read2(grub_disk_t disk, grub_uint64_t sector,
|
||||||
|
grub_uint64_t size, char *buf)
|
||||||
|
{
|
||||||
|
ventoy_img_chunk_list *chunk_list = (ventoy_img_chunk_list *)(disk->read_hook_data);
|
||||||
|
|
||||||
|
if (buf < chunk_list->buf || buf >= chunk_list->buf + VTOY_CHUNK_BUF_SIZE)
|
||||||
|
{
|
||||||
|
return 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((chunk_list->buf + chunk_list->last_off) != buf)
|
||||||
|
{
|
||||||
|
chunk_list->err_code = VTOY_CHUNK_ERR_NOT_FLAT;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (chunk_list->last_off + size > VTOY_CHUNK_BUF_SIZE)
|
||||||
|
{
|
||||||
|
chunk_list->err_code = VTOY_CHUNK_ERR_OVER_FLOW;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
chunk_list->last_off += (grub_uint32_t)size;
|
||||||
|
if (chunk_list->last_off == VTOY_CHUNK_BUF_SIZE)
|
||||||
|
{
|
||||||
|
chunk_list->last_off = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return grub_disk_blocklist_read(chunk_list, sector, size, disk->log_sector_size);
|
||||||
|
}
|
||||||
|
|
||||||
/* Read data from the disk. */
|
/* Read data from the disk. */
|
||||||
grub_err_t
|
grub_err_t
|
||||||
grub_disk_read (grub_disk_t disk, grub_disk_addr_t sector,
|
grub_disk_read (grub_disk_t disk, grub_disk_addr_t sector,
|
||||||
@@ -475,6 +506,14 @@ grub_disk_read (grub_disk_t disk, grub_disk_addr_t sector,
|
|||||||
{
|
{
|
||||||
return grub_disk_blocklist_read((ventoy_img_chunk_list *)disk->read_hook_data, sector, size, disk->log_sector_size);
|
return grub_disk_blocklist_read((ventoy_img_chunk_list *)disk->read_hook_data, sector, size, disk->log_sector_size);
|
||||||
}
|
}
|
||||||
|
else if (disk->read_hook == (grub_disk_read_hook_t)(void *)grub_disk_blocklist_read2)
|
||||||
|
{
|
||||||
|
grub_err_t rv = grub_disk_blocklist_read2(disk, sector, size, (char *)buf);
|
||||||
|
if (rv != 2)
|
||||||
|
{
|
||||||
|
return rv;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* First of all, check if the region is within the disk. */
|
/* First of all, check if the region is within the disk. */
|
||||||
if (grub_disk_adjust_range (disk, §or, &offset, size) != GRUB_ERR_NONE)
|
if (grub_disk_adjust_range (disk, §or, &offset, size) != GRUB_ERR_NONE)
|
||||||
|
|||||||
@@ -22,6 +22,9 @@
|
|||||||
#include <grub/misc.h>
|
#include <grub/misc.h>
|
||||||
#include <grub/mm.h>
|
#include <grub/mm.h>
|
||||||
|
|
||||||
|
grub_uint8_t g_sys_sb = 0;
|
||||||
|
grub_uint8_t g_sb_policy = VTOY_SB_POLICY_BYPASS;
|
||||||
|
|
||||||
/* The initial context. */
|
/* The initial context. */
|
||||||
static struct grub_env_context initial_context;
|
static struct grub_env_context initial_context;
|
||||||
|
|
||||||
|
|||||||
@@ -35,6 +35,8 @@
|
|||||||
#include <grub/i18n.h>
|
#include <grub/i18n.h>
|
||||||
#include <grub/lib/cmdline.h>
|
#include <grub/lib/cmdline.h>
|
||||||
#include <grub/linux.h>
|
#include <grub/linux.h>
|
||||||
|
#include <grub/time.h>
|
||||||
|
#include <grub/env.h>
|
||||||
#include <grub/machine/kernel.h>
|
#include <grub/machine/kernel.h>
|
||||||
|
|
||||||
GRUB_MOD_LICENSE ("GPLv3+");
|
GRUB_MOD_LICENSE ("GPLv3+");
|
||||||
@@ -750,6 +752,16 @@ grub_linux_boot (void)
|
|||||||
grub_size_t mmap_size;
|
grub_size_t mmap_size;
|
||||||
grub_size_t cl_offset;
|
grub_size_t cl_offset;
|
||||||
|
|
||||||
|
/* To be simple, just deny to boot linux kernel when SecureBoot is enabled and Policy is check */
|
||||||
|
if (g_sys_sb && g_sb_policy == VTOY_SB_POLICY_CHECK)
|
||||||
|
{
|
||||||
|
grub_printf("\n\n ######### Can not do linux boot in SecureBoot Policy Check #######\n\n");
|
||||||
|
grub_refresh();
|
||||||
|
grub_sleep(5);
|
||||||
|
grub_errno = GRUB_ERR_BAD_SIGNATURE;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
ventoy_preboot();
|
ventoy_preboot();
|
||||||
|
|
||||||
#ifdef GRUB_MACHINE_IEEE1275
|
#ifdef GRUB_MACHINE_IEEE1275
|
||||||
|
|||||||
@@ -128,11 +128,22 @@ insert_dir (const char *name, struct dir **root,
|
|||||||
n->name = grub_strndup (cb, ce - cb);
|
n->name = grub_strndup (cb, ce - cb);
|
||||||
if (ptr)
|
if (ptr)
|
||||||
{
|
{
|
||||||
|
/*
|
||||||
|
* Create the substring with the trailing NUL byte
|
||||||
|
* to be included in the cpio header.
|
||||||
|
*/
|
||||||
|
char *tmp_name = grub_strndup (name, ce - name);
|
||||||
|
if (!tmp_name) {
|
||||||
|
grub_free (n->name);
|
||||||
|
grub_free (n);
|
||||||
|
return grub_errno;
|
||||||
|
}
|
||||||
grub_dprintf ("linux", "Creating directory %s, %s\n", name, ce);
|
grub_dprintf ("linux", "Creating directory %s, %s\n", name, ce);
|
||||||
ptr = make_header (ptr, name, ce - name,
|
ptr = make_header (ptr, tmp_name, ce - name + 1,
|
||||||
040777, 0);
|
040777, 0);
|
||||||
|
grub_free (tmp_name);
|
||||||
}
|
}
|
||||||
size += ALIGN_UP ((ce - (char *) name)
|
size += ALIGN_UP ((ce - (char *) name + 1)
|
||||||
+ sizeof (struct newc_head), 4);
|
+ sizeof (struct newc_head), 4);
|
||||||
*head = n;
|
*head = n;
|
||||||
cur = n;
|
cur = n;
|
||||||
@@ -183,7 +194,7 @@ grub_initrd_init (int argc, char *argv[],
|
|||||||
}
|
}
|
||||||
initrd_ctx->size
|
initrd_ctx->size
|
||||||
+= ALIGN_UP (sizeof (struct newc_head)
|
+= ALIGN_UP (sizeof (struct newc_head)
|
||||||
+ grub_strlen (initrd_ctx->components[i].newc_name),
|
+ grub_strlen (initrd_ctx->components[i].newc_name) + 1,
|
||||||
4);
|
4);
|
||||||
initrd_ctx->size += insert_dir (initrd_ctx->components[i].newc_name,
|
initrd_ctx->size += insert_dir (initrd_ctx->components[i].newc_name,
|
||||||
&root, 0);
|
&root, 0);
|
||||||
@@ -194,7 +205,7 @@ grub_initrd_init (int argc, char *argv[],
|
|||||||
else if (newc)
|
else if (newc)
|
||||||
{
|
{
|
||||||
initrd_ctx->size += ALIGN_UP (sizeof (struct newc_head)
|
initrd_ctx->size += ALIGN_UP (sizeof (struct newc_head)
|
||||||
+ sizeof ("TRAILER!!!") - 1, 4);
|
+ sizeof ("TRAILER!!!"), 4);
|
||||||
free_dir (root);
|
free_dir (root);
|
||||||
root = 0;
|
root = 0;
|
||||||
newc = 0;
|
newc = 0;
|
||||||
@@ -217,7 +228,7 @@ grub_initrd_init (int argc, char *argv[],
|
|||||||
{
|
{
|
||||||
initrd_ctx->size = ALIGN_UP (initrd_ctx->size, 4);
|
initrd_ctx->size = ALIGN_UP (initrd_ctx->size, 4);
|
||||||
initrd_ctx->size += ALIGN_UP (sizeof (struct newc_head)
|
initrd_ctx->size += ALIGN_UP (sizeof (struct newc_head)
|
||||||
+ sizeof ("TRAILER!!!") - 1, 4);
|
+ sizeof ("TRAILER!!!"), 4);
|
||||||
free_dir (root);
|
free_dir (root);
|
||||||
root = 0;
|
root = 0;
|
||||||
}
|
}
|
||||||
@@ -269,14 +280,14 @@ grub_initrd_load (struct grub_linux_initrd_context *initrd_ctx,
|
|||||||
ptr += insert_dir (initrd_ctx->components[i].newc_name,
|
ptr += insert_dir (initrd_ctx->components[i].newc_name,
|
||||||
&root, ptr);
|
&root, ptr);
|
||||||
ptr = make_header (ptr, initrd_ctx->components[i].newc_name,
|
ptr = make_header (ptr, initrd_ctx->components[i].newc_name,
|
||||||
grub_strlen (initrd_ctx->components[i].newc_name),
|
grub_strlen (initrd_ctx->components[i].newc_name) + 1,
|
||||||
0100777,
|
0100777,
|
||||||
initrd_ctx->components[i].size);
|
initrd_ctx->components[i].size);
|
||||||
newc = 1;
|
newc = 1;
|
||||||
}
|
}
|
||||||
else if (newc)
|
else if (newc)
|
||||||
{
|
{
|
||||||
ptr = make_header (ptr, "TRAILER!!!", sizeof ("TRAILER!!!") - 1,
|
ptr = make_header (ptr, "TRAILER!!!", sizeof ("TRAILER!!!"),
|
||||||
0, 0);
|
0, 0);
|
||||||
free_dir (root);
|
free_dir (root);
|
||||||
root = 0;
|
root = 0;
|
||||||
@@ -308,7 +319,7 @@ grub_initrd_load (struct grub_linux_initrd_context *initrd_ctx,
|
|||||||
{
|
{
|
||||||
grub_memset (ptr, 0, ALIGN_UP_OVERHEAD (cursize, 4));
|
grub_memset (ptr, 0, ALIGN_UP_OVERHEAD (cursize, 4));
|
||||||
ptr += ALIGN_UP_OVERHEAD (cursize, 4);
|
ptr += ALIGN_UP_OVERHEAD (cursize, 4);
|
||||||
ptr = make_header (ptr, "TRAILER!!!", sizeof ("TRAILER!!!") - 1, 0, 0);
|
ptr = make_header (ptr, "TRAILER!!!", sizeof ("TRAILER!!!"), 0, 0);
|
||||||
}
|
}
|
||||||
free_dir (root);
|
free_dir (root);
|
||||||
root = 0;
|
root = 0;
|
||||||
|
|||||||
@@ -1134,6 +1134,7 @@ show_menu (grub_menu_t menu, int nested, int autobooted)
|
|||||||
while (1)
|
while (1)
|
||||||
{
|
{
|
||||||
int ndown;
|
int ndown;
|
||||||
|
char *pos = NULL;
|
||||||
int boot_entry;
|
int boot_entry;
|
||||||
grub_menu_entry_t e;
|
grub_menu_entry_t e;
|
||||||
int auto_boot;
|
int auto_boot;
|
||||||
@@ -1176,14 +1177,27 @@ show_menu (grub_menu_t menu, int nested, int autobooted)
|
|||||||
|
|
||||||
if (2 == e->argc && e->args && e->args[1] && grub_strncmp(e->args[1], "VTOY_RUN_RET", 12) == 0)
|
if (2 == e->argc && e->args && e->args[1] && grub_strncmp(e->args[1], "VTOY_RUN_RET", 12) == 0)
|
||||||
break;
|
break;
|
||||||
else if (2 == e->argc && e->args && e->args[1] && grub_strncmp(e->args[1], "VTOY_RUN_SET", 12) == 0) {
|
else if (2 == e->argc && e->args && e->args[1] && grub_strncmp(e->args[1], "VTOY_RUN_SET_", 13) == 0) {
|
||||||
ndown = (int)grub_strtol(e->args[1] + 12, NULL, 10);
|
pos = NULL;
|
||||||
|
ndown = (int)grub_strtol(e->args[1] + 13, &pos, 10);
|
||||||
while (ndown > 0)
|
while (ndown > 0)
|
||||||
{
|
{
|
||||||
ventoy_menu_push_key(GRUB_TERM_KEY_DOWN);
|
ventoy_menu_push_key(GRUB_TERM_KEY_DOWN);
|
||||||
ndown--;
|
ndown--;
|
||||||
}
|
}
|
||||||
|
|
||||||
ventoy_menu_push_key('\n');
|
ventoy_menu_push_key('\n');
|
||||||
|
|
||||||
|
if (pos && *pos == '_')
|
||||||
|
{
|
||||||
|
ndown = (int)grub_strtol(pos + 1, NULL, 10);
|
||||||
|
while (ndown > 0)
|
||||||
|
{
|
||||||
|
ventoy_menu_push_key(GRUB_TERM_KEY_DOWN);
|
||||||
|
ndown--;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -49,6 +49,10 @@ int g_ventoy_debug = 0;
|
|||||||
static int g_efi_os = 0xFF;
|
static int g_efi_os = 0xFF;
|
||||||
grub_uint32_t g_ventoy_plat_data;
|
grub_uint32_t g_ventoy_plat_data;
|
||||||
|
|
||||||
|
#ifdef GRUB_MACHINE_EFI
|
||||||
|
static VTOY_SHIM *g_vtoy_shim = NULL;
|
||||||
|
#endif
|
||||||
|
|
||||||
void ventoy_debug(const char *fmt, ...)
|
void ventoy_debug(const char *fmt, ...)
|
||||||
{
|
{
|
||||||
va_list args;
|
va_list args;
|
||||||
@@ -298,9 +302,134 @@ void ventoy_memfile_env_set(const char *prefix, const void *buf, unsigned long l
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef GRUB_MACHINE_EFI
|
||||||
|
static void ventoy_get_uefi_version(char *str, grub_size_t len)
|
||||||
|
{
|
||||||
|
grub_efi_uint8_t uefi_minor_1, uefi_minor_2;
|
||||||
|
|
||||||
|
uefi_minor_1 = (grub_efi_system_table->hdr.revision & 0xffff) / 10;
|
||||||
|
uefi_minor_2 = (grub_efi_system_table->hdr.revision & 0xffff) % 10;
|
||||||
|
grub_snprintf(str, len, "%d.%d", (grub_efi_system_table->hdr.revision >> 16), uefi_minor_1);
|
||||||
|
if (uefi_minor_2)
|
||||||
|
grub_snprintf(str, len, "%s.%d", str, uefi_minor_2);
|
||||||
|
}
|
||||||
|
|
||||||
|
int ventoy_set_sb_policy(void)
|
||||||
|
{
|
||||||
|
const char *env = NULL;
|
||||||
|
static int set_once = 0;
|
||||||
|
|
||||||
|
/* no need when SecureBoot is disabled */
|
||||||
|
if (g_sys_sb == 0)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* can only set once */
|
||||||
|
if (set_once > 0)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
set_once = 1;
|
||||||
|
|
||||||
|
/* VTOY_SECURE_BOOT_POLICY only take affect once during init */
|
||||||
|
env = grub_env_get("VTOY_SECURE_BOOT_POLICY");
|
||||||
|
if (env)
|
||||||
|
{
|
||||||
|
g_sb_policy = (grub_uint8_t)(env[0] - '0');
|
||||||
|
}
|
||||||
|
|
||||||
|
if (g_sb_policy == VTOY_SB_POLICY_BYPASS)
|
||||||
|
{
|
||||||
|
if (g_vtoy_shim && g_vtoy_shim->ByPassSB)
|
||||||
|
{
|
||||||
|
g_vtoy_shim->ByPassSB();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (g_sb_policy == VTOY_SB_POLICY_CHECK)
|
||||||
|
{
|
||||||
|
if (g_vtoy_shim && g_vtoy_shim->CheckSB)
|
||||||
|
{
|
||||||
|
g_vtoy_shim->CheckSB();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void ventoy_get_uefi_sb(void)
|
||||||
|
{
|
||||||
|
grub_uint8_t secure_boot = 0;
|
||||||
|
grub_uint8_t setup_mode = 0;
|
||||||
|
grub_uint8_t *var = NULL;
|
||||||
|
grub_size_t size = 0;
|
||||||
|
grub_efi_guid_t global = GRUB_EFI_GLOBAL_VARIABLE_GUID;
|
||||||
|
|
||||||
|
var = grub_efi_get_variable("SecureBoot", &global, &size);
|
||||||
|
if (var && size == 1 && *var == 1)
|
||||||
|
{
|
||||||
|
secure_boot = 1;
|
||||||
|
}
|
||||||
|
grub_check_free(var);
|
||||||
|
|
||||||
|
size = 0;
|
||||||
|
var = grub_efi_get_variable("SetupMode", &global, &size);
|
||||||
|
if (var && size == 1 && *var == 1)
|
||||||
|
{
|
||||||
|
setup_mode = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (secure_boot == 1 && setup_mode == 0)
|
||||||
|
{
|
||||||
|
g_sys_sb = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
grub_check_free(var);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int ventoy_secure_boot_init(void)
|
||||||
|
{
|
||||||
|
grub_efi_guid_t ProtGuid = VTOY_SHIM_POLICY_GUID;
|
||||||
|
|
||||||
|
ventoy_get_uefi_sb();
|
||||||
|
|
||||||
|
if (g_sys_sb == 0)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* When SecureBoot enabled, Ventoy grub must be launched by Ventoy Shim.
|
||||||
|
* Currently only x86_64 support this feature.
|
||||||
|
*/
|
||||||
|
if (g_ventoy_plat_data == VTOY_PLAT_X86_64_UEFI)
|
||||||
|
{
|
||||||
|
g_vtoy_shim = grub_efi_locate_protocol(&ProtGuid, NULL);
|
||||||
|
if (g_vtoy_shim == NULL || g_vtoy_shim->ByPassSB == NULL || g_vtoy_shim->CheckSB == NULL)
|
||||||
|
{
|
||||||
|
grub_cls();
|
||||||
|
grub_printf(VTOY_WARNING"\n");
|
||||||
|
grub_printf(VTOY_WARNING"\n");
|
||||||
|
grub_printf(VTOY_WARNING"\n\n\n");
|
||||||
|
|
||||||
|
grub_printf("Ventoy grub is not launched by Ventoy shim.\n\n");
|
||||||
|
grub_refresh();
|
||||||
|
|
||||||
|
ventoy_prompt_end();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
static int ventoy_arch_mode_init(void)
|
static int ventoy_arch_mode_init(void)
|
||||||
{
|
{
|
||||||
#ifdef GRUB_MACHINE_EFI
|
#ifdef GRUB_MACHINE_EFI
|
||||||
|
|
||||||
if (grub_strcmp(GRUB_TARGET_CPU, "i386") == 0)
|
if (grub_strcmp(GRUB_TARGET_CPU, "i386") == 0)
|
||||||
{
|
{
|
||||||
g_ventoy_plat_data = VTOY_PLAT_I386_UEFI;
|
g_ventoy_plat_data = VTOY_PLAT_I386_UEFI;
|
||||||
@@ -329,19 +458,6 @@ static int ventoy_arch_mode_init(void)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef GRUB_MACHINE_EFI
|
|
||||||
static void ventoy_get_uefi_version(char *str, grub_size_t len)
|
|
||||||
{
|
|
||||||
grub_efi_uint8_t uefi_minor_1, uefi_minor_2;
|
|
||||||
|
|
||||||
uefi_minor_1 = (grub_efi_system_table->hdr.revision & 0xffff) / 10;
|
|
||||||
uefi_minor_2 = (grub_efi_system_table->hdr.revision & 0xffff) % 10;
|
|
||||||
grub_snprintf(str, len, "%d.%d", (grub_efi_system_table->hdr.revision >> 16), uefi_minor_1);
|
|
||||||
if (uefi_minor_2)
|
|
||||||
grub_snprintf(str, len, "%s.%d", str, uefi_minor_2);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
static int ventoy_calc_totalmem(grub_uint64_t addr, grub_uint64_t size, grub_memory_type_t type, void *data)
|
static int ventoy_calc_totalmem(grub_uint64_t addr, grub_uint64_t size, grub_memory_type_t type, void *data)
|
||||||
{
|
{
|
||||||
grub_uint64_t *total_mem = (grub_uint64_t *)data;
|
grub_uint64_t *total_mem = (grub_uint64_t *)data;
|
||||||
@@ -431,11 +547,12 @@ int ventoy_global_var_init(void)
|
|||||||
|
|
||||||
static ctrl_var_cfg g_ctrl_vars[] =
|
static ctrl_var_cfg g_ctrl_vars[] =
|
||||||
{
|
{
|
||||||
{ "VTOY_WIN11_BYPASS_CHECK", 1 },
|
{ "VTOY_WIN11_BYPASS_CHECK", "1" },
|
||||||
{ "VTOY_WIN11_BYPASS_NRO", 1 },
|
{ "VTOY_WIN11_BYPASS_NRO", "1" },
|
||||||
{ "VTOY_LINUX_REMOUNT", 0 },
|
{ "VTOY_LINUX_REMOUNT", "0" },
|
||||||
{ "VTOY_SECONDARY_BOOT_MENU", 1 },
|
{ "VTOY_SECONDARY_BOOT_MENU", "1" },
|
||||||
{ NULL, 0 }
|
{ "VTOY_WIN_UEFI_RES_LOCK", "3" },
|
||||||
|
{ NULL, "" }
|
||||||
};
|
};
|
||||||
|
|
||||||
static const char * ventoy_ctrl_var_read_hook(struct grub_env_var *var, const char *val)
|
static const char * ventoy_ctrl_var_read_hook(struct grub_env_var *var, const char *val)
|
||||||
@@ -446,7 +563,7 @@ static const char * ventoy_ctrl_var_read_hook(struct grub_env_var *var, const ch
|
|||||||
{
|
{
|
||||||
if (grub_strcmp(g_ctrl_vars[i].name, var->name) == 0)
|
if (grub_strcmp(g_ctrl_vars[i].name, var->name) == 0)
|
||||||
{
|
{
|
||||||
return g_ctrl_vars[i].value ? "1" : "0";
|
return g_ctrl_vars[i].szval;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -461,14 +578,14 @@ static char * ventoy_ctrl_var_write_hook(struct grub_env_var *var, const char *v
|
|||||||
{
|
{
|
||||||
if (grub_strcmp(g_ctrl_vars[i].name, var->name) == 0)
|
if (grub_strcmp(g_ctrl_vars[i].name, var->name) == 0)
|
||||||
{
|
{
|
||||||
if (val && val[0] == '1' && val[1] == 0)
|
if (val && grub_isdigit(val[0]) && val[1] == 0)
|
||||||
{
|
{
|
||||||
g_ctrl_vars[i].value = 1;
|
g_ctrl_vars[i].szval[0] = val[0];
|
||||||
return grub_strdup("1");
|
return grub_strdup(val);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
g_ctrl_vars[i].value = 0;
|
g_ctrl_vars[i].szval[0] = '0';
|
||||||
return grub_strdup("0");
|
return grub_strdup("0");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -479,12 +596,13 @@ static char * ventoy_ctrl_var_write_hook(struct grub_env_var *var, const char *v
|
|||||||
|
|
||||||
int ventoy_ctrl_var_init(void)
|
int ventoy_ctrl_var_init(void)
|
||||||
{
|
{
|
||||||
int i;
|
ctrl_var_cfg *cfg = g_ctrl_vars;
|
||||||
|
|
||||||
for (i = 0; g_ctrl_vars[i].name; i++)
|
while (cfg->name)
|
||||||
{
|
{
|
||||||
ventoy_env_export(g_ctrl_vars[i].name, g_ctrl_vars[i].value ? "1" : "0");
|
ventoy_env_export(cfg->name, cfg->szval);
|
||||||
grub_register_variable_hook(g_ctrl_vars[i].name, ventoy_ctrl_var_read_hook, ventoy_ctrl_var_write_hook);
|
grub_register_variable_hook(cfg->name, ventoy_ctrl_var_read_hook, ventoy_ctrl_var_write_hook);
|
||||||
|
cfg++;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
@@ -495,6 +613,11 @@ GRUB_MOD_INIT(ventoy)
|
|||||||
ventoy_hwinfo_init();
|
ventoy_hwinfo_init();
|
||||||
ventoy_env_init();
|
ventoy_env_init();
|
||||||
ventoy_arch_mode_init();
|
ventoy_arch_mode_init();
|
||||||
|
|
||||||
|
#ifdef GRUB_MACHINE_EFI
|
||||||
|
ventoy_secure_boot_init();
|
||||||
|
#endif
|
||||||
|
|
||||||
ventoy_register_all_cmd();
|
ventoy_register_all_cmd();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -244,6 +244,15 @@ static int ventoy_browser_valid_dirname(const char *name, int len)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (g_filt_trash_dir)
|
||||||
|
{
|
||||||
|
if (0 == grub_strncmp(name, ".trash-", 7) ||
|
||||||
|
0 == grub_strcmp(name, ".Trashes"))
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (name[0] == '$')
|
if (name[0] == '$')
|
||||||
{
|
{
|
||||||
if (0 == grub_strncmp(name, "$RECYCLE.BIN", 12) ||
|
if (0 == grub_strncmp(name, "$RECYCLE.BIN", 12) ||
|
||||||
|
|||||||
@@ -65,6 +65,7 @@ int g_initrd_img_count = 0;
|
|||||||
int g_valid_initrd_count = 0;
|
int g_valid_initrd_count = 0;
|
||||||
int g_default_menu_mode = 0;
|
int g_default_menu_mode = 0;
|
||||||
int g_filt_dot_underscore_file = 0;
|
int g_filt_dot_underscore_file = 0;
|
||||||
|
int g_filt_trash_dir = 1;
|
||||||
int g_sort_case_sensitive = 0;
|
int g_sort_case_sensitive = 0;
|
||||||
int g_tree_view_menu_style = 0;
|
int g_tree_view_menu_style = 0;
|
||||||
static grub_file_t g_old_file;
|
static grub_file_t g_old_file;
|
||||||
@@ -201,6 +202,10 @@ int ventoy_get_fs_type(const char *fs)
|
|||||||
{
|
{
|
||||||
return ventoy_fs_fat;
|
return ventoy_fs_fat;
|
||||||
}
|
}
|
||||||
|
else if (grub_strncmp(fs, "btrfs", 5) == 0)
|
||||||
|
{
|
||||||
|
return ventoy_fs_btrfs;
|
||||||
|
}
|
||||||
|
|
||||||
return ventoy_fs_max;
|
return ventoy_fs_max;
|
||||||
}
|
}
|
||||||
@@ -891,6 +896,36 @@ static grub_err_t ventoy_cmd_strstr(grub_extcmd_context_t ctxt, int argc, char *
|
|||||||
return (grub_strstr(args[0], args[1])) ? 0 : 1;
|
return (grub_strstr(args[0], args[1])) ? 0 : 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static grub_err_t ventoy_cmd_istrstr(grub_extcmd_context_t ctxt, int argc, char **args)
|
||||||
|
{
|
||||||
|
grub_err_t ret = 1;
|
||||||
|
char *s1 = NULL;
|
||||||
|
char *s2 = NULL;
|
||||||
|
|
||||||
|
(void)ctxt;
|
||||||
|
|
||||||
|
if (argc != 2)
|
||||||
|
{
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
s1 = grub_strdup(args[0]);
|
||||||
|
s2 = grub_strdup(args[1]);
|
||||||
|
if (s1 == NULL || s2 == NULL)
|
||||||
|
{
|
||||||
|
goto end;
|
||||||
|
}
|
||||||
|
|
||||||
|
ventoy_str_toupper(s1);
|
||||||
|
ventoy_str_toupper(s2);
|
||||||
|
ret = (grub_strstr(s1, s2)) ? 0 : 1;
|
||||||
|
|
||||||
|
end:
|
||||||
|
grub_check_free(s1);
|
||||||
|
grub_check_free(s2);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
static grub_err_t ventoy_cmd_strbegin(grub_extcmd_context_t ctxt, int argc, char **args)
|
static grub_err_t ventoy_cmd_strbegin(grub_extcmd_context_t ctxt, int argc, char **args)
|
||||||
{
|
{
|
||||||
char *c0, *c1;
|
char *c0, *c1;
|
||||||
@@ -1568,19 +1603,25 @@ int ventoy_cmp_img(img_info *img1, img_info *img2)
|
|||||||
|
|
||||||
static int ventoy_cmp_subdir(img_iterator_node *node1, img_iterator_node *node2)
|
static int ventoy_cmp_subdir(img_iterator_node *node1, img_iterator_node *node2)
|
||||||
{
|
{
|
||||||
char *s1, *s2;
|
int i = 0;
|
||||||
int c1 = 0;
|
int c1 = 0;
|
||||||
int c2 = 0;
|
int c2 = 0;
|
||||||
|
int len = 0;
|
||||||
|
char *s1, *s2;
|
||||||
|
|
||||||
if (g_plugin_image_list == VENTOY_IMG_WHITE_LIST)
|
if (g_plugin_image_list == VENTOY_IMG_WHITE_LIST)
|
||||||
{
|
{
|
||||||
return (node1->plugin_list_index - node2->plugin_list_index);
|
return (node1->plugin_list_index - node2->plugin_list_index);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (s1 = node1->dir, s2 = node2->dir; *s1 && *s2; s1++, s2++)
|
s1 = node1->dir;
|
||||||
|
s2 = node2->dir;
|
||||||
|
len = grub_min(node1->dirlen, node2->dirlen);
|
||||||
|
|
||||||
|
for (i = 0; i < len - 1; i++)
|
||||||
{
|
{
|
||||||
c1 = *s1;
|
c1 = *s1++;
|
||||||
c2 = *s2;
|
c2 = *s2++;
|
||||||
|
|
||||||
if (0 == g_sort_case_sensitive)
|
if (0 == g_sort_case_sensitive)
|
||||||
{
|
{
|
||||||
@@ -1597,10 +1638,20 @@ static int ventoy_cmp_subdir(img_iterator_node *node1, img_iterator_node *node2)
|
|||||||
|
|
||||||
if (c1 != c2)
|
if (c1 != c2)
|
||||||
{
|
{
|
||||||
break;
|
return (c1 - c2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (len == node1->dirlen)
|
||||||
|
{
|
||||||
|
c1 = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (len == node2->dirlen)
|
||||||
|
{
|
||||||
|
c2 = 0;
|
||||||
|
}
|
||||||
|
|
||||||
return (c1 - c2);
|
return (c1 - c2);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1679,7 +1730,7 @@ static int ventoy_vlnk_probe_fs(ventoy_vlnk_part *cur)
|
|||||||
{
|
{
|
||||||
const char *fs[ventoy_fs_max + 1] =
|
const char *fs[ventoy_fs_max + 1] =
|
||||||
{
|
{
|
||||||
"exfat", "ntfs", "ext2", "xfs", "udf", "fat", NULL
|
"exfat", "ntfs", "ext2", "xfs", "udf", "fat", "btrfs", NULL
|
||||||
};
|
};
|
||||||
|
|
||||||
if (!cur->dev)
|
if (!cur->dev)
|
||||||
@@ -1900,9 +1951,14 @@ static int ventoy_collect_img_files(const char *filename, const struct grub_dirh
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (filename[0] == '$' && 0 == grub_strncmp(filename, "$RECYCLE.BIN", 12))
|
if (g_filt_trash_dir)
|
||||||
{
|
{
|
||||||
return 0;
|
if (0 == grub_strncmp(filename, ".trash-", 7) ||
|
||||||
|
0 == grub_strcmp(filename, ".Trashes") ||
|
||||||
|
0 == grub_strncmp(filename, "$RECYCLE.BIN", 12))
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (g_plugin_image_list == VENTOY_IMG_WHITE_LIST)
|
if (g_plugin_image_list == VENTOY_IMG_WHITE_LIST)
|
||||||
@@ -2832,6 +2888,12 @@ static grub_err_t ventoy_cmd_list_img(grub_extcmd_context_t ctxt, int argc, char
|
|||||||
g_filt_dot_underscore_file = 1;
|
g_filt_dot_underscore_file = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
strdata = ventoy_get_env("VTOY_FILT_TRASH_DIR");
|
||||||
|
if (strdata && strdata[0] == '0' && strdata[1] == 0)
|
||||||
|
{
|
||||||
|
g_filt_trash_dir = 0;
|
||||||
|
}
|
||||||
|
|
||||||
strdata = ventoy_get_env("VTOY_SORT_CASE_SENSITIVE");
|
strdata = ventoy_get_env("VTOY_SORT_CASE_SENSITIVE");
|
||||||
if (strdata && strdata[0] == '1' && strdata[1] == 0)
|
if (strdata && strdata[0] == '1' && strdata[1] == 0)
|
||||||
{
|
{
|
||||||
@@ -3213,6 +3275,25 @@ void ventoy_fill_os_param(grub_file_t file, ventoy_os_param *param)
|
|||||||
param->vtoy_reserved[6] = file->vlnk;
|
param->vtoy_reserved[6] = file->vlnk;
|
||||||
grub_memcpy(param->vtoy_reserved + 7, g_ventoy_part_info->MBR.BootCode + 0x1b8, 4);
|
grub_memcpy(param->vtoy_reserved + 7, g_ventoy_part_info->MBR.BootCode + 0x1b8, 4);
|
||||||
|
|
||||||
|
|
||||||
|
/* Windows UEFI force resolution lock */
|
||||||
|
if (g_ventoy_chain_type == 1) /* Windows */
|
||||||
|
{
|
||||||
|
val = ventoy_get_env("VTOY_WIN_UEFI_RES_LOCK");
|
||||||
|
if (val && val[1] == 0)
|
||||||
|
{
|
||||||
|
if (val[0] == '1')
|
||||||
|
{
|
||||||
|
param->vtoy_reserved[11] = 1;
|
||||||
|
}
|
||||||
|
else if (val[0] == '2')
|
||||||
|
{
|
||||||
|
param->vtoy_reserved[11] = 2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/* calculate checksum */
|
/* calculate checksum */
|
||||||
for (i = 0; i < sizeof(ventoy_os_param); i++)
|
for (i = 0; i < sizeof(ventoy_os_param); i++)
|
||||||
{
|
{
|
||||||
@@ -3223,13 +3304,49 @@ void ventoy_fill_os_param(grub_file_t file, ventoy_os_param *param)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
int ventoy_check_block_list(grub_file_t file, ventoy_img_chunk_list *chunklist, grub_disk_addr_t start)
|
static const char* g_chunk_err_msg[VTOY_CHUNK_ERR_MAX] =
|
||||||
|
{
|
||||||
|
"success",
|
||||||
|
"File system use more than 1 disks! (maybe RAID)",
|
||||||
|
"File system enable RAID feature, this is NOT supported!",
|
||||||
|
"File is compressed in disk, this is not supported!",
|
||||||
|
"File not flat in disk! (maybe compressed)",
|
||||||
|
"Read buffer overflow!",
|
||||||
|
};
|
||||||
|
|
||||||
|
static const char * ventoy_get_chunk_err_msg(grub_uint32_t err)
|
||||||
|
{
|
||||||
|
if (err < VTOY_CHUNK_ERR_MAX)
|
||||||
|
{
|
||||||
|
return g_chunk_err_msg[err];
|
||||||
|
}
|
||||||
|
|
||||||
|
return "XXXX";
|
||||||
|
}
|
||||||
|
|
||||||
|
int ventoy_check_block_list(grub_file_t file, ventoy_img_chunk_list *chunklist,
|
||||||
|
grub_disk_addr_t start, char *err, grub_uint32_t len)
|
||||||
{
|
{
|
||||||
grub_uint32_t i = 0;
|
grub_uint32_t i = 0;
|
||||||
grub_uint64_t total = 0;
|
grub_uint64_t total = 0;
|
||||||
grub_uint64_t fileblk = 0;
|
grub_uint64_t fileblk = 0;
|
||||||
ventoy_img_chunk *chunk = NULL;
|
ventoy_img_chunk *chunk = NULL;
|
||||||
|
|
||||||
|
if (chunklist->err_code)
|
||||||
|
{
|
||||||
|
if (err)
|
||||||
|
{
|
||||||
|
grub_snprintf(err, len, "%s", ventoy_get_chunk_err_msg(chunklist->err_code));
|
||||||
|
}
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (err)
|
||||||
|
{
|
||||||
|
grub_snprintf(err, len, "Unsupported chunk list.");
|
||||||
|
}
|
||||||
|
|
||||||
for (i = 0; i < chunklist->cur_chunk; i++)
|
for (i = 0; i < chunklist->cur_chunk; i++)
|
||||||
{
|
{
|
||||||
chunk = chunklist->chunk + i;
|
chunk = chunklist->chunk + i;
|
||||||
@@ -3279,6 +3396,10 @@ int ventoy_get_block_list(grub_file_t file, ventoy_img_chunk_list *chunklist, gr
|
|||||||
{
|
{
|
||||||
grub_ext_get_file_chunk(start, file, chunklist);
|
grub_ext_get_file_chunk(start, file, chunklist);
|
||||||
}
|
}
|
||||||
|
else if (fs_type == ventoy_fs_btrfs)
|
||||||
|
{
|
||||||
|
grub_btrfs_get_file_chunk(start, file, chunklist);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
file->read_hook = (grub_disk_read_hook_t)(void *)grub_disk_blocklist_read;
|
file->read_hook = (grub_disk_read_hook_t)(void *)grub_disk_blocklist_read;
|
||||||
@@ -3338,8 +3459,10 @@ int ventoy_get_block_list(grub_file_t file, ventoy_img_chunk_list *chunklist, gr
|
|||||||
static grub_err_t ventoy_cmd_img_sector(grub_extcmd_context_t ctxt, int argc, char **args)
|
static grub_err_t ventoy_cmd_img_sector(grub_extcmd_context_t ctxt, int argc, char **args)
|
||||||
{
|
{
|
||||||
int rc;
|
int rc;
|
||||||
|
int fs_type;
|
||||||
grub_file_t file;
|
grub_file_t file;
|
||||||
grub_disk_addr_t start;
|
grub_disk_addr_t start;
|
||||||
|
char errmsg[128];
|
||||||
|
|
||||||
(void)ctxt;
|
(void)ctxt;
|
||||||
(void)argc;
|
(void)argc;
|
||||||
@@ -3359,7 +3482,8 @@ static grub_err_t ventoy_cmd_img_sector(grub_extcmd_context_t ctxt, int argc, ch
|
|||||||
grub_free(g_img_chunk_list.chunk);
|
grub_free(g_img_chunk_list.chunk);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ventoy_get_fs_type(file->fs->name) >= ventoy_fs_max)
|
fs_type = ventoy_get_fs_type(file->fs->name);
|
||||||
|
if (fs_type >= ventoy_fs_max)
|
||||||
{
|
{
|
||||||
grub_file_close(file);
|
grub_file_close(file);
|
||||||
return grub_error(GRUB_ERR_BAD_ARGUMENT, "Unsupported filesystem %s\n", file->fs->name);
|
return grub_error(GRUB_ERR_BAD_ARGUMENT, "Unsupported filesystem %s\n", file->fs->name);
|
||||||
@@ -3380,12 +3504,17 @@ static grub_err_t ventoy_cmd_img_sector(grub_extcmd_context_t ctxt, int argc, ch
|
|||||||
|
|
||||||
ventoy_get_block_list(file, &g_img_chunk_list, start);
|
ventoy_get_block_list(file, &g_img_chunk_list, start);
|
||||||
|
|
||||||
rc = ventoy_check_block_list(file, &g_img_chunk_list, start);
|
rc = ventoy_check_block_list(file, &g_img_chunk_list, start, errmsg, sizeof(errmsg));
|
||||||
grub_file_close(file);
|
grub_file_close(file);
|
||||||
|
|
||||||
if (rc)
|
if (rc)
|
||||||
{
|
{
|
||||||
return grub_error(GRUB_ERR_NOT_IMPLEMENTED_YET, "Unsupported chunk list.\n");
|
if (fs_type == ventoy_fs_btrfs)
|
||||||
|
{
|
||||||
|
vtoy_tip(10, "%s\n\nWill exit in 10 seconds...\n", errmsg);
|
||||||
|
grub_exit();
|
||||||
|
}
|
||||||
|
return grub_error(GRUB_ERR_NOT_IMPLEMENTED_YET, "%s\n", errmsg);
|
||||||
}
|
}
|
||||||
|
|
||||||
grub_memset(&g_grub_param->file_replace, 0, sizeof(g_grub_param->file_replace));
|
grub_memset(&g_grub_param->file_replace, 0, sizeof(g_grub_param->file_replace));
|
||||||
@@ -3922,6 +4051,7 @@ static grub_err_t ventoy_cmd_test_block_list(grub_extcmd_context_t ctxt, int arg
|
|||||||
grub_uint32_t i;
|
grub_uint32_t i;
|
||||||
grub_file_t file;
|
grub_file_t file;
|
||||||
ventoy_img_chunk_list chunklist;
|
ventoy_img_chunk_list chunklist;
|
||||||
|
char errmsg[128];
|
||||||
|
|
||||||
(void)ctxt;
|
(void)ctxt;
|
||||||
(void)argc;
|
(void)argc;
|
||||||
@@ -3945,8 +4075,9 @@ static grub_err_t ventoy_cmd_test_block_list(grub_extcmd_context_t ctxt, int arg
|
|||||||
|
|
||||||
ventoy_get_block_list(file, &chunklist, 0);
|
ventoy_get_block_list(file, &chunklist, 0);
|
||||||
|
|
||||||
if (0 != ventoy_check_block_list(file, &chunklist, 0))
|
if (0 != ventoy_check_block_list(file, &chunklist, 0, errmsg, sizeof(errmsg)))
|
||||||
{
|
{
|
||||||
|
grub_printf("%s\n", errmsg);
|
||||||
grub_printf("########## UNSUPPORTED ###############\n");
|
grub_printf("########## UNSUPPORTED ###############\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -4622,7 +4753,7 @@ static grub_err_t ventoy_cmd_img_unhook_root(grub_extcmd_context_t ctxt, int arg
|
|||||||
static grub_err_t ventoy_cmd_check_secureboot_var(grub_extcmd_context_t ctxt, int argc, char **args)
|
static grub_err_t ventoy_cmd_check_secureboot_var(grub_extcmd_context_t ctxt, int argc, char **args)
|
||||||
{
|
{
|
||||||
int ret = 1;
|
int ret = 1;
|
||||||
grub_uint8_t *var;
|
grub_uint8_t *var = NULL;
|
||||||
grub_size_t size;
|
grub_size_t size;
|
||||||
grub_efi_guid_t global = GRUB_EFI_GLOBAL_VARIABLE_GUID;
|
grub_efi_guid_t global = GRUB_EFI_GLOBAL_VARIABLE_GUID;
|
||||||
|
|
||||||
@@ -4633,6 +4764,7 @@ static grub_err_t ventoy_cmd_check_secureboot_var(grub_extcmd_context_t ctxt, in
|
|||||||
var = grub_efi_get_variable("SecureBoot", &global, &size);
|
var = grub_efi_get_variable("SecureBoot", &global, &size);
|
||||||
if (var && *var == 1)
|
if (var && *var == 1)
|
||||||
{
|
{
|
||||||
|
grub_free(var);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -5017,7 +5149,7 @@ int ventoy_load_part_table(const char *diskname)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ventoy_prompt_end(void)
|
void ventoy_prompt_end(void)
|
||||||
{
|
{
|
||||||
int op = 0;
|
int op = 0;
|
||||||
char c;
|
char c;
|
||||||
@@ -6311,6 +6443,52 @@ static grub_err_t ventoy_cmd_load_menu_lang(grub_extcmd_context_t ctxt, int argc
|
|||||||
VENTOY_CMD_RETURN(0);
|
VENTOY_CMD_RETURN(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static grub_err_t ventoy_cmd_update_sb_policy(grub_extcmd_context_t ctxt, int argc, char **args)
|
||||||
|
{
|
||||||
|
(void)ctxt;
|
||||||
|
(void)argc;
|
||||||
|
(void)args;
|
||||||
|
|
||||||
|
#ifdef GRUB_MACHINE_EFI
|
||||||
|
ventoy_set_sb_policy();
|
||||||
|
#endif
|
||||||
|
|
||||||
|
VENTOY_CMD_RETURN(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static grub_err_t ventoy_cmd_sb_info(grub_extcmd_context_t ctxt, int argc, char **args)
|
||||||
|
{
|
||||||
|
(void)ctxt;
|
||||||
|
(void)argc;
|
||||||
|
(void)args;
|
||||||
|
|
||||||
|
#ifdef GRUB_MACHINE_EFI
|
||||||
|
const char *policy = NULL;
|
||||||
|
|
||||||
|
if (g_sb_policy == VTOY_SB_POLICY_BYPASS)
|
||||||
|
{
|
||||||
|
policy = "ByPass";
|
||||||
|
}
|
||||||
|
else if (g_sb_policy == VTOY_SB_POLICY_CHECK)
|
||||||
|
{
|
||||||
|
policy = "Check";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
policy = "XXX";
|
||||||
|
}
|
||||||
|
|
||||||
|
grub_printf("UEFI Firmware Secure Boot: %s\n", g_sys_sb ? "Enable" : "Disable");
|
||||||
|
grub_printf("Ventoy Secure Boot Policy: %s\n", policy);
|
||||||
|
#else
|
||||||
|
grub_printf("Non EFI mode!\n");
|
||||||
|
#endif
|
||||||
|
|
||||||
|
grub_refresh();
|
||||||
|
|
||||||
|
VENTOY_CMD_RETURN(0);
|
||||||
|
}
|
||||||
|
|
||||||
static int ventoy_chksum_pathcmp(int chktype, char *rlpath, char *rdpath)
|
static int ventoy_chksum_pathcmp(int chktype, char *rlpath, char *rdpath)
|
||||||
{
|
{
|
||||||
char *pos1 = NULL;
|
char *pos1 = NULL;
|
||||||
@@ -6796,6 +6974,7 @@ static cmd_para ventoy_cmds[] =
|
|||||||
{ "vt_incr", ventoy_cmd_incr, 0, NULL, "{Var} {INT}", "Increase integer variable", NULL },
|
{ "vt_incr", ventoy_cmd_incr, 0, NULL, "{Var} {INT}", "Increase integer variable", NULL },
|
||||||
{ "vt_mod", ventoy_cmd_mod, 0, NULL, "{Int} {Int} {Var}", "mod integer variable", NULL },
|
{ "vt_mod", ventoy_cmd_mod, 0, NULL, "{Int} {Int} {Var}", "mod integer variable", NULL },
|
||||||
{ "vt_strstr", ventoy_cmd_strstr, 0, NULL, "", "", NULL },
|
{ "vt_strstr", ventoy_cmd_strstr, 0, NULL, "", "", NULL },
|
||||||
|
{ "vt_istrstr", ventoy_cmd_istrstr, 0, NULL, "", "", NULL },
|
||||||
{ "vt_str_begin", ventoy_cmd_strbegin, 0, NULL, "", "", NULL },
|
{ "vt_str_begin", ventoy_cmd_strbegin, 0, NULL, "", "", NULL },
|
||||||
{ "vt_str_casebegin", ventoy_cmd_strcasebegin, 0, NULL, "", "", NULL },
|
{ "vt_str_casebegin", ventoy_cmd_strcasebegin, 0, NULL, "", "", NULL },
|
||||||
{ "vt_debug", ventoy_cmd_debug, 0, NULL, "{on|off}", "turn debug on/off", NULL },
|
{ "vt_debug", ventoy_cmd_debug, 0, NULL, "{on|off}", "turn debug on/off", NULL },
|
||||||
@@ -6957,6 +7136,10 @@ static cmd_para ventoy_cmds[] =
|
|||||||
{ "vt_cmp_checksum", ventoy_cmd_cmp_checksum, 0, NULL, "", "", NULL },
|
{ "vt_cmp_checksum", ventoy_cmd_cmp_checksum, 0, NULL, "", "", NULL },
|
||||||
{ "vt_push_menu_lang", ventoy_cmd_push_menulang, 0, NULL, "", "", NULL },
|
{ "vt_push_menu_lang", ventoy_cmd_push_menulang, 0, NULL, "", "", NULL },
|
||||||
{ "vt_pop_menu_lang", ventoy_cmd_pop_menulang, 0, NULL, "", "", NULL },
|
{ "vt_pop_menu_lang", ventoy_cmd_pop_menulang, 0, NULL, "", "", NULL },
|
||||||
|
{ "vt_linux_initrd", ventoy_cmd_linux_initrd, 0, NULL, "", "", NULL },
|
||||||
|
|
||||||
|
{ "vt_sbinfo", ventoy_cmd_sb_info, 0, NULL, "", "", NULL },
|
||||||
|
{ "vt_update_sb_policy", ventoy_cmd_update_sb_policy, 0, NULL, "", "", NULL },
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -37,6 +37,7 @@
|
|||||||
#define VTOY_SIZE_4MB (4 * 1024 * 1024)
|
#define VTOY_SIZE_4MB (4 * 1024 * 1024)
|
||||||
#define VTOY_SIZE_512KB (512 * 1024)
|
#define VTOY_SIZE_512KB (512 * 1024)
|
||||||
#define VTOY_SIZE_1KB 1024
|
#define VTOY_SIZE_1KB 1024
|
||||||
|
#define VTOY_SIZE_4KB 4096
|
||||||
#define VTOY_SIZE_32KB (32 * 1024)
|
#define VTOY_SIZE_32KB (32 * 1024)
|
||||||
#define VTOY_SIZE_128KB (128 * 1024)
|
#define VTOY_SIZE_128KB (128 * 1024)
|
||||||
|
|
||||||
@@ -95,6 +96,12 @@
|
|||||||
return (err);\
|
return (err);\
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#define vtoy_tip(wait_seconds, fmt, ...) \
|
||||||
|
grub_printf(fmt, __VA_ARGS__); \
|
||||||
|
grub_refresh(); \
|
||||||
|
grub_sleep(wait_seconds)
|
||||||
|
|
||||||
|
|
||||||
#define VTOY_APPEND_NEWBUF(buf) \
|
#define VTOY_APPEND_NEWBUF(buf) \
|
||||||
{\
|
{\
|
||||||
char *__c = buf;\
|
char *__c = buf;\
|
||||||
@@ -188,6 +195,16 @@ typedef struct cpio_newc_header
|
|||||||
#define check_free(p, func) if (p) { func(p); p = NULL; }
|
#define check_free(p, func) if (p) { func(p); p = NULL; }
|
||||||
#define grub_check_free(p) if (p) { grub_free(p); p = NULL; }
|
#define grub_check_free(p) if (p) { grub_free(p); p = NULL; }
|
||||||
|
|
||||||
|
#define VTOY_SHIM_POLICY_GUID {0x90a29d14, 0x3968, 0x48fe, { 0x85, 0x81, 0x6b, 0x7f, 0x7d, 0xc4, 0x70, 0x55 }};
|
||||||
|
|
||||||
|
typedef void (*VTOY_BYPASS_SB)(void);
|
||||||
|
typedef void (*VTOY_CHECK_SB)(void);
|
||||||
|
typedef struct _VTOY_SHIM{
|
||||||
|
VTOY_BYPASS_SB ByPassSB;
|
||||||
|
VTOY_CHECK_SB CheckSB;
|
||||||
|
} VTOY_SHIM;
|
||||||
|
|
||||||
|
|
||||||
typedef int (*grub_char_check_func)(int c);
|
typedef int (*grub_char_check_func)(int c);
|
||||||
#define ventoy_is_decimal(str) ventoy_string_check(str, grub_isdigit)
|
#define ventoy_is_decimal(str) ventoy_string_check(str, grub_isdigit)
|
||||||
|
|
||||||
@@ -656,6 +673,7 @@ grub_uint32_t ventoy_get_iso_boot_catlog(grub_file_t file);
|
|||||||
int ventoy_has_efi_eltorito(grub_file_t file, grub_uint32_t sector);
|
int ventoy_has_efi_eltorito(grub_file_t file, grub_uint32_t sector);
|
||||||
grub_err_t ventoy_cmd_linux_chain_data(grub_extcmd_context_t ctxt, int argc, char **args);
|
grub_err_t ventoy_cmd_linux_chain_data(grub_extcmd_context_t ctxt, int argc, char **args);
|
||||||
grub_err_t ventoy_cmd_linux_systemd_menu(grub_extcmd_context_t ctxt, int argc, char **args);
|
grub_err_t ventoy_cmd_linux_systemd_menu(grub_extcmd_context_t ctxt, int argc, char **args);
|
||||||
|
grub_err_t ventoy_cmd_linux_initrd(grub_extcmd_context_t ctxt, int argc, char **args);
|
||||||
grub_err_t ventoy_cmd_linux_limine_menu(grub_extcmd_context_t ctxt, int argc, char **args);
|
grub_err_t ventoy_cmd_linux_limine_menu(grub_extcmd_context_t ctxt, int argc, char **args);
|
||||||
grub_err_t ventoy_cmd_linux_locate_initrd(grub_extcmd_context_t ctxt, int argc, char **args);
|
grub_err_t ventoy_cmd_linux_locate_initrd(grub_extcmd_context_t ctxt, int argc, char **args);
|
||||||
grub_err_t ventoy_cmd_initrd_count(grub_extcmd_context_t ctxt, int argc, char **args);
|
grub_err_t ventoy_cmd_initrd_count(grub_extcmd_context_t ctxt, int argc, char **args);
|
||||||
@@ -861,7 +879,8 @@ typedef struct vhd_footer_t
|
|||||||
grub_uint8_t savedst; // Saved state
|
grub_uint8_t savedst; // Saved state
|
||||||
}vhd_footer_t;
|
}vhd_footer_t;
|
||||||
|
|
||||||
#define VDI_IMAGE_FILE_INFO "<<< Oracle VM VirtualBox Disk Image >>>\n"
|
#define VDI_IMAGE_FILE_INFO "<<< Oracle VM VirtualBox Disk Image >>>\n"
|
||||||
|
#define VDI_IMAGE_FILE_INFO2 "<<< Oracle VirtualBox Disk Image >>>\n"
|
||||||
|
|
||||||
/** Image signature. */
|
/** Image signature. */
|
||||||
#define VDI_IMAGE_SIGNATURE (0xbeda107f)
|
#define VDI_IMAGE_SIGNATURE (0xbeda107f)
|
||||||
@@ -1149,7 +1168,7 @@ int ventoy_plugin_find_conf_replace(const char *iso, conf_replace *nodes[VTOY_MA
|
|||||||
dud * ventoy_plugin_find_dud(const char *iso);
|
dud * ventoy_plugin_find_dud(const char *iso);
|
||||||
int ventoy_plugin_load_dud(dud *node, const char *isopart);
|
int ventoy_plugin_load_dud(dud *node, const char *isopart);
|
||||||
int ventoy_get_block_list(grub_file_t file, ventoy_img_chunk_list *chunklist, grub_disk_addr_t start);
|
int ventoy_get_block_list(grub_file_t file, ventoy_img_chunk_list *chunklist, grub_disk_addr_t start);
|
||||||
int ventoy_check_block_list(grub_file_t file, ventoy_img_chunk_list *chunklist, grub_disk_addr_t start);
|
int ventoy_check_block_list(grub_file_t file, ventoy_img_chunk_list *chunklist, grub_disk_addr_t start, char *err, grub_uint32_t len);
|
||||||
void ventoy_plugin_dump_persistence(void);
|
void ventoy_plugin_dump_persistence(void);
|
||||||
grub_err_t ventoy_cmd_set_theme(grub_extcmd_context_t ctxt, int argc, char **args);
|
grub_err_t ventoy_cmd_set_theme(grub_extcmd_context_t ctxt, int argc, char **args);
|
||||||
grub_err_t ventoy_cmd_set_theme_path(grub_extcmd_context_t ctxt, int argc, char **args);
|
grub_err_t ventoy_cmd_set_theme_path(grub_extcmd_context_t ctxt, int argc, char **args);
|
||||||
@@ -1272,6 +1291,7 @@ typedef struct systemd_menu_ctx
|
|||||||
{
|
{
|
||||||
char *dev;
|
char *dev;
|
||||||
char *buf;
|
char *buf;
|
||||||
|
const char *initrd_cmd;
|
||||||
int pos;
|
int pos;
|
||||||
int len;
|
int len;
|
||||||
}systemd_menu_ctx;
|
}systemd_menu_ctx;
|
||||||
@@ -1286,7 +1306,7 @@ typedef struct global_var_cfg
|
|||||||
typedef struct ctrl_var_cfg
|
typedef struct ctrl_var_cfg
|
||||||
{
|
{
|
||||||
const char *name;
|
const char *name;
|
||||||
int value;
|
char szval[2];
|
||||||
}ctrl_var_cfg;
|
}ctrl_var_cfg;
|
||||||
|
|
||||||
#define vtoy_check_goto_out(p) if (!p) goto out
|
#define vtoy_check_goto_out(p) if (!p) goto out
|
||||||
@@ -1298,6 +1318,7 @@ extern int g_tree_view_menu_style;
|
|||||||
extern int g_sort_case_sensitive;
|
extern int g_sort_case_sensitive;
|
||||||
extern int g_wimboot_enable;
|
extern int g_wimboot_enable;
|
||||||
extern int g_filt_dot_underscore_file;
|
extern int g_filt_dot_underscore_file;
|
||||||
|
extern int g_filt_trash_dir;
|
||||||
extern int g_vtoy_file_flt[VTOY_FILE_FLT_BUTT];
|
extern int g_vtoy_file_flt[VTOY_FILE_FLT_BUTT];
|
||||||
extern const char *g_menu_class[img_type_max];
|
extern const char *g_menu_class[img_type_max];
|
||||||
extern char g_iso_path[256];
|
extern char g_iso_path[256];
|
||||||
@@ -1315,6 +1336,8 @@ int ventoy_ctrl_var_init(void);
|
|||||||
int ventoy_global_var_init(void);
|
int ventoy_global_var_init(void);
|
||||||
grub_err_t ventoy_cmd_push_menulang(grub_extcmd_context_t ctxt, int argc, char **args);
|
grub_err_t ventoy_cmd_push_menulang(grub_extcmd_context_t ctxt, int argc, char **args);
|
||||||
grub_err_t ventoy_cmd_pop_menulang(grub_extcmd_context_t ctxt, int argc, char **args);
|
grub_err_t ventoy_cmd_pop_menulang(grub_extcmd_context_t ctxt, int argc, char **args);
|
||||||
|
void ventoy_prompt_end(void);
|
||||||
|
int ventoy_set_sb_policy(void);
|
||||||
|
|
||||||
#endif /* __VENTOY_DEF_H__ */
|
#endif /* __VENTOY_DEF_H__ */
|
||||||
|
|
||||||
|
|||||||
@@ -1867,7 +1867,7 @@ static int ventoy_systemd_conf_hook(const char *filename, const struct grub_dirh
|
|||||||
ctx->pos = oldpos;
|
ctx->pos = oldpos;
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
vtoy_len_ssprintf(ctx->buf, ctx->pos, ctx->len, " echo \"Downloading kernel ...\"\n linux %s ", tag);
|
vtoy_len_ssprintf(ctx->buf, ctx->pos, ctx->len, " echo \"Loading kernel ...\"\n linux %s ", tag);
|
||||||
|
|
||||||
/* kernel options */
|
/* kernel options */
|
||||||
grub_memcpy(filebuf, bkbuf, file->size);
|
grub_memcpy(filebuf, bkbuf, file->size);
|
||||||
@@ -1876,7 +1876,7 @@ static int ventoy_systemd_conf_hook(const char *filename, const struct grub_dirh
|
|||||||
|
|
||||||
|
|
||||||
/* initrd xxx xxx xxx */
|
/* initrd xxx xxx xxx */
|
||||||
vtoy_len_ssprintf(ctx->buf, ctx->pos, ctx->len, " echo \"Downloading initrd ...\"\n initrd ");
|
vtoy_len_ssprintf(ctx->buf, ctx->pos, ctx->len, " echo \"Loading initrd ...\"\n %s ", ctx->initrd_cmd);
|
||||||
grub_memcpy(filebuf, bkbuf, file->size);
|
grub_memcpy(filebuf, bkbuf, file->size);
|
||||||
tag = ventoy_systemd_conf_tag(filebuf, "initrd", 1);
|
tag = ventoy_systemd_conf_tag(filebuf, "initrd", 1);
|
||||||
while (tag)
|
while (tag)
|
||||||
@@ -1893,6 +1893,34 @@ out:
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
grub_err_t ventoy_cmd_linux_initrd(grub_extcmd_context_t ctxt, int argc, char **args)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
int pos = 0;
|
||||||
|
char *buf = NULL;
|
||||||
|
|
||||||
|
(void)ctxt;
|
||||||
|
|
||||||
|
buf = (char *)grub_malloc(VTOY_SIZE_4KB);
|
||||||
|
if (!buf)
|
||||||
|
{
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
pos += grub_snprintf(buf + pos, VTOY_SIZE_4KB - pos, "initrd mem:%s:size:%s",
|
||||||
|
grub_env_get("ventoy_cpio_addr"), grub_env_get("ventoy_cpio_size"));
|
||||||
|
|
||||||
|
for (i = 0; i < argc; i++)
|
||||||
|
{
|
||||||
|
pos += grub_snprintf(buf + pos, VTOY_SIZE_4KB - pos, " newc:initrd%03d:%s", i + 1, args[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
grub_script_execute_sourcecode(buf);
|
||||||
|
grub_free(buf);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
grub_err_t ventoy_cmd_linux_systemd_menu(grub_extcmd_context_t ctxt, int argc, char **args)
|
grub_err_t ventoy_cmd_linux_systemd_menu(grub_extcmd_context_t ctxt, int argc, char **args)
|
||||||
{
|
{
|
||||||
static char *buf = NULL;
|
static char *buf = NULL;
|
||||||
@@ -1936,6 +1964,7 @@ grub_err_t ventoy_cmd_linux_systemd_menu(grub_extcmd_context_t ctxt, int argc, c
|
|||||||
|
|
||||||
ctx.dev = args[0];
|
ctx.dev = args[0];
|
||||||
ctx.buf = buf;
|
ctx.buf = buf;
|
||||||
|
ctx.initrd_cmd = args[2] ? args[2] : "initrd";
|
||||||
ctx.pos = 0;
|
ctx.pos = 0;
|
||||||
ctx.len = VTOY_LINUX_SYSTEMD_MENU_MAX_BUF;
|
ctx.len = VTOY_LINUX_SYSTEMD_MENU_MAX_BUF;
|
||||||
fs->fs_dir(dev, "/loader/entries", ventoy_systemd_conf_hook, &ctx);
|
fs->fs_dir(dev, "/loader/entries", ventoy_systemd_conf_hook, &ctx);
|
||||||
|
|||||||
@@ -2765,7 +2765,7 @@ int ventoy_plugin_get_persistent_chunklist(const char *isopath, int index, vento
|
|||||||
start = file->device->disk->partition->start;
|
start = file->device->disk->partition->start;
|
||||||
ventoy_get_block_list(file, chunk_list, start);
|
ventoy_get_block_list(file, chunk_list, start);
|
||||||
|
|
||||||
if (0 != ventoy_check_block_list(file, chunk_list, start))
|
if (0 != ventoy_check_block_list(file, chunk_list, start, NULL, 0))
|
||||||
{
|
{
|
||||||
grub_free(chunk_list->chunk);
|
grub_free(chunk_list->chunk);
|
||||||
chunk_list->chunk = NULL;
|
chunk_list->chunk = NULL;
|
||||||
|
|||||||
@@ -504,7 +504,7 @@ grub_err_t ventoy_cmd_get_vtoy_type(grub_extcmd_context_t ctxt, int argc, char *
|
|||||||
vhd_footer_t vhdfoot;
|
vhd_footer_t vhdfoot;
|
||||||
VDIPREHEADER vdihdr;
|
VDIPREHEADER vdihdr;
|
||||||
char type[16] = {0};
|
char type[16] = {0};
|
||||||
ventoy_gpt_info *gpt;
|
ventoy_gpt_info *gpt = NULL;
|
||||||
|
|
||||||
(void)ctxt;
|
(void)ctxt;
|
||||||
|
|
||||||
@@ -536,12 +536,25 @@ grub_err_t ventoy_cmd_get_vtoy_type(grub_extcmd_context_t ctxt, int argc, char *
|
|||||||
{
|
{
|
||||||
grub_file_seek(file, 0);
|
grub_file_seek(file, 0);
|
||||||
grub_file_read(file, &vdihdr, sizeof(vdihdr));
|
grub_file_read(file, &vdihdr, sizeof(vdihdr));
|
||||||
if (vdihdr.u32Signature == VDI_IMAGE_SIGNATURE &&
|
if (vdihdr.u32Signature == VDI_IMAGE_SIGNATURE)
|
||||||
grub_strncmp(vdihdr.szFileInfo, VDI_IMAGE_FILE_INFO, grub_strlen(VDI_IMAGE_FILE_INFO)) == 0)
|
|
||||||
{
|
{
|
||||||
offset = 2 * 1048576;
|
|
||||||
g_img_trim_head_secnum = offset / 512;
|
|
||||||
grub_snprintf(type, sizeof(type), "vdi");
|
grub_snprintf(type, sizeof(type), "vdi");
|
||||||
|
if (grub_strncmp(vdihdr.szFileInfo, VDI_IMAGE_FILE_INFO, grub_strlen(VDI_IMAGE_FILE_INFO)) == 0)
|
||||||
|
{
|
||||||
|
offset = 2 * 1048576;
|
||||||
|
g_img_trim_head_secnum = offset / 512;
|
||||||
|
debug("VDI V1\n");
|
||||||
|
}
|
||||||
|
else if (grub_strncmp(vdihdr.szFileInfo, VDI_IMAGE_FILE_INFO2, grub_strlen(VDI_IMAGE_FILE_INFO2)) == 0)
|
||||||
|
{
|
||||||
|
offset = 2 * 1048576;
|
||||||
|
g_img_trim_head_secnum = offset / 512;
|
||||||
|
debug("VDI V2\n");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
debug("invalid file info <%s>\n", vdihdr.szFileInfo);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -568,7 +581,7 @@ grub_err_t ventoy_cmd_get_vtoy_type(grub_extcmd_context_t ctxt, int argc, char *
|
|||||||
if (gpt->MBR.Byte55 != 0x55 || gpt->MBR.ByteAA != 0xAA)
|
if (gpt->MBR.Byte55 != 0x55 || gpt->MBR.ByteAA != 0xAA)
|
||||||
{
|
{
|
||||||
grub_env_set(args[1], "unknown");
|
grub_env_set(args[1], "unknown");
|
||||||
debug("invalid mbr signature: 0x%x 0x%x\n", gpt->MBR.Byte55, gpt->MBR.ByteAA);
|
debug("invalid mbr signature: 0x%x 0x%x offset=%d\n", gpt->MBR.Byte55, gpt->MBR.ByteAA, offset);
|
||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -197,6 +197,8 @@ grub_disk_t EXPORT_FUNC(grub_disk_open) (const char *name);
|
|||||||
void EXPORT_FUNC(grub_disk_close) (grub_disk_t disk);
|
void EXPORT_FUNC(grub_disk_close) (grub_disk_t disk);
|
||||||
grub_err_t EXPORT_FUNC(grub_disk_blocklist_read)(void *chunklist, grub_uint64_t sector,
|
grub_err_t EXPORT_FUNC(grub_disk_blocklist_read)(void *chunklist, grub_uint64_t sector,
|
||||||
grub_uint64_t size, grub_uint32_t log_sector_size);
|
grub_uint64_t size, grub_uint32_t log_sector_size);
|
||||||
|
grub_err_t EXPORT_FUNC(grub_disk_blocklist_read2)(grub_disk_t disk, grub_uint64_t sector,
|
||||||
|
grub_uint64_t size, char *buf);
|
||||||
|
|
||||||
grub_err_t EXPORT_FUNC(grub_disk_read) (grub_disk_t disk,
|
grub_err_t EXPORT_FUNC(grub_disk_read) (grub_disk_t disk,
|
||||||
grub_disk_addr_t sector,
|
grub_disk_addr_t sector,
|
||||||
|
|||||||
@@ -24,6 +24,11 @@
|
|||||||
#include <grub/types.h>
|
#include <grub/types.h>
|
||||||
#include <grub/menu.h>
|
#include <grub/menu.h>
|
||||||
|
|
||||||
|
#define VTOY_SB_POLICY_BYPASS 0
|
||||||
|
#define VTOY_SB_POLICY_CHECK 1
|
||||||
|
extern grub_uint8_t EXPORT_VAR(g_sys_sb);
|
||||||
|
extern grub_uint8_t EXPORT_VAR(g_sb_policy);
|
||||||
|
|
||||||
struct grub_env_var;
|
struct grub_env_var;
|
||||||
|
|
||||||
typedef const char *(*grub_env_read_hook_t) (struct grub_env_var *var,
|
typedef const char *(*grub_env_read_hook_t) (struct grub_env_var *var,
|
||||||
|
|||||||
@@ -36,6 +36,7 @@ typedef enum ventoy_fs_type
|
|||||||
ventoy_fs_xfs, /* 3: XFS */
|
ventoy_fs_xfs, /* 3: XFS */
|
||||||
ventoy_fs_udf, /* 4: UDF */
|
ventoy_fs_udf, /* 4: UDF */
|
||||||
ventoy_fs_fat, /* 5: FAT */
|
ventoy_fs_fat, /* 5: FAT */
|
||||||
|
ventoy_fs_btrfs, /* 6: BTRFS */
|
||||||
|
|
||||||
ventoy_fs_max
|
ventoy_fs_max
|
||||||
}ventoy_fs_type;
|
}ventoy_fs_type;
|
||||||
@@ -124,6 +125,7 @@ typedef struct ventoy_os_param
|
|||||||
* vtoy_reserved[5]: vtoy_linux_remount
|
* vtoy_reserved[5]: vtoy_linux_remount
|
||||||
* vtoy_reserved[6]: vtoy_vlnk
|
* vtoy_reserved[6]: vtoy_vlnk
|
||||||
* vtoy_reserved[7~10]: vtoy_disk_sig[4] used for vlnk
|
* vtoy_reserved[7~10]: vtoy_disk_sig[4] used for vlnk
|
||||||
|
* vtoy_reserved[11]: vtoy_win_uefi_max_res
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
grub_uint8_t vtoy_reserved[32]; // Internal use by ventoy
|
grub_uint8_t vtoy_reserved[32]; // Internal use by ventoy
|
||||||
@@ -252,12 +254,15 @@ typedef struct ventoy_virt_chunk
|
|||||||
#define DEFAULT_CHUNK_NUM 1024
|
#define DEFAULT_CHUNK_NUM 1024
|
||||||
typedef struct ventoy_img_chunk_list
|
typedef struct ventoy_img_chunk_list
|
||||||
{
|
{
|
||||||
|
char *buf;
|
||||||
|
grub_uint32_t last_off;
|
||||||
|
grub_uint32_t err_code;
|
||||||
|
|
||||||
grub_uint32_t max_chunk;
|
grub_uint32_t max_chunk;
|
||||||
grub_uint32_t cur_chunk;
|
grub_uint32_t cur_chunk;
|
||||||
ventoy_img_chunk *chunk;
|
ventoy_img_chunk *chunk;
|
||||||
}ventoy_img_chunk_list;
|
}ventoy_img_chunk_list;
|
||||||
|
|
||||||
|
|
||||||
#pragma pack()
|
#pragma pack()
|
||||||
|
|
||||||
#define ventoy_filt_register grub_file_filter_register
|
#define ventoy_filt_register grub_file_filter_register
|
||||||
@@ -291,7 +296,21 @@ typedef struct ventoy_grub_param
|
|||||||
|
|
||||||
#pragma pack()
|
#pragma pack()
|
||||||
|
|
||||||
|
#define VTOY_CHUNK_BUF_SIZE (4 * 1024 * 1024)
|
||||||
|
|
||||||
|
typedef enum vtoy_chunk_err
|
||||||
|
{
|
||||||
|
VTOY_CHUNK_ERR_NONE = 0,
|
||||||
|
VTOY_CHUNK_ERR_MULTI_DEV,
|
||||||
|
VTOY_CHUNK_ERR_RAID,
|
||||||
|
VTOY_CHUNK_ERR_COMPRESS,
|
||||||
|
VTOY_CHUNK_ERR_NOT_FLAT,
|
||||||
|
VTOY_CHUNK_ERR_OVER_FLOW,
|
||||||
|
VTOY_CHUNK_ERR_MAX
|
||||||
|
}vtoy_chunk_err;
|
||||||
|
|
||||||
int grub_ext_get_file_chunk(grub_uint64_t part_start, grub_file_t file, ventoy_img_chunk_list *chunk_list);
|
int grub_ext_get_file_chunk(grub_uint64_t part_start, grub_file_t file, ventoy_img_chunk_list *chunk_list);
|
||||||
|
int grub_btrfs_get_file_chunk(grub_uint64_t part_start, grub_file_t file, ventoy_img_chunk_list *chunk_list);
|
||||||
int grub_fat_get_file_chunk(grub_uint64_t part_start, grub_file_t file, ventoy_img_chunk_list *chunk_list);
|
int grub_fat_get_file_chunk(grub_uint64_t part_start, grub_file_t file, ventoy_img_chunk_list *chunk_list);
|
||||||
void grub_iso9660_set_nojoliet(int nojoliet);
|
void grub_iso9660_set_nojoliet(int nojoliet);
|
||||||
int grub_iso9660_is_joliet(void);
|
int grub_iso9660_is_joliet(void);
|
||||||
|
|||||||
@@ -48,3 +48,6 @@ else
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
PATH=$VTPATH_OLD
|
PATH=$VTPATH_OLD
|
||||||
|
|
||||||
|
set_ventoy_hook_finish
|
||||||
|
|
||||||
|
|||||||
@@ -67,4 +67,5 @@ fi
|
|||||||
|
|
||||||
if [ -f $VTOY_PATH/ventoy_persistent_map ]; then
|
if [ -f $VTOY_PATH/ventoy_persistent_map ]; then
|
||||||
$SED "1 aexport cow_label=vtoycow" -i /init
|
$SED "1 aexport cow_label=vtoycow" -i /init
|
||||||
|
$SED "/parse.*cmdline/aecho cow_label=vtoycow>>/tmp/cmdline" -i /init
|
||||||
fi
|
fi
|
||||||
|
|||||||
@@ -49,3 +49,6 @@ else
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
PATH=$VTPATH_OLD
|
PATH=$VTPATH_OLD
|
||||||
|
|
||||||
|
set_ventoy_hook_finish
|
||||||
|
|
||||||
|
|||||||
@@ -20,7 +20,7 @@
|
|||||||
. $VTOY_PATH/hook/ventoy-os-lib.sh
|
. $VTOY_PATH/hook/ventoy-os-lib.sh
|
||||||
|
|
||||||
$BUSYBOX_PATH/mkdir /dev
|
$BUSYBOX_PATH/mkdir /dev
|
||||||
$BUSYBOX_PATH/mknod -m 660 /dev/console b 5 1
|
$BUSYBOX_PATH/mknod -m 660 /dev/console c 5 1
|
||||||
|
|
||||||
$SED "/for device in/i $BUSYBOX_PATH/sh $VTOY_PATH/hook/aryalinux/disk_hook.sh" -i /init
|
$SED "/for device in/i $BUSYBOX_PATH/sh $VTOY_PATH/hook/aryalinux/disk_hook.sh" -i /init
|
||||||
#$SED "/for device in/i exec $BUSYBOX_PATH/sh" -i /init
|
#$SED "/for device in/i exec $BUSYBOX_PATH/sh" -i /init
|
||||||
|
|||||||
@@ -52,3 +52,6 @@ ventoy_udev_disk_common_hook "${vtdiskname#/dev/}2"
|
|||||||
# fi
|
# fi
|
||||||
|
|
||||||
PATH=$VTPATH_OLD
|
PATH=$VTPATH_OLD
|
||||||
|
|
||||||
|
|
||||||
|
set_ventoy_hook_finish
|
||||||
|
|||||||
@@ -36,3 +36,6 @@ ventoy_udev_disk_common_hook "${vtdiskname#/dev/}2"
|
|||||||
|
|
||||||
PATH=$VTPATH_OLD
|
PATH=$VTPATH_OLD
|
||||||
|
|
||||||
|
|
||||||
|
set_ventoy_hook_finish
|
||||||
|
|
||||||
|
|||||||
@@ -30,3 +30,6 @@ for i in 0 1 2 3 4 5 6 7 8 9; do
|
|||||||
done
|
done
|
||||||
|
|
||||||
ventoy_udev_disk_common_hook "${vtdiskname#/dev/}2"
|
ventoy_udev_disk_common_hook "${vtdiskname#/dev/}2"
|
||||||
|
|
||||||
|
set_ventoy_hook_finish
|
||||||
|
|
||||||
|
|||||||
@@ -47,3 +47,6 @@ else
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
ventoy_udev_disk_common_hook "${vtdiskname#/dev/}2"
|
ventoy_udev_disk_common_hook "${vtdiskname#/dev/}2"
|
||||||
|
|
||||||
|
set_ventoy_hook_finish
|
||||||
|
|
||||||
|
|||||||
@@ -39,3 +39,6 @@ ventoy_udev_disk_common_hook "${vtdiskname#/dev/}2" "noreplace"
|
|||||||
|
|
||||||
$BUSYBOX_PATH/rm -f /dev/dm-*
|
$BUSYBOX_PATH/rm -f /dev/dm-*
|
||||||
|
|
||||||
|
|
||||||
|
set_ventoy_hook_finish
|
||||||
|
|
||||||
|
|||||||
@@ -119,3 +119,6 @@ fi
|
|||||||
|
|
||||||
PATH=$VTPATH_OLD
|
PATH=$VTPATH_OLD
|
||||||
|
|
||||||
|
|
||||||
|
set_ventoy_hook_finish
|
||||||
|
|
||||||
|
|||||||
43
IMG/cpio/ventoy/hook/debian/devuan-disk.sh
Normal file
43
IMG/cpio/ventoy/hook/debian/devuan-disk.sh
Normal file
@@ -0,0 +1,43 @@
|
|||||||
|
#!/ventoy/busybox/sh
|
||||||
|
#************************************************************************************
|
||||||
|
# Copyright (c) 2020, longpanda <admin@ventoy.net>
|
||||||
|
#
|
||||||
|
# This program is free software; you can redistribute it and/or
|
||||||
|
# modify it under the terms of the GNU General Public License as
|
||||||
|
# published by the Free Software Foundation; either version 3 of the
|
||||||
|
# License, or (at your option) any later version.
|
||||||
|
#
|
||||||
|
# This program is distributed in the hope that it will be useful, but
|
||||||
|
# WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
# General Public License for more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU General Public License
|
||||||
|
# along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||||
|
#
|
||||||
|
#************************************************************************************
|
||||||
|
|
||||||
|
. /ventoy/hook/ventoy-hook-lib.sh
|
||||||
|
|
||||||
|
if is_ventoy_hook_finished; then
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
vtlog "####### $0 $* ########"
|
||||||
|
|
||||||
|
VTPATH_OLD=$PATH; PATH=$BUSYBOX_PATH:$VTOY_PATH/tool:$PATH
|
||||||
|
|
||||||
|
wait_for_usb_disk_ready
|
||||||
|
|
||||||
|
vtdiskname=$(get_ventoy_disk_name)
|
||||||
|
if [ "$vtdiskname" = "unknown" ]; then
|
||||||
|
vtlog "ventoy disk not found"
|
||||||
|
PATH=$VTPATH_OLD
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
ventoy_udev_disk_common_hook "${vtdiskname#/dev/}2"
|
||||||
|
|
||||||
|
PATH=$VTPATH_OLD
|
||||||
|
|
||||||
|
set_ventoy_hook_finish
|
||||||
21
IMG/cpio/ventoy/hook/debian/devuan-hook.sh
Normal file
21
IMG/cpio/ventoy/hook/debian/devuan-hook.sh
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
#!/ventoy/busybox/sh
|
||||||
|
#************************************************************************************
|
||||||
|
# Copyright (c) 2020, longpanda <admin@ventoy.net>
|
||||||
|
#
|
||||||
|
# This program is free software; you can redistribute it and/or
|
||||||
|
# modify it under the terms of the GNU General Public License as
|
||||||
|
# published by the Free Software Foundation; either version 3 of the
|
||||||
|
# License, or (at your option) any later version.
|
||||||
|
#
|
||||||
|
# This program is distributed in the hope that it will be useful, but
|
||||||
|
# WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
# General Public License for more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU General Public License
|
||||||
|
# along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||||
|
#
|
||||||
|
#************************************************************************************
|
||||||
|
|
||||||
|
$SED "/Mount.*cdrom/a\ $BUSYBOX_PATH/sh $VTOY_PATH/hook/debian/devuan-disk.sh" -i /init
|
||||||
|
|
||||||
@@ -41,3 +41,6 @@ fi
|
|||||||
|
|
||||||
PATH=$VTPATH_OLD
|
PATH=$VTPATH_OLD
|
||||||
|
|
||||||
|
|
||||||
|
set_ventoy_hook_finish
|
||||||
|
|
||||||
|
|||||||
@@ -80,3 +80,6 @@ ventoy_os_install_dmsetup $vtdiskname
|
|||||||
ventoy_udev_disk_common_hook "${vtdiskname#/dev/}2" "noreplace"
|
ventoy_udev_disk_common_hook "${vtdiskname#/dev/}2" "noreplace"
|
||||||
|
|
||||||
PATH=$VTPATH_OLD
|
PATH=$VTPATH_OLD
|
||||||
|
|
||||||
|
set_ventoy_hook_finish
|
||||||
|
|
||||||
|
|||||||
@@ -75,3 +75,6 @@ ventoy_udev_disk_common_hook "${vtdiskname#/dev/}2" "noreplace"
|
|||||||
|
|
||||||
PATH=$VTPATH_OLD
|
PATH=$VTPATH_OLD
|
||||||
|
|
||||||
|
|
||||||
|
set_ventoy_hook_finish
|
||||||
|
|
||||||
|
|||||||
@@ -33,11 +33,13 @@ echo "_vtRet1=$_vtRet1 _vtRet2=$_vtRet2 ..." >> $VTLOG
|
|||||||
|
|
||||||
if [ $_vtRet1 -ne 0 -a $_vtRet2 -eq 0 ]; then
|
if [ $_vtRet1 -ne 0 -a $_vtRet2 -eq 0 ]; then
|
||||||
vtFindFlag=0
|
vtFindFlag=0
|
||||||
$GREP '`value from`' /usr/* -r | $AWK -F: '{print $1}' | while read vtline; do
|
$GREP '`value from`' /usr/* -r | $AWK -F: '{print $1}' > $VTOY_PATH/.porteus
|
||||||
|
while read vtline; do
|
||||||
echo "hooking $vtline ..." >> $VTLOG
|
echo "hooking $vtline ..." >> $VTLOG
|
||||||
$SED "s#\`value from\`#$vtPath#g" -i $vtline
|
$SED "s#\`value from\`#$vtPath#g" -i $vtline
|
||||||
vtFindFlag=1
|
vtFindFlag=1
|
||||||
done
|
done < $VTOY_PATH/.porteus
|
||||||
|
rm -f $VTOY_PATH/.porteus
|
||||||
|
|
||||||
if [ $vtFindFlag -eq 0 ]; then
|
if [ $vtFindFlag -eq 0 ]; then
|
||||||
if $GREP -q '`value from`' /linuxrc; then
|
if $GREP -q '`value from`' /linuxrc; then
|
||||||
|
|||||||
@@ -81,3 +81,6 @@ ventoy_udev_disk_common_hook "${vtdiskname#/dev/}2" "noreplace"
|
|||||||
|
|
||||||
PATH=$VTPATH_OLD
|
PATH=$VTPATH_OLD
|
||||||
|
|
||||||
|
|
||||||
|
set_ventoy_hook_finish
|
||||||
|
|
||||||
|
|||||||
25
IMG/cpio/ventoy/hook/debian/truenas-bottom.sh
Normal file
25
IMG/cpio/ventoy/hook/debian/truenas-bottom.sh
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
#!/ventoy/busybox/sh
|
||||||
|
#************************************************************************************
|
||||||
|
# Copyright (c) 2020, longpanda <admin@ventoy.net>
|
||||||
|
#
|
||||||
|
# This program is free software; you can redistribute it and/or
|
||||||
|
# modify it under the terms of the GNU General Public License as
|
||||||
|
# published by the Free Software Foundation; either version 3 of the
|
||||||
|
# License, or (at your option) any later version.
|
||||||
|
#
|
||||||
|
# This program is distributed in the hope that it will be useful, but
|
||||||
|
# WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
# General Public License for more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU General Public License
|
||||||
|
# along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||||
|
#
|
||||||
|
#************************************************************************************
|
||||||
|
|
||||||
|
. /ventoy/hook/ventoy-hook-lib.sh
|
||||||
|
|
||||||
|
vtlog "mount ventoy.iso"
|
||||||
|
mkdir -p /root/cdrom >>$VTLOG 2>&1
|
||||||
|
mount -t iso9660 $VTOY_PATH/mnt/fuse/ventoy.iso /root/cdrom >>$VTLOG 2>&1
|
||||||
|
|
||||||
52
IMG/cpio/ventoy/hook/debian/truenas-disk.sh
Normal file
52
IMG/cpio/ventoy/hook/debian/truenas-disk.sh
Normal file
@@ -0,0 +1,52 @@
|
|||||||
|
#!/ventoy/busybox/sh
|
||||||
|
#************************************************************************************
|
||||||
|
# Copyright (c) 2020, longpanda <admin@ventoy.net>
|
||||||
|
#
|
||||||
|
# This program is free software; you can redistribute it and/or
|
||||||
|
# modify it under the terms of the GNU General Public License as
|
||||||
|
# published by the Free Software Foundation; either version 3 of the
|
||||||
|
# License, or (at your option) any later version.
|
||||||
|
#
|
||||||
|
# This program is distributed in the hope that it will be useful, but
|
||||||
|
# WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
# General Public License for more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU General Public License
|
||||||
|
# along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||||
|
#
|
||||||
|
#************************************************************************************
|
||||||
|
|
||||||
|
. /ventoy/hook/ventoy-hook-lib.sh
|
||||||
|
|
||||||
|
vtlog "####### $0 $* ########"
|
||||||
|
|
||||||
|
VTPATH_OLD=$PATH; PATH=$BUSYBOX_PATH:$VTOY_PATH/tool:$PATH
|
||||||
|
|
||||||
|
|
||||||
|
ventoy_run_fuse() {
|
||||||
|
vtlog "ventoy_run_fuse $*"
|
||||||
|
|
||||||
|
mkdir -p $VTOY_PATH/mnt/fuse $VTOY_PATH/mnt/iso
|
||||||
|
|
||||||
|
vtoydm -p -f $VTOY_PATH/ventoy_image_map -d $1 > $VTOY_PATH/ventoy_dm_table
|
||||||
|
vtoy_fuse_iso -f $VTOY_PATH/ventoy_dm_table -m $VTOY_PATH/mnt/fuse
|
||||||
|
|
||||||
|
mount -t iso9660 $VTOY_PATH/mnt/fuse/ventoy.iso $VTOY_PATH/mnt/iso
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
wait_for_usb_disk_ready
|
||||||
|
|
||||||
|
vtdiskname=$(get_ventoy_disk_name)
|
||||||
|
if [ "$vtdiskname" = "unknown" ]; then
|
||||||
|
vtlog "ventoy disk not found"
|
||||||
|
PATH=$VTPATH_OLD
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
ventoy_run_fuse $vtdiskname
|
||||||
|
|
||||||
|
if [ -f /ventoy/autoinstall ]; then
|
||||||
|
sh /ventoy/hook/default/auto_install_varexp.sh /ventoy/autoinstall
|
||||||
|
fi
|
||||||
27
IMG/cpio/ventoy/hook/debian/truenas-hook.sh
Normal file
27
IMG/cpio/ventoy/hook/debian/truenas-hook.sh
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
#!/ventoy/busybox/sh
|
||||||
|
#************************************************************************************
|
||||||
|
# Copyright (c) 2020, longpanda <admin@ventoy.net>
|
||||||
|
#
|
||||||
|
# This program is free software; you can redistribute it and/or
|
||||||
|
# modify it under the terms of the GNU General Public License as
|
||||||
|
# published by the Free Software Foundation; either version 3 of the
|
||||||
|
# License, or (at your option) any later version.
|
||||||
|
#
|
||||||
|
# This program is distributed in the hope that it will be useful, but
|
||||||
|
# WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
# General Public License for more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU General Public License
|
||||||
|
# along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||||
|
#
|
||||||
|
#************************************************************************************
|
||||||
|
|
||||||
|
if [ -e /init ] && $GREP -q '^mountroot$' /init; then
|
||||||
|
echo "Here before mountroot ..." >> $VTLOG
|
||||||
|
$SED "/^mountroot$/i\\$BUSYBOX_PATH/sh $VTOY_PATH/hook/debian/truenas-disk.sh" -i /init
|
||||||
|
$SED "/^mountroot$/i\\export LIVEMEDIA=/dev/mapper/ventoy" -i /init
|
||||||
|
$SED "/^mountroot$/i\\export LIVE_MEDIA=/dev/mapper/ventoy" -i /init
|
||||||
|
$SED "/^mountroot$/i\\export FROMISO=$VTOY_PATH/mnt/fuse/ventoy.iso" -i /init
|
||||||
|
$SED "/exec *run-init/i\\$BUSYBOX_PATH/sh $VTOY_PATH/hook/debian/truenas-bottom.sh" -i /init
|
||||||
|
fi
|
||||||
@@ -49,6 +49,8 @@ ventoy_get_debian_distro() {
|
|||||||
echo 'mll'; return
|
echo 'mll'; return
|
||||||
elif $GREP -m1 -q 'stratodesk.com' /init; then
|
elif $GREP -m1 -q 'stratodesk.com' /init; then
|
||||||
echo 'stratodesk'; return
|
echo 'stratodesk'; return
|
||||||
|
elif $GREP -q "\bPVE\b" /init; then
|
||||||
|
echo 'pve'; return
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@@ -56,6 +58,9 @@ ventoy_get_debian_distro() {
|
|||||||
if $GREP -q 'Tails' /etc/os-release; then
|
if $GREP -q 'Tails' /etc/os-release; then
|
||||||
echo 'tails'; return
|
echo 'tails'; return
|
||||||
fi
|
fi
|
||||||
|
if $GREP -q 'NAME="Kylin"' /etc/os-release; then
|
||||||
|
echo 'kylin'; return
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if $GREP -q 'slax/' /proc/cmdline; then
|
if $GREP -q 'slax/' /proc/cmdline; then
|
||||||
@@ -108,6 +113,14 @@ ventoy_get_debian_distro() {
|
|||||||
echo 'pyabr'; return
|
echo 'pyabr'; return
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [ -e /devuan-logo.txt ]; then
|
||||||
|
echo 'devuan'; return
|
||||||
|
fi
|
||||||
|
|
||||||
|
if $GREP -q 'truenas' /proc/version; then
|
||||||
|
echo 'truenas'; return
|
||||||
|
fi
|
||||||
|
|
||||||
echo 'default'
|
echo 'default'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -39,3 +39,6 @@ $BUSYBOX_PATH/insmod $vtLoopExDir/dm-mod/$(uname -r)/64/dm-mod.ko
|
|||||||
ventoy_udev_disk_common_hook "${vtdiskname#/dev/}2" "noreplace"
|
ventoy_udev_disk_common_hook "${vtdiskname#/dev/}2" "noreplace"
|
||||||
|
|
||||||
PATH=$VTPATH_OLD
|
PATH=$VTPATH_OLD
|
||||||
|
|
||||||
|
set_ventoy_hook_finish
|
||||||
|
|
||||||
|
|||||||
@@ -84,3 +84,6 @@ cp -a /dev/$vtDM /dev/ventoy
|
|||||||
ln -s /dev/$vtDM /dev/root
|
ln -s /dev/$vtDM /dev/root
|
||||||
|
|
||||||
PATH=$VTPATH_OLD
|
PATH=$VTPATH_OLD
|
||||||
|
|
||||||
|
set_ventoy_hook_finish
|
||||||
|
|
||||||
|
|||||||
75
IMG/cpio/ventoy/hook/ewe/ventoy-disk.sh
Normal file
75
IMG/cpio/ventoy/hook/ewe/ventoy-disk.sh
Normal file
@@ -0,0 +1,75 @@
|
|||||||
|
#!/ventoy/busybox/sh
|
||||||
|
#************************************************************************************
|
||||||
|
# Copyright (c) 2020, longpanda <admin@ventoy.net>
|
||||||
|
#
|
||||||
|
# This program is free software; you can redistribute it and/or
|
||||||
|
# modify it under the terms of the GNU General Public License as
|
||||||
|
# published by the Free Software Foundation; either version 3 of the
|
||||||
|
# License, or (at your option) any later version.
|
||||||
|
#
|
||||||
|
# This program is distributed in the hope that it will be useful, but
|
||||||
|
# WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
# General Public License for more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU General Public License
|
||||||
|
# along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||||
|
#
|
||||||
|
#************************************************************************************
|
||||||
|
|
||||||
|
. /ventoy/hook/ventoy-hook-lib.sh
|
||||||
|
|
||||||
|
vtlog "######### $0 $* ############"
|
||||||
|
|
||||||
|
if is_ventoy_hook_finished; then
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
wait_for_usb_disk_ready
|
||||||
|
|
||||||
|
vtdiskname=$(get_ventoy_disk_name)
|
||||||
|
if [ "$vtdiskname" = "unknown" ]; then
|
||||||
|
vtlog "ventoy disk not found"
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
ventoy_udev_disk_common_hook "${vtdiskname#/dev/}2" "noreplace"
|
||||||
|
|
||||||
|
blkdev_num=$($VTOY_PATH/tool/dmsetup ls | $GREP ventoy | $SED 's/.*(\([0-9][0-9]*\),.*\([0-9][0-9]*\).*/\1:\2/')
|
||||||
|
vtDM=$(ventoy_find_dm_id ${blkdev_num})
|
||||||
|
vtlog "blkdev_num=$blkdev_num vtDM=$vtDM ..."
|
||||||
|
|
||||||
|
while [ -n "Y" ]; do
|
||||||
|
if [ -b /dev/$vtDM ]; then
|
||||||
|
break
|
||||||
|
else
|
||||||
|
sleep 0.3
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
if [ -n "$1" ]; then
|
||||||
|
vtlog "ln -s /dev/$vtDM $1"
|
||||||
|
|
||||||
|
if [ -e "$1" ]; then
|
||||||
|
vtlog "$1 already exist"
|
||||||
|
else
|
||||||
|
ln -s /dev/$vtDM "$1"
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
vtLABEL=$($BUSYBOX_PATH/blkid /dev/$vtDM | $SED 's/.*LABEL="\([^"]*\)".*/\1/')
|
||||||
|
vtlog "vtLABEL is $vtLABEL"
|
||||||
|
|
||||||
|
if [ -z "$vtLABEL" ]; then
|
||||||
|
vtLABEL=$($SED "s/.*label=\([^ ]*\)/\1/" /proc/cmdline)
|
||||||
|
vtlog "vtLABEL is $vtLABEL from cmdline"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -e "/dev/disk/by-label/$vtLABEL" ]; then
|
||||||
|
vtlog "$1 already exist"
|
||||||
|
else
|
||||||
|
ln -s /dev/$vtDM "/dev/disk/by-label/$vtLABEL"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
# OK finish
|
||||||
|
set_ventoy_hook_finish
|
||||||
25
IMG/cpio/ventoy/hook/ewe/ventoy-hook.sh
Normal file
25
IMG/cpio/ventoy/hook/ewe/ventoy-hook.sh
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
#!/ventoy/busybox/sh
|
||||||
|
#************************************************************************************
|
||||||
|
# Copyright (c) 2020, longpanda <admin@ventoy.net>
|
||||||
|
#
|
||||||
|
# This program is free software; you can redistribute it and/or
|
||||||
|
# modify it under the terms of the GNU General Public License as
|
||||||
|
# published by the Free Software Foundation; either version 3 of the
|
||||||
|
# License, or (at your option) any later version.
|
||||||
|
#
|
||||||
|
# This program is distributed in the hope that it will be useful, but
|
||||||
|
# WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
# General Public License for more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU General Public License
|
||||||
|
# along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||||
|
#
|
||||||
|
#************************************************************************************
|
||||||
|
|
||||||
|
. $VTOY_PATH/hook/ventoy-os-lib.sh
|
||||||
|
|
||||||
|
echo "hook live.init" >> $VTLOG
|
||||||
|
|
||||||
|
$SED "1i $BUSYBOX_PATH/sh $VTOY_PATH/hook/ewe/ventoy-disk.sh" -i /lib/tinyramfs/hook.d/live/live.init
|
||||||
|
|
||||||
@@ -34,3 +34,6 @@ for i in 0 1 2 3 4 5 6 7 8 9; do
|
|||||||
done
|
done
|
||||||
|
|
||||||
ventoy_udev_disk_common_hook "${vtdiskname#/dev/}2" "noreplace"
|
ventoy_udev_disk_common_hook "${vtdiskname#/dev/}2" "noreplace"
|
||||||
|
|
||||||
|
set_ventoy_hook_finish
|
||||||
|
|
||||||
|
|||||||
@@ -48,3 +48,6 @@ else
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
PATH=$VTPATH_OLD
|
PATH=$VTPATH_OLD
|
||||||
|
|
||||||
|
set_ventoy_hook_finish
|
||||||
|
|
||||||
|
|||||||
@@ -68,3 +68,6 @@ ventoy_os_install_dmsetup_by_unsquashfs $vtdiskname
|
|||||||
ventoy_udev_disk_common_hook "${vtdiskname#/dev/}2" "noreplace"
|
ventoy_udev_disk_common_hook "${vtdiskname#/dev/}2" "noreplace"
|
||||||
|
|
||||||
PATH=$VTPATH_OLD
|
PATH=$VTPATH_OLD
|
||||||
|
|
||||||
|
set_ventoy_hook_finish
|
||||||
|
|
||||||
|
|||||||
@@ -72,3 +72,6 @@ ventoy_os_install_device_mapper $vtdiskname
|
|||||||
ventoy_udev_disk_common_hook "${vtdiskname#/dev/}2"
|
ventoy_udev_disk_common_hook "${vtdiskname#/dev/}2"
|
||||||
|
|
||||||
PATH=$VTPATH_OLD
|
PATH=$VTPATH_OLD
|
||||||
|
|
||||||
|
set_ventoy_hook_finish
|
||||||
|
|
||||||
|
|||||||
@@ -36,3 +36,6 @@ blkdev_num=$($VTOY_PATH/tool/dmsetup ls | grep ventoy | sed 's/.*(\([0-9][0-9]*\
|
|||||||
mknod -m 0660 /dev/ventoy b $blkdev_num
|
mknod -m 0660 /dev/ventoy b $blkdev_num
|
||||||
|
|
||||||
PATH=$VTPATH_OLD
|
PATH=$VTPATH_OLD
|
||||||
|
|
||||||
|
set_ventoy_hook_finish
|
||||||
|
|
||||||
|
|||||||
@@ -36,3 +36,6 @@ vtDM=$(ventoy_find_dm_id ${blkdev_num})
|
|||||||
echo -n "/dev/$vtDM" > /ventoy/rootdev
|
echo -n "/dev/$vtDM" > /ventoy/rootdev
|
||||||
|
|
||||||
PATH=$VTPATH_OLD
|
PATH=$VTPATH_OLD
|
||||||
|
|
||||||
|
set_ventoy_hook_finish
|
||||||
|
|
||||||
|
|||||||
@@ -36,3 +36,6 @@ blkdev_num=$($VTOY_PATH/tool/dmsetup ls | grep ventoy | sed 's/.*(\([0-9][0-9]*\
|
|||||||
mknod -m 0660 /dev/ventoy b $blkdev_num
|
mknod -m 0660 /dev/ventoy b $blkdev_num
|
||||||
|
|
||||||
PATH=$VTPATH_OLD
|
PATH=$VTPATH_OLD
|
||||||
|
|
||||||
|
set_ventoy_hook_finish
|
||||||
|
|
||||||
|
|||||||
@@ -72,6 +72,12 @@ ventoy_udev_disk_common_hook $* "noreplace"
|
|||||||
|
|
||||||
$BUSYBOX_PATH/mount $VTOY_DM_PATH /mnt/ventoy
|
$BUSYBOX_PATH/mount $VTOY_DM_PATH /mnt/ventoy
|
||||||
|
|
||||||
|
#fix Oracle Linux 6.9 install issue
|
||||||
|
if $GREP -q -i 'Oracle Linux' /mnt/ventoy/.discinfo; then
|
||||||
|
ln -s /mnt/ventoy /mnt/source
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# We do a trick for rhel6 series here.
|
# We do a trick for rhel6 series here.
|
||||||
# Use /dev/$vtCheatLoop and wapper it as a removable cdrom with bind mount.
|
# Use /dev/$vtCheatLoop and wapper it as a removable cdrom with bind mount.
|
||||||
|
|||||||
@@ -33,3 +33,6 @@ fi
|
|||||||
ventoy_udev_disk_common_hook "${vtdiskname#/dev/}2" "noreplace"
|
ventoy_udev_disk_common_hook "${vtdiskname#/dev/}2" "noreplace"
|
||||||
|
|
||||||
PATH=$VTPATH_OLD
|
PATH=$VTPATH_OLD
|
||||||
|
|
||||||
|
set_ventoy_hook_finish
|
||||||
|
|
||||||
|
|||||||
@@ -40,3 +40,6 @@ mknod -m 660 /dev/ventoy b $blkdev_num
|
|||||||
echo "/dev/ventoy" > cdrom.hint
|
echo "/dev/ventoy" > cdrom.hint
|
||||||
|
|
||||||
PATH=$VTPATH_OLD
|
PATH=$VTPATH_OLD
|
||||||
|
|
||||||
|
set_ventoy_hook_finish
|
||||||
|
|
||||||
|
|||||||
@@ -50,3 +50,6 @@ if [ "$1" = "fakecdrom" ]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
PATH=$VTPATH_OLD
|
PATH=$VTPATH_OLD
|
||||||
|
|
||||||
|
set_ventoy_hook_finish
|
||||||
|
|
||||||
|
|||||||
@@ -63,3 +63,6 @@ blkdev_num=$($VTOY_PATH/tool/dmsetup ls | grep ventoy | sed 's/.*(\([0-9][0-9]*\
|
|||||||
mknod -m 0660 /dev/ventoy b $blkdev_num
|
mknod -m 0660 /dev/ventoy b $blkdev_num
|
||||||
|
|
||||||
PATH=$VTPATH_OLD
|
PATH=$VTPATH_OLD
|
||||||
|
|
||||||
|
set_ventoy_hook_finish
|
||||||
|
|
||||||
|
|||||||
@@ -26,6 +26,12 @@ if [ -f $VTOY_PATH/autoinstall ]; then
|
|||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if $GREP -q 'rdinit=/vtoy/vtoy' /proc/cmdline; then
|
||||||
|
echo "remove rdinit param" >> $VTLOG
|
||||||
|
echo "ptoptions=+rdinit" >> /linuxrc.config
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
if $BUSYBOX_PATH/ls $VTOY_PATH | $GREP -q 'ventoy_dud[0-9]'; then
|
if $BUSYBOX_PATH/ls $VTOY_PATH | $GREP -q 'ventoy_dud[0-9]'; then
|
||||||
if [ -f /linuxrc.config ]; then
|
if [ -f /linuxrc.config ]; then
|
||||||
vtKerVer=$($BUSYBOX_PATH/uname -r)
|
vtKerVer=$($BUSYBOX_PATH/uname -r)
|
||||||
@@ -60,7 +66,7 @@ fi
|
|||||||
if [ -e /etc/initrd.functions ] && $GREP -q 'HPIP' /etc/initrd.functions; then
|
if [ -e /etc/initrd.functions ] && $GREP -q 'HPIP' /etc/initrd.functions; then
|
||||||
echo "HPIP" >> $VTLOG
|
echo "HPIP" >> $VTLOG
|
||||||
$BUSYBOX_PATH/mkdir /dev
|
$BUSYBOX_PATH/mkdir /dev
|
||||||
$BUSYBOX_PATH/mknod -m 660 /dev/console b 5 1
|
$BUSYBOX_PATH/mknod -m 660 /dev/console c 5 1
|
||||||
$SED "/CD_DEVICES=/a $BUSYBOX_PATH/sh $VTOY_PATH/hook/suse/disk_hook.sh" -i /etc/initrd.functions
|
$SED "/CD_DEVICES=/a $BUSYBOX_PATH/sh $VTOY_PATH/hook/suse/disk_hook.sh" -i /etc/initrd.functions
|
||||||
$SED "/CD_DEVICES=/a CD_DEVICES=\"/dev/ventoy \$CD_DEVICES\"" -i /etc/initrd.functions
|
$SED "/CD_DEVICES=/a CD_DEVICES=\"/dev/ventoy \$CD_DEVICES\"" -i /etc/initrd.functions
|
||||||
elif [ -f /scripts/udev_setup ]; then
|
elif [ -f /scripts/udev_setup ]; then
|
||||||
|
|||||||
@@ -25,7 +25,19 @@ fi
|
|||||||
|
|
||||||
VTPATH_OLD=$PATH; PATH=$BUSYBOX_PATH:$VTOY_PATH/tool:$PATH
|
VTPATH_OLD=$PATH; PATH=$BUSYBOX_PATH:$VTOY_PATH/tool:$PATH
|
||||||
|
|
||||||
modprobe dm-mod
|
vtlog "Loading dax and dm-mod module ..."
|
||||||
|
$BUSYBOX_PATH/modprobe dax > /dev/null 2>&1
|
||||||
|
$BUSYBOX_PATH/modprobe dm-mod > /dev/null 2>&1
|
||||||
|
|
||||||
|
if $GREP -q 'device-mapper' /proc/devices; then
|
||||||
|
vtlog "dm-mod module check success ..."
|
||||||
|
else
|
||||||
|
vtlog "Need to extract dax and dm-mod module ..."
|
||||||
|
$VTOY_PATH/tool/zstdcat /lib/modules/$(uname -r)/drivers/dax/dax.ko.zst > $VTOY_PATH/extract_dax.ko
|
||||||
|
$BUSYBOX_PATH/insmod $VTOY_PATH/extract_dax.ko
|
||||||
|
$VTOY_PATH/tool/zstdcat /lib/modules/$(uname -r)/drivers/md/dm-mod.ko.zst > $VTOY_PATH/extract_dm_mod.ko
|
||||||
|
$BUSYBOX_PATH/insmod $VTOY_PATH/extract_dm_mod.ko
|
||||||
|
fi
|
||||||
|
|
||||||
wait_for_usb_disk_ready
|
wait_for_usb_disk_ready
|
||||||
|
|
||||||
|
|||||||
@@ -19,6 +19,8 @@
|
|||||||
|
|
||||||
. $VTOY_PATH/hook/ventoy-os-lib.sh
|
. $VTOY_PATH/hook/ventoy-os-lib.sh
|
||||||
|
|
||||||
|
$SED "/Searching/i $BUSYBOX_PATH/sh $VTOY_PATH/hook/t2/disk_hook.sh" -i /init
|
||||||
|
$SED "/disktype/i x=/dev/ventoy" -i /init
|
||||||
$SED "/getdevice *devicefile/i $BUSYBOX_PATH/sh $VTOY_PATH/hook/t2/disk_hook.sh" -i /init
|
$SED "/getdevice *devicefile/i $BUSYBOX_PATH/sh $VTOY_PATH/hook/t2/disk_hook.sh" -i /init
|
||||||
$SED "/getdevice *devicefile/a devicefile=/dev/ventoy" -i /init
|
$SED "/getdevice *devicefile/a devicefile=/dev/ventoy" -i /init
|
||||||
|
|
||||||
|
|||||||
@@ -45,6 +45,13 @@ fi
|
|||||||
# TinyCore linux distro doesn't contain dmsetup, we use aoe here
|
# TinyCore linux distro doesn't contain dmsetup, we use aoe here
|
||||||
sudo modprobe aoe aoe_iflist=lo
|
sudo modprobe aoe aoe_iflist=lo
|
||||||
if [ -e /sys/module/aoe ]; then
|
if [ -e /sys/module/aoe ]; then
|
||||||
|
|
||||||
|
if ! [ -d /lib64 ]; then
|
||||||
|
vtlog "link lib64"
|
||||||
|
NEED_UNLIB64=1
|
||||||
|
ln -s /lib /lib64
|
||||||
|
fi
|
||||||
|
|
||||||
VBLADE_BIN=$(ventoy_get_vblade_bin)
|
VBLADE_BIN=$(ventoy_get_vblade_bin)
|
||||||
|
|
||||||
sudo nohup $VBLADE_BIN -r -f $VTOY_PATH/ventoy_image_map 9 0 lo "$vtdiskname" > /dev/null &
|
sudo nohup $VBLADE_BIN -r -f $VTOY_PATH/ventoy_image_map 9 0 lo "$vtdiskname" > /dev/null &
|
||||||
@@ -57,6 +64,11 @@ if [ -e /sys/module/aoe ]; then
|
|||||||
|
|
||||||
sudo cp -a /dev/etherd/e9.0 "$vPart"
|
sudo cp -a /dev/etherd/e9.0 "$vPart"
|
||||||
|
|
||||||
|
if [ -n "$NEED_UNLIB64" ]; then
|
||||||
|
vtlog "unlink lib64"
|
||||||
|
unlink /lib64
|
||||||
|
fi
|
||||||
|
|
||||||
ventoy_find_bin_run rebuildfstab
|
ventoy_find_bin_run rebuildfstab
|
||||||
else
|
else
|
||||||
vterr "aoe driver module load failed..."
|
vterr "aoe driver module load failed..."
|
||||||
|
|||||||
@@ -64,6 +64,15 @@ is_ventoy_hook_finished() {
|
|||||||
|
|
||||||
set_ventoy_hook_finish() {
|
set_ventoy_hook_finish() {
|
||||||
echo 'Y' > $VTOY_PATH/hook_finish
|
echo 'Y' > $VTOY_PATH/hook_finish
|
||||||
|
|
||||||
|
if [ -f /ventoy/ventoy_iso_part_dm_cmd ]; then
|
||||||
|
echo "### create iso part raw dm" >> $VTLOG
|
||||||
|
$CAT $VTOY_PATH/ventoy_raw_table >> $VTLOG
|
||||||
|
echo "### iso part dm cmd" >> $VTLOG
|
||||||
|
$CAT /ventoy/ventoy_iso_part_dm_cmd >> $VTLOG
|
||||||
|
$BUSYBOX_PATH/sh /ventoy/ventoy_iso_part_dm_cmd >>$VTLOG 2>&1
|
||||||
|
#$BUSYBOX_PATH/rm -f /ventoy/ventoy_iso_part_dm_cmd
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
get_ventoy_disk_name() {
|
get_ventoy_disk_name() {
|
||||||
@@ -154,10 +163,10 @@ ventoy_get_vblade_bin() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ventoy_find_bin_path() {
|
ventoy_find_bin_path() {
|
||||||
|
#must use built-in dmsetup, so first try ventoy path. Otherwise ubuntu installer unhappy. #3567
|
||||||
if $BUSYBOX_PATH/which "$1" > /dev/null; then
|
if $BUSYBOX_PATH/which "$1" > /dev/null; then
|
||||||
$BUSYBOX_PATH/which "$1"; return
|
$BUSYBOX_PATH/which "$1"; return
|
||||||
fi
|
fi
|
||||||
|
|
||||||
for vt_path in '/bin' '/sbin' '/usr/bin' '/usr/sbin' '/usr/local/bin' '/usr/local/sbin' '/root/bin'; do
|
for vt_path in '/bin' '/sbin' '/usr/bin' '/usr/sbin' '/usr/local/bin' '/usr/local/sbin' '/root/bin'; do
|
||||||
if [ -e "$vt_path/$1" ]; then
|
if [ -e "$vt_path/$1" ]; then
|
||||||
echo "$vt_path/$1"; return
|
echo "$vt_path/$1"; return
|
||||||
@@ -232,230 +241,6 @@ ventoy_check_dm_module() {
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
ventoy_need_proc_ibt() {
|
|
||||||
vtKv=$($BUSYBOX_PATH/uname -r)
|
|
||||||
vtMajor=$(echo $vtKv | $AWK -F. '{print $1}')
|
|
||||||
vtMinor=$(echo $vtKv | $AWK -F. '{print $2}')
|
|
||||||
|
|
||||||
#ibt was supported since linux kernel 5.18
|
|
||||||
if [ $vtMajor -lt 5 ]; then
|
|
||||||
$BUSYBOX_PATH/false; return
|
|
||||||
elif [ $vtMajor -eq 5 ]; then
|
|
||||||
if [ $vtMajor -lt 18 ]; then
|
|
||||||
$BUSYBOX_PATH/false; return
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
if $GREP -q ' ibt=off' /proc/cmdline; then
|
|
||||||
$BUSYBOX_PATH/false; return
|
|
||||||
fi
|
|
||||||
|
|
||||||
#hardware CPU doesn't support IBT
|
|
||||||
if $VTOY_PATH/tool/vtoykmod -I; then
|
|
||||||
:
|
|
||||||
else
|
|
||||||
$BUSYBOX_PATH/false; return
|
|
||||||
fi
|
|
||||||
|
|
||||||
#dot.CONFIG not enabled
|
|
||||||
if $GREP -q ' ibt_restore$' /proc/kallsyms; then
|
|
||||||
:
|
|
||||||
else
|
|
||||||
$BUSYBOX_PATH/false; return
|
|
||||||
fi
|
|
||||||
|
|
||||||
$BUSYBOX_PATH/true
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
ventoy_need_dm_patch() {
|
|
||||||
if [ "$VTOY_LINUX_REMOUNT" != "01" ]; then
|
|
||||||
if $GREP -q 'VTOY_LINUX_REMOUNT=1' /proc/cmdline; then
|
|
||||||
:
|
|
||||||
else
|
|
||||||
$BUSYBOX_PATH/false; return
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
if $GREP -q 'device-mapper' /proc/devices; then
|
|
||||||
:
|
|
||||||
else
|
|
||||||
$BUSYBOX_PATH/false; return
|
|
||||||
fi
|
|
||||||
|
|
||||||
if $GREP -q 'dm_patch' /proc/modules; then
|
|
||||||
$BUSYBOX_PATH/false; return
|
|
||||||
fi
|
|
||||||
|
|
||||||
vtMajorVer=$($BUSYBOX_PATH/uname -r | $AWK -F. '{print $1}')
|
|
||||||
vtMinorVer=$($BUSYBOX_PATH/uname -r | $AWK -F. '{print $2}')
|
|
||||||
|
|
||||||
if [ $vtMajorVer -lt 3 ]; then
|
|
||||||
$BUSYBOX_PATH/false; return
|
|
||||||
elif [ $vtMajorVer -eq 3 -a $vtMinorVer -lt 10 ]; then
|
|
||||||
$BUSYBOX_PATH/false; return
|
|
||||||
fi
|
|
||||||
|
|
||||||
|
|
||||||
$BUSYBOX_PATH/true
|
|
||||||
}
|
|
||||||
|
|
||||||
ventoy_dm_patch() {
|
|
||||||
vtDmPatchDebug=0
|
|
||||||
vtMType=$($BUSYBOX_PATH/uname -m)
|
|
||||||
|
|
||||||
vtlog "######### ventoy_dm_patch ############"
|
|
||||||
|
|
||||||
if echo $vtMType | $EGREP -i -q "x86.64|amd64"; then
|
|
||||||
vtKoName=dm_patch_64.ko
|
|
||||||
elif echo $vtMType | $EGREP -i -q "i[3-6]86"; then
|
|
||||||
vtKoName=dm_patch_32.ko
|
|
||||||
else
|
|
||||||
vtlog "unsupported machine type $vtMType"
|
|
||||||
return
|
|
||||||
fi
|
|
||||||
|
|
||||||
if ventoy_need_proc_ibt; then
|
|
||||||
vtlog "need to proc IBT"
|
|
||||||
vtKoName=dm_patch_ibt_64.ko
|
|
||||||
vtIBT='0x8888'
|
|
||||||
else
|
|
||||||
vtlog "NO need to proc IBT"
|
|
||||||
vtIBT='0'
|
|
||||||
fi
|
|
||||||
|
|
||||||
|
|
||||||
if [ -f $VTOY_PATH/tool/$vtKoName ]; then
|
|
||||||
vtlog "/ventoy/tool/$vtKoName exist OK"
|
|
||||||
else
|
|
||||||
vtlog "/ventoy/tool/$vtKoName NOT exist"
|
|
||||||
return
|
|
||||||
fi
|
|
||||||
|
|
||||||
$CAT /proc/kallsyms | $BUSYBOX_PATH/sort > $VTOY_PATH/kallsyms
|
|
||||||
|
|
||||||
if $GREP -m1 -q 'open_table_device.isra' $VTOY_PATH/kallsyms; then
|
|
||||||
vtLine=$($VTOY_PATH/tool/vtoyksym open_table_device.isra $VTOY_PATH/kallsyms)
|
|
||||||
vtlog "get open_table_device.isra address $vtLine"
|
|
||||||
else
|
|
||||||
vtLine=$($VTOY_PATH/tool/vtoyksym dm_get_table_device $VTOY_PATH/kallsyms)
|
|
||||||
vtlog "get dm_get_table_device address $vtLine"
|
|
||||||
fi
|
|
||||||
get_addr=$(echo $vtLine | $AWK '{print $1}')
|
|
||||||
get_size=$(echo $vtLine | $AWK '{print $2}')
|
|
||||||
|
|
||||||
if $GREP -m1 -q 'close_table_device.isra' $VTOY_PATH/kallsyms; then
|
|
||||||
vtLine=$($VTOY_PATH/tool/vtoyksym close_table_device.isra $VTOY_PATH/kallsyms)
|
|
||||||
vtlog "get close_table_device.isra address $vtLine"
|
|
||||||
else
|
|
||||||
vtLine=$($VTOY_PATH/tool/vtoyksym dm_put_table_device $VTOY_PATH/kallsyms)
|
|
||||||
vtlog "get dm_put_table_device address $vtLine"
|
|
||||||
fi
|
|
||||||
put_addr=$(echo $vtLine | $AWK '{print $1}')
|
|
||||||
put_size=$(echo $vtLine | $AWK '{print $2}')
|
|
||||||
|
|
||||||
ro_addr=$($GREP ' set_memory_ro$' /proc/kallsyms | $AWK '{print $1}')
|
|
||||||
rw_addr=$($GREP ' set_memory_rw$' /proc/kallsyms | $AWK '{print $1}')
|
|
||||||
kprobe_reg_addr=$($GREP ' register_kprobe$' /proc/kallsyms | $AWK '{print $1}')
|
|
||||||
kprobe_unreg_addr=$($GREP ' unregister_kprobe$' /proc/kallsyms | $AWK '{print $1}')
|
|
||||||
|
|
||||||
if [ "$VTOY_DEBUG_LEVEL" = "01" ]; then
|
|
||||||
vtDmPatchDebug=1
|
|
||||||
fi
|
|
||||||
|
|
||||||
if $GREP -q 'dmpatch_debug' /proc/cmdline; then
|
|
||||||
vtDmPatchDebug=1
|
|
||||||
fi
|
|
||||||
|
|
||||||
|
|
||||||
if [ $vtDmPatchDebug -eq 1 ]; then
|
|
||||||
printk_addr=$($GREP ' printk$' /proc/kallsyms | $AWK '{print $1}')
|
|
||||||
if [ -z "$printk_addr" ]; then
|
|
||||||
printk_addr=$($GREP ' _printk$' /proc/kallsyms | $AWK '{print $1}')
|
|
||||||
fi
|
|
||||||
vtDebug="-v"
|
|
||||||
else
|
|
||||||
printk_addr=0
|
|
||||||
fi
|
|
||||||
|
|
||||||
#printk_addr=$($GREP ' printk$' /proc/kallsyms | $AWK '{print $1}')
|
|
||||||
#vtDebug="-v"
|
|
||||||
|
|
||||||
vtlog get_addr=$get_addr get_size=$get_size
|
|
||||||
vtlog put_addr=$put_addr put_size=$put_size
|
|
||||||
vtlog kprobe_reg_addr=$kprobe_reg_addr kprobe_unreg_addr=$kprobe_unreg_addr
|
|
||||||
vtlog ro_addr=$ro_addr rw_addr=$rw_addr printk_addr=$printk_addr
|
|
||||||
|
|
||||||
if [ "$get_addr" = "0" -o "$put_addr" = "0" ]; then
|
|
||||||
vtlog "Invalid symbol address"
|
|
||||||
return
|
|
||||||
fi
|
|
||||||
if [ "$ro_addr" = "0" -o "$rw_addr" = "0" ]; then
|
|
||||||
vtlog "Invalid symbol address"
|
|
||||||
return
|
|
||||||
fi
|
|
||||||
|
|
||||||
|
|
||||||
vtKv=$($BUSYBOX_PATH/uname -r)
|
|
||||||
|
|
||||||
if [ ! -d /lib/modules/$vtKv ]; then
|
|
||||||
vtlog "No modules directory found"
|
|
||||||
return
|
|
||||||
elif [ -d /lib/modules/$vtKv/kernel/fs ]; then
|
|
||||||
vtModPath=$($FIND /lib/modules/$vtKv/kernel/fs/ -name "*.ko*" | $HEAD -n1)
|
|
||||||
elif [ -d /lib/modules/$vtKv/kernel ]; then
|
|
||||||
vtModPath=$($FIND /lib/modules/$vtKv/kernel/ -name "xfs.ko*" | $HEAD -n1)
|
|
||||||
elif [ -d /lib/modules/$vtKv/initrd ]; then
|
|
||||||
vtModPath=$($FIND /lib/modules/$vtKv/initrd/ -name "xfs.ko*" | $HEAD -n1)
|
|
||||||
fi
|
|
||||||
|
|
||||||
|
|
||||||
if [ -z "$vtModPath" ]; then
|
|
||||||
vtModPath=$($FIND /lib/modules/$vtKv/ -name "*.ko*" | $HEAD -n1)
|
|
||||||
fi
|
|
||||||
|
|
||||||
vtModName=$($BUSYBOX_PATH/basename $vtModPath)
|
|
||||||
|
|
||||||
vtlog "template module is $vtModPath $vtModName"
|
|
||||||
|
|
||||||
if [ -z "$vtModPath" ]; then
|
|
||||||
vtlog "No template module found"
|
|
||||||
return
|
|
||||||
elif echo $vtModPath | $GREP -q "[.]ko$"; then
|
|
||||||
$BUSYBOX_PATH/cp -a $vtModPath $VTOY_PATH/$vtModName
|
|
||||||
elif echo $vtModPath | $GREP -q "[.]ko[.]xz$"; then
|
|
||||||
$BUSYBOX_PATH/xzcat $vtModPath > $VTOY_PATH/$vtModName
|
|
||||||
elif echo $vtModPath | $GREP -q "[.]ko[.]gz$"; then
|
|
||||||
$BUSYBOX_PATH/zcat $vtModPath > $VTOY_PATH/$vtModName
|
|
||||||
elif echo $vtModPath | $GREP -q "[.]ko[.]zst$"; then
|
|
||||||
$VTOY_PATH/tool/zstdcat $vtModPath > $VTOY_PATH/$vtModName
|
|
||||||
else
|
|
||||||
vtlog "unsupport module type"
|
|
||||||
return
|
|
||||||
fi
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#step1: modify vermagic/mod crc/relocation
|
|
||||||
vtlog "$VTOY_PATH/tool/vtoykmod -u $VTOY_PATH/tool/$vtKoName $VTOY_PATH/$vtModName $vtDebug"
|
|
||||||
$VTOY_PATH/tool/vtoykmod -u $VTOY_PATH/tool/$vtKoName $VTOY_PATH/$vtModName $vtDebug >>$VTLOG 2>&1
|
|
||||||
|
|
||||||
#step2: fill parameters
|
|
||||||
vtPgsize=$($VTOY_PATH/tool/vtoyksym -p)
|
|
||||||
vtlog "$VTOY_PATH/tool/vtoykmod -f $VTOY_PATH/tool/$vtKoName $vtPgsize 0x$printk_addr 0x$ro_addr 0x$rw_addr $get_addr $get_size $put_addr $put_size 0x$kprobe_reg_addr 0x$kprobe_unreg_addr $vtKv $vtIBT $vtDebug"
|
|
||||||
$VTOY_PATH/tool/vtoykmod -f $VTOY_PATH/tool/$vtKoName $vtPgsize 0x$printk_addr 0x$ro_addr 0x$rw_addr $get_addr $get_size $put_addr $put_size 0x$kprobe_reg_addr 0x$kprobe_unreg_addr $vtKv $vtIBT $vtDebug >>$VTLOG 2>&1
|
|
||||||
|
|
||||||
vtlog "insmod $VTOY_PATH/tool/$vtKoName"
|
|
||||||
$BUSYBOX_PATH/insmod $VTOY_PATH/tool/$vtKoName >>$VTLOG 2>&1
|
|
||||||
|
|
||||||
if $GREP -q 'dm_patch' /proc/modules; then
|
|
||||||
vtlog "dm_patch module OK"
|
|
||||||
echo "done" > $VTOY_PATH/dm_patch_done
|
|
||||||
else
|
|
||||||
vtlog "dm_patch module FAILED"
|
|
||||||
fi
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
create_ventoy_device_mapper() {
|
create_ventoy_device_mapper() {
|
||||||
vtlog "create_ventoy_device_mapper $*"
|
vtlog "create_ventoy_device_mapper $*"
|
||||||
@@ -475,17 +260,7 @@ create_ventoy_device_mapper() {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
$VTOY_PATH/tool/vtoydm -p -f $VTOY_PATH/ventoy_image_map -d $1 > $VTOY_PATH/ventoy_dm_table
|
$VTOY_PATH/tool/vtoydm -p -f $VTOY_PATH/ventoy_image_map -d $1 > $VTOY_PATH/ventoy_dm_table
|
||||||
|
$VTOY_PATH/tool/vtoydm -r -f $VTOY_PATH/ventoy_image_map -d $1 > $VTOY_PATH/ventoy_raw_table
|
||||||
|
|
||||||
vtLevel1=$($CAT /proc/sys/kernel/printk | $AWK '{print $1}')
|
|
||||||
vtLevel2=$($CAT /proc/sys/kernel/printk | $AWK '{print $2}')
|
|
||||||
vtLevel3=$($CAT /proc/sys/kernel/printk | $AWK '{print $3}')
|
|
||||||
vtLevel4=$($CAT /proc/sys/kernel/printk | $AWK '{print $4}')
|
|
||||||
if ventoy_need_dm_patch; then
|
|
||||||
ventoy_dm_patch
|
|
||||||
#suppress printk message
|
|
||||||
echo 0 $vtLevel2 0 $vtLevel4 > /proc/sys/kernel/printk
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ -z "$2" ]; then
|
if [ -z "$2" ]; then
|
||||||
$VT_DM_BIN create ventoy $VTOY_PATH/ventoy_dm_table >>$VTLOG 2>&1
|
$VT_DM_BIN create ventoy $VTOY_PATH/ventoy_dm_table >>$VTLOG 2>&1
|
||||||
@@ -493,10 +268,10 @@ create_ventoy_device_mapper() {
|
|||||||
$VT_DM_BIN "$2" create ventoy $VTOY_PATH/ventoy_dm_table >>$VTLOG 2>&1
|
$VT_DM_BIN "$2" create ventoy $VTOY_PATH/ventoy_dm_table >>$VTLOG 2>&1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if ventoy_need_dm_patch; then
|
RAWDISKNAME=$($HEAD -n1 $VTOY_PATH/ventoy_raw_table | $AWK '{print $4}')
|
||||||
#recover printk level
|
echo "$VT_DM_BIN create ${RAWDISKNAME#/dev/} $VTOY_PATH/ventoy_raw_table" > /ventoy/ventoy_iso_part_dm_cmd
|
||||||
echo $vtLevel1 $vtLevel2 $vtLevel3 $vtLevel4 > /proc/sys/kernel/printk
|
#echo "$VT_DM_BIN mknodes ${RAWDISKNAME#/dev/}" >> /ventoy/ventoy_iso_part_dm_cmd
|
||||||
fi
|
#echo "$VT_DM_BIN ls" >> /ventoy/ventoy_iso_part_dm_cmd
|
||||||
}
|
}
|
||||||
|
|
||||||
create_persistent_device_mapper() {
|
create_persistent_device_mapper() {
|
||||||
@@ -517,23 +292,7 @@ create_persistent_device_mapper() {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
$VTOY_PATH/tool/vtoydm -p -f $VTOY_PATH/ventoy_persistent_map -d $1 > $VTOY_PATH/persistent_dm_table
|
$VTOY_PATH/tool/vtoydm -p -f $VTOY_PATH/ventoy_persistent_map -d $1 > $VTOY_PATH/persistent_dm_table
|
||||||
|
|
||||||
|
|
||||||
vtLevel1=$($CAT /proc/sys/kernel/printk | $AWK '{print $1}')
|
|
||||||
vtLevel2=$($CAT /proc/sys/kernel/printk | $AWK '{print $2}')
|
|
||||||
vtLevel3=$($CAT /proc/sys/kernel/printk | $AWK '{print $3}')
|
|
||||||
vtLevel4=$($CAT /proc/sys/kernel/printk | $AWK '{print $4}')
|
|
||||||
if [ -f $VTOY_PATH/dm_patch_done ]; then
|
|
||||||
#suppress printk message
|
|
||||||
echo 0 $vtLevel2 0 $vtLevel4 > /proc/sys/kernel/printk
|
|
||||||
fi
|
|
||||||
|
|
||||||
$VT_DM_BIN create vtoy_persistent $VTOY_PATH/persistent_dm_table >>$VTLOG 2>&1
|
$VT_DM_BIN create vtoy_persistent $VTOY_PATH/persistent_dm_table >>$VTLOG 2>&1
|
||||||
|
|
||||||
if [ -f $VTOY_PATH/dm_patch_done ]; then
|
|
||||||
#recover printk level
|
|
||||||
echo $vtLevel1 $vtLevel2 $vtLevel3 $vtLevel4 > /proc/sys/kernel/printk
|
|
||||||
fi
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -827,11 +586,6 @@ ventoy_udev_disk_common_hook() {
|
|||||||
create_persistent_device_mapper "/dev/$VTDISK"
|
create_persistent_device_mapper "/dev/$VTDISK"
|
||||||
ventoy_create_persistent_link
|
ventoy_create_persistent_link
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if $GREP -q 'dm_patch' /proc/modules; then
|
|
||||||
vtlog "remove dm_patch module."
|
|
||||||
$BUSYBOX_PATH/rmmod dm_patch
|
|
||||||
fi
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ventoy_create_dev_ventoy_part() {
|
ventoy_create_dev_ventoy_part() {
|
||||||
@@ -840,16 +594,6 @@ ventoy_create_dev_ventoy_part() {
|
|||||||
|
|
||||||
if [ -e /vtoy_dm_table ]; then
|
if [ -e /vtoy_dm_table ]; then
|
||||||
vtPartid=1
|
vtPartid=1
|
||||||
|
|
||||||
vtLevel1=$($CAT /proc/sys/kernel/printk | $AWK '{print $1}')
|
|
||||||
vtLevel2=$($CAT /proc/sys/kernel/printk | $AWK '{print $2}')
|
|
||||||
vtLevel3=$($CAT /proc/sys/kernel/printk | $AWK '{print $3}')
|
|
||||||
vtLevel4=$($CAT /proc/sys/kernel/printk | $AWK '{print $4}')
|
|
||||||
if [ -f $VTOY_PATH/dm_patch_done ]; then
|
|
||||||
#suppress printk message
|
|
||||||
echo 0 $vtLevel2 0 $vtLevel4 > /proc/sys/kernel/printk
|
|
||||||
fi
|
|
||||||
|
|
||||||
$CAT /vtoy_dm_table | while read vtline; do
|
$CAT /vtoy_dm_table | while read vtline; do
|
||||||
echo $vtline > /ventoy/dm_table_part${vtPartid}
|
echo $vtline > /ventoy/dm_table_part${vtPartid}
|
||||||
$VTOY_PATH/tool/dmsetup create ventoy${vtPartid} /ventoy/dm_table_part${vtPartid}
|
$VTOY_PATH/tool/dmsetup create ventoy${vtPartid} /ventoy/dm_table_part${vtPartid}
|
||||||
@@ -859,11 +603,6 @@ ventoy_create_dev_ventoy_part() {
|
|||||||
|
|
||||||
vtPartid=$(expr $vtPartid + 1)
|
vtPartid=$(expr $vtPartid + 1)
|
||||||
done
|
done
|
||||||
|
|
||||||
if [ -f $VTOY_PATH/dm_patch_done ]; then
|
|
||||||
#recover printk level
|
|
||||||
echo $vtLevel1 $vtLevel2 $vtLevel3 $vtLevel4 > /proc/sys/kernel/printk
|
|
||||||
fi
|
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -46,3 +46,6 @@ done
|
|||||||
|
|
||||||
|
|
||||||
PATH=$VTPATH_OLD
|
PATH=$VTPATH_OLD
|
||||||
|
|
||||||
|
set_ventoy_hook_finish
|
||||||
|
|
||||||
|
|||||||
@@ -40,3 +40,6 @@ if ! [ -e $VTOY_DM_PATH ]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
PATH=$VTPATH_OLD
|
PATH=$VTPATH_OLD
|
||||||
|
|
||||||
|
set_ventoy_hook_finish
|
||||||
|
|
||||||
|
|||||||
@@ -73,25 +73,27 @@ ventoy_unpack_initramfs() {
|
|||||||
for vtx in '1F8B zcat' '1F9E zcat' '425A bzcat' '5D00 lzcat' 'FD37 xzcat' '894C lzopcat' '0221 lz4cat' '28B5 zstdcat' '3037 cat' '4C5A lunzip -c'; do
|
for vtx in '1F8B zcat' '1F9E zcat' '425A bzcat' '5D00 lzcat' 'FD37 xzcat' '894C lzopcat' '0221 lz4cat' '28B5 zstdcat' '3037 cat' '4C5A lunzip -c'; do
|
||||||
if [ "${vtx:0:4}" = "${vtmagic:0:4}" ]; then
|
if [ "${vtx:0:4}" = "${vtmagic:0:4}" ]; then
|
||||||
echo "vtx=$vtx" >> $VTLOG
|
echo "vtx=$vtx" >> $VTLOG
|
||||||
if [ $vtskip -eq 0 ]; then
|
if [ $vtskip -ne 0 ]; then
|
||||||
if [ "${vtx:5}" = "xzcat" ]; then
|
dd if=$vtfile skip=$vtskip iflag=skip_bytes status=none > ${vtfile}.skip
|
||||||
rm -f $VTOY_PATH/xzlog
|
rm -f $vtfile
|
||||||
${vtx:5} $vtfile 2> $VTOY_PATH/xzlog | (cpio -idmu 2>>$VTLOG; cat > $vttmp)
|
mv ${vtfile}.skip $vtfile
|
||||||
if grep -q 'corrupted data' $VTOY_PATH/xzlog; then
|
fi
|
||||||
echo 'xzcat failed, now try xzminidec...' >> $VTLOG
|
|
||||||
rm -f $VTOY_PATH/xzlog
|
|
||||||
cat $vtfile | xzminidec 2> $VTOY_PATH/xzlog | (cpio -idmu 2>>$VTLOG; cat > $vttmp)
|
|
||||||
|
|
||||||
if grep -q 'limit' $VTOY_PATH/xzlog; then
|
if [ "${vtx:5}" = "xzcat" ]; then
|
||||||
echo 'xzminidec failed, now try xzcat_musl ...' >> $VTLOG
|
rm -f $VTOY_PATH/xzlog
|
||||||
xzcat_musl $vtfile | (cpio -idmu 2>>$VTLOG; cat > $vttmp)
|
${vtx:5} $vtfile 2> $VTOY_PATH/xzlog | (cpio -idmu 2>>$VTLOG; cat > $vttmp)
|
||||||
fi
|
if grep -q 'corrupted data' $VTOY_PATH/xzlog; then
|
||||||
|
echo 'xzcat failed, now try xzminidec...' >> $VTLOG
|
||||||
|
rm -f $VTOY_PATH/xzlog
|
||||||
|
cat $vtfile | xzminidec 2> $VTOY_PATH/xzlog | (cpio -idmu 2>>$VTLOG; cat > $vttmp)
|
||||||
|
|
||||||
|
if grep -q 'limit' $VTOY_PATH/xzlog; then
|
||||||
|
echo 'xzminidec failed, now try xzcat_musl ...' >> $VTLOG
|
||||||
|
xzcat_musl $vtfile | (cpio -idmu 2>>$VTLOG; cat > $vttmp)
|
||||||
fi
|
fi
|
||||||
else
|
|
||||||
${vtx:5} $vtfile | (cpio -idmu 2>>$VTLOG; cat > $vttmp)
|
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
dd if=$vtfile skip=$vtskip iflag=skip_bytes status=none | ${vtx:5} | (cpio -idmu 2>>$VTLOG; cat > $vttmp)
|
${vtx:5} $vtfile | (cpio -idmu 2>>$VTLOG; cat > $vttmp)
|
||||||
fi
|
fi
|
||||||
break
|
break
|
||||||
fi
|
fi
|
||||||
@@ -112,6 +114,28 @@ ventoy_unpack_initrd() {
|
|||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
|
vtfile_head_zero() {
|
||||||
|
local vsize
|
||||||
|
local voffset
|
||||||
|
local vfile
|
||||||
|
local vzero
|
||||||
|
local vdump
|
||||||
|
|
||||||
|
voffset=0
|
||||||
|
vfile=$1
|
||||||
|
vsize=$(stat -c '%s' ${vfile})
|
||||||
|
vzero=$(hexdump -n 512 -e '512/1 "%02X"' $vfile)
|
||||||
|
|
||||||
|
while [ $voffset -lt $vsize ]; do
|
||||||
|
vdump=$(hexdump -s $voffset -n 512 -e '512/1 "%02X"' $vfile)
|
||||||
|
if [ "$vdump" != "$vzero" ]; then
|
||||||
|
echo $voffset
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
voffset=$($BUSYBOX_PATH/expr $voffset + 512)
|
||||||
|
done
|
||||||
|
echo 0
|
||||||
|
}
|
||||||
|
|
||||||
# This export is for busybox cpio command
|
# This export is for busybox cpio command
|
||||||
export EXTRACT_UNSAFE_SYMLINKS=1
|
export EXTRACT_UNSAFE_SYMLINKS=1
|
||||||
@@ -131,13 +155,22 @@ for vtfile in $(ls /initrd*); do
|
|||||||
#only for cpio,cpio,...,initrd sequence, initrd,cpio or initrd,initrd sequence is not supported
|
#only for cpio,cpio,...,initrd sequence, initrd,cpio or initrd,initrd sequence is not supported
|
||||||
while [ -e ${vtfile}_tmp ] && [ $(stat -c '%s' ${vtfile}_tmp) -gt 512 ]; do
|
while [ -e ${vtfile}_tmp ] && [ $(stat -c '%s' ${vtfile}_tmp) -gt 512 ]; do
|
||||||
mv ${vtfile}_tmp $vtfile
|
mv ${vtfile}_tmp $vtfile
|
||||||
|
|
||||||
vtdump=$(hexdump -n 512 -e '512/1 "%02X"' $vtfile)
|
vtdump=$(hexdump -n 512 -e '512/1 "%02X"' $vtfile)
|
||||||
vtmagic=$(echo $vtdump | sed 's/^\(00\)*//')
|
vtmagic=$(echo $vtdump | sed 's/^\(00\)*//')
|
||||||
let vtoffset="(${#vtdump}-${#vtmagic})/2"
|
let vtoffset="(${#vtdump}-${#vtmagic})/2"
|
||||||
|
|
||||||
if [ -z "$vtmagic" ]; then
|
if [ -z "$vtmagic" ]; then
|
||||||
echo "terminate with all zero data file" >> $VTLOG
|
vtHeadZero=$(vtfile_head_zero $vtfile)
|
||||||
break
|
if [ $vtHeadZero -gt 0 ]; then
|
||||||
|
vtdump=$(hexdump -s $vtHeadZero -n 512 -e '512/1 "%02X"' $vtfile)
|
||||||
|
vtmagic=$(echo $vtdump | sed 's/^\(00\)*//')
|
||||||
|
let vtoffset="(${#vtdump}-${#vtmagic})/2+$vtHeadZero"
|
||||||
|
echo "skip head $vtHeadZero zeros with magic ${vtmagic:0:4}" >> $VTLOG
|
||||||
|
else
|
||||||
|
echo "terminate with all zero data file" >> $VTLOG
|
||||||
|
break
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
ventoy_unpack_initramfs $vtfile $vtoffset ${vtmagic:0:4} ${vtfile}_tmp
|
ventoy_unpack_initramfs $vtfile $vtoffset ${vtmagic:0:4} ${vtfile}_tmp
|
||||||
|
|||||||
@@ -39,35 +39,6 @@ fi
|
|||||||
ventoy_udev_disk_common_hook "${vtdiskname#/dev/}2" "noreplace"
|
ventoy_udev_disk_common_hook "${vtdiskname#/dev/}2" "noreplace"
|
||||||
ventoy_create_dev_ventoy_part
|
ventoy_create_dev_ventoy_part
|
||||||
|
|
||||||
if ventoy_need_dm_patch; then
|
|
||||||
vtlog "extract a ko file"
|
|
||||||
|
|
||||||
mkdir -p /ventoy/tmpmnt1 /ventoy/tmpmnt2
|
|
||||||
mount /dev/ventoy1 /ventoy/tmpmnt1
|
|
||||||
mount /ventoy/tmpmnt1/boot/batocera /ventoy/tmpmnt2
|
|
||||||
vtKV=$(uname -r)
|
|
||||||
|
|
||||||
mkdir -p /lib/modules/$vtKV/kernel/
|
|
||||||
vtKO=$(find "/ventoy/tmpmnt2/lib/modules/$vtKV/kernel/fs/" -name "*.ko*" | head -n1)
|
|
||||||
cp -a $vtKO /lib/modules/$vtKV/kernel/
|
|
||||||
|
|
||||||
vtlog "vtKV=$vtKV vtKO=$vtKO"
|
|
||||||
|
|
||||||
umount /ventoy/tmpmnt2
|
|
||||||
umount /ventoy/tmpmnt1
|
|
||||||
|
|
||||||
vtPartid=1
|
|
||||||
cat /vtoy_dm_table | while read vtline; do
|
|
||||||
dmsetup remove ventoy$vtPartid
|
|
||||||
vtPartid=$(expr $vtPartid + 1)
|
|
||||||
done
|
|
||||||
dmsetup remove ventoy
|
|
||||||
|
|
||||||
vtlog "Recreate device-mapper"
|
|
||||||
ventoy_udev_disk_common_hook "${vtdiskname#/dev/}2" "noreplace"
|
|
||||||
ventoy_create_dev_ventoy_part
|
|
||||||
fi
|
|
||||||
|
|
||||||
|
|
||||||
PATH=$VTPATH_OLD
|
PATH=$VTPATH_OLD
|
||||||
|
|
||||||
|
|||||||
@@ -52,6 +52,11 @@ ventoy_get_os_type() {
|
|||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Parted Magic
|
||||||
|
if [ -d /pmagic ]; then
|
||||||
|
echo 'pmagic'; return
|
||||||
|
fi
|
||||||
|
|
||||||
# PrimeOS :
|
# PrimeOS :
|
||||||
if $GREP -q 'PrimeOS' /proc/version; then
|
if $GREP -q 'PrimeOS' /proc/version; then
|
||||||
echo 'primeos'; return
|
echo 'primeos'; return
|
||||||
@@ -164,7 +169,7 @@ ventoy_get_os_type() {
|
|||||||
echo 'debian'; return
|
echo 'debian'; return
|
||||||
elif $GREP -q 'Solus' /etc/os-release; then
|
elif $GREP -q 'Solus' /etc/os-release; then
|
||||||
echo 'rhel7'; return
|
echo 'rhel7'; return
|
||||||
elif $GREP -q 'openEuler' /etc/os-release; then
|
elif $GREP -q -i 'openEuler' /etc/os-release; then
|
||||||
echo 'openEuler'; return
|
echo 'openEuler'; return
|
||||||
elif $GREP -q 'fuyu' /etc/os-release; then
|
elif $GREP -q 'fuyu' /etc/os-release; then
|
||||||
echo 'openEuler'; return
|
echo 'openEuler'; return
|
||||||
@@ -172,6 +177,10 @@ ventoy_get_os_type() {
|
|||||||
echo 'deepin'; return
|
echo 'deepin'; return
|
||||||
elif $GREP -q 'chinauos' /etc/os-release; then
|
elif $GREP -q 'chinauos' /etc/os-release; then
|
||||||
echo 'deepin'; return
|
echo 'deepin'; return
|
||||||
|
elif $GREP -qi 'aerynos' /etc/os-release; then
|
||||||
|
echo 'rhel7'; return
|
||||||
|
elif $GREP -qi 'ID_LIKE=debian' /etc/os-release; then
|
||||||
|
echo 'debian'; return
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@@ -237,10 +246,6 @@ ventoy_get_os_type() {
|
|||||||
echo 'adelie'; return
|
echo 'adelie'; return
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if $GREP -q 'pmagic' /proc/version; then
|
|
||||||
echo 'pmagic'; return
|
|
||||||
fi
|
|
||||||
|
|
||||||
if $GREP -q 'CDlinux' /proc/cmdline; then
|
if $GREP -q 'CDlinux' /proc/cmdline; then
|
||||||
echo 'cdlinux'; return
|
echo 'cdlinux'; return
|
||||||
fi
|
fi
|
||||||
@@ -311,8 +316,8 @@ ventoy_get_os_type() {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
if [ -e /init ]; then
|
if [ -e /etc/initrd-release ]; then
|
||||||
if $GREP -q -m1 'T2 SDE' /init; then
|
if $GREP -q -m1 't2sde' /etc/initrd-release; then
|
||||||
echo 't2'; return
|
echo 't2'; return
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
@@ -372,6 +377,13 @@ ventoy_get_os_type() {
|
|||||||
echo 'openEuler'; return
|
echo 'openEuler'; return
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
if [ -f /etc/kylin-release ]; then
|
||||||
|
if $GREP -i -q -m1 'Kylin.*Server.* V1[1-9] ' /etc/kylin-release; then
|
||||||
|
echo 'openEuler'; return
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if $GREP -q 'chimera' /proc/version; then
|
if $GREP -q 'chimera' /proc/version; then
|
||||||
echo 'chimera'; return
|
echo 'chimera'; return
|
||||||
@@ -384,6 +396,12 @@ ventoy_get_os_type() {
|
|||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [ -f /etc/tinyramfs/config ]; then
|
||||||
|
if $GREP -q 'EWE_ISO' /etc/tinyramfs/config; then
|
||||||
|
echo "ewe"; return
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
echo "default"
|
echo "default"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -101,6 +101,11 @@ ventoy_get_os_type() {
|
|||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Parted Magic
|
||||||
|
if [ -d /pmagic ]; then
|
||||||
|
echo 'pmagic'; return
|
||||||
|
fi
|
||||||
|
|
||||||
# rhel5/CentOS5 and all other distributions based on them
|
# rhel5/CentOS5 and all other distributions based on them
|
||||||
if $GREP -q 'el5' /proc/version; then
|
if $GREP -q 'el5' /proc/version; then
|
||||||
echo 'rhel5'; return
|
echo 'rhel5'; return
|
||||||
@@ -200,7 +205,7 @@ ventoy_get_os_type() {
|
|||||||
echo 'debian'; return
|
echo 'debian'; return
|
||||||
elif $GREP -q 'Solus' /etc/os-release; then
|
elif $GREP -q 'Solus' /etc/os-release; then
|
||||||
echo 'rhel7'; return
|
echo 'rhel7'; return
|
||||||
elif $GREP -q 'openEuler' /etc/os-release; then
|
elif $GREP -q -i 'openEuler' /etc/os-release; then
|
||||||
echo 'openEuler'; return
|
echo 'openEuler'; return
|
||||||
elif $GREP -q 'fuyu' /etc/os-release; then
|
elif $GREP -q 'fuyu' /etc/os-release; then
|
||||||
echo 'openEuler'; return
|
echo 'openEuler'; return
|
||||||
@@ -269,10 +274,6 @@ ventoy_get_os_type() {
|
|||||||
echo 'adelie'; return
|
echo 'adelie'; return
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if $GREP -q 'pmagic' /proc/version; then
|
|
||||||
echo 'pmagic'; return
|
|
||||||
fi
|
|
||||||
|
|
||||||
if $GREP -q 'CDlinux' /proc/cmdline; then
|
if $GREP -q 'CDlinux' /proc/cmdline; then
|
||||||
echo 'cdlinux'; return
|
echo 'cdlinux'; return
|
||||||
fi
|
fi
|
||||||
@@ -343,8 +344,8 @@ ventoy_get_os_type() {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
if [ -e /init ]; then
|
if [ -e /etc/initrd-release ]; then
|
||||||
if $GREP -q -m1 'T2 SDE' /init; then
|
if $GREP -q -m1 't2sde' /etc/initrd-release; then
|
||||||
echo 't2'; return
|
echo 't2'; return
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user