Compare commits

...

818 Commits

Author SHA1 Message Date
A1ive
0e9d34422a
Update xfs to latest (#3284)
Some checks failed
Ventoy CI / build (push) Has been cancelled
Mirror GitHub to Gitee / Sync-GitHub-to-Gitee (push) Has been cancelled
Thanks!
2025-07-07 09:21:53 +08:00
longpanda
c7c9c62ec7
Update BLOB_List.md
Some checks failed
Ventoy CI / build (push) Has been cancelled
Mirror GitHub to Gitee / Sync-GitHub-to-Gitee (push) Has been cancelled
2025-05-22 12:55:41 +08:00
longpanda
9e13955af1 Add BLOB list file and some missing build desc. 2025-05-14 14:35:44 +08:00
longpanda
2dafe75509 Fix the boot issue for TrueNAS Scale. (#3069)
Some checks failed
Ventoy CI / build (push) Has been cancelled
Mirror GitHub to Gitee / Sync-GitHub-to-Gitee (push) Has been cancelled
2025-03-03 14:42:44 +08:00
longpanda
6fbc08cfcb Only for VirtualBox.
Some checks failed
Ventoy CI / build (push) Has been cancelled
Mirror GitHub to Gitee / Sync-GitHub-to-Gitee (push) Has been cancelled
2025-02-28 14:58:36 +08:00
longpanda
6034b25cba Don't force to use max resolution for VMware/VirtualBox. (#3140) 2025-02-28 14:49:40 +08:00
longpanda
c5fd64d21c Support TrueNAS Scale (Linux) distro. (#3069 #3137)
Some checks failed
Ventoy CI / build (push) Has been cancelled
Mirror GitHub to Gitee / Sync-GitHub-to-Gitee (push) Has been cancelled
2025-02-26 23:25:27 +08:00
longpanda
32fac72b5b 1.1.05
Some checks failed
Ventoy CI / build (push) Has been cancelled
Mirror GitHub to Gitee / Sync-GitHub-to-Gitee (push) Has been cancelled
2025-02-24 19:29:46 +08:00
longpanda
022322c8fa Fix the resolution issue when boot Windows/WinPE in UEFI mode. 2025-02-24 19:17:19 +08:00
longpanda
96f11252d9 support devuan in Legacy BIOS mode. 2025-02-24 19:16:31 +08:00
longpanda
004ad27e0d 1.1.04 release
Some checks failed
Ventoy CI / build (push) Has been cancelled
Mirror GitHub to Gitee / Sync-GitHub-to-Gitee (push) Has been cancelled
2025-02-22 11:27:31 +08:00
longpanda
9a8dc42d93 Fix the issue introduced in LinuxGUI version. (#3128) 2025-02-22 11:27:18 +08:00
longpanda
6166a813ea 1.1.03
Some checks are pending
Ventoy CI / build (push) Waiting to run
Mirror GitHub to Gitee / Sync-GitHub-to-Gitee (push) Waiting to run
2025-02-21 18:14:18 +08:00
longpanda
786a9ec678 Update Ventoy2Disk.exe
Some checks are pending
Ventoy CI / build (push) Waiting to run
Mirror GitHub to Gitee / Sync-GitHub-to-Gitee (push) Waiting to run
2025-02-21 13:00:15 +08:00
longpanda
0600576c78 Update Linux GUI type condition 2025-02-21 13:00:01 +08:00
longpanda
72b722c86c Fix the boot issue for latest TinyCore Linux. 2025-02-21 12:59:33 +08:00
longpanda
bea5607ea5 Fix the boot issue for pfSense 2.7.x (#2775)
Some checks are pending
Ventoy CI / build (push) Waiting to run
Mirror GitHub to Gitee / Sync-GitHub-to-Gitee (push) Waiting to run
2025-02-21 00:29:38 +08:00
longpanda
b3c2bcf58f Fix the issue that SLES/OpenSUSE can not boot after install. (#3125) 2025-02-20 22:07:28 +08:00
longpanda
4e8d8b2e19 Fix Windows 11 error 0x80070001. (#3010 #3029 #3105)
Some checks are pending
Ventoy CI / build (push) Waiting to run
Mirror GitHub to Gitee / Sync-GitHub-to-Gitee (push) Waiting to run
2025-02-19 23:49:03 +08:00
longpanda
60d88cb7b1 1.1.02 release
Some checks failed
Ventoy CI / build (push) Has been cancelled
Mirror GitHub to Gitee / Sync-GitHub-to-Gitee (push) Has been cancelled
2025-02-12 23:01:35 +08:00
longpanda
f7e6bbc70c Fix the "Unsupported vtoy type unknown" error when boot a VDI file created by VirtualBox 7.x 2025-02-12 23:00:27 +08:00
longpanda
ee994a0569 github ai version update
Some checks failed
Ventoy CI / build (push) Has been cancelled
Mirror GitHub to Gitee / Sync-GitHub-to-Gitee (push) Has been cancelled
2025-02-10 21:46:39 +08:00
longpanda
966ed21de7 1.1.01
Some checks are pending
Ventoy CI / build (push) Waiting to run
Mirror GitHub to Gitee / Sync-GitHub-to-Gitee (push) Waiting to run
2025-02-10 20:14:46 +08:00
longpanda
ff7ee9c10e 1.1.00 release 2025-01-22 19:32:29 +08:00
Liangbin Lian
f43461a16c
loader/linux: Ensure the newc pathname is NULL-terminated (#3082)
Per "man 5 cpio", the namesize in the cpio header includes the trailing
NUL byte of the pathname and the pathname is followed by NUL bytes, but
the current implementation ignores the trailing NUL byte when making
the newc header. Although make_header() tries to pad the pathname string,
the padding won't happen when strlen(name) + sizeof(struct newc_head)
is a multiple of 4, and the non-NULL-terminated pathname may lead to
unexpected results.

Assume that a file is created with 'echo -n aaaa > /boot/test12' and
loaded by grub2:

    linux /boot/vmlinuz
    initrd newc:test12:/boot/test12 /boot/initrd

The initrd command eventually invoked grub_initrd_load() and sent
't''e''s''t''1''2' to make_header() to generate the header:

00000070  30 37 30 37 30 31 33 30  31 43 41 30 44 45 30 30  |070701301CA0DE00|
00000080  30 30 38 31 41 34 30 30  30 30 30 33 45 38 30 30  |0081A4000003E800|
00000090  30 30 30 30 36 34 30 30  30 30 30 30 30 31 36 33  |0000640000000163|
000000a0  37 36 45 34 35 32 30 30  30 30 30 30 30 34 30 30  |76E4520000000400|
000000b0  30 30 30 30 30 38 30 30  30 30 30 30 31 33 30 30  |0000080000001300|
000000c0  30 30 30 30 30 30 30 30  30 30 30 30 30 30 30 30  |0000000000000000|
000000d0  30 30 30 30 30 36 30 30  30 30 30 30 30 30 74 65  |00000600000000te|
                                                                  ^namesize
000000e0  73 74 31 32 61 61 61 61  30 37 30 37 30 31 30 30  |st12aaaa07070100|
                   ^^ end of the pathname

Since strlen("test12") + sizeof(struct newc_head) is 116 = 29 * 4,
make_header() didn't pad the pathname, and the file content followed
"test12" immediately. This violates the cpio format and may trigger such
error during linux boot:

    Initramfs unpacking failed: ZSTD-compressed data is trunc

To avoid the potential problems, this commit counts the trailing NUL byte
in when calling make_header() and adjusts the initrd size accordingly.

Now the header becomes

00000070  30 37 30 37 30 31 33 30  31 43 41 30 44 45 30 30  |070701301CA0DE00|
00000080  30 30 38 31 41 34 30 30  30 30 30 33 45 38 30 30  |0081A4000003E800|
00000090  30 30 30 30 36 34 30 30  30 30 30 30 30 31 36 33  |0000640000000163|
000000a0  37 36 45 34 35 32 30 30  30 30 30 30 30 34 30 30  |76E4520000000400|
000000b0  30 30 30 30 30 38 30 30  30 30 30 30 31 33 30 30  |0000080000001300|
000000c0  30 30 30 30 30 30 30 30  30 30 30 30 30 30 30 30  |0000000000000000|
000000d0  30 30 30 30 30 37 30 30  30 30 30 30 30 30 74 65  |00000700000000te|
                                                                  ^namesize
000000e0  73 74 31 32 00 00 00 00  61 61 61 61 30 37 30 37  |st12....aaaa0707|
                      ^^ end of the pathname

Besides the trailing NUL byte, make_header() pads 3 more NUL bytes, and
the user can safely read the pathname without a further check.

To conform to the cpio format, the headers for "TRAILER!!!" are also
adjusted to include the trailing NUL byte, not ignore it.


Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>

Signed-off-by: Gary Lin <glin@suse.com>
Co-authored-by: Gary Lin <glin@suse.com>
2025-01-22 19:19:29 +08:00
longpanda
377e3fb7bc Fix the boot issue of SystemRescue 11.02+ (#2958) (#3058) 2025-01-22 19:07:08 +08:00
longpanda
f62bd1be14 support eweOS ISO (#3068) 2025-01-22 18:24:09 +08:00
longpanda
b11c38779d docker file 2024-11-16 17:00:25 +08:00
longpanda
f202542c62 docker compose up 2024-11-16 12:38:43 +08:00
longpanda
279491a36a Update to latest Shim (Fix verifying shim SBAT data failed) #2947 2024-11-16 12:34:39 +08:00
longpanda
cb209f9b9e 1.0.99 2024-06-08 17:26:33 +08:00
Andrei Stepanov
b7b2f6a5c1
Update Russian translation (#2857) 2024-06-08 17:10:31 +08:00
Zohir Tamda
3967fb5fb5
Fix French language (#2850)
Co-authored-by: tamdaz <tamda.zohir.pro@gmail.com>
2024-06-08 17:10:07 +08:00
bovirus
a2ad95792d
Fixed Italian language (#2840) 2024-06-08 17:09:53 +08:00
Re*Index. (ot_inc)
791308d2ce
Japanese Fix typo. (#2839)
* Japanese translation Fixed.

* Fix typo

Fix Typo.
2024-06-08 17:09:26 +08:00
longpanda
0ffb1b15ef Fix the issue that VTOY_LINUX_REMOUNT option does not take effect in latest openSUSE. (#2551) 2024-05-25 18:13:52 +08:00
longpanda
d6e1730ca0 Fix the install issue for /dev/mdX device. (#2846) 2024-05-23 19:30:11 +08:00
longpanda
4d55f505f9 Fix the UEFI boot issue for some computer. 2024-05-22 22:53:55 +08:00
longpanda
30a61ac5c4 1.0.98 release 2024-05-19 23:14:49 +08:00
Re*Index. (ot_inc)
9b79831516
Japanese translation Fixed. (#2808) 2024-05-19 16:43:20 +08:00
jermanuts
af2d6bc247
Update ar_AR.json (#2755)
* Update ar_AR.json

* Update ar_AR.json
2024-05-19 16:41:51 +08:00
bovirus
d8ae740427
Update Italian help/menu (#2752) 2024-05-19 16:41:37 +08:00
Samuel Johnson
b685157ae3
Minor Update on README.md for Consistency (#2687) 2024-05-19 16:41:12 +08:00
Fabian-Gruenbichler
3f6ddb6fb6
support zvol devices (#2678)
their partitions are exposed as "/dev/zdXXpY", handle accordingly.

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2024-05-19 16:39:34 +08:00
Zhymabek Roman
b8838b305d
Adding root user check to ExtendPersistentImg (as in CreatePersistentImg) (#2633)
* Adding root user check & Enhance help info

* Update root user check
2024-05-19 16:35:22 +08:00
Batuhan
00de8b932d
Update tr_TR.txt (#2618)
corrected grammar mistakes, fixed typos
2024-05-19 16:29:13 +08:00
WebSnke
1e49dbe957
Update German translation (#2612) 2024-05-19 16:28:35 +08:00
Ida Bagus
580416facc
Update languages.json (#2600)
minor update for indonesian language
2024-05-19 16:28:25 +08:00
gcf
75cf728fa9
The gpt pointer is not initialized, and when offset < 0, it may result in freeing unallocated memory. (#2499)
Signed-off-by: yuxiaojun <yuxiaojun1011@outlook.com>
Co-authored-by: yuxiaojun <yuxiaojun1011@outlook.com>
2024-05-19 16:27:19 +08:00
Ikko Eltociear Ashimine
8723aeb4cc
fix typo in diskio.h (#2497)
fucntion -> function
2024-05-19 16:25:42 +08:00
SunderB
dc9a99bb20
Correct some spelling and grammar in BuildVentoyFromSource.txt (#2491) 2024-05-19 16:24:41 +08:00
Hoang Nguyen
a40456d9d2
Added Vietnamese language support for GRUB and updated Vietnamese translation of the installer (#2362)
* Updated Vietnamese language

Added new translation for `STR_4KN_UNSUPPORTED` and retouched in some places

* Added Vietnamese language support for GRUB menu

* Removed vi_VN from helplist and menulist
2024-05-19 16:17:54 +08:00
Balázs Úr
bdab55e8aa
Updated Hungarian translation (#2836) 2024-05-19 16:11:30 +08:00
longpanda
1b2483ec14 Skip trash directory by default. (#2831) 2024-05-19 16:00:46 +08:00
longpanda
c16e76130b Fix VTOY_LINUX_REMOUNT option for latest CentOS 9 Stream. (#2827) 2024-05-19 15:35:05 +08:00
longpanda
d672af4819 Support ext4 fs with checksum seed feature. 2024-05-19 12:14:02 +08:00
longpanda
712f10e86a Fix VTOY_LINUX_REMOUNT feature in RHEL 9.4+ (#2827) 2024-05-14 14:59:12 +08:00
longpanda
2be340d2e8 update 2024-05-12 14:57:19 +08:00
longpanda
b77ef718b4 bugfix 2024-05-12 12:37:12 +08:00
longpanda
72f5710b88 Fix arch iso boot issue (#2825 #2824) 2024-05-12 12:36:58 +08:00
longpanda
ee7da60d88 Fix the boot issue for latest KAOS. 2024-04-06 23:53:07 +08:00
longpanda
44fb9f4564 Fix the VTOY_LINUX_REMOUNT option on latest linux kernel 2024-04-06 21:22:17 +08:00
longpanda
3f65f0ef03 1.0.97 release 2024-01-24 15:02:32 +08:00
longpanda
4faa5e4344 update tool 2024-01-24 13:35:27 +08:00
longpanda
c7693d4ecd Fix VTOY_LINUX_REMOUNT option does not work with latest linux kernel version. (#2661 #2674) 2024-01-24 12:09:29 +08:00
longpanda
4527e1db79 Add support for FreeBSD 14.0 2024-01-23 09:08:23 +08:00
longpanda
757cacf274 Fix Proxmox 8.1 boot issue. (#2657) 2023-12-04 23:00:31 +08:00
longpanda
39703cabb7 Fix the VentoyPlugson issue that default_file value is wrong for more than 10 theme files. (#2608) 2023-10-14 22:15:24 +08:00
longpanda
854d17a4e9 1.0.96 release 2023-10-06 22:39:39 +08:00
Maicol Battistini
a326b13fc3
Added italian translation (#2580) 2023-10-06 22:33:17 +08:00
longpanda
3ff1867a2a Fix the warning prompt for Ventoy2Disk.sh (#2593) 2023-10-06 22:05:39 +08:00
longpanda
7f63a1c327 Fix the issue that VTOY_LINUX_REMOUNT=1 does not work on some distros (e.g. Pop OS/openSUSE/Ubuntu 23.04) (#2475 #2551) 2023-10-06 21:12:34 +08:00
longpanda
d617985093 Add escaping for path in VentoyPlugson.sh (#2585) 2023-10-06 16:43:26 +08:00
longpanda
605da1ba94 Fix that bootpwd not working for VentoyPlugson. (#2584) 2023-10-03 23:49:22 +08:00
longpanda
c8dc36a5c3 1.0.95 release 2023-08-23 09:26:53 +08:00
I'm an OSK user, are you?
689f7df902
Update Swedish language (#2443) 2023-08-22 11:34:38 +08:00
Sönke Joppien
a9d53e7448
Update German translation (#2500) 2023-08-22 11:33:48 +08:00
Hugo Carvalho
46061bcd41
Update languages.json (#2504)
Update Portuguese (Portugal) translation
2023-08-22 11:33:34 +08:00
Felipe
01b0de7811
Updated brazilian portuguese translation - aside that included 2 missing translations. (#2533)
* Updated brazilian portuguese translation

Translated one string that wasnt translated and fixed the other ones.

* Added a brazilian portuguese file

It was missing one, suggested by https://www.ventoy.net/en/doc_menu_language.html

* Added a brazilian portuguese file

One was missing, again this is also a suggestion of https://www.ventoy.net/en/doc_menu_language.html
2023-08-22 11:23:15 +08:00
longpanda
2fee243a56 Support drag resize dialog window width. 2023-08-22 11:21:17 +08:00
longpanda
d0e10f8e48 Support veket_24 2023-07-31 23:33:25 +08:00
longpanda
7ff243f9bb Fix the media missing issue when boot UOS server ISO file. 2023-07-30 12:58:29 +08:00
longpanda
f8811a4656 1.0.94 release 2023-07-20 11:54:46 +08:00
VenusGirl❤
0ce90ad9b9
Update ko_KR.json (#2483) 2023-07-20 11:00:38 +08:00
Vasilis
5bfddae81d
Update languages.json (#2482)
Greek language update
2023-07-20 11:00:21 +08:00
YALdysse
2991f097fb
fixed ukrainian translation (#2469)
* Update uk_UA.txt

* fix ukrainian translation
2023-07-20 10:59:48 +08:00
Stanislav
986835338d
i18n: Small fix Russian language (#2473)
* i18n: Small fix Russian language

* Update languages.json
2023-07-20 10:59:34 +08:00
bovirus
f2562fecb9
Update italian strings (#2465) 2023-07-20 10:58:08 +08:00
Jianfeng Liu
529541f218
fix Synchronous Exception on some arm cpus (#2488) 2023-07-20 10:56:55 +08:00
longpanda
430f81ac49 cc 2023-06-23 23:07:21 +08:00
longpanda
038c0533d9 1.0.92 release 2023-06-23 21:29:51 +08:00
lollilol
102b179cd9
change password input field to type=password (#2427) 2023-06-23 16:28:38 +08:00
Kosta Stojiljkovic
6785f5d049
Added Serbian translation for STR_4KN_UNSUPPORTED strings for cyrilic and latin scripts. (#2406) 2023-06-23 16:27:11 +08:00
William Poetra Yoga
0c812ed5e9
fix: grep warning (#2398) 2023-06-23 16:26:55 +08:00
Blaž Osredkar
9f2b9b0867
Added Slovenian language (#2378) 2023-06-23 16:26:19 +08:00
wiz64
c79b072680
Update languages.json (viva l' ventoy) (#2372) 2023-06-23 16:25:39 +08:00
Nikolas Garofil
6b4509a550
Environment typos (#2368) 2023-06-23 16:24:36 +08:00
longpanda
feea11e2bb Support unattended auto install for Deepin/UOS 2023-05-29 00:11:21 +08:00
A1ive
35c952d891
Correct EFI chainloader image device path (#2397) 2023-05-19 23:23:14 +08:00
Dolphin Oracle
82053680bf
Update ventoy-hook.sh for MX Linux (#2390)
due to a systemd issue, we had to rename initrd-release to initrd_release.
2023-05-15 12:30:03 +08:00
longpanda
6d5de12f52 Merge branch 'master' of https://github.com/ventoy/Ventoy 2023-04-21 20:05:40 +08:00
longpanda
84b2ee7ee3 Fix the boot issue for Fedora/CentOS when file name contains special character (e.g. '(' ) #2360 2023-04-21 20:05:30 +08:00
K.B.Dharun Krishna
da1b306e81
ci.yml: bump actions to v3 to fix node warning (#2341) 2023-04-13 19:25:31 +08:00
longpanda
0961ce5624 1.0.91 release 2023-04-05 20:41:34 +08:00
longpanda
07574f0379 Improve grub2 mode process for legacy BIOS mode. 2023-04-05 20:16:36 +08:00
Steve
142aa47944
fixed german translation (#2318)
* Updated german translation

#2277 has an small issue (misstyping; "nocht" should read "noch")
Changed the translation. It is minimally shorter.

* fixed german translation
2023-04-04 13:54:49 +08:00
longpanda
11739fa9d0 Fix a bug that Fedora boot error if Ventoy partition is NTFS. (#2333) 2023-04-03 21:49:21 +08:00
longpanda
9fc85051a7 Fix the issue for booting Bliss OS 15.x 2023-04-03 09:18:13 +08:00
longpanda
b9e82bcf16 Support FreeBSD 14-CURRENT 2023-04-02 13:17:20 +08:00
longpanda
cff3a01289 Support NTFS with large cluster size (greater than 64KB). 2023-03-28 11:38:46 +08:00
longpanda
0f90149c4e 1.0.90 release 2023-03-26 19:01:13 +08:00
longpanda
8ef9732931 Update vtoytool 2023-03-26 16:03:32 +08:00
longpanda
b32eda4262 Fix the VTOY_LINUX_REMOUNT option for new linux kernel in intel 11th(and later) gen CPU. 2023-03-26 10:45:19 +08:00
longpanda
e743f7c15f Add support for chimera linux. (#2309) 2023-03-24 20:43:47 +08:00
longpanda
652475f1ef Optimization for Fedora boot process 2023-03-24 10:37:24 +08:00
longpanda
abfc2a6343 Add checksum jif 2023-03-21 15:44:54 +08:00
longpanda
e73ac04cb6 update README.md 2023-03-20 17:15:36 +08:00
StoyanDimitrov
8727e63880
Update languages.json (#2299) 2023-03-17 17:39:57 +08:00
VenusGirl❤
2d281d7dee
Update ko_KR.json (#2286)
Korean Update
2023-03-17 17:39:21 +08:00
Steve
385c806adf
Updated german translation (#2279)
#2277 has an small issue (misstyping; "nocht" should read "noch")
Changed the translation. It is minimally shorter.
2023-03-17 17:39:02 +08:00
longpanda
e869bc2386 Fix the issue that Fedora Rawhide install media not detected. (#2283) 2023-03-10 22:33:53 +08:00
longpanda
b47aa1abc7 Support LibreELEC 11.0+ (#2281) 2023-03-09 23:59:12 +08:00
longpanda
d8698b2194 1.0.89 release 2023-03-07 19:21:15 +08:00
longpanda
7fa4724743 Fix the menu missing issue when there exist an invalid vlnk file. (#2228) 2023-03-07 18:05:33 +08:00
WebSnke
2717405a7a
Add German translation for STR_4KN_UNSUPPORTED (#2277) 2023-03-05 20:59:09 +08:00
wiz64
d494007df9
update japanese (#2264) 2023-03-05 20:58:55 +08:00
Tayfun Akkoyun
bc9e3f641b
Update tr_TR.txt (#2262)
Long translations edited to be shorter
2023-03-05 20:58:32 +08:00
dmitrygribenchuk
9f02d37001
Update translation (#2261)
* update translation

* update translation
2023-03-05 20:58:16 +08:00
Thunderstrike116
fa1461bac7
Add Greek Language (#2258)
* Added Greek Translation

* Added Greek Translation
2023-03-05 20:57:55 +08:00
marcellogianola
3d56c3fa17
Update languages.json (#2257) 2023-03-05 20:57:29 +08:00
ИEØ_ΙΙØZ
a7e3d78d14
Update zh_TW.json (#2256) 2023-03-05 20:57:05 +08:00
longpanda
879a7592bd Fix dm_patch for new linux kernel. 2023-02-20 11:59:03 +08:00
longpanda
5a433f49f7 Optimization for booting Fedora series. 2023-02-18 21:33:05 +08:00
Ikko Eltociear Ashimine
0cce956c54
Fix typo in EXT/README.txt (#2247)
bellow -> below
2023-02-18 21:31:37 +08:00
Ing. Jan Kaláb
0b6372857c
Fix typo in Czech translation (#2252)
Thanks to Jiří Červinka
2023-02-18 21:31:19 +08:00
M
028663de9a
Update Polish translation (#2232) 2023-02-18 21:31:09 +08:00
Tyemak
5feb3f7b4b
Update languages.json (#2230) 2023-02-18 21:30:48 +08:00
longpanda
7035787f38 update languages.json 2023-02-08 10:42:35 +08:00
ИEØ_ΙΙØZ
7dd0f509f5
Update languages.json (#2207)
Fixed one string for Traditional Chinese,
Sorry, I missed it in my last submission.
2023-02-08 10:37:35 +08:00
andrewczm
15947caea2
Updated Polish translation (#2212)
* Update pl_PL.json

A few corrections to the Polish translation

* Update pl_PL.json

small correction

* Update pl_PL.json

the latest update

* Updated Polish translation

Some cosmetic corrections in the Polish translation
2023-02-08 10:36:39 +08:00
YALdysse
6aeba8f8b4
fix ukrainian language (#2222) 2023-02-08 10:36:16 +08:00
ИEØ_ΙΙØZ
fd46b2c3c3
Update languages.json (#2204)
add & correct some strings
2023-02-02 15:51:28 +08:00
YALdysse
e502f4291e
Ukrainian language (#2199) 2023-02-02 15:50:22 +08:00
andrewczm
9c59c27eff
Update pl_PL.json (#2191)
* Update pl_PL.json

A few corrections to the Polish translation

* Update pl_PL.json

small correction

* Update pl_PL.json

the latest update
2023-02-02 15:50:02 +08:00
YALdysse
daeb96ce80
fixed russian translation (#2190) 2023-02-02 15:49:42 +08:00
YALdysse
b7e878c466
fixed russian translation (#2189) 2023-02-02 15:49:28 +08:00
VenusGirl❤
b76ebf5b07
Update languages.json (#2186) 2023-02-02 15:49:10 +08:00
VenusGirl❤
9532776f39
Update ko_KR.txt (#2188)
* Update ko_KR.txt

* Update ko_KR.txt
2023-02-02 15:48:43 +08:00
Ing. Jan Kaláb
d8e81d41e4
Czech translation (#2185)
* Czech translation

* Fix missing translations

---------

Co-authored-by: Ing. Jan Kaláb <jan@kalabovi.org>
2023-02-02 15:48:16 +08:00
VenusGirl❤
fa3aa3b36f
Update ko_KR.json (#2177)
* Update ko_KR.json

* Update ko_KR.json

* Update ko_KR.json
2023-02-02 15:47:48 +08:00
MELERIX
e717d00d53
Update Spanish Latinoamérica translation (#2179) 2023-02-02 15:47:30 +08:00
wiz64
6bcaf19a1a
Update languages.json (#2172) 2023-01-16 15:35:25 +08:00
wiz64
bcbe8835d4
update Russian and Bengali languages.json (#2167) 2023-01-15 21:10:25 +08:00
gidano
ed746ce13e
Fixed hungarian text (#2163) 2023-01-15 21:10:11 +08:00
VenusGirl❤
07a790fc6a
Update languages.json (#2160)
Korean Update
2023-01-15 21:09:54 +08:00
Tayfun Akkoyun
fd393a02fd
Update languages.json (#2159)
"STR_4KN_UNSUPPORTED" line is translated to turkish language
2023-01-15 21:09:37 +08:00
longpanda
0501d03dbb Fix the syntax error in hu_HU.json 2023-01-15 13:15:51 +08:00
longpanda
c9939a8cfc Ignore reserved space when do non-destructive installation via GUI. (#2168) 2023-01-15 09:41:46 +08:00
longpanda
5067020a61 Add tip message when theme file contains non-enclosed literal values. (#2166) 2023-01-14 23:07:08 +08:00
longpanda
4f5334026e 1. Fix the issue that Ventoy2Disk_X64.exe can not run under altexe directory.
2. Fix the issue that VentoyPlugson_X64.exe exit silently.
3. Add missing /FS option for Ventoy2Disk.exe in Windows command line mode.
4. Ventoy2Disk.exe automatically change current directory when started from other directory.
2023-01-14 21:56:19 +08:00
longpanda
3e34dd8514 1.0.88 release 2023-01-13 21:57:44 +08:00
longpanda
4df793e021 1. Add new options for Windows CLI mode.
2. Add tip message for 4k native disk.
2023-01-13 20:55:40 +08:00
longpanda
e0132ac4b5 switch to en_US when use text mode. 2023-01-10 16:17:08 +08:00
VenusGirl❤
2b3192b098
Update ko_KR.json (#2152) 2023-01-10 15:48:22 +08:00
민웅기
7ee3a6d9f8
Update ko_KR (부트 -> 부팅) (#2147)
Changed the word "boot" to be spelled "부팅" rather than "부트" in the general context.

일반적인 맥락에서 단어 "boot"는 부트보다 부팅로 표기되므로 변경하였습니다.
2023-01-10 15:09:29 +08:00
Pierfrancesco Passerini
e1d3ca9fc4
Update italian language (#2141)
Small fix to Italian
2023-01-10 15:09:17 +08:00
Stefan Šućur
8653832551
Fixed and updated Serbian translations (both writing systems) (#2144)
* Update Serbian (both writing systems)

Fixed a stray Cyrillic word in the Latin text.
Translated the untranslated strings in both texts.
Changed a word in both texts.
Added part of a string that was missing in the Cyrillic version.
Fixed spelling mistakes in the Cyrillic text.

* Update languages.json

Added myself to the credits of the Cyrillic text too, as I forgot to do so earlier.
2023-01-10 15:08:54 +08:00
longpanda
c308892db0 Show file checksum menu title according to the existence of checksum value. 2023-01-10 12:23:35 +08:00
longpanda
1300f7f4f1 Fix the VHD(x) boot issue introduced in 1.0.87. 2023-01-10 09:37:05 +08:00
longpanda
d9182dbfa4 Fix the syntax error in F4 localboot 2023-01-10 09:17:18 +08:00
longpanda
e988c0dfe2 Fix that workaround #2 not working for Legacy BIOS access limit. 2023-01-08 21:35:50 +08:00
longpanda
0714971f8c Fix VTOY_WIN11_BYPASS_CHECK/VTOY_WIN11_BYPASS_NRO option web page display issue. 2023-01-07 20:14:38 +08:00
longpanda
3c03df31ce 1.0.87 release 2023-01-07 15:57:53 +08:00
longpanda
e24dacadcd Add /F option for VentoyPlugson.exe to use the system default browser.
By default it will firstly try to use Google Chrome if possible.
2023-01-07 15:35:47 +08:00
longpanda
315cabb945 Fix the file path when file checksum in F2 browse mode. 2023-01-07 11:33:04 +08:00
longpanda
72f25f14fc Merge branch 'master' of https://github.com/ventoy/Ventoy 2023-01-06 21:26:39 +08:00
longpanda
47e1553d23 Optimization for VTOY_WIN11_BYPASS_NRO option process. 2023-01-06 21:26:31 +08:00
MELERIX
9a2a7e83eb
Add Spanish Translation (json/txt) grub menu (#2135)
* Add Spanish Tranlsation (json/txt) grub menu

* renamed
2023-01-06 12:23:05 +08:00
K.B.Dharun Krishna
5f747148c6
grub/menu: Update Tamil translation (#2133) 2023-01-06 11:55:40 +08:00
longpanda
686ed11037 Optimization for Lenovo Recovery Image (USB unplug process) 2023-01-05 22:18:39 +08:00
longpanda
7fe4762faa 1. grub2 mode supports Porteus ISO file.
2. Optimization for Lenovo Recovery Image.
2023-01-04 21:46:40 +08:00
longpanda
eac1c35f76 Fix the bug when F2 browse and boot VHD/VHDX files in an extend logic partition. 2023-01-04 19:22:02 +08:00
longpanda
c7dcaa5734 1. Fix the blank item in the last of Language select menu
2. Fix the menu display VTLANG_NO_PERSISTENCE issue when use persistence
2023-01-04 19:19:32 +08:00
longpanda
4b17ee30c4 Add "return to previous menu" in secondary boot menu for convenience. 2023-01-04 15:55:32 +08:00
longpanda
a18aa36c01 Code optimization 2023-01-04 15:39:03 +08:00
Tyemak
1de7489c6d
Update ru_RU.txt (#2130) 2023-01-03 20:58:13 +08:00
longpanda
afb3340ce7 Disable Fn/L/Ctrl hotkeys when selecting auto install script or perssitence file. 2023-01-03 19:11:36 +08:00
longpanda
fdce4a756a Add support for Dell PER ISO. (#2113) 2023-01-03 16:43:17 +08:00
longpanda
5a7fa0c565 Support lenovo product recovery iso file. 2023-01-03 11:35:27 +08:00
longpanda
287d77224c Disable Fn/L/Ctrl hotkeys on select WIM menu. 2023-01-03 11:29:50 +08:00
longpanda
c6bd857cbe Support BSD style for .md5/.sha1/.sh256/.sha512 checksum file.
Support VENTOY_CHECKSUM file for checksum file.
(#2112)
2023-01-01 00:31:08 +08:00
wiz64
b4bb6efd3c
Update ru_RU.txt (#2120) 2022-12-31 20:59:08 +08:00
Hildo Guillardi Júnior
7386f64ed8
Update pt_PT.json (#2118) 2022-12-31 20:58:50 +08:00
Hildo Guillardi Júnior
044ca8811d
PT translate and SI grammar (#2117) 2022-12-31 20:58:38 +08:00
Tyemak
8c6fd872af
Update ru_RU.json (#2114) 2022-12-31 20:58:06 +08:00
longpanda
683101ae1a vtoyjump optimization.
Signed-off-by: longpanda <admin@ventoy.net>
2022-12-31 19:41:15 +08:00
longpanda
0e968e266e Update the F1 help text. WIMBOOT mode supports both Windows and WinPE ISO files. 2022-12-29 18:48:06 +08:00
longpanda
d94d59583a Search VTEFI directory for UEFI boot files.
When user install for example Windows in the reserved space of Ventoy USB stick in UEFI mode.
Windows will create part 3 as the EFI partition and when you boot the USB stick, the BIOS may skip Ventoy and directly boot the Windows.
To avoid this, we suggest to rename the directory name from EFI to VTEFI.
2022-12-26 22:08:23 +08:00
gidano
05bbef63c1
Edited! (#2105)
* Hungarian translation

* Hungarian translation

* HU update languages.json

Jól értettem, hogy a *#-t módosítani kell \r\n-re?!

* Edited!
2022-12-26 17:01:43 +08:00
longpanda
8923d4b8f1 Fix the menu title of F5 Tools ---> Power ---> $VTLANG_POWER_REBOOT_EFIFW 2022-12-26 16:56:53 +08:00
longpanda
377cd9e468 Update readme 2022-12-25 17:23:50 +08:00
longpanda
be78728342 1.0.86 release 2022-12-24 21:19:31 +08:00
Tayfun Akkoyun
3938fbb351
Update tr_TR.json (#2101) 2022-12-24 15:59:32 +08:00
longpanda
a2e7afd893 Update menu language translation 2022-12-24 10:16:13 +08:00
wiz64
27bb4a1168
Update bn_BN.json (#2100) 2022-12-24 10:06:41 +08:00
wiz64
b8b8c7bd66
Update hi_HI.json (#2099) 2022-12-24 10:06:29 +08:00
longpanda
12b51bcf09 Change the prompt format when check device failed. (#2094) 2022-12-24 09:39:27 +08:00
longpanda
911d5dcab9 Remove useless BypassStorageCheck registry when VTOY_WIN11_BYPASS_CHECK is set to 1. (#1873) 2022-12-23 23:41:57 +08:00
longpanda
f597497da6 1. Add VTOY_WIN11_BYPASS_NRO option in Global Control Plugin.
2. Change the default value of VTOY_WIN11_BYPASS_CHECK and VTOY_WIN11_BYPASS_NRO options to 1.
2022-12-23 23:17:39 +08:00
Frede H
54bca8c942
Added Danish (Dansk) to languages.json (#2096) 2022-12-23 16:01:45 +08:00
VenusGirl❤
6b422ad9c1
Update ko_KR.json (#2092) 2022-12-23 15:54:27 +08:00
wiz64
925d057883
Update ru_RU.json (#2091) 2022-12-23 15:54:08 +08:00
longpanda
a377dd6172 Support config ventoy_left/ventoy_top/ventoy_color in theme.txt.
The configuration must be the first line in theme.txt and must be in the following format.
ventoy_left_top_color: "@5%@95%@#0000ff@"

The format is very strict:
1. ventoy_left_top_color must start with no space in front of.
2. left/top/color options must be around with 4 @
2022-12-23 15:52:43 +08:00
longpanda
4707022ef9 Add prompt and wait for key when Ventoy check device failed. (#2094) 2022-12-23 11:42:22 +08:00
Tayfun Akkoyun
e03c73978a
Update tr_TR.json (#2090)
New Turkish menu interface lines is translated (VTLANG_CTRL_TEMP_SET,VTLANG_WIN11_BYPASS_CHECK,VTLANG_LINUX_REMOUNT,VTLANG_SECONDARY_BOOT_MENU)
2022-12-22 23:13:49 +08:00
longpanda
f434d1f5d0 Add Temporary Control Settings menu.
Refer https://www.ventoy.net/en/doc_ctrl_settings.html for details.
2022-12-22 22:14:51 +08:00
longpanda
23f8bc8aeb Add resolution_fit option in theme plugin. 2022-12-22 18:26:01 +08:00
wiz64
f2016ab899
Update Actions Image route (#2088) 2022-12-22 14:28:52 +08:00
wiz64
7acbf7e819
Update bn_BN.json (#2085) 2022-12-22 14:28:38 +08:00
Ida Bagus
0135bf1934
Update languages.json (#2087) 2022-12-22 10:04:22 +08:00
wiz64
f2c94bd963
Improve grammar (Readme.md) (#2086) 2022-12-22 10:04:01 +08:00
longpanda
676ae725ae Fix the egrep warning. (#2083) 2022-12-21 19:59:16 +08:00
longpanda
54dd35d277 Merge branch 'master' of https://github.com/ventoy/Ventoy 2022-12-21 13:22:11 +08:00
longpanda
3e75b2df3b VentoyPlugson: Add Windows duplicate file path check for different upper/lower case. 2022-12-21 13:21:54 +08:00
wiz64
2d1230cba4
Update hi_HI.json (#2081) 2022-12-20 21:17:49 +08:00
wiz64
309f85fd35
update ru_RU.json (#2080)
* Update ru_RU.json

* Update ru_RU.json
2022-12-20 21:17:41 +08:00
VenusGirl❤
a13d6d9c0e
Update ko_KR.json (#2079) 2022-12-20 21:17:24 +08:00
longpanda
9b7d6cbc3d Add theme plugin duplicate file check. (#2078) 2022-12-20 20:02:06 +08:00
longpanda
bf797ceadb Fix the drive letter case check issue for VentoyPlugson in Windows. (#2078) 2022-12-20 18:46:04 +08:00
longpanda
cd0c7ca884 Extend the donate link width. 2022-12-20 14:05:01 +08:00
longpanda
201f7cc13c Change the MBR partition type to 0x0C when select FAT32 for installation. 2022-12-20 00:16:01 +08:00
longpanda
44a3e23740 Optimization for the implement of menu languages. 2022-12-19 23:49:25 +08:00
9c3e1a6880
update Japanese translation (#2077)
* Remove unnecessary space.

* Unify the translation terms into which used in other files
  (language.json, help/ja_JP.txt...)
2022-12-19 22:21:27 +08:00
wiz64
8a664faa04
Update languages.json (#2076) 2022-12-19 22:20:51 +08:00
Hoàng Điềm Tĩnh
398ba9fb56
Update languages.json (#2075)
I update for Vietnamese lang. Please add to your the next release.
2022-12-19 22:20:34 +08:00
Tayfun Akkoyun
e7a0c2d359
Update languages.json (#2074)
hi master
STR_DONATE parameter is translated for turkish users again
2022-12-19 22:20:07 +08:00
longpanda
22ad828df2 1.0.85 release 2022-12-18 22:11:28 +08:00
longpanda
83f22173a5 menu language update 2022-12-18 17:30:29 +08:00
longpanda
2de7d9ffe0 Suppress some prompt window when install Ventoy. 2022-12-17 23:36:59 +08:00
Tyemak
5c174c4521
Update languages.json (russian translation) (#2070)
* Update languages.json

* Update languages.json
2022-12-17 23:34:03 +08:00
longpanda
c76ece4b74 Fix the format failure when install Ventoy. 2022-12-16 17:03:05 +08:00
longpanda
27eda4d1e7 Fix the issue when booting Peux distro iso file. 2022-12-13 12:17:46 +08:00
longpanda
acf5a84467 Add Arabic menu language. 2022-12-12 11:00:57 +08:00
longpanda
c93e406aa5 Add missing file. 2022-12-11 21:59:09 +08:00
longpanda
1b164e74e4 update pl_PL.json 2022-12-11 10:49:02 +08:00
longpanda
308cb86f83 Fix json syntax error. 2022-12-11 10:30:31 +08:00
longpanda
2ec593d355 Add pl_PL language for menu. 2022-12-11 10:22:39 +08:00
longpanda
594e735b91 Merge branch 'master' of https://github.com/ventoy/Ventoy 2022-12-10 19:27:49 +08:00
longpanda
6203366040 grub2 mode support KNOPPIX 2022-12-10 19:27:38 +08:00
Thomas De Rocker
64f4400305
Update languages.json (#2046) 2022-12-10 17:32:03 +08:00
Alexander Dolidze
d00e08e2e1
added Georgian (ka_GE) translation (json/txt) for grub menu (#2044)
Co-authored-by: Alexander Dolidze <alexander.dolidze@azry.com>
2022-12-10 17:31:48 +08:00
Hugo Carvalho
c6008be394
Update Portuguese(Portugal) Translation (#2039)
* Update languages.json

Update Portuguese (Portugal) language

* Update Portuguese(Portugal) Translation

* Update Portuguese(Portugal) Translation
2022-12-10 17:31:31 +08:00
longpanda
a5c6859f5f Add zh_TW menu language. 2022-12-09 21:36:32 +08:00
longpanda
497d4cc991 update grub2 mod file 2022-12-09 21:33:59 +08:00
VenusGirl❤
7e7687afe3
Update ko_KR.txt (#2038) 2022-12-08 21:11:04 +08:00
Ida Bagus
dd3276badf
Update id_ID.json (#2034)
first translation, if they find unrelevant translation, i will update it later
2022-12-08 21:10:49 +08:00
Ida Bagus
4a06f4a694
Update id_ID.txt (#2033)
fix little translation
2022-12-08 21:10:34 +08:00
Silejonu
c73bf256be
French translation additions & corrections (#2032)
* Update fr_FR.txt

* Update fr_FR.json
2022-12-08 21:10:17 +08:00
longpanda
21851f7e96 Optimization for booting memtest86-usb.img. 2022-12-05 11:19:46 +08:00
longpanda
f222f8cac9 Auto memdisk plugin support some IMA/IMG files. 2022-12-05 10:51:15 +08:00
gidano
40c4825aac
Hungarian translation (#2028)
* Hungarian translation

* Hungarian translation
2022-12-04 18:42:53 +08:00
VenusGirl❤
dd906e0b16
Update ko_KR.txt (#2025) 2022-12-04 17:38:48 +08:00
K.B.Dharun Krishna
324f2b927c
grub/*: add Tamil translation (#2023)
* grub/menu: Add Tamil translation

Signed-off-by: K.B.Dharun Krishna <kbdharunkrishna@gmail.com>

* grub/help: Add Tamil translation

Signed-off-by: K.B.Dharun Krishna <kbdharunkrishna@gmail.com>

Signed-off-by: K.B.Dharun Krishna <kbdharunkrishna@gmail.com>
2022-12-04 17:38:32 +08:00
K.B.Dharun Krishna
5797ca3396
grub/help/en_US: Fix typos (#2024)
* grub/help/en_US: Fix typos

* Apply suggestions from code review

* Fix typo in line 15
2022-12-04 17:37:25 +08:00
longpanda
b36b322c03 Update languages.json 2022-12-04 17:33:46 +08:00
longpanda
fd7e34b632 1.0.84 release 2022-12-04 15:33:16 +08:00
longpanda
e85c02756b 1.0.83 release 2022-12-04 13:15:18 +08:00
wiz64
c1d68bd787
Add Russian Tranlsation (json/txt) grub menu (#2022) 2022-12-04 11:18:33 +08:00
wiz64
a35a822723
add Bengali (bn_BN.json/txt) (#2019) 2022-12-04 09:22:26 +08:00
Tayfun Akkoyun
05137c83e2
Update tr_TR.txt (#2020)
tr_TR.txt Help file is updated.
2022-12-04 09:21:58 +08:00
VenusGirl❤
8058856182
Update ko_KR.json (#2021) 2022-12-04 09:21:36 +08:00
longpanda
33b958e112 Update language json files 2022-12-03 21:37:09 +08:00
Tayfun Akkoyun
9eb50a85e4
Update tr_TR.json (#2018)
Master hi!
I translated lines again. Can you UPDATE this file again?
2022-12-03 20:17:13 +08:00
Steve
3cc7e3772e
german translation (grub and related help) (#2016)
* updated german translation

translated the new strings

* german translation updated

* fixed STR_INSTALL_YES_TIP2

* german translation

* fix for F6

* german translation
2022-12-03 20:16:31 +08:00
longpanda
9c8292867f Update menu langauge json file 2022-12-03 17:53:42 +08:00
wiz64
a4053d2d05
add grub/menu hi.json (hindi) (#2014)
* add grub/menu hi.json (hindi)

* Update hi.json

* Update hotkey and rename

* Update and rename hi_HI.json to hi.json

* Rename hi.json to hi_HI.json

* Update hi_HI.json

* add grub/help/hi_HI.txt (hindi)
2022-12-03 17:45:47 +08:00
longpanda
5c14ea0a4a Add some menu language xx.json template. (copy from English) 2022-12-03 16:51:03 +08:00
longpanda
194e948cb6 Remove VTOY_HELP_TXT_LANGUAGE option from Global Control Plugin. 2022-12-03 14:33:52 +08:00
K.B.Dharun Krishna
c896c03efe
language.json: Update Tamil translation (#2009) 2022-12-03 13:52:47 +08:00
wiz64
574b4d850c
Update French [languages.json] (#2015) 2022-12-03 13:52:23 +08:00
wiz64
68a98325e6
Update German [languages.json] (#2006) 2022-12-03 13:52:08 +08:00
longpanda
25b055bb0f Hotkey change:
1. Change F1 from Memdisk to help
2. Add d/Ctrl+d for Memdisk
3. Add L for Language selection

So update the help txt files and menu json files at the same time.
2022-12-03 13:44:46 +08:00
longpanda
bda74cd89b VentoyPlugson supports multi-language menu option. 2022-12-02 20:46:57 +08:00
longpanda
511b8091eb Add muli-languages support for Ventoy menu.
F5 ---> Menu Language Select
Language files are in INSTALL/grub/menu/ directory.
2022-12-02 20:35:59 +08:00
VenusGirl❤
3be4aacd78
Update languages.json (#2003) 2022-12-02 20:26:34 +08:00
wiz64
2d8b27b172
Update Hindi & Bengali languages (#2002) 2022-12-02 20:26:21 +08:00
wiz64
c174410d35
Update Romanian Translation (#2001)
Co-authored-by: cezarlacatus 42448787+cezarlacatus@users.noreply.github.com
2022-12-02 20:26:06 +08:00
wiz64
f83e84f868
Fixed syntax errors for recent PRs (#1999) 2022-12-02 20:25:50 +08:00
dmitrygribenchuk
a39078b87a
add belarussian and update ukranian and russian (#1998) 2022-12-02 11:42:59 +08:00
Tayfun Akkoyun
2576235f97
Turkish update_language.json (#1996)
New Turkish translate rows are completed
2022-12-02 11:42:31 +08:00
longpanda
ee04af5243 Ventoy2Disk update:
1. Add UDF filesytem option.
2. Add Cluster Size option.
3. Support FAT32 for disk bigger than 32GB.
4. Fix the format fail issue.
5. Add a tip bubble with cluster size when mouse hover on the file system type string.
6. The secure boot lock character can not show in early Windows, change it to a yellow icon.
2022-11-30 21:12:43 +08:00
Ida Bagus
118bedd546
Indonesian translation update (#1978)
translating STR_PART_VENTOY_FS row & little change
2022-11-30 20:54:37 +08:00
longpanda
44ff3dd8d4 VentoyPlugson: Fix the garbled preview json for unicode characters. 2022-11-23 14:27:58 +08:00
wiz64
9da5a6ce65
Update Romanian Translation (languages.json) (#1968)
* Updated Romanian (languages.json)

Co-authored-by: cezarlacatus <42448787+cezarlacatus@users.noreply.github.com>

* Updated Romanian (languages.json)

Co-authored-by: cezarlacatus <42448787+cezarlacatus@users.noreply.github.com>

Co-authored-by: cezarlacatus <42448787+cezarlacatus@users.noreply.github.com>
2022-11-19 19:17:38 +08:00
marcellogianola
604b25ec82
Update languages.json (#1965) 2022-11-19 19:17:14 +08:00
Vasilis
0918355035
Update languages.json (#1963)
Updated Greek translation
2022-11-18 15:28:32 +08:00
wiz64
ce76fd5649
Update German, French (#1962)
Co-authored-by: galaxy2211 <56916688+galaxy2211@users.noreply.github.com>

Co-authored-by: galaxy2211 <56916688+galaxy2211@users.noreply.github.com>
2022-11-18 15:28:17 +08:00
MELERIX
42535f35bc
Update Spanish (Latinoamérica) translation (#1961)
* Update Spanish (Latinoamérica) translation

* Delete languages.json.bak
2022-11-18 15:25:38 +08:00
longpanda
68a9cebe19 1.0.82 release 2022-11-17 17:56:11 +08:00
wiz64
cc77c74bf4
Update Russian, Hindi, Bengali (languages.json) (#1959) 2022-11-17 17:15:29 +08:00
Tayfun Akkoyun
ee952e3f69
Turkish update.json (#1960) 2022-11-17 17:15:01 +08:00
longpanda
b11a499939 Update BOOT/BOOTX64.EFI and mm efi files from Fedora 37. 2022-11-16 22:34:37 +08:00
longpanda
fdf4693433 Ventoy2Disk.exe update.
1. Add exFAT/NTFS/FAT32 option when install Ventoy
2. Display Ventoy partition file system in physical disk
3. String "Status x%" is missing for translations (#1667)
2022-11-16 20:33:14 +08:00
VenusGirl❤
ac65c0fb24
Update languages.json (#1957) 2022-11-16 19:45:15 +08:00
wiz64
ea0afe7c8b
Update Bengali Translation (#1956) 2022-11-16 19:44:58 +08:00
wiz64
f8ca8b13d3
Update Hindi Translation (#1941) 2022-11-16 17:56:04 +08:00
longpanda
678a2abdf1 Fix the disk display error when pCloud virtual disk is installed in Windows OS. 2022-11-13 19:29:49 +08:00
longpanda
e645301713 Optimization for Windows unattended install process. 2022-11-10 10:10:10 +08:00
longpanda
43b415c032 Fix an issue that CGI backup tool can not open in WePE. 2022-11-08 15:27:08 +08:00
longpanda
311d2961ca Fix the issue that help line disappears when auto-going to a submenu. (#1939) 2022-11-02 20:13:12 +08:00
longpanda
1d66584190 Change Ventoy LiveCD GUI default language to English (#1938) 2022-10-31 09:40:10 +08:00
longpanda
553c853865 Fix the issue that Linux WEB/GUI does not restore MBR when updating. (#1935) 2022-10-30 13:39:19 +08:00
longpanda
7d90912a09 Add VTOY_SHOW_PASSWORD_ASTERISK option in global control plugon. (#1931) 2022-10-26 15:27:51 +08:00
longpanda
c2336f555a 1.0.81 release 2022-10-25 19:58:10 +08:00
longpanda
87391e8b32 Update BOOTX64.EFI MMX64.EFI 2022-10-23 21:41:05 +08:00
longpanda
f9c56c6686 update vtoyjump 2022-10-22 19:54:54 +08:00
longpanda
1ab1799b72 Code Optimization 2022-10-22 16:13:03 +08:00
longpanda
4a42bdfce7 Add support for easyOS easy-4.4.2-amd64.img. (#1926) 2022-10-22 15:28:16 +08:00
longpanda
3f09fb9a23 VentoyPlugson Update:
1. Add preview json feature
2. Add reset button
3. Add configuration active identifier for each tab
4. Bug fix
2022-10-21 16:06:13 +08:00
longpanda
c87ad1d734 Fix VentoyPlugson issue when ISO partition has a drive label with a space. (#1901) 2022-10-09 09:24:16 +08:00
longpanda
5590208885 Fix the issue that rockcluster, part of config missing during install. (#1900) 2022-10-08 10:07:39 +08:00
longpanda
09a6d33d62 Add _VTNORMAL identifier. 2022-10-07 17:28:31 +08:00
longpanda
9852252aba Merge branch 'master' of https://github.com/ventoy/Ventoy 2022-10-07 11:18:04 +08:00
longpanda
0585d83a8f Fix the issue that VTOY_LINUX_REMOUNT=1 does not work with Batocera 35 (#1878) 2022-10-07 11:16:45 +08:00
A1ive
ebe0b7d282
show asterisks ('*') when typing password (#1868)
* show asterisks ('*') when typing password

* add function ventoy_password_get
2022-09-25 12:31:32 +08:00
MELERIX
261ddcef45
added Spanish (Latinoamérica) translation (#1865)
* added Spanish (Latinoamérica) translation

* Update languages.json
2022-09-25 10:14:02 +08:00
longpanda
ebc5e2e993 1. Disable Fn hotkey during secondary boot menu.
2. Recover boot mode after boot fail from secondary boot menu.
2022-09-24 21:06:29 +08:00
longpanda
d58bd8c3f7 update README.md 2022-09-23 11:32:39 +08:00
longpanda
17f9e2fd09 1.0.80 release 2022-09-21 19:41:51 +08:00
longpanda
6b22a6200e upate issue template 2022-09-21 11:27:51 +08:00
longpanda
860dce6683 Fix languages.json syntax error 2022-09-19 23:00:57 +08:00
longpanda
7fc72d5ce6 Fix a bug when ISO contains a ks=file:/xxx boot parameter. 2022-09-19 22:35:02 +08:00
K.B.Dharun Krishna
b7c3cbd23b
languages.json: Add Tamil Language (#1848)
Adding Tamil Language translation to languages.json.

Signed-off-by: K.B.Dharun Krishna <kbdharunkrishna@gmail.com>

Signed-off-by: K.B.Dharun Krishna <kbdharunkrishna@gmail.com>
2022-09-19 21:40:31 +08:00
K.B.Dharun Krishna
3de97bdf44
Fix typo in GitHub Issue Templates (#1852) 2022-09-19 21:39:32 +08:00
longpanda
e79dc57ebe wimboot mode support Bob.Ombs.Modified.Win10PEx64 (#1842) 2022-09-16 01:05:58 +08:00
longpanda
7bf85a1ef8 Add 'i' 'u' hotkey. 2022-09-14 09:27:17 +08:00
crim50n
a5e0641226
Update to support a future version of MiniOS. (#1841)
* Update minios-hook.sh

* Update minios-disk.sh
2022-09-14 09:25:24 +08:00
longpanda
2c65eec9ec [update] Make injection plugin available in WIMBOOT mode. (#1834) 2022-09-13 22:04:19 +08:00
longpanda
0c310c5bd8 Make injection plugin available in WIMBOOT mode. (#1834) 2022-09-13 21:32:35 +08:00
Kamil Aronowski
c81b49807b
Mention EuroLinux support (#1832) 2022-09-12 23:18:55 +08:00
shulkalala
085e20f64d
Update languages.json - Spanish (#1827) 2022-09-12 23:18:30 +08:00
Henrique
ff3ce4da66
Fix Issue #1825 (#1826)
the modifications verify user privilege and prevent improper script execution.
2022-09-12 23:18:12 +08:00
longpanda
81d3492a61 Make injection plugin available in WIMBOOT mode. (#1834) 2022-09-12 22:40:00 +08:00
longpanda
635b1a1c6c Fix the 'overflow is detected' error in WIMBOOT mode for large ISO file. 2022-09-12 21:33:47 +08:00
longpanda
10b80f2690 Add w and r hotkey for WIMBOOT and GRUB2 mode. (#1837) 2022-09-12 11:24:57 +08:00
longpanda
36c21a21e4 Always use /bin/bash to launch VentoyPlugson.sh (#1809) 2022-08-23 20:50:18 +08:00
longpanda
13eb9829fa ALT Linux multiple initrd (#1784) 2022-08-14 23:10:46 +08:00
longpanda
88f77c01e4 bug fix 2022-08-13 22:12:00 +08:00
longpanda
11b30dab5f Fix typo in VentoyPlugson web page. (#1782) 2022-08-13 15:03:09 +08:00
longpanda
fb729146de Fix the issue when booting latest Gentoo live. (#1770) 2022-08-11 17:43:15 +08:00
longpanda
92bd6733dd Update MIPS GCC 7.3 download link. (#1757) 2022-07-29 13:50:11 +08:00
longpanda
9e28dd1394 1.0.79 release 2022-07-28 19:53:28 +08:00
longpanda
4100e7a886 Fix the repo missing for Kylin V10 SP2 Server 2022-07-26 23:08:40 +08:00
longpanda
a4f5ce2c9e update languages.json 2022-07-26 11:17:09 +08:00
aligoogo
c7967ea476
add georgian language (#1755) 2022-07-26 11:14:23 +08:00
sehnemvinicius
3e7f1ca764
Update portuguese translation (#1745) 2022-07-26 11:11:48 +08:00
longpanda
1bc18295ae Fix the bug that report 'invalid value for reserved space' in GTK. (#1752) 2022-07-25 10:49:57 +08:00
ShatteredMINT
b4f1f11742
remove '=' from reserved space check (#1753)
removes the (misplaced) '=' in the check of the configured reserved space in the 'on_part_cfg_ok' function.
This caused #1752
2022-07-25 10:46:07 +08:00
Jose Riha
20010c5e88
Fix and update Slovak translation (#1708) 2022-07-16 09:02:09 +08:00
Sopor
1de18e43c5
Update Swedish language (#1706)
* Update Swedish language

* Update Swedish language

Fixed the `YES`
2022-07-16 09:01:52 +08:00
lev741
15299d4d87
Updated Czech translation (#1705)
* Update languages.json

Updated Czech translation

* Update languages.json

Corrected typo
2022-07-16 09:01:30 +08:00
longpanda
5d6d6df39b autosel doesn't work since 1.0.77 (#1716) 2022-07-13 23:40:45 +08:00
longpanda
096cc99c3c Fix a bug that VTOY_LINUX_REMOUNT option doesn't take effect in openSUSE. 2022-07-13 22:40:32 +08:00
longpanda
602e8c7fdf Fix a bug when rhel based distribution has an external kickstart file. (#1717) 2022-07-12 17:13:49 +08:00
longpanda
da35a99f7c Support Fedora CoreOS (#1727) 2022-07-12 12:13:24 +08:00
longpanda
e46e24dde7 1.0.78 release 2022-07-01 19:10:12 +08:00
longpanda
0b81845e42 .ventoyignore also works in F2 browser mode. 2022-06-30 23:28:14 +08:00
longpanda
3c621e4aca Update Super-UEFIinSecureBoot-Disk to v3.4 (#1695) 2022-06-27 22:33:20 +08:00
longpanda
aecc579fcc Fix the bug when booting latest KaOS. (#1696) 2022-06-27 22:19:11 +08:00
longpanda
598af7f45c Auto remove the redundant trailing slash when set directory path on VentoyPlugson page. 2022-06-27 19:42:18 +08:00
longpanda
24b05c0345 Fix the bug when booting latest KaOS. (#1696) 2022-06-27 09:23:34 +08:00
Balázs Meskó
6d72617ef6
Update Hungarian translation (#1693)
* Update Hungarian translation

* Fixed a typo in languages.json
2022-06-24 18:52:25 +08:00
gidano
351f15ff18
Add files via upload (#1681)
Update Hungarian translaton
2022-06-20 16:26:31 +08:00
longpanda
1ee65a60c2 Fix a bug when booting TrueNAS Core 13.0. (#1684) 2022-06-20 15:29:27 +08:00
longpanda
ecbf45defe Fix an issue when booting StorageCraft StorageProtect SPX. (#1683) 2022-06-19 21:31:27 +08:00
longpanda
b976923f00 1.0.77 release 2022-06-19 13:56:49 +08:00
StoyanDimitrov
8db8e07b61
Update Bulgarian translation (#1677) 2022-06-18 16:35:04 +08:00
longpanda
f200c14730 fix build error 2022-06-17 12:25:21 +08:00
longpanda
c090197717 Fix build error 2022-06-17 09:36:01 +08:00
longpanda
3ac17aa825 Fix the issue that install media not recognized when install Clear Linux. (#1674) 2022-06-16 22:49:04 +08:00
longpanda
595b9441e9 Support prameters expansion in auto install script. 2022-06-15 20:53:35 +08:00
longpanda
0f3d48b3d9 Fix the chain load memory alloc failure in UEFI mode. 2022-06-15 20:50:25 +08:00
longpanda
61f289aa8a Fix a bug when booting daphile-21.01 2022-06-14 13:33:59 +08:00
longpanda
b099547af6 1.0.76 release 2022-06-12 17:54:51 +08:00
longpanda
23bd2d24e9 Enable secure boot support option by default. 2022-06-12 17:18:56 +08:00
longpanda
85d1910722 Enable secure boot support option by default. 2022-06-12 12:01:48 +08:00
longpanda
9b2b4aa354 Update UEFIinSecureBoot Disk v3-3. (#1657) 2022-06-12 10:31:06 +08:00
longpanda
45122b59c0 Add support for EasyOS 4.0 2022-06-11 22:47:38 +08:00
longpanda
5e607b7f9f Support EasyOS resize partition at first boot time. 2022-06-11 22:47:16 +08:00
longpanda
1c0b4ee903 Auto use memdisk/grub2/wimboot mode if the ISO file name has _VTMEMDISK/_VTGRUB2/_VTWIMBOOT suffix. (e.g. ubuntu-22.04-desktop-amd64_VTGRUB2.iso) 2022-06-08 10:15:56 +08:00
longpanda
bf2517bb25 Support Stratodesk NoTouch OS (#1652) 2022-06-05 11:32:15 +08:00
longpanda
1065a41992 Merge branch 'master' of https://github.com/ventoy/Ventoy 2022-06-04 11:43:42 +08:00
longpanda
954cb14d87 Support Stratodesk NoTouch OS (#1652) 2022-06-04 11:43:22 +08:00
Omar Namis
4f64aecfa3
Update languages.json (#1650)
- Updated the Arabic language
2022-06-02 16:28:50 +08:00
Steve
8af432b74b
updated german translation (#1648)
* updated german translation

translated the new strings

* german translation updated

* fixed STR_INSTALL_YES_TIP2
2022-06-02 16:28:35 +08:00
longpanda
d8bca311b2 Fix a bug when booting linux vdisk (.vtoy) file by F2 browser mode or by ventoy_grub.cfg in Legacy BIOS mode. 2022-06-02 10:18:16 +08:00
longpanda
025425f260 1.0.75 release 2022-05-31 19:22:02 +08:00
longpanda
b4120c4079 Update Super UEFIinSecureBoot Disk v3-2 2022-05-31 18:58:37 +08:00
longpanda
7f2f845a68 Auto use memdisk mode when booting iKuai OS. 2022-05-31 17:39:54 +08:00
longpanda
2cd22da8fb Fix a bug when booting latest Alpine linux. 2022-05-31 16:42:41 +08:00
longpanda
7b70a5278a Support programs loading for DLC Boot PE. (#1647) 2022-05-31 14:11:24 +08:00
M
f8b1f98304
Update Polish translation (#1637)
Fix typos and add new translations
2022-05-29 23:21:42 +08:00
longpanda
ddf0617d83 Fix the bug when booting ALT Linux in UEFI mode. (#1645) 2022-05-28 22:33:36 +08:00
longpanda
9b14b418b4 Fix a bug when UEFI booting KaOS-2022.04-x86_64.iso 2022-05-20 23:22:37 +08:00
longpanda
fe137522ad Fix a bug when boot in F2 browser mode if the computer has more than one disks with same size. 2022-05-08 11:41:12 +08:00
孟武.尼德霍格.龍
121d927367
Update Traditional Chinese Strings (#1615) 2022-05-07 17:35:17 +08:00
longpanda
75f3e4c5ee Add EDK debug info. 2022-05-06 14:44:10 +08:00
longpanda
fcf10deff3 Merge branch 'master' of https://github.com/ventoy/Ventoy 2022-05-05 19:12:15 +08:00
longpanda
4d4f958429 Fix the hardcoded dev/dm-0 2022-05-05 19:11:55 +08:00
e667233994
[l10n/jp] modify jp localization (#1608)
- Corrected no-need spaces (e.g. spaces after punctuation).
- Newly translated untranslated strings.
2022-05-04 16:55:05 +08:00
bovirus
57944520e5
Update italian language (#1598)
@ventoy 

Please check and merge. Thanks.
2022-05-04 16:54:56 +08:00
Urajmal
4544e221d3
Updated Slovenian language (#1597)
I did an update on Slovenian language, you can check out any problems.
2022-05-04 16:54:43 +08:00
longpanda
3263b64b8a Reduce required low memory. 2022-05-03 19:13:29 +08:00
longpanda
69da3a59d8 Reduce the required low memory. 2022-05-03 18:41:16 +08:00
longpanda
75c6c7257f Add debug info fix 2022-05-03 08:54:52 +08:00
longpanda
d4d8736620 Add debug info 2022-05-02 21:05:58 +08:00
longpanda
63f9331c31 Fix the bug when booting ATLAS Windows ISO. 2022-05-02 20:19:54 +08:00
longpanda
e1d161af4f Fix a issue when booting easyos 3.4.3+ 2022-05-02 18:21:30 +08:00
longpanda
9baa95359c Fix a bug in menu tip plugin webpage of VentoyPlugson. (#1602) 2022-04-30 14:52:00 +08:00
longpanda
5f3d7f3823 Fix the bug when booting linx iso (#1600) 2022-04-29 19:57:04 +08:00
longpanda
3d1dc81fda fix lvm issue 2022-04-29 01:13:04 +08:00
longpanda
3ebc610e7d fix the lvm issue 2022-04-29 00:51:56 +08:00
longpanda
60588c8442 1.0.74 release 2022-04-28 22:27:52 +08:00
longpanda
c4c05fc073 Add support for EulerOS 2022-04-28 22:18:02 +08:00
longpanda
0984f5ba58 Fix a bug that Windows ISO in local disk can not install when boot through F2 browser mode in Legacy BIOS mode. 2022-04-28 22:07:30 +08:00
longpanda
fd0d335eb6 Fix a bug when install Ventoy if the USB already mounted at a path that contains space. 2022-04-27 10:25:44 +08:00
Mastiggia
12a284b543
Update French translation (#1589) 2022-04-26 16:25:04 +08:00
longpanda
9e2e4ec0a9 Fix a bug for Linux GUI program when update from old release. (#1590) 2022-04-26 14:49:07 +08:00
longpanda
480afee1a7
Update FUNDING.yml 2022-04-25 22:14:13 +08:00
longpanda
1305945bc0
Update FUNDING.yml 2022-04-25 22:09:28 +08:00
longpanda
2feb148982 --xdg improvement 2022-04-25 10:38:16 +08:00
longpanda
5eec535391 --xdg improvement 2022-04-24 20:14:26 +08:00
longpanda
33a562c273 support inst.ks=cdrom:/xxx for CentOS 7 2022-04-24 15:28:32 +08:00
longpanda
75517039a1 Firstly try to use chainload to boot .efi files. 2022-04-20 12:19:47 +08:00
longpanda
620229508b Show the directory path in the return menu for TreeView mode and Browser mode. 2022-04-19 15:34:31 +08:00
Lyrx997
5553dd4fc4
Updated Italian language (#1574) 2022-04-18 17:53:11 +08:00
longpanda
89addae48f Fix the issue when booting Prime OS 2.1.0 (#1580) 2022-04-18 13:43:38 +08:00
longpanda
682e8cdc42 Fixe the boot issue for Fedora when VTOY_LINUX_REMOUNT=1 2022-04-16 22:17:23 +08:00
Ida Bagus
1882cfcce2
Update indonesian (#1573) 2022-04-12 10:32:52 +08:00
ShalokShalom
b8be46f0dc
Update README.md (#1570) 2022-04-11 09:03:40 +08:00
longpanda
07693bf840 cc 2022-04-09 18:07:04 +08:00
longpanda
b4a059dd68 Add missing file 2022-04-08 17:21:36 +08:00
longpanda
858eec99a1 Fix the log/ini owner for VentoyGUI in linux. 2022-04-08 15:35:22 +08:00
VenusGirl❤
8180382fe1
Update languages.json (#1564)
Korean Update
2022-04-07 15:12:09 +08:00
MELERIX
a5d9b1fd43
Update Spanish Translation (#1566) 2022-04-07 09:04:05 +08:00
VenusGirl❤
8b76e06f6d
Update languages.json (#1565)
Korean Update
2022-04-07 09:03:23 +08:00
VenusGirl❤
ecb133ed5e
Update languages.json (#1563)
Korean Update
2022-04-06 22:06:33 +08:00
longpanda
da20eb5568 1.0.73 release 2022-04-06 20:34:33 +08:00
A1ive
2d76fa7303
fix bugs (#1561)
* fix bug stopping iteration when --no-floppy is used

* fix gfxmenu theme config handling bug
2022-04-06 20:09:45 +08:00
Tayfun Akkoyun
8fc8cc6867
Update languages.json (#1560)
@ventoy 
I translated new adding lines(528,529) on Turkish Language
2022-04-06 19:13:54 +08:00
longpanda
132649c4e5 Add F5 Tools ---> Hardware Information menu 2022-04-06 19:12:59 +08:00
longpanda
c3c8100866 Merge branch 'master' of https://github.com/ventoy/Ventoy 2022-04-06 15:57:57 +08:00
longpanda
94e24e63c5 Add F5 Tools ---> Power ---> Reboot to EFI setup 2022-04-06 15:57:42 +08:00
reggie
c19cd649d8
Add all slovak and some czech translations (#1534)
* Add slovak translations

* Add missing czech translations

* Fix two typos

* Fix previous typo fix (im dumb, ok?)

Co-authored-by: longpanda <59477474+ventoy@users.noreply.github.com>
2022-04-06 15:24:25 +08:00
VlatkoS
20914350fb
Updated and fixed typos in the Macedonian language (#1535)
Updated and fixed typos in the Macedonian language
2022-04-06 15:19:49 +08:00
A1ive
8b411663cf
add support for uefi driver loading (#1552) 2022-04-06 15:13:37 +08:00
longpanda
01292939d3 update 2022-04-05 19:19:06 +08:00
longpanda
dcc5889677 Prevent DLL search order hijacking for VentoyPlugson.exe and VentoyVlnk.exe 2022-04-05 17:37:08 +08:00
longpanda
04828df028 1. When click install button, if the USB stick already installed with Ventoy, then popup a dialog to require a YES text input to confirm.
2. Prevent DLL search order hijacking
2022-04-05 17:26:59 +08:00
longpanda
2f95139c77 Update vtoytool 2022-04-02 23:24:10 +08:00
longpanda
f2bb3667c4 Support specify menu_tip position and color per theme. 2022-04-01 20:23:56 +08:00
longpanda
791da48673 Update for efi mouse 2022-03-30 19:52:04 +08:00
longpanda
f683bcbd59 update for scroll menu text 2022-03-30 16:35:07 +08:00
A1ive
15b8b1f358
support scrolling menu entry's text (#1539) 2022-03-29 22:50:11 +08:00
A1ive
a20592ecd1
Add mouse support for uefi (#1457)
* fix gcc11 warnings

* add mouse support for uefi
2022-03-29 22:49:37 +08:00
longpanda
ed1aa3d5be 1.0.72 release 2022-03-26 17:33:46 +08:00
longpanda
8e66110374
Update README.md 2022-03-26 16:07:51 +08:00
Kerollos Magdy
f5f65aa868
add GitHub actions state to README (#419)
* add GitHub actions state to README

* Update README.md

* remove link in README

Co-authored-by: Dylan M. Taylor <dylan@dylanmtaylor.com>
2022-03-26 10:51:26 +08:00
geeseven
4e5fcf211b
add IMG to no iso tip (#480) 2022-03-26 10:48:45 +08:00
Celine Lee
9789069c0d
Modify casting in protection against underflow (#1514)
Dear Ventoy community –
 
Our team is working with your code and we noticed this if logical expression:
 
                if (len - 1 - (int)(long)(pos - pwdstr) != 32)
 
We studied the surrounding code. We believe we understand the intention of the type casts in the above if statement. It seems they were meant to ensure an underflow doesn’t occur by the subtraction between to char pointers, which is a great catch (!). However, we believe the way the type casts are structured, the code is not actually protecting against such underflow because pwdstr isn’t cast into a signed long until after the subtraction occurs. To properly protect this code against underflow, we believe it should be changed to something like the following:

if (len - 1 - ((long)pos – (long)pwdstr) != 32)

Or, to enhance readability for junior engineers who may not know that the “long” type cast is implicitly of a signed integer type, we could include the `signed` keyword for added verbosity:
 
if (len - 1 - ((signed long)pos – (signed long)pwdstr) != 32)
 
Thank you!
2022-03-26 10:29:18 +08:00
longpanda
1cf45ac0c5 update 2022-03-26 10:07:22 +08:00
adrian5
40fe21f909
Fix wording, normalize capitalization (#762)
Co-authored-by: longpanda <59477474+ventoy@users.noreply.github.com>
2022-03-26 10:05:18 +08:00
George
e6bdf075ca
Changes to english language (#1140)
Changes detail to details and replug to reinsert. Which makes words flow with the sentance better.
2022-03-26 09:47:28 +08:00
Chrystian Rafael Rubio de Melo
7c76e57bf4
fixing grammar mistakes (#1482) 2022-03-26 09:46:35 +08:00
longpanda
7fe038b697 Merge branch 'master' of https://github.com/ventoy/Ventoy 2022-03-24 23:48:01 +08:00
longpanda
c01c69db3b Add missing execute bit when packing (#1530) 2022-03-24 23:47:43 +08:00
Celine Lee
0e996e74c9
Update error message to align with int16 range (#1513)
I think this might be a minor typo-- since the conditional checks for `priority` to be in the signed int16 range, the error message should line up with that expected range.
2022-03-22 19:15:25 +08:00
longpanda
1371159f0b update OS detection 2022-03-22 19:14:51 +08:00
longpanda
44b38dce74 Add support for venomlinux (#1526) 2022-03-22 17:52:56 +08:00
longpanda
392d8ef4fa 1.0.71 release 2022-03-11 21:36:42 +08:00
VenusGirl❤
d1900c75cd
Create ko_KR.txt (#1462)
Korean Help
2022-03-11 21:25:01 +08:00
fa7e1d5fa0
keep up with 1.0.67 (#1464)
Modify Japanese Translation for Grub Help Text to Keep up with 1.0.67 Release
2022-03-11 21:23:51 +08:00
longpanda
6ae8bf840d Suppress the Fn hotkey when VTOY_DEFAULT_IMAGE is already Fn>xxx 2022-03-08 19:26:04 +08:00
longpanda
ce862da402 1. Fix the bug when booing Easy Recovery Essentional for Windows10.
2. Fix the bug when booting FreeBSD 13.0 by F2 browser mode.
2022-03-08 18:27:07 +08:00
longpanda
6d4f5ff00b
Update FUNDING.yml 2022-03-07 00:14:40 +08:00
longpanda
ab0f25d097 Fixe the issue when booting PrimeOS 2.0.1 2022-03-06 21:04:36 +08:00
longpanda
ff14c07c4e Support Easy Recovery Essentials (#1481) 2022-03-06 19:31:18 +08:00
longpanda
f7fac26c91 Auto use memdisk mode for KolibriOS.iso 2022-02-23 23:35:57 +08:00
longpanda
ebae102f41 Fix the issue when set F2> as the default menu item. 2022-02-23 17:05:33 +08:00
longpanda
c3718d6001 Auto use memdisk mode for Memtest86+ iso file. 2022-02-22 22:23:33 +08:00
longpanda
d0744513a6 You can set { "VTOY_DEFAULT_IMAGE": "F2>" } to set F2 browser as the default menu entry. 2022-02-22 20:20:59 +08:00
longpanda
5b0fca8468 1.0.70 release 2022-02-19 10:28:09 +08:00
marcellogianola
27918eb3f9
Update languages.json (#1435) 2022-02-19 10:18:52 +08:00
Tayfun Akkoyun
7859271b20
Update tr_TR.txt (#1452) 2022-02-19 10:18:19 +08:00
longpanda
1c27c0b489 Updated help files (#1460) 2022-02-19 09:51:31 +08:00
longpanda
0f89c2767f Fix the bug when booting Windows 7 iso files in local disk. 2022-02-18 23:47:27 +08:00
longpanda
d1584c10b4 Add tip when save ventoy.json failed. 2022-02-18 09:48:57 +08:00
longpanda
43e921878b Fix a bug when creating multi-mod configuration for img_list in VentoyPlugson. 2022-02-17 20:06:18 +08:00
longpanda
23f4f18e27 Auto use grub2 mode for krd.iso 2022-02-17 12:15:57 +08:00
longpanda
53b95ae17b Support latest Qubes 4.1.0 release. 2022-02-17 11:40:54 +08:00
longpanda
e3506c0f10 Add cmdline check 2022-02-17 11:09:31 +08:00
longpanda
9118d5fe45 Add check for vlnk file suffix in save as 2022-02-17 10:49:56 +08:00
longpanda
f130325a9c Add commad line option -s in VentoyVlnk.exe. 2022-02-17 10:39:04 +08:00
longpanda
1ca48923da VentoyVlnk add cmdline mode.
VentoyVlnk.exe -i xxx.iso -o xxx.vlnk.iso
2022-02-17 10:13:27 +08:00
longpanda
730fdd5198 Update help text 2022-02-16 09:39:36 +08:00
longpanda
d0f3597b26 Fix Kiosk boot issue in latest Ventoy release. (#1446) 2022-02-15 23:59:28 +08:00
longpanda
045f53d768 1.0.69 release 2022-02-15 22:04:50 +08:00
longpanda
a173acaf17 1.0.68 release 2022-02-15 19:17:58 +08:00
longpanda
96fdd594f0 Support to F2 browse Ventoy partition self. 2022-02-15 14:42:46 +08:00
longpanda
62dc0033ad Make VTOY_TREE_VIEW_MENU_STYLE also control the browser menu style. (#1439) 2022-02-15 11:51:32 +08:00
longpanda
1c3fcbdfe9 Skip System Volume Information directory for F2 browser. 2022-02-15 11:39:09 +08:00
longpanda
7d37cab21d 1. F2 browser and vlnk support partitions in Ventoy reserved space (#1434)
2. Speedup browser
2022-02-15 11:31:03 +08:00
longpanda
a1c6fe2d24 1.0.67 release
support to browse and boot files in local disk.
2022-02-14 23:31:54 +08:00
longpanda
dbeb4023a2 Fixed to select the 1st menu item when switching between upper and lower sub-menus. 2022-02-14 14:29:50 +08:00
longpanda
58b1bbe0b5 Fix the issue when booting latest systemrescue 2022-02-14 13:28:26 +08:00
longpanda
86b13727ca Fix the issue when booting latest systemrescue 2022-02-14 12:31:06 +08:00
longpanda
006f26d07d Fix the Plugson web display issue of VTOY_DEFAULT_MENU_MODE. 2022-02-14 12:06:33 +08:00
longpanda
9203aa1ab3 Fix the issue when make vlnk for NTFS partition under Linux (#1430) 2022-02-13 21:25:58 +08:00
longpanda
5291d66736 Merge branch 'master' of https://github.com/ventoy/Ventoy 2022-02-13 17:01:10 +08:00
longpanda
ba5978d298 1.0.66 release 2022-02-13 17:00:39 +08:00
jakoblell
7f717a7fe9
Support /dev/disk/by-id/ symlinks in command-line installer (#1422)
* Allow symlinks as target device (for supporting /dev/disk/by-id)

* Use correct test (-L) for checking if it is a symlink

Co-authored-by: Jakob Lell <jakob@srlabs.com>
2022-02-06 23:13:15 +08:00
longpanda
c57717aea2 Add tip in Plugson web page when old ventoy.json contains invalid configuration. 2022-02-06 18:00:29 +08:00
longpanda
be0e19fc5b update tip message for recalbox img file. 2022-02-06 12:26:36 +08:00
longpanda
34a36bfc3e Fix the issue when booting the latest recalbox img file. (#1423) 2022-02-06 00:25:27 +08:00
longpanda
82e99a3b37 1.0.65 release 2022-02-04 17:05:14 +08:00
Sopor
b685431d66
Update Swedish language (#1415) 2022-02-03 12:08:42 +08:00
Guillem
8be8fd50b3
Add catalan language (#1407) 2022-02-03 12:08:27 +08:00
heidiwenger
999b15c4ef
Update languages.json (#1401)
Finnish language update
2022-02-03 12:07:31 +08:00
longpanda
28998edd94 Add check for size in CreatePersistentImg.sh (#1384) 2022-01-15 09:13:46 +08:00
longpanda
2ad69decad issue template update 2022-01-15 09:00:48 +08:00
longpanda
c2cc0bd3dc update tip message for VTOY_DEFAULT_SEARCH_ROOT (#1373) 2022-01-14 09:09:57 +08:00
longpanda
b128a0b6d3 fix the page language display issue in VentoyPlugson 2022-01-13 11:03:55 +08:00
longpanda
676831dbbe fix typo 2022-01-12 11:10:15 +08:00
longpanda
e5fa5e6d84 VTOY_LINUX_REMOUNT support for both 64bit(x86_64) and 32bit(i386) linux distro. 2022-01-12 10:24:44 +08:00
longpanda
76a6b8061c fix plugson page language issue 2022-01-11 09:39:01 +08:00
longpanda
036b58ff0c add intree flag for ko 2022-01-10 19:14:39 +08:00
longpanda
8e529c8559 Fix Plugson Web update issue. 2022-01-10 19:02:29 +08:00
longpanda
b8e624b0a0 1.0.64 2022-01-08 23:23:26 +08:00
longpanda
1f49265f29 1.0.64 release 2022-01-08 23:07:04 +08:00
longpanda
25dc323522 Support CentOS-9-Stream (#1335) 2021-12-24 10:32:59 +08:00
longpanda
446597d880 fix compile error for vtoyjump in debug mode. 2021-12-22 09:13:35 +08:00
longpanda
b9b6852631 1.0.63 release 2021-12-20 20:20:07 +08:00
crim50n
4a44a82840
Adding support for MiniOS. (#1317)
* Create minios-hook.sh

* Create minios-disk.sh

* Update ventoy-hook.sh

* Update grub.cfg

* Update README.md
2021-12-20 16:20:31 +08:00
kheyyam
f2e82862ab
Add Azerbaijani language (#1325) 2021-12-20 16:17:56 +08:00
gbrea
368151aa3b
Added Galician Language (#1323)
* Update languages.json, added Galician language

* Added Galician Language
2021-12-20 16:17:31 +08:00
Hoàng Điềm Tĩnh
b5dcaecffe
Update languages.json (#1320)
Please update Vietnamese Language.
2021-12-20 16:17:07 +08:00
longpanda
a4cfbd6799 Merge branch 'master' of https://github.com/ventoy/Ventoy 2021-12-08 11:55:23 +08:00
longpanda
ab964932cb Solus UEFI boot 2021-12-08 11:55:06 +08:00
VlatkoS
bcc81d31db
Updated Macedonian language (#1309)
Updated Macedonian language
2021-12-06 09:48:58 +08:00
longpanda
91330b97bf
Update grub.cfg 2021-12-05 21:02:14 +08:00
longpanda
fe7b9abcff Add missing manifest file. 2021-12-05 12:02:46 +08:00
longpanda
68d3b55167 misc update 2021-12-04 14:40:04 +08:00
longpanda
e1c26567a1 1. Add check for invalid characters in menu_class plugin.
2. Optimization for help language list process
2021-12-03 18:31:09 +08:00
4131d95cef
add ja_JP translation for Grub help text (#1294) 2021-12-03 17:09:30 +08:00
longpanda
8c18f91ac1 Fix the "plugson.tar.xz not found" error, when the path contains unicode characters. 2021-12-03 14:21:47 +08:00
longpanda
73fabd0c65 1.0.62 release 2021-12-02 20:02:42 +08:00
longpanda
0c140cf378 support LibreELEC 10.0.1 (#1268) 2021-12-02 15:17:52 +08:00
longpanda
293f677cbf VentoyPlugson update 2021-12-02 10:55:37 +08:00
longpanda
4bf43ab9d4 VentoyPlugson ---- A GUI ventoy.json configurator 2021-12-01 20:43:35 +08:00
salevdns
9eeb94e8b5
Add encryption support to CreatePersistentImg.sh (#1130)
Added option to create persistent fs inside LUKS container.
Had to change to #!/bin/bash to parse interactive user input for the encryption passphrase.
The _freeloop=$freeloop part is kind of bad style, but I kept it for now to keep changes minimal.
2021-11-25 11:44:31 +08:00
Hildo Guillardi Júnior
f4987fd7f4
Update Brazilian Portoguese language (#1273) 2021-11-25 11:39:13 +08:00
Alexander Berger
157c6f13ec
Updated Ukrainian and Russian localizations (#1269)
* Updated Ukrainian and Russian localizations

* comma in ukr locale
2021-11-25 11:38:55 +08:00
longpanda
6a506ee7f3 Optimization for FreeBSD fragments process. 2021-11-24 15:46:21 +08:00
longpanda
32643ecdbb compress 7za.exe 2021-11-23 17:29:25 +08:00
Ida Bagus
d2e5930520
Update languages.json (#1264) 2021-11-22 09:41:40 +08:00
944f376ffe
Modify Japanese Localization (#1261)
- Corrected no-need spaces (e.g. spaces after punctuation).
- Unified the message style.
- Newly translated untranslated strings.
2021-11-20 13:51:20 +08:00
longpanda
d402338ade Optimization for shell script (#1259) 2021-11-19 09:15:09 +08:00
longpanda
d938100eeb 1. Add default_file option in theme plugin
2. Add F5 Tools --> Theme Select menu to swith between themes
2021-11-16 19:32:23 +08:00
longpanda
a4200ed99e Merge branch 'master' of https://github.com/ventoy/Ventoy 2021-11-16 15:05:05 +08:00
longpanda
e4ccd5115e Optimization for FreeBSD 2021-11-16 15:04:41 +08:00
marcellogianola
cdb727dd22
Update languages.json (#1247) 2021-11-16 08:57:40 +08:00
Thomas De Rocker
6b4093fb93
Update Dutch translations (#1246) 2021-11-15 23:21:51 +08:00
longpanda
21450d4a56
Update Ventoy2Disk.sh
(#1245)
2021-11-15 23:20:33 +08:00
longpanda
164c8d6505 Optimization for FreeBSD distro. 2021-11-15 16:00:30 +08:00
孟武.尼德霍格.龍
37e7a539f9
Update Traditional Chinese (#1240)
Update Traditional Chinese strings
2021-11-15 09:18:02 +08:00
longpanda
b5a649f96f 1.0.61 release 2021-11-13 22:49:51 +08:00
B.O.S.S
443a1344f2
Update Polish translation (#1233) 2021-11-13 19:55:48 +08:00
VenusGirl
d3de1a91f8
Update languages.json (#1227)
Korean Update
2021-11-13 19:55:35 +08:00
longpanda
580ad598f6 Merge branch 'master' of https://github.com/ventoy/Ventoy 2021-11-13 19:53:09 +08:00
longpanda
0891e34d47 1. Fix some bugs when do update after non-destructive installation.
2. Call chkdsk to fix the volume before shrink.
2021-11-13 19:52:42 +08:00
longpanda
4d777090cb
Update README.md 2021-11-12 20:59:40 +08:00
longpanda
b0568922d2 1.0.60 release 2021-11-12 19:56:05 +08:00
soares23
69b6bb8fca
Create de_DE.txt (#1223)
Create  Grub Help de_De.txt
2021-11-12 14:24:14 +08:00
bovirus
3d686c27d7
Update Italian translation (#1218)
@ventoy 

Please check and merge. Thanks.
2021-11-11 15:36:24 +08:00
Steve
90ba217ec7
updated german translation (#1216)
translated the new strings
2021-11-11 15:35:56 +08:00
Tayfun Akkoyun
fab070ef64
Update Turkish Language (#1215) 2021-11-11 15:35:26 +08:00
longpanda
b3869b6894 1.0.59 release 2021-11-10 19:44:40 +08:00
longpanda
563214ed40 Add experimental support for Non-destructive Installation in Windows. 2021-11-10 17:53:21 +08:00
longpanda
b67f738b00 Update for Ventoy2Disk.exe 2021-11-08 14:56:35 +08:00
longpanda
a9c539572b Show a warning message if ventoy.json is in UCS-2 encoding. (#1125)
ventoy.json must in UTF-8 encoding. The BOM is auto skipped if exist.
2021-11-08 14:55:08 +08:00
longpanda
32602a79ab 1.0.58 release 2021-11-06 17:54:11 +08:00
longpanda
863eafd2cc
Update README.md 2021-11-04 18:27:50 +08:00
longpanda
0f135b6646
Update README.md 2021-11-04 18:26:37 +08:00
longpanda
675c24ffa3
Update README.md 2021-11-04 18:25:43 +08:00
longpanda
cd309eb663 template 2021-11-04 17:56:08 +08:00
longpanda
5cdd6540a4 template 2021-11-04 17:55:23 +08:00
longpanda
fde2e4430c template update 2021-11-04 17:51:30 +08:00
longpanda
9a471f4956 template update 2021-11-04 17:49:55 +08:00
longpanda
1f3b3afa35 template update 2021-11-04 17:44:32 +08:00
longpanda
6947f2a047 update template 2021-11-04 17:38:28 +08:00
longpanda
0a15e4e427 Add image report template. 2021-11-04 17:20:42 +08:00
longpanda
e763d7590f Fix a bug when booting HDM17x64_17.20.0_ADV_Linux_Downloadly.ir.iso 2021-11-02 23:23:39 +08:00
longpanda
f842d46f90 Fix the false error report about ventoy.jsonxxx file. (#1190) 2021-11-01 19:45:53 +08:00
longpanda
cc1cc6c301 misc update 2021-11-01 19:32:43 +08:00
Allan Nordhøy
9f3d209798
Norwegian Bokmål language added (#1189) 2021-11-01 09:37:59 +08:00
longpanda
fc742244ab
Update README.md 2021-10-30 12:04:43 +08:00
longpanda
3e66227dae
Update FUNDING.yml 2021-10-30 11:55:27 +08:00
longpanda
f32d342f66 1.0.57 release 2021-10-29 22:58:15 +08:00
Ida Bagus
09d7ae68e7
Create id_ID.txt (#1181) 2021-10-29 17:43:11 +08:00
Hugo Carvalho
68fefbc1fc
Add pt_PT.txt (#1180)
Add pt_PT.text to INSTALL/grub/help/
2021-10-29 17:43:00 +08:00
Hugo Carvalho
8d893d4c94
Update Portuguese(Portugal) language (#1179) 2021-10-29 17:42:49 +08:00
Tayfun Akkoyun
84798a4f7a
Update tr_Tr.txt (#1178)
new lines was translated
2021-10-29 17:42:33 +08:00
longpanda
87f88eeb2b [Ventoy2Disk.exe] improve Windows edition reporting 2021-10-29 09:28:20 +08:00
longpanda
7b2615744c Update help information 2021-10-28 18:16:50 +08:00
vboucard
d7faff4438
French translation of help messages (#1176) 2021-10-28 18:00:38 +08:00
Ida Bagus
f15dfd7409
Update languages.json (#1174) 2021-10-28 18:00:23 +08:00
longpanda
09162e8d97 Improvement for multi-mode option.
Now you can use for example theme_uefi and theme at the same time.
2021-10-27 20:08:47 +08:00
longpanda
eb8fcc8f30 Add hr_HR/sr_CY/sr_SR languages for help information. 2021-10-26 10:37:41 +08:00
longpanda
5fcb3971bc Optimization for Ventoy2Disk.exe 2021-10-26 09:18:41 +08:00
longpanda
e47e4484ce Optimization for Ventoy2Disk.exe 2021-10-25 20:38:04 +08:00
longpanda
7e26decb31 Update help information 2021-10-25 11:02:46 +08:00
longpanda
e713946fd0 Case insensitive when checking checksum value. 2021-10-25 09:29:51 +08:00
longpanda
a93b0f6656 Add .md5/.sha1/.sha256/.sha512 check file feature.
Hotkey m is for calculate checksum and print the result.
If also exist a .md5/.sha1/.sha256/.sha512 file, then it will check the result with the value in the file.
The .md5/.sha1/.sha256/.sha512 suffix is appended to the original file name not replace the original suffix.
For example:
/ISO/Ubuntu-20.04-amd64-desktop.iso
/ISO/Ubuntu-20.04-amd64-desktop.iso.md5
2021-10-24 18:52:09 +08:00
longpanda
836e1aa11e Add support for boot conf replace for distro which use systemd-boot in UEFI mode.
(#1170)
2021-10-23 23:15:25 +08:00
longpanda
154bbc6e5f hotkey optimization
h is equal to Ctrl+h
m is equal to Ctrl+m
2021-10-23 21:18:28 +08:00
longpanda
d151e74336 Optimization for Ventoy2Disk.exe 2021-10-23 15:46:28 +08:00
longpanda
df87cafdfb Optimization for Ventoy2Disk.exe 2021-10-23 11:26:16 +08:00
longpanda
09494a5b23 Optimization for Ventoy2Disk.exe 2021-10-22 22:30:38 +08:00
longpanda
e15a1c5ece Optimization for pyabr 2021-10-22 18:16:50 +08:00
longpanda
f5843f576b 1.0.56 release 2021-10-22 17:19:01 +08:00
longpanda
be5bc6f3b7 Optimization for Ventoy2Disk.exe 2021-10-22 11:59:51 +08:00
longpanda
f3b65452f4 Add extra check.
Still, Ventoy is used in some non standard way. (e.g. WuYouBBS)
I have explained in
8bbd5a14a3

So I add an extra check.
This is also a prepare for the future Ventoy secure boot policy.
2021-10-22 11:58:49 +08:00
longpanda
ec4b6c2a2c Fix a bug when booting Porteus 4.0 i586 20170701.iso 2021-10-21 20:23:32 +08:00
longpanda
be8b6e8976 Optimization for Ventoy2Disk.exe 2021-10-21 19:14:44 +08:00
longpanda
82b1faa132 Ventoy2Disk.exe update 2021-10-20 23:21:10 +08:00
longpanda
52ae65f54d Optimization for Ventoy2Disk.exe 2021-10-20 22:57:18 +08:00
longpanda
ee104bfa97 Optimization for Ventoy2Disk.exe 2021-10-20 17:27:06 +08:00
longpanda
9cfd05811b Add timeout option for auto_install/persistence plugin (#1161) 2021-10-20 17:00:20 +08:00
Tayfun Akkoyun
0c66908935
Create tr_TR.txt (#1157)
Mater @ventoy 
I translated English help file to Turkish language...Can you add this file?
2021-10-20 11:15:32 +08:00
Sopor
f53de3bdb0
Update Swedish language (#1163) 2021-10-20 11:14:17 +08:00
marcellogianola
8516786b31
Update languages.json (#1154) 2021-10-20 11:13:58 +08:00
longpanda
f7c78879c7 Support Eset SysRescue image file. (#1162) 2021-10-20 10:43:36 +08:00
longpanda
f3e267a09e support ALT rescue 2021-10-19 23:07:27 +08:00
longpanda
7c1370dcb0 Fix the long delay for Tails 2021-10-19 20:12:50 +08:00
longpanda
1b5aa9c61d Fix the long delay for Tails 2021-10-19 19:48:46 +08:00
longpanda
d6eba15d71 1. Add Ctrl+h hotkey for help
2. Add VTOY_HELP_TXT_LANGUAGE option in Global Control plugin
3. Add Ctrl+m hotkey for file cheksum
2021-10-19 17:42:32 +08:00
longpanda
734c7b8ac4 1.0.55 release 2021-10-17 21:56:30 +08:00
longpanda
0fa25c4526 1. Add support for some special WinPE
2. Add VentoyAutoRun.bat feature
2021-10-16 23:34:53 +08:00
longpanda
1473be0e4c Improve the success rate of Ventoy2Disk.exe installation and upgrade 2021-10-16 23:34:20 +08:00
longpanda
cd9aa16b20 Add support for Pyabr OS 2021-10-16 23:32:39 +08:00
longpanda
a9be2fd4d9 Improvement for some special WinPE 2021-10-14 11:27:22 +08:00
longpanda
f354d2b733 misc update 2021-10-12 20:10:37 +08:00
longpanda
aa033e1fb6 1.0.54 release 2021-10-12 19:20:02 +08:00
longpanda
9351fe4f97 Fix a bug that menu_tip is not shown for the default menu item. 2021-10-12 16:02:25 +08:00
longpanda
67b8a34e8c Support WinPE with PESET.EXE 2021-10-12 11:24:04 +08:00
longpanda
c18399e8b4 Add support for 小鱼儿yr系统维护PE 2021-10-11 21:11:52 +08:00
longpanda
5a591c1ae7 Optimization for LiveCDGUI 2021-10-11 17:44:12 +08:00
longpanda
e208199cca Optimization for LiveCDGUI 2021-10-10 10:34:17 +08:00
longpanda
4c9065a60d Fix a bug when booting trisquel 10 (#1127) 2021-10-10 09:51:13 +08:00
longpanda
4fd4977c3a Fix a bug when install Untangle 2021-10-09 22:53:48 +08:00
longpanda
93614c3251 support Porteus v5.0rc3 2021-10-09 19:22:42 +08:00
longpanda
1db0827463 misc update 2021-09-30 13:54:44 +08:00
longpanda
72d0fd0dd4 Optimization for GUI LiveCD 2021-09-30 13:40:48 +08:00
longpanda
47797f0285 Optimization for GUI LiveCD 2021-09-30 07:37:49 +08:00
longpanda
849eb7bf2c chown root for LiveCD GUI 2021-09-29 22:20:49 +08:00
longpanda
32c5b5deea Add GUI LiveCD 2021-09-29 19:26:50 +08:00
longpanda
d72bb15956 1.0.53 release 2021-09-27 21:00:08 +08:00
longpanda
89a34bac18 optimization for deepin/uos latest release 2021-09-25 11:22:55 +08:00
longpanda
8cecdae8f9 Support shrink persistence dat file for ext4 filesystem. 2021-09-24 10:07:32 +08:00
longpanda
471432fc50 Optimization for VentoyGUI 2021-09-22 14:44:50 +08:00
Thomas De Rocker
a78e19608b
Update languages.json (Dutch translations) (#1105) 2021-09-18 09:13:38 +08:00
Anton Grouchtchak
5e97d56033
Update Ukrainian and Russian translations (#1104) 2021-09-17 15:29:40 +08:00
albanobattistella
a5041ad43c
Update languages.json (#1103) 2021-09-17 10:02:17 +08:00
3149a67599
Modify Japanese Localization (#1102)
* modify Japanese localization

- Corrected duplicate punctuation.
- Changed the font to one that is compatible with Japanese.
- Unified the terminology.
- Newly translated untranslated strings.

* modify Japanese localization

- Unified the terminology.
2021-09-17 10:01:43 +08:00
MELERIX
d0b7927b51
Update languages.json (#1088)
- Renamed "disk" to "device" for consistency, due not all devices are essentially disks.

- Minor changes in Spanish translation.
2021-09-17 09:58:36 +08:00
longpanda
8775684367 1.0.52 release 2021-09-13 18:48:09 +08:00
longpanda
d148139227 Add QT GUI install program 2021-09-13 16:41:51 +08:00
longpanda
dd2411d7d4 Add Linux native GUI program for Ventoy2Disk.
x86_64    gtk2/gtk3
i386      gtk2/gtk3
aarch64   gtk3
mips64el  gtk3
2021-09-08 10:44:41 +08:00
longpanda
7db83dc0f1
Update README.md 2021-08-31 19:50:35 +08:00
longpanda
787d950f28
Update README.md 2021-08-31 19:47:38 +08:00
longpanda
892a819da4 Add support for Emergency Boot Kit 2021-08-31 19:43:30 +08:00
longpanda
bfc5eaebb9 Continue to boot even the ISO file size is invalid. 2021-08-31 17:04:09 +08:00
longpanda
e7d05df9fa
Update issue_template.yml 2021-08-31 16:47:40 +08:00
Oğuz Ersen
ca07b52cb2
Update languages.json (Turkish) (#1077) 2021-08-30 18:06:57 +08:00
longpanda
1a2a35f5bc add cryptsetup 2021-08-30 10:54:16 +08:00
longpanda
d71514f23e 1.0.51 release 2021-08-27 20:36:32 +08:00
longpanda
c5af17e04e experimental support for chromium os (fydeos/cloudready) 2021-08-26 14:17:44 +08:00
longpanda
05e208ea2a Support Lenovo EasyStartup 2021-08-23 16:56:17 +08:00
longpanda
112c557428 Show a warning message if the path of /ventoy/ventoy.json case mismatch. 2021-08-19 11:40:23 +08:00
longpanda
92db873b5c misc update 2021-08-18 23:00:11 +08:00
longpanda
3c01eec4af Add F4-->Search and boot xorboot 2021-08-17 14:44:43 +08:00
Vladimir Ulianitsky
5c6d18fcd4
Fix for PATH with spaces (#1060) 2021-08-17 10:01:42 +08:00
longpanda
84ec4b0de4 Support escaped quotes (\") in ventoy.json. (#1062) 2021-08-17 09:25:00 +08:00
longpanda
9615e7eaa0 Support 2k10 PE x86 series 2021-08-16 00:39:26 +08:00
longpanda
6a244ff260 Fix the mount issue for 2K10 Win7x64 PE 2021-08-16 00:00:21 +08:00
longpanda
b5503a7375 1.0.50 release 2021-08-14 20:30:28 +08:00
longpanda
0b7fa630a4 Support some special Win7PE 2021-08-14 11:49:51 +08:00
longpanda
7babe823d6 Add F5-->Tools-->Ventoy UEFI Utilities-->Show EFI Drivers feature. 2021-08-12 19:47:43 +08:00
longpanda
6db513a067 Fix the boot issue for Windows UEFI on some Dell server. (introduced since 1.0.48) 2021-08-12 14:26:47 +08:00
longpanda
bafac7479d Fix the boot issue for Untangle ISO in legacy bios mode. (#1054) 2021-08-11 09:44:09 +08:00
longpanda
d3138479d7 Fixe the boot issue for Untangle ISO (#1054) 2021-08-10 09:18:35 +08:00
longpanda
56a1543f7d Fix an issue when install some Lite Windows version with special file name.
We need to wrap the file name in quotation marks when use imdisk to mount the iso file.
2021-08-07 10:55:41 +08:00
longpanda
659ac1cfe3 Fix "Failed to open random seed file" error message for arch linux 2021-08-04 18:53:09 +08:00
longpanda
c83daa86b6 Fix the check media issue for SUSE/openSUSE 2021-08-04 11:24:50 +08:00
longpanda
dfcfaa9967 issue template update 2021-08-04 09:20:02 +08:00
longpanda
188f9e707c Change rufus 3.15beta+ to 3.15+ 2021-08-04 09:14:18 +08:00
longpanda
8b975b5e80 1.0.49 release 2021-08-03 17:31:39 +08:00
MELERIX
2ab717cc66
Updated Spanish Translation (#1039) 2021-08-03 14:53:57 +08:00
longpanda
88793d548a Compatibility improvement for some WinPE 2021-08-03 14:53:29 +08:00
longpanda
5fea6eab7e Add Bulgarian language 2021-08-03 10:05:01 +08:00
Ida Bagus
5d55dc68ae
Indonesian update (#1038) 2021-08-03 08:58:17 +08:00
VlatkoS
2c320aad60
Updated Macedonian language (#1037)
Updated Macedonian language
2021-08-03 08:57:54 +08:00
Hoàng Điềm Tĩnh
b63034b2c7
Update languages.json (#1036) 2021-08-03 08:57:43 +08:00
longpanda
6c113880e5 Fixed the boot issue for "StorageCraft Recovery Environment CrossPlatform" in UEFI mode. 2021-08-02 22:50:38 +08:00
longpanda
e2656c287b Compatibility improvement for some WinPE 2021-08-02 21:03:43 +08:00
longpanda
d8433985e7 1.0.48 release 2021-08-01 21:50:36 +08:00
Diacius
b003105925
Improve English Language (#963)
Changed `clear` to `clearing` and `detail` to `details`
2021-07-31 09:21:57 +08:00
fossdd
2ca2c83b6b
Let the link to build from source also work on gitee and local copies. (#1009)
The Link linked to a GitHub page. But markdown also support link in the directory: Now the link works in your local markdown viewer, github and gitee, to their own page instead that all redirect to GitHub
2021-07-31 09:21:02 +08:00
VenusGirl
dff7e495ca
Update languages.json (#1003)
Update Korean
2021-07-31 09:20:43 +08:00
VenusGirl
cf0f395c56
Update languages.json (#1002)
Update Korean
2021-07-31 09:20:23 +08:00
Tayfun Akkoyun
69bc90da42
Update languages.json (#1004)
New Lines of language.json file was translated for Turkish language. Can you update language.json file?
2021-07-31 09:20:06 +08:00
Hoàng Điềm Tĩnh
ffc40234ca
Update Vietnamese for languages.json (#1018)
* Update languages.json

Update Vietnamese for languages.json

* Update languages.json

* Update languages.json
2021-07-31 09:19:52 +08:00
Thomas De Rocker
e57daa5065
Update languages.json (#1014) 2021-07-31 09:19:32 +08:00
ensag-dev
5c733a20f8
Update occitan (#1012) 2021-07-31 09:19:13 +08:00
longpanda
069342ab9a change ownership when cpio pack 2021-07-27 22:18:39 +08:00
longpanda
32a964eded add vtoytool 01 2021-07-27 21:28:47 +08:00
longpanda
51b92f398a misc update 2021-07-27 19:10:30 +08:00
longpanda
5d0ebf4510 support custom arch iso (#1021) 2021-07-27 19:08:40 +08:00
longpanda
cf94487ad5 misc update 2021-07-26 15:31:56 +08:00
longpanda
af83f46a3d Merge branch 'master' of https://github.com/ventoy/Ventoy 2021-07-26 15:30:54 +08:00
啊o额iu鱼
4910e9f380
Mirror action check owner (#1016) 2021-07-25 20:00:23 +08:00
longpanda
fb38b321c2 Code Optimization 2021-07-24 19:03:09 +08:00
longpanda
7b78fe555e Support nested boot.
For example: Ventoy-->rEFInd.iso-->Ventoy-->Windows.iso
2021-07-24 18:47:39 +08:00
longpanda
094ba61848 Fix Windows boot issue when Ventoy is booted from rEFInd 2021-07-24 18:45:51 +08:00
longpanda
faa0e46d3a Fix the missing program issue for EasyU 2021-07-23 23:26:27 +08:00
longpanda
537f0eaa7e 1.0.47 release 2021-07-17 17:42:06 +08:00
longpanda
c8cf9b7ce2 Speedup md5sum/sha1sum/sha256sum/sha512sum command 2021-07-16 01:36:10 +08:00
longpanda
4c71d7c190 Support WinPE which contains pecmd.exe 2021-07-16 01:03:01 +08:00
longpanda
47f9f2c42c Add support for MocaccinoOS distro 2021-07-15 17:48:03 +08:00
longpanda
fc3a5fae36 Fixed HBCD boot issue. (#992) 2021-07-11 10:14:16 +08:00
longpanda
b3982d4930 Fixed a bug when booting big boot.wim file. 2021-07-11 01:02:00 +08:00
longpanda
c280baae27 Add Ventoy Sparse Image Option 2021-07-10 09:41:52 +08:00
longpanda
425d640480 Fixed a bug for ventoy_openwrt.xz check. 2021-07-10 09:20:54 +08:00
longpanda
07d4140cf4 Optimization for booting openwrt 2021-07-09 17:35:19 +08:00
longpanda
90ae07d227
Update README.md 2021-07-08 16:39:32 +08:00
longpanda
e3e21eb6e6 issue template 2021-07-06 22:52:26 +08:00
longpanda
c8ce2ae85a issue template 2021-07-06 22:51:27 +08:00
longpanda
c02a6955c3 Add check for the built-in browser in WebDeepin.sh 2021-07-06 10:10:59 +08:00
David P
6b78603dd3
fix Parabola rEFInd booting (#989)
newer Parabola rEFInd ISOs need to run vt_linux_get_main_initrd_index to actually work, just like the systemd-boot ISOs
2021-07-06 10:07:21 +08:00
longpanda
07a386c963 Add issue template 2021-07-05 16:49:31 +08:00
longpanda
eb048c0075 Remove the 2TB limit for the reserved space in Ventoy2Disk.exe 2021-07-05 13:40:19 +08:00
longpanda
37ac3f312f Optimization for booting openwrt 2021-06-28 15:15:39 +08:00
longpanda
092cff8429 Support some floppy image in Memdisk mode 2021-06-25 12:34:28 +08:00
longpanda
b347c1b5da Optimization for booting OpenWrt 2021-06-25 11:49:45 +08:00
longpanda
da746c608f Set hidden attribute for VTOYEFI part in GPT partition style 2021-06-21 13:27:41 +08:00
longpanda
81aa56955a optimization for boot openwrt 2021-06-20 21:44:37 +08:00
longpanda
d1679871a6 optimization for booting openwrt 2021-06-20 20:20:17 +08:00
longpanda
f383052013 add debug info 2021-06-20 11:28:19 +08:00
longpanda
667f5bcc1b Fix the Memdisk/WIMBOOT mode/... tip message display error
When VTOY_DEFAULT_IMAGE was set to F6>xxxx, if you press F1 or ctrl+w, the tip message will show ??
2021-06-18 10:41:41 +08:00
longpanda
af69cb7f44 1.0.46 release 2021-06-13 20:29:11 +08:00
longpanda
7bb13fc18a Merge branch 'master' of https://github.com/ventoy/Ventoy 2021-06-11 20:36:29 +08:00
longpanda
7fce7e0aba Fix a bug when booting nitrux-release-amd64_2021.05.28.iso (#953) 2021-06-11 20:36:17 +08:00
VlatkoS
2a435084c2
Updated and enhanced Macedonian translation (#930)
Updated and enhanced Macedonian translation
2021-06-11 10:52:01 +08:00
Silejonu
c0c454a436
Update French translation (#931)
Added missing French translation strings and corrected a few already existing ones.
2021-06-11 10:51:47 +08:00
longpanda
63924fa8bd optimize for CRUX 2021-06-09 22:40:08 +08:00
longpanda
3e47f5e8de Fix a bug about ventoy version message position when VTOY_DEFAULT_IMG is set to F6>xxx 2021-06-09 20:55:45 +08:00
longpanda
b5eb347244 Add support for Lakka 3.0/3.1 img file 2021-06-08 23:43:26 +08:00
longpanda
9225c940a6 optimization for cdlinux 2021-05-31 21:02:46 +08:00
longpanda
a8edb99d28 priority key>parent in menu class plugin 2021-05-31 20:46:45 +08:00
longpanda
ac3ab97686 1.0.45 release 2021-05-29 19:42:16 +08:00
longpanda
c42a8c6d93 misc update 2021-05-23 22:39:30 +08:00
longpanda
4b1dd4d3af print progress for md5sum/sha1sum/sha256sum/sha512sum 2021-05-22 19:39:59 +08:00
longpanda
f342be1d6c Merge branch 'master' of https://github.com/ventoy/Ventoy 2021-05-21 10:06:43 +08:00
longpanda
f4774ee0e4 Fix pack error in vDisk env (#912) 2021-05-21 10:06:16 +08:00
MELERIX
d3cfa73631
Updated Spanish Translation (#911) 2021-05-19 15:45:00 +08:00
longpanda
331080fb95 Add parent option in auto_install and injection plugin. 2021-05-16 18:12:07 +08:00
longpanda
99fbd14f08 1.0.44 release 2021-05-15 19:44:20 +08:00
longpanda
1c5aeb35dc Fix a bug about unaligned read in UEFI mode. 2021-05-15 14:23:46 +08:00
longpanda
f7b3bd1729 Add parent option in password plugin 2021-05-15 08:57:26 +08:00
longpanda
672632a0c2 Add isopwd wimpwd efipwd imgpwd vhdpwd vtoypwd option in password plugin (#898) 2021-05-14 22:27:26 +08:00
longpanda
d07aa6ce07 Add -o option in CreatePersistentImg.sh (#903) 2021-05-14 12:12:07 +08:00
longpanda
93996cf7e2 1. Optimization for WIMBOOT mode.
2. Add WIMBOOT for UEFI mode.
2021-05-13 23:05:42 +08:00
longpanda
ca62128f9b Add WIMBOOT mode 2021-05-12 22:49:12 +08:00
longpanda
265b70f1c7 misc update 2021-05-10 18:13:41 +08:00
longpanda
491f0bea8a Fix issue when install Fedora 34 Server Edition 2021-05-10 16:03:40 +08:00
longpanda
47e77e003c 1.0.43 release 2021-05-08 18:05:04 +08:00
longpanda
d05eab2be1 support boot Windows VHD(x) at local disk 2021-05-08 15:33:11 +08:00
longpanda
849dfb463d 1. Change the UTF-16 languages.ini to UTF-8 languages.json
2. The update button is available even if data corrupted in VTOYEFI partition.
3. Set the default focus to No when you click Install button in Ventoy2Disk.exe.
4. Fix a BUG when booting Windows VHD(x) with the latest ventoy_vhdboot.img.
5. Support boot Windows VHD(x) files in local disk.
2021-05-08 14:22:37 +08:00
longpanda
7715bd705c 1.0.42 release 2021-04-27 18:22:10 +08:00
panchenbo
042ca4b5e3
add support for UnionTechOS fuyu (#864) 2021-04-27 17:28:35 +08:00
longpanda
e1099e1e5b Add parent option in menu_class plugin. 2021-04-25 10:31:03 +08:00
longpanda
c6be35f2c0 Support * fuzzy matching for file path in some plugins 2021-04-24 16:03:38 +08:00
longpanda
b15a96b747 1.0.41 release 2021-04-21 21:12:43 +08:00
longpanda
6bd0463d34 Support openwrt IMG file 2021-04-21 19:40:54 +08:00
longpanda
1ce568d971 Support for new MidnightBSD release 2021-04-21 17:00:40 +08:00
longpanda
f82475d950 support new GhostBSD release 2021-04-20 13:10:35 +08:00
longpanda
aad154616c languages.ini update 2021-04-19 09:05:05 +08:00
longpanda
83c3a932d3 misc update 2021-04-14 16:59:57 +08:00
longpanda
0aff8f5109 update vtoytool 2021-04-14 10:26:27 +08:00
longpanda
2750f0c5a7 misc update 2021-04-13 19:42:19 +08:00
longpanda
f71a1fcce9 misc update 2021-04-13 16:46:23 +08:00
longpanda
e252fab9a4 boot iso file with ventoy in ventoy_grub.cfg 2021-04-12 22:30:14 +08:00
longpanda
37212a8ea4 1. Fix a bug about source media missing when boot CentOS8
2. Support RED OS
2021-04-12 18:56:26 +08:00
longpanda
e71221cdba Fix a bug about source media missing when boot openEuler 2021-04-12 11:53:25 +08:00
longpanda
65a2cb1685 1.0.40 release 2021-04-10 20:01:39 +08:00
longpanda
e23e76f54e grub2 boot mode for UEFI 2021-04-10 13:57:20 +08:00
longpanda
8ded032c92 Update vietnamese language (#836) 2021-04-09 19:54:24 +08:00
longpanda
fc5cd0a00a update languages.ini (#829 #834) 2021-04-07 13:37:52 +08:00
longpanda
6cc400b8d4 experimental persistent support for Fedora (#791) 2021-04-06 14:28:34 +08:00
longpanda
ffc915ca53 persistence support for ArchLinux series (Arch/ArchMan/ArchBang/ArchLabs/BlackArch...) 2021-04-04 22:25:26 +08:00
longpanda
8ebe972f6e Fixup a bug when booting special Windows/WinPE ISO file. 2021-04-02 14:11:47 +08:00
longpanda
39975dd1c3 update CI script 2021-04-02 10:08:23 +08:00
longpanda
1a648d8689 update tool chain download link 2021-04-02 09:51:42 +08:00
longpanda
8234961228 debug CI 2021-04-01 13:46:28 +08:00
longpanda
e1ffbad431 Support RHEL6/CentOS6 auto install 2021-04-01 12:02:32 +08:00
longpanda
4a66104c6e Clear input key before show main menu 2021-04-01 09:51:52 +08:00
longpanda
32bcd8f87b Clear input key before show main menu 2021-04-01 09:42:57 +08:00
longpanda
26c1756e8d languages.ini update (#809 #816 #818) 2021-04-01 09:21:42 +08:00
1371 changed files with 181358 additions and 7950 deletions

6
.github/FUNDING.yml vendored
View File

@ -2,11 +2,11 @@
github: # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2]
patreon: # Replace with a single Patreon username
open_collective: # Replace with a single Open Collective username
ko_fi: # Replace with a single Ko-fi username
tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
liberapay: # Replace with a single Liberapay username
liberapay: Ventoy
open_collective: ventoy
issuehunt: # Replace with a single IssueHunt username
otechie: # Replace with a single Otechie username
custom: ['https://www.ventoy.net/en/donation.html'] # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2']
custom: ['https://www.paypal.me/ventoy', 'https://www.ventoy.net/en/donation.html'] # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2']

1
.github/ISSUE_TEMPLATE/config.yml vendored Normal file
View File

@ -0,0 +1 @@
blank_issues_enabled: false

View File

@ -0,0 +1,110 @@
name: Issue Report
description: File an issue report
title: "[issue]: "
assignees:
- octocat
body:
- type: markdown
attributes:
value: |
Thanks for taking the time to fill out this issue report!
- type: checkboxes
id: faq
attributes:
label: Official FAQ
description: Have you checked the official FAQ at [https://www.ventoy.net/en/faq.html](https://www.ventoy.net/en/faq.html) ?
options:
- label: I have checked the official FAQ.
required: true
- type: input
id: version
attributes:
label: Ventoy Version
description: What version of ventoy are you running?
placeholder: 1.0.96
validations:
required: true
- type: dropdown
id: latestrelease
attributes:
label: What about latest release
description: Have you tried with the latest release of Ventoy?
options:
- Yes. I have tried the latest release, but the bug still exist.
- No. I didn't try the latest release.
validations:
required: true
- type: dropdown
id: alternativemode
attributes:
label: Try alternative boot mode
description: Have you tried alternative boot mode? (wimboot mode for Windows/WinPE, grub2 mode for linux)
options:
- Yes. I have tried them, but the bug still exist.
- No. I didn't try these alternative boot modes.
validations:
required: true
- type: dropdown
id: bios
attributes:
label: BIOS Mode
description: In which BIOS mode did you find the bug?
options:
- Legacy BIOS Mode
- UEFI Mode
- Both
validations:
required: true
- type: dropdown
id: partstyle
attributes:
label: Partition Style
description: Which partition style did you select when you install Ventoy?
options:
- MBR
- GPT
validations:
required: true
- type: input
id: capacity
attributes:
label: Disk Capacity
description: What is the capacity of the disk installed with Ventoy?
placeholder: 32GB
validations:
required: true
- type: input
id: vendor
attributes:
label: Disk Manufacturer
description: What is the manufacturer of the disk installed with Ventoy? (e.g. SanDisk/Kingston...)
validations:
required: false
- type: dropdown
id: checksum
attributes:
label: Image file checksum (if applicable)
description: Have you checked the image file in Ventoy's menu as [https://www.ventoy.net/en/faq.html#faq_boot_checksum](https://www.ventoy.net/en/faq.html#faq_boot_checksum) ?
options:
- Yes.
- No.
validations:
required: false
- type: input
id: link
attributes:
label: Image file download link (if applicable)
description: What is the image file download link?
placeholder: https://xxx
validations:
required: false
- type: textarea
id: what-happened
attributes:
label: What happened?
description: Tell me what happened. It's highly recommended to include some photo or video about the bug.
placeholder: Tell us what you see!
value: "A bug happened!"
validations:
required: true

View File

@ -0,0 +1,101 @@
name: Success Image Report
description: To report an image file that boot successfully in Ventoy and is not yet listed in https://www.ventoy.net/en/isolist.html
title: "[Success Image Report]: "
assignees:
- octocat
body:
- type: markdown
attributes:
value: |
I list all the successfully tested image files in the official website: https://www.ventoy.net/en/isolist.html
If you successfully test an image file which is not listed in the above page, you can tell me and I will be very glad to add it to the tested list.
- type: checkboxes
id: faq
attributes:
label: Official Website List
description: Have you checked the list at [https://www.ventoy.net/en/isolist.html](https://www.ventoy.net/en/isolist.html) and the image file is not listed?
options:
- label: I have checked the list in official website and the image file is not listed there.
required: true
- type: input
id: version
attributes:
label: Ventoy Version
description: What version of ventoy did you test with the image file.
placeholder: 1.0.57
validations:
required: true
- type: dropdown
id: bios
attributes:
label: BIOS Mode
description: In which BIOS mode did you successfully test the image file? (It's recommended to test in both mode)
options:
- Legacy BIOS Mode
- UEFI Mode
- Both
validations:
required: true
- type: dropdown
id: partstyle
attributes:
label: Partition Style
description: Which partition style did you use with Ventoy?
options:
- MBR
- GPT
validations:
required: true
- type: input
id: filename
attributes:
label: Image file name
description: The successfully tested image file name.
placeholder: xxxx.iso
validations:
required: true
- type: dropdown
id: checksum
attributes:
label: Image file checksum type
description:
options:
- MD5
- SHA1
- SHA256
- SHA512
validations:
required: true
- type: input
id: checkvalue
attributes:
label: Image file checksum value
description: What is the image file checksum value corresponding to the above checksum type?
placeholder: xxxx
validations:
required: true
- type: input
id: link
attributes:
label: Image file download link (if applicable)
description: What is the image file download link?
placeholder: https://xxx
validations:
required: false
- type: input
id: testenv
attributes:
label: Test environment
description: The manufacturer/model and other details about your computer (or VM).
placeholder: Lenovo Thinkpad T420 laptop
validations:
required: true
- type: textarea
id: details
attributes:
label: More Details?
description: You can give more details here.
value: "This image file booted successfully in Ventoy."
validations:
required: false

View File

@ -12,22 +12,26 @@ jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Run docker-compose up
run: docker-compose up
- uses: actions/upload-artifact@v2
- uses: actions/checkout@v3
- name: Run docker compose up
run: docker compose up
- uses: actions/upload-artifact@v4
with:
name: ventoy-windows
path: INSTALL/ventoy-*windows*
- uses: actions/upload-artifact@v2
- uses: actions/upload-artifact@v4
with:
name: ventoy-linux
path: INSTALL/ventoy-*linux*
- uses: actions/upload-artifact@v2
- uses: actions/upload-artifact@v4
with:
name: ventoy-livecd
path: INSTALL/ventoy-*livecd*
- uses: actions/upload-artifact@v2
- uses: actions/upload-artifact@v4
with:
name: SHA256SUM
path: INSTALL/sha256.txt
- uses: actions/upload-artifact@v4
with:
name: xxx-build-log
path: DOC/build.log

View File

@ -11,6 +11,7 @@ on:
jobs:
run:
name: Sync-GitHub-to-Gitee
if: ${{ github.repository_owner == 'ventoy' }}
runs-on: ubuntu-latest
steps:
- name: Mirror the Github repos to Gitee.

193
BLOB_List.md Normal file
View File

@ -0,0 +1,193 @@
<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> <td>./INSTALL/EFI/BOOT/grubia32_real.efi</td>
<tr> <td>./INSTALL/EFI/BOOT/grubx64_real.efi</td>
<tr> <td>./INSTALL/EFI/BOOT/grub.efi</td> <td rowspan=6>upstream</td> <td rowspan=6>https://github.com/ValdikSS/Super-UEFIinSecureBoot-Disk </td> </tr>
<tr> <td>./INSTALL/EFI/BOOT/BOOTIA32.EFI</td>
<tr> <td>./INSTALL/EFI/BOOT/BOOTX64.EFI</td>
<tr> <td>./INSTALL/EFI/BOOT/grubia32.efi</td>
<tr> <td>./INSTALL/EFI/BOOT/mmia32.efi</td>
<tr> <td>./INSTALL/EFI/BOOT/MokManager.efi</td>
<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> <td>./INSTALL/tool/aarch64/xzcat</td>
<tr> <td>./INSTALL/tool/i386/ash</td>
<tr> <td>./INSTALL/tool/i386/hexdump</td>
<tr> <td>./INSTALL/tool/i386/xzcat</td>
<tr> <td>./INSTALL/tool/mips64el/ash</td>
<tr> <td>./INSTALL/tool/mips64el/hexdump</td>
<tr> <td>./INSTALL/tool/mips64el/xzcat</td>
<tr> <td>./INSTALL/tool/x86_64/ash</td>
<tr> <td>./INSTALL/tool/x86_64/hexdump</td>
<tr> <td>./INSTALL/tool/x86_64/xzcat</td>
<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> <td>./INSTALL/tool/i386/Ventoy2Disk.gtk2</td>
<tr> <td>./INSTALL/tool/mips64el/Ventoy2Disk.gtk3</td>
<tr> <td>./INSTALL/tool/x86_64/Ventoy2Disk.gtk3</td>
<tr> <td>./INSTALL/tool/x86_64/Ventoy2Disk.gtk2</td>
<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> <td>./INSTALL/tool/mips64el/Ventoy2Disk.qt5</td>
<tr> <td>./INSTALL/tool/x86_64/Ventoy2Disk.qt5</td>
<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> <td>./INSTALL/tool/mips64el/Plugson</td>
<tr> <td>./INSTALL/tool/x86_64/Plugson</td>
<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> <td>./INSTALL/tool/mips64el/V2DServer</td>
<tr> <td>./INSTALL/tool/x86_64/V2DServer</td>
<tr> <td>./INSTALL/tool/aarch64/mkexfatfs</td> <td rowspan=8>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> <td>./INSTALL/tool/i386/mkexfatfs</td>
<tr> <td>./INSTALL/tool/i386/mount.exfat-fuse</td>
<tr> <td>./INSTALL/tool/mips64el/mkexfatfs</td>
<tr> <td>./INSTALL/tool/mips64el/mount.exfat-fuse</td>
<tr> <td>./INSTALL/tool/x86_64/mkexfatfs</td>
<tr> <td>./INSTALL/tool/x86_64/mount.exfat-fuse</td>
<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> <td>./INSTALL/tool/mips64el/vlnk</td>
<tr> <td>./INSTALL/tool/x86_64/vlnk</td>
<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> <td>./INSTALL/tool/mips64el/vtoycli</td>
<tr> <td>./INSTALL/tool/x86_64/vtoycli</td>
<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> <td>./INSTALL/ventoy/imdisk/32/imdisk.sys</td>
<tr> <td>./INSTALL/ventoy/imdisk/64/imdisk.cpl</td>
<tr> <td>./INSTALL/ventoy/imdisk/64/imdisk.exe</td>
<tr> <td>./INSTALL/ventoy/imdisk/64/imdisk.sys</td>
<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> <td>./INSTALL/ventoy/iso9660_ia32.efi</td>
<tr> <td>./INSTALL/ventoy/udf_ia32.efi</td>
<tr> <td>./INSTALL/ventoy/iso9660_x64.efi</td>
<tr> <td>./INSTALL/ventoy/udf_x64.efi</td>
<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> <td>./INSTALL/VentoyGUI.mips64el</td>
<tr> <td>./INSTALL/VentoyGUI.x86_64</td>
<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> <td>./INSTALL/Ventoy2Disk_ARM64.exe</td>
<tr> <td>./INSTALL/Ventoy2Disk_X64.exe</td>
<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> <td>./INSTALL/ventoy/ventoy_aa64.efi</td> <td rowspan=6>build</td> <td rowspan=6>Build Instructions:<br/>./EDK2/buildedk.sh</td> </tr>
<tr> <td>./INSTALL/ventoy/ventoy_ia32.efi</td>
<tr> <td>./INSTALL/ventoy/ventoy_x64.efi</td>
<tr> <td>./INSTALL/ventoy/vtoyutil_aa64.efi</td>
<tr> <td>./INSTALL/ventoy/vtoyutil_ia32.efi</td>
<tr> <td>./INSTALL/ventoy/vtoyutil_x64.efi</td>
<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> <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> <td>./LZIP/lunzipaa64</td>
<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> <td>./LZIP/lz4catm64e</td>
<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> <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> <td>./SQUASHFS/unsquashfs_aa64</td>
<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> <td>./VBLADE/vblade-master/vblade_aa64</td>
<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> <td>./VtoyTool/vtoytool/00/vtoytool_aa64</td>
<tr> <td>./VtoyTool/vtoytool/00/vtoytool_m64e</td>
<tr> <td>./VtoyTool/vtoytool/01/vtoytool_64</td>
<tr> <td>./VtoyTool/vtoytool/02/vtoytool_64</td>
<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> <td>./ZSTD/zstdcataa64</td>
<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> <td>./IMG/cpio_x86/ventoy/busybox/xzcat32_musl</td>
<tr> <td>./IMG/cpio_x86/ventoy/busybox/xzcat64_musl</td>
<tr> <td>./IMG/cpio_arm64/ventoy/busybox/busyboxaa64</td>
<tr> <td>./IMG/cpio_mips64/ventoy/busybox/busyboxm64e</td>
<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> <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> <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>

View File

@ -1,9 +1,11 @@
#!/bin/sh
DSTDIR=../../IMG/cpio/ventoy/busybox
DSTDIR1=../../IMG/cpio_x86/ventoy/busybox
DSTDIR2=../../IMG/cpio_arm64/ventoy/busybox
DSTDIR3=../../IMG/cpio_mips64/ventoy/busybox
rm -f vtchmod32 vtchmod64 vtchmod64_musl vtchmodaa64
rm -f $DSTDIR/vtchmod32 $DSTDIR/vtchmod64 $DSTDIR/vtchmodaa64 $DSTDIR/vtchmodm64e
rm -f $DSTDIR1/vtchmod32 $DSTDIR1/vtchmod64 $DSTDIR2/vtchmodaa64 $DSTDIR3/vtchmodm64e
/opt/diet32/bin/diet gcc -Os -m32 vtchmod.c -o vtchmod32
/opt/diet64/bin/diet gcc -Os vtchmod.c -o vtchmod64
@ -23,9 +25,9 @@ chmod 777 vtchmodaa64
chmod 777 vtchmod64_musl
chmod 777 vtchmodm64e
cp -a vtchmod32 $DSTDIR/
cp -a vtchmod64 $DSTDIR/
cp -a vtchmodaa64 $DSTDIR/
cp -a vtchmod64_musl $DSTDIR/
cp -a vtchmodm64e $DSTDIR/
cp -a vtchmod32 $DSTDIR1/
cp -a vtchmod64 $DSTDIR1/
cp -a vtchmod64_musl $DSTDIR1/
cp -a vtchmodaa64 $DSTDIR2/
cp -a vtchmodm64e $DSTDIR3/

View File

@ -1,5 +1,8 @@
#include <stdio.h>
#include <string.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/utsname.h>
int main(int argc, char **argv)
{
@ -7,7 +10,25 @@ int main(int argc, char **argv)
{
return 1;
}
if (argv[1][0] == '-' && argv[1][1] == '6')
{
struct utsname buf;
if (0 == uname(&buf))
{
if (strstr(buf.machine, "amd64"))
{
return 0;
}
if (strstr(buf.machine, "x86_64"))
{
return 0;
}
}
return 1;
}
return chmod(argv[1], 0777);
}

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

7
DMPATCH/Makefile Normal file
View File

@ -0,0 +1,7 @@
obj-m += dm_patch.o
EXTRA_CFLAGS := -Wall
dm_patch-objs := dmpatch.o

7
DMPATCH/Makefile_IBT Normal file
View File

@ -0,0 +1,7 @@
obj-m += dm_patch_ibt.o
EXTRA_CFLAGS := -Wall -DVTOY_IBT -fcf-protection=branch -mindirect-branch-register
dm_patch_ibt-objs := dmpatch.o

632
DMPATCH/dmpatch.c Normal file
View File

@ -0,0 +1,632 @@
/******************************************************************************
* 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 kv_minor;
unsigned long blkdev_get_addr;
unsigned long blkdev_put_addr;
unsigned long bdev_open_addr;
unsigned long kv_subminor;
unsigned long bdev_file_open_addr;
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 int g_claim_ptr = 0;
static unsigned char *g_get_patch[MAX_PATCH] = { NULL };
static unsigned char *g_put_patch[MAX_PATCH] = { NULL };
static int notrace dmpatch_kv_above(unsigned long Major, unsigned long Minor, unsigned long SubMinor)
{
if (g_ko_param.kv_major != Major)
{
return (g_ko_param.kv_major > Major) ? 1 : 0;
}
if (g_ko_param.kv_minor != Minor)
{
return (g_ko_param.kv_minor > Minor) ? 1 : 0;
}
if (g_ko_param.kv_subminor != SubMinor)
{
return (g_ko_param.kv_subminor > SubMinor) ? 1 : 0;
}
return 1;
}
static void notrace dmpatch_restore_code(int bytes, unsigned char *opCode, unsigned int code)
{
unsigned long align;
if (opCode)
{
align = (unsigned long)opCode / g_ko_param.pgsize * g_ko_param.pgsize;
set_mem_rw(align, 1);
if (bytes == 1)
{
*opCode = (unsigned char)code;
}
else
{
*(unsigned int *)opCode = code;
}
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;
}
static unsigned long notrace dmpatch_find_call_offset(unsigned long addr, unsigned long size, unsigned long func)
{
unsigned long i = 0;
unsigned long dest;
unsigned char *opCode = NULL;
unsigned char aucOffset[8] = { 0, 0, 0, 0, 0xFF, 0xFF, 0xFF, 0xFF };
opCode = (unsigned char *)addr;
for (i = 0; i + 4 < size; i++)
{
if (opCode[i] == 0xE8)
{
aucOffset[0] = opCode[i + 1];
aucOffset[1] = opCode[i + 2];
aucOffset[2] = opCode[i + 3];
aucOffset[3] = opCode[i + 4];
dest = addr + i + 5 + *(unsigned long *)aucOffset;
if (dest == func)
{
return i;
}
}
}
return 0;
}
static unsigned int notrace dmpatch_patch_claim_ptr(void)
{
unsigned long i = 0;
unsigned long t = 0;
unsigned long offset1 = 0;
unsigned long offset2 = 0;
unsigned long align = 0;
unsigned char *opCode = NULL;
opCode = (unsigned char *)g_ko_param.sym_get_addr;
for (i = 0; i < 4; i++)
{
vdebug("%02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X\n",
opCode[i + 0], opCode[i + 1], opCode[i + 2], opCode[i + 3],
opCode[i + 4], opCode[i + 5], opCode[i + 6], opCode[i + 7],
opCode[i + 8], opCode[i + 9], opCode[i + 10], opCode[i + 11],
opCode[i + 12], opCode[i + 13], opCode[i + 14], opCode[i + 15]);
}
if (dmpatch_kv_above(6, 7, 0)) /* >= 6.7 kernel */
{
vdebug("Get addr: 0x%lx %lu open 0x%lx\n", g_ko_param.sym_get_addr, g_ko_param.sym_get_size, g_ko_param.bdev_open_addr);
offset1 = dmpatch_find_call_offset(g_ko_param.sym_get_addr, g_ko_param.sym_get_size, g_ko_param.bdev_open_addr);
if (offset1 == 0)
{
vdebug("call bdev_open_addr Not found\n");
vdebug("Get addr: 0x%lx %lu file_open 0x%lx\n", g_ko_param.sym_get_addr, g_ko_param.sym_get_size, g_ko_param.bdev_file_open_addr);
offset1 = dmpatch_find_call_offset(g_ko_param.sym_get_addr, g_ko_param.sym_get_size, g_ko_param.bdev_file_open_addr);
if (offset1 == 0)
{
vdebug("call bdev_file_open_addr Not found\n");
return 1;
}
}
}
else
{
vdebug("Get addr: 0x%lx %lu 0x%lx\n", g_ko_param.sym_get_addr, g_ko_param.sym_get_size, g_ko_param.blkdev_get_addr);
vdebug("Put addr: 0x%lx %lu 0x%lx\n", g_ko_param.sym_put_addr, g_ko_param.sym_put_size, g_ko_param.blkdev_put_addr);
offset1 = dmpatch_find_call_offset(g_ko_param.sym_get_addr, g_ko_param.sym_get_size, g_ko_param.blkdev_get_addr);
offset2 = dmpatch_find_call_offset(g_ko_param.sym_put_addr, g_ko_param.sym_put_size, g_ko_param.blkdev_put_addr);
if (offset1 == 0 || offset2 == 0)
{
vdebug("call blkdev_get or blkdev_put Not found, %lu %lu\n", offset1, offset2);
return 1;
}
}
vdebug("call addr1:0x%lx call addr2:0x%lx\n",
g_ko_param.sym_get_addr + offset1,
g_ko_param.sym_put_addr + offset2);
opCode = (unsigned char *)g_ko_param.sym_get_addr;
for (i = offset1 - 1, t = 0; (i > 0) && (t < 24); i--, t++)
{
/* rdx */
if (opCode[i] == 0x48 && opCode[i + 1] == 0xc7 && opCode[i + 2] == 0xc2)
{
g_claim_ptr = *(unsigned int *)(opCode + i + 3);
g_get_patch[0] = opCode + i + 3;
vdebug("claim_ptr(%08X) found at get addr 0x%lx\n", g_claim_ptr, g_ko_param.sym_get_addr + i + 3);
break;
}
}
if (g_claim_ptr == 0)
{
vdebug("Claim_ptr not found in get\n");
return 1;
}
align = (unsigned long)g_get_patch[0] / g_ko_param.pgsize * g_ko_param.pgsize;
set_mem_rw(align, 1);
*(unsigned int *)(g_get_patch[0]) = 0;
set_mem_ro(align, 1);
if (offset2 > 0)
{
opCode = (unsigned char *)g_ko_param.sym_put_addr;
for (i = offset2 - 1, t = 0; (i > 0) && (t < 24); i--, t++)
{
/* rsi */
if (opCode[i] == 0x48 && opCode[i + 1] == 0xc7 && opCode[i + 2] == 0xc6)
{
if (*(unsigned int *)(opCode + i + 3) == g_claim_ptr)
{
vdebug("claim_ptr found at put addr 0x%lx\n", g_ko_param.sym_put_addr + i + 3);
g_put_patch[0] = opCode + i + 3;
break;
}
}
}
if (g_put_patch[0] == 0)
{
vdebug("Claim_ptr not found in put\n");
return 1;
}
align = (unsigned long)g_put_patch[0] / g_ko_param.pgsize * g_ko_param.pgsize;
set_mem_rw(align, 1);
*(unsigned int *)(g_put_patch[0]) = 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 notrace 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 notrace 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 notrace dmpatch_ibt_save(void) { return 0; }
static void notrace dmpatch_ibt_restore(u64 save) { (void)save; }
#endif
static int notrace dmpatch_process(unsigned long a, unsigned long b, unsigned long c)
{
int r = 0;
int rc = 0;
unsigned long kv_major = 0;
unsigned long kv_minor = 0;
unsigned long kv_subminor = 0;
vdebug("dmpatch_process as KV %d.%d.%d ...\n", (int)a, (int)b, (int)c);
kv_major = g_ko_param.kv_major;
kv_minor = g_ko_param.kv_minor;
kv_subminor = g_ko_param.kv_subminor;
g_ko_param.kv_major = a;
g_ko_param.kv_minor = b;
g_ko_param.kv_subminor = c;
if (dmpatch_kv_above(6, 5, 0)) /* >= kernel 6.5 */
{
vdebug("new interface patch dm_get_table_device...\n");
r = dmpatch_patch_claim_ptr();
}
else
{
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 = -EFAULT;
goto out;
}
vdebug("patch dm_get_table_device success\n");
if (dmpatch_kv_above(6, 5, 0))
{
r = 0;
}
else
{
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 = -EFAULT;
goto out;
}
vdebug("patch dm_put_table_device success\n");
}
vdebug("#####################################\n");
vdebug("######## dm patch success ###########\n");
vdebug("#####################################\n");
out:
g_ko_param.kv_major = kv_major;
g_ko_param.kv_minor = kv_minor;
g_ko_param.kv_subminor = kv_subminor;
return rc;
}
static int notrace dmpatch_init(void)
{
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 kernel=%lu.%lu.%lu ...\n",
g_ko_param.pgsize, g_ko_param.kv_major, g_ko_param.kv_minor, g_ko_param.kv_subminor);
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;
rc = dmpatch_process(g_ko_param.kv_major, g_ko_param.kv_minor, g_ko_param.kv_subminor);
if (rc)
{
if (g_ko_param.kv_major >= 5)
{
rc = dmpatch_process(6, 5, 0);
if (rc)
{
rc = dmpatch_process(6, 7, 0);
}
}
}
if (g_ko_param.ibt == 0x8888)
{
dmpatch_ibt_restore(msr);
}
return rc;
}
static void notrace dmpatch_exit(void)
{
int i = 0;
u64 msr;
if (g_ko_param.ibt == 0x8888)
{
msr = dmpatch_ibt_save();
}
if (g_claim_ptr)
{
dmpatch_restore_code(4, g_get_patch[0], g_claim_ptr);
if (g_put_patch[0])
{
dmpatch_restore_code(4, g_put_patch[0], g_claim_ptr);
}
}
else
{
for (i = 0; i < MAX_PATCH; i++)
{
dmpatch_restore_code(1, g_get_patch[i], 0x80);
dmpatch_restore_code(1, g_put_patch[i], 0x80);
}
}
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");

38
DMPATCH/readme.txt Normal file
View File

@ -0,0 +1,38 @@
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

65
DMPATCH/ubuntu_build.sh Normal file
View File

@ -0,0 +1,65 @@
#!/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

View File

@ -5,7 +5,7 @@ use an old version of dmsetup
http://vault.centos.org/5.3/os/SRPMS/device-mapper-1.02.28-2.el5.src.rpm
https://www.fefe.de/dietlibc/dietlibc-0.34.tar.xz
======== Build Envrioment ========
======== Build Environment ========
build for 32bit, static linked with dietlibc
1. install centos 6.10 i386 with CentOS-6.10-i386-bin-DVD1.iso
2. yum install gcc kernel-devel package

View File

@ -1,9 +1,9 @@
==========================================
1. Compile Enviroment
1. Compile Environment
==========================================
My build envrioment 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.
My build environment is CentOS 7.8 x86_64. So here I first explain how to create the build environment from scratch.
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
I use CentOS-7-x86_64-Everything-2003.iso and select Minimal install
@ -21,10 +21,10 @@
==========================================
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).
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://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://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
http://ftp.loongnix.org/toolchain/gcc/release/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
@ -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/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/
tar xf musl-1.2.1.tar.gz
cd musl-1.2.1
@ -54,7 +54,7 @@
mv /opt/output /opt/mips64el-linux-musl-gcc730
2.4 Set PATH envrioment
2.4 Set PATH environment
export PATH=$PATH:/opt/gcc-linaro-7.4.1-2019.02-x86_64_aarch64-linux-gnu/bin:/opt/aarch64--uclibc--stable-2020.08-1/bin:/opt/mips64el-linux-musl-gcc730/bin
better to add this line to /root/.bashrc and relogin as root
@ -62,21 +62,21 @@
==========================================
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.
cd /home/Ventoy-master/INSTALL
sh all_in_one.sh
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.
2. some part of Ventoy has 32bit&64bit 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.
Fortunately these parts are few modified, you only need to build once or you can directly use the binary I have built.
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 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 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
@ -108,10 +108,10 @@
cd /home/Ventoy-master/VtoyTool
sh build.sh
4.8 == Build vtoyfat ==
cd /home/Ventoy-master/vtoyfat/fat_io_lib
4.8 == Build vtoycli ==
cd /home/Ventoy-master/vtoycli/fat_io_lib
sh buildlib.sh
cd /home/Ventoy-master/vtoyfat
cd /home/Ventoy-master/vtoycli
sh build.sh
4.9 == Build exfat-util ==
@ -122,14 +122,14 @@
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
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 ==
cd /home/Ventoy-master/FUSEISO
sh build_libfuse.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 ==
cd /home/Ventoy-master/SQUASHFS/SRC
@ -141,7 +141,7 @@
cd /home/Ventoy-master/SQUASHFS/squashfs-tools-4.4/squashfs-tools
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 ==
cd /home/Ventoy-master/VBLADE/vblade-master
@ -159,12 +159,12 @@
make -f ventoy_makefile
strip --strip-all xzminidec
4.16 == Build xzminidec64 ==
4.16 == Build xzminidec64/xzminidec64_musl ==
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
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
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
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
==========================================
@ -256,5 +266,11 @@
ISNTALL/ventoy/7z/64/7za.exe SHA-256: 8117e40ee7f824f63373a4f5625bb62749f69159d0c449b3ce2f35aad3b83549
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

View File

@ -1,10 +1,15 @@
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 \
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-* \
libvirt* vte* NetworkManager-bluetooth brlapi fuse-devel dejavu* gnu-efi* pesign shim \
iscsi-initiator-utils grub2-tools zip nasm acpica-tools glibc-static zlib-static xorriso
iscsi-initiator-utils grub2-tools zip nasm acpica-tools glibc-static zlib-static xorriso lz4 squashfs-tools
CMD cd /ventoy/INSTALL && ls -la && sh docker_ci_build.sh

View File

@ -249,6 +249,12 @@ EFI_STATUS EFIAPI vdisk_exit_boot_service_wrapper
IN UINTN MapKey
)
{
if (g_org_get_variable)
{
gRT->GetVariable = g_org_get_variable;
g_org_get_variable = NULL;
}
return g_org_exit_boot_service(ImageHandle, MapKey);
}

View File

@ -34,6 +34,7 @@
#include <Protocol/BlockIo.h>
#include <Protocol/RamDisk.h>
#include <Protocol/SimpleFileSystem.h>
#include <Protocol/DriverBinding.h>
#include <Ventoy.h>
BOOLEAN gDebugPrint = FALSE;
@ -58,6 +59,9 @@ static grub_env_set_pf grub_env_set = NULL;
ventoy_grub_param_file_replace *g_file_replace_list = NULL;
ventoy_efi_file_replace g_efi_file_replace;
ventoy_grub_param_file_replace *g_img_replace_list = NULL;
ventoy_efi_file_replace g_img_file_replace[VTOY_MAX_CONF_REPLACE];
CONST CHAR16 gIso9660EfiDriverPath[] = ISO9660_EFI_DRIVER_PATH;
CONST CHAR16 gUdfEfiDriverPath[] = UDF_EFI_DRIVER_PATH;
@ -67,6 +71,9 @@ STATIC BOOLEAN g_hook_keyboard = FALSE;
CHAR16 gFirstTryBootFile[256] = {0};
STATIC EFI_GET_VARIABLE g_org_get_variable = NULL;
STATIC EFI_EXIT_BOOT_SERVICES g_org_exit_boot_service = NULL;
/* Boot filename */
UINTN gBootFileStartIndex = 1;
CONST CHAR16 *gEfiBootFileName[] =
@ -222,12 +229,14 @@ static void EFIAPI ventoy_dump_chain(ventoy_chain_head *chain)
debug("os_param->vtoy_img_size=<%llu>", chain->os_param.vtoy_img_size);
debug("os_param->vtoy_img_location_addr=<0x%llx>", chain->os_param.vtoy_img_location_addr);
debug("os_param->vtoy_img_location_len=<%u>", chain->os_param.vtoy_img_location_len);
debug("os_param->vtoy_reserved=<%u %u %u %u %u>",
debug("os_param->vtoy_reserved=<%u %u %u %u %u %u %u>",
g_os_param_reserved[0],
g_os_param_reserved[1],
g_os_param_reserved[2],
g_os_param_reserved[3],
g_os_param_reserved[4]
g_os_param_reserved[4],
g_os_param_reserved[5],
g_os_param_reserved[6]
);
ventoy_debug_pause();
@ -362,10 +371,22 @@ EFI_HANDLE EFIAPI ventoy_get_parent_handle(IN EFI_DEVICE_PATH_PROTOCOL *pDevPath
return Handle;
}
STATIC ventoy_ram_disk g_backup_ramdisk_param;
STATIC ventoy_os_param g_backup_os_param_var;
EFI_STATUS EFIAPI ventoy_save_ramdisk_param(VOID)
{
UINTN DataSize;
EFI_STATUS Status = EFI_SUCCESS;
EFI_GUID VarGuid = VENTOY_GUID;
DataSize = sizeof(g_backup_ramdisk_param);
Status = gRT->GetVariable(L"VentoyRamDisk", &VarGuid, NULL, &DataSize, &g_backup_ramdisk_param);
if (!EFI_ERROR(Status))
{
debug("find previous ramdisk variable <%llu>", g_backup_ramdisk_param.DiskSize);
}
Status = gRT->SetVariable(L"VentoyRamDisk", &VarGuid,
EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS,
@ -379,21 +400,38 @@ EFI_STATUS EFIAPI ventoy_delete_ramdisk_param(VOID)
{
EFI_STATUS Status = EFI_SUCCESS;
EFI_GUID VarGuid = VENTOY_GUID;
Status = gRT->SetVariable(L"VentoyRamDisk", &VarGuid,
if (g_backup_ramdisk_param.DiskSize > 0 && g_backup_ramdisk_param.PhyAddr > 0)
{
Status = gRT->SetVariable(L"VentoyRamDisk", &VarGuid,
EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS,
sizeof(g_backup_ramdisk_param), &g_backup_ramdisk_param);
debug("resotre ramdisk variable %r", Status);
}
else
{
Status = gRT->SetVariable(L"VentoyRamDisk", &VarGuid,
EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS,
0, NULL);
debug("delete efi variable %r", Status);
debug("delete ramdisk variable %r", Status);
}
return Status;
}
EFI_STATUS EFIAPI ventoy_save_variable(VOID)
{
UINTN DataSize;
EFI_STATUS Status = EFI_SUCCESS;
EFI_GUID VarGuid = VENTOY_GUID;
DataSize = sizeof(g_backup_os_param_var);
Status = gRT->GetVariable(L"VentoyOsParam", &VarGuid, NULL, &DataSize, &g_backup_os_param_var);
if (!EFI_ERROR(Status))
{
debug("find previous efi variable <%a>", g_backup_os_param_var.vtoy_img_path);
}
Status = gRT->SetVariable(L"VentoyOsParam", &VarGuid,
EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS,
sizeof(g_chain->os_param), &(g_chain->os_param));
@ -406,11 +444,21 @@ EFI_STATUS EFIAPI ventoy_delete_variable(VOID)
{
EFI_STATUS Status = EFI_SUCCESS;
EFI_GUID VarGuid = VENTOY_GUID;
Status = gRT->SetVariable(L"VentoyOsParam", &VarGuid,
if (0 == CompareMem(&(g_backup_os_param_var.guid), &VarGuid, sizeof(EFI_GUID)))
{
Status = gRT->SetVariable(L"VentoyOsParam", &VarGuid,
EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS,
sizeof(g_backup_os_param_var), &(g_backup_os_param_var));
debug("restore efi variable %r", Status);
}
else
{
Status = gRT->SetVariable(L"VentoyOsParam", &VarGuid,
EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS,
0, NULL);
debug("delete efi variable %r", Status);
debug("delete efi variable %r", Status);
}
return Status;
}
@ -529,10 +577,11 @@ STATIC EFI_STATUS EFIAPI ventoy_find_iso_disk(IN EFI_HANDLE ImageHandle)
continue;
}
if (CompareMem(g_chain->os_param.vtoy_disk_guid, pBuffer + 0x180, 16) == 0)
if (CompareMem(g_chain->os_param.vtoy_disk_guid, pBuffer + 0x180, 16) == 0 &&
CompareMem(g_chain->os_param.vtoy_disk_signature, pBuffer + 0x1b8, 4) == 0)
{
pMBR = (MBR_HEAD *)pBuffer;
if (pMBR->PartTbl[0].FsFlag != 0xEE)
if (g_os_param_reserved[6] == 0 && pMBR->PartTbl[0].FsFlag != 0xEE)
{
if (pMBR->PartTbl[0].StartSectorId != 2048 ||
pMBR->PartTbl[1].SectorCount != 65536 ||
@ -551,7 +600,7 @@ STATIC EFI_STATUS EFIAPI ventoy_find_iso_disk(IN EFI_HANDLE ImageHandle)
Handles[i],
EFI_OPEN_PROTOCOL_GET_PROTOCOL);
debug("Find Ventoy Disk Handle:%p DP:%s", Handles[i],
debug("Find Ventoy Disk Sig Handle:%p DP:%s", Handles[i],
ConvertDevicePathToText(gBlockData.pDiskDevPath, FALSE, FALSE));
break;
}
@ -667,6 +716,106 @@ STATIC EFI_STATUS EFIAPI ventoy_load_isoefi_driver(IN EFI_HANDLE ImageHandle)
return EFI_SUCCESS;
}
STATIC EFI_STATUS ventoy_proc_img_replace_name(ventoy_grub_param_file_replace *replace)
{
UINT32 i;
char tmp[256];
if (replace->magic != GRUB_IMG_REPLACE_MAGIC)
{
return EFI_SUCCESS;
}
if (replace->old_file_name[0][0] == 0)
{
return EFI_SUCCESS;
}
AsciiStrCpyS(tmp, sizeof(tmp), replace->old_file_name[0]);
for (i = 0; i < 256 && tmp[i]; i++)
{
if (tmp[i] == '/')
{
tmp[i] = '\\';
}
}
AsciiStrCpyS(replace->old_file_name[0], 256, tmp);
return EFI_SUCCESS;
}
EFI_STATUS EFIAPI ventoy_get_variable_wrapper
(
IN CHAR16 *VariableName,
IN EFI_GUID *VendorGuid,
OUT UINT32 *Attributes, OPTIONAL
IN OUT UINTN *DataSize,
OUT VOID *Data OPTIONAL
)
{
EFI_STATUS Status = EFI_SUCCESS;
Status = g_org_get_variable(VariableName, VendorGuid, Attributes, DataSize, Data);
if (StrCmp(VariableName, L"SecureBoot") == 0)
{
if ((*DataSize == 1) && Data)
{
*(UINT8 *)Data = 0;
}
}
return Status;
}
EFI_STATUS EFIAPI ventoy_exit_boot_service_wrapper
(
IN EFI_HANDLE ImageHandle,
IN UINTN MapKey
)
{
if (g_org_get_variable)
{
gRT->GetVariable = g_org_get_variable;
g_org_get_variable = NULL;
}
return g_org_exit_boot_service(ImageHandle, MapKey);
}
STATIC EFI_STATUS EFIAPI ventoy_disable_secure_boot(IN EFI_HANDLE ImageHandle)
{
UINT8 Value = 0;
UINTN DataSize = 1;
EFI_STATUS Status = EFI_SUCCESS;
Status = gRT->GetVariable(L"SecureBoot", &gEfiGlobalVariableGuid, NULL, &DataSize, &Value);
if (!EFI_ERROR(Status))
{
if (DataSize == 1 && Value == 0)
{
debug("Current secure boot is off, no need to disable");
return EFI_SUCCESS;
}
}
debug("ventoy_disable_secure_boot");
/* step1: wrapper security protocol. */
/* Do we still need it since we have been loaded ? */
/* step2: fake SecureBoot variable */
g_org_exit_boot_service = gBS->ExitBootServices;
gBS->ExitBootServices = ventoy_exit_boot_service_wrapper;
g_org_get_variable = gRT->GetVariable;
gRT->GetVariable = ventoy_get_variable_wrapper;
return EFI_SUCCESS;
}
STATIC EFI_STATUS EFIAPI ventoy_parse_cmdline(IN EFI_HANDLE ImageHandle)
{
UINT32 i = 0;
@ -680,6 +829,7 @@ STATIC EFI_STATUS EFIAPI ventoy_parse_cmdline(IN EFI_HANDLE ImageHandle)
ventoy_grub_param *pGrubParam = NULL;
EFI_LOADED_IMAGE_PROTOCOL *pImageInfo = NULL;
ventoy_chain_head *chain = NULL;
ventoy_grub_param_file_replace *replace = NULL;
Status = gBS->HandleProtocol(ImageHandle, &gEfiLoadedImageProtocolGuid, (VOID **)&pImageInfo);
if (EFI_ERROR(Status))
@ -777,6 +927,28 @@ STATIC EFI_STATUS EFIAPI ventoy_parse_cmdline(IN EFI_HANDLE ImageHandle)
old_cnt > 3 ? g_file_replace_list->old_file_name[3] : ""
);
for (i = 0; i < VTOY_MAX_CONF_REPLACE; i++)
{
replace = pGrubParam->img_replace + i;
if (replace->magic == GRUB_IMG_REPLACE_MAGIC)
{
ventoy_proc_img_replace_name(replace);
old_cnt = replace->old_file_cnt;
debug("img replace[%d]: magic:0x%x virtid:%u name count:%u <%a> <%a> <%a> <%a>",
i, replace->magic,
replace->new_file_virtual_id,
old_cnt,
old_cnt > 0 ? replace->old_file_name[0] : "",
old_cnt > 1 ? replace->old_file_name[1] : "",
old_cnt > 2 ? replace->old_file_name[2] : "",
old_cnt > 3 ? replace->old_file_name[3] : ""
);
g_img_replace_list = pGrubParam->img_replace;
}
}
pPos = StrStr(pCmdLine, L"mem:");
chain = (ventoy_chain_head *)StrHexToUintn(pPos + 4);
@ -797,6 +969,7 @@ STATIC EFI_STATUS EFIAPI ventoy_parse_cmdline(IN EFI_HANDLE ImageHandle)
debug("memdisk mode iso_buf_size:%u", g_iso_buf_size);
g_chain = chain;
g_os_param_reserved = (UINT8 *)(g_chain->os_param.vtoy_reserved);
gMemdiskMode = TRUE;
}
else
@ -824,6 +997,11 @@ STATIC EFI_STATUS EFIAPI ventoy_parse_cmdline(IN EFI_HANDLE ImageHandle)
{
g_hook_keyboard = TRUE;
}
if (g_os_param_reserved[5] == 1 && g_os_param_reserved[2] == ventoy_chain_linux)
{
ventoy_disable_secure_boot(ImageHandle);
}
debug("internal param: secover:%u keyboard:%u", g_fixup_iso9660_secover_enable, g_hook_keyboard);
@ -1010,7 +1188,7 @@ EFI_STATUS EFIAPI ventoy_boot(IN EFI_HANDLE ImageHandle)
gST->ConIn->Reset(gST->ConIn, FALSE);
}
if (g_file_replace_list && g_file_replace_list->magic == GRUB_FILE_REPLACE_MAGIC)
if ((g_file_replace_list && g_file_replace_list->magic == GRUB_FILE_REPLACE_MAGIC) || g_img_replace_list)
{
ventoy_wrapper_push_openvolume(pFile->OpenVolume);
pFile->OpenVolume = ventoy_wrapper_open_volume;
@ -1085,6 +1263,8 @@ EFI_STATUS EFIAPI VentoyEfiMain
return Status;
}
ventoy_disable_ex_filesystem();
if (gMemdiskMode)
{
g_ramdisk_param.PhyAddr = (UINT64)(UINTN)g_iso_data_buf;
@ -1159,6 +1339,8 @@ EFI_STATUS EFIAPI VentoyEfiMain
grub_env_set("vtoy_dotefi_retry", "YES");
}
ventoy_enable_ex_filesystem();
return EFI_SUCCESS;
}

View File

@ -98,7 +98,9 @@ typedef struct ventoy_os_param
UINT64 vtoy_reserved[4]; // Internal use by ventoy
UINT8 reserved[31];
UINT8 vtoy_disk_signature[4];
UINT8 reserved[27];
}ventoy_os_param;
#pragma pack()
@ -169,7 +171,6 @@ typedef struct ventoy_virt_chunk
{ 0x37b87ac6, 0xc180, 0x4583, { 0xa7, 0x05, 0x41, 0x4d, 0xa8, 0xf7, 0x7e, 0xd2 }}
#define VTOY_BLOCK_DEVICE_PATH_NAME L"ventoy"
#if defined (MDE_CPU_IA32)
#define VENTOY_UEFI_DESC L"IA32 UEFI"
@ -243,7 +244,9 @@ typedef int (*grub_env_printf_pf)(const char *fmt, ...);
#pragma pack(1)
#define VTOY_MAX_CONF_REPLACE 2
#define GRUB_FILE_REPLACE_MAGIC 0x1258BEEF
#define GRUB_IMG_REPLACE_MAGIC 0x1259BEEF
typedef struct ventoy_efi_file_replace
{
@ -268,6 +271,7 @@ typedef struct ventoy_grub_param
grub_env_get_pf grub_env_get;
grub_env_set_pf grub_env_set;
ventoy_grub_param_file_replace file_replace;
ventoy_grub_param_file_replace img_replace[VTOY_MAX_CONF_REPLACE];
grub_env_printf_pf grub_env_printf;
}ventoy_grub_param;
@ -344,6 +348,14 @@ typedef struct ventoy_system_wrapper
EFI_LOCATE_DEVICE_PATH OriLocateDevicePath;
} ventoy_system_wrapper;
#define MAX_DRIVER_BIND_WRAPPER 64
typedef struct DriverBindWrapper
{
EFI_DRIVER_BINDING_PROTOCOL *DriverBinding;
EFI_DRIVER_BINDING_SUPPORTED pfOldSupport;
}DRIVER_BIND_WRAPPER;
#define ventoy_wrapper(bs, wrapper, func, newfunc) \
{\
wrapper.Ori##func = bs->func;\
@ -351,6 +363,22 @@ typedef struct ventoy_system_wrapper
bs->func = wrapper.New##func;\
}
#define VENTOY_GET_COMPONENT_NAME(Protocol, DriverName) \
{\
DriverName = NULL;\
Status = Protocol->GetDriverName(Protocol, "en", &DriverName);\
if (EFI_ERROR(Status) || NULL == DriverName) \
{\
DriverName = NULL;\
Status = Protocol->GetDriverName(Protocol, "eng", &DriverName);\
if (EFI_ERROR(Status) || NULL == DriverName) \
{\
continue;\
}\
}\
}
extern BOOLEAN gDebugPrint;
VOID EFIAPI VtoyDebug(IN CONST CHAR8 *Format, ...);
EFI_STATUS EFIAPI ventoy_wrapper_system(VOID);
@ -373,6 +401,7 @@ extern ventoy_virt_chunk *g_virt_chunk;
extern UINT32 g_virt_chunk_num;
extern vtoy_block_data gBlockData;
extern ventoy_efi_file_replace g_efi_file_replace;
extern ventoy_efi_file_replace g_img_file_replace[VTOY_MAX_CONF_REPLACE];
extern ventoy_sector_flag *g_sector_flag;
extern UINT32 g_sector_flag_num;
extern BOOLEAN gMemdiskMode;
@ -380,6 +409,7 @@ extern BOOLEAN gSector512Mode;
extern UINTN g_iso_buf_size;
extern UINT8 *g_iso_data_buf;
extern ventoy_grub_param_file_replace *g_file_replace_list;
extern ventoy_grub_param_file_replace *g_img_replace_list;
extern BOOLEAN g_fixup_iso9660_secover_enable;
extern EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *g_con_simple_input_ex;
extern BOOLEAN g_fix_windows_1st_cdrom_issue;
@ -396,6 +426,8 @@ EFI_STATUS ventoy_hook_keyboard_stop(VOID);
BOOLEAN ventoy_is_cdrom_dp_exist(VOID);
EFI_STATUS ventoy_hook_1st_cdrom_start(VOID);
EFI_STATUS ventoy_hook_1st_cdrom_stop(VOID);
EFI_STATUS ventoy_disable_ex_filesystem(VOID);
EFI_STATUS ventoy_enable_ex_filesystem(VOID);
#endif

View File

@ -42,6 +42,7 @@
DebugLib
[Guids]
gEfiGlobalVariableGuid
gShellVariableGuid
gEfiVirtualCdGuid
gEfiFileInfoGuid

View File

@ -34,6 +34,7 @@
#include <Protocol/BlockIo.h>
#include <Protocol/RamDisk.h>
#include <Protocol/SimpleFileSystem.h>
#include <Protocol/DriverBinding.h>
#include <Ventoy.h>
#define PROCOTOL_SLEEP_MSECONDS 0

View File

@ -34,6 +34,7 @@
#include <Protocol/BlockIo.h>
#include <Protocol/RamDisk.h>
#include <Protocol/SimpleFileSystem.h>
#include <Protocol/DriverBinding.h>
#include <Ventoy.h>
UINT8 *g_iso_data_buf = NULL;
@ -73,6 +74,9 @@ STATIC UINT8 g_sector_buf[2048];
STATIC EFI_BLOCK_READ g_sector_2048_read = NULL;
STATIC EFI_BLOCK_WRITE g_sector_2048_write = NULL;
STATIC UINTN g_DriverBindWrapperCnt = 0;
STATIC DRIVER_BIND_WRAPPER g_DriverBindWrapperList[MAX_DRIVER_BIND_WRAPPER];
BOOLEAN ventoy_is_cdrom_dp_exist(VOID)
{
UINTN i = 0;
@ -148,7 +152,8 @@ STATIC EFI_STATUS EFIAPI ventoy_read_iso_sector
ventoy_override_chunk *pOverride = g_override_chunk;
EFI_BLOCK_IO_PROTOCOL *pRawBlockIo = gBlockData.pRawBlockIo;
debug("read iso sector %lu count %u", Sector, Count);
debug("read iso sector %lu count %u Buffer:%p Align:%u blk:%u",
Sector, Count, Buffer, pRawBlockIo->Media->IoAlign, pRawBlockIo->Media->BlockSize);
ReadStart = Sector * 2048;
ReadEnd = (Sector + Count) * 2048;
@ -173,7 +178,6 @@ STATIC EFI_STATUS EFIAPI ventoy_read_iso_sector
{
MapLba = ((Sector - pchunk->img_start_sector) >> 1) + pchunk->disk_start_sector;
}
secLeft = pchunk->img_end_sector + 1 - Sector;
secRead = (Count < secLeft) ? Count : secLeft;
@ -182,7 +186,7 @@ STATIC EFI_STATUS EFIAPI ventoy_read_iso_sector
MapLba, secRead * 2048, pCurBuf);
if (EFI_ERROR(Status))
{
debug("Raw disk read block failed %r LBA:%lu Count:%u", Status, MapLba, secRead);
debug("Raw disk read block failed %r LBA:%lu Count:%u %p", Status, MapLba, secRead, pCurBuf);
return Status;
}
@ -425,7 +429,7 @@ end:
return Lba;
}
EFI_STATUS EFIAPI ventoy_block_io_read
EFI_STATUS EFIAPI ventoy_block_io_read_real
(
IN EFI_BLOCK_IO_PROTOCOL *This,
IN UINT32 MediaId,
@ -447,7 +451,7 @@ EFI_STATUS EFIAPI ventoy_block_io_read
ventoy_sector_flag *cur_flag;
ventoy_virt_chunk *node;
//debug("### ventoy_block_io_read sector:%u count:%u", (UINT32)Lba, (UINT32)BufferSize / 2048);
debug("### block_io_read_real sector:%u count:%u Buffer:%p", (UINT32)Lba, (UINT32)BufferSize / 2048, Buffer);
secNum = BufferSize / 2048;
@ -484,6 +488,8 @@ EFI_STATUS EFIAPI ventoy_block_io_read
secNum = VirtSec - Lba;
}
debug("XXX block_io_read_real sector:%u count:%u Buffer:%p", (UINT32)Lba, (UINT32)BufferSize / 2048, Buffer);
if (secNum > g_sector_flag_num)
{
cur_flag = AllocatePool(secNum * sizeof(ventoy_sector_flag));
@ -551,6 +557,42 @@ EFI_STATUS EFIAPI ventoy_block_io_read
return EFI_SUCCESS;
}
EFI_STATUS EFIAPI ventoy_block_io_read
(
IN EFI_BLOCK_IO_PROTOCOL *This,
IN UINT32 MediaId,
IN EFI_LBA Lba,
IN UINTN BufferSize,
OUT VOID *Buffer
)
{
UINT32 IoAlign = 0;
VOID *NewBuf = NULL;
EFI_STATUS Status = EFI_OUT_OF_RESOURCES;
if (gBlockData.pRawBlockIo && gBlockData.pRawBlockIo->Media)
{
IoAlign = gBlockData.pRawBlockIo->Media->IoAlign;
}
if ((IoAlign == 0) || (((UINTN) Buffer & (IoAlign - 1)) == 0))
{
Status = ventoy_block_io_read_real(This, MediaId, Lba, BufferSize, Buffer);
}
else
{
NewBuf = AllocatePages(EFI_SIZE_TO_PAGES(BufferSize + IoAlign));
if (NewBuf)
{
Status = ventoy_block_io_read_real(This, MediaId, Lba, BufferSize, NewBuf);
CopyMem(Buffer, NewBuf, BufferSize);
FreePages(NewBuf, EFI_SIZE_TO_PAGES(BufferSize + IoAlign));
}
}
return Status;
}
EFI_STATUS EFIAPI ventoy_block_io_write
(
IN EFI_BLOCK_IO_PROTOCOL *This,
@ -583,26 +625,74 @@ EFI_STATUS EFIAPI ventoy_block_io_flush(IN EFI_BLOCK_IO_PROTOCOL *This)
return EFI_SUCCESS;
}
STATIC UINTN ventoy_get_current_device_path_id(VOID)
{
UINTN i = 0;
UINTN Count = 0;
UINTN MaxId = 0;
UINTN CurId = 0;
BOOLEAN Find = FALSE;
EFI_HANDLE *Handles = NULL;
EFI_STATUS Status = EFI_SUCCESS;
EFI_DEVICE_PATH_PROTOCOL *DevicePath = NULL;
VENDOR_DEVICE_PATH *venPath = NULL;
Status = gBS->LocateHandleBuffer(ByProtocol, &gEfiDevicePathProtocolGuid,
NULL, &Count, &Handles);
if (EFI_ERROR(Status))
{
return 0;
}
for (i = 0; i < Count; i++)
{
Status = gBS->HandleProtocol(Handles[i], &gEfiDevicePathProtocolGuid, (VOID **)&DevicePath);
if (EFI_ERROR(Status))
{
continue;
}
if (DevicePath->Type == HARDWARE_DEVICE_PATH && DevicePath->SubType == HW_VENDOR_DP)
{
venPath = (VENDOR_DEVICE_PATH *)DevicePath;
if (CompareGuid(&venPath->Guid, &gVtoyBlockDevicePathGuid))
{
CurId = StrDecimalToUintn((CHAR16 *)(venPath + 1) + StrLen(L"ventoy_"));
MaxId = MAX(MaxId, CurId);
Find = TRUE;
}
}
}
FreePool(Handles);
return Find ? (MaxId + 1) : 0;
}
EFI_STATUS EFIAPI ventoy_fill_device_path(VOID)
{
UINTN CurVtoyDpId = 0;
UINTN NameLen = 0;
UINT8 TmpBuf[128] = {0};
VENDOR_DEVICE_PATH *venPath = NULL;
CHAR16 VtoyDpName[32];
CurVtoyDpId = ventoy_get_current_device_path_id();
UnicodeSPrintAsciiFormat(VtoyDpName, sizeof(VtoyDpName), "ventoy_%03lu", CurVtoyDpId);
venPath = (VENDOR_DEVICE_PATH *)TmpBuf;
NameLen = StrSize(VTOY_BLOCK_DEVICE_PATH_NAME);
NameLen = StrSize(VtoyDpName);
venPath->Header.Type = HARDWARE_DEVICE_PATH;
venPath->Header.SubType = HW_VENDOR_DP;
venPath->Header.Length[0] = sizeof(VENDOR_DEVICE_PATH) + NameLen;
venPath->Header.Length[1] = 0;
CopyMem(&venPath->Guid, &gVtoyBlockDevicePathGuid, sizeof(EFI_GUID));
CopyMem(venPath + 1, VTOY_BLOCK_DEVICE_PATH_NAME, NameLen);
CopyMem(venPath + 1, VtoyDpName, NameLen);
gBlockData.Path = AppendDevicePathNode(NULL, (EFI_DEVICE_PATH_PROTOCOL *)TmpBuf);
gBlockData.DevicePathCompareLen = sizeof(VENDOR_DEVICE_PATH) + NameLen;
debug("gBlockData.Path=<%s>\n", ConvertDevicePathToText(gBlockData.Path, FALSE, FALSE));
debug("gBlockData.Path=<%lu><%s>\n", CurVtoyDpId, ConvertDevicePathToText(gBlockData.Path, FALSE, FALSE));
return EFI_SUCCESS;
}
@ -635,11 +725,7 @@ EFI_STATUS EFIAPI ventoy_connect_driver(IN EFI_HANDLE ControllerHandle, IN CONST
continue;
}
Status = Name2Protocol->GetDriverName(Name2Protocol, "en", &DriverName);
if (EFI_ERROR(Status) || NULL == DriverName)
{
continue;
}
VENTOY_GET_COMPONENT_NAME(Name2Protocol, DriverName);
if (StrStr(DriverName, DrvName))
{
@ -677,11 +763,7 @@ EFI_STATUS EFIAPI ventoy_connect_driver(IN EFI_HANDLE ControllerHandle, IN CONST
continue;
}
Status = NameProtocol->GetDriverName(NameProtocol, "en", &DriverName);
if (EFI_ERROR(Status))
{
continue;
}
VENTOY_GET_COMPONENT_NAME(NameProtocol, DriverName);
if (StrStr(DriverName, DrvName))
{
@ -706,6 +788,223 @@ end:
return Status;
}
STATIC BOOLEAN ventoy_filesystem_need_wrapper(IN CONST CHAR16 *DrvName)
{
UINTN i;
CHAR16 UpperDrvName[256];
StrCpyS(UpperDrvName, 256, DrvName);
for (i = 0; i < 256 && UpperDrvName[i]; i++)
{
if (UpperDrvName[i] >= 'a' && UpperDrvName[i] <= 'z')
{
UpperDrvName[i] = 'A' + (UpperDrvName[i] - 'a');
}
}
/*
* suppress some file system drivers
* 1. rEFInd File System Driver
*
*/
if (StrStr(UpperDrvName, L"REFIND") && StrStr(UpperDrvName, L"FILE SYSTEM"))
{
return TRUE;
}
return FALSE;
}
STATIC VOID ventoy_add_filesystem_wrapper
(
IN EFI_DRIVER_BINDING_PROTOCOL *DriverBindProtocol,
IN CONST CHAR16 *DriverName
)
{
UINTN j;
if (g_DriverBindWrapperCnt >= MAX_DRIVER_BIND_WRAPPER)
{
debug("driver binding wrapper overflow %lu", g_DriverBindWrapperCnt);
return;
}
if (!ventoy_filesystem_need_wrapper(DriverName))
{
return;
}
for (j = 0; j < g_DriverBindWrapperCnt; j++)
{
if (g_DriverBindWrapperList[j].DriverBinding == DriverBindProtocol)
{
debug("Duplicate driverbinding <%s> %p %lu %lu", DriverName, DriverBindProtocol, j, g_DriverBindWrapperCnt);
break;
}
}
if (j >= g_DriverBindWrapperCnt)
{
g_DriverBindWrapperList[g_DriverBindWrapperCnt].DriverBinding = DriverBindProtocol;
g_DriverBindWrapperList[g_DriverBindWrapperCnt].pfOldSupport = DriverBindProtocol->Supported;
g_DriverBindWrapperCnt++;
debug("Add driverbinding <%s> %p %lu", DriverName, DriverBindProtocol, g_DriverBindWrapperCnt);
}
}
STATIC EFI_STATUS ventoy_find_filesystem_driverbind(VOID)
{
UINTN i = 0;
UINTN Count = 0;
CHAR16 *DriverName = NULL;
EFI_HANDLE *Handles = NULL;
EFI_STATUS Status = EFI_SUCCESS;
EFI_COMPONENT_NAME_PROTOCOL *NameProtocol = NULL;
EFI_COMPONENT_NAME2_PROTOCOL *Name2Protocol = NULL;
EFI_DRIVER_BINDING_PROTOCOL *DriverBindProtocol = NULL;
debug("ventoy_find_filesystem_driverbind...");
Status = gBS->LocateHandleBuffer(ByProtocol, &gEfiComponentName2ProtocolGuid,
NULL, &Count, &Handles);
if (EFI_ERROR(Status))
{
return Status;
}
for (i = 0; i < Count; i++)
{
Status = gBS->HandleProtocol(Handles[i], &gEfiComponentName2ProtocolGuid, (VOID **)&Name2Protocol);
if (EFI_ERROR(Status))
{
continue;
}
VENTOY_GET_COMPONENT_NAME(Name2Protocol, DriverName);
Status = gBS->HandleProtocol(Handles[i], &gEfiDriverBindingProtocolGuid, (VOID **)&DriverBindProtocol);
if (EFI_ERROR(Status))
{
debug("### 2 No DriverBind <%s> <%r>", DriverName, Status);
continue;
}
ventoy_add_filesystem_wrapper(DriverBindProtocol, DriverName);
}
Count = 0;
FreePool(Handles);
Handles = NULL;
Status = gBS->LocateHandleBuffer(ByProtocol, &gEfiComponentNameProtocolGuid,
NULL, &Count, &Handles);
if (EFI_ERROR(Status))
{
return Status;
}
for (i = 0; i < Count; i++)
{
Status = gBS->HandleProtocol(Handles[i], &gEfiComponentNameProtocolGuid, (VOID **)&NameProtocol);
if (EFI_ERROR(Status))
{
continue;
}
VENTOY_GET_COMPONENT_NAME(NameProtocol, DriverName);
Status = gBS->HandleProtocol(Handles[i], &gEfiDriverBindingProtocolGuid, (VOID **)&DriverBindProtocol);
if (EFI_ERROR(Status))
{
debug("### 1 No DriverBind <%s> <%r>", DriverName, Status);
continue;
}
ventoy_add_filesystem_wrapper(DriverBindProtocol, DriverName);
}
FreePool(Handles);
return EFI_SUCCESS;
}
STATIC EFI_STATUS EFIAPI ventoy_wrapper_driver_bind_support
(
IN EFI_DRIVER_BINDING_PROTOCOL *This,
IN EFI_HANDLE ControllerHandle,
IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL
)
{
UINTN i;
EFI_STATUS Status = EFI_SUCCESS;
EFI_DEVICE_PATH_PROTOCOL *DevicePath = NULL;
EFI_DRIVER_BINDING_SUPPORTED pfOldSupport = NULL;
for (i = 0; i < g_DriverBindWrapperCnt; i++)
{
if (g_DriverBindWrapperList[i].DriverBinding == This)
{
pfOldSupport = g_DriverBindWrapperList[i].pfOldSupport;
break;
}
}
debug("ventoy_wrapper_driver_bind_support %lu %p", i, pfOldSupport);
if (!pfOldSupport)
{
return EFI_UNSUPPORTED;
}
Status = gBS->HandleProtocol(ControllerHandle, &gEfiDevicePathProtocolGuid, (VOID **)&DevicePath);
if (EFI_ERROR(Status))
{
goto out;
}
if (0 == CompareMem(gBlockData.Path, DevicePath, gBlockData.DevicePathCompareLen))
{
debug("return EFI_UNSUPPORTED for ventoy");
return EFI_UNSUPPORTED;
}
out:
return pfOldSupport(This, ControllerHandle, RemainingDevicePath);
}
EFI_STATUS ventoy_disable_ex_filesystem(VOID)
{
UINTN i;
ventoy_find_filesystem_driverbind();
for (i = 0; i < g_DriverBindWrapperCnt; i++)
{
g_DriverBindWrapperList[i].DriverBinding->Supported = ventoy_wrapper_driver_bind_support;
}
debug("Wrapper Ex Driver Binding %lu", g_DriverBindWrapperCnt);
ventoy_debug_pause();
return EFI_SUCCESS;
}
EFI_STATUS ventoy_enable_ex_filesystem(VOID)
{
UINTN i;
for (i = 0; i < g_DriverBindWrapperCnt; i++)
{
g_DriverBindWrapperList[i].DriverBinding->Supported = g_DriverBindWrapperList[i].pfOldSupport;
}
g_DriverBindWrapperCnt = 0;
return EFI_SUCCESS;
}
EFI_STATUS EFIAPI ventoy_block_io_read_512
(
IN EFI_BLOCK_IO_PROTOCOL *This,
@ -720,7 +1019,7 @@ EFI_STATUS EFIAPI ventoy_block_io_read_512
UINT8 *CurBuf = NULL;
EFI_STATUS Status = EFI_SUCCESS;
debug("ventoy_block_io_read_512 %lu %lu\n", Lba, BufferSize / 512);
debug("ventoy_block_io_read_512 %lu %lu Buffer:%p\n", Lba, BufferSize / 512, Buffer);
CurBuf = (UINT8 *)Buffer;
@ -840,14 +1139,15 @@ EFI_STATUS EFIAPI ventoy_install_blockio(IN EFI_HANDLE ImageHandle, IN UINT64 Im
{
gBlockData.Media.BlockSize = 512;
gBlockData.Media.LastBlock = ImgSize / 512 - 1;
gBlockData.Media.ReadOnly = FALSE;
}
else
{
gBlockData.Media.BlockSize = 2048;
gBlockData.Media.LastBlock = ImgSize / 2048 - 1;
gBlockData.Media.ReadOnly = TRUE;
}
gBlockData.Media.ReadOnly = TRUE;
gBlockData.Media.MediaPresent = 1;
gBlockData.Media.LogicalBlocksPerPhysicalBlock = 1;
@ -946,6 +1246,98 @@ ventoy_wrapper_file_flush_ex(EFI_FILE_HANDLE This, EFI_FILE_IO_TOKEN *Token)
return EFI_SUCCESS;
}
/* Ex version */
STATIC EFI_STATUS EFIAPI
ventoy_wrapper_file_flush_ex_img0(EFI_FILE_HANDLE This, EFI_FILE_IO_TOKEN *Token)
{
(VOID)This;
(VOID)Token;
return EFI_SUCCESS;
}
/* Ex version */
STATIC EFI_STATUS EFIAPI
ventoy_wrapper_file_flush_ex_img1(EFI_FILE_HANDLE This, EFI_FILE_IO_TOKEN *Token)
{
(VOID)This;
(VOID)Token;
return EFI_SUCCESS;
}
#define DEF_WRAP_FUNC(n) \
STATIC EFI_STATUS EFIAPI ventoy_wrapper_file_flush_ex_img#n(EFI_FILE_HANDLE This, EFI_FILE_IO_TOKEN *Token) \
{\
(VOID)This;\
(VOID)Token;\
return EFI_SUCCESS;\
}
#define ITEM_WRAP_FUNC(n) ventoy_wrapper_file_flush_ex_img#n
#if (VTOY_MAX_CONF_REPLACE > 2)
DEF_WRAP_FUNC(2);
#endif
#if (VTOY_MAX_CONF_REPLACE > 3)
DEF_WRAP_FUNC(3);
#endif
#if (VTOY_MAX_CONF_REPLACE > 4)
DEF_WRAP_FUNC(4);
#endif
#if (VTOY_MAX_CONF_REPLACE > 5)
DEF_WRAP_FUNC(5);
#endif
#if (VTOY_MAX_CONF_REPLACE > 6)
DEF_WRAP_FUNC(6);
#endif
#if (VTOY_MAX_CONF_REPLACE > 7)
DEF_WRAP_FUNC(7);
#endif
#if (VTOY_MAX_CONF_REPLACE > 8)
#error "VTOY_MAX_CONF_REPLACE overflow"
#endif
static EFI_FILE_FLUSH_EX g_img_flush_func[VTOY_MAX_CONF_REPLACE] =
{
ventoy_wrapper_file_flush_ex_img0,
ventoy_wrapper_file_flush_ex_img1,
#if (VTOY_MAX_CONF_REPLACE > 2)
ITEM_WRAP_FUNC(2),
#endif
#if (VTOY_MAX_CONF_REPLACE > 3)
ITEM_WRAP_FUNC(3),
#endif
#if (VTOY_MAX_CONF_REPLACE > 4)
ITEM_WRAP_FUNC(4),
#endif
#if (VTOY_MAX_CONF_REPLACE > 5)
ITEM_WRAP_FUNC(5),
#endif
#if (VTOY_MAX_CONF_REPLACE > 6)
ITEM_WRAP_FUNC(6),
#endif
#if (VTOY_MAX_CONF_REPLACE > 7)
ITEM_WRAP_FUNC(7),
#endif
};
STATIC ventoy_efi_file_replace *ventoy_wrapper_get_replace(EFI_FILE_HANDLE This)
{
UINTN i;
if (This->FlushEx == ventoy_wrapper_file_flush_ex)
{
return &g_efi_file_replace;
}
for (i = 0; i < VTOY_MAX_CONF_REPLACE; i++)
{
if (This->FlushEx == g_img_flush_func[i])
{
return g_img_file_replace + i;
}
}
return NULL;
}
STATIC EFI_STATUS EFIAPI
ventoy_wrapper_file_write(EFI_FILE_HANDLE This, UINTN *Len, VOID *Data)
@ -971,19 +1363,20 @@ ventoy_wrapper_file_close(EFI_FILE_HANDLE This)
return EFI_SUCCESS;
}
STATIC EFI_STATUS EFIAPI
ventoy_wrapper_file_set_pos(EFI_FILE_HANDLE This, UINT64 Position)
{
(VOID)This;
if (Position <= g_efi_file_replace.FileSizeBytes)
ventoy_efi_file_replace *replace = NULL;
replace = ventoy_wrapper_get_replace(This);
if (Position <= replace->FileSizeBytes)
{
g_efi_file_replace.CurPos = Position;
replace->CurPos = Position;
}
else
{
g_efi_file_replace.CurPos = g_efi_file_replace.FileSizeBytes;
replace->CurPos = replace->FileSizeBytes;
}
return EFI_SUCCESS;
@ -992,9 +1385,11 @@ ventoy_wrapper_file_set_pos(EFI_FILE_HANDLE This, UINT64 Position)
STATIC EFI_STATUS EFIAPI
ventoy_wrapper_file_get_pos(EFI_FILE_HANDLE This, UINT64 *Position)
{
(VOID)This;
ventoy_efi_file_replace *replace = NULL;
*Position = g_efi_file_replace.CurPos;
replace = ventoy_wrapper_get_replace(This);
*Position = replace->CurPos;
return EFI_SUCCESS;
}
@ -1004,6 +1399,9 @@ STATIC EFI_STATUS EFIAPI
ventoy_wrapper_file_get_info(EFI_FILE_HANDLE This, EFI_GUID *Type, UINTN *Len, VOID *Data)
{
EFI_FILE_INFO *Info = (EFI_FILE_INFO *) Data;
ventoy_efi_file_replace *replace = NULL;
replace = ventoy_wrapper_get_replace(This);
debug("ventoy_wrapper_file_get_info ... %u", *Len);
@ -1021,8 +1419,8 @@ ventoy_wrapper_file_get_info(EFI_FILE_HANDLE This, EFI_GUID *Type, UINTN *Len, V
ZeroMem(Data, sizeof(EFI_FILE_INFO));
Info->Size = sizeof(EFI_FILE_INFO);
Info->FileSize = g_efi_file_replace.FileSizeBytes;
Info->PhysicalSize = g_efi_file_replace.FileSizeBytes;
Info->FileSize = replace->FileSizeBytes;
Info->PhysicalSize = replace->FileSizeBytes;
Info->Attribute = EFI_FILE_READ_ONLY;
//Info->FileName = EFI_FILE_READ_ONLY;
@ -1036,23 +1434,24 @@ ventoy_wrapper_file_read(EFI_FILE_HANDLE This, UINTN *Len, VOID *Data)
{
EFI_LBA Lba;
UINTN ReadLen = *Len;
(VOID)This;
ventoy_efi_file_replace *replace = NULL;
replace = ventoy_wrapper_get_replace(This);
debug("ventoy_wrapper_file_read ... %u", *Len);
if (g_efi_file_replace.CurPos + ReadLen > g_efi_file_replace.FileSizeBytes)
if (replace->CurPos + ReadLen > replace->FileSizeBytes)
{
ReadLen = g_efi_file_replace.FileSizeBytes - g_efi_file_replace.CurPos;
ReadLen = replace->FileSizeBytes - replace->CurPos;
}
Lba = g_efi_file_replace.CurPos / 2048 + g_efi_file_replace.BlockIoSectorStart;
Lba = replace->CurPos / 2048 + replace->BlockIoSectorStart;
ventoy_block_io_read(NULL, 0, Lba, ReadLen, Data);
*Len = ReadLen;
g_efi_file_replace.CurPos += ReadLen;
replace->CurPos += ReadLen;
return EFI_SUCCESS;
}
@ -1063,7 +1462,7 @@ ventoy_wrapper_file_read_ex(IN EFI_FILE_PROTOCOL *This, IN OUT EFI_FILE_IO_TOKEN
return ventoy_wrapper_file_read(This, &(Token->BufferSize), Token->Buffer);
}
STATIC EFI_STATUS EFIAPI ventoy_wrapper_file_procotol(EFI_FILE_PROTOCOL *File)
STATIC EFI_STATUS EFIAPI ventoy_wrapper_file_procotol(EFI_FILE_PROTOCOL *File, BOOLEAN Img, UINTN Index)
{
File->Revision = EFI_FILE_PROTOCOL_REVISION2;
File->Open = ventoy_wrapper_fs_open;
@ -1079,11 +1478,47 @@ STATIC EFI_STATUS EFIAPI ventoy_wrapper_file_procotol(EFI_FILE_PROTOCOL *File)
File->OpenEx = ventoy_wrapper_file_open_ex;
File->ReadEx = ventoy_wrapper_file_read_ex;
File->WriteEx = ventoy_wrapper_file_write_ex;
File->FlushEx = ventoy_wrapper_file_flush_ex;
if (Img)
{
File->FlushEx = g_img_flush_func[Index];
}
else
{
File->FlushEx = ventoy_wrapper_file_flush_ex;
}
return EFI_SUCCESS;
}
STATIC BOOLEAN EFIAPI ventoy_replace_name_match(CHAR8 *pReplace, CHAR8 *pName)
{
UINTN Len1, Len2;
Len1 = AsciiStrLen(pReplace);
Len2 = AsciiStrLen(pName);
if (Len1 == 0 || Len2 == 0)
{
return FALSE;
}
if (0 == AsciiStriCmp(pReplace, pName))
{
return TRUE;
}
if (Len1 > 2 && Len2 > 2)
{
if ((pReplace[0] != '\\') && (pName[0] == '\\') && (0 == AsciiStriCmp(pReplace, pName + 1)))
{
return TRUE;
}
}
return FALSE;
}
STATIC EFI_STATUS EFIAPI ventoy_wrapper_file_open
(
EFI_FILE_HANDLE This,
@ -1098,27 +1533,40 @@ STATIC EFI_STATUS EFIAPI ventoy_wrapper_file_open
UINT64 Sectors = 0;
EFI_STATUS Status = EFI_SUCCESS;
CHAR8 TmpName[256];
CHAR8 OldName[256];
ventoy_virt_chunk *virt = NULL;
ventoy_grub_param_file_replace *replace = NULL;
debug("## ventoy_wrapper_file_open <%s> ", Name);
if ((Mode & EFI_FILE_MODE_WRITE) > 0 && StrCmp(Name, L"\\loader\\random-seed") == 0)
{
if (gDebugPrint)
{
debug("## ventoy_wrapper_file_open return NOT_FOUND for random-seed %lx", Mode);
sleep(3);
}
return EFI_NOT_FOUND;
}
Status = g_original_fopen(This, New, Name, Mode, Attributes);
if (EFI_ERROR(Status))
{
return Status;
}
if (g_file_replace_list && g_file_replace_list->magic == GRUB_FILE_REPLACE_MAGIC &&
g_file_replace_list->new_file_virtual_id < g_virt_chunk_num)
{
AsciiSPrint(TmpName, sizeof(TmpName), "%s", Name);
for (j = 0; j < 4; j++)
{
if (0 == AsciiStrCmp(g_file_replace_list[i].old_file_name[j], TmpName))
if (ventoy_replace_name_match(g_file_replace_list[i].old_file_name[j], TmpName))
{
g_original_fclose(*New);
*New = &g_efi_file_replace.WrapperHandle;
ventoy_wrapper_file_procotol(*New);
ventoy_wrapper_file_procotol(*New, FALSE, 0);
virt = g_virt_chunk + g_file_replace_list->new_file_virtual_id;
@ -1144,6 +1592,52 @@ STATIC EFI_STATUS EFIAPI ventoy_wrapper_file_open
}
}
for (i = 0; g_img_replace_list && i < VTOY_MAX_CONF_REPLACE; i++)
{
replace = g_img_replace_list + i;
if (replace->magic != GRUB_IMG_REPLACE_MAGIC || replace->new_file_virtual_id >= g_virt_chunk_num)
{
continue;
}
AsciiSPrint(TmpName, sizeof(TmpName), "%s", Name);
for (j = 0; j < replace->old_file_cnt; j++)
{
AsciiStrCpyS(OldName, sizeof(OldName), replace->old_file_name[j]);
if ((0 == AsciiStrCmp(OldName, TmpName)) ||
(AsciiStrnCmp(OldName, "\\loader\\entries\\", 16) == 0 &&
AsciiStrCmp(OldName + 16, TmpName) == 0
)
)
{
g_original_fclose(*New);
*New = &(g_img_file_replace[i].WrapperHandle);
ventoy_wrapper_file_procotol(*New, TRUE, i);
virt = g_virt_chunk + replace->new_file_virtual_id;
Sectors = (virt->mem_sector_end - virt->mem_sector_start) + (virt->remap_sector_end - virt->remap_sector_start);
g_img_file_replace[i].BlockIoSectorStart = virt->mem_sector_start;
g_img_file_replace[i].FileSizeBytes = Sectors * 2048;
if (gDebugPrint)
{
debug("## ventoy_wrapper_file_open2 <%s> BlockStart:%lu Sectors:%lu Bytes:%lu", Name,
g_img_file_replace[i].BlockIoSectorStart, Sectors, Sectors * 2048);
sleep(3);
}
return Status;
}
}
}
if (g_img_replace_list && StrCmp(Name, L"\\loader\\entries") == 0)
{
(*New)->Open = ventoy_wrapper_file_open;
}
return Status;
}

View File

@ -0,0 +1,140 @@
/******************************************************************************
* VtoyDrv.c
*
* 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/>.
*
*/
#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 <Protocol/LoadedImage.h>
#include <Guid/FileInfo.h>
#include <Guid/FileSystemInfo.h>
#include <Protocol/BlockIo.h>
#include <Protocol/RamDisk.h>
#include <Protocol/SimpleFileSystem.h>
#include <VtoyUtil.h>
STATIC UINTN g_EfiDriverNameCnt = 0;
STATIC CHAR16 *g_EfiDriverNameList[1024] = { NULL };
STATIC EFI_STATUS AddEfiDriverName(IN CHAR16 *DriverName)
{
UINTN i = 0;
if (g_EfiDriverNameCnt >= 1024)
{
return EFI_OUT_OF_RESOURCES;
}
for (i = 0; i < g_EfiDriverNameCnt; i++)
{
if (g_EfiDriverNameList[i] && StrCmp(g_EfiDriverNameList[i], DriverName) == 0)
{
break;
}
}
if (i >= g_EfiDriverNameCnt)
{
g_EfiDriverNameList[g_EfiDriverNameCnt] = DriverName;
g_EfiDriverNameCnt++;
}
return EFI_SUCCESS;
}
EFI_STATUS ShowEfiDrivers(IN EFI_HANDLE ImageHandle, IN CONST CHAR16 *CmdLine)
{
UINTN i = 0;
UINTN Count = 0;
CHAR16 *DriverName = NULL;
EFI_HANDLE *Handles = NULL;
EFI_STATUS Status = EFI_SUCCESS;
EFI_COMPONENT_NAME_PROTOCOL *NameProtocol = NULL;
EFI_COMPONENT_NAME2_PROTOCOL *Name2Protocol = NULL;
(VOID)ImageHandle;
(VOID)CmdLine;
Status = gBS->LocateHandleBuffer(ByProtocol, &gEfiComponentName2ProtocolGuid,
NULL, &Count, &Handles);
if (EFI_ERROR(Status))
{
return Status;
}
for (i = 0; i < Count; i++)
{
Status = gBS->HandleProtocol(Handles[i], &gEfiComponentName2ProtocolGuid, (VOID **)&Name2Protocol);
if (EFI_ERROR(Status))
{
continue;
}
DriverName = NULL;
Status = VtoyGetComponentName(2, Name2Protocol, &DriverName);
if ((!EFI_ERROR(Status)) && (DriverName))
{
AddEfiDriverName(DriverName);
}
}
Count = 0;
FreePool(Handles);
Handles = NULL;
Status = gBS->LocateHandleBuffer(ByProtocol, &gEfiComponentNameProtocolGuid,
NULL, &Count, &Handles);
if (EFI_ERROR(Status))
{
return Status;
}
for (i = 0; i < Count; i++)
{
Status = gBS->HandleProtocol(Handles[i], &gEfiComponentNameProtocolGuid, (VOID **)&NameProtocol);
if (EFI_ERROR(Status))
{
continue;
}
DriverName = NULL;
Status = VtoyGetComponentName(1, Name2Protocol, &DriverName);
if ((!EFI_ERROR(Status)) && (DriverName))
{
AddEfiDriverName(DriverName);
}
}
FreePool(Handles);
for (i = 0; i < g_EfiDriverNameCnt; i++)
{
Printf("%2d %s\n", i, g_EfiDriverNameList[i]);
}
return EFI_SUCCESS;
}

View File

@ -44,8 +44,39 @@ STATIC grub_env_printf_pf g_env_printf = NULL;
STATIC VtoyUtilFeature gFeatureList[] =
{
{ L"fix_windows_mmap", FixWindowsMemhole },
{ L"show_efi_drivers", ShowEfiDrivers },
};
EFI_STATUS VtoyGetComponentName(IN UINTN Ver, IN VOID *Protocol, OUT CHAR16 **DriverName)
{
EFI_STATUS Status = EFI_SUCCESS;
CHAR16 *DrvName = NULL;
EFI_COMPONENT_NAME_PROTOCOL *NameProtocol = NULL;
EFI_COMPONENT_NAME2_PROTOCOL *Name2Protocol = NULL;
if (1 == Ver)
{
NameProtocol = (EFI_COMPONENT_NAME_PROTOCOL *)Protocol;
Status = NameProtocol->GetDriverName(Protocol, "en", &DrvName);
if (EFI_ERROR(Status) || NULL == DrvName)
{
Status = NameProtocol->GetDriverName(Protocol, "eng", &DrvName);
}
}
else
{
Name2Protocol = (EFI_COMPONENT_NAME2_PROTOCOL *)Protocol;
Status = Name2Protocol->GetDriverName(Protocol, "en", &DrvName);
if (EFI_ERROR(Status) || NULL == DrvName)
{
Status = Name2Protocol->GetDriverName(Protocol, "eng", &DrvName);
}
}
*DriverName = DrvName;
return Status;
}
VOID EFIAPI VtoyUtilDebug(IN CONST CHAR8 *Format, ...)
{
VA_LIST Marker;

View File

@ -28,6 +28,8 @@ typedef int (*grub_env_set_pf)(const char *name, const char *val);
typedef const char * (*grub_env_get_pf)(const char *name);
typedef int (*grub_env_printf_pf)(const char *fmt, ...);
#define VTOY_MAX_CONF_REPLACE 2
typedef struct ventoy_grub_param_file_replace
{
UINT32 magic;
@ -41,6 +43,7 @@ typedef struct ventoy_grub_param
grub_env_get_pf grub_env_get;
grub_env_set_pf grub_env_set;
ventoy_grub_param_file_replace file_replace;
ventoy_grub_param_file_replace img_replace[VTOY_MAX_CONF_REPLACE];
grub_env_printf_pf grub_env_printf;
}ventoy_grub_param;
#pragma pack()
@ -57,7 +60,9 @@ VOID EFIAPI VtoyUtilDebug(IN CONST CHAR8 *Format, ...);
#define debug(expr, ...) if (gVtoyDebugPrint) VtoyUtilDebug("[VTOY] "expr"\n", ##__VA_ARGS__)
#define Printf VtoyUtilDebug
EFI_STATUS VtoyGetComponentName(IN UINTN Ver, IN VOID *Protocol, OUT CHAR16 **DriverName);
EFI_STATUS FixWindowsMemhole(IN EFI_HANDLE ImageHandle, IN CONST CHAR16 *CmdLine);
EFI_STATUS ShowEfiDrivers(IN EFI_HANDLE ImageHandle, IN CONST CHAR16 *CmdLine);
#endif

View File

@ -28,6 +28,7 @@
[Sources]
VtoyUtil.h
VtoyUtil.c
VtoyDrv.c
Memhole.c
[Packages]

View File

@ -913,6 +913,12 @@ module = {
enable = x86_64_efi;
};
module = {
name = fwload;
efi = commands/efi/fwload.c;
enable = efi;
};
module = {
name = gptsync;
common = commands/gptsync.c;
@ -1123,6 +1129,21 @@ module = {
common = commands/sleep.c;
};
module = {
name = smbios;
common = commands/smbios.c;
efi = commands/efi/smbios.c;
i386_pc = commands/i386/pc/smbios.c;
i386_coreboot = commands/i386/pc/smbios.c;
i386_multiboot = commands/i386/pc/smbios.c;
enable = efi;
enable = i386_pc;
enable = i386_coreboot;
enable = i386_multiboot;
};
module = {
name = suspend;
ieee1275 = commands/ieee1275/suspend.c;
@ -1512,7 +1533,7 @@ module = {
name = squash4;
common = fs/squash4.c;
cflags = '$(CFLAGS_POSIX) -Wno-undef';
cppflags = '-I$(srcdir)/lib/posix_wrap -I$(srcdir)/lib/xzembed -I$(srcdir)/lib/minilzo -DMINILZO_HAVE_CONFIG_H';
cppflags = '-I$(srcdir)/lib/posix_wrap -I$(srcdir)/lib/xzembed -I$(srcdir)/lib/minilzo -I$(srcdir)/lib/zstd -DMINILZO_HAVE_CONFIG_H';
};
module = {
@ -1603,12 +1624,14 @@ module = {
module = {
name = ventoy;
common = ventoy/ventoy.c;
common = ventoy/ventoy_cmd.c;
common = ventoy/ventoy_linux.c;
common = ventoy/ventoy_unix.c;
common = ventoy/ventoy_windows.c;
common = ventoy/ventoy_vhd.c;
common = ventoy/ventoy_plugin.c;
common = ventoy/ventoy_json.c;
common = ventoy/ventoy_browser.c;
common = ventoy/lzx.c;
common = ventoy/xpress.c;
common = ventoy/huffman.c;
@ -1620,6 +1643,12 @@ module = {
common = term/setkey.c;
};
module = {
name = mouse;
efi = term/efi/mouse.c;
enable = efi;
};
module = {
name = hello;
common = hello/hello.c;

View File

@ -0,0 +1,205 @@
/*
* GRUB -- GRand Unified Bootloader
* Copyright (C) 2022 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/dl.h>
#include <grub/efi/api.h>
#include <grub/efi/efi.h>
#include <grub/err.h>
#include <grub/extcmd.h>
#include <grub/file.h>
#include <grub/i18n.h>
#include <grub/misc.h>
#include <grub/mm.h>
#include <grub/types.h>
GRUB_MOD_LICENSE ("GPLv3+");
static grub_efi_guid_t loaded_image_guid = GRUB_EFI_LOADED_IMAGE_GUID;
static grub_efi_status_t
grub_efi_connect_all (void)
{
grub_efi_status_t status;
grub_efi_uintn_t handle_count;
grub_efi_handle_t *handle_buffer;
grub_efi_uintn_t index;
grub_efi_boot_services_t *b;
grub_dprintf ("efi", "Connecting ...\n");
b = grub_efi_system_table->boot_services;
status = efi_call_5 (b->locate_handle_buffer,
GRUB_EFI_ALL_HANDLES, NULL, NULL,
&handle_count, &handle_buffer);
if (status != GRUB_EFI_SUCCESS)
return status;
for (index = 0; index < handle_count; index++)
{
status = efi_call_4 (b->connect_controller,
handle_buffer[index], NULL, NULL, 1);
}
if (handle_buffer)
{
efi_call_1 (b->free_pool, handle_buffer);
}
return GRUB_EFI_SUCCESS;
}
static grub_err_t
grub_efi_load_driver (grub_size_t size, void *boot_image, int connect)
{
grub_efi_status_t status;
grub_efi_handle_t driver_handle;
grub_efi_boot_services_t *b;
grub_efi_loaded_image_t *loaded_image;
b = grub_efi_system_table->boot_services;
status = efi_call_6 (b->load_image, 0, grub_efi_image_handle, NULL,
boot_image, size, &driver_handle);
if (status != GRUB_EFI_SUCCESS)
{
if (status == GRUB_EFI_OUT_OF_RESOURCES)
grub_error (GRUB_ERR_OUT_OF_MEMORY, "out of resources");
else
grub_error (GRUB_ERR_BAD_OS, "cannot load image");
goto fail;
}
loaded_image = grub_efi_get_loaded_image (driver_handle);
if (! loaded_image)
{
grub_error (GRUB_ERR_BAD_OS, "no loaded image available");
goto fail;
}
grub_dprintf ("efi", "Registering loaded image\n");
status = efi_call_3 (b->handle_protocol, driver_handle,
&loaded_image_guid, (void **)&loaded_image);
if (status != GRUB_EFI_SUCCESS)
{
grub_error (GRUB_ERR_BAD_OS, "not a dirver");
goto fail;
}
grub_dprintf ("efi", "StartImage: %p\n", boot_image);
status = efi_call_3 (b->start_image, driver_handle, NULL, NULL);
if (status != GRUB_EFI_SUCCESS)
{
grub_error (GRUB_ERR_BAD_OS, "StartImage failed");
goto fail;
}
if (connect)
{
status = grub_efi_connect_all ();
if (status != GRUB_EFI_SUCCESS)
{
grub_error (GRUB_ERR_BAD_OS, "cannot connect controllers\n");
goto fail;
}
}
grub_dprintf ("efi", "Driver installed\n");
return 0;
fail:
return grub_errno;
}
static const struct grub_arg_option options_fwload[] =
{
{"nc", 'n', 0, N_("Loads the driver, but does not connect the driver."), 0, 0},
{0, 0, 0, 0, 0, 0}
};
static grub_err_t
grub_cmd_fwload (grub_extcmd_context_t ctxt, int argc, char **args)
{
struct grub_arg_list *state = ctxt->state;
int connect = 1;
grub_file_t file = 0;
grub_efi_boot_services_t *b;
grub_efi_status_t status;
grub_efi_uintn_t pages = 0;
grub_ssize_t size;
grub_efi_physical_address_t address;
void *boot_image = 0;
b = grub_efi_system_table->boot_services;
if (argc != 1)
goto fail;
file = grub_file_open (args[0], GRUB_FILE_TYPE_EFI_CHAINLOADED_IMAGE);
if (! file)
goto fail;
size = grub_file_size (file);
if (!size)
{
grub_error (GRUB_ERR_BAD_OS, N_("premature end of file %s"), args[0]);
goto fail;
}
pages = (((grub_efi_uintn_t) size + ((1 << 12) - 1)) >> 12);
status = efi_call_4 (b->allocate_pages, GRUB_EFI_ALLOCATE_ANY_PAGES,
GRUB_EFI_LOADER_CODE, pages, &address);
if (status != GRUB_EFI_SUCCESS)
{
grub_error (GRUB_ERR_OUT_OF_MEMORY, N_("out of memory"));
goto fail;
}
boot_image = (void *) ((grub_addr_t) address);
if (grub_file_read (file, boot_image, size) != size)
{
if (grub_errno == GRUB_ERR_NONE)
grub_error (GRUB_ERR_BAD_OS, N_("premature end of file %s"), args[0]);
goto fail;
}
grub_file_close (file);
if (state[0].set)
connect = 0;
if (grub_efi_load_driver (size, boot_image, connect))
goto fail;
return GRUB_ERR_NONE;
fail:
if (file)
grub_file_close (file);
if (address)
efi_call_2 (b->free_pages, address, pages);
return grub_errno;
}
static grub_err_t
grub_cmd_fwconnect (grub_extcmd_context_t ctxt __attribute__ ((unused)),
int argc __attribute__ ((unused)),
char **args __attribute__ ((unused)))
{
grub_efi_connect_all ();
return GRUB_ERR_NONE;
}
static grub_extcmd_t cmd_fwload, cmd_fwconnect;
GRUB_MOD_INIT(fwload)
{
cmd_fwload = grub_register_extcmd ("fwload", grub_cmd_fwload, 0, N_("FILE"),
N_("Install UEFI driver."), options_fwload);
cmd_fwconnect = grub_register_extcmd ("fwconnect", grub_cmd_fwconnect, 0,
NULL, N_("Connect drivers."), 0);
}
GRUB_MOD_FINI(fwload)
{
grub_unregister_extcmd (cmd_fwload);
grub_unregister_extcmd (cmd_fwconnect);
}

View File

@ -0,0 +1,61 @@
/* smbios.c - get smbios tables. */
/*
* GRUB -- GRand Unified Bootloader
* Copyright (C) 2019 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/smbios.h>
#include <grub/misc.h>
#include <grub/efi/efi.h>
#include <grub/efi/api.h>
struct grub_smbios_eps *
grub_machine_smbios_get_eps (void)
{
unsigned i;
static grub_efi_packed_guid_t smbios_guid = GRUB_EFI_SMBIOS_TABLE_GUID;
for (i = 0; i < grub_efi_system_table->num_table_entries; i++)
{
grub_efi_packed_guid_t *guid =
&grub_efi_system_table->configuration_table[i].vendor_guid;
if (! grub_memcmp (guid, &smbios_guid, sizeof (grub_efi_packed_guid_t)))
return (struct grub_smbios_eps *)
grub_efi_system_table->configuration_table[i].vendor_table;
}
return 0;
}
struct grub_smbios_eps3 *
grub_machine_smbios_get_eps3 (void)
{
unsigned i;
static grub_efi_packed_guid_t smbios3_guid = GRUB_EFI_SMBIOS3_TABLE_GUID;
for (i = 0; i < grub_efi_system_table->num_table_entries; i++)
{
grub_efi_packed_guid_t *guid =
&grub_efi_system_table->configuration_table[i].vendor_guid;
if (! grub_memcmp (guid, &smbios3_guid, sizeof (grub_efi_packed_guid_t)))
return (struct grub_smbios_eps3 *)
grub_efi_system_table->configuration_table[i].vendor_table;
}
return 0;
}

View File

@ -0,0 +1,351 @@
/*
* 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/dl.h>
#include <grub/extcmd.h>
#include <grub/file.h>
#include <grub/disk.h>
#include <grub/mm.h>
#include <grub/misc.h>
#include <grub/crypto.h>
#include <grub/normal.h>
#include <grub/i18n.h>
GRUB_MOD_LICENSE ("GPLv3+");
static const struct grub_arg_option options[] = {
{"hash", 'h', 0, N_("Specify hash to use."), N_("HASH"), ARG_TYPE_STRING},
{"check", 'c', 0, N_("Check hashes of files with hash list FILE."),
N_("FILE"), ARG_TYPE_STRING},
{"prefix", 'p', 0, N_("Base directory for hash list."), N_("DIR"),
ARG_TYPE_STRING},
{"keep-going", 'k', 0, N_("Don't stop after first error."), 0, 0},
{"uncompress", 'u', 0, N_("Uncompress file before checksumming."), 0, 0},
{0, 0, 0, 0, 0, 0}
};
static struct { const char *name; const char *hashname; } aliases[] =
{
{"sha256sum", "sha256"},
{"sha512sum", "sha512"},
{"sha1sum", "sha1"},
{"md5sum", "md5"},
{"crc", "crc32"},
};
static inline int
hextoval (char c)
{
if (c >= '0' && c <= '9')
return c - '0';
if (c >= 'a' && c <= 'f')
return c - 'a' + 10;
if (c >= 'A' && c <= 'F')
return c - 'A' + 10;
return -1;
}
static grub_err_t
hash_file (grub_file_t file, const gcry_md_spec_t *hash, void *result)
{
int progress = 0;
grub_uint64_t ro = 0;
grub_uint64_t div = 0;
grub_uint64_t total = 0;
void *context;
grub_uint8_t *readbuf;
#define BUF_SIZE 1024 * 1024
readbuf = grub_malloc (BUF_SIZE);
if (!readbuf)
return grub_errno;
context = grub_zalloc (hash->contextsize);
if (!readbuf || !context)
goto fail;
if (file->size > 16 * 1024 * 1024)
progress = 1;
hash->init (context);
while (1)
{
grub_ssize_t r;
r = grub_file_read (file, readbuf, BUF_SIZE);
if (r < 0)
goto fail;
if (r == 0)
break;
hash->write (context, readbuf, r);
if (progress)
{
total += r;
div = grub_divmod64(total * 100, (grub_uint64_t)file->size, &ro);
grub_printf("\rCalculating %s %d%% ", hash->name, (int)div);
grub_refresh();
}
}
hash->final (context);
grub_memcpy (result, hash->read (context), hash->mdlen);
grub_free (readbuf);
grub_free (context);
if (progress)
{
grub_printf("\rCalculating %s 100%% \n\r\n", hash->name);
grub_refresh();
}
return GRUB_ERR_NONE;
fail:
grub_free (readbuf);
grub_free (context);
return grub_errno;
}
static grub_err_t
check_list (const gcry_md_spec_t *hash, const char *hashfilename,
const char *prefix, int keep, int uncompress)
{
grub_file_t hashlist, file;
char *buf = NULL;
grub_uint8_t expected[GRUB_CRYPTO_MAX_MDLEN];
grub_uint8_t actual[GRUB_CRYPTO_MAX_MDLEN];
grub_err_t err;
unsigned i;
unsigned unread = 0, mismatch = 0;
if (hash->mdlen > GRUB_CRYPTO_MAX_MDLEN)
return grub_error (GRUB_ERR_BUG, "mdlen is too long");
hashlist = grub_file_open (hashfilename, GRUB_FILE_TYPE_HASHLIST);
if (!hashlist)
return grub_errno;
while (grub_free (buf), (buf = grub_file_getline (hashlist)))
{
const char *p = buf;
while (grub_isspace (p[0]))
p++;
for (i = 0; i < hash->mdlen; i++)
{
int high, low;
high = hextoval (*p++);
low = hextoval (*p++);
if (high < 0 || low < 0)
return grub_error (GRUB_ERR_BAD_FILE_TYPE, "invalid hash list");
expected[i] = (high << 4) | low;
}
if ((p[0] != ' ' && p[0] != '\t') || (p[1] != ' ' && p[1] != '\t'))
return grub_error (GRUB_ERR_BAD_FILE_TYPE, "invalid hash list");
p += 2;
if (prefix)
{
char *filename;
filename = grub_xasprintf ("%s/%s", prefix, p);
if (!filename)
return grub_errno;
file = grub_file_open (filename, GRUB_FILE_TYPE_TO_HASH
| (!uncompress ? GRUB_FILE_TYPE_NO_DECOMPRESS
: GRUB_FILE_TYPE_NONE));
grub_free (filename);
}
else
file = grub_file_open (p, GRUB_FILE_TYPE_TO_HASH
| (!uncompress ? GRUB_FILE_TYPE_NO_DECOMPRESS
: GRUB_FILE_TYPE_NONE));
if (!file)
{
grub_file_close (hashlist);
grub_free (buf);
return grub_errno;
}
err = hash_file (file, hash, actual);
grub_file_close (file);
if (err)
{
grub_printf_ (N_("%s: READ ERROR\n"), p);
if (!keep)
{
grub_file_close (hashlist);
grub_free (buf);
return err;
}
grub_print_error ();
grub_errno = GRUB_ERR_NONE;
unread++;
continue;
}
if (grub_crypto_memcmp (expected, actual, hash->mdlen) != 0)
{
grub_printf_ (N_("%s: HASH MISMATCH\n"), p);
if (!keep)
{
grub_file_close (hashlist);
grub_free (buf);
return grub_error (GRUB_ERR_TEST_FAILURE,
"hash of '%s' mismatches", p);
}
mismatch++;
continue;
}
grub_printf_ (N_("%s: OK\n"), p);
}
if (mismatch || unread)
return grub_error (GRUB_ERR_TEST_FAILURE,
"%d files couldn't be read and hash "
"of %d files mismatches", unread, mismatch);
return GRUB_ERR_NONE;
}
static grub_err_t
grub_cmd_hashsum (struct grub_extcmd_context *ctxt,
int argc, char **args)
{
struct grub_arg_list *state = ctxt->state;
const char *hashname = NULL;
const char *prefix = NULL;
const gcry_md_spec_t *hash;
unsigned i;
int keep = state[3].set;
int uncompress = state[4].set;
unsigned unread = 0;
int len = 0;
char hashsum[256];
for (i = 0; i < ARRAY_SIZE (aliases); i++)
if (grub_strcmp (ctxt->extcmd->cmd->name, aliases[i].name) == 0)
hashname = aliases[i].hashname;
if (state[0].set)
hashname = state[0].arg;
if (!hashname)
return grub_error (GRUB_ERR_BAD_ARGUMENT, "no hash specified");
hash = grub_crypto_lookup_md_by_name (hashname);
if (!hash)
return grub_error (GRUB_ERR_BAD_ARGUMENT, "unknown hash");
if (hash->mdlen > GRUB_CRYPTO_MAX_MDLEN)
return grub_error (GRUB_ERR_BUG, "mdlen is too long");
if (state[2].set)
prefix = state[2].arg;
if (state[1].set)
{
if (argc != 0)
return grub_error (GRUB_ERR_BAD_ARGUMENT,
"--check is incompatible with file list");
return check_list (hash, state[1].arg, prefix, keep, uncompress);
}
for (i = 0; i < (unsigned) argc; i++)
{
GRUB_PROPERLY_ALIGNED_ARRAY (result, GRUB_CRYPTO_MAX_MDLEN);
grub_file_t file;
grub_err_t err;
unsigned j;
int vlnk = 0;
file = grub_file_open (args[i], GRUB_FILE_TYPE_TO_HASH
| (!uncompress ? GRUB_FILE_TYPE_NO_DECOMPRESS
: GRUB_FILE_TYPE_NONE));
if (!file)
{
if (!keep)
return grub_errno;
grub_print_error ();
grub_errno = GRUB_ERR_NONE;
unread++;
continue;
}
vlnk = file->vlnk;
err = hash_file (file, hash, result);
grub_file_close (file);
if (err)
{
if (!keep)
return err;
grub_print_error ();
grub_errno = GRUB_ERR_NONE;
unread++;
continue;
}
for (j = 0; j < hash->mdlen; j++)
{
grub_printf ("%02x", ((grub_uint8_t *) result)[j]);
len += grub_snprintf(hashsum + len, sizeof(hashsum) - len, "%02x", ((grub_uint8_t *) result)[j]);
}
grub_printf (" %s\n", vlnk ? grub_file_get_vlnk(args[i], NULL) : args[i]);
grub_env_set("VT_LAST_CHECK_SUM", hashsum);
}
if (unread)
return grub_error (GRUB_ERR_TEST_FAILURE, "%d files couldn't be read",
unread);
return GRUB_ERR_NONE;
}
static grub_extcmd_t cmd, cmd_md5, cmd_sha1, cmd_sha256, cmd_sha512, cmd_crc;
GRUB_MOD_INIT(hashsum)
{
cmd = grub_register_extcmd ("hashsum", grub_cmd_hashsum, 0,
N_("-h HASH [-c FILE [-p PREFIX]] "
"[FILE1 [FILE2 ...]]"),
/* TRANSLATORS: "hash checksum" is just to
be a bit more precise, you can treat it as
just "hash". */
N_("Compute or check hash checksum."),
options);
cmd_md5 = grub_register_extcmd ("md5sum", grub_cmd_hashsum, 0,
N_("[-c FILE [-p PREFIX]] "
"[FILE1 [FILE2 ...]]"),
N_("Compute or check hash checksum."),
options);
cmd_sha1 = grub_register_extcmd ("sha1sum", grub_cmd_hashsum, 0,
N_("[-c FILE [-p PREFIX]] "
"[FILE1 [FILE2 ...]]"),
N_("Compute or check hash checksum."),
options);
cmd_sha256 = grub_register_extcmd ("sha256sum", grub_cmd_hashsum, 0,
N_("[-c FILE [-p PREFIX]] "
"[FILE1 [FILE2 ...]]"),
N_("Compute or check hash checksum."),
options);
cmd_sha512 = grub_register_extcmd ("sha512sum", grub_cmd_hashsum, 0,
N_("[-c FILE [-p PREFIX]] "
"[FILE1 [FILE2 ...]]"),
N_("Compute or check hash checksum."),
options);
cmd_crc = grub_register_extcmd ("crc", grub_cmd_hashsum, 0,
N_("[-c FILE [-p PREFIX]] "
"[FILE1 [FILE2 ...]]"),
N_("Compute or check hash checksum."),
options);
}
GRUB_MOD_FINI(hashsum)
{
grub_unregister_extcmd (cmd);
grub_unregister_extcmd (cmd_md5);
grub_unregister_extcmd (cmd_sha1);
grub_unregister_extcmd (cmd_sha256);
grub_unregister_extcmd (cmd_sha512);
grub_unregister_extcmd (cmd_crc);
}

View File

@ -0,0 +1,52 @@
/* smbios.c - get smbios tables. */
/*
* GRUB -- GRand Unified Bootloader
* Copyright (C) 2019 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/acpi.h>
#include <grub/smbios.h>
#include <grub/misc.h>
struct grub_smbios_eps *
grub_machine_smbios_get_eps (void)
{
grub_uint8_t *ptr;
grub_dprintf ("smbios", "Looking for SMBIOS EPS. Scanning BIOS\n");
for (ptr = (grub_uint8_t *) 0xf0000; ptr < (grub_uint8_t *) 0x100000; ptr += 16)
if (grub_memcmp (ptr, "_SM_", 4) == 0
&& grub_byte_checksum (ptr, sizeof (struct grub_smbios_eps)) == 0)
return (struct grub_smbios_eps *) ptr;
return 0;
}
struct grub_smbios_eps3 *
grub_machine_smbios_get_eps3 (void)
{
grub_uint8_t *ptr;
grub_dprintf ("smbios", "Looking for SMBIOS3 EPS. Scanning BIOS\n");
for (ptr = (grub_uint8_t *) 0xf0000; ptr < (grub_uint8_t *) 0x100000; ptr += 16)
if (grub_memcmp (ptr, "_SM3_", 5) == 0
&& grub_byte_checksum (ptr, sizeof (struct grub_smbios_eps3)) == 0)
return (struct grub_smbios_eps3 *) ptr;
return 0;
}

View File

@ -68,7 +68,7 @@ iterate_device (const char *name, void *data)
/* Skip floppy drives when requested. */
if (ctx->no_floppy &&
name[0] == 'f' && name[1] == 'd' && name[2] >= '0' && name[2] <= '9')
return 1;
return 0;
if (g_no_vtoyefi_part && (grub_strcmp(name, g_vtoyefi_dosname) == 0 || grub_strcmp(name, g_vtoyefi_gptname) == 0)) {
return 0;

View File

@ -0,0 +1,399 @@
/* smbios.c - retrieve smbios information. */
/*
* GRUB -- GRand Unified Bootloader
* Copyright (C) 2019 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/dl.h>
#include <grub/env.h>
#include <grub/extcmd.h>
#include <grub/i18n.h>
#include <grub/misc.h>
#include <grub/mm.h>
#include <grub/smbios.h>
GRUB_MOD_LICENSE ("GPLv3+");
/* Abstract useful values found in either the SMBIOS3 or SMBIOS EPS. */
static struct {
grub_addr_t start;
grub_addr_t end;
grub_uint16_t structures;
} table_desc;
static grub_extcmd_t cmd;
/* Locate the SMBIOS entry point structure depending on the hardware. */
struct grub_smbios_eps *
grub_smbios_get_eps (void)
{
static struct grub_smbios_eps *eps = NULL;
if (eps != NULL)
return eps;
eps = grub_machine_smbios_get_eps ();
return eps;
}
/* Locate the SMBIOS3 entry point structure depending on the hardware. */
static struct grub_smbios_eps3 *
grub_smbios_get_eps3 (void)
{
static struct grub_smbios_eps3 *eps = NULL;
if (eps != NULL)
return eps;
eps = grub_machine_smbios_get_eps3 ();
return eps;
}
static char *
linux_string (const char *value)
{
char *out = grub_malloc( grub_strlen (value) + 1);
const char *src = value;
char *dst = out;
for (; *src; src++)
if (*src > ' ' && *src < 127 && *src != ':')
*dst++ = *src;
*dst = 0;
return out;
}
/*
* These functions convert values from the various SMBIOS structure field types
* into a string formatted to be returned to the user. They expect that the
* structure and offset were already validated. When the requested data is
* successfully retrieved and formatted, the pointer to the string is returned;
* otherwise, NULL is returned on failure. Don't free the result.
*/
static const char *
grub_smbios_format_byte (const grub_uint8_t *structure, grub_uint8_t offset)
{
static char buffer[sizeof ("255")];
grub_snprintf (buffer, sizeof (buffer), "%u", structure[offset]);
return (const char *)buffer;
}
static const char *
grub_smbios_format_word (const grub_uint8_t *structure, grub_uint8_t offset)
{
static char buffer[sizeof ("65535")];
grub_uint16_t value = grub_get_unaligned16 (structure + offset);
grub_snprintf (buffer, sizeof (buffer), "%u", value);
return (const char *)buffer;
}
static const char *
grub_smbios_format_dword (const grub_uint8_t *structure, grub_uint8_t offset)
{
static char buffer[sizeof ("4294967295")];
grub_uint32_t value = grub_get_unaligned32 (structure + offset);
grub_snprintf (buffer, sizeof (buffer), "%" PRIuGRUB_UINT32_T, value);
return (const char *)buffer;
}
static const char *
grub_smbios_format_qword (const grub_uint8_t *structure, grub_uint8_t offset)
{
static char buffer[sizeof ("18446744073709551615")];
grub_uint64_t value = grub_get_unaligned64 (structure + offset);
grub_snprintf (buffer, sizeof (buffer), "%" PRIuGRUB_UINT64_T, value);
return (const char *)buffer;
}
static const char *
grub_smbios_get_string (const grub_uint8_t *structure, grub_uint8_t offset)
{
const grub_uint8_t *ptr = structure + structure[1];
const grub_uint8_t *table_end = (const grub_uint8_t *)table_desc.end;
const grub_uint8_t referenced_string_number = structure[offset];
grub_uint8_t i;
/* A string referenced with zero is interpreted as unset. */
if (referenced_string_number == 0)
return NULL;
/* Search the string set. */
for (i = 1; *ptr != 0 && ptr < table_end; i++)
if (i == referenced_string_number)
{
const char *str = (const char *)ptr;
while (*ptr++ != 0)
if (ptr >= table_end)
return NULL; /* The string isn't terminated. */
return str;
}
else
while (*ptr++ != 0 && ptr < table_end);
/* The string number is greater than the number of strings in the set. */
return NULL;
}
static const char *
grub_smbios_format_uuid (const grub_uint8_t *structure, grub_uint8_t offset)
{
static char buffer[sizeof ("ffffffff-ffff-ffff-ffff-ffffffffffff")];
const grub_uint8_t *f = structure + offset; /* little-endian fields */
const grub_uint8_t *g = f + 8; /* byte-by-byte fields */
grub_snprintf (buffer, sizeof (buffer),
"%02x%02x%02x%02x-%02x%02x-%02x%02x-"
"%02x%02x-%02x%02x%02x%02x%02x%02x",
f[3], f[2], f[1], f[0], f[5], f[4], f[7], f[6],
g[0], g[1], g[2], g[3], g[4], g[5], g[6], g[7]);
return (const char *)buffer;
}
/* List the field formatting functions and the number of bytes they need. */
static const struct {
const char *(*format) (const grub_uint8_t *structure, grub_uint8_t offset);
grub_uint8_t field_length;
} field_extractors[] = {
{grub_smbios_format_byte, 1},
{grub_smbios_format_word, 2},
{grub_smbios_format_dword, 4},
{grub_smbios_format_qword, 8},
{grub_smbios_get_string, 1},
{grub_smbios_format_uuid, 16}
};
/* List command options, with structure field getters ordered as above. */
#define FIRST_GETTER_OPT (3)
#define SETTER_OPT (FIRST_GETTER_OPT + ARRAY_SIZE(field_extractors))
#define LINUX_OPT (FIRST_GETTER_OPT + ARRAY_SIZE(field_extractors) + 1)
static const struct grub_arg_option options[] = {
{"type", 't', 0, N_("Match structures with the given type."),
N_("type"), ARG_TYPE_INT},
{"handle", 'h', 0, N_("Match structures with the given handle."),
N_("handle"), ARG_TYPE_INT},
{"match", 'm', 0, N_("Select a structure when several match."),
N_("match"), ARG_TYPE_INT},
{"get-byte", 'b', 0, N_("Get the byte's value at the given offset."),
N_("offset"), ARG_TYPE_INT},
{"get-word", 'w', 0, N_("Get two bytes' value at the given offset."),
N_("offset"), ARG_TYPE_INT},
{"get-dword", 'd', 0, N_("Get four bytes' value at the given offset."),
N_("offset"), ARG_TYPE_INT},
{"get-qword", 'q', 0, N_("Get eight bytes' value at the given offset."),
N_("offset"), ARG_TYPE_INT},
{"get-string", 's', 0, N_("Get the string specified at the given offset."),
N_("offset"), ARG_TYPE_INT},
{"get-uuid", 'u', 0, N_("Get the UUID's value at the given offset."),
N_("offset"), ARG_TYPE_INT},
{"set", '\0', 0, N_("Store the value in the given variable name."),
N_("variable"), ARG_TYPE_STRING},
{"linux", '\0', 0, N_("Filter the result like linux does."),
N_("variable"), ARG_TYPE_NONE},
{0, 0, 0, 0, 0, 0}
};
/*
* Return a matching SMBIOS structure.
*
* This method can use up to three criteria for selecting a structure:
* - The "type" field (use -1 to ignore)
* - The "handle" field (use -1 to ignore)
* - Which to return if several match (use 0 to ignore)
*
* The return value is a pointer to the first matching structure. If no
* structures match the given parameters, NULL is returned.
*/
static const grub_uint8_t *
grub_smbios_match_structure (const grub_int16_t type,
const grub_int32_t handle,
const grub_uint16_t match)
{
const grub_uint8_t *ptr = (const grub_uint8_t *)table_desc.start;
const grub_uint8_t *table_end = (const grub_uint8_t *)table_desc.end;
grub_uint16_t structures = table_desc.structures;
grub_uint16_t structure_count = 0;
grub_uint16_t matches = 0;
while (ptr < table_end
&& ptr[1] >= 4 /* Valid structures include the 4-byte header. */
&& (structure_count++ < structures || structures == 0))
{
grub_uint16_t structure_handle = grub_get_unaligned16 (ptr + 2);
grub_uint8_t structure_type = ptr[0];
if ((handle < 0 || handle == structure_handle)
&& (type < 0 || type == structure_type)
&& (match == 0 || match == ++matches))
return ptr;
else
{
ptr += ptr[1];
while ((*ptr++ != 0 || *ptr++ != 0) && ptr < table_end);
}
if (structure_type == GRUB_SMBIOS_TYPE_END_OF_TABLE)
break;
}
return NULL;
}
static grub_err_t
grub_cmd_smbios (grub_extcmd_context_t ctxt,
int argc __attribute__ ((unused)),
char **argv __attribute__ ((unused)))
{
struct grub_arg_list *state = ctxt->state;
grub_int16_t type = -1;
grub_int32_t handle = -1;
grub_uint16_t match = 0;
grub_uint8_t offset = 0;
const grub_uint8_t *structure;
const char *value;
char *modified_value = NULL;
grub_int32_t option;
grub_int8_t field_type = -1;
grub_uint8_t i;
if (table_desc.start == 0)
return grub_error (GRUB_ERR_IO,
N_("the SMBIOS entry point structure was not found"));
/* Read the given filtering options. */
if (state[0].set)
{
option = grub_strtol (state[0].arg, NULL, 0);
if (option < 0 || option > 255)
return grub_error (GRUB_ERR_BAD_ARGUMENT,
N_("the type must be between 0 and 255"));
type = (grub_int16_t)option;
}
if (state[1].set)
{
option = grub_strtol (state[1].arg, NULL, 0);
if (option < 0 || option > 65535)
return grub_error (GRUB_ERR_BAD_ARGUMENT,
N_("the handle must be between 0 and 65535"));
handle = (grub_int32_t)option;
}
if (state[2].set)
{
option = grub_strtol (state[2].arg, NULL, 0);
if (option <= 0 || option > 65535)
return grub_error (GRUB_ERR_BAD_ARGUMENT,
N_("the match must be a positive integer"));
match = (grub_uint16_t)option;
}
/* Determine the data type of the structure field to retrieve. */
for (i = 0; i < ARRAY_SIZE(field_extractors); i++)
if (state[FIRST_GETTER_OPT + i].set)
{
if (field_type >= 0)
return grub_error (GRUB_ERR_BAD_ARGUMENT,
N_("only one --get option is usable at a time"));
field_type = i;
}
/* Require a choice of a structure field to return. */
if (field_type < 0)
return grub_error (GRUB_ERR_BAD_ARGUMENT,
N_("one of the --get options is required"));
/* Locate a matching SMBIOS structure. */
structure = grub_smbios_match_structure (type, handle, match);
if (structure == NULL)
return grub_error (GRUB_ERR_IO,
N_("no structure matched the given options"));
/* Ensure the requested byte offset is inside the structure. */
option = grub_strtol (state[FIRST_GETTER_OPT + field_type].arg, NULL, 0);
if (option < 0 || option >= structure[1])
return grub_error (GRUB_ERR_OUT_OF_RANGE,
N_("the given offset is outside the structure"));
/* Ensure the requested data type at the offset is inside the structure. */
offset = (grub_uint8_t)option;
if (offset + field_extractors[field_type].field_length > structure[1])
return grub_error (GRUB_ERR_OUT_OF_RANGE,
N_("the field ends outside the structure"));
/* Format the requested structure field into a readable string. */
value = field_extractors[field_type].format (structure, offset);
if (value == NULL)
return grub_error (GRUB_ERR_IO,
N_("failed to retrieve the structure field"));
if (state[LINUX_OPT].set)
value = modified_value = linux_string (value);
/* Store or print the formatted value. */
if (state[SETTER_OPT].set)
grub_env_set (state[SETTER_OPT].arg, value);
else
grub_printf ("%s\n", value);
grub_free(modified_value);
return GRUB_ERR_NONE;
}
GRUB_MOD_INIT(smbios)
{
struct grub_smbios_eps3 *eps3;
struct grub_smbios_eps *eps;
if ((eps3 = grub_smbios_get_eps3 ()))
{
table_desc.start = (grub_addr_t)eps3->table_address;
table_desc.end = table_desc.start + eps3->maximum_table_length;
table_desc.structures = 0; /* SMBIOS3 drops the structure count. */
}
else if ((eps = grub_smbios_get_eps ()))
{
table_desc.start = (grub_addr_t)eps->intermediate.table_address;
table_desc.end = table_desc.start + eps->intermediate.table_length;
table_desc.structures = eps->intermediate.structures;
}
cmd = grub_register_extcmd ("smbios", grub_cmd_smbios, 0,
N_("[-t type] [-h handle] [-m match] "
"(-b|-w|-d|-q|-s|-u) offset "
"[--set variable]"),
N_("Retrieve SMBIOS information."), options);
}
GRUB_MOD_FINI(smbios)
{
grub_unregister_extcmd (cmd);
}

View File

@ -229,6 +229,13 @@ test_parse (char **args, int *argn, int argc)
(*argn) += 3;
continue;
}
if (grub_strcmp (args[*argn + 1], "-EQ") == 0)
{
update_val (grub_strtoull (args[*argn], 0, 0)
== grub_strtoull (args[*argn + 2], 0, 0), &ctx);
(*argn) += 3;
continue;
}
if (grub_strcmp (args[*argn + 1], "-ge") == 0)
{
@ -237,6 +244,13 @@ test_parse (char **args, int *argn, int argc)
(*argn) += 3;
continue;
}
if (grub_strcmp (args[*argn + 1], "-GE") == 0)
{
update_val (grub_strtoull (args[*argn], 0, 0)
>= grub_strtoull (args[*argn + 2], 0, 0), &ctx);
(*argn) += 3;
continue;
}
if (grub_strcmp (args[*argn + 1], "-gt") == 0)
{
@ -245,6 +259,13 @@ test_parse (char **args, int *argn, int argc)
(*argn) += 3;
continue;
}
if (grub_strcmp (args[*argn + 1], "-GT") == 0)
{
update_val (grub_strtoull (args[*argn], 0, 0)
> grub_strtoull (args[*argn + 2], 0, 0), &ctx);
(*argn) += 3;
continue;
}
if (grub_strcmp (args[*argn + 1], "-le") == 0)
{
@ -253,6 +274,13 @@ test_parse (char **args, int *argn, int argc)
(*argn) += 3;
continue;
}
if (grub_strcmp (args[*argn + 1], "-LE") == 0)
{
update_val (grub_strtoull (args[*argn], 0, 0)
<= grub_strtoull (args[*argn + 2], 0, 0), &ctx);
(*argn) += 3;
continue;
}
if (grub_strcmp (args[*argn + 1], "-lt") == 0)
{
@ -261,6 +289,13 @@ test_parse (char **args, int *argn, int argc)
(*argn) += 3;
continue;
}
if (grub_strcmp (args[*argn + 1], "-LT") == 0)
{
update_val (grub_strtoull (args[*argn], 0, 0)
< grub_strtoull (args[*argn + 2], 0, 0), &ctx);
(*argn) += 3;
continue;
}
if (grub_strcmp (args[*argn + 1], "-ne") == 0)
{
@ -269,6 +304,13 @@ test_parse (char **args, int *argn, int argc)
(*argn) += 3;
continue;
}
if (grub_strcmp (args[*argn + 1], "-NE") == 0)
{
update_val (grub_strtoull (args[*argn], 0, 0)
!= grub_strtoull (args[*argn + 2], 0, 0), &ctx);
(*argn) += 3;
continue;
}
/* GRUB extension: compare numbers skipping prefixes.
Useful for comparing versions. E.g. vmlinuz-2 -plt vmlinuz-11. */

View File

@ -0,0 +1,257 @@
/* loopback.c - command to add loopback devices. */
/*
* GRUB -- GRand Unified Bootloader
* Copyright (C) 2005,2006,2007 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/dl.h>
#include <grub/misc.h>
#include <grub/file.h>
#include <grub/disk.h>
#include <grub/mm.h>
#include <grub/extcmd.h>
#include <grub/i18n.h>
GRUB_MOD_LICENSE ("GPLv3+");
struct grub_loopback
{
char *devname;
grub_file_t file;
struct grub_loopback *next;
unsigned long id;
grub_off_t skip;
};
static struct grub_loopback *loopback_list;
static unsigned long last_id = 0;
static const struct grub_arg_option options[] =
{
/* TRANSLATORS: The disk is simply removed from the list of available ones,
not wiped, avoid to scare user. */
{"delete", 'd', 0, N_("Delete the specified loopback drive."), 0, 0},
{"skip", 's', 0, "skip sectors of the file.", "SECTORS", ARG_TYPE_INT },
{0, 0, 0, 0, 0, 0}
};
/* Delete the loopback device NAME. */
static grub_err_t
delete_loopback (const char *name)
{
struct grub_loopback *dev;
struct grub_loopback **prev;
/* Search for the device. */
for (dev = loopback_list, prev = &loopback_list;
dev;
prev = &dev->next, dev = dev->next)
if (grub_strcmp (dev->devname, name) == 0)
break;
if (! dev)
return grub_error (GRUB_ERR_BAD_DEVICE, "device not found");
/* Remove the device from the list. */
*prev = dev->next;
grub_free (dev->devname);
grub_file_close (dev->file);
grub_free (dev);
return 0;
}
/* The command to add and remove loopback devices. */
static grub_err_t
grub_cmd_loopback (grub_extcmd_context_t ctxt, int argc, char **args)
{
struct grub_arg_list *state = ctxt->state;
grub_file_t file;
struct grub_loopback *newdev;
grub_err_t ret;
grub_off_t skip = 0;
if (argc < 1)
return grub_error (GRUB_ERR_BAD_ARGUMENT, "device name required");
/* Check if `-d' was used. */
if (state[0].set)
return delete_loopback (args[0]);
if (state[1].set)
skip = (grub_off_t)grub_strtoull(state[1].arg, NULL, 10);
if (argc < 2)
return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("filename expected"));
file = grub_file_open (args[1], GRUB_FILE_TYPE_LOOPBACK
| GRUB_FILE_TYPE_NO_DECOMPRESS);
if (! file)
return grub_errno;
/* First try to replace the old device. */
for (newdev = loopback_list; newdev; newdev = newdev->next)
if (grub_strcmp (newdev->devname, args[0]) == 0)
break;
if (newdev)
{
grub_file_close (newdev->file);
newdev->file = file;
newdev->skip = skip;
return 0;
}
/* Unable to replace it, make a new entry. */
newdev = grub_malloc (sizeof (struct grub_loopback));
if (! newdev)
goto fail;
newdev->devname = grub_strdup (args[0]);
if (! newdev->devname)
{
grub_free (newdev);
goto fail;
}
newdev->file = file;
newdev->skip = skip;
newdev->id = last_id++;
/* Add the new entry to the list. */
newdev->next = loopback_list;
loopback_list = newdev;
return 0;
fail:
ret = grub_errno;
grub_file_close (file);
return ret;
}
static int
grub_loopback_iterate (grub_disk_dev_iterate_hook_t hook, void *hook_data,
grub_disk_pull_t pull)
{
struct grub_loopback *d;
if (pull != GRUB_DISK_PULL_NONE)
return 0;
for (d = loopback_list; d; d = d->next)
{
if (hook (d->devname, hook_data))
return 1;
}
return 0;
}
static grub_err_t
grub_loopback_open (const char *name, grub_disk_t disk)
{
struct grub_loopback *dev;
for (dev = loopback_list; dev; dev = dev->next)
if (grub_strcmp (dev->devname, name) == 0)
break;
if (! dev)
return grub_error (GRUB_ERR_UNKNOWN_DEVICE, "can't open device");
/* Use the filesize for the disk size, round up to a complete sector. */
if (dev->file->size != GRUB_FILE_SIZE_UNKNOWN)
disk->total_sectors = ((dev->file->size + GRUB_DISK_SECTOR_SIZE - 1)
/ GRUB_DISK_SECTOR_SIZE);
else
disk->total_sectors = GRUB_DISK_SIZE_UNKNOWN;
/* Avoid reading more than 512M. */
disk->max_agglomerate = 1 << (29 - GRUB_DISK_SECTOR_BITS
- GRUB_DISK_CACHE_BITS);
disk->id = dev->id;
disk->data = dev;
return 0;
}
static grub_err_t
grub_loopback_read (grub_disk_t disk, grub_disk_addr_t sector,
grub_size_t size, char *buf)
{
grub_file_t file = ((struct grub_loopback *) disk->data)->file;
grub_off_t skip = ((struct grub_loopback *) disk->data)->skip;
grub_off_t pos;
grub_file_seek (file, (sector + skip) << GRUB_DISK_SECTOR_BITS);
grub_file_read (file, buf, size << GRUB_DISK_SECTOR_BITS);
if (grub_errno)
return grub_errno;
/* In case there is more data read than there is available, in case
of files that are not a multiple of GRUB_DISK_SECTOR_SIZE, fill
the rest with zeros. */
pos = (sector + skip + size) << GRUB_DISK_SECTOR_BITS;
if (pos > file->size)
{
grub_size_t amount = pos - file->size;
grub_memset (buf + (size << GRUB_DISK_SECTOR_BITS) - amount, 0, amount);
}
return 0;
}
static grub_err_t
grub_loopback_write (grub_disk_t disk __attribute ((unused)),
grub_disk_addr_t sector __attribute ((unused)),
grub_size_t size __attribute ((unused)),
const char *buf __attribute ((unused)))
{
return grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET,
"loopback write is not supported");
}
static struct grub_disk_dev grub_loopback_dev =
{
.name = "loopback",
.id = GRUB_DISK_DEVICE_LOOPBACK_ID,
.disk_iterate = grub_loopback_iterate,
.disk_open = grub_loopback_open,
.disk_read = grub_loopback_read,
.disk_write = grub_loopback_write,
.next = 0
};
static grub_extcmd_t cmd;
GRUB_MOD_INIT(loopback)
{
cmd = grub_register_extcmd ("loopback", grub_cmd_loopback, 0,
N_("[-d] DEVICENAME FILE."),
/* TRANSLATORS: The file itself is not destroyed
or transformed into drive. */
N_("Make a virtual drive from a file."), options);
grub_disk_dev_register (&grub_loopback_dev);
}
GRUB_MOD_FINI(loopback)
{
grub_unregister_extcmd (cmd);
grub_disk_dev_unregister (&grub_loopback_dev);
}

File diff suppressed because it is too large Load Diff

View File

@ -103,6 +103,7 @@ GRUB_MOD_LICENSE ("GPLv3+");
#define EXT4_FEATURE_INCOMPAT_64BIT 0x0080
#define EXT4_FEATURE_INCOMPAT_MMP 0x0100
#define EXT4_FEATURE_INCOMPAT_FLEX_BG 0x0200
#define EXT4_FEATURE_INCOMPAT_CSUM_SEED 0x2000
#define EXT4_FEATURE_INCOMPAT_ENCRYPT 0x10000
/* 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
* avoid multiple read-write mounts. Safe to ignore for this
* 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 \
| EXT4_FEATURE_INCOMPAT_MMP)
| EXT4_FEATURE_INCOMPAT_MMP \
| EXT4_FEATURE_INCOMPAT_CSUM_SEED)
#define EXT3_JOURNAL_MAGIC_NUMBER 0xc03b3998U
@ -723,10 +731,11 @@ grub_ext2_read_symlink (grub_fshelp_node_t node)
if (! symlink)
return 0;
/* If the filesize of the symlink is bigger than
60 the symlink 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 the filesize of the symlink is equal to or bigger than 60 the symlink
* 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))
grub_memcpy (symlink,
diro->inode.symlink,
grub_le_to_cpu32 (diro->inode.size));

View File

@ -426,7 +426,7 @@ grub_fshelp_read_file (grub_disk_t disk, grub_fshelp_node_t node,
if (grub_errno)
return -1;
}
else if (read_hook != (grub_disk_read_hook_t)grub_disk_blocklist_read)
else if (read_hook != (grub_disk_read_hook_t)(void *)grub_disk_blocklist_read)
grub_memset (buf, 0, blockend);
buf += blocksize - skipfirst;

View File

@ -33,6 +33,7 @@
GRUB_MOD_LICENSE ("GPLv3+");
static int g_ventoy_no_joliet = 0;
static int g_ventoy_cur_joliet = 0;
static grub_uint64_t g_ventoy_last_read_pos = 0;
static grub_uint64_t g_ventoy_last_read_offset = 0;
static grub_uint64_t g_ventoy_last_read_dirent_pos = 0;
@ -451,6 +452,7 @@ grub_iso9660_mount (grub_disk_t disk)
data->disk = disk;
g_ventoy_cur_joliet = 0;
block = 16;
do
{
@ -484,6 +486,7 @@ grub_iso9660_mount (grub_disk_t disk)
if (0 == g_ventoy_no_joliet) {
copy_voldesc = 1;
data->joliet = 1;
g_ventoy_cur_joliet = 1;
}
}
@ -1118,6 +1121,11 @@ void grub_iso9660_set_nojoliet(int nojoliet)
g_ventoy_no_joliet = nojoliet;
}
int grub_iso9660_is_joliet(void)
{
return g_ventoy_cur_joliet;
}
grub_uint64_t grub_iso9660_get_last_read_pos(grub_file_t file)
{
(void)file;

View File

@ -889,6 +889,7 @@ grub_ntfs_mount (grub_disk_t disk)
struct grub_ntfs_bpb bpb;
struct grub_ntfs_data *data = 0;
grub_uint32_t spc;
grub_uint32_t sectors_per_cluster;
if (!disk)
goto fail;
@ -903,14 +904,18 @@ grub_ntfs_mount (grub_disk_t disk)
if (grub_disk_read (disk, 0, 0, sizeof (bpb), &bpb))
goto fail;
sectors_per_cluster = bpb.sectors_per_cluster;
if (sectors_per_cluster > 0x80)
sectors_per_cluster = 1U << (256U - bpb.sectors_per_cluster);
if (grub_memcmp ((char *) &bpb.oem_name, "NTFS", 4) != 0
|| bpb.sectors_per_cluster == 0
|| (bpb.sectors_per_cluster & (bpb.sectors_per_cluster - 1)) != 0
|| sectors_per_cluster == 0
|| (sectors_per_cluster & (sectors_per_cluster - 1)) != 0
|| bpb.bytes_per_sector == 0
|| (bpb.bytes_per_sector & (bpb.bytes_per_sector - 1)) != 0)
goto fail;
spc = (((grub_uint32_t) bpb.sectors_per_cluster
spc = (((grub_uint32_t) sectors_per_cluster
* (grub_uint32_t) grub_le_to_cpu16 (bpb.bytes_per_sector))
>> GRUB_NTFS_BLK_SHR);
if (spc == 0)

File diff suppressed because it is too large Load Diff

View File

@ -23,11 +23,25 @@
#include <grub/misc.h>
#include <grub/disk.h>
#include <grub/dl.h>
#include <grub/time.h>
#include <grub/types.h>
#include <grub/fshelp.h>
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_FORMAT_INO 1
@ -74,10 +88,22 @@ GRUB_MOD_LICENSE ("GPLv3+");
XFS_SB_VERSION2_PROJID32BIT | \
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 */
#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_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.
@ -87,11 +113,26 @@ GRUB_MOD_LICENSE ("GPLv3+");
*
* We do not currently verify metadata UUID, so it is safe to read filesystems
* 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 \
(XFS_SB_FEAT_INCOMPAT_FTYPE | \
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
{
@ -176,33 +217,49 @@ struct grub_xfs_btree_root
grub_uint64_t keys[1];
} GRUB_PACKED;
struct grub_xfs_time
struct grub_xfs_time_legacy
{
grub_uint32_t sec;
grub_uint32_t nanosec;
} 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
{
grub_uint8_t magic[2];
grub_uint16_t mode;
grub_uint8_t version;
grub_uint8_t format;
grub_uint8_t unused2[26];
struct grub_xfs_time atime;
struct grub_xfs_time mtime;
struct grub_xfs_time ctime;
grub_uint8_t unused2[18];
grub_uint64_t nextents_big;
grub_uint64_t atime;
grub_uint64_t mtime;
grub_uint64_t ctime;
grub_uint64_t size;
grub_uint64_t nblocks;
grub_uint32_t extsize;
grub_uint32_t nextents;
grub_uint16_t unused3;
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;
#define XFS_V2_INODE_SIZE sizeof(struct grub_xfs_inode)
#define XFS_V3_INODE_SIZE (XFS_V2_INODE_SIZE + 76)
#define XFS_V3_INODE_SIZE sizeof(struct grub_xfs_inode)
/* 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
{
@ -220,6 +277,7 @@ struct grub_fshelp_node
struct grub_xfs_data
{
grub_size_t data_size;
struct grub_xfs_sblock sblock;
grub_disk_t disk;
int pos;
@ -232,8 +290,6 @@ struct grub_xfs_data
static grub_dl_t my_mod;
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)) ==
@ -296,9 +352,21 @@ static int grub_xfs_sb_valid(struct grub_xfs_data *data)
}
return 1;
}
grub_error (GRUB_ERR_BAD_FS, "unsupported XFS filesystem version");
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. */
#define FILETYPE_INO_MASK 0170000
#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));
}
static inline grub_uint64_t
grub_xfs_inode_block (struct grub_xfs_data *data,
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);
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);
/* Read the inode. */
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));
}
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
grub_xfs_read_block (grub_fshelp_node_t node, grub_disk_addr_t fileblock)
{
struct grub_xfs_btree_node *leaf = 0;
int ex, nrec;
grub_uint64_t ex, nrec;
struct grub_xfs_extent *exts;
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));
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++)
{
@ -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,
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))
return 0;
{
grub_free (leaf);
return 0;
}
if ((!node->data->hascrc &&
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)
{
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);
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
{
@ -634,6 +742,7 @@ static char *
grub_xfs_read_symlink (grub_fshelp_node_t node)
{
grub_ssize_t size = grub_be_to_cpu64 (node->inode.size);
grub_size_t sz;
if (size < 0)
{
@ -655,7 +764,12 @@ grub_xfs_read_symlink (grub_fshelp_node_t node)
if (node->data->hascrc)
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)
return 0;
@ -705,8 +819,15 @@ static int iterate_dir_call_hook (grub_uint64_t ino, const char *filename,
{
struct grub_fshelp_node *fdiro;
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)
{
grub_print_error ();
@ -722,6 +843,7 @@ static int iterate_dir_call_hook (grub_uint64_t ino, const char *filename,
if (err)
{
grub_print_error ();
grub_free (fdiro);
return 0;
}
@ -764,12 +886,20 @@ grub_xfs_iterate_dir (grub_fshelp_node_t dir,
if (iterate_dir_call_hook (parent, "..", &ctx))
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_uint8_t *inopos = grub_xfs_inline_de_inopos(dir->data, de);
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. */
if (smallino)
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 =
grub_xfs_first_de(dir->data, dirblock);
int entries;
struct grub_xfs_dirblock_tail *tail =
grub_xfs_dir_tail(dir->data, dirblock);
int entries = -1;
char *end = dirblock + dirblk_size;
grub_uint32_t magic;
numread = grub_xfs_read_file (dir, 0, 0,
blk << dirblk_log2,
dirblk_size, dirblock, 0);
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 (!entries)
/*
* 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
* number field is all zeros then this block should be skipped.
*/
magic = *(grub_uint32_t *)(void *) dirblock;
if (!magic)
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. */
while ((char *)direntry < (char *)tail)
while ((char *) direntry < (char *) end)
{
grub_uint8_t *freetag;
char *filename;
@ -861,22 +1016,34 @@ grub_xfs_iterate_dir (grub_fshelp_node_t dir,
}
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
tag, which is not used by GRUB. So it can be overwritten. */
filename[direntry->len] = '\0';
if (iterate_dir_call_hook (grub_be_to_cpu64(direntry->inode),
if (iterate_dir_call_hook (grub_be_to_cpu64(direntry->inode),
filename, &ctx))
{
grub_free (dirblock);
return 1;
}
/* Check if last direntry in this block is
reached. */
entries--;
if (!entries)
break;
/*
* The expected number of directory entries is only tracked for the
* single extent case.
*/
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. */
direntry = grub_xfs_next_de(dir->data, direntry);
@ -899,11 +1066,14 @@ static struct grub_xfs_data *
grub_xfs_mount (grub_disk_t disk)
{
struct grub_xfs_data *data = 0;
grub_size_t sz;
data = grub_zalloc (sizeof (struct grub_xfs_data));
if (!data)
return 0;
data->data_size = sizeof (struct grub_xfs_data);
grub_dprintf("xfs", "Reading sb\n");
/* Read the superblock. */
if (grub_disk_read (disk, 0, 0,
@ -913,14 +1083,19 @@ grub_xfs_mount (grub_disk_t disk)
if (!grub_xfs_sb_valid(data))
goto fail;
data = grub_realloc (data,
sizeof (struct grub_xfs_data)
- sizeof (struct grub_xfs_inode)
+ grub_xfs_inode_size(data) + 1);
if (grub_xfs_sb_needs_repair (data))
grub_dprintf ("xfs", "XFS filesystem needs repair, boot may fail\n");
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)
goto fail;
data->data_size = sz;
data->diropen.data = data;
data->diropen.ino = grub_be_to_cpu64(data->sblock.rootino);
data->diropen.inode_read = 1;
@ -931,7 +1106,7 @@ grub_xfs_mount (grub_disk_t disk)
data->disk = disk;
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_xfs_read_inode (data, data->diropen.ino, &data->diropen.inode);
@ -939,7 +1114,7 @@ grub_xfs_mount (grub_disk_t disk)
return data;
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_free (data);
@ -947,7 +1122,6 @@ grub_xfs_mount (grub_disk_t disk)
return 0;
}
/* Context for grub_xfs_dir. */
struct grub_xfs_dir_ctx
{
@ -955,6 +1129,27 @@ struct grub_xfs_dir_ctx
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. */
static int
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)
{
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);
grub_free (node);
@ -1132,8 +1327,6 @@ grub_xfs_uuid (grub_device_t device, char **uuid)
return grub_errno;
}
static struct grub_fs grub_xfs_fs =
{
.name = "xfs",
@ -1152,6 +1345,7 @@ static struct grub_fs grub_xfs_fs =
GRUB_MOD_INIT(xfs)
{
//grub_xfs_fs.mod = mod;
grub_fs_register (&grub_xfs_fs);
my_mod = mod;
}

View File

@ -0,0 +1,285 @@
/*
* LZ4 - Fast LZ compression algorithm
* Header File
* Copyright (C) 2011-2013, Yann Collet.
* BSD 2-Clause License (http://www.opensource.org/licenses/bsd-license.php)
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following disclaimer
* in the documentation and/or other materials provided with the
* distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* You can contact the author at :
* - LZ4 homepage : http://fastcompression.blogspot.com/p/lz4.html
* - LZ4 source repository : http://code.google.com/p/lz4/
*/
#include <grub/err.h>
#include <grub/mm.h>
#include <grub/misc.h>
#include <grub/types.h>
int LZ4_uncompress_unknownOutputSize(const char *source, char *dest,
int isize, int maxOutputSize);
/*
* CPU Feature Detection
*/
/* 32 or 64 bits ? */
#if (GRUB_CPU_SIZEOF_VOID_P == 8)
#define LZ4_ARCH64 1
#else
#define LZ4_ARCH64 0
#endif
/*
* Compiler Options
*/
#define GCC_VERSION (__GNUC__ * 100 + __GNUC_MINOR__)
#if (GCC_VERSION >= 302) || (defined (__INTEL_COMPILER) && __INTEL_COMPILER >= 800) || defined(__clang__)
#define expect(expr, value) (__builtin_expect((expr), (value)))
#else
#define expect(expr, value) (expr)
#endif
#define likely(expr) expect((expr) != 0, 1)
#define unlikely(expr) expect((expr) != 0, 0)
/* Basic types */
#define BYTE grub_uint8_t
#define U16 grub_uint16_t
#define U32 grub_uint32_t
#define S32 grub_int32_t
#define U64 grub_uint64_t
typedef struct _U16_S {
U16 v;
} GRUB_PACKED U16_S;
typedef struct _U32_S {
U32 v;
} GRUB_PACKED U32_S;
typedef struct _U64_S {
U64 v;
} GRUB_PACKED U64_S;
#define A64(x) (((U64_S *)(x))->v)
#define A32(x) (((U32_S *)(x))->v)
#define A16(x) (((U16_S *)(x))->v)
/*
* Constants
*/
#define MINMATCH 4
#define COPYLENGTH 8
#define LASTLITERALS 5
#define ML_BITS 4
#define ML_MASK ((1U<<ML_BITS)-1)
#define RUN_BITS (8-ML_BITS)
#define RUN_MASK ((1U<<RUN_BITS)-1)
/*
* Architecture-specific macros
*/
#if LZ4_ARCH64
#define STEPSIZE 8
#define UARCH U64
#define AARCH A64
#define LZ4_COPYSTEP(s, d) A64(d) = A64(s); d += 8; s += 8;
#define LZ4_COPYPACKET(s, d) LZ4_COPYSTEP(s, d)
#define LZ4_SECURECOPY(s, d, e) if (d < e) LZ4_WILDCOPY(s, d, e)
#define HTYPE U32
#define INITBASE(base) const BYTE* const base = ip
#else
#define STEPSIZE 4
#define UARCH U32
#define AARCH A32
#define LZ4_COPYSTEP(s, d) A32(d) = A32(s); d += 4; s += 4;
#define LZ4_COPYPACKET(s, d) LZ4_COPYSTEP(s, d); LZ4_COPYSTEP(s, d);
#define LZ4_SECURECOPY LZ4_WILDCOPY
#define HTYPE const BYTE*
#define INITBASE(base) const int base = 0
#endif
#define LZ4_READ_LITTLEENDIAN_16(d, s, p) { d = (s) - grub_le_to_cpu16 (A16 (p)); }
#define LZ4_WRITE_LITTLEENDIAN_16(p, v) { A16(p) = grub_cpu_to_le16 (v); p += 2; }
/* Macros */
#define LZ4_WILDCOPY(s, d, e) do { LZ4_COPYPACKET(s, d) } while (d < e);
/* Decompression functions */
grub_err_t
lz4_decompress(void *s_start, void *d_start, grub_size_t s_len, grub_size_t d_len);
grub_err_t
lz4_decompress(void *s_start, void *d_start, grub_size_t s_len, grub_size_t d_len)
{
const BYTE *src = s_start;
U32 bufsiz = (src[0] << 24) | (src[1] << 16) | (src[2] << 8) |
src[3];
/* invalid compressed buffer size encoded at start */
if (bufsiz + 4 > s_len)
return grub_error(GRUB_ERR_BAD_FS,"lz4 decompression failed.");
/*
* Returns 0 on success (decompression function returned non-negative)
* and appropriate error on failure (decompression function returned negative).
*/
return (LZ4_uncompress_unknownOutputSize((char*)s_start + 4, d_start, bufsiz,
d_len) < 0)?grub_error(GRUB_ERR_BAD_FS,"lz4 decompression failed."):0;
}
int
LZ4_uncompress_unknownOutputSize(const char *source,
char *dest, int isize, int maxOutputSize)
{
/* Local Variables */
const BYTE * ip = (const BYTE *) source;
const BYTE *const iend = ip + isize;
const BYTE * ref;
BYTE * op = (BYTE *) dest;
BYTE *const oend = op + maxOutputSize;
BYTE *cpy;
grub_size_t dec[] = { 0, 3, 2, 3, 0, 0, 0, 0 };
/* Main Loop */
while (ip < iend) {
BYTE token;
int length;
/* get runlength */
token = *ip++;
if ((length = (token >> ML_BITS)) == RUN_MASK) {
int s = 255;
while ((ip < iend) && (s == 255)) {
s = *ip++;
length += s;
}
}
/* copy literals */
if ((grub_addr_t) length > ~(grub_addr_t)op)
goto _output_error;
cpy = op + length;
if ((cpy > oend - COPYLENGTH) ||
(ip + length > iend - COPYLENGTH)) {
if (cpy > oend)
/*
* Error: request to write beyond destination
* buffer.
*/
goto _output_error;
if (ip + length > iend)
/*
* Error : request to read beyond source
* buffer.
*/
goto _output_error;
grub_memcpy(op, ip, length);
op += length;
ip += length;
if (ip < iend)
/* Error : LZ4 format violation */
goto _output_error;
/* Necessarily EOF, due to parsing restrictions. */
break;
}
LZ4_WILDCOPY(ip, op, cpy);
ip -= (op - cpy);
op = cpy;
/* get offset */
LZ4_READ_LITTLEENDIAN_16(ref, cpy, ip);
ip += 2;
if (ref < (BYTE * const) dest)
/*
* Error: offset creates reference outside of
* destination buffer.
*/
goto _output_error;
/* get matchlength */
if ((length = (token & ML_MASK)) == ML_MASK) {
while (ip < iend) {
int s = *ip++;
length += s;
if (s == 255)
continue;
break;
}
}
/* copy repeated sequence */
if unlikely(op - ref < STEPSIZE) {
#if LZ4_ARCH64
grub_size_t dec2table[] = { 0, 0, 0, -1, 0, 1, 2, 3 };
grub_size_t dec2 = dec2table[op - ref];
#else
const int dec2 = 0;
#endif
*op++ = *ref++;
*op++ = *ref++;
*op++ = *ref++;
*op++ = *ref++;
ref -= dec[op - ref];
A32(op) = A32(ref);
op += STEPSIZE - 4;
ref -= dec2;
} else {
LZ4_COPYSTEP(ref, op);
}
cpy = op + length - (STEPSIZE - 4);
if (cpy > oend - COPYLENGTH) {
if (cpy > oend)
/*
* Error: request to write outside of
* destination buffer.
*/
goto _output_error;
LZ4_SECURECOPY(ref, op, (oend - COPYLENGTH));
while (op < cpy)
*op++ = *ref++;
op = cpy;
if (op == oend)
/*
* Check EOF (should never happen, since last
* 5 bytes are supposed to be literals).
*/
break;
continue;
}
LZ4_SECURECOPY(ref, op, cpy);
op = cpy; /* correction */
}
/* end of decoding */
return (int)(((char *)op) - dest);
/* write overflow error detected */
_output_error:
return (int)(-(((char *)ip) - source));
}

View File

@ -119,6 +119,8 @@ grub_gfxmenu_try (int entry, grub_menu_t menu, int nested)
view->menu = menu;
view->nested = nested;
view->first_timeout = -1;
if (menu->size)
view->menu_title_offset = grub_zalloc (sizeof (*view->menu_title_offset) * menu->size);
grub_video_set_viewport (0, 0, mode_info.width, mode_info.height);
if (view->double_repaint)
@ -134,6 +136,8 @@ grub_gfxmenu_try (int entry, grub_menu_t menu, int nested)
instance->fini = grub_gfxmenu_viewer_fini;
instance->print_timeout = grub_gfxmenu_print_timeout;
instance->clear_timeout = grub_gfxmenu_clear_timeout;
if (view->menu_title_offset)
instance->scroll_chosen_entry = grub_gfxmenu_scroll_chosen_entry;
grub_menu_register_viewer (instance);

View File

@ -28,7 +28,10 @@
extern int g_ventoy_memdisk_mode;
extern int g_ventoy_iso_raw;
extern int g_ventoy_grub2_mode;
extern int g_ventoy_wimboot_mode;
extern int g_ventoy_iso_uefi_drv;
extern char g_ventoy_hotkey_tip[256];
static const char *align_options[] =
{
@ -57,11 +60,15 @@ struct grub_gui_label
grub_font_t font;
grub_video_rgba_color_t color;
int value;
int vtoytip;
enum align_mode align;
};
typedef struct grub_gui_label *grub_gui_label_t;
extern const char * g_ventoy_tip_msg1;
extern const char * g_ventoy_tip_msg2;
static void
label_destroy (void *vself)
{
@ -88,6 +95,7 @@ label_is_instance (void *vself __attribute__((unused)), const char *type)
static void
label_paint (void *vself, const grub_video_rect_t *region)
{
const char *text;
grub_gui_label_t self = vself;
if (! self->visible)
@ -96,16 +104,24 @@ label_paint (void *vself, const grub_video_rect_t *region)
if (!grub_video_have_common_points (region, &self->bounds))
return;
if (self->vtoytip == 1) {
text = g_ventoy_tip_msg1 ? g_ventoy_tip_msg1 : "";
} else if (self->vtoytip == 2) {
text = g_ventoy_tip_msg2 ? g_ventoy_tip_msg2 : "";
} else {
text = self->text;
}
/* Calculate the starting x coordinate. */
int left_x;
if (self->align == align_left)
left_x = 0;
else if (self->align == align_center)
left_x = (self->bounds.width
- grub_font_get_string_width (self->font, self->text)) / 2;
- grub_font_get_string_width (self->font, text)) / 2;
else if (self->align == align_right)
left_x = (self->bounds.width
- grub_font_get_string_width (self->font, self->text));
- grub_font_get_string_width (self->font, text));
else
return; /* Invalid alignment. */
@ -114,7 +130,7 @@ label_paint (void *vself, const grub_video_rect_t *region)
grub_video_rect_t vpsave;
grub_gui_set_viewport (&self->bounds, &vpsave);
grub_font_draw_string (self->text,
grub_font_draw_string (text,
self->font,
grub_video_map_rgba_color (self->color),
left_x,
@ -154,8 +170,8 @@ static void
label_get_minimal_size (void *vself, unsigned *width, unsigned *height)
{
grub_gui_label_t self = vself;
*width = grub_font_get_string_width (self->font, self->text);
*height = (grub_font_get_ascent (self->font)
*width = grub_font_get_string_width (self->font, self->text);
*height = (grub_font_get_ascent (self->font)
+ grub_font_get_descent (self->font));
}
@ -205,14 +221,21 @@ label_set_property (void *vself, const char *name, const char *value)
else if (grub_strcmp (value, "@VTOY_ISO_RAW@") == 0) {
value = g_ventoy_iso_raw ? grub_env_get("VTOY_ISO_RAW_STR") : " ";
}
else if (grub_strcmp (value, "@VTOY_GRUB2_MODE@") == 0) {
value = g_ventoy_grub2_mode ? grub_env_get("VTOY_GRUB2_MODE_STR") : " ";
}
else if (grub_strcmp (value, "@VTOY_WIMBOOT_MODE@") == 0) {
value = g_ventoy_wimboot_mode ? grub_env_get("VTOY_WIMBOOT_MODE_STR") : " ";
}
else if (grub_strcmp (value, "@VTOY_ISO_UEFI_DRV@") == 0) {
value = g_ventoy_iso_uefi_drv ? grub_env_get("VTOY_ISO_UEFI_DRV_STR") : " ";
}
else if (grub_strcmp (value, "@VTOY_HOTKEY_TIP@") == 0) {
value = grub_env_get("VTOY_HOTKEY_TIP");
if (value == NULL) {
value = _(" ");
}
value = g_ventoy_hotkey_tip;
} else if (value[0] == '@' && value[1] == '@' && value[2]) {
value = grub_env_get(value + 2);
if (!value)
value = " ";
}
self->template = grub_strdup (value);
@ -247,8 +270,14 @@ label_set_property (void *vself, const char *name, const char *value)
{
grub_gfxmenu_timeout_unregister ((grub_gui_component_t) self);
grub_free (self->id);
if (value)
if (value) {
self->id = grub_strdup (value);
if (grub_strcmp(value, "VTOY_MENU_TIP_1") == 0) {
self->vtoytip = 1;
} else if (grub_strcmp(value, "VTOY_MENU_TIP_2") == 0) {
self->vtoytip = 2;
}
}
else
self->id = 0;
if (self->id && grub_strcmp (self->id, GRUB_GFXMENU_TIMEOUT_COMPONENT_ID)

View File

@ -0,0 +1,961 @@
/* gui_list.c - GUI component to display a selectable list of items. */
/*
* GRUB -- GRand Unified Bootloader
* Copyright (C) 2008,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/misc.h>
#include <grub/gui.h>
#include <grub/gui_string_util.h>
#include <grub/gfxmenu_view.h>
#include <grub/gfxwidgets.h>
#include <grub/color.h>
#include <grub/charset.h>
enum scrollbar_slice_mode {
SCROLLBAR_SLICE_WEST,
SCROLLBAR_SLICE_CENTER,
SCROLLBAR_SLICE_EAST
};
struct grub_gui_list_impl
{
struct grub_gui_list list;
grub_gui_container_t parent;
grub_video_rect_t bounds;
char *id;
int visible;
int icon_width;
int icon_height;
int item_height;
int item_padding;
int item_icon_space;
int item_spacing;
grub_font_t item_font;
int selected_item_font_inherit;
grub_font_t selected_item_font;
grub_video_rgba_color_t item_color;
int selected_item_color_inherit;
grub_video_rgba_color_t selected_item_color;
int draw_scrollbar;
int need_to_recreate_scrollbar;
char *scrollbar_frame_pattern;
char *scrollbar_thumb_pattern;
grub_gfxmenu_box_t scrollbar_frame;
grub_gfxmenu_box_t scrollbar_thumb;
int scrollbar_thumb_overlay;
int scrollbar_width;
enum scrollbar_slice_mode scrollbar_slice;
int scrollbar_left_pad;
int scrollbar_right_pad;
int scrollbar_top_pad;
int scrollbar_bottom_pad;
int first_shown_index;
int need_to_recreate_boxes;
char *theme_dir;
char *menu_box_pattern;
char *item_box_pattern;
int selected_item_box_pattern_inherit;
char *selected_item_box_pattern;
grub_gfxmenu_box_t menu_box;
grub_gfxmenu_box_t selected_item_box;
grub_gfxmenu_box_t item_box;
grub_gfxmenu_icon_manager_t icon_manager;
grub_gfxmenu_view_t view;
};
typedef struct grub_gui_list_impl *list_impl_t;
static void
list_destroy (void *vself)
{
list_impl_t self = vself;
grub_free (self->theme_dir);
grub_free (self->menu_box_pattern);
grub_free (self->item_box_pattern);
grub_free (self->selected_item_box_pattern);
if (self->menu_box)
self->menu_box->destroy (self->menu_box);
if (self->item_box)
self->item_box->destroy (self->item_box);
if (self->selected_item_box)
self->selected_item_box->destroy (self->selected_item_box);
if (self->icon_manager)
grub_gfxmenu_icon_manager_destroy (self->icon_manager);
if (self->scrollbar_thumb)
self->scrollbar_thumb->destroy (self->scrollbar_thumb);
if (self->scrollbar_frame)
self->scrollbar_frame->destroy (self->scrollbar_frame);
grub_free (self->scrollbar_thumb_pattern);
grub_free (self->scrollbar_frame_pattern);
grub_free (self);
}
static int
get_num_shown_items (list_impl_t self)
{
int boxpad = self->item_padding;
int item_vspace = self->item_spacing;
int item_height = self->item_height;
grub_gfxmenu_box_t box = self->menu_box;
int box_top_pad = box->get_top_pad (box);
int box_bottom_pad = box->get_bottom_pad (box);
grub_gfxmenu_box_t itembox = self->item_box;
grub_gfxmenu_box_t selbox = self->selected_item_box;
int item_top_pad = itembox->get_top_pad (itembox);
int item_bottom_pad = itembox->get_bottom_pad (itembox);
int sel_top_pad = selbox->get_top_pad (selbox);
int sel_bottom_pad = selbox->get_bottom_pad (selbox);
int max_top_pad = grub_max (item_top_pad, sel_top_pad);
int max_bottom_pad = grub_max (item_bottom_pad, sel_bottom_pad);
if (item_height + item_vspace <= 0)
return 1;
return (self->bounds.height + item_vspace - 2 * boxpad
- max_top_pad - max_bottom_pad
- box_top_pad - box_bottom_pad) / (item_height + item_vspace);
}
static int
check_boxes (list_impl_t self)
{
if (self->need_to_recreate_boxes)
{
grub_gui_recreate_box (&self->menu_box,
self->menu_box_pattern,
self->theme_dir);
grub_gui_recreate_box (&self->item_box,
self->item_box_pattern,
self->theme_dir);
grub_gui_recreate_box (&self->selected_item_box,
self->selected_item_box_pattern,
self->theme_dir);
self->need_to_recreate_boxes = 0;
}
return (self->menu_box != 0 && self->selected_item_box != 0
&& self->item_box != 0);
}
static int
check_scrollbar (list_impl_t self)
{
if (self->need_to_recreate_scrollbar)
{
grub_gui_recreate_box (&self->scrollbar_frame,
self->scrollbar_frame_pattern,
self->theme_dir);
grub_gui_recreate_box (&self->scrollbar_thumb,
self->scrollbar_thumb_pattern,
self->theme_dir);
self->need_to_recreate_scrollbar = 0;
}
if (self->scrollbar_frame == 0 || self->scrollbar_thumb == 0)
return 0;
/* Sanity checks. */
grub_gfxmenu_box_t frame = self->scrollbar_frame;
grub_gfxmenu_box_t thumb = self->scrollbar_thumb;
grub_gfxmenu_box_t menu = self->menu_box;
int min_width = frame->get_left_pad (frame)
+ frame->get_right_pad (frame);
int min_height = frame->get_top_pad (frame)
+ frame->get_bottom_pad (frame)
+ self->scrollbar_top_pad + self->scrollbar_bottom_pad
+ menu->get_top_pad (menu)
+ menu->get_bottom_pad (menu);
if (!self->scrollbar_thumb_overlay)
{
min_width += thumb->get_left_pad (thumb)
+ thumb->get_right_pad (thumb);
min_height += thumb->get_top_pad (thumb)
+ thumb->get_bottom_pad (thumb);
}
if (min_width <= self->scrollbar_width
&& min_height <= (int) self->bounds.height)
return 1;
/* Unprintable dimenstions. */
self->draw_scrollbar = 0;
return 0;
}
static const char *
list_get_id (void *vself)
{
list_impl_t self = vself;
return self->id;
}
static int
list_is_instance (void *vself __attribute__((unused)), const char *type)
{
return (grub_strcmp (type, "component") == 0
|| grub_strcmp (type, "list") == 0);
}
static struct grub_video_bitmap *
get_item_icon (list_impl_t self, int item_index)
{
grub_menu_entry_t entry;
entry = grub_menu_get_entry (self->view->menu, item_index);
if (! entry)
return 0;
return grub_gfxmenu_icon_manager_get_icon (self->icon_manager, entry);
}
static void
make_selected_item_visible (list_impl_t self)
{
int selected_index = self->view->selected;
if (selected_index < 0)
return; /* No item is selected. */
int num_shown_items = get_num_shown_items (self);
int last_shown_index = self->first_shown_index + (num_shown_items - 1);
if (selected_index < self->first_shown_index)
self->first_shown_index = selected_index;
else if (selected_index > last_shown_index)
self->first_shown_index = selected_index - (num_shown_items - 1);
}
/* Draw a scrollbar on the menu. */
static void
draw_scrollbar (list_impl_t self,
int value, int extent, int min, int max,
int scrollbar_width, int scrollbar_height)
{
unsigned thumby, thumbheight;
grub_gfxmenu_box_t frame = self->scrollbar_frame;
grub_gfxmenu_box_t thumb = self->scrollbar_thumb;
int frame_vertical_pad = (frame->get_top_pad (frame)
+ frame->get_bottom_pad (frame));
int frame_horizontal_pad = (frame->get_left_pad (frame)
+ frame->get_right_pad (frame));
unsigned thumb_vertical_pad = (thumb->get_top_pad (thumb)
+ thumb->get_bottom_pad (thumb));
int thumb_horizontal_pad = (thumb->get_left_pad (thumb)
+ thumb->get_right_pad (thumb));
int tracktop = frame->get_top_pad (frame);
unsigned tracklen;
if (scrollbar_height <= frame_vertical_pad)
tracklen = 0;
else
tracklen = scrollbar_height - frame_vertical_pad;
frame->set_content_size (frame,
scrollbar_width - frame_horizontal_pad,
tracklen);
if (self->scrollbar_thumb_overlay)
{
tracklen += thumb_vertical_pad;
tracktop -= thumb->get_top_pad (thumb);
}
if (value <= min || max <= min)
thumby = 0;
else
thumby = ((unsigned) tracklen * (value - min))
/ ((unsigned) (max - min));
if (max <= min)
thumbheight = 1;
else
thumbheight = ((unsigned) (tracklen * extent)
/ ((unsigned) (max - min))) + 1;
/* Rare occasion: too many entries or too low height. */
if (thumbheight < thumb_vertical_pad)
{
thumbheight = thumb_vertical_pad;
if (value <= min || max <= extent
|| tracklen <= thumb_vertical_pad)
thumby = 0;
else
thumby = ((unsigned) ((tracklen - thumb_vertical_pad) * (value - min))
/ ((unsigned)(max - extent)));
}
thumby += tracktop;
int thumbx = frame->get_left_pad (frame);
int thumbwidth = scrollbar_width - frame_horizontal_pad;
if (!self->scrollbar_thumb_overlay)
thumbwidth -= thumb_horizontal_pad;
else
thumbx -= thumb->get_left_pad (thumb);
thumb->set_content_size (thumb, thumbwidth,
thumbheight - thumb_vertical_pad);
frame->draw (frame, 0, 0);
thumb->draw (thumb, thumbx, thumby);
}
/* Draw the list of items. */
static void
draw_menu (list_impl_t self, int num_shown_items)
{
if (! self->menu_box || ! self->selected_item_box || ! self->item_box)
return;
int boxpad = self->item_padding;
int icon_text_space = self->item_icon_space;
int item_vspace = self->item_spacing;
int ascent = grub_font_get_ascent (self->item_font);
int descent = grub_font_get_descent (self->item_font);
int selected_ascent = grub_font_get_ascent (self->selected_item_font);
int selected_descent = grub_font_get_descent (self->selected_item_font);
int text_box_height = self->item_height;
make_selected_item_visible (self);
grub_gfxmenu_box_t itembox = self->item_box;
grub_gfxmenu_box_t selbox = self->selected_item_box;
int item_leftpad = itembox->get_left_pad (itembox);
int item_rightpad = itembox->get_right_pad (itembox);
int item_border_width = item_leftpad + item_rightpad;
int item_toppad = itembox->get_top_pad (itembox);
int sel_leftpad = selbox->get_left_pad (selbox);
int sel_rightpad = selbox->get_right_pad (selbox);
int sel_border_width = sel_leftpad + sel_rightpad;
int sel_toppad = selbox->get_top_pad (selbox);
int max_leftpad = grub_max (item_leftpad, sel_leftpad);
int max_toppad = grub_max (item_toppad, sel_toppad);
int item_top = 0;
int menu_index;
int visible_index;
struct grub_video_rect oviewport;
grub_video_get_viewport (&oviewport.x, &oviewport.y,
&oviewport.width, &oviewport.height);
grub_video_set_viewport (oviewport.x + boxpad,
oviewport.y + boxpad,
oviewport.width - 2 * boxpad,
oviewport.height - 2 * boxpad);
int cwidth = oviewport.width - 2 * boxpad;
itembox->set_content_size (itembox, cwidth - item_border_width,
text_box_height);
selbox->set_content_size (selbox, cwidth - sel_border_width,
text_box_height);
int text_left_offset = self->icon_width + icon_text_space;
int item_text_top_offset = (text_box_height - (ascent + descent)) / 2 + ascent;
int sel_text_top_offset = (text_box_height - (selected_ascent
+ selected_descent)) / 2
+ selected_ascent;
grub_video_rect_t svpsave, sviewport;
sviewport.x = max_leftpad + text_left_offset;
int text_viewport_width = cwidth - sviewport.x;
sviewport.height = text_box_height;
grub_video_color_t item_color;
grub_video_color_t sel_color;
item_color = grub_video_map_rgba_color (self->item_color);
sel_color = grub_video_map_rgba_color (self->selected_item_color);
int item_box_top_offset = max_toppad - item_toppad;
int sel_box_top_offset = max_toppad - sel_toppad;
int item_viewport_width = text_viewport_width - item_rightpad;
int sel_viewport_width = text_viewport_width - sel_rightpad;
int tmp_icon_top_offset = (text_box_height - self->icon_height) / 2;
int item_icon_top_offset = item_toppad + tmp_icon_top_offset;
int sel_icon_top_offset = sel_toppad + tmp_icon_top_offset;
for (visible_index = 0, menu_index = self->first_shown_index;
visible_index < num_shown_items && menu_index < self->view->menu->size;
visible_index++, menu_index++)
{
int is_selected = (menu_index == self->view->selected);
struct grub_video_bitmap *icon;
grub_font_t font;
grub_video_color_t color;
int text_top_offset;
int top_pad;
int icon_top_offset;
int viewport_width;
if (is_selected)
{
selbox->draw (selbox, 0, item_top + sel_box_top_offset);
font = self->selected_item_font;
color = sel_color;
text_top_offset = sel_text_top_offset;
top_pad = sel_toppad;
icon_top_offset = sel_icon_top_offset;
viewport_width = sel_viewport_width;
}
else
{
itembox->draw (itembox, 0, item_top + item_box_top_offset);
font = self->item_font;
color = item_color;
text_top_offset = item_text_top_offset;
top_pad = item_toppad;
icon_top_offset = item_icon_top_offset;
viewport_width = item_viewport_width;
}
icon = get_item_icon (self, menu_index);
if (icon != 0)
grub_video_blit_bitmap (icon, GRUB_VIDEO_BLIT_BLEND,
max_leftpad,
item_top + icon_top_offset,
0, 0, self->icon_width, self->icon_height);
const char *item_title =
grub_menu_get_entry (self->view->menu, menu_index)->title;
int off = self->view->menu_title_offset[menu_index];
const char *scrolled_title =
grub_utf8_offset_code (item_title, grub_strlen (item_title), off);
if (scrolled_title)
item_title = scrolled_title;
sviewport.y = item_top + top_pad;
sviewport.width = viewport_width;
grub_gui_set_viewport (&sviewport, &svpsave);
grub_font_draw_string (item_title,
font,
color,
0,
text_top_offset);
grub_gui_restore_viewport (&svpsave);
item_top += text_box_height + item_vspace;
}
grub_video_set_viewport (oviewport.x,
oviewport.y,
oviewport.width,
oviewport.height);
}
static void
list_paint (void *vself, const grub_video_rect_t *region)
{
list_impl_t self = vself;
grub_video_rect_t vpsave;
if (! self->visible)
return;
if (!grub_video_have_common_points (region, &self->bounds))
return;
check_boxes (self);
if (! self->menu_box || ! self->selected_item_box || ! self->item_box)
return;
grub_gui_set_viewport (&self->bounds, &vpsave);
{
grub_gfxmenu_box_t box = self->menu_box;
int box_left_pad = box->get_left_pad (box);
int box_top_pad = box->get_top_pad (box);
int box_right_pad = box->get_right_pad (box);
int box_bottom_pad = box->get_bottom_pad (box);
grub_video_rect_t vpsave2, content_rect;
int num_shown_items = get_num_shown_items (self);
int drawing_scrollbar = (self->draw_scrollbar
&& (num_shown_items < self->view->menu->size)
&& check_scrollbar (self));
int scrollbar_width = self->scrollbar_width;
content_rect.x = box_left_pad;
content_rect.y = box_top_pad;
content_rect.width = self->bounds.width - box_left_pad - box_right_pad;
content_rect.height = self->bounds.height - box_top_pad - box_bottom_pad;
box->set_content_size (box, content_rect.width, content_rect.height);
box->draw (box, 0, 0);
switch (self->scrollbar_slice)
{
case SCROLLBAR_SLICE_WEST:
content_rect.x += self->scrollbar_right_pad;
content_rect.width -= self->scrollbar_right_pad;
break;
case SCROLLBAR_SLICE_CENTER:
if (drawing_scrollbar)
content_rect.width -= scrollbar_width + self->scrollbar_left_pad
+ self->scrollbar_right_pad;
break;
case SCROLLBAR_SLICE_EAST:
content_rect.width -= self->scrollbar_left_pad;
break;
}
grub_gui_set_viewport (&content_rect, &vpsave2);
draw_menu (self, num_shown_items);
grub_gui_restore_viewport (&vpsave2);
if (drawing_scrollbar)
{
content_rect.y += self->scrollbar_top_pad;
content_rect.height -= self->scrollbar_top_pad
+ self->scrollbar_bottom_pad;
content_rect.width = scrollbar_width;
switch (self->scrollbar_slice)
{
case SCROLLBAR_SLICE_WEST:
if (box_left_pad > scrollbar_width)
{
content_rect.x = box_left_pad - scrollbar_width;
content_rect.width = scrollbar_width;
}
else
{
content_rect.x = 0;
content_rect.width = box_left_pad;
}
break;
case SCROLLBAR_SLICE_CENTER:
content_rect.x = self->bounds.width - box_right_pad
- scrollbar_width - self->scrollbar_right_pad;
content_rect.width = scrollbar_width;
break;
case SCROLLBAR_SLICE_EAST:
content_rect.x = self->bounds.width - box_right_pad;
content_rect.width = box_right_pad;
break;
}
grub_gui_set_viewport (&content_rect, &vpsave2);
draw_scrollbar (self,
self->first_shown_index, num_shown_items,
0, self->view->menu->size,
scrollbar_width,
content_rect.height);
grub_gui_restore_viewport (&vpsave2);
}
}
grub_gui_restore_viewport (&vpsave);
}
static void
list_set_parent (void *vself, grub_gui_container_t parent)
{
list_impl_t self = vself;
self->parent = parent;
}
static grub_gui_container_t
list_get_parent (void *vself)
{
list_impl_t self = vself;
return self->parent;
}
static void
list_set_bounds (void *vself, const grub_video_rect_t *bounds)
{
list_impl_t self = vself;
self->bounds = *bounds;
}
static void
list_get_bounds (void *vself, grub_video_rect_t *bounds)
{
list_impl_t self = vself;
*bounds = self->bounds;
}
static void
list_get_minimal_size (void *vself, unsigned *width, unsigned *height)
{
list_impl_t self = vself;
if (check_boxes (self))
{
int boxpad = self->item_padding;
int item_vspace = self->item_spacing;
int item_height = self->item_height;
int num_items = 3;
grub_gfxmenu_box_t box = self->menu_box;
int box_left_pad = box->get_left_pad (box);
int box_top_pad = box->get_top_pad (box);
int box_right_pad = box->get_right_pad (box);
int box_bottom_pad = box->get_bottom_pad (box);
unsigned width_s;
grub_gfxmenu_box_t selbox = self->selected_item_box;
int sel_top_pad = selbox->get_top_pad (selbox);
int sel_bottom_pad = selbox->get_bottom_pad (selbox);
int sel_left_pad = selbox->get_left_pad (selbox);
int sel_right_pad = selbox->get_right_pad (selbox);
grub_gfxmenu_box_t itembox = self->item_box;
int item_top_pad = itembox->get_top_pad (itembox);
int item_bottom_pad = itembox->get_bottom_pad (itembox);
int item_left_pad = itembox->get_left_pad (itembox);
int item_right_pad = itembox->get_right_pad (itembox);
int max_left_pad = grub_max (item_left_pad, sel_left_pad);
int max_right_pad = grub_max (item_right_pad, sel_right_pad);
int max_top_pad = grub_max (item_top_pad, sel_top_pad);
int max_bottom_pad = grub_max (item_bottom_pad, sel_bottom_pad);
*width = grub_font_get_string_width (self->item_font, "Typical OS");
width_s = grub_font_get_string_width (self->selected_item_font,
"Typical OS");
if (*width < width_s)
*width = width_s;
*width += 2 * boxpad + box_left_pad + box_right_pad
+ max_left_pad + max_right_pad
+ self->item_icon_space + self->icon_width;
switch (self->scrollbar_slice)
{
case SCROLLBAR_SLICE_WEST:
*width += self->scrollbar_right_pad;
break;
case SCROLLBAR_SLICE_CENTER:
*width += self->scrollbar_width + self->scrollbar_left_pad
+ self->scrollbar_right_pad;
break;
case SCROLLBAR_SLICE_EAST:
*width += self->scrollbar_left_pad;
break;
}
/* Set the menu box height to fit the items. */
*height = (item_height * num_items
+ item_vspace * (num_items - 1)
+ 2 * boxpad
+ box_top_pad + box_bottom_pad
+ max_top_pad + max_bottom_pad);
}
else
{
*width = 0;
*height = 0;
}
}
static grub_err_t
list_set_property (void *vself, const char *name, const char *value)
{
list_impl_t self = vself;
if (grub_strcmp (name, "item_font") == 0)
{
self->item_font = grub_font_get (value);
if (self->selected_item_font_inherit)
self->selected_item_font = self->item_font;
}
else if (grub_strcmp (name, "selected_item_font") == 0)
{
if (! value || grub_strcmp (value, "inherit") == 0)
{
self->selected_item_font = self->item_font;
self->selected_item_font_inherit = 1;
}
else
{
self->selected_item_font = grub_font_get (value);
self->selected_item_font_inherit = 0;
}
}
else if (grub_strcmp (name, "item_color") == 0)
{
grub_video_rgba_color_t color;
if (grub_video_parse_color (value, &color) == GRUB_ERR_NONE)
{
self->item_color = color;
if (self->selected_item_color_inherit)
self->selected_item_color = self->item_color;
}
}
else if (grub_strcmp (name, "selected_item_color") == 0)
{
if (! value || grub_strcmp (value, "inherit") == 0)
{
self->selected_item_color = self->item_color;
self->selected_item_color_inherit = 1;
}
else
{
grub_video_rgba_color_t color;
if (grub_video_parse_color (value, &color)
== GRUB_ERR_NONE)
{
self->selected_item_color = color;
self->selected_item_color_inherit = 0;
}
}
}
else if (grub_strcmp (name, "icon_width") == 0)
{
self->icon_width = grub_strtol (value, 0, 10);
grub_gfxmenu_icon_manager_set_icon_size (self->icon_manager,
self->icon_width,
self->icon_height);
}
else if (grub_strcmp (name, "icon_height") == 0)
{
self->icon_height = grub_strtol (value, 0, 10);
grub_gfxmenu_icon_manager_set_icon_size (self->icon_manager,
self->icon_width,
self->icon_height);
}
else if (grub_strcmp (name, "item_height") == 0)
{
self->item_height = grub_strtol (value, 0, 10);
}
else if (grub_strcmp (name, "item_padding") == 0)
{
self->item_padding = grub_strtol (value, 0, 10);
}
else if (grub_strcmp (name, "item_icon_space") == 0)
{
self->item_icon_space = grub_strtol (value, 0, 10);
}
else if (grub_strcmp (name, "item_spacing") == 0)
{
self->item_spacing = grub_strtol (value, 0, 10);
}
else if (grub_strcmp (name, "visible") == 0)
{
self->visible = grub_strcmp (value, "false") != 0;
}
else if (grub_strcmp (name, "menu_pixmap_style") == 0)
{
self->need_to_recreate_boxes = 1;
grub_free (self->menu_box_pattern);
self->menu_box_pattern = value ? grub_strdup (value) : 0;
}
else if (grub_strcmp (name, "item_pixmap_style") == 0)
{
self->need_to_recreate_boxes = 1;
grub_free (self->item_box_pattern);
self->item_box_pattern = value ? grub_strdup (value) : 0;
if (self->selected_item_box_pattern_inherit)
{
grub_free (self->selected_item_box_pattern);
self->selected_item_box_pattern = value ? grub_strdup (value) : 0;
}
}
else if (grub_strcmp (name, "selected_item_pixmap_style") == 0)
{
if (!value || grub_strcmp (value, "inherit") == 0)
{
grub_free (self->selected_item_box_pattern);
char *tmp = self->item_box_pattern;
self->selected_item_box_pattern = tmp ? grub_strdup (tmp) : 0;
self->selected_item_box_pattern_inherit = 1;
}
else
{
self->need_to_recreate_boxes = 1;
grub_free (self->selected_item_box_pattern);
self->selected_item_box_pattern = value ? grub_strdup (value) : 0;
self->selected_item_box_pattern_inherit = 0;
}
}
else if (grub_strcmp (name, "scrollbar_frame") == 0)
{
self->need_to_recreate_scrollbar = 1;
grub_free (self->scrollbar_frame_pattern);
self->scrollbar_frame_pattern = value ? grub_strdup (value) : 0;
}
else if (grub_strcmp (name, "scrollbar_thumb") == 0)
{
self->need_to_recreate_scrollbar = 1;
grub_free (self->scrollbar_thumb_pattern);
self->scrollbar_thumb_pattern = value ? grub_strdup (value) : 0;
}
else if (grub_strcmp (name, "scrollbar_thumb_overlay") == 0)
{
self->scrollbar_thumb_overlay = grub_strcmp (value, "true") == 0;
}
else if (grub_strcmp (name, "scrollbar_width") == 0)
{
self->scrollbar_width = grub_strtol (value, 0, 10);
}
else if (grub_strcmp (name, "scrollbar_slice") == 0)
{
if (grub_strcmp (value, "west") == 0)
self->scrollbar_slice = SCROLLBAR_SLICE_WEST;
else if (grub_strcmp (value, "center") == 0)
self->scrollbar_slice = SCROLLBAR_SLICE_CENTER;
else if (grub_strcmp (value, "east") == 0)
self->scrollbar_slice = SCROLLBAR_SLICE_EAST;
}
else if (grub_strcmp (name, "scrollbar_left_pad") == 0)
{
self->scrollbar_left_pad = grub_strtol (value, 0, 10);
}
else if (grub_strcmp (name, "scrollbar_right_pad") == 0)
{
self->scrollbar_right_pad = grub_strtol (value, 0, 10);
}
else if (grub_strcmp (name, "scrollbar_top_pad") == 0)
{
self->scrollbar_top_pad = grub_strtol (value, 0, 10);
}
else if (grub_strcmp (name, "scrollbar_bottom_pad") == 0)
{
self->scrollbar_bottom_pad = grub_strtol (value, 0, 10);
}
else if (grub_strcmp (name, "scrollbar") == 0)
{
self->draw_scrollbar = grub_strcmp (value, "false") != 0;
}
else if (grub_strcmp (name, "theme_dir") == 0)
{
self->need_to_recreate_boxes = 1;
grub_free (self->theme_dir);
self->theme_dir = value ? grub_strdup (value) : 0;
}
else if (grub_strcmp (name, "id") == 0)
{
grub_free (self->id);
if (value)
self->id = grub_strdup (value);
else
self->id = 0;
}
return grub_errno;
}
/* Set necessary information that the gfxmenu view provides. */
static void
list_set_view_info (void *vself,
grub_gfxmenu_view_t view)
{
list_impl_t self = vself;
grub_gfxmenu_icon_manager_set_theme_path (self->icon_manager,
view->theme_path);
self->view = view;
}
/* Refresh list variables */
static void
list_refresh_info (void *vself,
grub_gfxmenu_view_t view)
{
list_impl_t self = vself;
if (view->nested)
self->first_shown_index = 0;
}
static struct grub_gui_component_ops list_comp_ops =
{
.destroy = list_destroy,
.get_id = list_get_id,
.is_instance = list_is_instance,
.paint = list_paint,
.set_parent = list_set_parent,
.get_parent = list_get_parent,
.set_bounds = list_set_bounds,
.get_bounds = list_get_bounds,
.get_minimal_size = list_get_minimal_size,
.set_property = list_set_property
};
static struct grub_gui_list_ops list_ops =
{
.set_view_info = list_set_view_info,
.refresh_list = list_refresh_info
};
grub_gui_component_t
grub_gui_list_new (void)
{
list_impl_t self;
grub_font_t default_font;
grub_video_rgba_color_t default_fg_color;
self = grub_zalloc (sizeof (*self));
if (! self)
return 0;
self->list.ops = &list_ops;
self->list.component.ops = &list_comp_ops;
self->visible = 1;
default_font = grub_font_get ("Unknown Regular 16");
default_fg_color = grub_video_rgba_color_rgb (0, 0, 0);
self->icon_width = 32;
self->icon_height = 32;
self->item_height = 42;
self->item_padding = 14;
self->item_icon_space = 4;
self->item_spacing = 16;
self->item_font = default_font;
self->selected_item_font_inherit = 1; /* Default to using the item_font. */
self->selected_item_font = default_font;
self->item_color = default_fg_color;
self->selected_item_color_inherit = 1; /* Default to using the item_color. */
self->selected_item_color = default_fg_color;
self->draw_scrollbar = 1;
self->need_to_recreate_scrollbar = 1;
self->scrollbar_frame = 0;
self->scrollbar_thumb = 0;
self->scrollbar_frame_pattern = 0;
self->scrollbar_thumb_pattern = 0;
self->scrollbar_thumb_overlay = 0;
self->scrollbar_width = 16;
self->scrollbar_slice = SCROLLBAR_SLICE_EAST;
self->scrollbar_left_pad = 2;
self->scrollbar_right_pad = 0;
self->scrollbar_top_pad = 0;
self->scrollbar_bottom_pad = 0;
self->first_shown_index = 0;
self->need_to_recreate_boxes = 0;
self->theme_dir = 0;
self->menu_box_pattern = 0;
self->item_box_pattern = 0;
self->selected_item_box_pattern_inherit = 1;/*Default to using the item_box.*/
self->selected_item_box_pattern = 0;
self->menu_box = grub_gfxmenu_create_box (0, 0);
self->item_box = grub_gfxmenu_create_box (0, 0);
self->selected_item_box = grub_gfxmenu_create_box (0, 0);
self->icon_manager = grub_gfxmenu_icon_manager_new ();
if (! self->icon_manager)
{
self->list.component.ops->destroy (self);
return 0;
}
grub_gfxmenu_icon_manager_set_icon_size (self->icon_manager,
self->icon_width,
self->icon_height);
return (grub_gui_component_t) self;
}

View File

@ -163,6 +163,12 @@ theme_set_string (grub_gfxmenu_view_t view,
grub_video_parse_color (value, &view->message_color);
else if (! grub_strcmp ("message-bg-color", name))
grub_video_parse_color (value, &view->message_bg_color);
else if (! grub_strcmp("menu-tip-left", name))
grub_env_set("VTOY_TIP_LEFT", value);
else if (! grub_strcmp("menu-tip-top", name))
grub_env_set("VTOY_TIP_TOP", value);
else if (! grub_strcmp("menu-tip-color", name))
grub_env_set("VTOY_TIP_COLOR", value);
else if (! grub_strcmp ("desktop-image", name))
{
struct grub_video_bitmap *raw_bitmap;
@ -289,6 +295,8 @@ theme_set_string (grub_gfxmenu_view_t view,
if (! view->title_text)
return grub_errno;
}
else if (! grub_strcmp ("ventoy_left_top_color", name))
return grub_errno;
else
{
return grub_error (GRUB_ERR_BAD_ARGUMENT,
@ -450,7 +458,8 @@ read_expression (struct parsebuf *p)
/* Read as a single word -- for numeric values or words without
whitespace. */
start = p->pos;
while (has_more (p) && ! is_whitespace (peek_char (p)))
while (has_more (p) && ! is_whitespace (peek_char (p))
&& peek_char (p) != '}')
read_char (p);
end = p->pos;
}
@ -725,6 +734,11 @@ read_property (struct parsebuf *p)
"%s:%d:%d property value invalid; "
"enclose literal values in quotes (\")",
p->filename, p->line_num, p->col_num);
grub_printf("File: %s\nLine:%d Column:%d\n"
"property value invalid; enclose literal values in quotes (\")\n\n",
p->filename, p->line_num, p->col_num);
goto done;
}
@ -733,11 +747,14 @@ done:
return grub_errno;
}
extern int g_menu_update_mode;
/* Set properties on the view based on settings from the specified
theme file. */
grub_err_t
grub_gfxmenu_view_load_theme (grub_gfxmenu_view_t view, const char *theme_path)
{
int flag = 0;
grub_file_t file;
struct parsebuf p;
@ -752,7 +769,7 @@ grub_gfxmenu_view_load_theme (grub_gfxmenu_view_t view, const char *theme_path)
}
p.len = grub_file_size (file);
p.buf = grub_malloc (p.len + 4096);
p.buf = grub_malloc (p.len + 8192);
p.pos = 0;
p.line_num = 1;
p.col_num = 1;
@ -781,6 +798,8 @@ grub_gfxmenu_view_load_theme (grub_gfxmenu_view_t view, const char *theme_path)
}
}
if (view->canvas)
view->canvas->component.ops->destroy (view->canvas);
@ -791,6 +810,7 @@ grub_gfxmenu_view_load_theme (grub_gfxmenu_view_t view, const char *theme_path)
->ops->set_bounds ((grub_gui_component_t) view->canvas,
&view->screen);
parse:
while (has_more (&p))
{
/* Skip comments (lines beginning with #). */
@ -819,6 +839,40 @@ grub_gfxmenu_view_load_theme (grub_gfxmenu_view_t view, const char *theme_path)
goto fail;
}
if (flag == 0)
{
const char *tip = grub_env_get("VTOY_MENU_TIP_ENABLE");
if (tip && tip[0] == '1')
{
char tmpmsg[512];
grub_memset(tmpmsg, 'w', 500);
tmpmsg[500] = 0;
g_menu_update_mode = 1;
p.len += grub_snprintf(p.buf + p.len, 4096,
"\n+ vbox{\n left = %s\n top = %s\n"
"+ label { id=\"VTOY_MENU_TIP_1\" text = \"%s\" color = \"%s\" align = \"%s\"}\n"
"+ label { id=\"VTOY_MENU_TIP_2\" text = \"%s\" color = \"%s\" align = \"%s\"}\n"
"}\n",
grub_env_get("VTOY_TIP_LEFT"),
grub_env_get("VTOY_TIP_TOP"),
tmpmsg,
grub_env_get("VTOY_TIP_COLOR"),
grub_env_get("VTOY_TIP_ALIGN"),
tmpmsg,
grub_env_get("VTOY_TIP_COLOR"),
grub_env_get("VTOY_TIP_ALIGN")
);
flag = 1;
goto parse;
}
}
/* Set the new theme path. */
grub_free (view->theme_path);
view->theme_path = grub_strdup (theme_path);

View File

@ -37,6 +37,7 @@
#include <grub/gui_string_util.h>
#include <grub/icon_manager.h>
#include <grub/i18n.h>
#include <grub/charset.h>
static void
init_terminal (grub_gfxmenu_view_t view);
@ -142,6 +143,8 @@ grub_gfxmenu_view_destroy (grub_gfxmenu_view_t view)
grub_free (view->title_text);
grub_free (view->progress_message_text);
grub_free (view->theme_path);
if (view->menu_title_offset)
grub_free (view->menu_title_offset);
if (view->canvas)
view->canvas->component.ops->destroy (view->canvas);
grub_free (view);
@ -386,21 +389,37 @@ redraw_menu_visit (grub_gui_component_t component,
}
}
extern int g_menu_update_mode;
static void grub_gfxmenu_update_all(grub_gfxmenu_view_t view)
{
grub_video_set_area_status(GRUB_VIDEO_AREA_DISABLED);
grub_gfxmenu_view_redraw(view, &view->screen);
}
void
grub_gfxmenu_redraw_menu (grub_gfxmenu_view_t view)
{
update_menu_components (view);
grub_gui_iterate_recursively ((grub_gui_component_t) view->canvas,
redraw_menu_visit, view);
if (g_menu_update_mode)
grub_gfxmenu_update_all(view);
else
grub_gui_iterate_recursively ((grub_gui_component_t) view->canvas,
redraw_menu_visit, view);
grub_video_swap_buffers ();
if (view->double_repaint)
{
grub_gui_iterate_recursively ((grub_gui_component_t) view->canvas,
redraw_menu_visit, view);
if (g_menu_update_mode)
grub_gfxmenu_update_all(view);
else
grub_gui_iterate_recursively ((grub_gui_component_t) view->canvas,
redraw_menu_visit, view);
}
}
void
grub_gfxmenu_set_chosen_entry (int entry, void *data)
{
@ -408,6 +427,34 @@ grub_gfxmenu_set_chosen_entry (int entry, void *data)
view->selected = entry;
grub_gfxmenu_redraw_menu (view);
}
void
grub_gfxmenu_scroll_chosen_entry (void *data, int diren)
{
grub_gfxmenu_view_t view = data;
const char *item_title;
int off;
int max;
if (!view->menu->size)
return;
item_title = grub_menu_get_entry (view->menu, view->selected)->title;
off = view->menu_title_offset[view->selected] + diren;
max = grub_utf8_get_num_code (item_title, grub_strlen(item_title));
if (diren == 1000000)
off = (max >= 20) ? (max - 20) : 0;
else if (off < 0)
off = 0;
else if (off > max)
off = max;
view->menu_title_offset[view->selected] = off;
grub_gfxmenu_redraw_menu (view);
}
static void

View File

@ -471,7 +471,7 @@ grub_err_t
grub_disk_read (grub_disk_t disk, grub_disk_addr_t sector,
grub_off_t offset, grub_size_t size, void *buf)
{
if (disk->read_hook == (grub_disk_read_hook_t)grub_disk_blocklist_read)
if (disk->read_hook == (grub_disk_read_hook_t)(void *)grub_disk_blocklist_read)
{
return grub_disk_blocklist_read((ventoy_img_chunk_list *)disk->read_hook_data, sector, size, disk->log_sector_size);
}

View File

@ -964,3 +964,20 @@ void * grub_efi_allocate_iso_buf(grub_uint64_t size)
return (void *)(unsigned long)address;
}
void * grub_efi_allocate_chain_buf(grub_uint64_t size)
{
grub_efi_boot_services_t *b;
grub_efi_status_t status;
grub_efi_physical_address_t address = 0;
grub_efi_uintn_t pages = GRUB_EFI_BYTES_TO_PAGES(size);
b = grub_efi_system_table->boot_services;
status = efi_call_4 (b->allocate_pages, GRUB_EFI_ALLOCATE_ANY_PAGES, GRUB_EFI_LOADER_DATA, pages, &address);
if (status != GRUB_EFI_SUCCESS)
{
return NULL;
}
return (void *)(unsigned long)address;
}

View File

@ -49,6 +49,12 @@ static grub_efi_uintn_t finish_desc_size;
static grub_efi_uint32_t finish_desc_version;
int grub_efi_is_finished = 0;
/* 160MB 160 * 1024 * 1024 / 4096 */
#define VTOY_CHAIN_MIN_PAGES (160 * 256)
static grub_efi_uint64_t g_total_pages;
static grub_efi_uint64_t g_org_required_pages;
static grub_efi_uint64_t g_new_required_pages;
/*
* We need to roll back EFI allocations on exit. Remember allocations that
* we'll free on exit.
@ -614,6 +620,22 @@ grub_efi_mm_init (void)
else if (required_pages > BYTES_TO_PAGES (MAX_HEAP_SIZE))
required_pages = BYTES_TO_PAGES (MAX_HEAP_SIZE);
g_org_required_pages = required_pages;
if (((total_pages - required_pages) >> 2) < VTOY_CHAIN_MIN_PAGES)
{
if (total_pages > (VTOY_CHAIN_MIN_PAGES << 2))
{
g_new_required_pages = total_pages - (VTOY_CHAIN_MIN_PAGES << 2);
if (g_new_required_pages >= 8192)
{
required_pages = g_new_required_pages;
}
}
}
g_total_pages = total_pages;
g_new_required_pages = required_pages;
/* Sort the filtered descriptors, so that GRUB can allocate pages
from smaller regions. */
sort_memory_map (filtered_memory_map, desc_size, filtered_memory_map_end);
@ -670,3 +692,11 @@ grub_efi_get_ram_base(grub_addr_t *base_addr)
return GRUB_ERR_NONE;
}
#endif
void grub_efi_get_reserved_page_num(grub_uint64_t *total, grub_uint64_t *org_required, grub_uint64_t *new_required)
{
*total = g_total_pages;
*org_required = g_org_required_pages;
*new_required = g_new_required_pages;
}

View File

@ -0,0 +1,250 @@
/* env.c - Environment variables */
/*
* GRUB -- GRand Unified Bootloader
* Copyright (C) 2003,2005,2006,2007,2008,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/env.h>
#include <grub/env_private.h>
#include <grub/misc.h>
#include <grub/mm.h>
/* The initial context. */
static struct grub_env_context initial_context;
/* The current context. */
struct grub_env_context *grub_current_context = &initial_context;
static grub_env_read_hook_t vtoy_menu_lang_read_hook;
/* Return the hash representation of the string S. */
static unsigned int
grub_env_hashval (const char *s)
{
unsigned int i = 0;
/* XXX: This can be done much more efficiently. */
while (*s)
i += 5 * *(s++);
return i % HASHSZ;
}
static struct grub_env_var *
grub_env_find (const char *name)
{
struct grub_env_var *var;
int idx = grub_env_hashval (name);
/* Look for the variable in the current context. */
for (var = grub_current_context->vars[idx]; var; var = var->next)
if (grub_strcmp (var->name, name) == 0)
return var;
return 0;
}
static void
grub_env_insert (struct grub_env_context *context,
struct grub_env_var *var)
{
int idx = grub_env_hashval (var->name);
/* Insert the variable into the hashtable. */
var->prevp = &context->vars[idx];
var->next = context->vars[idx];
if (var->next)
var->next->prevp = &(var->next);
context->vars[idx] = var;
}
static void
grub_env_remove (struct grub_env_var *var)
{
/* Remove the entry from the variable table. */
*var->prevp = var->next;
if (var->next)
var->next->prevp = var->prevp;
}
grub_err_t
grub_env_set (const char *name, const char *val)
{
struct grub_env_var *var;
/* If the variable does already exist, just update the variable. */
var = grub_env_find (name);
if (var)
{
char *old = var->value;
if (var->write_hook)
var->value = var->write_hook (var, val);
else
var->value = grub_strdup (val);
if (! var->value)
{
var->value = old;
return grub_errno;
}
grub_free (old);
return GRUB_ERR_NONE;
}
/* The variable does not exist, so create a new one. */
var = grub_zalloc (sizeof (*var));
if (! var)
return grub_errno;
var->name = grub_strdup (name);
if (! var->name)
goto fail;
var->value = grub_strdup (val);
if (! var->value)
goto fail;
grub_env_insert (grub_current_context, var);
return GRUB_ERR_NONE;
fail:
grub_free (var->name);
grub_free (var->value);
grub_free (var);
return grub_errno;
}
const char *
grub_env_get (const char *name)
{
struct grub_env_var *var;
if (name && vtoy_menu_lang_read_hook && grub_strncmp(name, "VTLANG_", 7) == 0)
return vtoy_menu_lang_read_hook(NULL, name);
var = grub_env_find (name);
if (! var)
return 0;
if (var->read_hook)
return var->read_hook (var, var->value);
return var->value;
}
void
grub_env_unset (const char *name)
{
struct grub_env_var *var;
var = grub_env_find (name);
if (! var)
return;
if (var->read_hook || var->write_hook)
{
grub_env_set (name, "");
return;
}
grub_env_remove (var);
grub_free (var->name);
grub_free (var->value);
grub_free (var);
}
struct grub_env_var *
grub_env_update_get_sorted (void)
{
struct grub_env_var *sorted_list = 0;
int i;
/* Add variables associated with this context into a sorted list. */
for (i = 0; i < HASHSZ; i++)
{
struct grub_env_var *var;
for (var = grub_current_context->vars[i]; var; var = var->next)
{
struct grub_env_var *p, **q;
for (q = &sorted_list, p = *q; p; q = &((*q)->sorted_next), p = *q)
{
if (grub_strcmp (p->name, var->name) > 0)
break;
}
var->sorted_next = *q;
*q = var;
}
}
return sorted_list;
}
grub_err_t
grub_register_variable_hook (const char *name,
grub_env_read_hook_t read_hook,
grub_env_write_hook_t write_hook)
{
struct grub_env_var *var = grub_env_find (name);
if (! var)
{
if (grub_env_set (name, "") != GRUB_ERR_NONE)
return grub_errno;
var = grub_env_find (name);
/* XXX Insert an assertion? */
}
var->read_hook = read_hook;
var->write_hook = write_hook;
return GRUB_ERR_NONE;
}
grub_err_t
grub_register_vtoy_menu_lang_hook(grub_env_read_hook_t read_hook)
{
vtoy_menu_lang_read_hook = read_hook;
return GRUB_ERR_NONE;
}
grub_err_t
grub_env_export (const char *name)
{
struct grub_env_var *var;
var = grub_env_find (name);
if (! var)
{
grub_err_t err;
err = grub_env_set (name, "");
if (err)
return err;
var = grub_env_find (name);
}
var->global = 1;
return GRUB_ERR_NONE;
}

View File

@ -106,19 +106,136 @@ int ventoy_check_file_exist(const char * fmt, ...)
}
}
typedef struct grub_vlnk
{
int srclen;
char src[512];
char dst[512];
struct grub_vlnk *next;
}grub_vlnk;
static grub_vlnk g_vtoy_vlnk;
static grub_vlnk *g_vlnk_list;
int grub_file_is_vlnk_suffix(const char *name, int len)
{
grub_uint32_t suffix;
if (len > 9)
{
suffix = *(grub_uint32_t *)(name + len - 4);
if (grub_strncmp(name + len - 9, ".vlnk.", 6) == 0)
{
/* .iso .wim .img .vhd .efi .dat */
if (suffix == 0x6F73692E || suffix == 0x6D69772E ||
suffix == 0x676D692E || suffix == 0x6468762E ||
suffix == 0x6966652E || suffix == 0x7461642E)
{
return 1;
}
}
else if (len > 10 && grub_strncmp(name + len - 10, ".vlnk.", 6) == 0)
{
/* vhdx vtoy */
if (suffix == 0x78646876 || suffix == 0x796F7476)
{
return 1;
}
}
}
return 0;
}
int grub_file_vtoy_vlnk(const char *src, const char *dst)
{
if (src)
{
g_vtoy_vlnk.srclen = (int)grub_strlen(src);
grub_strncpy(g_vtoy_vlnk.src, src, sizeof(g_vtoy_vlnk.src) - 1);
grub_strncpy(g_vtoy_vlnk.dst, dst, sizeof(g_vtoy_vlnk.dst) - 1);
}
else
{
g_vtoy_vlnk.srclen = 0;
g_vtoy_vlnk.src[0] = 0;
g_vtoy_vlnk.dst[0] = 0;
}
return 0;
}
int grub_file_add_vlnk(const char *src, const char *dst)
{
grub_vlnk *node = NULL;
if (src && dst)
{
node = grub_zalloc(sizeof(grub_vlnk));
if (node)
{
node->srclen = (int)grub_strlen(src);
grub_strncpy(node->src, src, sizeof(node->src) - 1);
grub_strncpy(node->dst, dst, sizeof(node->dst) - 1);
node->next = g_vlnk_list;
g_vlnk_list = node;
return 0;
}
}
return 1;
}
const char *grub_file_get_vlnk(const char *name, int *vlnk)
{
int len;
grub_vlnk *node = g_vlnk_list;
len = grub_strlen(name);
if (!grub_file_is_vlnk_suffix(name, len))
{
return name;
}
if (len == g_vtoy_vlnk.srclen && grub_strcmp(name, g_vtoy_vlnk.src) == 0)
{
if (vlnk)
*vlnk = 1;
return g_vtoy_vlnk.dst;
}
while (node)
{
if (node->srclen == len && grub_strcmp(name, node->src) == 0)
{
if (vlnk)
*vlnk = 1;
return node->dst;
}
node = node->next;
}
return name;
}
grub_file_t
grub_file_open (const char *name, enum grub_file_type type)
{
int vlnk = 0;
grub_device_t device = 0;
grub_file_t file = 0, last_file = 0;
char *device_name;
const char *file_name;
grub_file_filter_id_t filter;
/* <DESC> : mem:xxx:size:xxx format in chainloader */
if (grub_strncmp(name, GRUB_MEMFILE_MEM, grub_strlen(GRUB_MEMFILE_MEM)) == 0) {
/* <DESC> : mem:xxx:size:xxx format in chainloader grub_strlen(GRUB_MEMFILE_MEM) */
if (grub_strncmp(name, GRUB_MEMFILE_MEM, 4) == 0) {
return grub_memfile_open(name);
}
}
if ((g_vlnk_list || g_vtoy_vlnk.srclen) && (type & GRUB_FILE_TYPE_NO_VLNK) == 0)
name = grub_file_get_vlnk(name, &vlnk);
device_name = grub_file_get_device_name (name);
if (grub_errno)
@ -141,6 +258,7 @@ grub_file_open (const char *name, enum grub_file_type type)
goto fail;
file->device = device;
file->vlnk = vlnk;
/* In case of relative pathnames and non-Unix systems (like Windows)
* name of host files may not start with `/'. Blocklists for host files
@ -224,10 +342,12 @@ grub_file_read (grub_file_t file, void *buf, grub_size_t len)
if (len == 0)
return 0;
if (grub_strncmp(file->name, GRUB_MEMFILE_MEM, grub_strlen(GRUB_MEMFILE_MEM)) == 0) {
if (file->name) {
if (grub_strncmp(file->name, GRUB_MEMFILE_MEM, grub_strlen(GRUB_MEMFILE_MEM)) == 0) {
grub_memcpy(buf, (grub_uint8_t *)(file->data) + file->offset, len);
file->offset += len;
return len;
}
}
read_hook = file->read_hook;

View File

@ -42,6 +42,44 @@ probe_dummy_iter (const char *filename __attribute__ ((unused)),
return 1;
}
grub_fs_t grub_fs_list_probe(grub_device_t device, const char **list)
{
int i;
grub_fs_t p;
if (!device->disk)
return 0;
for (p = grub_fs_list; p; p = p->next)
{
for (i = 0; list[i]; i++)
{
if (grub_strcmp(p->name, list[i]) == 0)
break;
}
if (list[i] == NULL)
continue;
grub_dprintf("fs", "Detecting %s...\n", p->name);
(p->fs_dir) (device, "/", probe_dummy_iter, NULL);
if (grub_errno == GRUB_ERR_NONE)
return p;
grub_error_push ();
grub_dprintf ("fs", "%s detection failed.\n", p->name);
grub_error_pop ();
if (grub_errno != GRUB_ERR_BAD_FS && grub_errno != GRUB_ERR_OUT_OF_RANGE) {
return 0;
}
grub_errno = GRUB_ERR_NONE;
}
return 0;
}
grub_fs_t
grub_fs_probe (grub_device_t device)
{

View File

@ -362,7 +362,8 @@ static grub_err_t
cmd_append (const char *line, struct syslinux_menu *menu)
{
if (!menu->entries)
return grub_error (GRUB_ERR_BAD_ARGUMENT, "kernel without label");
return GRUB_ERR_NONE;
//return grub_error (GRUB_ERR_BAD_ARGUMENT, "kernel without label");
menu->entries->append = grub_strdup (line);
if (!menu->entries->append)

View File

@ -279,6 +279,13 @@ static int ventoy_boot_opt_filter(char *opt)
opt[1] = 't';
return 0;
}
if (grub_strncmp(opt, "dm=", 3) == 0)
{
opt[0] = 'D';
opt[1] = 'M';
return 0;
}
if (ventoy_debug)
{

View File

@ -229,10 +229,7 @@ grub_cmd_chainloader (grub_command_t cmd __attribute__ ((unused)),
if (! file)
goto fail;
/* Get the root device's device path. */
dev = grub_device_open (0);
if (! dev)
goto fail;
dev = file->device;
if (dev->disk)
dev_handle = grub_efidisk_get_device_handle (dev->disk);
@ -257,16 +254,13 @@ grub_cmd_chainloader (grub_command_t cmd __attribute__ ((unused)),
if (dev_handle)
dp = grub_efi_get_device_path (dev_handle);
if (! dp)
if (dp != NULL)
{
grub_error (GRUB_ERR_BAD_DEVICE, "not a valid root device");
goto fail;
file_path = make_file_path (dp, filename);
if (! file_path)
goto fail;
}
file_path = make_file_path (dp, filename);
if (! file_path)
goto fail;
//grub_printf ("file path: ");
//grub_efi_print_device_path (file_path);
@ -390,16 +384,12 @@ grub_cmd_chainloader (grub_command_t cmd __attribute__ ((unused)),
}
grub_file_close (file);
grub_device_close (dev);
grub_loader_set (grub_chainloader_boot, grub_chainloader_unload, 0);
return 0;
fail:
if (dev)
grub_device_close (dev);
if (file)
grub_file_close (file);

View File

@ -88,6 +88,8 @@ static int ventoy_linux_argc = 0;
static char **ventoy_linux_args = NULL;
static int ventoy_extra_initrd_num = 0;
static char *ventoy_extra_initrd_list[256];
static grub_command_func_t ventoy_linux16_func = NULL;
static grub_command_func_t ventoy_initrd16_func = NULL;
static grub_err_t
grub_cmd_initrd (grub_command_t cmd __attribute__ ((unused)), int argc, char *argv[]);
@ -506,6 +508,13 @@ static int ventoy_boot_opt_filter(char *opt)
return 0;
}
if (grub_strncmp(opt, "dm=", 3) == 0)
{
opt[0] = 'D';
opt[1] = 'M';
return 0;
}
if (ventoy_debug)
{
if (grub_strcmp(opt, "quiet") == 0)
@ -660,54 +669,6 @@ static int ventoy_bootopt_hook(int argc, char *argv[])
return 0;
}
static grub_err_t
grub_cmd_set_boot_opt (grub_command_t cmd __attribute__ ((unused)),
int argc, char *argv[])
{
int i;
const char *vtdebug;
for (i = 0; i < argc; i++)
{
ventoy_linux_args[ventoy_linux_argc + (LINUX_MAX_ARGC / 2) ] = grub_strdup(argv[i]);
ventoy_linux_argc++;
}
vtdebug = grub_env_get("vtdebug_flag");
if (vtdebug && vtdebug[0])
{
ventoy_debug = 1;
}
if (ventoy_debug) grub_printf("ventoy set boot opt %d\n", ventoy_linux_argc);
return 0;
}
static grub_err_t
grub_cmd_unset_boot_opt (grub_command_t cmd __attribute__ ((unused)),
int argc, char *argv[])
{
int i;
(void)argc;
(void)argv;
for (i = 0; i < LINUX_MAX_ARGC; i++)
{
if (ventoy_linux_args[i])
{
grub_free(ventoy_linux_args[i]);
}
}
ventoy_debug = 0;
ventoy_linux_argc = 0;
ventoy_initrd_called = 0;
grub_memset(ventoy_linux_args, 0, sizeof(char *) * LINUX_MAX_ARGC);
return 0;
}
static grub_err_t
grub_cmd_extra_initrd_append (grub_command_t cmd __attribute__ ((unused)),
int argc, char *argv[])
@ -1569,6 +1530,92 @@ ventoy_cmd_initrd (grub_command_t cmd __attribute__ ((unused)),
return grub_cmd_initrd(cmd, ventoy_extra_initrd_num, ventoy_extra_initrd_list);
}
static grub_err_t
grub_cmd_set_boot_opt (grub_command_t cmd __attribute__ ((unused)),
int argc, char *argv[])
{
int i;
const char *vtdebug;
grub_command_t regcmd;
for (i = 0; i < argc; i++)
{
ventoy_linux_args[ventoy_linux_argc + (LINUX_MAX_ARGC / 2) ] = grub_strdup(argv[i]);
ventoy_linux_argc++;
}
vtdebug = grub_env_get("vtdebug_flag");
if (vtdebug && vtdebug[0])
{
ventoy_debug = 1;
}
if (ventoy_debug) grub_printf("ventoy set boot opt %d\n", ventoy_linux_argc);
ventoy_linux16_func = ventoy_initrd16_func = NULL;
regcmd = grub_command_find("linux16");
if (regcmd)
{
ventoy_linux16_func = regcmd->func;
regcmd->func = grub_cmd_linux;
}
regcmd = grub_command_find("initrd16");
if (regcmd)
{
ventoy_initrd16_func = regcmd->func;
regcmd->func = ventoy_cmd_initrd;
}
return 0;
}
static grub_err_t
grub_cmd_unset_boot_opt (grub_command_t cmd __attribute__ ((unused)),
int argc, char *argv[])
{
int i;
grub_command_t regcmd;
(void)argc;
(void)argv;
for (i = 0; i < LINUX_MAX_ARGC; i++)
{
if (ventoy_linux_args[i])
{
grub_free(ventoy_linux_args[i]);
}
}
ventoy_debug = 0;
ventoy_linux_argc = 0;
ventoy_initrd_called = 0;
grub_memset(ventoy_linux_args, 0, sizeof(char *) * LINUX_MAX_ARGC);
if (ventoy_linux16_func)
{
regcmd = grub_command_find("linux16");
if (regcmd)
{
regcmd->func = ventoy_linux16_func;
}
ventoy_linux16_func = NULL;
}
if (ventoy_initrd16_func)
{
regcmd = grub_command_find("initrd16");
if (regcmd)
{
regcmd->func = ventoy_initrd16_func;
}
ventoy_initrd16_func = NULL;
}
return 0;
}
static grub_command_t cmd_linux, cmd_initrd, cmd_linuxefi, cmd_initrdefi;
static grub_command_t cmd_set_bootopt, cmd_unset_bootopt, cmd_extra_initrd_append, cmd_extra_initrd_reset;

View File

@ -0,0 +1,327 @@
#include <grub/types.h>
#include <grub/err.h>
#include <grub/linux.h>
#include <grub/misc.h>
#include <grub/file.h>
#include <grub/mm.h>
#include <grub/env.h>
#include <grub/term.h>
struct newc_head
{
char magic[6];
char ino[8];
char mode[8];
char uid[8];
char gid[8];
char nlink[8];
char mtime[8];
char filesize[8];
char devmajor[8];
char devminor[8];
char rdevmajor[8];
char rdevminor[8];
char namesize[8];
char check[8];
} GRUB_PACKED;
struct grub_linux_initrd_component
{
grub_file_t file;
char *newc_name;
grub_off_t size;
};
struct dir
{
char *name;
struct dir *next;
struct dir *child;
};
static char
hex (grub_uint8_t val)
{
if (val < 10)
return '0' + val;
return 'a' + val - 10;
}
static void
set_field (char *var, grub_uint32_t val)
{
int i;
char *ptr = var;
for (i = 28; i >= 0; i -= 4)
*ptr++ = hex((val >> i) & 0xf);
}
static grub_uint8_t *
make_header (grub_uint8_t *ptr,
const char *name, grub_size_t len,
grub_uint32_t mode,
grub_off_t fsize)
{
struct newc_head *head = (struct newc_head *) ptr;
grub_uint8_t *optr;
grub_size_t oh = 0;
grub_memcpy (head->magic, "070701", 6);
set_field (head->ino, 0);
set_field (head->mode, mode);
set_field (head->uid, 0);
set_field (head->gid, 0);
set_field (head->nlink, 1);
set_field (head->mtime, 0);
set_field (head->filesize, fsize);
set_field (head->devmajor, 0);
set_field (head->devminor, 0);
set_field (head->rdevmajor, 0);
set_field (head->rdevminor, 0);
set_field (head->namesize, len);
set_field (head->check, 0);
optr = ptr;
ptr += sizeof (struct newc_head);
grub_memcpy (ptr, name, len);
ptr += len;
oh = ALIGN_UP_OVERHEAD (ptr - optr, 4);
grub_memset (ptr, 0, oh);
ptr += oh;
return ptr;
}
static void
free_dir (struct dir *root)
{
if (!root)
return;
free_dir (root->next);
free_dir (root->child);
grub_free (root->name);
grub_free (root);
}
static grub_size_t
insert_dir (const char *name, struct dir **root,
grub_uint8_t *ptr)
{
struct dir *cur, **head = root;
const char *cb, *ce = name;
grub_size_t size = 0;
while (1)
{
for (cb = ce; *cb == '/'; cb++);
for (ce = cb; *ce && *ce != '/'; ce++);
if (!*ce)
break;
for (cur = *root; cur; cur = cur->next)
if (grub_memcmp (cur->name, cb, ce - cb)
&& cur->name[ce - cb] == 0)
break;
if (!cur)
{
struct dir *n;
n = grub_zalloc (sizeof (*n));
if (!n)
return 0;
n->next = *head;
n->name = grub_strndup (cb, ce - cb);
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);
ptr = make_header (ptr, tmp_name, ce - name + 1,
040777, 0);
grub_free (tmp_name);
}
size += ALIGN_UP ((ce - (char *) name + 1)
+ sizeof (struct newc_head), 4);
*head = n;
cur = n;
}
root = &cur->next;
}
return size;
}
grub_err_t
grub_initrd_init (int argc, char *argv[],
struct grub_linux_initrd_context *initrd_ctx)
{
int i;
int newc = 0;
struct dir *root = 0;
initrd_ctx->nfiles = 0;
initrd_ctx->components = 0;
initrd_ctx->components = grub_zalloc (argc
* sizeof (initrd_ctx->components[0]));
if (!initrd_ctx->components)
return grub_errno;
initrd_ctx->size = 0;
for (i = 0; i < argc; i++)
{
const char *fname = argv[i];
initrd_ctx->size = ALIGN_UP (initrd_ctx->size, 4);
if (grub_memcmp (argv[i], "newc:", 5) == 0)
{
const char *ptr, *eptr;
ptr = argv[i] + 5;
while (*ptr == '/')
ptr++;
eptr = grub_strchr (ptr, ':');
if (eptr)
{
initrd_ctx->components[i].newc_name = grub_strndup (ptr, eptr - ptr);
if (!initrd_ctx->components[i].newc_name)
{
grub_initrd_close (initrd_ctx);
return grub_errno;
}
initrd_ctx->size
+= ALIGN_UP (sizeof (struct newc_head)
+ grub_strlen (initrd_ctx->components[i].newc_name) + 1,
4);
initrd_ctx->size += insert_dir (initrd_ctx->components[i].newc_name,
&root, 0);
newc = 1;
fname = eptr + 1;
}
}
else if (newc)
{
initrd_ctx->size += ALIGN_UP (sizeof (struct newc_head)
+ sizeof ("TRAILER!!!"), 4);
free_dir (root);
root = 0;
newc = 0;
}
initrd_ctx->components[i].file = grub_file_open (fname,
GRUB_FILE_TYPE_LINUX_INITRD
| GRUB_FILE_TYPE_NO_DECOMPRESS);
if (!initrd_ctx->components[i].file)
{
grub_initrd_close (initrd_ctx);
return grub_errno;
}
initrd_ctx->nfiles++;
initrd_ctx->components[i].size
= grub_file_size (initrd_ctx->components[i].file);
initrd_ctx->size += initrd_ctx->components[i].size;
}
if (newc)
{
initrd_ctx->size = ALIGN_UP (initrd_ctx->size, 4);
initrd_ctx->size += ALIGN_UP (sizeof (struct newc_head)
+ sizeof ("TRAILER!!!"), 4);
free_dir (root);
root = 0;
}
return GRUB_ERR_NONE;
}
grub_size_t
grub_get_initrd_size (struct grub_linux_initrd_context *initrd_ctx)
{
return initrd_ctx->size;
}
void
grub_initrd_close (struct grub_linux_initrd_context *initrd_ctx)
{
int i;
if (!initrd_ctx->components)
return;
for (i = 0; i < initrd_ctx->nfiles; i++)
{
grub_free (initrd_ctx->components[i].newc_name);
grub_file_close (initrd_ctx->components[i].file);
}
grub_free (initrd_ctx->components);
initrd_ctx->components = 0;
}
extern int ventoy_need_prompt_load_file(void);
extern grub_ssize_t ventoy_load_file_with_prompt(grub_file_t file, void *buf, grub_ssize_t size);
grub_err_t
grub_initrd_load (struct grub_linux_initrd_context *initrd_ctx,
char *argv[], void *target)
{
grub_uint8_t *ptr = target;
int i;
int newc = 0;
struct dir *root = 0;
grub_ssize_t cursize = 0;
grub_ssize_t readsize = 0;
for (i = 0; i < initrd_ctx->nfiles; i++)
{
grub_memset (ptr, 0, ALIGN_UP_OVERHEAD (cursize, 4));
ptr += ALIGN_UP_OVERHEAD (cursize, 4);
if (initrd_ctx->components[i].newc_name)
{
ptr += insert_dir (initrd_ctx->components[i].newc_name,
&root, ptr);
ptr = make_header (ptr, initrd_ctx->components[i].newc_name,
grub_strlen (initrd_ctx->components[i].newc_name) + 1,
0100777,
initrd_ctx->components[i].size);
newc = 1;
}
else if (newc)
{
ptr = make_header (ptr, "TRAILER!!!", sizeof ("TRAILER!!!"),
0, 0);
free_dir (root);
root = 0;
newc = 0;
}
cursize = initrd_ctx->components[i].size;
if (ventoy_need_prompt_load_file() && initrd_ctx->components[i].newc_name &&
grub_strcmp(initrd_ctx->components[i].newc_name, "boot.wim") == 0)
{
readsize = ventoy_load_file_with_prompt(initrd_ctx->components[i].file, ptr, cursize);
}
else
{
readsize = grub_file_read (initrd_ctx->components[i].file, ptr, cursize);
}
if (readsize != cursize)
{
if (!grub_errno)
grub_error (GRUB_ERR_FILE_READ_ERROR, N_("premature end of file %s"),
argv[i]);
grub_initrd_close (initrd_ctx);
return grub_errno;
}
ptr += cursize;
}
if (newc)
{
grub_memset (ptr, 0, ALIGN_UP_OVERHEAD (cursize, 4));
ptr += ALIGN_UP_OVERHEAD (cursize, 4);
ptr = make_header (ptr, "TRAILER!!!", sizeof ("TRAILER!!!"), 0, 0);
}
free_dir (root);
root = 0;
return GRUB_ERR_NONE;
}

View File

@ -228,6 +228,13 @@ static int ventoy_boot_opt_filter(char *opt)
return 0;
}
if (grub_strncmp(opt, "dm=", 3) == 0)
{
opt[0] = 'D';
opt[1] = 'M';
return 0;
}
if (ventoy_debug)
{
if (grub_strcmp(opt, "quiet") == 0)

File diff suppressed because it is too large Load Diff

View File

@ -33,16 +33,60 @@
#include <grub/gfxterm.h>
#include <grub/dl.h>
#include <grub/env.h>
#include <grub/extcmd.h>
#include <grub/ventoy.h>
#include "ventoy/ventoy_def.h"
int g_ventoy_menu_refresh = 0;
int g_ventoy_memdisk_mode = 0;
int g_ventoy_iso_raw = 0;
int g_ventoy_grub2_mode = 0;
int g_ventoy_wimboot_mode = 0;
int g_ventoy_iso_uefi_drv = 0;
int g_ventoy_last_entry = -1;
int g_ventoy_suppress_esc = 0;
int g_ventoy_suppress_esc_default = 1;
int g_ventoy_menu_esc = 0;
int g_ventoy_fn_mutex = 0;
int g_ventoy_secondary_menu_on = 0;
int g_ventoy_terminal_output = 0;
char g_ventoy_hotkey_tip[256];
static int g_vt_key_num = 0;
static int g_vt_key_code[128];
static int ventoy_menu_pop_key(void)
{
if (g_vt_key_num > 0 && g_vt_key_num < (int)(sizeof(g_vt_key_code) / sizeof(g_vt_key_code[0])))
{
g_vt_key_num--;
return g_vt_key_code[g_vt_key_num];
}
return -1;
}
int ventoy_menu_push_key(int code)
{
if (g_vt_key_num >= 0 && g_vt_key_num < (int)(sizeof(g_vt_key_code) / sizeof(g_vt_key_code[0])))
{
g_vt_key_code[g_vt_key_num++] = code;
return 0;
}
return -1;
}
#define VTOY_COMM_HOTKEY(cmdkey) \
if (0 == g_ventoy_fn_mutex && 0 == g_ventoy_secondary_menu_on) { \
cmdstr = grub_env_get(cmdkey); \
if (cmdstr) \
{ \
menu_fini (); \
g_ventoy_fn_mutex = 1; \
grub_script_execute_sourcecode(cmdstr); \
g_ventoy_fn_mutex = 0; \
goto refresh; \
} \
}
/* Time to delay after displaying an error message about a default/fallback
entry failing to boot. */
@ -379,12 +423,76 @@ grub_menu_execute_with_fallback (grub_menu_t menu,
static struct grub_menu_viewer *viewers;
int g_menu_update_mode = 0;
int g_ventoy_tip_label_enable = 0;
const char * g_ventoy_tip_msg1 = NULL;
const char * g_ventoy_tip_msg2 = NULL;
char g_ventoy_theme_path[256] = {0};
static const char *g_ventoy_cur_img_path = NULL;
static void menu_set_chosen_tip(grub_menu_t menu, int entry)
{
int i;
img_info *img;
menu_tip *tip;
grub_menu_entry_t e = grub_menu_get_entry (menu, entry);
if (g_ventoy_theme_path[0])
{
grub_env_set("theme", g_ventoy_theme_path);
}
g_ventoy_tip_msg1 = g_ventoy_tip_msg2 = NULL;
if (e && e->id && grub_strncmp(e->id, "VID_", 4) == 0)
{
g_ventoy_theme_path[0] = 0;
img = (img_info *)(void *)grub_strtoul(e->id + 4, NULL, 16);
if (img)
{
g_ventoy_tip_msg1 = img->tip1;
g_ventoy_tip_msg2 = img->tip2;
g_ventoy_cur_img_path = img->path;
}
}
else if (e && e->id && grub_strncmp(e->id, "DIR_", 4) == 0)
{
g_ventoy_theme_path[0] = 0;
for (i = 0; i < e->argc; i++)
{
if (e->args[i] && grub_strncmp(e->args[i], "_VTIP_", 6) == 0)
{
break;
}
}
if (i < e->argc)
{
tip = (menu_tip *)(void *)grub_strtoul(e->args[i] + 6, NULL, 16);
if (tip)
{
g_ventoy_tip_msg1 = tip->tip1;
g_ventoy_tip_msg2 = tip->tip2;
}
}
}
}
static void
menu_set_chosen_entry (int entry)
menu_set_chosen_entry (grub_menu_t menu, int entry)
{
struct grub_menu_viewer *cur;
menu_set_chosen_tip(menu, entry);
for (cur = viewers; cur; cur = cur->next)
cur->set_chosen_entry (entry, cur->data);
}
static void
menu_scroll_chosen_entry (int diren)
{
struct grub_menu_viewer *cur;
for (cur = viewers; cur; cur = cur->next)
cur->set_chosen_entry (entry, cur->data);
if (cur->scroll_chosen_entry)
cur->scroll_chosen_entry (cur->data, diren);
}
static void
@ -596,10 +704,8 @@ run_menu (grub_menu_t menu, int nested, int *auto_boot)
default_entry = get_entry_number (menu, "default");
if (g_ventoy_suppress_esc)
default_entry = 1;
else if (g_ventoy_last_entry >= 0 && g_ventoy_last_entry < menu->size) {
default_entry = g_ventoy_last_entry;
}
default_entry = g_ventoy_suppress_esc_default;
/* If DEFAULT_ENTRY is not within the menu entries, fall back to
the first entry. */
else if (default_entry < 0 || default_entry >= menu->size)
@ -678,6 +784,7 @@ run_menu (grub_menu_t menu, int nested, int *auto_boot)
current_entry = default_entry;
refresh:
menu_set_chosen_tip(menu, current_entry);
menu_init (current_entry, menu, nested);
/* Initialize the time. */
@ -713,7 +820,11 @@ run_menu (grub_menu_t menu, int nested, int *auto_boot)
return default_entry;
}
c = grub_getkey_noblock ();
if (g_vt_key_num > 0) {
c = ventoy_menu_pop_key();
} else {
c = grub_getkey_noblock ();
}
/* Negative values are returned on error. */
if ((c != GRUB_TERM_NO_KEY) && (c > 0))
@ -730,13 +841,13 @@ run_menu (grub_menu_t menu, int nested, int *auto_boot)
case GRUB_TERM_KEY_HOME:
case GRUB_TERM_CTRL | 'a':
current_entry = 0;
menu_set_chosen_entry (current_entry);
menu_set_chosen_entry (menu, current_entry);
break;
case GRUB_TERM_KEY_END:
case GRUB_TERM_CTRL | 'e':
current_entry = menu->size - 1;
menu_set_chosen_entry (current_entry);
menu_set_chosen_entry (menu, current_entry);
break;
case GRUB_TERM_KEY_UP:
@ -744,7 +855,7 @@ run_menu (grub_menu_t menu, int nested, int *auto_boot)
case '^':
if (current_entry > 0)
current_entry--;
menu_set_chosen_entry (current_entry);
menu_set_chosen_entry (menu, current_entry);
break;
case GRUB_TERM_CTRL | 'n':
@ -752,7 +863,7 @@ run_menu (grub_menu_t menu, int nested, int *auto_boot)
case 'v':
if (current_entry < menu->size - 1)
current_entry++;
menu_set_chosen_entry (current_entry);
menu_set_chosen_entry (menu, current_entry);
break;
case GRUB_TERM_CTRL | 'g':
@ -761,7 +872,7 @@ run_menu (grub_menu_t menu, int nested, int *auto_boot)
current_entry = 0;
else
current_entry -= GRUB_MENU_PAGE_SIZE;
menu_set_chosen_entry (current_entry);
menu_set_chosen_entry (menu, current_entry);
break;
case GRUB_TERM_CTRL | 'c':
@ -770,7 +881,20 @@ run_menu (grub_menu_t menu, int nested, int *auto_boot)
current_entry += GRUB_MENU_PAGE_SIZE;
else
current_entry = menu->size - 1;
menu_set_chosen_entry (current_entry);
menu_set_chosen_entry (menu, current_entry);
break;
case GRUB_TERM_KEY_RIGHT:
menu_scroll_chosen_entry (1);
break;
case GRUB_TERM_KEY_LEFT:
menu_scroll_chosen_entry (-1);
break;
case GRUB_TERM_CTRL | GRUB_TERM_KEY_RIGHT:
menu_scroll_chosen_entry (1000000);
break;
case GRUB_TERM_CTRL | GRUB_TERM_KEY_LEFT:
menu_scroll_chosen_entry (-1000000);
break;
case '\n':
@ -805,104 +929,135 @@ run_menu (grub_menu_t menu, int nested, int *auto_boot)
case GRUB_TERM_KEY_F2:
case '2':
if (0 == g_ventoy_fn_mutex) {
cmdstr = grub_env_get("VTOY_F2_CMD");
if (cmdstr)
{
menu_fini ();
g_ventoy_fn_mutex = 1;
grub_script_execute_sourcecode(cmdstr);
g_ventoy_fn_mutex = 0;
goto refresh;
}
}
VTOY_COMM_HOTKEY("VTOY_F2_CMD");
break;
case GRUB_TERM_KEY_F3:
case '3':
if (0 == g_ventoy_fn_mutex) {
cmdstr = grub_env_get("VTOY_F3_CMD");
if (cmdstr)
{
menu_fini ();
grub_script_execute_sourcecode(cmdstr);
goto refresh;
}
}
VTOY_COMM_HOTKEY("VTOY_F3_CMD");
break;
case GRUB_TERM_KEY_F4:
case '4':
if (0 == g_ventoy_fn_mutex) {
cmdstr = grub_env_get("VTOY_F4_CMD");
if (cmdstr)
{
menu_fini ();
g_ventoy_fn_mutex = 1;
grub_script_execute_sourcecode(cmdstr);
g_ventoy_fn_mutex = 0;
goto refresh;
}
}
VTOY_COMM_HOTKEY("VTOY_F4_CMD");
break;
case GRUB_TERM_KEY_F5:
case '5':
if (0 == g_ventoy_fn_mutex) {
cmdstr = grub_env_get("VTOY_F5_CMD");
if (cmdstr)
{
menu_fini ();
g_ventoy_fn_mutex = 1;
grub_script_execute_sourcecode(cmdstr);
g_ventoy_fn_mutex = 0;
goto refresh;
}
}
VTOY_COMM_HOTKEY("VTOY_F5_CMD");
break;
case GRUB_TERM_KEY_F6:
case '6':
if (0 == g_ventoy_fn_mutex) {
cmdstr = grub_env_get("VTOY_F6_CMD");
if (cmdstr)
{
menu_fini ();
g_ventoy_fn_mutex = 1;
grub_script_execute_sourcecode(cmdstr);
g_ventoy_fn_mutex = 0;
goto refresh;
}
}
VTOY_COMM_HOTKEY("VTOY_F6_CMD");
break;
case GRUB_TERM_KEY_F7:
menu_fini ();
if (g_ventoy_terminal_output == 0)
{
grub_script_execute_sourcecode("terminal_output console");
grub_script_execute_sourcecode("vt_push_menu_lang en_US\nterminal_output console");
g_ventoy_terminal_output = 1;
}
else
{
grub_script_execute_sourcecode("terminal_output gfxterm");
grub_script_execute_sourcecode("terminal_output gfxterm\nvt_pop_menu_lang");
g_ventoy_terminal_output = 0;
}
goto refresh;
case GRUB_TERM_KEY_F1:
case '1':
menu_fini ();
g_ventoy_memdisk_mode = 1 - g_ventoy_memdisk_mode;
g_ventoy_menu_refresh = 1;
goto refresh;
if (0 == g_ventoy_secondary_menu_on)
{
cmdstr = grub_env_get("VTOY_HELP_CMD");
if (cmdstr)
{
grub_script_execute_sourcecode(cmdstr);
while (grub_getkey() != GRUB_TERM_ESC)
;
menu_fini ();
goto refresh;
}
}
break;
case (GRUB_TERM_CTRL | 'd'):
case 'd':
if (0 == g_ventoy_secondary_menu_on)
{
menu_fini ();
g_ventoy_memdisk_mode = 1 - g_ventoy_memdisk_mode;
g_ventoy_menu_refresh = 1;
goto refresh;
}
break;
case (GRUB_TERM_CTRL | 'i'):
menu_fini ();
g_ventoy_iso_raw = 1 - g_ventoy_iso_raw;
g_ventoy_menu_refresh = 1;
goto refresh;
case 'i':
if (0 == g_ventoy_secondary_menu_on)
{
menu_fini ();
g_ventoy_iso_raw = 1 - g_ventoy_iso_raw;
g_ventoy_menu_refresh = 1;
goto refresh;
}
break;
case (GRUB_TERM_CTRL | 'r'):
case 'r':
if (0 == g_ventoy_secondary_menu_on)
{
menu_fini ();
g_ventoy_grub2_mode = 1 - g_ventoy_grub2_mode;
g_ventoy_menu_refresh = 1;
goto refresh;
}
break;
case (GRUB_TERM_CTRL | 'w'):
case 'w':
if (0 == g_ventoy_secondary_menu_on)
{
menu_fini ();
g_ventoy_wimboot_mode = 1 - g_ventoy_wimboot_mode;
g_ventoy_menu_refresh = 1;
goto refresh;
}
break;
case (GRUB_TERM_CTRL | 'u'):
menu_fini ();
g_ventoy_iso_uefi_drv = 1 - g_ventoy_iso_uefi_drv;
g_ventoy_menu_refresh = 1;
goto refresh;
case 'u':
if (0 == g_ventoy_secondary_menu_on)
{
menu_fini ();
g_ventoy_iso_uefi_drv = 1 - g_ventoy_iso_uefi_drv;
g_ventoy_menu_refresh = 1;
goto refresh;
}
break;
case (GRUB_TERM_CTRL | 'l'):
case (GRUB_TERM_CTRL | 'L'):
case (GRUB_TERM_SHIFT | 'l'):
case (GRUB_TERM_SHIFT | 'L'):
case 'l':
case 'L':
{
VTOY_COMM_HOTKEY("VTOY_LANG_CMD");
break;
}
case (GRUB_TERM_CTRL | 'm'):
case 'm':
{
if (0 == g_ventoy_secondary_menu_on)
{
if (g_ventoy_cur_img_path)
{
grub_env_set("VTOY_CHKSUM_FILE_PATH", g_ventoy_cur_img_path);
cmdstr = grub_env_get("VTOY_CHKSUM_CMD");
if (cmdstr)
{
menu_fini();
grub_script_execute_sourcecode(cmdstr);
goto refresh;
}
}
else
{
grub_env_set("VTOY_CHKSUM_FILE_PATH", "X");
}
}
break;
}
default:
{
int entry;
@ -978,6 +1133,7 @@ show_menu (grub_menu_t menu, int nested, int autobooted)
while (1)
{
int ndown;
int boot_entry;
grub_menu_entry_t e;
int auto_boot;
@ -996,6 +1152,11 @@ show_menu (grub_menu_t menu, int nested, int autobooted)
break;
}
if (autobooted == 0 && g_ventoy_menu_esc && auto_boot) {
g_ventoy_last_entry = boot_entry;
break;
}
e = grub_menu_get_entry (menu, boot_entry);
if (! e)
continue; /* Menu is empty. */
@ -1015,6 +1176,16 @@ 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)
break;
else if (2 == e->argc && e->args && e->args[1] && grub_strncmp(e->args[1], "VTOY_RUN_SET", 12) == 0) {
ndown = (int)grub_strtol(e->args[1] + 12, NULL, 10);
while (ndown > 0)
{
ventoy_menu_push_key(GRUB_TERM_KEY_DOWN);
ndown--;
}
ventoy_menu_push_key('\n');
break;
}
}
return GRUB_ERR_NONE;

View File

@ -31,6 +31,8 @@
static grub_uint8_t grub_color_menu_normal;
static grub_uint8_t grub_color_menu_highlight;
extern char g_ventoy_hotkey_tip[256];
struct menu_viewer_data
{
int first, offset;
@ -42,6 +44,7 @@ struct menu_viewer_data
TIMEOUT_TERSE_NO_MARGIN
} timeout_msg;
grub_menu_t menu;
int *menu_title_offset;
struct grub_term_output *term;
};
@ -203,7 +206,7 @@ command-line or ESC to discard edits and return to the GRUB menu."),
ret += grub_print_message_indented_real(szLine, STANDARD_MARGIN, STANDARD_MARGIN, term, dry_run);
ret += grub_print_message_indented_real("\n", STANDARD_MARGIN, STANDARD_MARGIN, term, dry_run);
ret += grub_print_message_indented_real(grub_env_get("VTOY_HOTKEY_TIP"),
ret += grub_print_message_indented_real(g_ventoy_hotkey_tip,
3, 6, term, dry_run);
}
}
@ -524,6 +527,37 @@ menu_text_set_chosen_entry (int entry, void *dataptr)
grub_term_refresh (data->term);
}
static void
menu_text_scroll_chosen_entry (void *dataptr, int diren)
{
struct menu_viewer_data *data = dataptr;
const char *orig_title, *scrolled_title;
int off;
int selected;
grub_menu_entry_t entry;
if (!data->menu->size)
return;
selected = data->first + data->offset;
entry = grub_menu_get_entry (data->menu, selected);
orig_title = entry->title;
off = data->menu_title_offset[selected] + diren;
if (off < 0
|| off > grub_utf8_get_num_code (orig_title, grub_strlen(orig_title)))
return;
scrolled_title =
grub_utf8_offset_code (orig_title, grub_strlen (orig_title), off);
if (scrolled_title)
entry->title = scrolled_title;
print_entry (data->geo.first_entry_y + data->offset, 1, entry, data);
entry->title = orig_title;
data->menu_title_offset[selected] = off;
grub_term_refresh (data->term);
}
static void
menu_text_fini (void *dataptr)
{
@ -531,6 +565,8 @@ menu_text_fini (void *dataptr)
grub_term_setcursor (data->term, 1);
grub_term_cls (data->term);
if (data->menu_title_offset)
grub_free (data->menu_title_offset);
grub_free (data);
}
@ -585,9 +621,14 @@ grub_menu_try_text (struct grub_term_output *term,
return grub_errno;
}
if (menu->size)
data->menu_title_offset = grub_zalloc (sizeof (*data->menu_title_offset) * menu->size);
data->term = term;
instance->data = data;
instance->set_chosen_entry = menu_text_set_chosen_entry;
if (data->menu_title_offset)
instance->scroll_chosen_entry = menu_text_scroll_chosen_entry;
instance->print_timeout = menu_text_print_timeout;
instance->clear_timeout = menu_text_clear_timeout;
instance->fini = menu_text_fini;

View File

@ -0,0 +1,232 @@
/* gpt.c - Read GUID Partition Tables (GPT). */
/*
* GRUB -- GRand Unified Bootloader
* Copyright (C) 2002,2005,2006,2007,2008 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/disk.h>
#include <grub/misc.h>
#include <grub/mm.h>
#include <grub/partition.h>
#include <grub/dl.h>
#include <grub/msdos_partition.h>
#include <grub/gpt_partition.h>
#include <grub/i18n.h>
GRUB_MOD_LICENSE ("GPLv3+");
static grub_uint8_t grub_gpt_magic[8] =
{
0x45, 0x46, 0x49, 0x20, 0x50, 0x41, 0x52, 0x54
};
static const grub_gpt_part_guid_t grub_gpt_partition_type_empty = GRUB_GPT_PARTITION_TYPE_EMPTY;
#ifdef GRUB_UTIL
static const grub_gpt_part_guid_t grub_gpt_partition_type_bios_boot = GRUB_GPT_PARTITION_TYPE_BIOS_BOOT;
#endif
/* 512 << 7 = 65536 byte sectors. */
#define MAX_SECTOR_LOG 7
static struct grub_partition_map grub_gpt_partition_map;
grub_err_t
grub_gpt_partition_map_iterate (grub_disk_t disk,
grub_partition_iterate_hook_t hook,
void *hook_data)
{
struct grub_partition part;
struct grub_gpt_header gpt;
struct grub_gpt_partentry entry;
struct grub_msdos_partition_mbr mbr;
grub_uint64_t entries;
unsigned int i;
int last_offset = 0;
int sector_log = 0;
/* Read the protective MBR. */
if (grub_disk_read (disk, 0, 0, sizeof (mbr), &mbr))
return grub_errno;
/* Check if it is valid. */
if (mbr.signature != grub_cpu_to_le16_compile_time (GRUB_PC_PARTITION_SIGNATURE))
return grub_error (GRUB_ERR_BAD_PART_TABLE, "no signature");
/* Make sure the MBR is a protective MBR and not a normal MBR. */
for (i = 0; i < 4; i++)
if (mbr.entries[i].type == GRUB_PC_PARTITION_TYPE_GPT_DISK)
break;
if (i == 4)
return grub_error (GRUB_ERR_BAD_PART_TABLE, "no GPT partition map found");
/* Read the GPT header. */
for (sector_log = 0; sector_log < MAX_SECTOR_LOG; sector_log++)
{
if (grub_disk_read (disk, 1 << sector_log, 0, sizeof (gpt), &gpt))
return grub_errno;
if (grub_memcmp (gpt.magic, grub_gpt_magic, sizeof (grub_gpt_magic)) == 0)
break;
}
if (sector_log == MAX_SECTOR_LOG)
return grub_error (GRUB_ERR_BAD_PART_TABLE, "no valid GPT header");
grub_dprintf ("gpt", "Read a valid GPT header\n");
entries = grub_le_to_cpu64 (gpt.partitions) << sector_log;
for (i = 0; i < grub_le_to_cpu32 (gpt.maxpart); i++)
{
if (grub_disk_read (disk, entries, last_offset,
sizeof (entry), &entry))
return grub_errno;
if (grub_memcmp (&grub_gpt_partition_type_empty, &entry.type,
sizeof (grub_gpt_partition_type_empty)))
{
/* Calculate the first block and the size of the partition. */
part.start = grub_le_to_cpu64 (entry.start) << sector_log;
part.len = (grub_le_to_cpu64 (entry.end)
- grub_le_to_cpu64 (entry.start) + 1) << sector_log;
part.offset = entries;
part.number = i;
part.index = last_offset;
part.partmap = &grub_gpt_partition_map;
part.parent = disk->partition;
part.gpt_attrib = entry.attrib;
grub_dprintf ("gpt", "GPT entry %d: start=%lld, length=%lld\n", i,
(unsigned long long) part.start,
(unsigned long long) part.len);
if (hook (disk, &part, hook_data))
return grub_errno;
}
last_offset += grub_le_to_cpu32 (gpt.partentry_size);
if (last_offset == GRUB_DISK_SECTOR_SIZE)
{
last_offset = 0;
entries++;
}
}
return GRUB_ERR_NONE;
}
#ifdef GRUB_UTIL
/* Context for gpt_partition_map_embed. */
struct gpt_partition_map_embed_ctx
{
grub_disk_addr_t start, len;
};
/* Helper for gpt_partition_map_embed. */
static int
find_usable_region (grub_disk_t disk __attribute__ ((unused)),
const grub_partition_t p, void *data)
{
struct gpt_partition_map_embed_ctx *ctx = data;
struct grub_gpt_partentry gptdata;
grub_partition_t p2;
p2 = disk->partition;
disk->partition = p->parent;
if (grub_disk_read (disk, p->offset, p->index,
sizeof (gptdata), &gptdata))
{
disk->partition = p2;
return 0;
}
disk->partition = p2;
/* If there's an embed region, it is in a dedicated partition. */
if (! grub_memcmp (&gptdata.type, &grub_gpt_partition_type_bios_boot, 16))
{
ctx->start = p->start;
ctx->len = p->len;
return 1;
}
return 0;
}
static grub_err_t
gpt_partition_map_embed (struct grub_disk *disk, unsigned int *nsectors,
unsigned int max_nsectors,
grub_embed_type_t embed_type,
grub_disk_addr_t **sectors)
{
struct gpt_partition_map_embed_ctx ctx = {
.start = 0,
.len = 0
};
unsigned i;
grub_err_t err;
if (embed_type != GRUB_EMBED_PCBIOS)
return grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET,
"GPT currently supports only PC-BIOS embedding");
err = grub_gpt_partition_map_iterate (disk, find_usable_region, &ctx);
if (err)
return err;
if (ctx.len == 0)
return grub_error (GRUB_ERR_FILE_NOT_FOUND,
N_("this GPT partition label contains no BIOS Boot Partition;"
" embedding won't be possible"));
if (ctx.len < *nsectors)
return grub_error (GRUB_ERR_OUT_OF_RANGE,
N_("your BIOS Boot Partition is too small;"
" embedding won't be possible"));
*nsectors = ctx.len;
if (*nsectors > max_nsectors)
*nsectors = max_nsectors;
*sectors = grub_malloc (*nsectors * sizeof (**sectors));
if (!*sectors)
return grub_errno;
for (i = 0; i < *nsectors; i++)
(*sectors)[i] = ctx.start + i;
return GRUB_ERR_NONE;
}
#endif
/* Partition map type. */
static struct grub_partition_map grub_gpt_partition_map =
{
.name = "gpt",
.iterate = grub_gpt_partition_map_iterate,
#ifdef GRUB_UTIL
.embed = gpt_partition_map_embed
#endif
};
GRUB_MOD_INIT(part_gpt)
{
grub_partition_map_register (&grub_gpt_partition_map);
}
GRUB_MOD_FINI(part_gpt)
{
grub_partition_map_unregister (&grub_gpt_partition_map);
}

View File

@ -0,0 +1,113 @@
/*
* GRUB -- GRand Unified Bootloader
* Copyright (C) 2005,2007,2009,2010 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/misc.h>
#include <grub/script_sh.h>
#include <grub/parser.h>
#include <grub/mm.h>
#include <grub/charset.h>
grub_script_function_t grub_script_function_list;
grub_script_function_t
grub_script_function_create (struct grub_script_arg *functionname_arg,
struct grub_script *cmd)
{
grub_script_function_t func;
grub_script_function_t *p;
func = (grub_script_function_t) grub_malloc (sizeof (*func));
if (! func)
return 0;
func->name = grub_strdup (functionname_arg->str);
if (! func->name)
{
grub_free (func);
return 0;
}
func->func = cmd;
/* Keep the list sorted for simplicity. */
p = &grub_script_function_list;
while (*p)
{
if (grub_strcmp ((*p)->name, func->name) >= 0)
break;
p = &((*p)->next);
}
/* If the function already exists, overwrite the old function. */
if (*p && grub_strcmp ((*p)->name, func->name) == 0)
{
grub_script_function_t q;
q = *p;
grub_script_free (q->func);
q->func = cmd;
grub_free (func);
func = q;
}
else
{
func->next = *p;
*p = func;
}
return func;
}
void
grub_script_function_remove (const char *name)
{
grub_script_function_t *p, q;
for (p = &grub_script_function_list, q = *p; q; p = &(q->next), q = q->next)
if (grub_strcmp (name, q->name) == 0)
{
*p = q->next;
grub_free (q->name);
grub_script_free (q->func);
grub_free (q);
break;
}
}
grub_script_function_t
grub_script_function_find (char *functionname)
{
grub_script_function_t func;
for (func = grub_script_function_list; func; func = func->next)
if (grub_strcmp (functionname, func->name) == 0)
break;
if (! func)
{
char tmp[64];
grub_strncpy (tmp, functionname, 63);
tmp[63] = 0;
/* Avoid truncating inside UTF-8 character. */
tmp[grub_getend (tmp, tmp + grub_strlen (tmp))] = 0;
grub_error (GRUB_ERR_UNKNOWN_COMMAND, N_("can't find command `%s'"), tmp);
}
return func;
}

View File

@ -0,0 +1,260 @@
/*
* GRUB -- GRand Unified Bootloader
* Copyright (C) 2022 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/dl.h>
#include <grub/term.h>
#include <grub/misc.h>
#include <grub/types.h>
#include <grub/command.h>
#include <grub/i18n.h>
#include <grub/err.h>
#include <grub/env.h>
#include <grub/efi/efi.h>
#include <grub/efi/api.h>
GRUB_MOD_LICENSE ("GPLv3+");
#define GRUB_EFI_SIMPLE_POINTER_GUID \
{ 0x31878c87, 0x0b75, 0x11d5, \
{ 0x9a, 0x4f, 0x00, 0x90, 0x27, 0x3f, 0xc1, 0x4d } \
}
typedef struct
{
grub_efi_int32_t x;
grub_efi_int32_t y;
grub_efi_int32_t z;
grub_efi_boolean_t left;
grub_efi_boolean_t right;
} grub_efi_mouse_state;
grub_efi_mouse_state no_move = {0, 0, 0, 0, 0};
typedef struct
{
grub_efi_uint64_t x;
grub_efi_uint64_t y;
grub_efi_uint64_t z;
grub_efi_boolean_t left;
grub_efi_boolean_t right;
} grub_efi_mouse_mode;
struct grub_efi_simple_pointer_protocol
{
grub_efi_status_t (*reset) (struct grub_efi_simple_pointer_protocol *this,
grub_efi_boolean_t extended_verification);
grub_efi_status_t (*get_state) (struct grub_efi_simple_pointer_protocol *this,
grub_efi_mouse_state *state);
grub_efi_event_t *wait_for_input;
grub_efi_mouse_mode *mode;
};
typedef struct grub_efi_simple_pointer_protocol grub_efi_simple_pointer_protocol_t;
typedef struct
{
grub_efi_uintn_t count;
grub_efi_simple_pointer_protocol_t **mouse;
} grub_efi_mouse_prot_t;
static grub_int32_t
mouse_div (grub_int32_t a, grub_uint64_t b)
{
grub_int32_t s = 1, q, ret;
grub_uint64_t n = a;
if (!b)
return 0;
if (a < 0)
{
s = -1;
n = -a;
}
q = grub_divmod64 (n, b, NULL);
ret = s * (q > 0 ? q : -q);
return ret;
}
static grub_efi_mouse_prot_t *
grub_efi_mouse_prot_init (void)
{
grub_efi_status_t status;
grub_efi_guid_t mouse_guid = GRUB_EFI_SIMPLE_POINTER_GUID;
grub_efi_mouse_prot_t *mouse_input = NULL;
grub_efi_boot_services_t *b = grub_efi_system_table->boot_services;
grub_efi_handle_t *buf;
grub_efi_uintn_t count;
grub_efi_uintn_t i;
status = efi_call_5 (b->locate_handle_buffer, GRUB_EFI_BY_PROTOCOL,
&mouse_guid, NULL, &count, &buf);
if (status != GRUB_EFI_SUCCESS)
{
#ifdef MOUSE_DEBUG
grub_printf ("ERROR: SimplePointerProtocol not found.\n");
#endif
return NULL;
}
mouse_input = grub_malloc (sizeof (grub_efi_mouse_prot_t));
if (!mouse_input)
goto end;
mouse_input->mouse = grub_malloc (count
* sizeof (grub_efi_simple_pointer_protocol_t *));
if (!mouse_input->mouse)
{
grub_free (mouse_input);
mouse_input = NULL;
goto end;
}
mouse_input->count = count;
for (i = 0; i < count; i++)
{
efi_call_3 (b->handle_protocol,
buf[i], &mouse_guid, (void **)&mouse_input->mouse[i]);
#ifdef MOUSE_DEBUG
grub_printf ("%d %p ", (int)i, mouse_input->mouse[i]);
#endif
efi_call_2 (mouse_input->mouse[i]->reset, mouse_input->mouse[i], 1);
#ifdef MOUSE_DEBUG
grub_printf
("[%"PRIuGRUB_UINT64_T"] [%"PRIuGRUB_UINT64_T"] [%"PRIuGRUB_UINT64_T"]\n",
mouse_input->mouse[i]->mode->x,
mouse_input->mouse[i]->mode->y, mouse_input->mouse[i]->mode->z);
#endif
}
end:
efi_call_1(b->free_pool, buf);
return mouse_input;
}
static grub_err_t
grub_efi_mouse_input_init (struct grub_term_input *term)
{
grub_efi_mouse_prot_t *mouse_input = NULL;
if (term->data)
return 0;
mouse_input = grub_efi_mouse_prot_init ();
if (!mouse_input)
return GRUB_ERR_BAD_OS;
term->data = (void *)mouse_input;
return 0;
}
static int
grub_mouse_getkey (struct grub_term_input *term)
{
grub_efi_mouse_state cur;
grub_efi_mouse_prot_t *mouse = term->data;
//int x;
int y;
int delta = 0;
const char *env;
grub_efi_uintn_t i;
if (!mouse)
return GRUB_TERM_NO_KEY;
env = grub_env_get("mouse_delta");
if (env)
delta = (int)grub_strtol(env, NULL, 10);
for (i = 0; i < mouse->count; i++)
{
efi_call_2 (mouse->mouse[i]->get_state, mouse->mouse[i], &cur);
if (grub_memcmp (&cur, &no_move, sizeof (grub_efi_mouse_state)) != 0)
{
y = mouse_div (cur.y, mouse->mouse[i]->mode->y);
if (cur.left)
return 0x0d;
if (cur.right)
return GRUB_TERM_ESC;
if (y > delta)
return GRUB_TERM_KEY_DOWN;
if (y < -delta)
return GRUB_TERM_KEY_UP;
}
}
return GRUB_TERM_NO_KEY;
}
#ifdef MOUSE_DEBUG
static grub_err_t
grub_cmd_mouse_test (grub_command_t cmd __attribute__ ((unused)),
int argc __attribute__ ((unused)),
char **args __attribute__ ((unused)))
{
grub_efi_mouse_state cur;
int x = 0, y = 0, z = 0;
grub_efi_uintn_t i;
grub_efi_mouse_prot_t *mouse = NULL;
mouse = grub_efi_mouse_prot_init ();
if (!mouse)
return grub_error (GRUB_ERR_BAD_OS, "mouse not found.\n");
grub_printf ("Press [1] to exit.\n");
while (1)
{
if (grub_getkey_noblock () == '1')
break;
for (i = 0; i < mouse->count; i++)
{
efi_call_2 (mouse->mouse[i]->get_state, mouse->mouse[i], &cur);
if (grub_memcmp (&cur, &no_move, sizeof (grub_efi_mouse_state)) != 0)
{
x = mouse_div (cur.x, mouse->mouse[i]->mode->x);
y = mouse_div (cur.y, mouse->mouse[i]->mode->y);
z = mouse_div (cur.z, mouse->mouse[i]->mode->z);
grub_printf ("[ID=%d] X=%d Y=%d Z=%d L=%d R=%d\n",
(int)i, x, y, z, cur.left, cur.right);
}
}
grub_refresh ();
}
grub_free (mouse->mouse);
grub_free (mouse);
return GRUB_ERR_NONE;
}
static grub_command_t cmd;
#endif
static struct grub_term_input grub_mouse_term_input =
{
.name = "mouse",
.getkey = grub_mouse_getkey,
.init = grub_efi_mouse_input_init,
};
GRUB_MOD_INIT(mouse)
{
grub_term_register_input ("mouse", &grub_mouse_term_input);
#ifdef MOUSE_DEBUG
cmd = grub_register_command ("mouse_test", grub_cmd_mouse_test, 0,
N_("UEFI mouse test."));
#endif
}
GRUB_MOD_FINI(mouse)
{
grub_term_unregister_input (&grub_mouse_term_input);
#ifdef MOUSE_DEBUG
grub_unregister_command (cmd);
#endif
}

View File

@ -462,6 +462,8 @@ static int lzx_uncompressed ( struct lzx *lzx ) {
if ( len % 2 )
lzx->input.offset++;
lzx->output.offset += len;
return 0;
}
@ -614,7 +616,7 @@ ssize_t lzx_decompress ( const void *data, size_t len, void *buf ) {
/* Sanity check */
if ( len % 2 ) {
DBG ( "LZX cannot handle odd-length input data\n" );
return -1;
//return -1;
}
/* Initialise global state, if required */

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,652 @@
/******************************************************************************
* ventoy_browser.c
*
* Copyright (c) 2022, 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 <grub/types.h>
#include <grub/misc.h>
#include <grub/mm.h>
#include <grub/err.h>
#include <grub/dl.h>
#include <grub/disk.h>
#include <grub/device.h>
#include <grub/term.h>
#include <grub/partition.h>
#include <grub/file.h>
#include <grub/normal.h>
#include <grub/extcmd.h>
#include <grub/datetime.h>
#include <grub/i18n.h>
#include <grub/net.h>
#include <grub/time.h>
#include <grub/ventoy.h>
#include "ventoy_def.h"
GRUB_MOD_LICENSE ("GPLv3+");
#define BROWSER_MENU_BUF 65536
static const char *g_vtoy_dev = NULL;
static grub_fs_t g_menu_fs = NULL;
static char *g_menu_device = NULL;
static grub_device_t g_menu_dev = NULL;
static char g_menu_path_buf[1024];
static int g_menu_path_len = 0;
static browser_node *g_browser_list = NULL;
static int ventoy_browser_strcmp(char *str1, char *str2)
{
char *s1, *s2;
int c1 = 0;
int c2 = 0;
for (s1 = str1, s2 = str2; *s1 && *s2; s1++, s2++)
{
c1 = *s1;
c2 = *s2;
if (0 == g_sort_case_sensitive)
{
if (grub_islower(c1))
{
c1 = c1 - 'a' + 'A';
}
if (grub_islower(c2))
{
c2 = c2 - 'a' + 'A';
}
}
if (c1 != c2)
{
break;
}
}
return (c1 - c2);
}
static int ventoy_browser_mbuf_alloc(browser_mbuf *mbuf)
{
grub_memset(mbuf, 0, sizeof(browser_mbuf));
mbuf->buf = grub_malloc(BROWSER_MENU_BUF);
if (!mbuf->buf)
{
return 0;
}
mbuf->pos = 0;
mbuf->max = BROWSER_MENU_BUF;
return 1;
}
static inline void ventoy_browser_mbuf_free(browser_mbuf *mbuf)
{
if (mbuf)
grub_check_free(mbuf->buf)
}
static inline int ventoy_browser_mbuf_extend(browser_mbuf *mbuf)
{
if (mbuf->max - mbuf->pos <= VTOY_SIZE_1KB)
{
mbuf->max += BROWSER_MENU_BUF;
mbuf->buf = grub_realloc(mbuf->buf, mbuf->max);
}
return 0;
}
static browser_node * ventoy_browser_find_top_node(int dir)
{
browser_node *node = NULL;
browser_node *sel = NULL;
for (node = g_browser_list; node; node = node->next)
{
if (node->dir == dir)
{
if (sel)
{
if (ventoy_browser_strcmp(sel->filename, node->filename) > 0)
{
sel = node;
}
}
else
{
sel = node;
}
}
}
return sel;
}
static int ventoy_browser_iterate_partition(struct grub_disk *disk, const grub_partition_t partition, void *data)
{
char partname[64];
char title[256];
grub_device_t dev;
grub_fs_t fs;
char *Label = NULL;
browser_mbuf *mbuf = (browser_mbuf *)data;
(void)data;
if (partition->number == 1 && g_vtoy_dev && grub_strcmp(disk->name, g_vtoy_dev) == 0)
{
return 0;
}
grub_snprintf(partname, sizeof(partname) - 1, "%s,%d", disk->name, partition->number + 1);
dev = grub_device_open(partname);
if (!dev)
{
return 0;
}
fs = grub_fs_probe(dev);
if (!fs)
{
grub_device_close(dev);
return 0;
}
fs->fs_label(dev, &Label);
if (ventoy_check_file_exist("(%s)/.ventoyignore", partname))
{
return 0;
}
if (g_tree_view_menu_style == 0)
{
grub_snprintf(title, sizeof(title), "%-10s (%s,%s%d) [%s] %s %s",
"DISK", disk->name, partition->msdostype == 0xee ? "gpt" : "msdos",
partition->number + 1, (Label ? Label : ""), fs->name,
grub_get_human_size(partition->len << disk->log_sector_size, GRUB_HUMAN_SIZE_SHORT));
}
else
{
grub_snprintf(title, sizeof(title), "(%s,%s%d) [%s] %s %s",
disk->name, partition->msdostype == 0xee ? "gpt" : "msdos",
partition->number + 1, (Label ? Label : ""), fs->name,
grub_get_human_size(partition->len << disk->log_sector_size, GRUB_HUMAN_SIZE_SHORT));
}
if (ventoy_get_fs_type(fs->name) >= ventoy_fs_max)
{
browser_ssprintf(mbuf, "menuentry \"%s\" --class=vtoydisk {\n"
" echo \"unsupported file system type!\" \n"
" ventoy_pause\n"
"}\n",
title);
}
else
{
browser_ssprintf(mbuf, "menuentry \"%s\" --class=vtoydisk {\n"
" vt_browser_dir %s,%d 0x%lx /\n"
"}\n",
title, disk->name, partition->number + 1, (ulong)fs);
}
ventoy_browser_mbuf_extend(mbuf);
return 0;
}
static int ventoy_browser_iterate_disk(const char *name, void *data)
{
grub_disk_t disk;
if (name[0] != 'h')
{
return 0;
}
disk = grub_disk_open(name);
if (disk)
{
grub_partition_iterate(disk, ventoy_browser_iterate_partition, data);
grub_disk_close(disk);
}
return 0;
}
static int ventoy_browser_valid_dirname(const char *name, int len)
{
if ((len == 1 && name[0] == '.') ||
(len == 2 && name[0] == '.' && name[1] == '.'))
{
return 0;
}
if (!ventoy_img_name_valid(name, len))
{
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 (0 == grub_strncmp(name, "$RECYCLE.BIN", 12) ||
0 == grub_strncasecmp(name, "$Extend", 7))
{
return 0;
}
}
if (len == 25 && grub_strncmp(name, "System Volume Information", 25) == 0)
{
return 0;
}
return 1;
}
static int ventoy_browser_valid_filename(const char *filename, int len, int *type)
{
if (len < 4)
{
return 0;
}
if (FILE_FLT(ISO) && 0 == grub_strcasecmp(filename + len - 4, ".iso"))
{
*type = img_type_iso;
}
else if (FILE_FLT(WIM) && g_wimboot_enable && (0 == grub_strcasecmp(filename + len - 4, ".wim")))
{
*type = img_type_wim;
}
else if (FILE_FLT(VHD) && g_vhdboot_enable && (0 == grub_strcasecmp(filename + len - 4, ".vhd") ||
(len >= 5 && 0 == grub_strcasecmp(filename + len - 5, ".vhdx"))))
{
*type = img_type_vhd;
}
#ifdef GRUB_MACHINE_EFI
else if (FILE_FLT(EFI) && 0 == grub_strcasecmp(filename + len - 4, ".efi"))
{
*type = img_type_efi;
}
#endif
else if (FILE_FLT(IMG) && 0 == grub_strcasecmp(filename + len - 4, ".img"))
{
if (len == 18 && grub_strncmp(filename, "ventoy_", 7) == 0)
{
if (grub_strncmp(filename + 7, "wimboot", 7) == 0 ||
grub_strncmp(filename + 7, "vhdboot", 7) == 0)
{
return 0;
}
}
*type = img_type_img;
}
else if (FILE_FLT(VTOY) && len >= 5 && 0 == grub_strcasecmp(filename + len - 5, ".vtoy"))
{
*type = img_type_vtoy;
}
else
{
return 0;
}
if (g_filt_dot_underscore_file && filename[0] == '.' && filename[1] == '_')
{
return 0;
}
return 1;
}
static int ventoy_browser_check_ignore(const char *device, const char *root, const char *dir)
{
grub_file_t file;
char fullpath[1024] = {0};
grub_snprintf(fullpath, 1023, "(%s)%s/%s/.ventoyignore", device, root, dir);
file = grub_file_open(fullpath, GRUB_FILE_TYPE_NONE);
if (!file)
{
grub_errno = 0;
return 0;
}
else
{
grub_file_close(file);
return 1;
}
}
static int ventoy_browser_iterate_dir(const char *filename, const struct grub_dirhook_info *info, void *data)
{
int type;
int len;
browser_node *node;
(void)data;
len = grub_strlen(filename);
if (info->dir)
{
if (!ventoy_browser_valid_dirname(filename, len))
{
return 0;
}
if (ventoy_browser_check_ignore(g_menu_device, g_menu_path_buf, filename))
{
return 0;
}
node = grub_zalloc(sizeof(browser_node));
if (!node)
{
return 0;
}
node->dir = 1;
grub_strncpy(node->filename, filename, sizeof(node->filename));
if (g_tree_view_menu_style == 0)
{
grub_snprintf(node->menuentry, sizeof(node->menuentry),
"menuentry \"%-10s [%s]\" --class=vtoydir {\n"
" vt_browser_dir %s 0x%lx \"%s/%s\"\n"
"}\n",
"DIR", filename, g_menu_device, (ulong)g_menu_fs, g_menu_path_buf, filename);
}
else
{
grub_snprintf(node->menuentry, sizeof(node->menuentry),
"menuentry \"[%s]\" --class=vtoydir {\n"
" vt_browser_dir %s 0x%lx \"%s/%s\"\n"
"}\n",
filename, g_menu_device, (ulong)g_menu_fs, g_menu_path_buf, filename);
}
}
else
{
grub_uint64_t fsize = info->size;
if (!ventoy_browser_valid_filename(filename, len, &type))
{
return 0;
}
if (grub_file_is_vlnk_suffix(filename, len))
{
return 0;
}
node = grub_zalloc(sizeof(browser_node));
if (!node)
{
return 0;
}
if (fsize == 0)
{
struct grub_file file;
grub_memset(&file, 0, sizeof(file));
file.device = g_menu_dev;
grub_snprintf(node->menuentry, sizeof(node->menuentry), "%s/%s", g_menu_path_buf, filename);
if (g_menu_fs->fs_open(&file, node->menuentry) == GRUB_ERR_NONE)
{
fsize = file.size;
g_menu_fs->fs_close(&file);
}
}
node->dir = 0;
grub_strncpy(node->filename, filename, sizeof(node->filename));
if (g_tree_view_menu_style == 0)
{
grub_snprintf(node->menuentry, sizeof(node->menuentry),
"menuentry \"%-10s %s\" --class=%s {\n"
" vt_set_fake_vlnk \"(%s)%s/%s\" %s %llu\n"
" %s_common_menuentry\n"
" vt_reset_fake_vlnk\n"
"}\n",
grub_get_human_size(fsize, GRUB_HUMAN_SIZE_SHORT), filename, g_menu_class[type],
g_menu_device, g_menu_path_buf, filename, g_menu_prefix[type], (ulonglong)fsize,
g_menu_prefix[type]);
}
else
{
grub_snprintf(node->menuentry, sizeof(node->menuentry),
"menuentry \"%s\" --class=%s {\n"
" vt_set_fake_vlnk \"(%s)%s/%s\" %s %llu\n"
" %s_common_menuentry\n"
" vt_reset_fake_vlnk\n"
"}\n",
filename, g_menu_class[type],
g_menu_device, g_menu_path_buf, filename, g_menu_prefix[type], (ulonglong)fsize,
g_menu_prefix[type]);
}
}
node->prev = NULL;
node->next = g_browser_list;
if (g_browser_list)
{
g_browser_list->prev = node;
}
g_browser_list = node;
return 0;
}
static grub_err_t ventoy_browser_iso_part(void)
{
char cfgfile[64];
char *buffer = NULL;
int pos = 0;
int buflen = 0;
int cfglen = 0;
cfglen = g_tree_script_pos - g_tree_script_pre;
buflen = cfglen + 512;
buffer = grub_malloc(buflen);
if (!buffer)
{
return 1;
}
if (g_tree_view_menu_style == 0)
{
pos = grub_snprintf(buffer, buflen, "menuentry \"%-10s [../]\" --class=\"vtoyret\" VTOY_RET {\n "
" echo 'return ...' \n}\n", "<--");
}
else
{
pos = grub_snprintf(buffer, buflen, "menuentry \"[../]\" --class=\"vtoyret\" VTOY_RET {\n "
" echo 'return ...' \n}\n");
}
grub_memcpy(buffer + pos, g_tree_script_buf + g_tree_script_pre, cfglen);
pos += cfglen;
grub_snprintf(cfgfile, sizeof(cfgfile), "configfile mem:0x%lx:size:%d", (ulong)buffer, pos);
grub_script_execute_sourcecode(cfgfile);
grub_free(buffer);
VENTOY_CMD_RETURN(GRUB_ERR_NONE);
}
grub_err_t ventoy_cmd_browser_dir(grub_extcmd_context_t ctxt, int argc, char **args)
{
int i;
grub_fs_t fs;
grub_device_t dev;
char cfgfile[64];
browser_node *node;
browser_mbuf mbuf;
(void)ctxt;
(void)argc;
if (args[2][0] == '/' && args[2][1] == 0)
{
grub_snprintf(cfgfile, sizeof(cfgfile), "(%s)", args[0]);
if (grub_strcmp(cfgfile, g_iso_path) == 0)
{
return ventoy_browser_iso_part();
}
}
if (!ventoy_browser_mbuf_alloc(&mbuf))
{
return 1;
}
fs = (grub_fs_t)grub_strtoul(args[1], NULL, 16);
if (!fs)
{
debug("Invalid fs %s\n", args[1]);
return 1;
}
dev = grub_device_open(args[0]);
if (!dev)
{
debug("Failed to open device %s\n", args[0]);
return 1;
}
g_menu_fs = fs;
g_menu_device = args[0];
g_menu_dev = dev;
g_browser_list = NULL;
if (args[2][0] == '/' && args[2][1] == 0)
{
g_menu_path_len = 0;
g_menu_path_buf[0] = 0;
fs->fs_dir(dev, "/", ventoy_browser_iterate_dir, NULL);
}
else
{
g_menu_path_len = grub_snprintf(g_menu_path_buf, sizeof(g_menu_path_buf), "%s", args[2]);
fs->fs_dir(dev, g_menu_path_buf, ventoy_browser_iterate_dir, NULL);
}
grub_device_close(dev);
if (g_tree_view_menu_style == 0)
{
browser_ssprintf(&mbuf, "menuentry \"%-10s [(%s)%s/..]\" --class=\"vtoyret\" VTOY_RET {\n "
" echo 'return ...' \n}\n", "<--", args[0], g_menu_path_buf);
}
else
{
browser_ssprintf(&mbuf, "menuentry \"[(%s)%s/..]\" --class=\"vtoyret\" VTOY_RET {\n "
" echo 'return ...' \n}\n", args[0], g_menu_path_buf);
}
for (i = 1; i >= 0; i--)
{
while (1)
{
node = ventoy_browser_find_top_node(i);
if (node)
{
browser_ssprintf(&mbuf, "%s", node->menuentry);
ventoy_browser_mbuf_extend(&mbuf);
if (node->prev)
{
node->prev->next = node->next;
}
if (node->next)
{
node->next->prev = node->prev;
}
if (node == g_browser_list)
{
g_browser_list = node->next;
}
grub_free(node);
}
else
{
break;
}
}
}
g_browser_list = NULL;
grub_snprintf(cfgfile, sizeof(cfgfile), "configfile mem:0x%lx:size:%d", (ulong)mbuf.buf, mbuf.pos);
grub_script_execute_sourcecode(cfgfile);
ventoy_browser_mbuf_free(&mbuf);
VENTOY_CMD_RETURN(GRUB_ERR_NONE);
}
grub_err_t ventoy_cmd_browser_disk(grub_extcmd_context_t ctxt, int argc, char **args)
{
char cfgfile[64];
browser_mbuf mbuf;
(void)ctxt;
(void)argc;
(void)args;
if (!ventoy_browser_mbuf_alloc(&mbuf))
{
return 1;
}
g_vtoy_dev = grub_env_get("vtoydev");
if (g_tree_view_menu_style == 0)
{
browser_ssprintf(&mbuf, "menuentry \"%-10s [%s]\" --class=\"vtoyret\" VTOY_RET {\n "
" echo 'return ...' \n}\n", "<--",
ventoy_get_vmenu_title("VTLANG_BROWER_RETURN"));
}
else
{
browser_ssprintf(&mbuf, "menuentry \"[%s]\" --class=\"vtoyret\" VTOY_RET {\n "
" echo 'return ...' \n}\n",
ventoy_get_vmenu_title("VTLANG_BROWER_RETURN"));
}
grub_disk_dev_iterate(ventoy_browser_iterate_disk, &mbuf);
grub_snprintf(cfgfile, sizeof(cfgfile), "configfile mem:0x%lx:size:%d", (ulong)mbuf.buf, mbuf.pos);
grub_script_execute_sourcecode(cfgfile);
ventoy_browser_mbuf_free(&mbuf);
VENTOY_CMD_RETURN(GRUB_ERR_NONE);
}

File diff suppressed because it is too large Load Diff

View File

@ -21,21 +21,31 @@
#ifndef __VENTOY_DEF_H__
#define __VENTOY_DEF_H__
#define VTOY_MAX_DIR_DEPTH 32
#define VTOY_MAX_SCRIPT_BUF (4 * 1024 * 1024)
#define VTOY_PART_BUF_LEN (128 * 1024)
#define VTOY_FILT_MIN_FILE_SIZE 32768
#define VTOY_LINUX_SYSTEMD_MENU_MAX_BUF 16384
#define VTOY_SIZE_1GB 1073741824
#define VTOY_SIZE_1MB (1024 * 1024)
#define VTOY_SIZE_2MB (2 * 1024 * 1024)
#define VTOY_SIZE_4MB (4 * 1024 * 1024)
#define VTOY_SIZE_512KB (512 * 1024)
#define VTOY_SIZE_1KB 1024
#define VTOY_SIZE_32KB (32 * 1024)
#define VTOY_SIZE_128KB (128 * 1024)
#define JSON_SUCCESS 0
#define JSON_FAILED 1
#define JSON_NOT_FOUND 2
#define WINDATA_FLAG_TEMPLATE 1
#define ulong unsigned long
#define ulonglong unsigned long long
@ -52,6 +62,8 @@
#define VTOY_WARNING "!!!!!!!!!!!!! WARNING !!!!!!!!!!!!!"
#define VTOY_CHKSUM_NUM 4
#define VTOY_PLAT_I386_UEFI 0x49413332
#define VTOY_PLAT_ARM64_UEFI 0x41413634
#define VTOY_PLAT_X86_64_UEFI 0x55454649
@ -67,6 +79,13 @@
#define VTOY_ARCH_CPIO "ventoy_x86.cpio"
#endif
#define ventoy_left_key "VTLE_LFT"
#define ventoy_top_key "VTLE_TOP"
#define ventoy_color_key "VTLE_CLR"
#define ventoy_varg_4(arg) arg[0], arg[1], arg[2], arg[3]
#define ventoy_varg_8(arg) arg[0], arg[1], arg[2], arg[3], arg[4], arg[5], arg[6], arg[7]
#define VTOY_PWD_CORRUPTED(err) \
{\
grub_printf("\n\n Password corrupted, will reboot after 5 seconds.\n\n"); \
@ -76,6 +95,38 @@
return (err);\
}
#define VTOY_APPEND_NEWBUF(buf) \
{\
char *__c = buf;\
while (*__c)\
{\
newbuf[pos++] = *__c;\
__c++;\
}\
}
#define VTOY_SKIP_SPACE(s) \
while (ventoy_isspace(*s)) \
{\
s++;\
}
#define VTOY_SKIP_SPACE_NEXT(s, initial) \
s += initial;\
while (ventoy_isspace(*s)) \
{\
s++;\
}
#define VTOY_SKIP_SPACE_NEXT_EX(s, base, initial) \
s = base + initial;\
while (ventoy_isspace(*s)) \
{\
s++;\
}
#define VTOY_GOTO_END(v) ret = v; goto end
typedef enum VTOY_FILE_FLT
{
VTOY_FILE_FLT_ISO = 0, /* .iso */
@ -140,6 +191,7 @@ typedef struct cpio_newc_header
typedef int (*grub_char_check_func)(int c);
#define ventoy_is_decimal(str) ventoy_string_check(str, grub_isdigit)
#define OFFSET_OF(TYPE, MEMBER) ((grub_size_t) &((TYPE *)0)->MEMBER)
#pragma pack(1)
typedef struct ventoy_patch_vhd
@ -191,14 +243,28 @@ typedef struct ventoy_iso9660_vd
grub_uint32_t space;
}ventoy_iso9660_vd;
/* https://wiki.osdev.org/El-Torito */
typedef struct boot_info_table
{
grub_uint32_t bi_data0;
grub_uint32_t bi_data1;
grub_uint32_t bi_PrimaryVolumeDescriptor;
grub_uint32_t bi_BootFileLocation;
grub_uint32_t bi_BootFileLength;
grub_uint32_t bi_Checksum;
grub_uint8_t bi_Reserved[40];
}boot_info_table;
#pragma pack()
#define img_type_iso 0
#define img_type_wim 1
#define img_type_efi 2
#define img_type_img 3
#define img_type_vhd 4
#define img_type_vtoy 5
#define img_type_start 0
#define img_type_iso 0
#define img_type_wim 1
#define img_type_efi 2
#define img_type_img 3
#define img_type_vhd 4
#define img_type_vtoy 5
#define img_type_max 6
typedef struct img_info
{
@ -207,6 +273,8 @@ typedef struct img_info
char name[256];
const char *alias;
const char *tip1;
const char *tip2;
const char *class;
const char *menu_prefix;
@ -280,14 +348,26 @@ extern ventoy_guid g_ventoy_guid;
extern ventoy_img_chunk_list g_img_chunk_list;
extern ventoy_img_chunk_list g_wimiso_chunk_list;
extern char *g_wimiso_path;
extern grub_uint32_t g_wimiso_size;
extern char g_arch_mode_suffix[64];
extern const char *g_menu_prefix[img_type_max];
extern int g_ventoy_debug;
void ventoy_debug(const char *fmt, ...);
#define debug(fmt, ...) if (g_ventoy_debug) ventoy_debug("[VTOY]: "fmt, __VA_ARGS__)
#define debug(fmt, args...) if (g_ventoy_debug) ventoy_debug("[VTOY]: "fmt, ##args)
#define vtoy_ssprintf(buf, pos, fmt, args...) \
pos += grub_snprintf(buf + pos, VTOY_MAX_SCRIPT_BUF - pos, fmt, ##args)
#define vtoy_len_ssprintf(buf, pos, len, fmt, args...) \
pos += grub_snprintf(buf + pos, len - pos, fmt, ##args)
#define browser_ssprintf(mbuf, fmt, args...) \
(mbuf)->pos += grub_snprintf((mbuf)->buf + (mbuf)->pos, (mbuf)->max - (mbuf)->pos, fmt, ##args)
#define vtoy_dummy_menuentry(buf, pos, len, title, class) \
vtoy_len_ssprintf(buf, pos, len, "menuentry \"%s\" --class=\"%s\" {\n echo \"\"\n}\n", title, class)
#define vtoy_ssprintf(buf, pos, fmt, ...) \
pos += grub_snprintf(buf + pos, VTOY_MAX_SCRIPT_BUF - pos, fmt, __VA_ARGS__)
#define FLAG_HEADER_RESERVED 0x00000001
#define FLAG_HEADER_COMPRESSION 0x00000002
@ -390,6 +470,15 @@ typedef struct wim_security_header
grub_uint32_t count; /* Number of entries */
}wim_security_header;
typedef struct wim_stream_entry
{
grub_uint64_t len;
grub_uint64_t unused1;
wim_hash hash;
grub_uint16_t name_len;
/* name */
}wim_stream_entry;
/* Directory entry */
typedef struct wim_directory_entry
{
@ -414,6 +503,18 @@ typedef struct wim_directory_entry
/** No security information exists for this file */
#define WIM_NO_SECURITY 0xffffffffUL
typedef struct reg_vk
{
grub_uint32_t res1;
grub_uint16_t sig;
grub_uint16_t namesize;
grub_uint32_t datasize;
grub_uint32_t dataoffset;
grub_uint32_t datatype;
grub_uint16_t flag;
grub_uint16_t res2;
}reg_vk;
#pragma pack()
@ -437,6 +538,7 @@ typedef struct wim_tail
grub_uint8_t *jump_bin_data;
grub_uint32_t bin_raw_len;
grub_uint32_t bin_align_len;
grub_uint32_t windata_flag;
grub_uint8_t *new_meta_data;
grub_uint32_t new_meta_len;
@ -516,9 +618,34 @@ typedef struct plugin_entry
const char *key;
ventoy_plugin_entry_pf entryfunc;
ventoy_plugin_check_pf checkfunc;
int flag;
}plugin_entry;
typedef struct replace_fs_dir
{
grub_device_t dev;
grub_fs_t fs;
char fullpath[512];
char initrd[512];
int curpos;
int dircnt;
int filecnt;
}replace_fs_dir;
typedef struct chk_case_fs_dir
{
grub_device_t dev;
grub_fs_t fs;
}chk_case_fs_dir;
int ventoy_str_all_digit(const char *str);
int ventoy_str_all_alnum(const char *str);
int ventoy_str_len_alnum(const char *str, int len);
char * ventoy_str_basename(char *path);
grub_err_t ventoy_env_int_set(const char *name, int value);
int ventoy_str_chrcnt(const char *str, char c);
int ventoy_strcmp(const char *pattern, const char *str);
int ventoy_strncmp (const char *pattern, const char *str, grub_size_t n);
void ventoy_fill_os_param(grub_file_t file, ventoy_os_param *param);
grub_err_t ventoy_cmd_isolinux_initrd_collect(grub_extcmd_context_t ctxt, int argc, char **args);
grub_err_t ventoy_cmd_grub_initrd_collect(grub_extcmd_context_t ctxt, int argc, char **args);
@ -528,25 +655,34 @@ grub_err_t ventoy_cmd_clear_initrd_list(grub_extcmd_context_t ctxt, int argc, ch
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);
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_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_initrd_count(grub_extcmd_context_t ctxt, int argc, char **args);
grub_err_t ventoy_cmd_valid_initrd_count(grub_extcmd_context_t ctxt, int argc, char **args);
grub_err_t ventoy_cmd_load_cpio(grub_extcmd_context_t ctxt, int argc, char **args);
grub_err_t ventoy_cmd_append_ext_sector(grub_extcmd_context_t ctxt, int argc, char **args);
grub_err_t ventoy_cmd_skip_svd(grub_extcmd_context_t ctxt, int argc, char **args);
grub_err_t ventoy_cmd_cpio_busybox_64(grub_extcmd_context_t ctxt, int argc, char **args);
grub_err_t ventoy_cmd_trailer_cpio(grub_extcmd_context_t ctxt, int argc, char **args);
int ventoy_cpio_newc_fill_head(void *buf, int filesize, const void *filedata, const char *name);
grub_file_t ventoy_grub_file_open(enum grub_file_type type, const char *fmt, ...);
grub_uint64_t ventoy_grub_get_file_size(const char *fmt, ...);
int ventoy_is_file_exist(const char *fmt, ...);
int ventoy_is_dir_exist(const char *fmt, ...);
int ventoy_fill_data(grub_uint32_t buflen, char *buffer);
grub_err_t ventoy_cmd_load_plugin(grub_extcmd_context_t ctxt, int argc, char **args);
grub_err_t ventoy_cmd_wimdows_reset(grub_extcmd_context_t ctxt, int argc, char **args);
grub_err_t ventoy_cmd_is_pe64(grub_extcmd_context_t ctxt, int argc, char **args);
grub_err_t ventoy_cmd_windows_chain_data(grub_extcmd_context_t ctxt, int argc, char **args);
grub_err_t ventoy_cmd_windows_wimboot_data(grub_extcmd_context_t ctxt, int argc, char **args);
grub_err_t ventoy_cmd_wim_chain_data(grub_extcmd_context_t ctxt, int argc, char **args);
grub_err_t ventoy_cmd_wim_check_bootable(grub_extcmd_context_t ctxt, int argc, char **args);
grub_err_t ventoy_cmd_is_standard_winiso(grub_extcmd_context_t ctxt, int argc, char **args);
grub_err_t ventoy_cmd_dump_wim_patch(grub_extcmd_context_t ctxt, int argc, char **args);
grub_err_t ventoy_cmd_sel_wimboot(grub_extcmd_context_t ctxt, int argc, char **args);
grub_err_t ventoy_cmd_set_wim_prompt(grub_extcmd_context_t ctxt, int argc, char **args);
grub_ssize_t ventoy_load_file_with_prompt(grub_file_t file, void *buf, grub_ssize_t size);
int ventoy_need_prompt_load_file(void);
VTOY_JSON *vtoy_json_find_item
(
@ -725,7 +861,8 @@ typedef struct vhd_footer_t
grub_uint8_t savedst; // Saved state
}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. */
#define VDI_IMAGE_SIGNATURE (0xbeda107f)
@ -754,18 +891,32 @@ typedef struct ventoy_video_mode
typedef struct file_fullpath
{
char path[256];
int vlnk_add;
}file_fullpath;
typedef struct theme_list
{
file_fullpath theme;
struct theme_list *next;
}theme_list;
#define auto_install_type_file 0
#define auto_install_type_parent 1
typedef struct install_template
{
int type;
int pathlen;
char isopath[256];
int timeout;
int autosel;
int cursel;
int templatenum;
file_fullpath *templatepath;
char *filebuf;
int filelen;
struct install_template *next;
}install_template;
@ -792,6 +943,7 @@ typedef struct persistence_config
int pathlen;
char isopath[256];
int timeout;
int autosel;
int cursel;
int backendnum;
@ -813,6 +965,20 @@ typedef struct menu_alias
struct menu_alias *next;
}menu_alias;
#define vtoy_tip_image_file 0
#define vtoy_tip_directory 1
typedef struct menu_tip
{
int type;
int pathlen;
char isopath[256];
char tip1[1024];
char tip2[1024];
struct menu_tip *next;
}menu_tip;
#define vtoy_class_image_file 0
#define vtoy_class_directory 1
@ -820,6 +986,7 @@ typedef struct menu_class
{
int type;
int patlen;
int parent;
char pattern[256];
char class[64];
@ -839,10 +1006,11 @@ typedef struct custom_boot
struct custom_boot *next;
}custom_boot;
#define vtoy_max_replace_file_size (2 * 1024 * 1024)
#define vtoy_max_replace_file_size (1024 * 1024)
typedef struct conf_replace
{
int pathlen;
int img;
char isopath[256];
char orgconf[256];
char newconf[256];
@ -850,8 +1018,11 @@ typedef struct conf_replace
struct conf_replace *next;
}conf_replace;
#define injection_type_file 0
#define injection_type_parent 1
typedef struct injection_config
{
int type;
int pathlen;
char isopath[256];
char archive[256];
@ -888,8 +1059,12 @@ typedef struct vtoy_password
grub_uint8_t md5[16];
}vtoy_password;
#define vtoy_menu_pwd_file 0
#define vtoy_menu_pwd_parent 1
typedef struct menu_password
{
int type;
int pathlen;
char isopath[256];
@ -899,27 +1074,39 @@ typedef struct menu_password
}menu_password;
extern int g_ventoy_menu_esc;
extern int g_ventoy_secondary_menu_on;
extern int g_ventoy_suppress_esc;
extern int g_ventoy_suppress_esc_default;
extern int g_ventoy_last_entry;
extern int g_ventoy_memdisk_mode;
extern int g_ventoy_iso_raw;
extern int g_ventoy_grub2_mode;
extern int g_ventoy_wimboot_mode;
extern int g_ventoy_iso_uefi_drv;
extern int g_ventoy_case_insensitive;
extern int g_ventoy_fn_mutex;
extern grub_uint8_t g_ventoy_chain_type;
extern int g_vhdboot_enable;
extern int g_default_menu_mode;
extern char g_ventoy_hotkey_tip[256];
extern int g_ventoy_menu_refresh;
#define VENTOY_IMG_WHITE_LIST 1
#define VENTOY_IMG_BLACK_LIST 2
extern int g_plugin_image_list;
extern ventoy_gpt_info *g_ventoy_part_info;
extern grub_uint64_t g_conf_replace_offset;
extern int g_conf_replace_count;
extern grub_uint64_t g_conf_replace_offset[VTOY_MAX_CONF_REPLACE];
extern grub_uint64_t g_svd_replace_offset;
extern conf_replace *g_conf_replace_node;
extern grub_uint8_t *g_conf_replace_new_buf;
extern int g_conf_replace_new_len;
extern int g_conf_replace_new_len_align;
extern conf_replace *g_conf_replace_node[VTOY_MAX_CONF_REPLACE];
extern grub_uint8_t *g_conf_replace_new_buf[VTOY_MAX_CONF_REPLACE];
extern int g_conf_replace_new_len[VTOY_MAX_CONF_REPLACE];
extern int g_conf_replace_new_len_align[VTOY_MAX_CONF_REPLACE];
extern int g_ventoy_disk_bios_id;
extern grub_uint64_t g_ventoy_disk_size;
extern grub_uint64_t g_ventoy_disk_part_size[2];
extern grub_uint32_t g_ventoy_plat_data;
#define ventoy_unix_fill_virt(new_data, new_len) \
{ \
@ -937,42 +1124,57 @@ extern grub_uint64_t g_ventoy_disk_size;
chain->virt_img_size_in_bytes += data_secs * 2048; \
}
#define ventoy_syscall0(name) grub_##name()
#define ventoy_syscall1(name, a) grub_##name(a)
void ventoy_str_tolower(char *str);
void ventoy_str_toupper(char *str);
char * ventoy_get_line(char *start);
char *ventoy_str_last(char *str, char ch);
int ventoy_cmp_img(img_info *img1, img_info *img2);
void ventoy_swap_img(img_info *img1, img_info *img2);
char * ventoy_plugin_get_cur_install_template(const char *isopath);
char * ventoy_plugin_get_cur_install_template(const char *isopath, install_template **cur);
install_template * ventoy_plugin_find_install_template(const char *isopath);
persistence_config * ventoy_plugin_find_persistent(const char *isopath);
grub_uint64_t ventoy_get_vtoy_partsize(int part);
void ventoy_plugin_dump_injection(void);
void ventoy_plugin_dump_auto_install(void);
int ventoy_fill_windows_rtdata(void *buf, char *isopath);
int ventoy_plugin_get_persistent_chunklist(const char *isopath, int index, ventoy_img_chunk_list *chunk_list);
const char * ventoy_plugin_get_injection(const char *isopath);
const char * ventoy_plugin_get_menu_alias(int type, const char *isopath);
const char * ventoy_plugin_get_menu_class(int type, const char *name);
const menu_tip * ventoy_plugin_get_menu_tip(int type, const char *isopath);
const char * ventoy_plugin_get_menu_class(int type, const char *name, const char *path);
int ventoy_plugin_check_memdisk(const char *isopath);
int ventoy_plugin_get_image_list_index(int type, const char *name);
conf_replace * ventoy_plugin_find_conf_replace(const char *iso);
int ventoy_plugin_find_conf_replace(const char *iso, conf_replace *nodes[VTOY_MAX_CONF_REPLACE]);
dud * ventoy_plugin_find_dud(const char *iso);
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_check_block_list(grub_file_t file, ventoy_img_chunk_list *chunklist, grub_disk_addr_t start);
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_path(grub_extcmd_context_t ctxt, int argc, char **args);
grub_err_t ventoy_cmd_select_theme_cfg(grub_extcmd_context_t ctxt, int argc, char **args);
grub_err_t ventoy_cmd_plugin_check_json(grub_extcmd_context_t ctxt, int argc, char **args);
grub_err_t ventoy_cmd_check_password(grub_extcmd_context_t ctxt, int argc, char **args);
grub_err_t ventoy_cmd_linux_get_main_initrd_index(grub_extcmd_context_t ctxt, int argc, char **args);
grub_err_t ventoy_cmd_collect_wim_patch(grub_extcmd_context_t ctxt, int argc, char **args);
grub_err_t ventoy_cmd_wim_patch_count(grub_extcmd_context_t ctxt, int argc, char **args);
grub_err_t ventoy_cmd_locate_wim_patch(grub_extcmd_context_t ctxt, int argc, char **args);
grub_err_t ventoy_cmd_sel_winpe_wim(grub_extcmd_context_t ctxt, int argc, char **args);
grub_err_t ventoy_cmd_unix_chain_data(grub_extcmd_context_t ctxt, int argc, char **args);
int ventoy_get_disk_guid(const char *filename, grub_uint8_t *guid, grub_uint8_t *signature);
grub_err_t ventoy_cmd_unix_reset(grub_extcmd_context_t ctxt, int argc, char **args);
grub_err_t ventoy_cmd_unix_check_vlnk(grub_extcmd_context_t ctxt, int argc, char **args);
grub_err_t ventoy_cmd_unix_replace_conf(grub_extcmd_context_t ctxt, int argc, char **args);
grub_err_t ventoy_cmd_unix_replace_grub_conf(grub_extcmd_context_t ctxt, int argc, char **args);
grub_err_t ventoy_cmd_unix_replace_ko(grub_extcmd_context_t ctxt, int argc, char **args);
grub_err_t ventoy_cmd_unix_ko_fillmap(grub_extcmd_context_t ctxt, int argc, char **args);
grub_err_t ventoy_cmd_unix_fill_image_desc(grub_extcmd_context_t ctxt, int argc, char **args);
grub_err_t ventoy_cmd_unix_gzip_newko(grub_extcmd_context_t ctxt, int argc, char **args);
grub_err_t ventoy_cmd_unix_freebsd_ver(grub_extcmd_context_t ctxt, int argc, char **args);
grub_err_t ventoy_cmd_parse_freenas_ver(grub_extcmd_context_t ctxt, int argc, char **args);
grub_err_t ventoy_cmd_unix_freebsd_ver_elf(grub_extcmd_context_t ctxt, int argc, char **args);
int ventoy_check_device_result(int ret);
int ventoy_check_device(grub_device_t dev);
void ventoy_debug_dump_guid(const char *prefix, grub_uint8_t *guid);
@ -981,11 +1183,140 @@ grub_err_t ventoy_cmd_patch_vhdboot(grub_extcmd_context_t ctxt, int argc, char *
grub_err_t ventoy_cmd_raw_chain_data(grub_extcmd_context_t ctxt, int argc, char **args);
grub_err_t ventoy_cmd_get_vtoy_type(grub_extcmd_context_t ctxt, int argc, char **args);
int ventoy_check_password(const vtoy_password *pwd, int retry);
int ventoy_gzip_compress(void *mem_in, int mem_in_len, void *mem_out, int mem_out_len);
grub_uint64_t ventoy_get_part1_size(ventoy_gpt_info *gpt);
int ventoy_plugin_add_custom_boot(const char *vcfgpath);
const char * ventoy_plugin_get_custom_boot(const char *isopath);
grub_err_t ventoy_cmd_dump_custom_boot(grub_extcmd_context_t ctxt, int argc, char **args);
int ventoy_gzip_compress(void *mem_in, int mem_in_len, void *mem_out, int mem_out_len);
int ventoy_load_part_table(const char *diskname);
int ventoy_env_init(void);
int ventoy_register_all_cmd(void);
int ventoy_unregister_all_cmd(void);
int ventoy_chain_file_size(const char *path);
int ventoy_chain_file_read(const char *path, int offset, int len, void *buf);
#define VTOY_CMD_CHECK(a) if (33554432 != g_ventoy_disk_part_size[a]) ventoy_syscall0(exit)
#define vtoy_theme_random_boot_second 0
#define vtoy_theme_random_boot_day 1
#define vtoy_theme_random_boot_month 2
#define ventoy_env_export(env, name) \
{\
grub_env_set((env), (name));\
grub_env_export(env);\
}
#define ret_goto_end(a) ret = a; goto end;
extern ventoy_grub_param *g_grub_param;
#pragma pack(1)
#define VENTOY_UNIX_SEG_MAGIC0 0x11223344
#define VENTOY_UNIX_SEG_MAGIC1 0x55667788
#define VENTOY_UNIX_SEG_MAGIC2 0x99aabbcc
#define VENTOY_UNIX_SEG_MAGIC3 0xddeeff00
#define VENTOY_UNIX_MAX_SEGNUM 40960
struct g_ventoy_seg {
grub_uint64_t seg_start_bytes;
grub_uint64_t seg_end_bytes;
};
struct g_ventoy_map{
grub_uint32_t magic1[4];
grub_uint32_t magic2[4];
grub_uint64_t segnum;
grub_uint64_t disksize;
grub_uint8_t diskuuid[16];
struct g_ventoy_seg seglist[VENTOY_UNIX_MAX_SEGNUM];
grub_uint32_t magic3[4];
};
#pragma pack()
typedef struct ventoy_vlnk_part
{
grub_uint32_t disksig;
grub_uint64_t partoffset;
char disk[64];
char device[64];
grub_device_t dev;
grub_fs_t fs;
int probe;
struct ventoy_vlnk_part *next;
}ventoy_vlnk_part;
typedef struct browser_mbuf
{
int max;
int pos;
char *buf;
}browser_mbuf;
typedef struct browser_node
{
int dir;
char menuentry[1024];
char filename[512];
struct browser_node *prev;
struct browser_node *next;
}browser_node;
typedef struct var_node
{
char var[128];
char val[256];
struct var_node *next;
}var_node;
typedef struct systemd_menu_ctx
{
char *dev;
char *buf;
int pos;
int len;
}systemd_menu_ctx;
typedef struct global_var_cfg
{
const char *name;
const char *defval;
char *value;
}global_var_cfg;
typedef struct ctrl_var_cfg
{
const char *name;
int value;
}ctrl_var_cfg;
#define vtoy_check_goto_out(p) if (!p) goto out
extern char *g_tree_script_buf;
extern int g_tree_script_pos;
extern int g_tree_script_pre;
extern int g_tree_view_menu_style;
extern int g_sort_case_sensitive;
extern int g_wimboot_enable;
extern int g_filt_dot_underscore_file;
extern int g_filt_trash_dir;
extern int g_vtoy_file_flt[VTOY_FILE_FLT_BUTT];
extern const char *g_menu_class[img_type_max];
extern char g_iso_path[256];
int ventoy_add_vlnk_file(char *dir, const char *name);
grub_err_t ventoy_cmd_browser_dir(grub_extcmd_context_t ctxt, int argc, char **args);
grub_err_t ventoy_cmd_browser_disk(grub_extcmd_context_t ctxt, int argc, char **args);
int ventoy_get_fs_type(const char *fs);
int ventoy_img_name_valid(const char *filename, grub_size_t namelen);
void * ventoy_alloc_chain(grub_size_t size);
int ventoy_plugin_load_menu_lang(int init, const char *lang);
const char *ventoy_get_vmenu_title(const char *vMenu);
grub_err_t ventoy_cmd_cur_menu_lang(grub_extcmd_context_t ctxt, int argc, char **args);
extern int ventoy_menu_push_key(int code);
int ventoy_ctrl_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_pop_menulang(grub_extcmd_context_t ctxt, int argc, char **args);
#endif /* __VENTOY_DEF_H__ */

View File

@ -152,6 +152,23 @@ static int vtoy_json_parse_string
return JSON_FAILED;
}
if (*(pcPos - 1) == '\\')
{
for (pcPos++; *pcPos; pcPos++)
{
if (*pcPos == '"' && *(pcPos - 1) != '\\')
{
break;
}
}
if (*pcPos == 0 || pcPos < pcTmp)
{
json_debug("Invalid quotes string %s.", pcData);
return JSON_FAILED;
}
}
*ppcEnd = pcPos + 1;
uiLen = (grub_uint32_t)(unsigned long)(pcPos - pcTmp);

View File

@ -38,6 +38,9 @@
GRUB_MOD_LICENSE ("GPLv3+");
#define VTOY_APPEND_EXT_SIZE 4096
static int g_append_ext_sector = 0;
char * ventoy_get_line(char *start)
{
if (start == NULL)
@ -174,10 +177,7 @@ static grub_err_t ventoy_isolinux_initrd_collect(grub_file_t file, const char *p
{
nextline = ventoy_get_line(start);
while (ventoy_isspace(*start))
{
start++;
}
VTOY_SKIP_SPACE(start);
offset = 7; // strlen("initrd=") or "INITRD " or "initrd "
pos = grub_strstr(start, "initrd=");
@ -330,10 +330,84 @@ end:
VENTOY_CMD_RETURN(GRUB_ERR_NONE);
}
static int ventoy_linux_initrd_collect_hook(const char *filename, const struct grub_dirhook_info *info, void *data)
{
int len;
initrd_info *img = NULL;
(void)data;
if (0 == info->dir)
{
if (grub_strncmp(filename, "initrd", 6) == 0)
{
len = (int)grub_strlen(filename);
if (grub_strcmp(filename + len - 4, ".img") == 0)
{
img = grub_zalloc(sizeof(initrd_info));
if (img)
{
grub_snprintf(img->name, sizeof(img->name), "/boot/%s", filename);
if (ventoy_find_initrd_by_name(g_initrd_img_list, img->name))
{
grub_free(img);
}
else
{
if (g_initrd_img_list)
{
img->prev = g_initrd_img_tail;
g_initrd_img_tail->next = img;
}
else
{
g_initrd_img_list = img;
}
g_initrd_img_tail = img;
g_initrd_img_count++;
}
}
}
}
}
return 0;
}
static int ventoy_linux_collect_boot_initrds(void)
{
grub_fs_t fs;
grub_device_t dev = NULL;
dev = grub_device_open("loop");
if (!dev)
{
debug("failed to open device loop\n");
goto end;
}
fs = grub_fs_probe(dev);
if (!fs)
{
debug("failed to probe fs %d\n", grub_errno);
goto end;
}
fs->fs_dir(dev, "/boot", ventoy_linux_initrd_collect_hook, NULL);
end:
return 0;
}
static grub_err_t ventoy_grub_cfg_initrd_collect(const char *fileName)
{
int i = 0;
int len = 0;
int dollar = 0;
int quotation = 0;
int initrd_dollar = 0;
grub_file_t file = NULL;
char *buf = NULL;
char *start = NULL;
@ -361,10 +435,7 @@ static grub_err_t ventoy_grub_cfg_initrd_collect(const char *fileName)
{
nextline = ventoy_get_line(start);
while (ventoy_isspace(*start))
{
start++;
}
VTOY_SKIP_SPACE(start);
if (grub_strncmp(start, "initrd", 6) != 0)
{
@ -377,8 +448,11 @@ static grub_err_t ventoy_grub_cfg_initrd_collect(const char *fileName)
start++;
}
while (ventoy_isspace(*start))
VTOY_SKIP_SPACE(start);
if (*start == '"')
{
quotation = 1;
start++;
}
@ -400,6 +474,29 @@ static grub_err_t ventoy_grub_cfg_initrd_collect(const char *fileName)
}
}
if (quotation)
{
len = (int)grub_strlen(img->name);
if (len > 2 && img->name[len - 1] == '"')
{
img->name[len - 1] = 0;
}
debug("Remove quotation <%s>\n", img->name);
}
/* special process for /boot/initrd$XXX.img */
if (dollar == 1)
{
if (grub_strncmp(img->name, "/boot/initrd$", 13) == 0)
{
len = (int)grub_strlen(img->name);
if (grub_strcmp(img->name + len - 4, ".img") == 0)
{
initrd_dollar++;
}
}
}
if (dollar == 1 || ventoy_find_initrd_by_name(g_initrd_img_list, img->name))
{
grub_free(img);
@ -422,10 +519,7 @@ static grub_err_t ventoy_grub_cfg_initrd_collect(const char *fileName)
if (*start == ' ' || *start == '\t')
{
while (ventoy_isspace(*start))
{
start++;
}
VTOY_SKIP_SPACE(start);
}
else
{
@ -437,6 +531,12 @@ static grub_err_t ventoy_grub_cfg_initrd_collect(const char *fileName)
grub_free(buf);
grub_file_close(file);
if (initrd_dollar > 0 && grub_strncmp(fileName, "(loop)/", 7) == 0)
{
debug("collect initrd variable %d\n", initrd_dollar);
ventoy_linux_collect_boot_initrds();
}
VENTOY_CMD_RETURN(GRUB_ERR_NONE);
}
@ -633,9 +733,21 @@ int ventoy_cpio_newc_fill_head(void *buf, int filesize, const void *filedata, co
static grub_uint32_t ventoy_linux_get_virt_chunk_count(void)
{
int i;
grub_uint32_t count = g_valid_initrd_count;
if (g_conf_replace_offset > 0)
if (g_conf_replace_count > 0)
{
for (i = 0; i < g_conf_replace_count; i++)
{
if (g_conf_replace_offset[i] > 0)
{
count++;
}
}
}
if (g_append_ext_sector > 0)
{
count++;
}
@ -645,13 +757,25 @@ static grub_uint32_t ventoy_linux_get_virt_chunk_count(void)
static grub_uint32_t ventoy_linux_get_virt_chunk_size(void)
{
int i;
grub_uint32_t size;
size = (sizeof(ventoy_virt_chunk) + g_ventoy_cpio_size) * g_valid_initrd_count;
if (g_conf_replace_offset > 0)
if (g_conf_replace_count > 0)
{
size += sizeof(ventoy_virt_chunk) + g_conf_replace_new_len_align;
for (i = 0; i < g_conf_replace_count; i++)
{
if (g_conf_replace_offset[i] > 0)
{
size += sizeof(ventoy_virt_chunk) + g_conf_replace_new_len_align[i];
}
}
}
if (g_append_ext_sector > 0)
{
size += sizeof(ventoy_virt_chunk) + VTOY_APPEND_EXT_SIZE;
}
return size;
@ -659,7 +783,9 @@ static grub_uint32_t ventoy_linux_get_virt_chunk_size(void)
static void ventoy_linux_fill_virt_data( grub_uint64_t isosize, ventoy_chain_head *chain)
{
int i = 0;
int id = 0;
int virtid = 0;
initrd_info *node;
grub_uint64_t sector;
grub_uint32_t offset;
@ -667,6 +793,7 @@ static void ventoy_linux_fill_virt_data( grub_uint64_t isosize, ventoy_chain_
grub_uint32_t initrd_secs;
char *override;
ventoy_virt_chunk *cur;
ventoy_grub_param_file_replace *replace = NULL;
char name[32];
override = (char *)chain + chain->virt_chunk_offset;
@ -707,11 +834,13 @@ static void ventoy_linux_fill_virt_data( grub_uint64_t isosize, ventoy_chain_
offset += g_ventoy_cpio_size;
sector += cpio_secs + initrd_secs;
cur++;
virtid++;
}
if (g_conf_replace_offset > 0)
/* Lenovo EasyStartup need an addional sector for boundary check */
if (g_append_ext_sector > 0)
{
cpio_secs = g_conf_replace_new_len_align / 2048;
cpio_secs = VTOY_APPEND_EXT_SIZE / 2048;
cur->mem_sector_start = sector;
cur->mem_sector_end = cur->mem_sector_start + cpio_secs;
@ -720,13 +849,47 @@ static void ventoy_linux_fill_virt_data( grub_uint64_t isosize, ventoy_chain_
cur->remap_sector_end = 0;
cur->org_sector_start = 0;
grub_memcpy(override + offset, g_conf_replace_new_buf, g_conf_replace_new_len);
grub_memset(override + offset, 0, VTOY_APPEND_EXT_SIZE);
chain->virt_img_size_in_bytes += g_conf_replace_new_len_align;
chain->virt_img_size_in_bytes += VTOY_APPEND_EXT_SIZE;
offset += g_conf_replace_new_len_align;
offset += VTOY_APPEND_EXT_SIZE;
sector += cpio_secs;
cur++;
virtid++;
}
if (g_conf_replace_count > 0)
{
for (i = 0; i < g_conf_replace_count; i++)
{
if (g_conf_replace_offset[i] > 0)
{
cpio_secs = g_conf_replace_new_len_align[i] / 2048;
cur->mem_sector_start = sector;
cur->mem_sector_end = cur->mem_sector_start + cpio_secs;
cur->mem_sector_offset = offset;
cur->remap_sector_start = 0;
cur->remap_sector_end = 0;
cur->org_sector_start = 0;
grub_memcpy(override + offset, g_conf_replace_new_buf[i], g_conf_replace_new_len[i]);
chain->virt_img_size_in_bytes += g_conf_replace_new_len_align[i];
replace = g_grub_param->img_replace + i;
if (replace->magic == GRUB_IMG_REPLACE_MAGIC)
{
replace->new_file_virtual_id = virtid;
}
offset += g_conf_replace_new_len_align[i];
sector += cpio_secs;
cur++;
virtid++;
}
}
}
return;
@ -734,11 +897,18 @@ static void ventoy_linux_fill_virt_data( grub_uint64_t isosize, ventoy_chain_
static grub_uint32_t ventoy_linux_get_override_chunk_count(void)
{
int i;
grub_uint32_t count = g_valid_initrd_count;
if (g_conf_replace_offset > 0)
if (g_conf_replace_count > 0)
{
count++;
for (i = 0; i < g_conf_replace_count; i++)
{
if (g_conf_replace_offset[i] > 0)
{
count++;
}
}
}
if (g_svd_replace_offset > 0)
@ -751,11 +921,18 @@ static grub_uint32_t ventoy_linux_get_override_chunk_count(void)
static grub_uint32_t ventoy_linux_get_override_chunk_size(void)
{
int i;
int count = g_valid_initrd_count;
if (g_conf_replace_offset > 0)
if (g_conf_replace_count > 0)
{
count++;
for (i = 0; i < g_conf_replace_count; i++)
{
if (g_conf_replace_offset[i] > 0)
{
count++;
}
}
}
if (g_svd_replace_offset > 0)
@ -768,6 +945,7 @@ static grub_uint32_t ventoy_linux_get_override_chunk_size(void)
static void ventoy_linux_fill_override_data( grub_uint64_t isosize, void *override)
{
int i;
initrd_info *node;
grub_uint32_t mod;
grub_uint32_t newlen;
@ -822,23 +1000,29 @@ static void ventoy_linux_fill_override_data( grub_uint64_t isosize, void *ove
cur++;
}
if (g_conf_replace_offset > 0)
{
cur->img_offset = g_conf_replace_offset;
cur->override_size = sizeof(ventoy_iso9660_override);
if (g_conf_replace_count > 0)
{
for (i = 0; i < g_conf_replace_count; i++)
{
if (g_conf_replace_offset[i] > 0)
{
cur->img_offset = g_conf_replace_offset[i];
cur->override_size = sizeof(ventoy_iso9660_override);
newlen = (grub_uint32_t)(g_conf_replace_new_len);
newlen = (grub_uint32_t)(g_conf_replace_new_len[i]);
dirent = (ventoy_iso9660_override *)cur->override_data;
dirent->first_sector = (grub_uint32_t)sector;
dirent->size = newlen;
dirent->first_sector_be = grub_swap_bytes32(dirent->first_sector);
dirent->size_be = grub_swap_bytes32(dirent->size);
dirent = (ventoy_iso9660_override *)cur->override_data;
dirent->first_sector = (grub_uint32_t)sector;
dirent->size = newlen;
dirent->first_sector_be = grub_swap_bytes32(dirent->first_sector);
dirent->size_be = grub_swap_bytes32(dirent->size);
sector += (dirent->size + 2047) / 2048;
cur++;
sector += (dirent->size + 2047) / 2048;
cur++;
}
}
}
if (g_svd_replace_offset > 0)
{
cur->img_offset = g_svd_replace_offset;
@ -915,6 +1099,7 @@ static grub_err_t ventoy_linux_locate_initrd(int filt, int *filtcnt)
if (filtbysize
&& (NULL == grub_strstr(node->name, "minirt.gz"))
&& (NULL == grub_strstr(node->name, "initrd.xz"))
&& (NULL == grub_strstr(node->name, "initrd.gz"))
)
{
if (filt > 0 && file->size <= g_ventoy_cpio_size + 2048)
@ -926,6 +1111,12 @@ static grub_err_t ventoy_linux_locate_initrd(int filt, int *filtcnt)
}
}
/* skip hdt.img */
if (file->size <= VTOY_SIZE_1MB && grub_strcmp(node->name, "/boot/hdt.img") == 0)
{
continue;
}
if (grub_strcmp(file->fs->name, "iso9660") == 0)
{
node->iso_type = 0;
@ -1101,6 +1292,24 @@ grub_err_t ventoy_cmd_skip_svd(grub_extcmd_context_t ctxt, int argc, char **args
VENTOY_CMD_RETURN(GRUB_ERR_NONE);
}
grub_err_t ventoy_cmd_append_ext_sector(grub_extcmd_context_t ctxt, int argc, char **args)
{
(void)ctxt;
(void)argc;
(void)args;
if (args[0][0] == '1')
{
g_append_ext_sector = 1;
}
else
{
g_append_ext_sector = 0;
}
VENTOY_CMD_RETURN(GRUB_ERR_NONE);
}
grub_err_t ventoy_cmd_load_cpio(grub_extcmd_context_t ctxt, int argc, char **args)
{
int i;
@ -1126,6 +1335,7 @@ grub_err_t ventoy_cmd_load_cpio(grub_extcmd_context_t ctxt, int argc, char **arg
grub_file_t file;
grub_file_t archfile;
grub_file_t tmpfile;
install_template *template_node = NULL;
ventoy_img_chunk_list chunk_list;
(void)ctxt;
@ -1172,26 +1382,17 @@ grub_err_t ventoy_cmd_load_cpio(grub_extcmd_context_t ctxt, int argc, char **arg
persistent_buf = (char *)(chunk_list.chunk);
}
template_file = ventoy_plugin_get_cur_install_template(args[1]);
template_file = ventoy_plugin_get_cur_install_template(args[1], &template_node);
if (template_file)
{
debug("auto install template: <%s>\n", template_file);
tmpfile = ventoy_grub_file_open(VENTOY_FILE_TYPE, "%s%s", args[2], template_file);
if (tmpfile)
debug("auto install template: <%s> <addr:%p> <len:%d>\n",
template_file, template_node->filebuf, template_node->filelen);
template_size = template_node->filelen;
template_buf = grub_malloc(template_size);
if (template_buf)
{
debug("auto install script size %d\n", (int)tmpfile->size);
template_size = tmpfile->size;
template_buf = grub_malloc(template_size);
if (template_buf)
{
grub_file_read(tmpfile, template_buf, template_size);
}
grub_file_close(tmpfile);
}
else
{
debug("Failed to open install script %s%s\n", args[2], template_file);
grub_memcpy(template_buf, template_node->filebuf, template_size);
}
}
else
@ -1278,15 +1479,14 @@ grub_err_t ventoy_cmd_load_cpio(grub_extcmd_context_t ctxt, int argc, char **arg
{
headlen = ventoy_cpio_newc_fill_head(buf, template_size, template_buf, "ventoy/autoinstall");
buf += headlen + ventoy_align(template_size, 4);
grub_check_free(template_buf);
}
if (persistent_size > 0 && persistent_buf)
{
headlen = ventoy_cpio_newc_fill_head(buf, persistent_size, persistent_buf, "ventoy/ventoy_persistent_map");
buf += headlen + ventoy_align(persistent_size, 4);
grub_free(persistent_buf);
persistent_buf = NULL;
grub_check_free(persistent_buf);
}
if (injection_size > 0 && injection_buf)
@ -1361,7 +1561,6 @@ grub_err_t ventoy_cmd_trailer_cpio(grub_extcmd_context_t ctxt, int argc, char **
grub_uint8_t *bufend;
cpio_newc_header *head;
grub_file_t file;
char value[64];
const grub_uint8_t trailler[124] = {
0x30, 0x37, 0x30, 0x37, 0x30, 0x31, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30,
0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30,
@ -1432,18 +1631,15 @@ grub_err_t ventoy_cmd_trailer_cpio(grub_extcmd_context_t ctxt, int argc, char **
name = (char *)(head + 1);
}
}
grub_snprintf(value, sizeof(value), "0x%llx", (ulonglong)(ulong)g_ventoy_cpio_buf);
ventoy_set_env("ventoy_cpio_addr", value);
grub_snprintf(value, sizeof(value), "%d", bufsize);
ventoy_set_env("ventoy_cpio_size", value);
ventoy_memfile_env_set("ventoy_cpio", g_ventoy_cpio_buf, (ulonglong)bufsize);
VENTOY_CMD_RETURN(GRUB_ERR_NONE);
}
grub_err_t ventoy_cmd_linux_chain_data(grub_extcmd_context_t ctxt, int argc, char **args)
{
int len = 0;
int ventoy_compatible = 0;
grub_uint32_t size = 0;
grub_uint64_t isosize = 0;
@ -1458,7 +1654,6 @@ grub_err_t ventoy_cmd_linux_chain_data(grub_extcmd_context_t ctxt, int argc, cha
const char *pLastChain = NULL;
const char *compatible;
ventoy_chain_head *chain;
char envbuf[64];
(void)ctxt;
(void)argc;
@ -1483,23 +1678,31 @@ grub_err_t ventoy_cmd_linux_chain_data(grub_extcmd_context_t ctxt, int argc, cha
isosize = file->size;
boot_catlog = ventoy_get_iso_boot_catlog(file);
if (boot_catlog)
len = (int)grub_strlen(args[0]);
if (len >= 4 && 0 == grub_strcasecmp(args[0] + len - 4, ".img"))
{
if (ventoy_is_efi_os() && (!ventoy_has_efi_eltorito(file, boot_catlog)))
{
grub_env_set("LoadIsoEfiDriver", "on");
}
debug("boot catlog %u for img file\n", boot_catlog);
}
else
{
if (ventoy_is_efi_os())
boot_catlog = ventoy_get_iso_boot_catlog(file);
if (boot_catlog)
{
grub_env_set("LoadIsoEfiDriver", "on");
if (ventoy_is_efi_os() && (!ventoy_has_efi_eltorito(file, boot_catlog)))
{
grub_env_set("LoadIsoEfiDriver", "on");
}
}
else
{
return grub_error(GRUB_ERR_BAD_ARGUMENT, "File %s is not bootable", args[0]);
if (ventoy_is_efi_os())
{
grub_env_set("LoadIsoEfiDriver", "on");
}
else
{
return grub_error(GRUB_ERR_BAD_ARGUMENT, "File %s is not bootable", args[0]);
}
}
}
@ -1530,18 +1733,15 @@ grub_err_t ventoy_cmd_linux_chain_data(grub_extcmd_context_t ctxt, int argc, cha
}
}
chain = grub_malloc(size);
chain = ventoy_alloc_chain(size);
if (!chain)
{
grub_printf("Failed to alloc chain memory size %u\n", size);
grub_printf("Failed to alloc chain linux memory size %u\n", size);
grub_file_close(file);
return 1;
}
grub_snprintf(envbuf, sizeof(envbuf), "0x%lx", (unsigned long)chain);
grub_env_set("vtoy_chain_mem_addr", envbuf);
grub_snprintf(envbuf, sizeof(envbuf), "%u", size);
grub_env_set("vtoy_chain_mem_size", envbuf);
ventoy_memfile_env_set("vtoy_chain_mem", chain, (ulonglong)size);
grub_memset(chain, 0, sizeof(ventoy_chain_head));
@ -1592,3 +1792,300 @@ grub_err_t ventoy_cmd_linux_chain_data(grub_extcmd_context_t ctxt, int argc, cha
VENTOY_CMD_RETURN(GRUB_ERR_NONE);
}
static char *ventoy_systemd_conf_tag(char *buf, const char *tag, int optional)
{
int taglen = 0;
char *start = NULL;
char *nextline = NULL;
taglen = grub_strlen(tag);
for (start = buf; start; start = nextline)
{
nextline = ventoy_get_line(start);
VTOY_SKIP_SPACE(start);
if (grub_strncmp(start, tag, taglen) == 0 && (start[taglen] == ' ' || start[taglen] == '\t'))
{
start += taglen;
VTOY_SKIP_SPACE(start);
return start;
}
}
if (optional == 0)
{
debug("tag<%s> NOT found\n", tag);
}
return NULL;
}
static int ventoy_systemd_conf_hook(const char *filename, const struct grub_dirhook_info *info, void *data)
{
int oldpos = 0;
char *tag = NULL;
char *bkbuf = NULL;
char *filebuf = NULL;
grub_file_t file = NULL;
systemd_menu_ctx *ctx = (systemd_menu_ctx *)data;
debug("ventoy_systemd_conf_hook %s\n", filename);
if (info->dir || NULL == grub_strstr(filename, ".conf"))
{
return 0;
}
file = ventoy_grub_file_open(VENTOY_FILE_TYPE, "%s/loader/entries/%s", ctx->dev, filename);
if (!file)
{
return 0;
}
filebuf = grub_zalloc(2 * file->size + 8);
if (!filebuf)
{
goto out;
}
bkbuf = filebuf + file->size + 4;
grub_file_read(file, bkbuf, file->size);
oldpos = ctx->pos;
/* title --> menuentry */
grub_memcpy(filebuf, bkbuf, file->size);
tag = ventoy_systemd_conf_tag(filebuf, "title", 0);
vtoy_check_goto_out(tag);
vtoy_len_ssprintf(ctx->buf, ctx->pos, ctx->len, "menuentry \"%s\" {\n", tag);
/* linux xxx */
grub_memcpy(filebuf, bkbuf, file->size);
tag = ventoy_systemd_conf_tag(filebuf, "linux", 0);
if (!tag)
{
ctx->pos = oldpos;
goto out;
}
vtoy_len_ssprintf(ctx->buf, ctx->pos, ctx->len, " echo \"Downloading kernel ...\"\n linux %s ", tag);
/* kernel options */
grub_memcpy(filebuf, bkbuf, file->size);
tag = ventoy_systemd_conf_tag(filebuf, "options", 0);
vtoy_len_ssprintf(ctx->buf, ctx->pos, ctx->len, "%s \n", tag ? tag : "");
/* initrd xxx xxx xxx */
vtoy_len_ssprintf(ctx->buf, ctx->pos, ctx->len, " echo \"Downloading initrd ...\"\n initrd ");
grub_memcpy(filebuf, bkbuf, file->size);
tag = ventoy_systemd_conf_tag(filebuf, "initrd", 1);
while (tag)
{
vtoy_len_ssprintf(ctx->buf, ctx->pos, ctx->len, "%s ", tag);
tag = ventoy_systemd_conf_tag(tag + grub_strlen(tag) + 1, "initrd", 1);
}
vtoy_len_ssprintf(ctx->buf, ctx->pos, ctx->len, "\n boot\n}\n");
out:
grub_check_free(filebuf);
grub_file_close(file);
return 0;
}
grub_err_t ventoy_cmd_linux_systemd_menu(grub_extcmd_context_t ctxt, int argc, char **args)
{
static char *buf = NULL;
grub_fs_t fs;
char *device_name = NULL;
grub_device_t dev = NULL;
systemd_menu_ctx ctx;
(void)ctxt;
(void)argc;
if (!buf)
{
buf = grub_malloc(VTOY_LINUX_SYSTEMD_MENU_MAX_BUF);
if (!buf)
{
goto end;
}
}
device_name = grub_file_get_device_name(args[0]);
if (!device_name)
{
debug("failed to get device name %s\n", args[0]);
goto end;
}
dev = grub_device_open(device_name);
if (!dev)
{
debug("failed to open device %s\n", device_name);
goto end;
}
fs = grub_fs_probe(dev);
if (!fs)
{
debug("failed to probe fs %d\n", grub_errno);
goto end;
}
ctx.dev = args[0];
ctx.buf = buf;
ctx.pos = 0;
ctx.len = VTOY_LINUX_SYSTEMD_MENU_MAX_BUF;
fs->fs_dir(dev, "/loader/entries", ventoy_systemd_conf_hook, &ctx);
ventoy_memfile_env_set(args[1], buf, (ulonglong)(ctx.pos));
end:
grub_check_free(device_name);
check_free(dev, grub_device_close);
VENTOY_CMD_RETURN(GRUB_ERR_NONE);
}
static int ventoy_limine_path_convert(char *path)
{
char newpath[256] = {0};
if (grub_strncmp(path, "boot://2/", 9) == 0)
{
grub_snprintf(newpath, sizeof(newpath), "(vtimghd,2)/%s", path + 9);
}
else if (grub_strncmp(path, "boot://1/", 9) == 0)
{
grub_snprintf(newpath, sizeof(newpath), "(vtimghd,1)/%s", path + 9);
}
if (newpath[0])
{
grub_snprintf(path, 1024, "%s", newpath);
}
return 0;
}
grub_err_t ventoy_cmd_linux_limine_menu(grub_extcmd_context_t ctxt, int argc, char **args)
{
int pos = 0;
int sub = 0;
int len = VTOY_LINUX_SYSTEMD_MENU_MAX_BUF;
char *filebuf = NULL;
char *start = NULL;
char *nextline = NULL;
grub_file_t file = NULL;
char *title = NULL;
char *kernel = NULL;
char *initrd = NULL;
char *param = NULL;
static char *buf = NULL;
(void)ctxt;
(void)argc;
if (!buf)
{
buf = grub_malloc(len + 4 * 1024);
if (!buf)
{
goto end;
}
}
title = buf + len;
kernel = title + 1024;
initrd = kernel + 1024;
param = initrd + 1024;
file = ventoy_grub_file_open(VENTOY_FILE_TYPE, args[0]);
if (!file)
{
return 0;
}
filebuf = grub_zalloc(file->size + 8);
if (!filebuf)
{
goto end;
}
grub_file_read(file, filebuf, file->size);
grub_file_close(file);
title[0] = kernel[0] = initrd[0] = param[0] = 0;
for (start = filebuf; start; start = nextline)
{
nextline = ventoy_get_line(start);
VTOY_SKIP_SPACE(start);
if (start[0] == ':')
{
if (start[1] == ':')
{
grub_snprintf(title, 1024, "%s", start + 2);
}
else
{
if (sub)
{
vtoy_len_ssprintf(buf, pos, len, "}\n");
sub = 0;
}
if (nextline && nextline[0] == ':' && nextline[1] == ':')
{
vtoy_len_ssprintf(buf, pos, len, "submenu \"[+] %s\" {\n", start + 2);
sub = 1;
title[0] = 0;
}
else
{
grub_snprintf(title, 1024, "%s", start + 1);
}
}
}
else if (grub_strncmp(start, "KERNEL_PATH=", 12) == 0)
{
grub_snprintf(kernel, 1024, "%s", start + 12);
}
else if (grub_strncmp(start, "MODULE_PATH=", 12) == 0)
{
grub_snprintf(initrd, 1024, "%s", start + 12);
}
else if (grub_strncmp(start, "KERNEL_CMDLINE=", 15) == 0)
{
grub_snprintf(param, 1024, "%s", start + 15);
}
if (title[0] && kernel[0] && initrd[0] && param[0])
{
ventoy_limine_path_convert(kernel);
ventoy_limine_path_convert(initrd);
vtoy_len_ssprintf(buf, pos, len, "menuentry \"%s\" {\n", title);
vtoy_len_ssprintf(buf, pos, len, " echo \"Downloading kernel ...\"\n linux %s %s\n", kernel, param);
vtoy_len_ssprintf(buf, pos, len, " echo \"Downloading initrd ...\"\n initrd %s\n", initrd);
vtoy_len_ssprintf(buf, pos, len, "}\n");
title[0] = kernel[0] = initrd[0] = param[0] = 0;
}
}
if (sub)
{
vtoy_len_ssprintf(buf, pos, len, "}\n");
sub = 0;
}
ventoy_memfile_env_set(args[1], buf, (ulonglong)pos);
end:
grub_check_free(filebuf);
VENTOY_CMD_RETURN(GRUB_ERR_NONE);
}

File diff suppressed because it is too large Load Diff

View File

@ -33,6 +33,8 @@
#include <grub/i18n.h>
#include <grub/net.h>
#include <grub/time.h>
#include <grub/elf.h>
#include <grub/elfload.h>
#include <grub/ventoy.h>
#include "ventoy_def.h"
@ -45,6 +47,12 @@ char *g_conf_new_data = NULL;
int g_mod_new_len = 0;
char *g_mod_new_data = NULL;
int g_mod_search_magic = 0;
int g_unix_vlnk_boot = 0;
int g_ko_fillmap_len = 0;
char *g_ko_fillmap_data = NULL;
grub_uint64_t g_mod_override_offset = 0;
grub_uint64_t g_conf_override_offset = 0;
@ -80,6 +88,15 @@ static grub_uint32_t ventoy_unix_get_override_chunk_count(void)
{
count++;
}
if (g_ko_fillmap_len > 0)
{
count += (g_ko_fillmap_len / 512);
if ((g_ko_fillmap_len % 512) > 0)
{
count++;
}
}
return count;
}
@ -119,15 +136,50 @@ static grub_uint32_t ventoy_unix_get_virt_chunk_size(void)
return size;
}
static void ventoy_unix_fill_override_data( grub_uint64_t isosize, void *override)
static void ventoy_unix_fill_map_data(ventoy_chain_head *chain, struct g_ventoy_map *map)
{
grub_uint32_t i;
ventoy_img_chunk *chunk = NULL;
debug("Fill unix map data: <%llu> <%u> %p\n",
(unsigned long long)chain->os_param.vtoy_disk_size, g_img_chunk_list.cur_chunk, map);
map->magic1[0] = map->magic2[0] = VENTOY_UNIX_SEG_MAGIC0;
map->magic1[1] = map->magic2[1] = VENTOY_UNIX_SEG_MAGIC1;
map->magic1[2] = map->magic2[2] = VENTOY_UNIX_SEG_MAGIC2;
map->magic1[3] = map->magic2[3] = VENTOY_UNIX_SEG_MAGIC3;
map->disksize = chain->os_param.vtoy_disk_size;
grub_memcpy(map->diskuuid, chain->os_param.vtoy_disk_guid, 16);
map->segnum = g_img_chunk_list.cur_chunk;
if (g_img_chunk_list.cur_chunk > VENTOY_UNIX_MAX_SEGNUM)
{
debug("####[FAIL] Too many segments for the ISO file %u\n", g_img_chunk_list.cur_chunk);
map->segnum = VENTOY_UNIX_MAX_SEGNUM;
}
for (i = 0; i < (grub_uint32_t)(map->segnum); i++)
{
chunk = g_img_chunk_list.chunk + i;
map->seglist[i].seg_start_bytes = chunk->disk_start_sector * 512ULL;
map->seglist[i].seg_end_bytes = (chunk->disk_end_sector + 1) * 512ULL;
}
}
static void ventoy_unix_fill_override_data( grub_uint64_t isosize, ventoy_chain_head *chain)
{
int i;
int left;
char *data = NULL;
grub_uint64_t offset;
grub_uint64_t sector;
ventoy_override_chunk *cur;
ventoy_iso9660_override *dirent;
sector = (isosize + 2047) / 2048;
cur = (ventoy_override_chunk *)override;
cur = (ventoy_override_chunk *)((char *)chain + chain->override_chunk_offset);
if (g_conf_new_len > 0)
{
@ -140,12 +192,12 @@ static void ventoy_unix_fill_override_data( grub_uint64_t isosize, void *over
dirent->first_sector_be = grub_swap_bytes32(dirent->first_sector);
dirent->size_be = grub_swap_bytes32(dirent->size);
sector += (dirent->size + 2047) / 2048;
cur++;
}
if (g_mod_new_len > 0)
{
/* mod.ko */
cur++;
cur->img_offset = g_mod_override_offset;
cur->override_size = sizeof(ventoy_iso9660_override);
dirent = (ventoy_iso9660_override *)cur->override_data;
@ -154,6 +206,37 @@ static void ventoy_unix_fill_override_data( grub_uint64_t isosize, void *over
dirent->first_sector_be = grub_swap_bytes32(dirent->first_sector);
dirent->size_be = grub_swap_bytes32(dirent->size);
sector += (dirent->size + 2047) / 2048;
cur++;
}
if (g_ko_fillmap_len > 0)
{
data = g_ko_fillmap_data;
offset = g_mod_override_offset;
ventoy_unix_fill_map_data(chain, (struct g_ventoy_map *)data);
for (i = 0; i < g_ko_fillmap_len / 512; i++)
{
cur->img_offset = offset;
cur->override_size = 512;
grub_memcpy(cur->override_data, data, 512);
offset += 512;
data += 512;
cur++;
}
left = (g_ko_fillmap_len % 512);
if (left > 0)
{
cur->img_offset = offset;
cur->override_size = left;
grub_memcpy(cur->override_data, data, left);
offset += left;
cur++;
}
}
return;
@ -180,19 +263,25 @@ static void ventoy_unix_fill_virt_data( grub_uint64_t isosize, ventoy_chain_h
if (g_mod_new_len > 0)
{
if (g_mod_search_magic > 0)
{
ventoy_unix_fill_map_data(chain, (struct g_ventoy_map *)(g_mod_new_data + g_mod_search_magic));
}
ventoy_unix_fill_virt(g_mod_new_data, g_mod_new_len);
}
return;
}
static int ventoy_freebsd_append_conf(char *buf, const char *isopath)
static int ventoy_freebsd_append_conf(char *buf, const char *isopath, const char *alias)
{
int pos = 0;
grub_uint32_t i;
grub_disk_t disk;
grub_file_t isofile;
char uuid[64] = {0};
const char *val = NULL;
ventoy_img_chunk *chunk;
grub_uint8_t disk_sig[4];
grub_uint8_t disk_guid[16];
@ -207,7 +296,31 @@ static int ventoy_freebsd_append_conf(char *buf, const char *isopath)
vtoy_ssprintf(buf, pos, "ventoy_load=\"%s\"\n", "YES");
vtoy_ssprintf(buf, pos, "ventoy_name=\"%s\"\n", g_ko_mod_path);
if (alias)
{
vtoy_ssprintf(buf, pos, "hint.ventoy.0.alias=\"%s\"\n", alias);
}
if (g_unix_vlnk_boot)
{
vtoy_ssprintf(buf, pos, "hint.ventoy.0.vlnk=%d\n", 1);
}
val = ventoy_get_env("VTOY_UNIX_REMOUNT");
if (val && val[0] == '1' && val[1] == 0)
{
vtoy_ssprintf(buf, pos, "hint.ventoy.0.remount=%d\n", 1);
}
if (g_mod_search_magic)
{
debug("hint.ventoy NO need\n");
goto out;
}
debug("Fill hint.ventoy info\n");
disk = isofile->device->disk;
ventoy_get_disk_guid(isofile->name, disk_guid, disk_sig);
@ -230,8 +343,8 @@ static int ventoy_freebsd_append_conf(char *buf, const char *isopath)
(ulonglong)((chunk->disk_end_sector + 1) * 512));
}
out:
grub_file_close(isofile);
return pos;
}
@ -256,13 +369,38 @@ grub_err_t ventoy_cmd_unix_reset(grub_extcmd_context_t ctxt, int argc, char **ar
(void)argc;
(void)args;
g_unix_vlnk_boot = 0;
g_mod_search_magic = 0;
g_conf_new_len = 0;
g_mod_new_len = 0;
g_mod_override_offset = 0;
g_conf_override_offset = 0;
g_ko_fillmap_len = 0;
check_free(g_mod_new_data, grub_free);
check_free(g_conf_new_data, grub_free);
check_free(g_ko_fillmap_data, grub_free);
VENTOY_CMD_RETURN(GRUB_ERR_NONE);
}
grub_err_t ventoy_cmd_unix_check_vlnk(grub_extcmd_context_t ctxt, int argc, char **args)
{
grub_file_t file;
(void)ctxt;
if (argc != 1)
{
return 1;
}
file = grub_file_open(args[0], VENTOY_FILE_TYPE);
if (file)
{
g_unix_vlnk_boot = file->vlnk;
grub_file_close(file);
}
VENTOY_CMD_RETURN(GRUB_ERR_NONE);
}
@ -307,12 +445,16 @@ grub_err_t ventoy_cmd_parse_freenas_ver(grub_extcmd_context_t ctxt, int argc, ch
ver = vtoy_json_get_string_ex(json->pstChild, "Version");
if (ver)
{
debug("freenas version:<%s>\n", ver);
debug("NAS version:<%s>\n", ver);
if (grub_strncmp(ver, "TrueNAS-", 8) == 0)
{
ver += 8;
}
ventoy_set_env(args[1], ver);
}
else
{
debug("freenas version:<%s>\n", "NOT FOUND");
debug("NAS version:<%s>\n", "NOT FOUND");
grub_env_unset(args[1]);
}
@ -383,6 +525,277 @@ grub_err_t ventoy_cmd_unix_freebsd_ver(grub_extcmd_context_t ctxt, int argc, cha
VENTOY_CMD_RETURN(GRUB_ERR_NONE);
}
grub_err_t ventoy_cmd_unix_freebsd_ver_elf(grub_extcmd_context_t ctxt, int argc, char **args)
{
int j;
int k;
grub_elf_t elf = NULL;
grub_off_t offset = 0;
grub_uint32_t len = 0;
char *str = NULL;
char *data = NULL;
void *hdr = NULL;
char ver[64] = {0};
(void)ctxt;
(void)argc;
(void)args;
if (argc != 3)
{
debug("Invalid argc %d\n", argc);
return 1;
}
data = grub_zalloc(8192);
if (!data)
{
goto out;
}
elf = grub_elf_open(args[0], GRUB_FILE_TYPE_LINUX_INITRD);
if (!elf)
{
debug("Failed to open file %s\n", args[0]);
goto out;
}
if (args[1][0] == '6')
{
Elf64_Ehdr *e = &(elf->ehdr.ehdr64);
Elf64_Shdr *h;
Elf64_Shdr *s;
Elf64_Shdr *t;
Elf64_Half i;
h = hdr = grub_zalloc(e->e_shnum * e->e_shentsize);
if (!h)
{
goto out;
}
debug("read section header %u %u %u\n", e->e_shnum, e->e_shentsize, e->e_shstrndx);
grub_file_seek(elf->file, e->e_shoff);
grub_file_read(elf->file, h, e->e_shnum * e->e_shentsize);
s = (Elf64_Shdr *)((char *)h + e->e_shstrndx * e->e_shentsize);
str = grub_malloc(s->sh_size + 1);
if (!str)
{
goto out;
}
str[s->sh_size] = 0;
debug("read string table %u %u\n", (grub_uint32_t)s->sh_offset, (grub_uint32_t)s->sh_size);
grub_file_seek(elf->file, s->sh_offset);
grub_file_read(elf->file, str, s->sh_size);
for (t = h, i = 0; i < e->e_shnum; i++)
{
if (grub_strcmp(str + t->sh_name, ".data") == 0)
{
offset = t->sh_offset;
len = t->sh_size;
debug("find .data section at %u %u\n", (grub_uint32_t)offset, len);
break;
}
t = (Elf64_Shdr *)((char *)t + e->e_shentsize);
}
}
else
{
Elf32_Ehdr *e = &(elf->ehdr.ehdr32);
Elf32_Shdr *h;
Elf32_Shdr *s;
Elf32_Shdr *t;
Elf32_Half i;
h = hdr = grub_zalloc(e->e_shnum * e->e_shentsize);
if (!h)
{
goto out;
}
debug("read section header %u %u %u\n", e->e_shnum, e->e_shentsize, e->e_shstrndx);
grub_file_seek(elf->file, e->e_shoff);
grub_file_read(elf->file, h, e->e_shnum * e->e_shentsize);
s = (Elf32_Shdr *)((char *)h + e->e_shstrndx * e->e_shentsize);
str = grub_malloc(s->sh_size + 1);
if (!str)
{
goto out;
}
str[s->sh_size] = 0;
debug("read string table %u %u\n", (grub_uint32_t)s->sh_offset, (grub_uint32_t)s->sh_size);
grub_file_seek(elf->file, s->sh_offset);
grub_file_read(elf->file, str, s->sh_size);
for (t = h, i = 0; i < e->e_shnum; i++)
{
if (grub_strcmp(str + t->sh_name, ".data") == 0)
{
offset = t->sh_offset;
len = t->sh_size;
debug("find .data section at %u %u\n", (grub_uint32_t)offset, len);
break;
}
t = (Elf32_Shdr *)((char *)t + e->e_shentsize);
}
}
if (offset == 0 || len == 0)
{
debug(".data section not found %s\n", args[0]);
goto out;
}
grub_file_seek(elf->file, offset + len - 8192);
grub_file_read(elf->file, data, 8192);
for (j = 0; j < 8192 - 12; j++)
{
if (grub_strncmp(data + j, "@(#)FreeBSD ", 12) == 0)
{
for (k = j + 12; k < 8192; k++)
{
if (0 == grub_isdigit(data[k]) && data[k] != '.')
{
data[k] = 0;
break;
}
}
grub_snprintf(ver, sizeof(ver), "%s", data + j + 12);
break;
}
}
if (ver[0])
{
k = (int)grub_strtoul(ver, NULL, 10);
debug("freebsd version:<%s> <%d.x>\n", ver, k);
grub_snprintf(ver, sizeof(ver), "%d.x", k);
ventoy_set_env(args[2], ver);
}
else
{
debug("freebsd version:<%s>\n", "NOT FOUND");
}
out:
grub_check_free(str);
grub_check_free(hdr);
grub_check_free(data);
check_free(elf, grub_elf_close);
VENTOY_CMD_RETURN(GRUB_ERR_NONE);
}
grub_err_t ventoy_cmd_unix_replace_grub_conf(grub_extcmd_context_t ctxt, int argc, char **args)
{
int len = 0;
grub_uint32_t i;
char *data;
char *pos;
const char *val = NULL;
grub_uint64_t offset;
grub_file_t file;
char extcfg[512];
const char *confile = NULL;
const char * loader_conf[] =
{
"/boot/grub/grub.cfg",
};
(void)ctxt;
if (argc != 1 && argc != 2)
{
debug("Replace conf invalid argc %d\n", argc);
return 1;
}
for (i = 0; i < sizeof(loader_conf) / sizeof(loader_conf[0]); i++)
{
if (ventoy_get_file_override(loader_conf[i], &offset) == 0)
{
confile = loader_conf[i];
g_conf_override_offset = offset;
break;
}
}
if (confile == NULL)
{
debug("Can't find grub.cfg file from %u locations\n", i);
return 1;
}
file = ventoy_grub_file_open(GRUB_FILE_TYPE_LINUX_INITRD, "(loop)/%s", confile);
if (!file)
{
debug("Failed to open %s \n", confile);
return 1;
}
debug("old grub2 conf file size:%d\n", (int)file->size);
data = grub_malloc(VTOY_MAX_SCRIPT_BUF);
if (!data)
{
grub_file_close(file);
return 1;
}
grub_file_read(file, data, file->size);
grub_file_close(file);
g_conf_new_data = data;
g_conf_new_len = (int)file->size;
pos = grub_strstr(data, "kfreebsd /boot/kernel/kernel");
if (pos)
{
pos += grub_strlen("kfreebsd /boot/kernel/kernel");
if (grub_strncmp(pos, ".gz", 3) == 0)
{
pos += 3;
}
if (argc == 2)
{
vtoy_ssprintf(extcfg, len, ";kfreebsd_module_elf %s; set kFreeBSD.hint.ventoy.0.alias=\"%s\"", args[0], args[1]);
}
else
{
vtoy_ssprintf(extcfg, len, ";kfreebsd_module_elf %s", args[0]);
}
if (g_unix_vlnk_boot)
{
vtoy_ssprintf(extcfg, len, ";set kFreeBSD.hint.ventoy.0.vlnk=%d", 1);
}
val = ventoy_get_env("VTOY_UNIX_REMOUNT");
if (val && val[0] == '1' && val[1] == 0)
{
vtoy_ssprintf(extcfg, len, ";set kFreeBSD.hint.ventoy.0.remount=%d", 1);
}
grub_memmove(pos + len, pos, (int)(file->size - (pos - data)));
grub_memcpy(pos, extcfg, len);
g_conf_new_len += len;
}
else
{
debug("no kfreebsd found\n");
}
VENTOY_CMD_RETURN(GRUB_ERR_NONE);
}
grub_err_t ventoy_cmd_unix_replace_conf(grub_extcmd_context_t ctxt, int argc, char **args)
{
grub_uint32_t i;
@ -398,7 +811,7 @@ grub_err_t ventoy_cmd_unix_replace_conf(grub_extcmd_context_t ctxt, int argc, ch
(void)ctxt;
if (argc != 2)
if (argc != 2 && argc != 3)
{
debug("Replace conf invalid argc %d\n", argc);
return 1;
@ -427,7 +840,7 @@ grub_err_t ventoy_cmd_unix_replace_conf(grub_extcmd_context_t ctxt, int argc, ch
return 1;
}
debug("old conf file size:%d\n", (int)file->size);
debug("old conf file <%s> size:%d\n", confile, (int)file->size);
data = grub_malloc(VTOY_MAX_SCRIPT_BUF);
if (!data)
@ -444,7 +857,7 @@ grub_err_t ventoy_cmd_unix_replace_conf(grub_extcmd_context_t ctxt, int argc, ch
if (grub_strcmp(args[0], "FreeBSD") == 0)
{
g_conf_new_len += ventoy_freebsd_append_conf(data + file->size, args[1]);
g_conf_new_len += ventoy_freebsd_append_conf(data + file->size, args[1], (argc > 2) ? args[2] : NULL);
}
else if (grub_strcmp(args[0], "DragonFly") == 0)
{
@ -454,6 +867,27 @@ grub_err_t ventoy_cmd_unix_replace_conf(grub_extcmd_context_t ctxt, int argc, ch
VENTOY_CMD_RETURN(GRUB_ERR_NONE);
}
static int ventoy_unix_search_magic(char *data, int len)
{
int i;
grub_uint32_t *magic = NULL;
for (i = 0; i < len; i += 4096)
{
magic = (grub_uint32_t *)(data + i);
if (magic[0] == VENTOY_UNIX_SEG_MAGIC0 && magic[1] == VENTOY_UNIX_SEG_MAGIC1 &&
magic[2] == VENTOY_UNIX_SEG_MAGIC2 && magic[3] == VENTOY_UNIX_SEG_MAGIC3)
{
debug("unix find search magic at 0x%x loop:%d\n", i, (i >> 12));
g_mod_search_magic = i;
return 0;
}
}
debug("unix can not find search magic\n");
return 1;
}
grub_err_t ventoy_cmd_unix_replace_ko(grub_extcmd_context_t ctxt, int argc, char **args)
{
char *data;
@ -503,10 +937,73 @@ grub_err_t ventoy_cmd_unix_replace_ko(grub_extcmd_context_t ctxt, int argc, char
g_mod_new_data = data;
g_mod_new_len = (int)file->size;
ventoy_unix_search_magic(g_mod_new_data, g_mod_new_len);
VENTOY_CMD_RETURN(GRUB_ERR_NONE);
}
grub_err_t ventoy_cmd_unix_ko_fillmap(grub_extcmd_context_t ctxt, int argc, char **args)
{
int i;
grub_file_t file;
grub_uint32_t magic[4];
grub_uint32_t len;
(void)ctxt;
if (argc != 1)
{
debug("Fillmap ko invalid argc %d\n", argc);
return 1;
}
debug("Fillmap ko %s\n", args[0]);
file = ventoy_grub_file_open(VENTOY_FILE_TYPE, "(loop)%s", args[0]);
if (file)
{
grub_file_read(file, magic, 4); /* read for trigger */
g_mod_override_offset = grub_iso9660_get_last_read_pos(file);
}
else
{
debug("Can't find replace ko file from %s\n", args[0]);
return 1;
}
for (i = 0; i < (int)(file->size); i += 65536)
{
magic[0] = 0;
grub_file_seek(file, i);
grub_file_read(file, magic, sizeof(magic));
if (magic[0] == VENTOY_UNIX_SEG_MAGIC0 && magic[1] == VENTOY_UNIX_SEG_MAGIC1 &&
magic[2] == VENTOY_UNIX_SEG_MAGIC2 && magic[3] == VENTOY_UNIX_SEG_MAGIC3)
{
debug("unix find search magic at 0x%x loop:%d\n", i, (i >> 16));
g_mod_override_offset += i;
break;
}
}
len = (grub_uint32_t)OFFSET_OF(struct g_ventoy_map, seglist) +
(sizeof(struct g_ventoy_seg) * g_img_chunk_list.cur_chunk);
g_ko_fillmap_len = (int)len;
g_ko_fillmap_data = grub_malloc(len);
if (!g_ko_fillmap_data)
{
g_ko_fillmap_len = 0;
debug("Failed to malloc fillmap data\n");
}
debug("Fillmap ko segnum:%u, override len:%u data:%p\n", g_img_chunk_list.cur_chunk, len, g_ko_fillmap_data);
grub_file_close(file);
VENTOY_CMD_RETURN(GRUB_ERR_NONE);
}
grub_err_t ventoy_cmd_unix_fill_image_desc(grub_extcmd_context_t ctxt, int argc, char **args)
{
int i;
@ -550,7 +1047,7 @@ grub_err_t ventoy_cmd_unix_fill_image_desc(grub_extcmd_context_t ctxt, int argc,
desc = (ventoy_image_desc *)(byte + i);
desc->disk_size = g_ventoy_disk_size;
desc->part1_size = ventoy_get_part1_size(g_ventoy_part_info);
desc->part1_size = g_ventoy_disk_part_size[0];
grub_memcpy(desc->disk_uuid, g_ventoy_part_info->MBR.BootCode + 0x180, 16);
grub_memcpy(desc->disk_signature, g_ventoy_part_info->MBR.BootCode + 0x1B8, 4);
@ -621,7 +1118,6 @@ grub_err_t ventoy_cmd_unix_chain_data(grub_extcmd_context_t ctxt, int argc, char
const char *pLastChain = NULL;
const char *compatible;
ventoy_chain_head *chain;
char envbuf[64];
(void)ctxt;
(void)argc;
@ -692,18 +1188,15 @@ grub_err_t ventoy_cmd_unix_chain_data(grub_extcmd_context_t ctxt, int argc, char
}
}
chain = grub_malloc(size);
chain = ventoy_alloc_chain(size);
if (!chain)
{
grub_printf("Failed to alloc chain memory size %u\n", size);
grub_printf("Failed to alloc chain unix memory size %u\n", size);
grub_file_close(file);
return 1;
}
grub_snprintf(envbuf, sizeof(envbuf), "0x%lx", (unsigned long)chain);
grub_env_set("vtoy_chain_mem_addr", envbuf);
grub_snprintf(envbuf, sizeof(envbuf), "%u", size);
grub_env_set("vtoy_chain_mem_size", envbuf);
ventoy_memfile_env_set("vtoy_chain_mem", chain, (ulonglong)size);
grub_memset(chain, 0, sizeof(ventoy_chain_head));
@ -738,7 +1231,7 @@ grub_err_t ventoy_cmd_unix_chain_data(grub_extcmd_context_t ctxt, int argc, char
/* part 4: override chunk */
chain->override_chunk_offset = chain->img_chunk_offset + img_chunk_size;
chain->override_chunk_num = override_count;
ventoy_unix_fill_override_data(isosize, (char *)chain + chain->override_chunk_offset);
ventoy_unix_fill_override_data(isosize, chain);
/* part 5: virt chunk */
chain->virt_chunk_offset = chain->override_chunk_offset + override_size;

View File

@ -44,14 +44,12 @@
GRUB_MOD_LICENSE ("GPLv3+");
static int g_vhdboot_bcd_offset = 0;
static int g_vhdboot_bcd_len = 0;
static int g_vhdboot_isolen = 0;
static char *g_vhdboot_totbuf = NULL;
static char *g_vhdboot_isobuf = NULL;
static grub_uint64_t g_img_trim_head_secnum = 0;
static int ventoy_vhd_find_bcd(int *bcdoffset, int *bcdlen)
static int ventoy_vhd_find_bcd(int *bcdoffset, int *bcdlen, const char *path)
{
grub_uint32_t offset;
grub_file_t file;
@ -61,10 +59,9 @@ static int ventoy_vhd_find_bcd(int *bcdoffset, int *bcdlen)
grub_script_execute_sourcecode(cmdbuf);
file = ventoy_grub_file_open(VENTOY_FILE_TYPE, "%s", "(vhdiso)/boot/bcd");
file = ventoy_grub_file_open(VENTOY_FILE_TYPE, "(vhdiso)%s", path);
if (!file)
{
grub_printf("Failed to open bcd file in the image file\n");
return 1;
}
@ -83,13 +80,15 @@ static int ventoy_vhd_find_bcd(int *bcdoffset, int *bcdlen)
return 0;
}
static int ventoy_vhd_patch_path(char *vhdpath, ventoy_patch_vhd *patch1, ventoy_patch_vhd *patch2)
static int ventoy_vhd_patch_path(char *vhdpath, ventoy_patch_vhd *patch1, ventoy_patch_vhd *patch2,
int bcdoffset, int bcdlen)
{
int i;
int cnt = 0;
char *pos;
grub_size_t pathlen;
const char *plat;
char *newpath = NULL;
grub_uint16_t *unicode_path;
const grub_uint8_t winloadexe[] =
{
@ -97,6 +96,11 @@ static int ventoy_vhd_patch_path(char *vhdpath, ventoy_patch_vhd *patch1, ventoy
0x65, 0x00, 0x78, 0x00, 0x65, 0x00
};
while ((*vhdpath) != '/')
{
vhdpath++;
}
pathlen = sizeof(grub_uint16_t) * (grub_strlen(vhdpath) + 1);
debug("unicode path for <%s> len:%d\n", vhdpath, (int)pathlen);
@ -110,10 +114,10 @@ static int ventoy_vhd_patch_path(char *vhdpath, ventoy_patch_vhd *patch1, ventoy
if (plat && (plat[0] == 'e')) /* UEFI */
{
pos = g_vhdboot_isobuf + g_vhdboot_bcd_offset;
pos = g_vhdboot_isobuf + bcdoffset;
/* winload.exe ==> winload.efi */
for (i = 0; i + (int)sizeof(winloadexe) < g_vhdboot_bcd_len; i++)
for (i = 0; i + (int)sizeof(winloadexe) < bcdlen; i++)
{
if (*((grub_uint32_t *)(pos + i)) == 0x00690077 &&
grub_memcmp(pos + i, winloadexe, sizeof(winloadexe)) == 0)
@ -127,7 +131,8 @@ static int ventoy_vhd_patch_path(char *vhdpath, ventoy_patch_vhd *patch1, ventoy
debug("winload patch %d times\n", cnt);
}
for (pos = vhdpath; *pos; pos++)
newpath = grub_strdup(vhdpath);
for (pos = newpath; *pos; pos++)
{
if (*pos == '/')
{
@ -135,40 +140,174 @@ static int ventoy_vhd_patch_path(char *vhdpath, ventoy_patch_vhd *patch1, ventoy
}
}
grub_utf8_to_utf16(unicode_path, pathlen, (grub_uint8_t *)vhdpath, -1, NULL);
grub_utf8_to_utf16(unicode_path, pathlen, (grub_uint8_t *)newpath, -1, NULL);
grub_memcpy(patch1->vhd_file_path, unicode_path, pathlen);
grub_memcpy(patch2->vhd_file_path, unicode_path, pathlen);
grub_free(newpath);
return 0;
}
static int ventoy_vhd_patch_disk(ventoy_patch_vhd *patch1, ventoy_patch_vhd *patch2)
static int ventoy_vhd_read_parttbl(const char *filename, ventoy_gpt_info *gpt, int *index, grub_uint64_t *poffset)
{
int i;
int find = 0;
int ret = 1;
grub_uint64_t start;
grub_file_t file = NULL;
grub_disk_t disk = NULL;
grub_uint8_t zeroguid[16] = {0};
file = grub_file_open(filename, VENTOY_FILE_TYPE);
if (!file)
{
goto end;
}
disk = grub_disk_open(file->device->disk->name);
if (!disk)
{
goto end;
}
grub_disk_read(disk, 0, 0, sizeof(ventoy_gpt_info), gpt);
start = file->device->disk->partition->start;
if (grub_memcmp(gpt->Head.Signature, "EFI PART", 8) == 0)
{
debug("GPT part start: %llu\n", (ulonglong)start);
for (i = 0; i < 128; i++)
{
if (grub_memcmp(gpt->PartTbl[i].PartGuid, zeroguid, 16))
{
if (start == gpt->PartTbl[i].StartLBA)
{
*index = i;
find = 1;
break;
}
}
}
}
else
{
debug("MBR part start: %llu\n", (ulonglong)start);
for (i = 0; i < 4; i++)
{
if ((grub_uint32_t)start == gpt->MBR.PartTbl[i].StartSectorId)
{
*index = i;
find = 1;
break;
}
}
}
if (find == 0) // MBR Logical partition
{
if (file->device->disk->partition->number > 0)
{
*index = file->device->disk->partition->number;
debug("Fall back part number: %d\n", *index);
}
}
*poffset = start;
ret = 0;
end:
check_free(file, grub_file_close);
check_free(disk, grub_disk_close);
return ret;
}
static int ventoy_vhd_patch_disk(const char *vhdpath, ventoy_patch_vhd *patch1, ventoy_patch_vhd *patch2)
{
int partIndex = 0;
grub_uint64_t offset = 0;
char efipart[16] = {0};
ventoy_gpt_info *gpt = NULL;
grub_memcpy(efipart, g_ventoy_part_info->Head.Signature, sizeof(g_ventoy_part_info->Head.Signature));
if (vhdpath[0] == '/')
{
gpt = g_ventoy_part_info;
partIndex = 0;
debug("This is Ventoy ISO partIndex %d %s\n", partIndex, vhdpath);
}
else
{
gpt = grub_zalloc(sizeof(ventoy_gpt_info));
ventoy_vhd_read_parttbl(vhdpath, gpt, &partIndex, &offset);
debug("This is HDD partIndex %d %s\n", partIndex, vhdpath);
}
debug("part1 type: 0x%x <%s>\n", g_ventoy_part_info->MBR.PartTbl[0].FsFlag, efipart);
grub_memcpy(efipart, gpt->Head.Signature, sizeof(gpt->Head.Signature));
grub_memset(patch1, 0, OFFSET_OF(ventoy_patch_vhd, vhd_file_path));
grub_memset(patch2, 0, OFFSET_OF(ventoy_patch_vhd, vhd_file_path));
if (grub_strncmp(efipart, "EFI PART", 8) == 0)
{
ventoy_debug_dump_guid("GPT disk GUID: ", g_ventoy_part_info->Head.DiskGuid);
ventoy_debug_dump_guid("GPT part GUID: ", g_ventoy_part_info->PartTbl[0].PartGuid);
ventoy_debug_dump_guid("GPT disk GUID: ", gpt->Head.DiskGuid);
ventoy_debug_dump_guid("GPT partIndex GUID: ", gpt->PartTbl[partIndex].PartGuid);
grub_memcpy(patch1->disk_signature_or_guid, g_ventoy_part_info->Head.DiskGuid, 16);
grub_memcpy(patch1->part_offset_or_guid, g_ventoy_part_info->PartTbl[0].PartGuid, 16);
grub_memcpy(patch2->disk_signature_or_guid, g_ventoy_part_info->Head.DiskGuid, 16);
grub_memcpy(patch2->part_offset_or_guid, g_ventoy_part_info->PartTbl[0].PartGuid, 16);
grub_memcpy(patch1->disk_signature_or_guid, gpt->Head.DiskGuid, 16);
grub_memcpy(patch1->part_offset_or_guid, gpt->PartTbl[partIndex].PartGuid, 16);
grub_memcpy(patch2->disk_signature_or_guid, gpt->Head.DiskGuid, 16);
grub_memcpy(patch2->part_offset_or_guid, gpt->PartTbl[partIndex].PartGuid, 16);
patch1->part_type = patch2->part_type = 0;
}
else
{
debug("MBR disk signature: %02x%02x%02x%02x\n",
g_ventoy_part_info->MBR.BootCode[0x1b8 + 0], g_ventoy_part_info->MBR.BootCode[0x1b8 + 1],
g_ventoy_part_info->MBR.BootCode[0x1b8 + 2], g_ventoy_part_info->MBR.BootCode[0x1b8 + 3]);
grub_memcpy(patch1->disk_signature_or_guid, g_ventoy_part_info->MBR.BootCode + 0x1b8, 4);
grub_memcpy(patch2->disk_signature_or_guid, g_ventoy_part_info->MBR.BootCode + 0x1b8, 4);
if (offset == 0)
{
offset = gpt->MBR.PartTbl[partIndex].StartSectorId;
}
offset *= 512;
debug("MBR disk signature: %02x%02x%02x%02x Part(%d) offset:%llu\n",
gpt->MBR.BootCode[0x1b8 + 0], gpt->MBR.BootCode[0x1b8 + 1],
gpt->MBR.BootCode[0x1b8 + 2], gpt->MBR.BootCode[0x1b8 + 3],
partIndex + 1, offset);
grub_memcpy(patch1->part_offset_or_guid, &offset, 8);
grub_memcpy(patch2->part_offset_or_guid, &offset, 8);
grub_memcpy(patch1->disk_signature_or_guid, gpt->MBR.BootCode + 0x1b8, 4);
grub_memcpy(patch2->disk_signature_or_guid, gpt->MBR.BootCode + 0x1b8, 4);
patch1->part_type = patch2->part_type = 1;
}
if (gpt != g_ventoy_part_info)
{
grub_free(gpt);
}
return 0;
}
static int ventoy_find_vhdpatch_offset(int bcdoffset, int bcdlen, int *offset)
{
int i;
int cnt = 0;
grub_uint8_t *buf = (grub_uint8_t *)(g_vhdboot_isobuf + bcdoffset);
grub_uint8_t magic[16] = {
0x5C, 0x00, 0x58, 0x00, 0x58, 0x00, 0x58, 0x00, 0x58, 0x00, 0x58, 0x00, 0x58, 0x00, 0x58, 0x00
};
for (i = 0; i < bcdlen - 16 && cnt < 2; i++)
{
if (*(grub_uint32_t *)(buf + i) == 0x0058005C)
{
if (grub_memcmp(magic, buf + i, 16) == 0)
{
*offset++ = i - (int)OFFSET_OF(ventoy_patch_vhd, vhd_file_path);
cnt++;
}
}
}
return 0;
@ -177,9 +316,10 @@ static int ventoy_vhd_patch_disk(ventoy_patch_vhd *patch1, ventoy_patch_vhd *pat
grub_err_t ventoy_cmd_patch_vhdboot(grub_extcmd_context_t ctxt, int argc, char **args)
{
int rc;
int bcdoffset, bcdlen;
int patchoffset[2];
ventoy_patch_vhd *patch1;
ventoy_patch_vhd *patch2;
char envbuf[64];
(void)ctxt;
(void)argc;
@ -194,33 +334,48 @@ grub_err_t ventoy_cmd_patch_vhdboot(grub_extcmd_context_t ctxt, int argc, char *
return 0;
}
rc = ventoy_vhd_find_bcd(&g_vhdboot_bcd_offset, &g_vhdboot_bcd_len);
rc = ventoy_vhd_find_bcd(&bcdoffset, &bcdlen, "/boot/bcd");
if (rc)
{
debug("failed to get bcd location %d\n", rc);
return 0;
}
else
{
ventoy_find_vhdpatch_offset(bcdoffset, bcdlen, patchoffset);
patch1 = (ventoy_patch_vhd *)(g_vhdboot_isobuf + bcdoffset + patchoffset[0]);
patch2 = (ventoy_patch_vhd *)(g_vhdboot_isobuf + bcdoffset + patchoffset[1]);
debug("Find /boot/bcd (%d %d) now patch it (offset: 0x%x 0x%x) ...\n",
bcdoffset, bcdlen, patchoffset[0], patchoffset[1]);
ventoy_vhd_patch_disk(args[0], patch1, patch2);
ventoy_vhd_patch_path(args[0], patch1, patch2, bcdoffset, bcdlen);
}
patch1 = (ventoy_patch_vhd *)(g_vhdboot_isobuf + g_vhdboot_bcd_offset + 0x495a);
patch2 = (ventoy_patch_vhd *)(g_vhdboot_isobuf + g_vhdboot_bcd_offset + 0x50aa);
ventoy_vhd_patch_disk(patch1, patch2);
ventoy_vhd_patch_path(args[0], patch1, patch2);
rc = ventoy_vhd_find_bcd(&bcdoffset, &bcdlen, "/boot/BCD");
if (rc)
{
debug("No file /boot/BCD \n");
}
else
{
ventoy_find_vhdpatch_offset(bcdoffset, bcdlen, patchoffset);
patch1 = (ventoy_patch_vhd *)(g_vhdboot_isobuf + bcdoffset + patchoffset[0]);
patch2 = (ventoy_patch_vhd *)(g_vhdboot_isobuf + bcdoffset + patchoffset[1]);
debug("Find /boot/BCD (%d %d) now patch it (offset: 0x%x 0x%x) ...\n",
bcdoffset, bcdlen, patchoffset[0], patchoffset[1]);
ventoy_vhd_patch_disk(args[0], patch1, patch2);
ventoy_vhd_patch_path(args[0], patch1, patch2, bcdoffset, bcdlen);
}
/* set buffer and size */
#ifdef GRUB_MACHINE_EFI
grub_snprintf(envbuf, sizeof(envbuf), "0x%lx", (ulong)g_vhdboot_totbuf);
grub_env_set("vtoy_vhd_buf_addr", envbuf);
grub_snprintf(envbuf, sizeof(envbuf), "%d", (int)(g_vhdboot_isolen + sizeof(ventoy_chain_head)));
grub_env_set("vtoy_vhd_buf_size", envbuf);
ventoy_memfile_env_set("vtoy_vhd_buf", g_vhdboot_totbuf, (ulonglong)(g_vhdboot_isolen + sizeof(ventoy_chain_head)));
#else
grub_snprintf(envbuf, sizeof(envbuf), "0x%lx", (ulong)g_vhdboot_isobuf);
grub_env_set("vtoy_vhd_buf_addr", envbuf);
grub_snprintf(envbuf, sizeof(envbuf), "%d", g_vhdboot_isolen);
grub_env_set("vtoy_vhd_buf_size", envbuf);
ventoy_memfile_env_set("vtoy_vhd_buf", g_vhdboot_isobuf, (ulonglong)g_vhdboot_isolen);
#endif
return 0;
VENTOY_CMD_RETURN(GRUB_ERR_NONE);
}
grub_err_t ventoy_cmd_load_vhdboot(grub_extcmd_context_t ctxt, int argc, char **args)
@ -349,7 +504,7 @@ grub_err_t ventoy_cmd_get_vtoy_type(grub_extcmd_context_t ctxt, int argc, char *
vhd_footer_t vhdfoot;
VDIPREHEADER vdihdr;
char type[16] = {0};
ventoy_gpt_info *gpt;
ventoy_gpt_info *gpt = NULL;
(void)ctxt;
@ -381,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_read(file, &vdihdr, sizeof(vdihdr));
if (vdihdr.u32Signature == VDI_IMAGE_SIGNATURE &&
grub_strncmp(vdihdr.szFileInfo, VDI_IMAGE_FILE_INFO, grub_strlen(VDI_IMAGE_FILE_INFO)) == 0)
if (vdihdr.u32Signature == VDI_IMAGE_SIGNATURE)
{
offset = 2 * 1048576;
g_img_trim_head_secnum = offset / 512;
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
{
@ -396,7 +564,7 @@ grub_err_t ventoy_cmd_get_vtoy_type(grub_extcmd_context_t ctxt, int argc, char *
}
grub_env_set(args[1], type);
debug("<%s> vtoy type: <%s> ", args[0], type);
debug("<%s> vtoy type: <%s> offset:%d\n", args[0], type, offset);
if (offset >= 0)
{
@ -413,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)
{
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;
}
@ -451,6 +619,14 @@ grub_err_t ventoy_cmd_get_vtoy_type(grub_extcmd_context_t ctxt, int argc, char *
altboot = 1;
grub_env_set(args[3], "1");
}
else
{
debug("offset data=0x%x\n", data);
}
}
else
{
debug("BootCode: 0x%x\n", gpt->MBR.BootCode[92]);
}
}
}
@ -490,7 +666,6 @@ grub_err_t ventoy_cmd_raw_chain_data(grub_extcmd_context_t ctxt, int argc, char
grub_disk_t disk;
const char *pLastChain = NULL;
ventoy_chain_head *chain;
char envbuf[64];
(void)ctxt;
(void)argc;
@ -512,6 +687,11 @@ grub_err_t ventoy_cmd_raw_chain_data(grub_extcmd_context_t ctxt, int argc, char
return 1;
}
if (grub_strncmp(args[0], g_iso_path, grub_strlen(g_iso_path)))
{
file->vlnk = 1;
}
img_chunk_size = g_img_chunk_list.cur_chunk * sizeof(ventoy_img_chunk);
size = sizeof(ventoy_chain_head) + img_chunk_size;
@ -527,18 +707,15 @@ grub_err_t ventoy_cmd_raw_chain_data(grub_extcmd_context_t ctxt, int argc, char
}
}
chain = grub_malloc(size);
chain = ventoy_alloc_chain(size);
if (!chain)
{
grub_printf("Failed to alloc chain memory size %u\n", size);
grub_printf("Failed to alloc chain raw memory size %u\n", size);
grub_file_close(file);
return 1;
}
grub_snprintf(envbuf, sizeof(envbuf), "0x%lx", (unsigned long)chain);
grub_env_set("vtoy_chain_mem_addr", envbuf);
grub_snprintf(envbuf, sizeof(envbuf), "%u", size);
grub_env_set("vtoy_chain_mem_size", envbuf);
ventoy_memfile_env_set("vtoy_chain_mem", chain, (ulonglong)size);
grub_env_export("vtoy_chain_mem_addr");
grub_env_export("vtoy_chain_mem_size");

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,329 @@
/*
* GRUB -- GRand Unified Bootloader
* Copyright (C) 1999,2000,2001,2002,2003,2004,2005,2006,2007,2008,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/>.
*/
#ifndef GRUB_CHARSET_HEADER
#define GRUB_CHARSET_HEADER 1
#include <grub/types.h>
#define GRUB_UINT8_1_LEADINGBIT 0x80
#define GRUB_UINT8_2_LEADINGBITS 0xc0
#define GRUB_UINT8_3_LEADINGBITS 0xe0
#define GRUB_UINT8_4_LEADINGBITS 0xf0
#define GRUB_UINT8_5_LEADINGBITS 0xf8
#define GRUB_UINT8_6_LEADINGBITS 0xfc
#define GRUB_UINT8_7_LEADINGBITS 0xfe
#define GRUB_UINT8_1_TRAILINGBIT 0x01
#define GRUB_UINT8_2_TRAILINGBITS 0x03
#define GRUB_UINT8_3_TRAILINGBITS 0x07
#define GRUB_UINT8_4_TRAILINGBITS 0x0f
#define GRUB_UINT8_5_TRAILINGBITS 0x1f
#define GRUB_UINT8_6_TRAILINGBITS 0x3f
#define GRUB_MAX_UTF8_PER_UTF16 4
/* You need at least one UTF-8 byte to have one UTF-16 word.
You need at least three UTF-8 bytes to have 2 UTF-16 words (surrogate pairs).
*/
#define GRUB_MAX_UTF16_PER_UTF8 1
#define GRUB_MAX_UTF8_PER_CODEPOINT 4
#define GRUB_UCS2_LIMIT 0x10000
#define GRUB_UTF16_UPPER_SURROGATE(code) \
(0xD800 | ((((code) - GRUB_UCS2_LIMIT) >> 10) & 0x3ff))
#define GRUB_UTF16_LOWER_SURROGATE(code) \
(0xDC00 | (((code) - GRUB_UCS2_LIMIT) & 0x3ff))
/* Process one character from UTF8 sequence.
At beginning set *code = 0, *count = 0. Returns 0 on failure and
1 on success. *count holds the number of trailing bytes. */
static inline int
grub_utf8_process (grub_uint8_t c, grub_uint32_t *code, int *count)
{
if (*count)
{
if ((c & GRUB_UINT8_2_LEADINGBITS) != GRUB_UINT8_1_LEADINGBIT)
{
*count = 0;
/* invalid */
return 0;
}
else
{
*code <<= 6;
*code |= (c & GRUB_UINT8_6_TRAILINGBITS);
(*count)--;
/* Overlong. */
if ((*count == 1 && *code <= 0x1f)
|| (*count == 2 && *code <= 0xf))
{
*code = 0;
*count = 0;
return 0;
}
return 1;
}
}
if ((c & GRUB_UINT8_1_LEADINGBIT) == 0)
{
*code = c;
return 1;
}
if ((c & GRUB_UINT8_3_LEADINGBITS) == GRUB_UINT8_2_LEADINGBITS)
{
*count = 1;
*code = c & GRUB_UINT8_5_TRAILINGBITS;
/* Overlong */
if (*code <= 1)
{
*count = 0;
*code = 0;
return 0;
}
return 1;
}
if ((c & GRUB_UINT8_4_LEADINGBITS) == GRUB_UINT8_3_LEADINGBITS)
{
*count = 2;
*code = c & GRUB_UINT8_4_TRAILINGBITS;
return 1;
}
if ((c & GRUB_UINT8_5_LEADINGBITS) == GRUB_UINT8_4_LEADINGBITS)
{
*count = 3;
*code = c & GRUB_UINT8_3_TRAILINGBITS;
return 1;
}
return 0;
}
/* Convert a (possibly null-terminated) UTF-8 string of at most SRCSIZE
bytes (if SRCSIZE is -1, it is ignored) in length to a UTF-16 string.
Return the number of characters converted. DEST must be able to hold
at least DESTSIZE characters. If an invalid sequence is found, return -1.
If SRCEND is not NULL, then *SRCEND is set to the next byte after the
last byte used in SRC. */
static inline grub_size_t
grub_utf8_to_utf16 (grub_uint16_t *dest, grub_size_t destsize,
const grub_uint8_t *src, grub_size_t srcsize,
const grub_uint8_t **srcend)
{
grub_uint16_t *p = dest;
int count = 0;
grub_uint32_t code = 0;
if (srcend)
*srcend = src;
while (srcsize && destsize)
{
int was_count = count;
if (srcsize != (grub_size_t)-1)
srcsize--;
if (!grub_utf8_process (*src++, &code, &count))
{
code = '?';
count = 0;
/* Character c may be valid, don't eat it. */
if (was_count)
src--;
}
if (count != 0)
continue;
if (code == 0)
break;
if (destsize < 2 && code >= GRUB_UCS2_LIMIT)
break;
if (code >= GRUB_UCS2_LIMIT)
{
*p++ = GRUB_UTF16_UPPER_SURROGATE (code);
*p++ = GRUB_UTF16_LOWER_SURROGATE (code);
destsize -= 2;
}
else
{
*p++ = code;
destsize--;
}
}
if (srcend)
*srcend = src;
return p - dest;
}
/* Determine the last position where the UTF-8 string [beg, end) can
be safely cut. */
static inline grub_size_t
grub_getend (const char *beg, const char *end)
{
const char *ptr;
for (ptr = end - 1; ptr >= beg; ptr--)
if ((*ptr & GRUB_UINT8_2_LEADINGBITS) != GRUB_UINT8_1_LEADINGBIT)
break;
if (ptr < beg)
return 0;
if ((*ptr & GRUB_UINT8_1_LEADINGBIT) == 0)
return ptr + 1 - beg;
if ((*ptr & GRUB_UINT8_3_LEADINGBITS) == GRUB_UINT8_2_LEADINGBITS
&& ptr + 2 <= end)
return ptr + 2 - beg;
if ((*ptr & GRUB_UINT8_4_LEADINGBITS) == GRUB_UINT8_3_LEADINGBITS
&& ptr + 3 <= end)
return ptr + 3 - beg;
if ((*ptr & GRUB_UINT8_5_LEADINGBITS) == GRUB_UINT8_4_LEADINGBITS
&& ptr + 4 <= end)
return ptr + 4 - beg;
/* Invalid character or incomplete. Cut before it. */
return ptr - beg;
}
/* Convert UTF-16 to UTF-8. */
static inline grub_uint8_t *
grub_utf16_to_utf8 (grub_uint8_t *dest, const grub_uint16_t *src,
grub_size_t size)
{
grub_uint32_t code_high = 0;
while (size--)
{
grub_uint32_t code = *src++;
if (code_high)
{
if (code >= 0xDC00 && code <= 0xDFFF)
{
/* Surrogate pair. */
code = ((code_high - 0xD800) << 10) + (code - 0xDC00) + 0x10000;
*dest++ = (code >> 18) | 0xF0;
*dest++ = ((code >> 12) & 0x3F) | 0x80;
*dest++ = ((code >> 6) & 0x3F) | 0x80;
*dest++ = (code & 0x3F) | 0x80;
}
else
{
/* Error... */
*dest++ = '?';
/* *src may be valid. Don't eat it. */
src--;
}
code_high = 0;
}
else
{
if (code <= 0x007F)
*dest++ = code;
else if (code <= 0x07FF)
{
*dest++ = (code >> 6) | 0xC0;
*dest++ = (code & 0x3F) | 0x80;
}
else if (code >= 0xD800 && code <= 0xDBFF)
{
code_high = code;
continue;
}
else if (code >= 0xDC00 && code <= 0xDFFF)
{
/* Error... */
*dest++ = '?';
}
else if (code < 0x10000)
{
*dest++ = (code >> 12) | 0xE0;
*dest++ = ((code >> 6) & 0x3F) | 0x80;
*dest++ = (code & 0x3F) | 0x80;
}
else
{
*dest++ = (code >> 18) | 0xF0;
*dest++ = ((code >> 12) & 0x3F) | 0x80;
*dest++ = ((code >> 6) & 0x3F) | 0x80;
*dest++ = (code & 0x3F) | 0x80;
}
}
}
return dest;
}
#define GRUB_MAX_UTF8_PER_LATIN1 2
/* Convert Latin1 to UTF-8. */
static inline grub_uint8_t *
grub_latin1_to_utf8 (grub_uint8_t *dest, const grub_uint8_t *src,
grub_size_t size)
{
while (size--)
{
if (!(*src & 0x80))
*dest++ = *src;
else
{
*dest++ = (*src >> 6) | 0xC0;
*dest++ = (*src & 0x3F) | 0x80;
}
src++;
}
return dest;
}
/* Convert UCS-4 to UTF-8. */
char *grub_ucs4_to_utf8_alloc (const grub_uint32_t *src, grub_size_t size);
int
grub_is_valid_utf8 (const grub_uint8_t *src, grub_size_t srcsize);
grub_ssize_t grub_utf8_to_ucs4_alloc (const char *msg,
grub_uint32_t **unicode_msg,
grub_uint32_t **last_position);
/* Returns the number of bytes the string src would occupy is converted
to UTF-8, excluding \0. */
grub_size_t
grub_get_num_of_utf8_bytes (const grub_uint32_t *src, grub_size_t size);
/* Converts UCS-4 to UTF-8. Returns the number of bytes effectively written
excluding the trailing \0. */
grub_size_t
grub_ucs4_to_utf8 (const grub_uint32_t *src, grub_size_t size,
grub_uint8_t *dest, grub_size_t destsize);
grub_size_t grub_utf8_to_ucs4 (grub_uint32_t *dest, grub_size_t destsize,
const grub_uint8_t *src, grub_size_t srcsize,
const grub_uint8_t **srcend);
/* Returns -2 if not enough space, -1 on invalid character. */
grub_ssize_t
grub_encode_utf8_character (grub_uint8_t *dest, grub_uint8_t *destend,
grub_uint32_t code);
const grub_uint32_t *
grub_unicode_get_comb_start (const grub_uint32_t *str,
const grub_uint32_t *cur);
int
grub_utf8_get_num_code (const char *src, grub_size_t srcsize);
const char *
grub_utf8_offset_code (const char *src, grub_size_t srcsize, int num);
#endif

View File

@ -314,6 +314,11 @@
{ 0x9a, 0x16, 0x0, 0x90, 0x27, 0x3f, 0xc1, 0x4d } \
}
#define GRUB_EFI_SMBIOS3_TABLE_GUID \
{ 0xf2fd1544, 0x9794, 0x4a2c, \
{ 0x99, 0x2e, 0xe5, 0xbb, 0xcf, 0x20, 0xe3, 0x94 } \
}
#define GRUB_EFI_SAL_TABLE_GUID \
{ 0xeb9d2d32, 0x2d88, 0x11d3, \
{ 0x9a, 0x16, 0x0, 0x90, 0x27, 0x3f, 0xc1, 0x4d } \

View File

@ -87,7 +87,8 @@ EXPORT_FUNC (grub_efi_compare_device_paths) (const grub_efi_device_path_t *dp1,
const grub_efi_device_path_t *dp2);
void * EXPORT_FUNC (grub_efi_allocate_iso_buf) (grub_uint64_t size);
void * EXPORT_FUNC (grub_efi_allocate_chain_buf) (grub_uint64_t size);
void EXPORT_FUNC (grub_efi_get_reserved_page_num) (grub_uint64_t *total, grub_uint64_t *org_required, grub_uint64_t *new_required);
extern void (*EXPORT_VAR(grub_efi_net_config)) (grub_efi_handle_t hnd,
char **device,

View File

@ -0,0 +1,73 @@
/*
* GRUB -- GRand Unified Bootloader
* Copyright (C) 2003,2005,2006,2007,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/>.
*/
#ifndef GRUB_ENV_HEADER
#define GRUB_ENV_HEADER 1
#include <grub/symbol.h>
#include <grub/err.h>
#include <grub/types.h>
#include <grub/menu.h>
struct grub_env_var;
typedef const char *(*grub_env_read_hook_t) (struct grub_env_var *var,
const char *val);
typedef char *(*grub_env_write_hook_t) (struct grub_env_var *var,
const char *val);
struct grub_env_var
{
char *name;
char *value;
grub_env_read_hook_t read_hook;
grub_env_write_hook_t write_hook;
struct grub_env_var *next;
struct grub_env_var **prevp;
struct grub_env_var *sorted_next;
int global;
};
grub_err_t EXPORT_FUNC(grub_env_set) (const char *name, const char *val);
const char *EXPORT_FUNC(grub_env_get) (const char *name);
void EXPORT_FUNC(grub_env_unset) (const char *name);
struct grub_env_var *EXPORT_FUNC(grub_env_update_get_sorted) (void);
#define FOR_SORTED_ENV(var) for (var = grub_env_update_get_sorted (); var; var = var->sorted_next)
grub_err_t EXPORT_FUNC(grub_register_variable_hook) (const char *name,
grub_env_read_hook_t read_hook,
grub_env_write_hook_t write_hook);
grub_err_t EXPORT_FUNC(grub_register_vtoy_menu_lang_hook) (grub_env_read_hook_t read_hook);
grub_err_t grub_env_context_open (void);
grub_err_t grub_env_context_close (void);
grub_err_t EXPORT_FUNC(grub_env_export) (const char *name);
void grub_env_unset_menu (void);
grub_menu_t grub_env_get_menu (void);
void grub_env_set_menu (grub_menu_t nmenu);
grub_err_t
grub_env_extractor_open (int source);
grub_err_t
grub_env_extractor_close (int source);
#endif /* ! GRUB_ENV_HEADER */

View File

@ -132,7 +132,8 @@ enum grub_file_type
/* --skip-sig is specified. */
GRUB_FILE_TYPE_SKIP_SIGNATURE = 0x10000,
GRUB_FILE_TYPE_NO_DECOMPRESS = 0x20000
GRUB_FILE_TYPE_NO_DECOMPRESS = 0x20000,
GRUB_FILE_TYPE_NO_VLNK = 0x40000,
};
/* File description. */
@ -141,6 +142,8 @@ struct grub_file
/* File name. */
char *name;
int vlnk;
/* The underlying device. */
grub_device_t device;
@ -213,6 +216,11 @@ grub_ssize_t EXPORT_FUNC(grub_file_read) (grub_file_t file, void *buf,
grub_off_t EXPORT_FUNC(grub_file_seek) (grub_file_t file, grub_off_t offset);
grub_err_t EXPORT_FUNC(grub_file_close) (grub_file_t file);
int EXPORT_FUNC(grub_file_is_vlnk_suffix)(const char *name, int len);
int EXPORT_FUNC(grub_file_add_vlnk)(const char *src, const char *dst);
int EXPORT_FUNC(grub_file_vtoy_vlnk)(const char *src, const char *dst);
const char * EXPORT_FUNC(grub_file_get_vlnk)(const char *name, int *vlnk);
/* Return value of grub_file_size() in case file size is unknown. */
#define GRUB_FILE_SIZE_UNKNOWN 0xffffffffffffffffULL

View File

@ -128,5 +128,6 @@ grub_fs_unregister (grub_fs_t fs)
#define FOR_FILESYSTEMS(var) FOR_LIST_ELEMENTS((var), (grub_fs_list))
grub_fs_t EXPORT_FUNC(grub_fs_probe) (grub_device_t device);
grub_fs_t EXPORT_FUNC(grub_fs_list_probe) (grub_device_t device, const char **list);
#endif /* ! GRUB_FS_HEADER */

View File

@ -0,0 +1,128 @@
/* gfxmenu_view.h - gfxmenu view interface. */
/*
* GRUB -- GRand Unified Bootloader
* Copyright (C) 2008,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/>.
*/
#ifndef GRUB_GFXMENU_VIEW_HEADER
#define GRUB_GFXMENU_VIEW_HEADER 1
#include <grub/types.h>
#include <grub/err.h>
#include <grub/menu.h>
#include <grub/font.h>
#include <grub/gfxwidgets.h>
struct grub_gfxmenu_view; /* Forward declaration of opaque type. */
typedef struct grub_gfxmenu_view *grub_gfxmenu_view_t;
grub_gfxmenu_view_t grub_gfxmenu_view_new (const char *theme_path,
int width, int height);
void grub_gfxmenu_view_destroy (grub_gfxmenu_view_t view);
/* Set properties on the view based on settings from the specified
theme file. */
grub_err_t grub_gfxmenu_view_load_theme (grub_gfxmenu_view_t view,
const char *theme_path);
grub_err_t grub_gui_recreate_box (grub_gfxmenu_box_t *boxptr,
const char *pattern, const char *theme_dir);
void grub_gfxmenu_view_draw (grub_gfxmenu_view_t view);
void
grub_gfxmenu_redraw_menu (grub_gfxmenu_view_t view);
void
grub_gfxmenu_redraw_timeout (grub_gfxmenu_view_t view);
void
grub_gfxmenu_view_redraw (grub_gfxmenu_view_t view,
const grub_video_rect_t *region);
void
grub_gfxmenu_clear_timeout (void *data);
void
grub_gfxmenu_print_timeout (int timeout, void *data);
void
grub_gfxmenu_set_chosen_entry (int entry, void *data);
void
grub_gfxmenu_scroll_chosen_entry (void *data, int diren);
grub_err_t grub_font_draw_string (const char *str,
grub_font_t font,
grub_video_color_t color,
int left_x, int baseline_y);
int grub_font_get_string_width (grub_font_t font,
const char *str);
/* Implementation details -- this should not be used outside of the
view itself. */
#include <grub/video.h>
#include <grub/bitmap.h>
#include <grub/bitmap_scale.h>
#include <grub/gui.h>
#include <grub/gfxwidgets.h>
#include <grub/icon_manager.h>
/* Definition of the private representation of the view. */
struct grub_gfxmenu_view
{
grub_video_rect_t screen;
int need_to_check_sanity;
grub_video_rect_t terminal_rect;
int terminal_border;
grub_font_t title_font;
grub_font_t message_font;
char *terminal_font_name;
grub_video_rgba_color_t title_color;
grub_video_rgba_color_t message_color;
grub_video_rgba_color_t message_bg_color;
struct grub_video_bitmap *raw_desktop_image;
struct grub_video_bitmap *scaled_desktop_image;
grub_video_bitmap_selection_method_t desktop_image_scale_method;
grub_video_bitmap_h_align_t desktop_image_h_align;
grub_video_bitmap_v_align_t desktop_image_v_align;
grub_video_rgba_color_t desktop_color;
grub_gfxmenu_box_t terminal_box;
char *title_text;
char *progress_message_text;
char *theme_path;
grub_gui_container_t canvas;
int double_repaint;
int selected;
grub_video_rect_t progress_message_frame;
grub_menu_t menu;
int nested;
int first_timeout;
int *menu_title_offset;
};
#endif /* ! GRUB_GFXMENU_VIEW_HEADER */

View File

@ -0,0 +1,49 @@
/* menu_viewer.h - Interface to menu viewer implementations. */
/*
* 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/>.
*/
#ifndef GRUB_MENU_VIEWER_HEADER
#define GRUB_MENU_VIEWER_HEADER 1
#include <grub/err.h>
#include <grub/symbol.h>
#include <grub/types.h>
#include <grub/menu.h>
#include <grub/term.h>
struct grub_menu_viewer
{
struct grub_menu_viewer *next;
void *data;
void (*set_chosen_entry) (int entry, void *data);
void (*scroll_chosen_entry) (void *data, int diren);
void (*print_timeout) (int timeout, void *data);
void (*clear_timeout) (void *data);
void (*fini) (void *fini);
};
void grub_menu_register_viewer (struct grub_menu_viewer *viewer);
grub_err_t
grub_menu_try_text (struct grub_term_output *term,
int entry, grub_menu_t menu, int nested);
extern grub_err_t (*grub_gfxmenu_try_hook) (int entry, grub_menu_t menu,
int nested);
#endif /* GRUB_MENU_VIEWER_HEADER */

View File

@ -0,0 +1,141 @@
/*
* GRUB -- GRand Unified Bootloader
* Copyright (C) 1999,2000,2001,2002,2004,2006,2007 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/>.
*/
#ifndef GRUB_PART_HEADER
#define GRUB_PART_HEADER 1
#include <grub/dl.h>
#include <grub/list.h>
struct grub_disk;
typedef struct grub_partition *grub_partition_t;
#ifdef GRUB_UTIL
typedef enum
{
GRUB_EMBED_PCBIOS
} grub_embed_type_t;
#endif
typedef int (*grub_partition_iterate_hook_t) (struct grub_disk *disk,
const grub_partition_t partition,
void *data);
/* Partition map type. */
struct grub_partition_map
{
/* The next partition map type. */
struct grub_partition_map *next;
struct grub_partition_map **prev;
/* The name of the partition map type. */
const char *name;
/* Call HOOK with each partition, until HOOK returns non-zero. */
grub_err_t (*iterate) (struct grub_disk *disk,
grub_partition_iterate_hook_t hook, void *hook_data);
#ifdef GRUB_UTIL
/* Determine sectors available for embedding. */
grub_err_t (*embed) (struct grub_disk *disk, unsigned int *nsectors,
unsigned int max_nsectors,
grub_embed_type_t embed_type,
grub_disk_addr_t **sectors);
#endif
};
typedef struct grub_partition_map *grub_partition_map_t;
/* Partition description. */
struct grub_partition
{
/* The partition number. */
int number;
/* The start sector (relative to parent). */
grub_disk_addr_t start;
/* The length in sector units. */
grub_uint64_t len;
/* The offset of the partition table. */
grub_disk_addr_t offset;
/* The index of this partition in the partition table. */
int index;
/* Parent partition (physically contains this partition). */
struct grub_partition *parent;
/* The type partition map. */
grub_partition_map_t partmap;
/* The type of partition whne it's on MSDOS.
Used for embedding detection. */
grub_uint8_t msdostype;
/* The attrib field for GPT. Needed for priority detection. */
grub_uint64_t gpt_attrib;
};
grub_partition_t EXPORT_FUNC(grub_partition_probe) (struct grub_disk *disk,
const char *str);
int EXPORT_FUNC(grub_partition_iterate) (struct grub_disk *disk,
grub_partition_iterate_hook_t hook,
void *hook_data);
char *EXPORT_FUNC(grub_partition_get_name) (const grub_partition_t partition);
extern grub_partition_map_t EXPORT_VAR(grub_partition_map_list);
#ifndef GRUB_LST_GENERATOR
static inline void
grub_partition_map_register (grub_partition_map_t partmap)
{
grub_list_push (GRUB_AS_LIST_P (&grub_partition_map_list),
GRUB_AS_LIST (partmap));
}
#endif
static inline void
grub_partition_map_unregister (grub_partition_map_t partmap)
{
grub_list_remove (GRUB_AS_LIST (partmap));
}
#define FOR_PARTITION_MAPS(var) FOR_LIST_ELEMENTS((var), (grub_partition_map_list))
static inline grub_disk_addr_t
grub_partition_get_start (const grub_partition_t p)
{
grub_partition_t part;
grub_uint64_t part_start = 0;
for (part = p; part; part = part->parent)
part_start += part->start;
return part_start;
}
static inline grub_uint64_t
grub_partition_get_len (const grub_partition_t p)
{
return p->len;
}
#endif /* ! GRUB_PART_HEADER */

View File

@ -0,0 +1,69 @@
/*
* GRUB -- GRand Unified Bootloader
* Copyright (C) 2019 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/>.
*/
#ifndef GRUB_SMBIOS_HEADER
#define GRUB_SMBIOS_HEADER 1
#include <grub/symbol.h>
#include <grub/types.h>
#define GRUB_SMBIOS_TYPE_END_OF_TABLE ((grub_uint8_t)127)
struct grub_smbios_ieps
{
grub_uint8_t anchor[5]; /* "_DMI_" */
grub_uint8_t checksum;
grub_uint16_t table_length;
grub_uint32_t table_address;
grub_uint16_t structures;
grub_uint8_t revision;
} GRUB_PACKED;
struct grub_smbios_eps
{
grub_uint8_t anchor[4]; /* "_SM_" */
grub_uint8_t checksum;
grub_uint8_t length; /* 0x1f */
grub_uint8_t version_major;
grub_uint8_t version_minor;
grub_uint16_t maximum_structure_size;
grub_uint8_t revision;
grub_uint8_t formatted[5];
struct grub_smbios_ieps intermediate;
} GRUB_PACKED;
struct grub_smbios_eps3
{
grub_uint8_t anchor[5]; /* "_SM3_" */
grub_uint8_t checksum;
grub_uint8_t length; /* 0x18 */
grub_uint8_t version_major;
grub_uint8_t version_minor;
grub_uint8_t docrev;
grub_uint8_t revision;
grub_uint8_t reserved;
grub_uint32_t maximum_table_length;
grub_uint64_t table_address;
} GRUB_PACKED;
extern struct grub_smbios_eps *grub_machine_smbios_get_eps (void);
extern struct grub_smbios_eps3 *grub_machine_smbios_get_eps3 (void);
extern struct grub_smbios_eps *EXPORT_FUNC (grub_smbios_get_eps) (void);
#endif /* ! GRUB_SMBIOS_HEADER */

View File

@ -121,6 +121,9 @@ typedef struct ventoy_os_param
* vtoy_reserved[2]: vtoy_chain_type 0:Linux 1:Windows 2:wimfile
* vtoy_reserved[3]: vtoy_iso_format 0:iso9660 1:udf
* vtoy_reserved[4]: vtoy_windows_cd_prompt
* vtoy_reserved[5]: vtoy_linux_remount
* vtoy_reserved[6]: vtoy_vlnk
* vtoy_reserved[7~10]: vtoy_disk_sig[4] used for vlnk
*
*/
grub_uint8_t vtoy_reserved[32]; // Internal use by ventoy
@ -135,7 +138,16 @@ typedef struct ventoy_windows_data
{
char auto_install_script[384];
char injection_archive[384];
grub_uint8_t reserved[256];
grub_uint8_t windows11_bypass_check;
grub_uint32_t auto_install_len;
grub_uint8_t windows11_bypass_nro;
grub_uint8_t reserved[255 - 5];
/* auto_intall file buf */
/* ...... + auto_install_len */
}ventoy_windows_data;
@ -149,11 +161,23 @@ typedef struct ventoy_secure_data
grub_uint8_t magic2[16]; /* VENTOY_GUID */
}ventoy_secure_data;
typedef struct ventoy_vlnk
{
ventoy_guid guid; // VENTOY_GUID
grub_uint32_t crc32; // crc32
grub_uint32_t disk_signature;
grub_uint64_t part_offset; // in bytes
char filepath[384];
grub_uint8_t reserved[96];
}ventoy_vlnk;
#pragma pack()
// compile assert check : sizeof(ventoy_os_param) must be 512
COMPILE_ASSERT(1,sizeof(ventoy_os_param) == 512);
COMPILE_ASSERT(2,sizeof(ventoy_secure_data) == 4096);
COMPILE_ASSERT(3,sizeof(ventoy_vlnk) == 512);
@ -240,7 +264,9 @@ typedef struct ventoy_img_chunk_list
#pragma pack(1)
#define VTOY_MAX_CONF_REPLACE 2
#define GRUB_FILE_REPLACE_MAGIC 0x1258BEEF
#define GRUB_IMG_REPLACE_MAGIC 0x1259BEEF
typedef const char * (*grub_env_get_pf)(const char *name);
typedef int (*grub_env_set_pf)(const char *name, const char *val);
@ -259,6 +285,7 @@ typedef struct ventoy_grub_param
grub_env_get_pf grub_env_get;
grub_env_set_pf grub_env_set;
ventoy_grub_param_file_replace file_replace;
ventoy_grub_param_file_replace img_replace[VTOY_MAX_CONF_REPLACE];
grub_env_printf_pf grub_env_printf;
}ventoy_grub_param;
@ -267,6 +294,7 @@ typedef struct ventoy_grub_param
int grub_ext_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);
int grub_iso9660_is_joliet(void);
grub_uint64_t grub_iso9660_get_last_read_pos(grub_file_t file);
grub_uint64_t grub_iso9660_get_last_file_dirent_pos(grub_file_t file);
grub_uint64_t grub_udf_get_file_offset(grub_file_t file);
@ -278,6 +306,7 @@ grub_uint64_t grub_udf_get_last_file_attr_offset
grub_uint64_t *fe_entry_size_offset
);
int ventoy_is_efi_os(void);
void ventoy_memfile_env_set(const char *prefix, const void *buf, unsigned long long len);
#endif /* __VENTOY_H__ */

View File

@ -9,17 +9,17 @@ mkdir -p $VT_DIR/GRUB2/PXE
make install
PATH=$PATH:$VT_DIR/GRUB2/INSTALL/bin/:$VT_DIR/GRUB2/INSTALL/sbin/
PATH=$VT_DIR/GRUB2/INSTALL/bin/:$VT_DIR/GRUB2/INSTALL/sbin/:$PATH
net_modules_legacy="net tftp http"
all_modules_legacy="setkey date drivemap blocklist regexp newc vga_text ntldr search at_keyboard usb_keyboard gcry_md5 hashsum gzio xzio lzopio lspci pci ext2 xfs ventoy chain read halt iso9660 linux16 test true sleep reboot echo videotest videoinfo videotest_checksum video_colors video_cirrus video_bochs vga vbe video_fb font video gettext extcmd terminal linux minicmd help configfile tr trig boot biosdisk disk ls tar squash4 password_pbkdf2 all_video png jpeg part_gpt part_msdos fat exfat ntfs loopback gzio normal udf gfxmenu gfxterm gfxterm_background gfxterm_menu"
all_modules_legacy="file date drivemap blocklist newc vga_text ntldr search at_keyboard usb_keyboard gcry_md5 hashsum gzio xzio lzopio lspci pci ext2 xfs ventoy chain read halt iso9660 linux16 test true sleep reboot echo videotest videoinfo videotest_checksum video_colors video_cirrus video_bochs vga vbe font video gettext extcmd terminal linux minicmd help configfile tr trig boot biosdisk disk ls tar squash4 password_pbkdf2 all_video png jpeg part_gpt part_msdos fat exfat ntfs loopback gzio normal video_fb udf gfxmenu gfxterm gfxterm_background gfxterm_menu smbios"
net_modules_uefi="efinet net tftp http"
all_modules_uefi="setkey blocklist ventoy test true regexp newc search at_keyboard usb_keyboard gcry_md5 hashsum gzio xzio lzopio ext2 xfs read halt sleep serial terminfo png password_pbkdf2 gcry_sha512 pbkdf2 part_gpt part_msdos ls tar squash4 loopback part_apple minicmd diskfilter linux relocator jpeg iso9660 udf hfsplus halt acpi mmap gfxmenu video_colors trig bitmap_scale gfxterm bitmap font fat exfat ntfs fshelp efifwsetup reboot echo configfile normal terminal gettext chain priority_queue bufio datetime cat extcmd crypto gzio boot all_video efi_gop efi_uga video_bochs video_cirrus video video_fb gfxterm_background gfxterm_menu"
all_modules_uefi="file setkey blocklist ventoy test true regexp newc search at_keyboard usb_keyboard gcry_md5 hashsum gzio xzio lzopio ext2 xfs read halt sleep serial terminfo png password_pbkdf2 gcry_sha512 pbkdf2 part_gpt part_msdos ls tar squash4 loopback part_apple minicmd diskfilter linux relocator jpeg iso9660 udf hfsplus halt acpi mmap gfxmenu video_colors trig bitmap_scale gfxterm bitmap font fat exfat ntfs fshelp efifwsetup reboot echo configfile normal terminal gettext chain priority_queue bufio datetime cat extcmd crypto gzio boot all_video efi_gop efi_uga video_bochs video_cirrus video video_fb gfxterm_background gfxterm_menu mouse fwload smbios zfs"
all_modules_arm64_uefi="setkey blocklist ventoy test true regexp newc search gcry_md5 hashsum gzio xzio lzopio ext2 xfs read halt sleep serial terminfo png password_pbkdf2 gcry_sha512 pbkdf2 part_gpt part_msdos ls tar squash4 loopback part_apple minicmd diskfilter linux jpeg iso9660 udf hfsplus halt acpi mmap gfxmenu video_colors trig bitmap_scale gfxterm bitmap font fat exfat ntfs fshelp efifwsetup reboot echo configfile normal terminal gettext chain priority_queue bufio datetime cat extcmd crypto gzio boot all_video efi_gop video video_fb gfxterm_background gfxterm_menu"
all_modules_arm64_uefi="file setkey blocklist ventoy test true regexp newc search gcry_md5 hashsum gzio xzio lzopio ext2 xfs read halt sleep serial terminfo png password_pbkdf2 gcry_sha512 pbkdf2 part_gpt part_msdos ls tar squash4 loopback part_apple minicmd diskfilter linux jpeg iso9660 udf hfsplus halt acpi mmap gfxmenu video_colors trig bitmap_scale gfxterm bitmap font fat exfat ntfs fshelp efifwsetup reboot echo configfile normal terminal gettext chain priority_queue bufio datetime cat extcmd crypto gzio boot all_video efi_gop video video_fb gfxterm_background gfxterm_menu zfs"
all_modules_mips64el_uefi="setkey blocklist ventoy test true regexp newc search gcry_md5 hashsum gzio xzio lzopio ext2 xfs read halt sleep serial terminfo png password_pbkdf2 gcry_sha512 pbkdf2 part_gpt part_msdos ls tar squash4 loopback part_apple minicmd diskfilter linux jpeg iso9660 udf hfsplus halt acpi mmap gfxmenu video_colors trig bitmap_scale gfxterm bitmap font fat exfat ntfs fshelp efifwsetup reboot echo configfile normal terminal gettext chain priority_queue bufio datetime cat extcmd crypto gzio boot all_video efi_gop video video_fb gfxterm_background gfxterm_menu"
all_modules_mips64el_uefi="file setkey blocklist ventoy test true regexp newc search gcry_md5 hashsum gzio xzio lzopio ext2 xfs read halt sleep serial terminfo png password_pbkdf2 gcry_sha512 pbkdf2 part_gpt part_msdos ls tar squash4 loopback part_apple minicmd diskfilter linux jpeg iso9660 udf hfsplus halt acpi mmap gfxmenu video_colors trig bitmap_scale gfxterm bitmap font fat exfat ntfs fshelp efifwsetup reboot echo configfile normal terminal gettext chain priority_queue bufio datetime cat extcmd crypto gzio boot all_video efi_gop video video_fb gfxterm_background gfxterm_menu zfs"
if [ "$1" = "uefi" ]; then
@ -97,6 +97,8 @@ elif [ "$1" = "arm64" ]; then
if ! echo $all_modules | grep -q " ${line%.mod} "; then
echo "Copy $line ..."
cp -a $VT_DIR/GRUB2/INSTALL/lib/grub/arm64-efi/$line $VT_DIR/INSTALL/grub/arm64-efi/
xz $VT_DIR/INSTALL/grub/arm64-efi/$line
mv $VT_DIR/INSTALL/grub/arm64-efi/${line}.xz $VT_DIR/INSTALL/grub/arm64-efi/${line}
fi
done
elif [ "$1" = "mips64el" ]; then

View File

@ -1165,6 +1165,7 @@ main (int argc, char *argv[])
break;
case GRUB_INSTALL_PLATFORM_MIPS64EL_EFI:
efi_file = "grubmips64el.efi";
break;
case GRUB_INSTALL_PLATFORM_RISCV32_EFI:
efi_file = "grubriscv32.efi";
break;

View File

@ -0,0 +1,878 @@
/* grub-setup.c - make GRUB usable */
/*
* GRUB -- GRand Unified Bootloader
* Copyright (C) 1999,2000,2001,2002,2003,2004,2005,2006,2007,2008,2009,2010,2011 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 <config.h>
#include <grub/types.h>
#include <grub/emu/misc.h>
#include <grub/util/misc.h>
#include <grub/device.h>
#include <grub/disk.h>
#include <grub/file.h>
#include <grub/fs.h>
#include <grub/partition.h>
#include <grub/env.h>
#include <grub/emu/hostdisk.h>
#include <grub/term.h>
#include <grub/i18n.h>
#ifdef GRUB_SETUP_SPARC64
#include <grub/util/ofpath.h>
#include <grub/sparc64/ieee1275/boot.h>
#include <grub/sparc64/ieee1275/kernel.h>
#else
#include <grub/i386/pc/boot.h>
#include <grub/i386/pc/kernel.h>
#endif
#include <stdio.h>
#include <unistd.h>
#include <string.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <dirent.h>
#include <assert.h>
#include <grub/emu/getroot.h>
#include "progname.h"
#include <grub/reed_solomon.h>
#include <grub/msdos_partition.h>
#include <grub/crypto.h>
#include <grub/util/install.h>
#include <grub/emu/hostfile.h>
#include <errno.h>
/* On SPARC this program fills in various fields inside of the 'boot' and 'core'
* image files.
*
* The 'boot' image needs to know the OBP path name of the root
* device. It also needs to know the initial block number of
* 'core' (which is 'diskboot' concatenated with 'kernel' and
* all the modules, this is created by grub-mkimage). This resulting
* 'boot' image is 512 bytes in size and is placed in the second block
* of a partition.
*
* The initial 'diskboot' block acts as a loader for the actual GRUB
* kernel. It contains the loading code and then a block list.
*
* The block list of 'core' starts at the end of the 'diskboot' image
* and works it's way backwards towards the end of the code of 'diskboot'.
*
* We patch up the images with the necessary values and write out the
* result.
*/
#ifdef GRUB_SETUP_SPARC64
#define grub_target_to_host16(x) grub_be_to_cpu16(x)
#define grub_target_to_host32(x) grub_be_to_cpu32(x)
#define grub_target_to_host64(x) grub_be_to_cpu64(x)
#define grub_host_to_target16(x) grub_cpu_to_be16(x)
#define grub_host_to_target32(x) grub_cpu_to_be32(x)
#define grub_host_to_target64(x) grub_cpu_to_be64(x)
#elif defined (GRUB_SETUP_BIOS)
#define grub_target_to_host16(x) grub_le_to_cpu16(x)
#define grub_target_to_host32(x) grub_le_to_cpu32(x)
#define grub_target_to_host64(x) grub_le_to_cpu64(x)
#define grub_host_to_target16(x) grub_cpu_to_le16(x)
#define grub_host_to_target32(x) grub_cpu_to_le32(x)
#define grub_host_to_target64(x) grub_cpu_to_le64(x)
#else
#error Complete this
#endif
static void
write_rootdev (grub_device_t root_dev,
char *boot_img, grub_uint64_t first_sector)
{
#ifdef GRUB_SETUP_BIOS
{
grub_uint8_t *boot_drive;
void *kernel_sector;
boot_drive = (grub_uint8_t *) (boot_img + GRUB_BOOT_MACHINE_BOOT_DRIVE);
kernel_sector = (boot_img + GRUB_BOOT_MACHINE_KERNEL_SECTOR);
/* FIXME: can this be skipped? */
*boot_drive = 0xFF;
grub_set_unaligned64 (kernel_sector, grub_cpu_to_le64 (first_sector));
}
#endif
#ifdef GRUB_SETUP_SPARC64
{
void *kernel_byte;
kernel_byte = (boot_img + GRUB_BOOT_AOUT_HEADER_SIZE
+ GRUB_BOOT_MACHINE_KERNEL_BYTE);
grub_set_unaligned64 (kernel_byte,
grub_cpu_to_be64 (first_sector << GRUB_DISK_SECTOR_BITS));
}
#endif
}
#ifdef GRUB_SETUP_SPARC64
#define BOOT_SECTOR 1
#else
#define BOOT_SECTOR 0
#endif
/* Helper for setup. */
struct blocklists
{
struct grub_boot_blocklist *first_block, *block;
#ifdef GRUB_SETUP_BIOS
grub_uint16_t current_segment;
#endif
#ifdef GRUB_SETUP_SPARC64
grub_uint64_t gpt_offset;
#endif
grub_uint16_t last_length;
grub_disk_addr_t first_sector;
};
/* Helper for setup. */
static void
save_blocklists (grub_disk_addr_t sector, unsigned offset, unsigned length,
void *data)
{
struct blocklists *bl = data;
struct grub_boot_blocklist *prev = bl->block + 1;
grub_uint64_t seclen;
#ifdef GRUB_SETUP_SPARC64
sector -= bl->gpt_offset;
#endif
grub_util_info ("saving <%" GRUB_HOST_PRIuLONG_LONG ",%u,%u>",
(unsigned long long) sector, offset, length);
if (bl->first_sector == (grub_disk_addr_t) -1)
{
if (offset != 0 || length < GRUB_DISK_SECTOR_SIZE)
grub_util_error ("%s", _("the first sector of the core file is not sector-aligned"));
bl->first_sector = sector;
sector++;
length -= GRUB_DISK_SECTOR_SIZE;
if (!length)
return;
}
if (offset != 0 || bl->last_length != 0)
grub_util_error ("%s", _("non-sector-aligned data is found in the core file"));
seclen = (length + GRUB_DISK_SECTOR_SIZE - 1) >> GRUB_DISK_SECTOR_BITS;
if (bl->block != bl->first_block
&& (grub_target_to_host64 (prev->start)
+ grub_target_to_host16 (prev->len)) == sector)
{
grub_uint16_t t = grub_target_to_host16 (prev->len);
t += seclen;
prev->len = grub_host_to_target16 (t);
}
else
{
bl->block->start = grub_host_to_target64 (sector);
bl->block->len = grub_host_to_target16 (seclen);
#ifdef GRUB_SETUP_BIOS
bl->block->segment = grub_host_to_target16 (bl->current_segment);
#endif
bl->block--;
if (bl->block->len)
grub_util_error ("%s", _("the sectors of the core file are too fragmented"));
}
bl->last_length = length & (GRUB_DISK_SECTOR_SIZE - 1);
#ifdef GRUB_SETUP_BIOS
bl->current_segment += seclen << (GRUB_DISK_SECTOR_BITS - 4);
#endif
}
/* Context for setup/identify_partmap. */
struct identify_partmap_ctx
{
grub_partition_map_t dest_partmap;
grub_partition_t container;
int multiple_partmaps;
};
/* Helper for setup.
Unlike root_dev, with dest_dev we're interested in the partition map even
if dest_dev itself is a whole disk. */
static int
identify_partmap (grub_disk_t disk __attribute__ ((unused)),
const grub_partition_t p, void *data)
{
struct identify_partmap_ctx *ctx = data;
if (p->parent != ctx->container)
return 0;
/* NetBSD and OpenBSD subpartitions have metadata inside a partition,
so they are safe to ignore.
*/
if (grub_strcmp (p->partmap->name, "netbsd") == 0
|| grub_strcmp (p->partmap->name, "openbsd") == 0)
return 0;
if (ctx->dest_partmap == NULL)
{
ctx->dest_partmap = p->partmap;
return 0;
}
if (ctx->dest_partmap == p->partmap)
return 0;
ctx->multiple_partmaps = 1;
return 1;
}
#ifdef GRUB_SETUP_BIOS
#define SETUP grub_util_bios_setup
#elif GRUB_SETUP_SPARC64
#define SETUP grub_util_sparc_setup
#else
#error "Shouldn't happen"
#endif
void
SETUP (const char *dir,
const char *boot_file, const char *core_file,
const char *dest, int force,
int fs_probe, int allow_floppy,
int add_rs_codes __attribute__ ((unused))) /* unused on sparc64 */
{
char *core_path;
char *boot_img, *core_img, *boot_path;
char *root = 0;
size_t boot_size, core_size;
grub_uint16_t core_sectors;
grub_device_t root_dev = 0, dest_dev, core_dev;
grub_util_fd_t fp;
struct blocklists bl;
bl.first_sector = (grub_disk_addr_t) -1;
#ifdef GRUB_SETUP_BIOS
bl.current_segment =
GRUB_BOOT_I386_PC_KERNEL_SEG + (GRUB_DISK_SECTOR_SIZE >> 4);
#endif
bl.last_length = 0;
/* Read the boot image by the OS service. */
boot_path = grub_util_get_path (dir, boot_file);
boot_size = grub_util_get_image_size (boot_path);
if (boot_size != GRUB_DISK_SECTOR_SIZE)
grub_util_error (_("the size of `%s' is not %u"),
boot_path, GRUB_DISK_SECTOR_SIZE);
boot_img = grub_util_read_image (boot_path);
free (boot_path);
core_path = grub_util_get_path (dir, core_file);
core_size = grub_util_get_image_size (core_path);
core_sectors = ((core_size + GRUB_DISK_SECTOR_SIZE - 1)
>> GRUB_DISK_SECTOR_BITS);
if (core_size < GRUB_DISK_SECTOR_SIZE)
grub_util_error (_("the size of `%s' is too small"), core_path);
#ifdef GRUB_SETUP_BIOS
if (core_size > 0xFFFF * GRUB_DISK_SECTOR_SIZE)
grub_util_error (_("the size of `%s' is too large"), core_path);
#endif
core_img = grub_util_read_image (core_path);
/* Have FIRST_BLOCK to point to the first blocklist. */
bl.first_block = (struct grub_boot_blocklist *) (core_img
+ GRUB_DISK_SECTOR_SIZE
- sizeof (*bl.block));
grub_util_info ("Opening dest `%s'", dest);
dest_dev = grub_device_open (dest);
if (! dest_dev)
grub_util_error ("%s", grub_errmsg);
core_dev = dest_dev;
{
char **root_devices = grub_guess_root_devices (dir);
char **cur;
int found = 0;
if (!root_devices)
grub_util_error (_("cannot find a device for %s (is /dev mounted?)"), dir);
for (cur = root_devices; *cur; cur++)
{
char *drive;
grub_device_t try_dev;
drive = grub_util_get_grub_dev (*cur);
if (!drive)
continue;
try_dev = grub_device_open (drive);
if (! try_dev)
{
free (drive);
continue;
}
if (!found && try_dev->disk->id == dest_dev->disk->id
&& try_dev->disk->dev->id == dest_dev->disk->dev->id)
{
if (root_dev)
grub_device_close (root_dev);
free (root);
root_dev = try_dev;
root = drive;
found = 1;
continue;
}
if (!root_dev)
{
root_dev = try_dev;
root = drive;
continue;
}
grub_device_close (try_dev);
free (drive);
}
if (!root_dev)
{
root = grub_util_get_grub_dev ("/dev/sda");
root_dev = grub_device_open (root);
if (root_dev)
grub_util_info ("guessing the root device failed, because of `%s'", grub_errmsg);
else
grub_util_error ("guessing the root device failed, because of `%s'", grub_errmsg);
}
grub_util_info ("guessed root_dev `%s' from "
"dir `%s'", root_dev->disk->name, dir);
for (cur = root_devices; *cur; cur++)
free (*cur);
free (root_devices);
}
grub_util_info ("setting the root device to `%s'", root);
if (grub_env_set ("root", root) != GRUB_ERR_NONE)
grub_util_error ("%s", grub_errmsg);
{
#ifdef GRUB_SETUP_BIOS
char *tmp_img;
grub_uint8_t *boot_drive_check;
/* Read the original sector from the disk. */
tmp_img = xmalloc (GRUB_DISK_SECTOR_SIZE);
if (grub_disk_read (dest_dev->disk, 0, 0, GRUB_DISK_SECTOR_SIZE, tmp_img))
grub_util_error ("%s", grub_errmsg);
boot_drive_check = (grub_uint8_t *) (boot_img
+ GRUB_BOOT_MACHINE_DRIVE_CHECK);
/* Copy the possible DOS BPB. */
memcpy (boot_img + GRUB_BOOT_MACHINE_BPB_START,
tmp_img + GRUB_BOOT_MACHINE_BPB_START,
GRUB_BOOT_MACHINE_BPB_END - GRUB_BOOT_MACHINE_BPB_START);
/* If DEST_DRIVE is a hard disk, enable the workaround, which is
for buggy BIOSes which don't pass boot drive correctly. Instead,
they pass 0x00 or 0x01 even when booted from 0x80. */
if (!allow_floppy && !grub_util_biosdisk_is_floppy (dest_dev->disk))
{
/* Replace the jmp (2 bytes) with double nop's. */
boot_drive_check[0] = 0x90;
boot_drive_check[1] = 0x90;
}
#endif
struct identify_partmap_ctx ctx = {
.dest_partmap = NULL,
.container = dest_dev->disk->partition,
.multiple_partmaps = 0
};
int is_ldm;
grub_err_t err;
grub_disk_addr_t *sectors;
int i;
grub_fs_t fs;
unsigned int nsec, maxsec;
grub_partition_iterate (dest_dev->disk, identify_partmap, &ctx);
#ifdef GRUB_SETUP_BIOS
/* Copy the partition table. */
if (ctx.dest_partmap ||
(!allow_floppy && !grub_util_biosdisk_is_floppy (dest_dev->disk)))
memcpy (boot_img + GRUB_BOOT_MACHINE_WINDOWS_NT_MAGIC,
tmp_img + GRUB_BOOT_MACHINE_WINDOWS_NT_MAGIC,
GRUB_BOOT_MACHINE_PART_END - GRUB_BOOT_MACHINE_WINDOWS_NT_MAGIC);
free (tmp_img);
#endif
if (ctx.container
&& grub_strcmp (ctx.container->partmap->name, "msdos") == 0
&& ctx.dest_partmap
&& (ctx.container->msdostype == GRUB_PC_PARTITION_TYPE_NETBSD
|| ctx.container->msdostype == GRUB_PC_PARTITION_TYPE_OPENBSD))
{
grub_util_warn ("%s", _("Attempting to install GRUB to a disk with multiple partition labels or both partition label and filesystem. This is not supported yet."));
goto unable_to_embed;
}
fs = grub_fs_probe (dest_dev);
if (!fs)
grub_errno = GRUB_ERR_NONE;
is_ldm = grub_util_is_ldm (dest_dev->disk);
if (fs_probe)
{
if (!fs && !ctx.dest_partmap)
grub_util_error (_("unable to identify a filesystem in %s; safety check can't be performed"),
dest_dev->disk->name);
if (fs && !fs->reserved_first_sector)
/* TRANSLATORS: Filesystem may reserve the space just GRUB isn't sure about it. */
grub_util_error (_("%s appears to contain a %s filesystem which isn't known to "
"reserve space for DOS-style boot. Installing GRUB there could "
"result in FILESYSTEM DESTRUCTION if valuable data is overwritten "
"by grub-setup (--skip-fs-probe disables this "
"check, use at your own risk)"), dest_dev->disk->name, fs->name);
if (ctx.dest_partmap && strcmp (ctx.dest_partmap->name, "msdos") != 0
&& strcmp (ctx.dest_partmap->name, "gpt") != 0
&& strcmp (ctx.dest_partmap->name, "bsd") != 0
&& strcmp (ctx.dest_partmap->name, "netbsd") != 0
&& strcmp (ctx.dest_partmap->name, "openbsd") != 0
&& strcmp (ctx.dest_partmap->name, "sunpc") != 0)
/* TRANSLATORS: Partition map may reserve the space just GRUB isn't sure about it. */
grub_util_error (_("%s appears to contain a %s partition map which isn't known to "
"reserve space for DOS-style boot. Installing GRUB there could "
"result in FILESYSTEM DESTRUCTION if valuable data is overwritten "
"by grub-setup (--skip-fs-probe disables this "
"check, use at your own risk)"), dest_dev->disk->name, ctx.dest_partmap->name);
if (is_ldm && ctx.dest_partmap && strcmp (ctx.dest_partmap->name, "msdos") != 0
&& strcmp (ctx.dest_partmap->name, "gpt") != 0)
grub_util_error (_("%s appears to contain a %s partition map and "
"LDM which isn't known to be a safe combination."
" Installing GRUB there could "
"result in FILESYSTEM DESTRUCTION if valuable data"
" is overwritten "
"by grub-setup (--skip-fs-probe disables this "
"check, use at your own risk)"),
dest_dev->disk->name, ctx.dest_partmap->name);
}
if (! ctx.dest_partmap && ! fs && !is_ldm)
{
grub_util_warn ("%s", _("Attempting to install GRUB to a partitionless disk or to a partition. This is a BAD idea."));
goto unable_to_embed;
}
if (ctx.multiple_partmaps || (ctx.dest_partmap && fs) || (is_ldm && fs))
{
grub_util_warn ("%s", _("Attempting to install GRUB to a disk with multiple partition labels. This is not supported yet."));
goto unable_to_embed;
}
if (ctx.dest_partmap && !ctx.dest_partmap->embed)
{
grub_util_warn (_("Partition style `%s' doesn't support embedding"),
ctx.dest_partmap->name);
goto unable_to_embed;
}
if (fs && !fs->fs_embed)
{
grub_util_warn (_("File system `%s' doesn't support embedding"),
fs->name);
goto unable_to_embed;
}
nsec = core_sectors;
if (add_rs_codes)
maxsec = 2 * core_sectors;
else
maxsec = core_sectors;
#ifdef GRUB_SETUP_BIOS
if (maxsec > ((0x78000 - GRUB_KERNEL_I386_PC_LINK_ADDR)
>> GRUB_DISK_SECTOR_BITS))
maxsec = ((0x78000 - GRUB_KERNEL_I386_PC_LINK_ADDR)
>> GRUB_DISK_SECTOR_BITS);
#endif
#ifdef GRUB_SETUP_SPARC64
/*
* On SPARC we need two extra. One is because we are combining the
* core.img with the boot.img. The other is because the boot sector
* starts at 1.
*/
nsec += 2;
maxsec += 2;
#endif
if (is_ldm)
err = grub_util_ldm_embed (dest_dev->disk, &nsec, maxsec,
GRUB_EMBED_PCBIOS, &sectors);
else if (ctx.dest_partmap)
err = ctx.dest_partmap->embed (dest_dev->disk, &nsec, maxsec,
GRUB_EMBED_PCBIOS, &sectors);
else
err = fs->fs_embed (dest_dev, &nsec, maxsec,
GRUB_EMBED_PCBIOS, &sectors);
if (!err && nsec < core_sectors)
{
err = grub_error (GRUB_ERR_OUT_OF_RANGE,
N_("Your embedding area is unusually small. "
"core.img won't fit in it."));
}
if (err)
{
grub_util_warn ("%s", grub_errmsg);
grub_errno = GRUB_ERR_NONE;
goto unable_to_embed;
}
assert (nsec <= maxsec);
/* Clean out the blocklists. */
bl.block = bl.first_block;
while (bl.block->len)
{
grub_memset (bl.block, 0, sizeof (*bl.block));
bl.block--;
if ((char *) bl.block <= core_img)
grub_util_error ("%s", _("no terminator in the core image"));
}
bl.block = bl.first_block;
for (i = 0; i < nsec; i++)
save_blocklists (sectors[i] + grub_partition_get_start (ctx.container),
0, GRUB_DISK_SECTOR_SIZE, &bl);
/* Make sure that the last blocklist is a terminator. */
if (bl.block == bl.first_block)
bl.block--;
bl.block->start = 0;
bl.block->len = 0;
#ifdef GRUB_SETUP_BIOS
bl.block->segment = 0;
#endif
#ifdef GRUB_SETUP_SPARC64
{
/*
* On SPARC, the block-list entries need to be based off the beginning
* of the parition, not the beginning of the disk.
*/
struct grub_boot_blocklist *block;
block = bl.first_block;
while (block->len)
{
block->start -= bl.first_sector;
block--;
}
}
/*
* Reserve space for the boot block since it can not be in the
* Parition table on SPARC.
*/
assert (bl.first_block->len > 2);
bl.first_block->start += 2;
bl.first_block->len -= 2;
write_rootdev (root_dev, boot_img, sectors[BOOT_SECTOR + 1] - bl.first_sector);
#endif
#ifdef GRUB_SETUP_BIOS
write_rootdev (root_dev, boot_img, bl.first_sector);
#endif
/* Round up to the nearest sector boundary, and zero the extra memory */
core_img = xrealloc (core_img, nsec * GRUB_DISK_SECTOR_SIZE);
assert (core_img && (nsec * GRUB_DISK_SECTOR_SIZE >= core_size));
memset (core_img + core_size, 0, nsec * GRUB_DISK_SECTOR_SIZE - core_size);
bl.first_block = (struct grub_boot_blocklist *) (core_img
+ GRUB_DISK_SECTOR_SIZE
- sizeof (*bl.block));
#if GRUB_SETUP_BIOS
grub_size_t no_rs_length;
no_rs_length = grub_target_to_host16
(grub_get_unaligned16 (core_img
+ GRUB_DISK_SECTOR_SIZE
+ GRUB_KERNEL_I386_PC_NO_REED_SOLOMON_LENGTH));
if (no_rs_length == 0xffff)
grub_util_error ("%s", _("core.img version mismatch"));
if (add_rs_codes)
{
grub_set_unaligned32 ((core_img + GRUB_DISK_SECTOR_SIZE
+ GRUB_KERNEL_I386_PC_REED_SOLOMON_REDUNDANCY),
grub_host_to_target32 (nsec * GRUB_DISK_SECTOR_SIZE - core_size));
void *tmp = xmalloc (core_size);
grub_memcpy (tmp, core_img, core_size);
grub_reed_solomon_add_redundancy (core_img + no_rs_length + GRUB_DISK_SECTOR_SIZE,
core_size - no_rs_length - GRUB_DISK_SECTOR_SIZE,
nsec * GRUB_DISK_SECTOR_SIZE
- core_size);
assert (grub_memcmp (tmp, core_img, core_size) == 0);
free (tmp);
}
/* Write the core image onto the disk. */
for (i = 0; i < nsec; i++)
grub_disk_write (dest_dev->disk, sectors[i], 0,
GRUB_DISK_SECTOR_SIZE,
core_img + i * GRUB_DISK_SECTOR_SIZE);
#endif
#ifdef GRUB_SETUP_SPARC64
{
int isec = BOOT_SECTOR;
/* Write the boot image onto the disk. */
if (grub_disk_write (dest_dev->disk, sectors[isec++], 0,
GRUB_DISK_SECTOR_SIZE, boot_img))
grub_util_error ("%s", grub_errmsg);
/* Write the core image onto the disk. */
for (i = 0 ; isec < nsec; i++, isec++)
{
if (grub_disk_write (dest_dev->disk, sectors[isec], 0,
GRUB_DISK_SECTOR_SIZE,
core_img + i * GRUB_DISK_SECTOR_SIZE))
grub_util_error ("%s", grub_errmsg);
}
}
#endif
grub_free (sectors);
goto finish;
}
unable_to_embed:
if (dest_dev->disk->dev->id != root_dev->disk->dev->id)
grub_util_error ("%s", _("embedding is not possible, but this is required for "
"RAID and LVM install"));
{
grub_fs_t fs;
fs = grub_fs_probe (root_dev);
if (!fs)
grub_util_error (_("can't determine filesystem on %s"), root);
if (!fs->blocklist_install)
grub_util_error (_("filesystem `%s' doesn't support blocklists"),
fs->name);
}
#ifdef GRUB_SETUP_BIOS
if (dest_dev->disk->id != root_dev->disk->id
|| dest_dev->disk->dev->id != root_dev->disk->dev->id)
/* TRANSLATORS: cross-disk refers to /boot being on one disk
but MBR on another. */
grub_util_error ("%s", _("embedding is not possible, but this is required for "
"cross-disk install"));
#else
core_dev = root_dev;
#endif
grub_util_warn ("%s", _("Embedding is not possible. GRUB can only be installed in this "
"setup by using blocklists. However, blocklists are UNRELIABLE and "
"their use is discouraged."));
if (! force)
/* TRANSLATORS: Here GRUB refuses to continue with blocklist install. */
grub_util_error ("%s", _("will not proceed with blocklists"));
/* The core image must be put on a filesystem unfortunately. */
grub_util_info ("will leave the core image on the filesystem");
grub_util_biosdisk_flush (root_dev->disk);
/* Clean out the blocklists. */
bl.block = bl.first_block;
while (bl.block->len)
{
bl.block->start = 0;
bl.block->len = 0;
#ifdef GRUB_SETUP_BIOS
bl.block->segment = 0;
#endif
bl.block--;
if ((char *) bl.block <= core_img)
grub_util_error ("%s", _("no terminator in the core image"));
}
bl.block = bl.first_block;
#ifdef GRUB_SETUP_SPARC64
{
grub_partition_t container = root_dev->disk->partition;
bl.gpt_offset = 0;
if (grub_strstr (container->partmap->name, "gpt"))
bl.gpt_offset = grub_partition_get_start (container);
}
#endif
grub_install_get_blocklist (root_dev, core_path, core_img, core_size,
save_blocklists, &bl);
if (bl.first_sector == (grub_disk_addr_t)-1)
grub_util_error ("%s", _("can't retrieve blocklists"));
#ifdef GRUB_SETUP_SPARC64
{
char *boot_devpath;
boot_devpath = (char *) (boot_img
+ GRUB_BOOT_AOUT_HEADER_SIZE
+ GRUB_BOOT_MACHINE_BOOT_DEVPATH);
if (dest_dev->disk->id != root_dev->disk->id
|| dest_dev->disk->dev->id != root_dev->disk->dev->id)
{
char *dest_ofpath;
dest_ofpath
= grub_util_devname_to_ofpath (grub_util_biosdisk_get_osdev (root_dev->disk));
/* FIXME handle NULL result */
grub_util_info ("dest_ofpath is `%s'", dest_ofpath);
strncpy (boot_devpath, dest_ofpath,
GRUB_BOOT_MACHINE_BOOT_DEVPATH_END
- GRUB_BOOT_MACHINE_BOOT_DEVPATH - 1);
boot_devpath[GRUB_BOOT_MACHINE_BOOT_DEVPATH_END
- GRUB_BOOT_MACHINE_BOOT_DEVPATH - 1] = 0;
free (dest_ofpath);
}
else
{
grub_util_info ("non cross-disk install");
memset (boot_devpath, 0, GRUB_BOOT_MACHINE_BOOT_DEVPATH_END
- GRUB_BOOT_MACHINE_BOOT_DEVPATH);
}
grub_util_info ("boot device path %s", boot_devpath);
}
#endif
write_rootdev (root_dev, boot_img, bl.first_sector);
/* Write the first two sectors of the core image onto the disk. */
grub_util_info ("opening the core image `%s'", core_path);
fp = grub_util_fd_open (core_path, GRUB_UTIL_FD_O_WRONLY);
if (! GRUB_UTIL_FD_IS_VALID (fp))
grub_util_error (_("cannot open `%s': %s"), core_path,
grub_util_fd_strerror ());
if (grub_util_fd_write (fp, core_img, GRUB_DISK_SECTOR_SIZE * 2)
!= GRUB_DISK_SECTOR_SIZE * 2)
grub_util_error (_("cannot write to `%s': %s"),
core_path, strerror (errno));
if (grub_util_fd_sync (fp) < 0)
grub_util_error (_("cannot sync `%s': %s"), core_path, strerror (errno));
if (grub_util_fd_close (fp) < 0)
grub_util_error (_("cannot close `%s': %s"), core_path, strerror (errno));
grub_util_biosdisk_flush (root_dev->disk);
grub_disk_cache_invalidate_all ();
{
char *buf, *ptr = core_img;
size_t len = core_size;
grub_uint64_t blk, offset = 0;
grub_partition_t container = core_dev->disk->partition;
grub_err_t err;
core_dev->disk->partition = 0;
#ifdef GRUB_SETUP_SPARC64
offset = bl.gpt_offset;
#endif
buf = xmalloc (core_size);
blk = bl.first_sector;
err = grub_disk_read (core_dev->disk, blk + offset, 0, GRUB_DISK_SECTOR_SIZE, buf);
if (err)
grub_util_error (_("cannot read `%s': %s"), core_dev->disk->name,
grub_errmsg);
if (grub_memcmp (buf, ptr, GRUB_DISK_SECTOR_SIZE) != 0)
grub_util_error ("%s", _("blocklists are invalid"));
ptr += GRUB_DISK_SECTOR_SIZE;
len -= GRUB_DISK_SECTOR_SIZE;
bl.block = bl.first_block;
while (bl.block->len)
{
size_t cur = grub_target_to_host16 (bl.block->len) << GRUB_DISK_SECTOR_BITS;
blk = grub_target_to_host64 (bl.block->start);
if (cur > len)
cur = len;
err = grub_disk_read (core_dev->disk, blk + offset, 0, cur, buf);
if (err)
grub_util_error (_("cannot read `%s': %s"), core_dev->disk->name,
grub_errmsg);
if (grub_memcmp (buf, ptr, cur) != 0)
grub_util_error ("%s", _("blocklists are invalid"));
ptr += cur;
len -= cur;
bl.block--;
if ((char *) bl.block <= core_img)
grub_util_error ("%s", _("no terminator in the core image"));
}
if (len)
grub_util_error ("%s", _("blocklists are incomplete"));
core_dev->disk->partition = container;
free (buf);
}
#ifdef GRUB_SETUP_BIOS
finish:
#endif
/* Write the boot image onto the disk. */
if (grub_disk_write (dest_dev->disk, BOOT_SECTOR,
0, GRUB_DISK_SECTOR_SIZE, boot_img))
grub_util_error ("%s", grub_errmsg);
#ifdef GRUB_SETUP_SPARC64
finish:
#endif
grub_util_biosdisk_flush (root_dev->disk);
grub_util_biosdisk_flush (dest_dev->disk);
free (core_path);
free (core_img);
free (boot_img);
grub_device_close (dest_dev);
grub_device_close (root_dev);
}

BIN
ICON/filechecksum.gif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 437 KiB

View File

@ -48,6 +48,12 @@ else
fi
fi
if [ "$VTOY_ARCH" = "i386" ]; then
if $BUSYBOX_PATH/vtchmod32 -6; then
export VTOY_ARCH=x86_64
fi
fi
echo $VTOY_ARCH > $VTOY_PATH/ventoy_arch
@ -81,6 +87,7 @@ export PATH=$BUSYBOX_PATH/:$VTOY_PATH/tool
export VTOY_BREAK_LEVEL=$(hexdump -n 1 -s 449 -e '1/1 "%02x"' $VTOY_PATH/ventoy_os_param)
export VTOY_DEBUG_LEVEL=$(hexdump -n 1 -s 450 -e '1/1 "%02x"' $VTOY_PATH/ventoy_os_param)
export VTOY_LINUX_REMOUNT=$(hexdump -n 1 -s 454 -e '1/1 "%02x"' $VTOY_PATH/ventoy_os_param)
#Fixme: busybox shell output redirect seems to have some bug in rhel5
if uname -a | grep -q el5; then
@ -108,6 +115,8 @@ fi
if [ "$VTOY_ARCH" = "x86_64" ]; then
echo "Use x86_64 busybox toolkit ..." >>$VTLOG
$BUSYBOX_PATH/xzcat $BUSYBOX_PATH/xzcat64_musl.xz > $BUSYBOX_PATH/xzcat_musl
$BUSYBOX_PATH/chmod +x $BUSYBOX_PATH/xzcat_musl
ln -s $BUSYBOX_PATH/xzminidec64 $BUSYBOX_PATH/xzminidec
ln -s $VTOY_PATH/tool/dmsetup64 $VTOY_PATH/tool/dmsetup
ln -s $VTOY_PATH/tool/lunzip64 $VTOY_PATH/tool/lunzip
@ -117,10 +126,17 @@ if [ "$VTOY_ARCH" = "x86_64" ]; then
ln -s $VTOY_PATH/tool/zstdcat64 $VTOY_PATH/tool/zstdcat
elif [ "$VTOY_ARCH" = "i386" ]; then
echo "Use i386 busybox toolkit ..." >>$VTLOG
$BUSYBOX_PATH/xzcat $BUSYBOX_PATH/xzcat32_musl.xz > $BUSYBOX_PATH/xzcat_musl
$BUSYBOX_PATH/chmod +x $BUSYBOX_PATH/xzcat_musl
ln -s $BUSYBOX_PATH/xzminidec32 $BUSYBOX_PATH/xzminidec
ln -s $VTOY_PATH/tool/dmsetup32 $VTOY_PATH/tool/dmsetup
ln -s $VTOY_PATH/tool/lunzip32 $VTOY_PATH/tool/lunzip
if uname -a | egrep -q 'x86_64|amd64'; then
echo "zstdcat use 64bit ..." >>$VTLOG
rm -f $VTOY_PATH/tool/zstdcat
ln -s $VTOY_PATH/tool/zstdcat64 $VTOY_PATH/tool/zstdcat
fi
elif [ "$VTOY_ARCH" = "mips64el" ]; then
echo "Use MIPS64 busybox toolkit ..." >>$VTLOG
ln -s $BUSYBOX_PATH/xzminidecm64e $BUSYBOX_PATH/xzminidec

View File

@ -0,0 +1,4 @@
for i in 1 2; do
if [ $i -eq 2 ]; then
/ventoy/busybox/sh /ventoy/hook/alpine/udev_disk_hook.sh
fi

Some files were not shown because too many files have changed in this diff Show More