Compare commits

..

115 Commits

Author SHA1 Message Date
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
460 changed files with 90536 additions and 1489 deletions

2
.github/FUNDING.yml vendored
View File

@@ -9,4 +9,4 @@ community_bridge: # Replace with a single Community Bridge project-name e.g., cl
liberapay: # Replace with a single Liberapay username
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']

View File

@@ -21,7 +21,7 @@ body:
attributes:
label: Ventoy Version
description: What version of ventoy are you running?
placeholder: 1.0.51
placeholder: 1.0.63
validations:
required: true
- type: dropdown

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 envrionment
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

@@ -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

179
DMPATCH/dmpatch.c Normal file
View File

@@ -0,0 +1,179 @@
/******************************************************************************
* 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 padding[3];
}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
};
#define CODE_MATCH(code, i) \
(code[i] == 0x40 && code[i + 1] == 0x80 && code[i + 2] == 0xce && code[i + 3] == 0x80)
#define vdebug(fmt, args...) if(kprintf) kprintf(KERN_ERR fmt, ##args)
static int notrace dmpatch_replace_code(unsigned long addr, unsigned long size, int expect, const char *desc)
{
int i = 0;
int cnt = 0;
unsigned long align;
unsigned char *patch[MAX_PATCH];
unsigned char *opCode = (unsigned char *)addr;
vdebug("patch for %s 0x%lx %d\n", desc, addr, (int)size);
for (i = 0; i < (int)size - 4; i++)
{
if (CODE_MATCH(opCode, i) && cnt < MAX_PATCH)
{
patch[cnt] = opCode + i + 3;
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 int notrace dmpatch_init(void)
{
int r = 0;
int rc = 0;
kprintf = (printk_pf)(g_ko_param.printk_addr);
vdebug("dmpatch_init start pagesize=%lu ...\n", g_ko_param.pgsize);
if (g_ko_param.struct_size != sizeof(ko_param))
{
vdebug("Invalid struct size %d %d\n", (int)g_ko_param.struct_size, (int)sizeof(ko_param));
return -EINVAL;
}
if (g_ko_param.sym_get_addr == 0 || g_ko_param.sym_put_addr == 0 ||
g_ko_param.ro_addr == 0 || g_ko_param.rw_addr == 0)
{
return -EINVAL;
}
set_mem_ro = (set_memory_attr_pf)(g_ko_param.ro_addr);
set_mem_rw = (set_memory_attr_pf)(g_ko_param.rw_addr);
reg_kprobe = (kprobe_reg_pf)g_ko_param.reg_kprobe_addr;
unreg_kprobe = (kprobe_unreg_pf)g_ko_param.unreg_kprobe_addr;
r = dmpatch_replace_code(g_ko_param.sym_get_addr, g_ko_param.sym_get_size, 2, "dm_get_table_device");
if (r)
{
rc = -EINVAL;
goto out;
}
vdebug("patch dm_get_table_device success\n");
r = dmpatch_replace_code(g_ko_param.sym_put_addr, g_ko_param.sym_put_size, 1, "dm_put_table_device");
if (r)
{
rc = -EINVAL;
goto out;
}
vdebug("patch dm_put_table_device success\n");
vdebug("#####################################\n");
vdebug("######## dm patch success ###########\n");
vdebug("#####################################\n");
out:
return rc;
}
static void notrace dmpatch_exit(void)
{
}
module_init(dmpatch_init);
module_exit(dmpatch_exit);
MODULE_DESCRIPTION("dmpatch driver");
MODULE_AUTHOR("longpanda <admin@ventoy.net>");
MODULE_LICENSE("GPL");

35
DMPATCH/readme.txt Normal file
View File

@@ -0,0 +1,35 @@
1. install ubuntu 21.10
2. apt-get install build-essential flex ncurse linux-headers-generic linux-source ...... and so on
3. cp /lib/modules/5.13.0-23-generic/build/Module.symvers ./
4. /boot/config-5.13.0-23-generic as .config make oldconfig
5. make menuconfig
1. close CONFIG_STACKPROTECTOR
2. close CONFIG_RETPOLINE
6. modify ./scripts/mod/modpost.c
1. skip add_srcversion (just return)
2. force add_retpoline (#ifdef --> #ifndef)
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

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

@@ -59,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;
CONST CHAR16 gIso9660EfiDriverPath[] = ISO9660_EFI_DRIVER_PATH;
CONST CHAR16 gUdfEfiDriverPath[] = UDF_EFI_DRIVER_PATH;
@@ -68,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[] =
@@ -707,6 +713,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;
@@ -817,6 +923,19 @@ STATIC EFI_STATUS EFIAPI ventoy_parse_cmdline(IN EFI_HANDLE ImageHandle)
old_cnt > 3 ? g_file_replace_list->old_file_name[3] : ""
);
g_img_replace_list = &pGrubParam->img_replace;
ventoy_proc_img_replace_name(g_img_replace_list);
old_cnt = g_img_replace_list->old_file_cnt;
debug("img replace: magic:0x%x virtid:%u name count:%u <%a> <%a> <%a> <%a>",
g_img_replace_list->magic,
g_img_replace_list->new_file_virtual_id,
old_cnt,
old_cnt > 0 ? g_img_replace_list->old_file_name[0] : "",
old_cnt > 1 ? g_img_replace_list->old_file_name[1] : "",
old_cnt > 2 ? g_img_replace_list->old_file_name[2] : "",
old_cnt > 3 ? g_img_replace_list->old_file_name[3] : ""
);
pPos = StrStr(pCmdLine, L"mem:");
chain = (ventoy_chain_head *)StrHexToUintn(pPos + 4);
@@ -864,6 +983,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);
@@ -1050,7 +1174,8 @@ 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 && g_img_replace_list->magic == GRUB_IMG_REPLACE_MAGIC))
{
ventoy_wrapper_push_openvolume(pFile->OpenVolume);
pFile->OpenVolume = ventoy_wrapper_open_volume;

View File

@@ -243,6 +243,7 @@ typedef int (*grub_env_printf_pf)(const char *fmt, ...);
#pragma pack(1)
#define GRUB_FILE_REPLACE_MAGIC 0x1258BEEF
#define GRUB_IMG_REPLACE_MAGIC 0x1259BEEF
typedef struct ventoy_efi_file_replace
{
@@ -267,6 +268,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;
grub_env_printf_pf grub_env_printf;
}ventoy_grub_param;
@@ -396,6 +398,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;
extern ventoy_sector_flag *g_sector_flag;
extern UINT32 g_sector_flag_num;
extern BOOLEAN gMemdiskMode;
@@ -403,6 +406,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;

View File

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

View File

@@ -37,6 +37,9 @@
#include <Protocol/DriverBinding.h>
#include <Ventoy.h>
#define ASSIGN_REPLACE(This, replace) \
replace = (This->FlushEx == ventoy_wrapper_file_flush_ex) ? &g_efi_file_replace : &g_img_file_replace
UINT8 *g_iso_data_buf = NULL;
UINTN g_iso_buf_size = 0;
BOOLEAN gMemdiskMode = FALSE;
@@ -1245,6 +1248,15 @@ 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_img(EFI_FILE_HANDLE This, EFI_FILE_IO_TOKEN *Token)
{
(VOID)This;
(VOID)Token;
return EFI_SUCCESS;
}
STATIC EFI_STATUS EFIAPI
ventoy_wrapper_file_write(EFI_FILE_HANDLE This, UINTN *Len, VOID *Data)
@@ -1270,19 +1282,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;
ASSIGN_REPLACE(This, replace);
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;
@@ -1291,9 +1304,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;
ASSIGN_REPLACE(This, replace);
*Position = replace->CurPos;
return EFI_SUCCESS;
}
@@ -1303,6 +1318,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;
ASSIGN_REPLACE(This, replace);
debug("ventoy_wrapper_file_get_info ... %u", *Len);
@@ -1320,8 +1338,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;
@@ -1335,23 +1353,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;
ASSIGN_REPLACE(This, replace);
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;
}
@@ -1362,7 +1381,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)
{
File->Revision = EFI_FILE_PROTOCOL_REVISION2;
File->Open = ventoy_wrapper_fs_open;
@@ -1378,7 +1397,7 @@ 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;
File->FlushEx = Img ? ventoy_wrapper_file_flush_ex_img : ventoy_wrapper_file_flush_ex;
return EFI_SUCCESS;
}
@@ -1397,6 +1416,7 @@ 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;
debug("## ventoy_wrapper_file_open <%s> ", Name);
@@ -1417,6 +1437,7 @@ STATIC EFI_STATUS EFIAPI ventoy_wrapper_file_open
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)
{
@@ -1427,7 +1448,7 @@ STATIC EFI_STATUS EFIAPI ventoy_wrapper_file_open
{
g_original_fclose(*New);
*New = &g_efi_file_replace.WrapperHandle;
ventoy_wrapper_file_procotol(*New);
ventoy_wrapper_file_procotol(*New, FALSE);
virt = g_virt_chunk + g_file_replace_list->new_file_virtual_id;
@@ -1453,6 +1474,49 @@ STATIC EFI_STATUS EFIAPI ventoy_wrapper_file_open
}
}
if (g_img_replace_list && g_img_replace_list->magic == GRUB_IMG_REPLACE_MAGIC &&
g_img_replace_list->new_file_virtual_id < g_virt_chunk_num)
{
AsciiSPrint(TmpName, sizeof(TmpName), "%s", Name);
for (j = 0; j < g_img_replace_list->old_file_cnt; j++)
{
AsciiStrCpyS(OldName, sizeof(OldName), g_img_replace_list[i].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.WrapperHandle;
ventoy_wrapper_file_procotol(*New, TRUE);
virt = g_virt_chunk + g_img_replace_list->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.BlockIoSectorStart = virt->mem_sector_start;
g_img_file_replace.FileSizeBytes = Sectors * 2048;
if (gDebugPrint)
{
debug("## ventoy_wrapper_file_open2 <%s> BlockStart:%lu Sectors:%lu Bytes:%lu", Name,
g_img_file_replace.BlockIoSectorStart, Sectors, Sectors * 2048);
sleep(3);
}
return Status;
}
}
if (StrCmp(Name, L"\\loader\\entries") == 0)
{
(*New)->Open = ventoy_wrapper_file_open;
}
}
return Status;
}

View File

@@ -41,6 +41,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;
grub_env_printf_pf grub_env_printf;
}ventoy_grub_param;
#pragma pack()

View File

@@ -94,7 +94,7 @@ hash_file (grub_file_t file, const gcry_md_spec_t *hash, void *result)
{
total += r;
div = grub_divmod64(total * 100, (grub_uint64_t)file->size, &ro);
grub_printf("\rCalculating %d%% ", (int)div);
grub_printf("\rCalculating %s %d%% ", hash->name, (int)div);
grub_refresh();
}
}
@@ -105,7 +105,7 @@ hash_file (grub_file_t file, const gcry_md_spec_t *hash, void *result)
grub_free (context);
if (progress)
{
grub_printf("\rCalculating 100%% \n\r\n");
grub_printf("\rCalculating %s 100%% \n\r\n", hash->name);
grub_refresh();
}
return GRUB_ERR_NONE;
@@ -224,6 +224,8 @@ grub_cmd_hashsum (struct grub_extcmd_context *ctxt,
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)
@@ -282,8 +284,12 @@ grub_cmd_hashsum (struct grub_extcmd_context *ctxt,
continue;
}
for (j = 0; j < hash->mdlen; j++)
grub_printf ("%02x", ((grub_uint8_t *) result)[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", args[i]);
grub_env_set("VT_LAST_CHECK_SUM", hashsum);
}
if (unread)

View File

@@ -45,10 +45,24 @@ 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_terminal_output = 0;
#define VTOY_COMM_HOTKEY(cmdkey) \
if (0 == g_ventoy_fn_mutex) { \
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. */
#define DEFAULT_ENTRY_ERROR_DELAY_MS 2500
@@ -388,20 +402,51 @@ 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;
}
}
}
}
@@ -625,7 +670,7 @@ 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;
default_entry = g_ventoy_suppress_esc_default;
else if (g_ventoy_last_entry >= 0 && g_ventoy_last_entry < menu->size) {
default_entry = g_ventoy_last_entry;
}
@@ -835,71 +880,23 @@ 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 ();
@@ -945,6 +942,40 @@ run_menu (grub_menu_t menu, int nested, int *auto_boot)
g_ventoy_menu_refresh = 1;
goto refresh;
case (GRUB_TERM_CTRL | 'h'):
case 'h':
{
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 | 'm'):
case 'm':
{
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;
@@ -1038,6 +1069,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. */

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

@@ -51,6 +51,13 @@
GRUB_MOD_LICENSE ("GPLv3+");
static grub_uint8_t g_check_mbr_data[] = {
0xEB, 0x63, 0x90, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x56, 0x54, 0x00, 0x47, 0x65, 0x00, 0x48, 0x44, 0x00, 0x52, 0x64, 0x00, 0x20, 0x45, 0x72, 0x0D,
};
initrd_info *g_initrd_img_list = NULL;
initrd_info *g_initrd_img_tail = NULL;
int g_initrd_img_count = 0;
@@ -479,7 +486,7 @@ static int ventoy_set_check_result(int ret)
grub_printf(VTOY_WARNING"\n");
grub_printf(VTOY_WARNING"\n\n\n");
grub_printf("This is NOT a standard Ventoy device and is NOT supported (0x%x).\n\n", ret);
grub_printf("This is NOT a standard Ventoy device and is NOT supported (%d).\n\n", ret);
grub_printf("You should follow the instructions in https://www.ventoy.net to use Ventoy.\n");
grub_printf("\n\nWill exit after 10 seconds ...... ");
@@ -497,6 +504,8 @@ static int ventoy_check_official_device(grub_device_t dev)
grub_uint64_t offset;
char devname[64];
grub_fs_t fs;
grub_uint8_t mbr[512];
grub_disk_t disk;
grub_device_t dev2;
char *label = NULL;
struct grub_partition *partition;
@@ -611,7 +620,23 @@ static int ventoy_check_official_device(grub_device_t dev)
grub_device_close(dev2);
}
/* MBR check */
disk = grub_disk_open(dev->disk->name);
if (!disk)
{
return ventoy_set_check_result(11);
}
grub_memset(mbr, 0, 512);
grub_disk_read(disk, 0, 0, 512, mbr);
grub_disk_close(disk);
if (grub_memcmp(g_check_mbr_data, mbr, 0x30) || grub_memcmp(g_check_mbr_data + 0x30, mbr + 0x190, 16))
{
return ventoy_set_check_result(12);
}
return ventoy_set_check_result(0);
}
@@ -865,6 +890,38 @@ static grub_err_t ventoy_cmd_strbegin(grub_extcmd_context_t ctxt, int argc, char
return 0;
}
static grub_err_t ventoy_cmd_strcasebegin(grub_extcmd_context_t ctxt, int argc, char **args)
{
char *c0, *c1;
(void)ctxt;
if (argc != 2)
{
return 1;
}
c0 = args[0];
c1 = args[1];
while (*c0 && *c1)
{
if ((*c0 != *c1) && (*c0 != grub_toupper(*c1)))
{
return 1;
}
c0++;
c1++;
}
if (*c1)
{
return 1;
}
return 0;
}
static grub_err_t ventoy_cmd_incr(grub_extcmd_context_t ctxt, int argc, char **args)
{
long value_long = 0;
@@ -1781,7 +1838,7 @@ static int ventoy_collect_img_files(const char *filename, const struct grub_dirh
img->alias = ventoy_plugin_get_menu_alias(vtoy_alias_image_file, img->path);
tip = ventoy_plugin_get_menu_tip(img->path);
tip = ventoy_plugin_get_menu_tip(vtoy_tip_image_file, img->path);
if (tip)
{
img->tip1 = tip->tip1;
@@ -1982,7 +2039,8 @@ static int ventoy_dynamic_tree_menu(img_iterator_node *node)
const char *dir_class = NULL;
const char *dir_alias = NULL;
img_iterator_node *child = NULL;
const menu_tip *tip = NULL;
if (node->isocnt == 0 || node->done == 1)
{
return 0;
@@ -2022,20 +2080,22 @@ static int ventoy_dynamic_tree_menu(img_iterator_node *node)
dir_class = "vtoydir";
}
tip = ventoy_plugin_get_menu_tip(vtoy_tip_directory, node->dir);
dir_alias = ventoy_plugin_get_menu_alias(vtoy_alias_directory, node->dir);
if (dir_alias)
{
if (g_tree_view_menu_style == 0)
{
vtoy_ssprintf(g_tree_script_buf, g_tree_script_pos,
"submenu \"%-10s %s\" --class=\"%s\" --id=\"DIR_%s\" {\n",
"DIR", dir_alias, dir_class, node->dir + offset);
"submenu \"%-10s %s\" --class=\"%s\" --id=\"DIR_%s\" _VTIP_%p {\n",
"DIR", dir_alias, dir_class, node->dir + offset, tip);
}
else
{
vtoy_ssprintf(g_tree_script_buf, g_tree_script_pos,
"submenu \"%s\" --class=\"%s\" --id=\"DIR_%s\" {\n",
dir_alias, dir_class, node->dir + offset);
"submenu \"%s\" --class=\"%s\" --id=\"DIR_%s\" _VTIP_%p {\n",
dir_alias, dir_class, node->dir + offset, tip);
}
}
else
@@ -2045,14 +2105,14 @@ static int ventoy_dynamic_tree_menu(img_iterator_node *node)
if (g_tree_view_menu_style == 0)
{
vtoy_ssprintf(g_tree_script_buf, g_tree_script_pos,
"submenu \"%-10s [%s]\" --class=\"%s\" --id=\"DIR_%s\" {\n",
"DIR", dir_alias, dir_class, node->dir + offset);
"submenu \"%-10s [%s]\" --class=\"%s\" --id=\"DIR_%s\" _VTIP_%p {\n",
"DIR", dir_alias, dir_class, node->dir + offset, tip);
}
else
{
vtoy_ssprintf(g_tree_script_buf, g_tree_script_pos,
"submenu \"[%s]\" --class=\"%s\" --id=\"DIR_%s\" {\n",
dir_alias, dir_class, node->dir + offset);
"submenu \"[%s]\" --class=\"%s\" --id=\"DIR_%s\" _VTIP_%p {\n",
dir_alias, dir_class, node->dir + offset, tip);
}
}
@@ -2616,6 +2676,22 @@ grub_uint32_t ventoy_get_iso_boot_catlog(grub_file_t file)
return desc.sector;
}
static grub_uint32_t ventoy_get_bios_eltorito_rba(grub_file_t file, grub_uint32_t sector)
{
grub_uint8_t buf[512];
grub_file_seek(file, sector * 2048);
grub_file_read(file, buf, sizeof(buf));
if (buf[0] == 0x01 && buf[1] == 0x00 &&
buf[30] == 0x55 && buf[31] == 0xaa && buf[32] == 0x88)
{
return *((grub_uint32_t *)(buf + 40));
}
return 0;
}
int ventoy_has_efi_eltorito(grub_file_t file, grub_uint32_t sector)
{
int i;
@@ -2672,6 +2748,7 @@ void ventoy_fill_os_param(grub_file_t file, ventoy_os_param *param)
{
char *pos;
const char *fs = NULL;
const char *val = NULL;
const char *cdprompt = NULL;
grub_uint32_t i;
grub_uint8_t chksum = 0;
@@ -2718,6 +2795,13 @@ void ventoy_fill_os_param(grub_file_t file, ventoy_os_param *param)
param->vtoy_reserved[3] = 1;
}
param->vtoy_reserved[5] = 0;
val = ventoy_get_env("VTOY_LINUX_REMOUNT");
if (val && val[0] == '1' && val[1] == 0)
{
param->vtoy_reserved[5] = 1;
}
/* calculate checksum */
for (i = 0; i < sizeof(ventoy_os_param); i++)
{
@@ -2893,6 +2977,7 @@ static grub_err_t ventoy_cmd_img_sector(grub_extcmd_context_t ctxt, int argc, ch
}
grub_memset(&g_grub_param->file_replace, 0, sizeof(g_grub_param->file_replace));
grub_memset(&g_grub_param->img_replace, 0, sizeof(g_grub_param->img_replace));
VENTOY_CMD_RETURN(GRUB_ERR_NONE);
}
@@ -2924,15 +3009,21 @@ static grub_err_t ventoy_select_conf_replace(grub_extcmd_context_t ctxt, int arg
debug("Find conf replace for %s\n", args[1]);
file = ventoy_grub_file_open(VENTOY_FILE_TYPE, "(loop)%s", node->orgconf);
if (!file)
if (file)
{
offset = grub_iso9660_get_last_file_dirent_pos(file);
grub_file_close(file);
}
else if (node->img > 0)
{
offset = 0;
}
else
{
debug("<(loop)%s> NOT exist\n", node->orgconf);
goto end;
}
offset = grub_iso9660_get_last_file_dirent_pos(file);
grub_file_close(file);
file = ventoy_grub_file_open(VENTOY_FILE_TYPE, "%s%s", args[0], node->newconf);
if (!file)
{
@@ -2955,6 +3046,13 @@ static grub_err_t ventoy_select_conf_replace(grub_extcmd_context_t ctxt, int arg
g_conf_replace_node = node;
g_conf_replace_offset = offset + 2;
if (node->img > 0)
{
g_grub_param->img_replace.magic = GRUB_IMG_REPLACE_MAGIC;
g_grub_param->img_replace.old_name_cnt = 1;
grub_snprintf(g_grub_param->img_replace.old_file_name[0], 256, "%s", node->orgconf);
}
debug("conf_replace OK: newlen: %d\n", g_conf_replace_new_len);
end:
@@ -2969,6 +3067,7 @@ static grub_err_t ventoy_cmd_sel_auto_install(grub_extcmd_context_t ctxt, int ar
{
int i = 0;
int pos = 0;
int defidx = 1;
char *buf = NULL;
char configfile[128];
install_template *node = NULL;
@@ -2993,9 +3092,13 @@ static grub_err_t ventoy_cmd_sel_auto_install(grub_extcmd_context_t ctxt, int ar
if (node->autosel >= 0 && node->autosel <= node->templatenum)
{
node->cursel = node->autosel - 1;
debug("Auto install template auto select %d\n", node->autosel);
return 0;
defidx = node->autosel;
if (node->timeout < 0)
{
node->cursel = node->autosel - 1;
debug("Auto install template auto select %d\n", node->autosel);
return 0;
}
}
buf = (char *)grub_malloc(VTOY_MAX_SCRIPT_BUF);
@@ -3004,24 +3107,31 @@ static grub_err_t ventoy_cmd_sel_auto_install(grub_extcmd_context_t ctxt, int ar
return 0;
}
if (node->timeout > 0)
{
vtoy_ssprintf(buf, pos, "set timeout=%d\n", node->timeout);
}
vtoy_ssprintf(buf, pos, "menuentry \"Boot without auto installation template\" {\n"
" echo %s\n}\n", "123");
" echo %s\n}\n", "");
for (i = 0; i < node->templatenum; i++)
{
vtoy_ssprintf(buf, pos, "menuentry \"Boot with %s\" {\n"
" echo 123\n}\n",
vtoy_ssprintf(buf, pos, "menuentry \"Boot with %s\"{\n"
" echo \"\"\n}\n",
node->templatepath[i].path);
}
g_ventoy_menu_esc = 1;
g_ventoy_suppress_esc = 1;
g_ventoy_suppress_esc_default = defidx;
grub_snprintf(configfile, sizeof(configfile), "configfile mem:0x%llx:size:%d", (ulonglong)(ulong)buf, pos);
grub_script_execute_sourcecode(configfile);
g_ventoy_menu_esc = 0;
g_ventoy_suppress_esc = 0;
g_ventoy_suppress_esc_default = 1;
grub_free(buf);
@@ -3034,6 +3144,7 @@ static grub_err_t ventoy_cmd_sel_persistence(grub_extcmd_context_t ctxt, int arg
{
int i = 0;
int pos = 0;
int defidx = 1;
char *buf = NULL;
char configfile[128];
persistence_config *node;
@@ -3058,9 +3169,13 @@ static grub_err_t ventoy_cmd_sel_persistence(grub_extcmd_context_t ctxt, int arg
if (node->autosel >= 0 && node->autosel <= node->backendnum)
{
node->cursel = node->autosel - 1;
debug("Persistence image auto select %d\n", node->autosel);
return 0;
defidx = node->autosel;
if (node->timeout < 0)
{
node->cursel = node->autosel - 1;
debug("Persistence image auto select %d\n", node->autosel);
return 0;
}
}
buf = (char *)grub_malloc(VTOY_MAX_SCRIPT_BUF);
@@ -3069,25 +3184,32 @@ static grub_err_t ventoy_cmd_sel_persistence(grub_extcmd_context_t ctxt, int arg
return 0;
}
if (node->timeout > 0)
{
vtoy_ssprintf(buf, pos, "set timeout=%d\n", node->timeout);
}
vtoy_ssprintf(buf, pos, "menuentry \"Boot without persistence\" {\n"
" echo %s\n}\n", "123");
" echo %s\n}\n", "");
for (i = 0; i < node->backendnum; i++)
{
vtoy_ssprintf(buf, pos, "menuentry \"Boot with %s\" {\n"
" echo 123\n}\n",
" echo \"\"\n}\n",
node->backendpath[i].path);
}
g_ventoy_menu_esc = 1;
g_ventoy_suppress_esc = 1;
g_ventoy_suppress_esc_default = defidx;
grub_snprintf(configfile, sizeof(configfile), "configfile mem:0x%llx:size:%d", (ulonglong)(ulong)buf, pos);
grub_script_execute_sourcecode(configfile);
g_ventoy_menu_esc = 0;
g_ventoy_suppress_esc = 0;
g_ventoy_suppress_esc_default = 1;
grub_free(buf);
@@ -4743,7 +4865,7 @@ static int ventoy_chk_case_file(const char *filename, const struct grub_dirhook_
return 1;
}
if (0 == info->dir && grub_strncasecmp(filename, "ventoy.json", 11) == 0)
if (0 == info->dir && grub_strcasecmp(filename, "ventoy.json") == 0)
{
grub_snprintf(g_json_case_mis_path, 32, "%s/%s", (char *)data, filename);
return 1;
@@ -4763,7 +4885,7 @@ static int ventoy_chk_case_dir(const char *filename, const struct grub_dirhook_i
if (info->dir && (filename[0] == 'v' || filename[0] == 'V'))
{
if (grub_strncasecmp(filename, "ventoy", 6) == 0)
if (grub_strcasecmp(filename, "ventoy") == 0)
{
grub_snprintf(path, sizeof(path), "/%s", filename);
fs_dir->fs->fs_dir(fs_dir->dev, path, ventoy_chk_case_file, path);
@@ -4884,26 +5006,71 @@ static grub_err_t grub_cmd_gptpriority(grub_extcmd_context_t ctxt, int argc, cha
}
/* <BEGIN>: Deleted by longpanda, 20210916 PN:XX LABEL:XX */
#if 0
void ventoy_tip_set_menu_label(const char *vid)
static grub_err_t grub_cmd_syslinux_nojoliet(grub_extcmd_context_t ctxt, int argc, char **args)
{
img_info *node;
int ret = 1;
int joliet = 0;
grub_file_t file = NULL;
grub_uint32_t loadrba = 0;
grub_uint32_t boot_catlog = 0;
grub_uint8_t sector[512];
boot_info_table *info = NULL;
(void)ctxt;
(void)argc;
g_ventoy_tip_msg1 = g_ventoy_tip_msg2 = NULL;
if (vid)
/* This also trigger a iso9660 fs parse */
if (ventoy_check_file_exist("(loop)/isolinux/isolinux.cfg"))
{
node = (img_info *)(void *)grub_strtoul(vid + 4, NULL, 16);
if (node)
{
g_ventoy_tip_msg1 = node->tip1;
g_ventoy_tip_msg2 = node->tip2;
}
return 0;
}
joliet = grub_iso9660_is_joliet();
if (joliet == 0)
{
return 1;
}
file = grub_file_open(args[0], VENTOY_FILE_TYPE);
if (!file)
{
debug("failed to open %s\n", args[0]);
return 1;
}
boot_catlog = ventoy_get_iso_boot_catlog(file);
if (boot_catlog == 0)
{
debug("no bootcatlog found %u\n", boot_catlog);
goto out;
}
loadrba = ventoy_get_bios_eltorito_rba(file, boot_catlog);
if (loadrba == 0)
{
debug("no bios eltorito rba found %u\n", loadrba);
goto out;
}
grub_file_seek(file, loadrba * 2048);
grub_file_read(file, sector, 512);
info = (boot_info_table *)sector;
if (info->bi_data0 == 0x7c6ceafa &&
info->bi_data1 == 0x90900000 &&
info->bi_PrimaryVolumeDescriptor == 16 &&
info->bi_BootFileLocation == loadrba)
{
debug("bootloader is syslinux, %u.\n", loadrba);
ret = 0;
}
out:
grub_file_close(file);
grub_errno = GRUB_ERR_NONE;
return ret;
}
#endif /* #if 0 */
/* <END> : Deleted by longpanda, 20210916 PN:XX LABEL:XX */
int ventoy_env_init(void)
{
@@ -4960,6 +5127,7 @@ static cmd_para ventoy_cmds[] =
{ "vt_mod", ventoy_cmd_mod, 0, NULL, "{Int} {Int} {Var}", "mod integer variable", NULL },
{ "vt_strstr", ventoy_cmd_strstr, 0, NULL, "", "", NULL },
{ "vt_str_begin", ventoy_cmd_strbegin, 0, NULL, "", "", NULL },
{ "vt_str_casebegin", ventoy_cmd_strcasebegin, 0, NULL, "", "", NULL },
{ "vt_debug", ventoy_cmd_debug, 0, NULL, "{on|off}", "turn debug on/off", NULL },
{ "vtdebug", ventoy_cmd_debug, 0, NULL, "{on|off}", "turn debug on/off", NULL },
{ "vtbreak", ventoy_cmd_break, 0, NULL, "{level}", "set debug break", NULL },
@@ -5065,6 +5233,7 @@ static cmd_para ventoy_cmds[] =
{ "vt_unix_reset", ventoy_cmd_unix_reset, 0, NULL, "", "", NULL },
{ "vt_unix_replace_conf", ventoy_cmd_unix_replace_conf, 0, NULL, "", "", NULL },
{ "vt_unix_replace_ko", ventoy_cmd_unix_replace_ko, 0, NULL, "", "", NULL },
{ "vt_unix_ko_fillmap", ventoy_cmd_unix_ko_fillmap, 0, NULL, "", "", NULL },
{ "vt_unix_fill_image_desc", ventoy_cmd_unix_fill_image_desc, 0, NULL, "", "", NULL },
{ "vt_unix_gzip_new_ko", ventoy_cmd_unix_gzip_newko, 0, NULL, "", "", NULL },
{ "vt_unix_chain_data", ventoy_cmd_unix_chain_data, 0, NULL, "", "", NULL },
@@ -5079,6 +5248,8 @@ static cmd_para ventoy_cmds[] =
{ "vt_sel_wimboot", ventoy_cmd_sel_wimboot, 0, NULL, "", "", NULL },
{ "vt_set_wim_load_prompt", ventoy_cmd_set_wim_prompt, 0, NULL, "", "", NULL },
{ "vt_set_theme", ventoy_cmd_set_theme, 0, NULL, "", "", NULL },
{ "vt_set_theme_path", ventoy_cmd_set_theme_path, 0, NULL, "", "", NULL },
{ "vt_select_theme_cfg", ventoy_cmd_select_theme_cfg, 0, NULL, "", "", NULL },
{ "vt_get_efi_vdisk_offset", ventoy_cmd_get_efivdisk_offset, 0, NULL, "", "", NULL },
{ "vt_search_replace_initrd", ventoy_cmd_search_replace_initrd, 0, NULL, "", "", NULL },
@@ -5087,6 +5258,7 @@ static cmd_para ventoy_cmds[] =
{ "vt_check_json_path_case", ventoy_cmd_chk_json_pathcase, 0, NULL, "", "", NULL },
{ "vt_append_extra_sector", ventoy_cmd_append_ext_sector, 0, NULL, "", "", NULL },
{ "gptpriority", grub_cmd_gptpriority, 0, NULL, "", "", NULL },
{ "vt_syslinux_need_nojoliet", grub_cmd_syslinux_nojoliet, 0, NULL, "", "", NULL },
};
int ventoy_register_all_cmd(void)

View File

@@ -21,6 +21,8 @@
#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)
@@ -197,6 +199,18 @@ 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_start 0
@@ -548,6 +562,7 @@ 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
@@ -827,6 +842,7 @@ typedef struct install_template
int pathlen;
char isopath[256];
int timeout;
int autosel;
int cursel;
int templatenum;
@@ -858,6 +874,7 @@ typedef struct persistence_config
int pathlen;
char isopath[256];
int timeout;
int autosel;
int cursel;
int backendnum;
@@ -879,8 +896,11 @@ 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];
@@ -921,6 +941,7 @@ typedef struct custom_boot
typedef struct conf_replace
{
int pathlen;
int img;
char isopath[256];
char orgconf[256];
char newconf[256];
@@ -985,6 +1006,7 @@ typedef struct menu_password
extern int g_ventoy_menu_esc;
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;
@@ -1044,7 +1066,7 @@ 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 menu_tip * ventoy_plugin_get_menu_tip(const char *isopath);
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);
@@ -1055,6 +1077,8 @@ int ventoy_get_block_list(grub_file_t file, ventoy_img_chunk_list *chunklist, gr
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);
@@ -1066,6 +1090,7 @@ int ventoy_get_disk_guid(const char *filename, grub_uint8_t *guid, grub_uint8_t
grub_err_t ventoy_cmd_unix_reset(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_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);
@@ -1104,5 +1129,29 @@ int ventoy_chain_file_read(const char *path, int offset, int len, void *buf);
#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()
#endif /* __VENTOY_DEF_H__ */

View File

@@ -691,6 +691,7 @@ 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 id = 0;
int virtid = 0;
initrd_info *node;
grub_uint64_t sector;
grub_uint32_t offset;
@@ -738,6 +739,7 @@ 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++;
}
/* Lenovo EasyStartup need an addional sector for boundary check */
@@ -759,6 +761,7 @@ static void ventoy_linux_fill_virt_data( grub_uint64_t isosize, ventoy_chain_
offset += VTOY_APPEND_EXT_SIZE;
sector += cpio_secs;
cur++;
virtid++;
}
if (g_conf_replace_offset > 0)
@@ -776,9 +779,15 @@ static void ventoy_linux_fill_virt_data( grub_uint64_t isosize, ventoy_chain_
chain->virt_img_size_in_bytes += g_conf_replace_new_len_align;
if (g_grub_param->img_replace.magic == GRUB_IMG_REPLACE_MAGIC)
{
g_grub_param->img_replace.new_file_virtual_id = virtid;
}
offset += g_conf_replace_new_len_align;
sector += cpio_secs;
cur++;
virtid++;
}
return;
@@ -978,6 +987,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;

View File

@@ -57,6 +57,7 @@ static auto_memdisk *g_auto_memdisk_head = NULL;
static image_list *g_image_list_head = NULL;
static conf_replace *g_conf_replace_head = NULL;
static int g_theme_id = 0;
static int g_theme_num = 0;
static theme_list *g_theme_head = NULL;
static int g_theme_random = vtoy_theme_random_boot_second;
@@ -281,6 +282,7 @@ static int ventoy_plugin_theme_check(VTOY_JSON *json, const char *isodisk)
static int ventoy_plugin_theme_entry(VTOY_JSON *json, const char *isodisk)
{
const char *value;
char val[64];
char filepath[256];
VTOY_JSON *node = NULL;
theme_list *tail = NULL;
@@ -366,6 +368,18 @@ static int ventoy_plugin_theme_entry(VTOY_JSON *json, const char *isodisk)
}
}
}
grub_snprintf(val, sizeof(val), "%d", g_theme_num);
grub_env_set("VTOY_THEME_COUNT", val);
grub_env_export("VTOY_THEME_COUNT");
if (g_theme_num > 0)
{
vtoy_json_get_int(json->pstChild, "default_file", &g_theme_id);
if (g_theme_id > g_theme_num || g_theme_id < 0)
{
g_theme_id = 0;
}
}
value = vtoy_json_get_string_ex(json->pstChild, "gfxmode");
if (value)
@@ -602,6 +616,7 @@ static int ventoy_plugin_auto_install_check(VTOY_JSON *json, const char *isodisk
{
int pathnum = 0;
int autosel = 0;
int timeout = 0;
char *pos = NULL;
const char *iso = NULL;
VTOY_JSON *pNode = NULL;
@@ -638,6 +653,18 @@ static int ventoy_plugin_auto_install_check(VTOY_JSON *json, const char *isodisk
grub_printf("autosel: %d [FAIL]\n", autosel);
}
}
if (JSON_SUCCESS == vtoy_json_get_int(pNode->pstChild, "timeout", &timeout))
{
if (timeout >= 0)
{
grub_printf("timeout: %d [OK]\n", timeout);
}
else
{
grub_printf("timeout: %d [FAIL]\n", timeout);
}
}
}
else
{
@@ -662,6 +689,18 @@ static int ventoy_plugin_auto_install_check(VTOY_JSON *json, const char *isodisk
grub_printf("autosel: %d [FAIL]\n", autosel);
}
}
if (JSON_SUCCESS == vtoy_json_get_int(pNode->pstChild, "timeout", &timeout))
{
if (timeout >= 0)
{
grub_printf("timeout: %d [OK]\n", timeout);
}
else
{
grub_printf("timeout: %d [FAIL]\n", timeout);
}
}
}
else
{
@@ -682,6 +721,7 @@ static int ventoy_plugin_auto_install_entry(VTOY_JSON *json, const char *isodisk
int type = 0;
int pathnum = 0;
int autosel = 0;
int timeout = 0;
const char *iso = NULL;
VTOY_JSON *pNode = NULL;
install_template *node = NULL;
@@ -729,6 +769,7 @@ static int ventoy_plugin_auto_install_entry(VTOY_JSON *json, const char *isodisk
node->templatenum = pathnum;
node->autosel = -1;
node->timeout = -1;
if (JSON_SUCCESS == vtoy_json_get_int(pNode->pstChild, "autosel", &autosel))
{
if (autosel >= 0 && autosel <= pathnum)
@@ -736,6 +777,14 @@ static int ventoy_plugin_auto_install_entry(VTOY_JSON *json, const char *isodisk
node->autosel = autosel;
}
}
if (JSON_SUCCESS == vtoy_json_get_int(pNode->pstChild, "timeout", &timeout))
{
if (timeout >= 0)
{
node->timeout = timeout;
}
}
if (g_install_template_head)
{
@@ -1175,6 +1224,7 @@ static int ventoy_plugin_pwd_check(VTOY_JSON *json, const char *isodisk)
static int ventoy_plugin_persistence_check(VTOY_JSON *json, const char *isodisk)
{
int autosel = 0;
int timeout = 0;
int pathnum = 0;
char *pos = NULL;
const char *iso = NULL;
@@ -1213,6 +1263,18 @@ static int ventoy_plugin_persistence_check(VTOY_JSON *json, const char *isodisk)
grub_printf("autosel: %d [FAIL]\n", autosel);
}
}
if (JSON_SUCCESS == vtoy_json_get_int(pNode->pstChild, "timeout", &timeout))
{
if (timeout >= 0)
{
grub_printf("timeout: %d [OK]\n", timeout);
}
else
{
grub_printf("timeout: %d [FAIL]\n", timeout);
}
}
}
else
{
@@ -1231,6 +1293,7 @@ static int ventoy_plugin_persistence_check(VTOY_JSON *json, const char *isodisk)
static int ventoy_plugin_persistence_entry(VTOY_JSON *json, const char *isodisk)
{
int autosel = 0;
int timeout = 0;
int pathnum = 0;
const char *iso = NULL;
VTOY_JSON *pNode = NULL;
@@ -1273,6 +1336,7 @@ static int ventoy_plugin_persistence_entry(VTOY_JSON *json, const char *isodisk)
node->backendnum = pathnum;
node->autosel = -1;
node->timeout = -1;
if (JSON_SUCCESS == vtoy_json_get_int(pNode->pstChild, "autosel", &autosel))
{
if (autosel >= 0 && autosel <= pathnum)
@@ -1280,6 +1344,14 @@ static int ventoy_plugin_persistence_entry(VTOY_JSON *json, const char *isodisk)
node->autosel = autosel;
}
}
if (JSON_SUCCESS == vtoy_json_get_int(pNode->pstChild, "timeout", &timeout))
{
if (timeout >= 0)
{
node->timeout = timeout;
}
}
if (g_persistence_head)
{
@@ -1420,6 +1492,7 @@ static int ventoy_plugin_menualias_entry(VTOY_JSON *json, const char *isodisk)
static int ventoy_plugin_menutip_check(VTOY_JSON *json, const char *isodisk)
{
int type;
const char *path = NULL;
const char *tip = NULL;
VTOY_JSON *pNode = NULL;
@@ -1453,20 +1526,41 @@ static int ventoy_plugin_menutip_check(VTOY_JSON *json, const char *isodisk)
pNode = vtoy_json_find_item(json->pstChild, JSON_TYPE_ARRAY, "tips");
for (pNode = pNode->pstChild; pNode; pNode = pNode->pstNext)
{
type = vtoy_tip_image_file;
path = vtoy_json_get_string_ex(pNode->pstChild, "image");
if (!path)
{
path = vtoy_json_get_string_ex(pNode->pstChild, "dir");
type = vtoy_tip_directory;
}
if (path && path[0] == '/')
{
if (grub_strchr(path, '*'))
if (vtoy_tip_image_file == type)
{
grub_printf("image: <%s> [ * ]\n", path);
}
else if (ventoy_check_file_exist("%s%s", isodisk, path))
{
grub_printf("image: <%s> [ OK ]\n", path);
if (grub_strchr(path, '*'))
{
grub_printf("image: <%s> [ * ]\n", path);
}
else if (ventoy_is_file_exist("%s%s", isodisk, path))
{
grub_printf("image: <%s> [ OK ]\n", path);
}
else
{
grub_printf("image: <%s> [ NOT EXIST ]\n", path);
}
}
else
{
grub_printf("image: <%s> [ NOT EXIST ]\n", path);
if (ventoy_is_dir_exist("%s%s", isodisk, path))
{
grub_printf("dir: <%s> [ OK ]\n", path);
}
else
{
grub_printf("dir: <%s> [ NOT EXIST ]\n", path);
}
}
tip = vtoy_json_get_string_ex(pNode->pstChild, "tip");
@@ -1500,6 +1594,7 @@ static int ventoy_plugin_menutip_check(VTOY_JSON *json, const char *isodisk)
static int ventoy_plugin_menutip_entry(VTOY_JSON *json, const char *isodisk)
{
int type;
const char *path = NULL;
const char *tip = NULL;
VTOY_JSON *pNode = NULL;
@@ -1552,12 +1647,20 @@ static int ventoy_plugin_menutip_entry(VTOY_JSON *json, const char *isodisk)
for (pNode = pNode->pstChild; pNode; pNode = pNode->pstNext)
{
type = vtoy_tip_image_file;
path = vtoy_json_get_string_ex(pNode->pstChild, "image");
if (!path)
{
path = vtoy_json_get_string_ex(pNode->pstChild, "dir");
type = vtoy_tip_directory;
}
if (path && path[0] == '/')
{
node = grub_zalloc(sizeof(menu_tip));
if (node)
{
node->type = type;
node->pathlen = grub_snprintf(node->isopath, sizeof(node->isopath), "%s", path);
tip = vtoy_json_get_string_ex(pNode->pstChild, "tip");
@@ -1947,6 +2050,7 @@ static int ventoy_plugin_custom_boot_check(VTOY_JSON *json, const char *isodisk)
static int ventoy_plugin_conf_replace_entry(VTOY_JSON *json, const char *isodisk)
{
int img = 0;
const char *isof = NULL;
const char *orgf = NULL;
const char *newf = NULL;
@@ -1984,6 +2088,11 @@ static int ventoy_plugin_conf_replace_entry(VTOY_JSON *json, const char *isodisk
node = grub_zalloc(sizeof(conf_replace));
if (node)
{
if (JSON_SUCCESS == vtoy_json_get_int(pNode->pstChild, "img", &img))
{
node->img = img;
}
node->pathlen = grub_snprintf(node->isopath, sizeof(node->isopath), "%s", isof);
grub_snprintf(node->orgconf, sizeof(node->orgconf), "%s", orgf);
grub_snprintf(node->newconf, sizeof(node->newconf), "%s", newf);
@@ -2006,6 +2115,7 @@ static int ventoy_plugin_conf_replace_entry(VTOY_JSON *json, const char *isodisk
static int ventoy_plugin_conf_replace_check(VTOY_JSON *json, const char *isodisk)
{
int img = 0;
const char *isof = NULL;
const char *orgf = NULL;
const char *newf = NULL;
@@ -2075,7 +2185,7 @@ static int ventoy_plugin_conf_replace_check(VTOY_JSON *json, const char *isodisk
}
else
{
grub_printf("new:<%s> [OK]\n", newf);
grub_printf("new1:<%s> [OK]\n", newf);
}
grub_file_close(file);
}
@@ -2083,6 +2193,12 @@ static int ventoy_plugin_conf_replace_check(VTOY_JSON *json, const char *isodisk
{
grub_printf("new:<%s> [NOT Exist]\n", newf);
}
if (JSON_SUCCESS == vtoy_json_get_int(pNode->pstChild, "img", &img))
{
grub_printf("img:<%d>\n", img);
}
grub_printf("\n");
}
}
@@ -2267,45 +2383,59 @@ static int ventoy_plugin_image_list_check(VTOY_JSON *json, const char *isodisk)
static plugin_entry g_plugin_entries[] =
{
{ "control", ventoy_plugin_control_entry, ventoy_plugin_control_check },
{ "theme", ventoy_plugin_theme_entry, ventoy_plugin_theme_check },
{ "auto_install", ventoy_plugin_auto_install_entry, ventoy_plugin_auto_install_check },
{ "persistence", ventoy_plugin_persistence_entry, ventoy_plugin_persistence_check },
{ "menu_alias", ventoy_plugin_menualias_entry, ventoy_plugin_menualias_check },
{ "menu_tip", ventoy_plugin_menutip_entry, ventoy_plugin_menutip_check },
{ "menu_class", ventoy_plugin_menuclass_entry, ventoy_plugin_menuclass_check },
{ "injection", ventoy_plugin_injection_entry, ventoy_plugin_injection_check },
{ "auto_memdisk", ventoy_plugin_auto_memdisk_entry, ventoy_plugin_auto_memdisk_check },
{ "image_list", ventoy_plugin_image_list_entry, ventoy_plugin_image_list_check },
{ "image_blacklist", ventoy_plugin_image_list_entry, ventoy_plugin_image_list_check },
{ "conf_replace", ventoy_plugin_conf_replace_entry, ventoy_plugin_conf_replace_check },
{ "dud", ventoy_plugin_dud_entry, ventoy_plugin_dud_check },
{ "password", ventoy_plugin_pwd_entry, ventoy_plugin_pwd_check },
{ "custom_boot", ventoy_plugin_custom_boot_entry, ventoy_plugin_custom_boot_check },
{ "control", ventoy_plugin_control_entry, ventoy_plugin_control_check, 0 },
{ "theme", ventoy_plugin_theme_entry, ventoy_plugin_theme_check, 0 },
{ "auto_install", ventoy_plugin_auto_install_entry, ventoy_plugin_auto_install_check, 0 },
{ "persistence", ventoy_plugin_persistence_entry, ventoy_plugin_persistence_check, 0 },
{ "menu_alias", ventoy_plugin_menualias_entry, ventoy_plugin_menualias_check, 0 },
{ "menu_tip", ventoy_plugin_menutip_entry, ventoy_plugin_menutip_check, 0 },
{ "menu_class", ventoy_plugin_menuclass_entry, ventoy_plugin_menuclass_check, 0 },
{ "injection", ventoy_plugin_injection_entry, ventoy_plugin_injection_check, 0 },
{ "auto_memdisk", ventoy_plugin_auto_memdisk_entry, ventoy_plugin_auto_memdisk_check, 0 },
{ "image_list", ventoy_plugin_image_list_entry, ventoy_plugin_image_list_check, 0 },
{ "image_blacklist", ventoy_plugin_image_list_entry, ventoy_plugin_image_list_check, 0 },
{ "conf_replace", ventoy_plugin_conf_replace_entry, ventoy_plugin_conf_replace_check, 0 },
{ "dud", ventoy_plugin_dud_entry, ventoy_plugin_dud_check, 0 },
{ "password", ventoy_plugin_pwd_entry, ventoy_plugin_pwd_check, 0 },
{ "custom_boot", ventoy_plugin_custom_boot_entry, ventoy_plugin_custom_boot_check, 0 },
};
static int ventoy_parse_plugin_config(VTOY_JSON *json, const char *isodisk)
{
int i;
char key[128];
VTOY_JSON *cur = json;
VTOY_JSON *cur = NULL;
grub_snprintf(g_iso_disk_name, sizeof(g_iso_disk_name), "%s", isodisk);
while (cur)
for (cur = json; cur; cur = cur->pstNext)
{
for (i = 0; i < (int)ARRAY_SIZE(g_plugin_entries); i++)
{
grub_snprintf(key, sizeof(key), "%s_%s", g_plugin_entries[i].key, g_arch_mode_suffix);
if (grub_strcmp(g_plugin_entries[i].key, cur->pcName) == 0 || grub_strcmp(key, cur->pcName) == 0)
if (g_plugin_entries[i].flag == 0 && grub_strcmp(key, cur->pcName) == 0)
{
debug("Plugin entry for %s\n", g_plugin_entries[i].key);
g_plugin_entries[i].entryfunc(cur, isodisk);
g_plugin_entries[i].flag = 1;
break;
}
}
}
cur = cur->pstNext;
for (cur = json; cur; cur = cur->pstNext)
{
for (i = 0; i < (int)ARRAY_SIZE(g_plugin_entries); i++)
{
if (g_plugin_entries[i].flag == 0 && grub_strcmp(g_plugin_entries[i].key, cur->pcName) == 0)
{
debug("Plugin entry for %s\n", g_plugin_entries[i].key);
g_plugin_entries[i].entryfunc(cur, isodisk);
g_plugin_entries[i].flag = 1;
break;
}
}
}
return 0;
@@ -2314,7 +2444,9 @@ static int ventoy_parse_plugin_config(VTOY_JSON *json, const char *isodisk)
grub_err_t ventoy_cmd_load_plugin(grub_extcmd_context_t ctxt, int argc, char **args)
{
int ret = 0;
int offset = 0;
char *buf = NULL;
grub_uint8_t *code = NULL;
grub_file_t file;
VTOY_JSON *json = NULL;
@@ -2351,9 +2483,25 @@ grub_err_t ventoy_cmd_load_plugin(grub_extcmd_context_t ctxt, int argc, char **a
return 1;
}
code = (grub_uint8_t *)buf;
if (code[0] == 0xef && code[1] == 0xbb && code[2] == 0xbf)
{
offset = 3; /* Skip UTF-8 BOM */
}
else if ((code[0] == 0xff && code[1] == 0xfe) || (code[0] == 0xfe && code[1] == 0xff))
{
grub_env_set("VTOY_PLUGIN_SYNTAX_ERROR", "1");
grub_env_export("VTOY_PLUGIN_SYNTAX_ERROR");
ret = vtoy_json_parse(json, buf);
grub_env_set("VTOY_PLUGIN_ENCODE_ERROR", "1");
grub_env_export("VTOY_PLUGIN_ENCODE_ERROR");
debug("Failed to parse json string %d\n", ret);
grub_free(buf);
return 1;
}
ret = vtoy_json_parse(json, buf + offset);
if (ret)
{
grub_env_set("VTOY_PLUGIN_SYNTAX_ERROR", "1");
@@ -2651,7 +2799,7 @@ const char * ventoy_plugin_get_menu_alias(int type, const char *isopath)
return NULL;
}
const menu_tip * ventoy_plugin_get_menu_tip(const char *isopath)
const menu_tip * ventoy_plugin_get_menu_tip(int type, const char *isopath)
{
int len;
menu_tip *node = NULL;
@@ -2664,7 +2812,8 @@ const menu_tip * ventoy_plugin_get_menu_tip(const char *isopath)
len = (int)grub_strlen(isopath);
for (node = g_menu_tip_head; node; node = node->next)
{
if (node->pathlen == len && ventoy_strcmp(node->isopath, isopath) == 0)
if (node->type == type && node->pathlen &&
node->pathlen == len && ventoy_strcmp(node->isopath, isopath) == 0)
{
return node;
}
@@ -3099,7 +3248,7 @@ grub_err_t ventoy_cmd_plugin_check_json(grub_extcmd_context_t ctxt, int argc, ch
grub_snprintf(key, sizeof(key), "%s_%s", args[1], g_arch_mode_suffix);
for (node = json->pstChild; node; node = node->pstNext)
{
if (grub_strcmp(node->pcName, args[1]) == 0 || grub_strcmp(node->pcName, key) == 0)
if (grub_strcmp(node->pcName, key) == 0)
{
break;
}
@@ -3107,8 +3256,19 @@ grub_err_t ventoy_cmd_plugin_check_json(grub_extcmd_context_t ctxt, int argc, ch
if (!node)
{
grub_printf("%s is NOT found in ventoy.json\n", args[1]);
goto end;
for (node = json->pstChild; node; node = node->pstNext)
{
if (grub_strcmp(node->pcName, args[1]) == 0)
{
break;
}
}
if (!node)
{
grub_printf("%s is NOT found in ventoy.json\n", args[1]);
goto end;
}
}
for (i = 0; i < (int)ARRAY_SIZE(g_plugin_entries); i++)
@@ -3131,6 +3291,65 @@ end:
return 0;
}
grub_err_t ventoy_cmd_select_theme_cfg(grub_extcmd_context_t ctxt, int argc, char **args)
{
int pos = 0;
int bufsize = 0;
char *name = NULL;
char *buf = NULL;
theme_list *node = NULL;
(void)argc;
(void)args;
(void)ctxt;
if (g_theme_single_file[0])
{
return 0;
}
if (g_theme_num < 2)
{
return 0;
}
bufsize = (g_theme_num + 1) * 1024;
buf = grub_malloc(bufsize);
if (!buf)
{
return 0;
}
for (node = g_theme_head; node; node = node->next)
{
name = grub_strstr(node->theme.path, ")/");
if (name)
{
name++;
}
else
{
name = node->theme.path;
}
pos += grub_snprintf(buf + pos, bufsize - pos,
"menuentry \"%s\" --class=debug_theme_item --class=debug_theme_select --class=F5tool {\n"
"vt_set_theme_path \"%s\"\n"
"}\n",
name, node->theme.path);
}
pos += grub_snprintf(buf + pos, bufsize - pos,
"menuentry 'Return to previous menu [Esc]' --class=vtoyret VTOY_RET {\n"
"echo 'Return ...'\n"
"}\n");
grub_script_execute_sourcecode(buf);
grub_free(buf);
return 0;
}
grub_err_t ventoy_cmd_set_theme(grub_extcmd_context_t ctxt, int argc, char **args)
{
grub_uint32_t i = 0;
@@ -3155,6 +3374,17 @@ grub_err_t ventoy_cmd_set_theme(grub_extcmd_context_t ctxt, int argc, char **arg
{
goto end;
}
if (g_theme_id > 0 && g_theme_id <= g_theme_num)
{
for (i = 0; i < (grub_uint32_t)(g_theme_id - 1) && node; i++)
{
node = node->next;
}
grub_env_set("theme", node->theme.path);
goto end;
}
grub_memset(&datetime, 0, sizeof(datetime));
grub_get_datetime(&datetime);
@@ -3186,7 +3416,25 @@ grub_err_t ventoy_cmd_set_theme(grub_extcmd_context_t ctxt, int argc, char **arg
grub_env_set("theme", node->theme.path);
end:
VENTOY_CMD_RETURN(GRUB_ERR_NONE);
}
extern char g_ventoy_theme_path[256];
grub_err_t ventoy_cmd_set_theme_path(grub_extcmd_context_t ctxt, int argc, char **args)
{
(void)argc;
(void)ctxt;
if (argc == 0)
{
g_ventoy_theme_path[0] = 0;
}
else
{
grub_snprintf(g_ventoy_theme_path, sizeof(g_ventoy_theme_path), "%s", args[0]);
}
VENTOY_CMD_RETURN(GRUB_ERR_NONE);
}

View File

@@ -47,6 +47,11 @@ 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_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;
@@ -82,6 +87,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;
}
@@ -121,15 +135,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)
{
@@ -142,12 +191,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;
@@ -156,6 +205,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;
@@ -182,6 +262,11 @@ 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);
}
@@ -210,6 +295,12 @@ 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 (g_mod_search_magic)
{
debug("hint.ventoy NO need\n");
goto out;
}
disk = isofile->device->disk;
ventoy_get_disk_guid(isofile->name, disk_guid, disk_sig);
@@ -232,8 +323,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;
}
@@ -258,13 +349,16 @@ grub_err_t ventoy_cmd_unix_reset(grub_extcmd_context_t ctxt, int argc, char **ar
(void)argc;
(void)args;
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);
}
@@ -624,6 +718,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 += 65536)
{
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 >> 16));
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;
@@ -673,10 +788,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;
@@ -908,7 +1086,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

@@ -375,6 +375,7 @@ grub_err_t ventoy_cmd_sel_wimboot(grub_extcmd_context_t ctxt, int argc, char **a
g_ventoy_menu_esc = 1;
g_ventoy_suppress_esc = 1;
g_ventoy_suppress_esc_default = 1;
grub_snprintf(configfile, sizeof(configfile), "configfile mem:0x%llx:size:%d", (ulonglong)(ulong)buf, size);
grub_script_execute_sourcecode(configfile);
@@ -776,6 +777,67 @@ end:
return ret;
}
static int parse_custom_setup_path(char *cmdline, const char **path, char *exefile)
{
int i = 0;
int len = 0;
char *pos1 = NULL;
char *pos2 = NULL;
if ((cmdline[0] == 'x' || cmdline[0] == 'X') && cmdline[1] == ':')
{
pos1 = pos2 = cmdline + 3;
while (i < VTOY_MAX_DIR_DEPTH && *pos2)
{
while (*pos2 && *pos2 != '\\' && *pos2 != '/')
{
pos2++;
}
path[i++] = pos1;
if (*pos2 == 0)
{
break;
}
*pos2 = 0;
pos1 = pos2 + 1;
pos2 = pos1;
}
if (i == 0 || i >= VTOY_MAX_DIR_DEPTH)
{
return 1;
}
}
else
{
path[i++] = "Windows";
path[i++] = "System32";
path[i++] = cmdline;
}
pos1 = (char *)path[i - 1];
while (*pos1 != ' ' && *pos1 != '\t' && *pos1)
{
pos1++;
}
*pos1 = 0;
len = (int)grub_strlen(path[i - 1]);
if (len < 4 || grub_strcasecmp(path[i - 1] + len - 4, ".exe") != 0)
{
grub_snprintf(exefile, 256, "%s.exe", path[i - 1]);
path[i - 1] = exefile;
}
debug("custom setup: %d <%s>\n", i, path[i - 1]);
return 0;
}
static wim_directory_entry * search_replace_wim_dirent
(
grub_file_t file,
@@ -786,38 +848,44 @@ static wim_directory_entry * search_replace_wim_dirent
)
{
int ret;
char exefile[256] = {0};
char cmdline[256] = {0};
wim_directory_entry *wim_dirent = NULL;
wim_directory_entry *pecmd_dirent = NULL;
const char *peset_path[] = { "Windows", "System32", "peset.exe", NULL };
const char *pecmd_path[] = { "Windows", "System32", "pecmd.exe", NULL };
const char *winpeshl_path[] = { "Windows", "System32", "winpeshl.exe", NULL };
const char *custom_path[VTOY_MAX_DIR_DEPTH + 1] = { NULL };
pecmd_dirent = search_full_wim_dirent(meta_data, dir, pecmd_path);
debug("search pecmd.exe %p\n", pecmd_dirent);
if (pecmd_dirent)
{
ret = parse_registry_setup_cmdline(file, head, lookup, meta_data, dir, cmdline, sizeof(cmdline));
ret = parse_registry_setup_cmdline(file, head, lookup, meta_data, dir, cmdline, sizeof(cmdline) - 1);
if (0 == ret)
{
debug("registry setup cmdline:<%s>\n", cmdline);
ventoy_str_toupper(cmdline);
if (grub_strncmp(cmdline, "PECMD", 5) == 0)
if (grub_strncasecmp(cmdline, "PECMD", 5) == 0)
{
wim_dirent = pecmd_dirent;
}
else if (grub_strncmp(cmdline, "PESET", 5) == 0)
else if (grub_strncasecmp(cmdline, "PESET", 5) == 0)
{
wim_dirent = search_full_wim_dirent(meta_data, dir, peset_path);
debug("search peset.exe %p\n", wim_dirent);
}
else if (grub_strncmp(cmdline, "WINPESHL", 8) == 0)
else if (grub_strncasecmp(cmdline, "WINPESHL", 8) == 0)
{
wim_dirent = search_full_wim_dirent(meta_data, dir, winpeshl_path);
debug("search winpeshl.exe %p\n", wim_dirent);
}
else if (0 == parse_custom_setup_path(cmdline, custom_path, exefile))
{
wim_dirent = search_full_wim_dirent(meta_data, dir, custom_path);
debug("search custom path %p\n", wim_dirent);
}
if (wim_dirent)
{
@@ -982,6 +1050,7 @@ int ventoy_fill_windows_rtdata(void *buf, char *isopath)
{
char *pos = NULL;
char *script = NULL;
const char *env = NULL;
ventoy_windows_data *data = (ventoy_windows_data *)buf;
grub_memset(data, 0, sizeof(ventoy_windows_data));
@@ -1020,7 +1089,13 @@ int ventoy_fill_windows_rtdata(void *buf, char *isopath)
{
debug("injection archive not configed %s\n", pos);
}
env = grub_env_get("VTOY_WIN11_BYPASS_CHECK");
if (env && env[0] == '1' && env[1] == 0)
{
data->windows11_bypass_check = 1;
}
return 0;
}

View File

@@ -121,6 +121,7 @@ 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
*
*/
grub_uint8_t vtoy_reserved[32]; // Internal use by ventoy
@@ -135,7 +136,8 @@ 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_uint8_t reserved[255];
}ventoy_windows_data;
@@ -241,6 +243,7 @@ typedef struct ventoy_img_chunk_list
#pragma pack(1)
#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 +262,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;
grub_env_printf_pf grub_env_printf;
}ventoy_grub_param;

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

View File

@@ -29,13 +29,21 @@ for i in 0 1 2 3 4 5 6 7 8 9; do
fi
done
ventoy_extract_vtloopex ${vtdiskname}2 crux
# no need since 3.6.1
$BUSYBOX_PATH/modprobe dax > /dev/null 2>&1
$BUSYBOX_PATH/modprobe dm-mod > /dev/null 2>&1
if $GREP -q 'device-mapper' /proc/devices; then
vtlog "dm-mod module check success ..."
else
vtlog "Need to load dm-mod module ..."
ventoy_extract_vtloopex ${vtdiskname}2 crux
vtKver=$(uname -r)
vtLoopExDir=$VTOY_PATH/vtloopex/crux/vtloopex
vtKver=$(uname -r)
vtLoopExDir=$VTOY_PATH/vtloopex/crux/vtloopex
ventoy_check_install_module_xz $vtLoopExDir/dm-mod/$vtKver/64/dax.ko
ventoy_check_install_module_xz $vtLoopExDir/dm-mod/$vtKver/64/dm-mod.ko
ventoy_check_install_module_xz $vtLoopExDir/dm-mod/$vtKver/64/dax.ko
ventoy_check_install_module_xz $vtLoopExDir/dm-mod/$vtKver/64/dm-mod.ko
fi
ventoy_udev_disk_common_hook "${vtdiskname#/dev/}2"

View File

@@ -0,0 +1,82 @@
#!/ventoy/busybox/sh
#************************************************************************************
# Copyright (c) 2020, longpanda <admin@ventoy.net>
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation; either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, see <http://www.gnu.org/licenses/>.
#
#************************************************************************************
. /ventoy/hook/ventoy-hook-lib.sh
vtlog "####### $0 $* ########"
VTPATH_OLD=$PATH; PATH=$BUSYBOX_PATH:$VTOY_PATH/tool:$PATH
ventoy_os_install_dmsetup_by_fuse() {
vtlog "ventoy_os_install_dmsetup_by_fuse $*"
mkdir -p $VTOY_PATH/mnt/fuse $VTOY_PATH/mnt/iso $VTOY_PATH/mnt/squashfs
vtoydm -p -f $VTOY_PATH/ventoy_image_map -d $1 > $VTOY_PATH/ventoy_dm_table
vtoy_fuse_iso -f $VTOY_PATH/ventoy_dm_table -m $VTOY_PATH/mnt/fuse
mount -t iso9660 $VTOY_PATH/mnt/fuse/ventoy.iso $VTOY_PATH/mnt/iso
mount -t squashfs $VTOY_PATH/mnt/iso/minios/01-core*.sb $VTOY_PATH/mnt/squashfs
KoName=$(ls $VTOY_PATH/mnt/squashfs/lib/modules/$2/kernel/drivers/md/dm-mod.ko*)
vtlog "insmod $KoName"
insmod $KoName
umount $VTOY_PATH/mnt/squashfs
umount $VTOY_PATH/mnt/iso
umount $VTOY_PATH/mnt/fuse
}
ventoy_os_install_dmsetup() {
vtlog "ventoy_os_install_dmsetup"
if grep -q 'device-mapper' /proc/devices; then
vtlog "device-mapper module already loaded"
return;
fi
vtKerVer=$(uname -r)
if modprobe fuse 2>>$VTLOG; then
ventoy_os_install_dmsetup_by_fuse $1 $vtKerVer
fi
}
vtdiskname=$(get_ventoy_disk_name)
if [ "$vtdiskname" = "unknown" ]; then
vtlog "ventoy disk not found"
PATH=$VTPATH_OLD
exit 0
fi
if check_usb_disk_ready "$vtdiskname"; then
vtlog "check_usb_disk_ready ok"
else
vtlog "check_usb_disk_ready error"
PATH=$VTPATH_OLD
exit 0
fi
ventoy_os_install_dmsetup $vtdiskname
ventoy_udev_disk_common_hook "${vtdiskname#/dev/}2" "noreplace"
PATH=$VTPATH_OLD

View File

@@ -0,0 +1,24 @@
#!/ventoy/busybox/sh
#************************************************************************************
# Copyright (c) 2020, longpanda <admin@ventoy.net>
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation; either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, see <http://www.gnu.org/licenses/>.
#
#************************************************************************************
if [ -f /lib/livekitlib ] && $GREP -q 'debug_log.*find_data_try' /lib/livekitlib; then
$SED "/debug_log.*find_data_try/a\ $BUSYBOX_PATH/sh $VTOY_PATH/hook/debian/minios-disk.sh" -i /lib/livekitlib
else
$SED "/find_data/i\ $BUSYBOX_PATH/sh $VTOY_PATH/hook/debian/minios-disk.sh" -i /init
fi

View File

@@ -22,9 +22,16 @@ porteus_hook() {
$SED "/searching *for *\$CFG *file/i\ $BUSYBOX_PATH/sh $VTOY_PATH/hook/debian/porteus-disk.sh" -i $1
}
if $GREP -q exfat /proc/filesystems; then
vtPath=$($VTOY_PATH/tool/vtoydump -p $VTOY_PATH/ventoy_os_param)
vtPath=$($VTOY_PATH/tool/vtoydump -p $VTOY_PATH/ventoy_os_param)
echo $vtPath | $GREP -q " "
_vtRet1=$?
$GREP -q exfat /proc/filesystems
_vtRet2=$?
echo "_vtRet1=$_vtRet1 _vtRet2=$_vtRet2 ..." >> $VTLOG
if [ $_vtRet1 -ne 0 -a $_vtRet2 -eq 0 ]; then
vtFindFlag=0
$GREP '`value from`' /usr/* -r | $AWK -F: '{print $1}' | while read vtline; do
echo "hooking $vtline ..." >> $VTLOG
@@ -34,11 +41,19 @@ if $GREP -q exfat /proc/filesystems; then
if [ $vtFindFlag -eq 0 ]; then
if $GREP -q '`value from`' /linuxrc; then
echo "hooking linuxrc ..." >> $VTLOG
$SED "/searching *for *\$CFG *file/i$BUSYBOX_PATH/sh $VTOY_PATH/hook/debian/porteus-path.sh" -i /linuxrc
$SED "/searching *for *\$CFG *file/iFROM=\$(cat /porteus-from)" -i /linuxrc
$SED "/searching *for *\$CFG *file/iISO=\$(cat /porteus-from)" -i /linuxrc
vtFindFlag=1
if $GREP -q "searching *for *\$CFG *file" /linuxrc; then
echo "hooking linuxrc CFG..." >> $VTLOG
$SED "/searching *for *\$CFG *file/i$BUSYBOX_PATH/sh $VTOY_PATH/hook/debian/porteus-path.sh" -i /linuxrc
$SED "/searching *for *\$CFG *file/iFROM=\$(cat /porteus-from)" -i /linuxrc
$SED "/searching *for *\$CFG *file/iISO=\$(cat /porteus-from)" -i /linuxrc
vtFindFlag=1
else
echo "hooking linuxrc SGN..." >> $VTLOG
$SED "/searching *for *\$SGN *file/i$BUSYBOX_PATH/sh $VTOY_PATH/hook/debian/porteus-path.sh" -i /linuxrc
$SED "/searching *for *\$SGN *file/iFROM=\$(cat /porteus-from)" -i /linuxrc
$SED "/searching *for *\$SGN *file/iISO=\$(cat /porteus-from)" -i /linuxrc
vtFindFlag=1
fi
fi
fi
@@ -46,7 +61,7 @@ else
for vtfile in '/linuxrc' '/init'; do
if [ -e $vtfile ]; then
if ! $GREP -q ventoy $vtfile; then
echo "hooking $vtfile ..." >> $VTLOG
echo "hooking disk $vtfile ..." >> $VTLOG
porteus_hook $vtfile
fi
fi

View File

@@ -0,0 +1,91 @@
#!/ventoy/busybox/sh
#************************************************************************************
# Copyright (c) 2020, longpanda <admin@ventoy.net>
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation; either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, see <http://www.gnu.org/licenses/>.
#
#************************************************************************************
. /ventoy/hook/ventoy-hook-lib.sh
if is_ventoy_hook_finished; then
exit 0
fi
vtlog "####### $0 $* ########"
VTPATH_OLD=$PATH; PATH=$BUSYBOX_PATH:$VTOY_PATH/tool:$PATH
ventoy_os_install_dmsetup_by_fuse() {
vtlog "ventoy_os_install_dmsetup_by_fuse $*"
mkdir -p $VTOY_PATH/mnt/fuse $VTOY_PATH/mnt/iso $VTOY_PATH/mnt/squashfs
vtoydm -p -f $VTOY_PATH/ventoy_image_map -d $1 > $VTOY_PATH/ventoy_dm_table
vtoy_fuse_iso -f $VTOY_PATH/ventoy_dm_table -m $VTOY_PATH/mnt/fuse
mount -t iso9660 $VTOY_PATH/mnt/fuse/ventoy.iso $VTOY_PATH/mnt/iso
mount -t squashfs $VTOY_PATH/mnt/iso/pyabr/01-core.sb $VTOY_PATH/mnt/squashfs
KoName=$(ls $VTOY_PATH/mnt/squashfs/lib/modules/$2/kernel/drivers/md/dm-mod.ko*)
vtlog "insmod $KoName"
insmod $KoName
umount $VTOY_PATH/mnt/squashfs
umount $VTOY_PATH/mnt/iso
umount $VTOY_PATH/mnt/fuse
}
while [ -n "Y" ]; do
vtdiskname=$(get_ventoy_disk_name)
if [ "$vtdiskname" = "unknown" ]; then
vtlog "ventoy disk not found"
if [ -r /proc/sys/kernel/hotplug ]; then
echo /sbin/mdev > /proc/sys/kernel/hotplug
fi
mdev -s
sleep 1
else
if check_usb_disk_ready "$vtdiskname"; then
vtlog "check_usb_disk_ready $vtdiskname ok"
break
else
vtlog "check_usb_disk_ready $vtdiskname error"
if [ -r /proc/sys/kernel/hotplug ]; then
echo /sbin/mdev > /proc/sys/kernel/hotplug
fi
mdev -s
sleep 1
fi
fi
done
vtdiskname=$(get_ventoy_disk_name)
if [ "$vtdiskname" = "unknown" ]; then
vtlog "ventoy disk not found"
PATH=$VTPATH_OLD
exit 0
fi
modprobe fuse
modprobe cuse
vtKver=$(uname -r)
ventoy_os_install_dmsetup_by_fuse $vtdiskname $vtKver
ventoy_udev_disk_common_hook "${vtdiskname#/dev/}2" "noreplace"
PATH=$VTPATH_OLD
set_ventoy_hook_finish

View File

@@ -0,0 +1,20 @@
#!/ventoy/busybox/sh
#************************************************************************************
# Copyright (c) 2020, longpanda <admin@ventoy.net>
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation; either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, see <http://www.gnu.org/licenses/>.
#
#************************************************************************************
$SED "/find_data/i\ $BUSYBOX_PATH/sh $VTOY_PATH/hook/debian/pyabr-disk.sh" -i /init

View File

@@ -23,6 +23,11 @@ $SED "s#.*livefs_root=.*find_livefs.*#$BUSYBOX_PATH/mount -t iso9660 /dev/mapper
if [ -e /init ] && $GREP -q '^mountroot$' /init; then
echo "Here before mountroot ..." >> $VTLOG
$SED "/^mountroot$/i\\$BUSYBOX_PATH/sh $VTOY_PATH/hook/debian/disk_mount_hook.sh" -i /init
if [ -f /scripts/init-premount/ORDER ]; then
$SED "/\/scripts\/init-premount\/partitioning/,+1d" -i /scripts/init-premount/ORDER
fi
else
echo "Use default hook ..." >> $VTLOG
ventoy_systemd_udevd_work_around

View File

@@ -56,6 +56,10 @@ ventoy_get_debian_distro() {
echo 'slax'; return
fi
if $GREP -q 'minios/' /proc/cmdline; then
echo 'minios'; return
fi
if $GREP -q 'PVE ' /proc/version; then
echo 'pve'; return
fi
@@ -94,6 +98,10 @@ ventoy_get_debian_distro() {
echo 'mocaccino'; return
fi
if $GREP -q '/pyabr/' /proc/cmdline; then
echo 'pyabr'; return
fi
echo 'default'
}

View File

@@ -92,7 +92,8 @@ if [ -f /etc/system-release ]; then
vtNeedRepo="yes"
fi
fi
if $GREP -q el8 /proc/version; then
if $GREP -q 'el[89]' /proc/version; then
vtNeedRepo="yes"
fi
@@ -102,6 +103,8 @@ if $GREP -i -q Fedora /proc/version; then
fi
fi
echo "vtNeedRepo=$vtNeedRepo" >> $VTLOG
if [ "$vtNeedRepo" = "yes" ]; then
$BUSYBOX_PATH/cp -a $VTOY_PATH/hook/rhel7/ventoy-repo.sh /lib/dracut/hooks/pre-pivot/99-ventoy-repo.sh
fi

View File

@@ -30,6 +30,7 @@ SLEEP=$BUSYBOX_PATH/sleep
HEAD=$BUSYBOX_PATH/head
VTOY_DM_PATH=/dev/mapper/ventoy
VTOY_DEBUG_LEVEL=$($BUSYBOX_PATH/hexdump -n 1 -s 450 -e '1/1 "%02x"' $VTOY_PATH/ventoy_os_param)
VTOY_LINUX_REMOUNT=$($BUSYBOX_PATH/hexdump -n 1 -s 454 -e '1/1 "%02x"' $VTOY_PATH/ventoy_os_param)
if [ "$VTOY_DEBUG_LEVEL" = "01" ]; then
if [ -e /dev/console ]; then
@@ -220,6 +221,135 @@ ventoy_check_dm_module() {
fi
}
ventoy_need_dm_patch() {
if [ "$VTOY_LINUX_REMOUNT" != "01" ]; then
$BUSYBOX_PATH/false; return
fi
if $GREP -q 'device-mapper' /proc/devices; then
:
else
$BUSYBOX_PATH/false; return
fi
if $GREP -q 'dm_patch' /proc/modules; then
$BUSYBOX_PATH/false; return
fi
vtMajorVer=$($BUSYBOX_PATH/uname -r | $AWK -F. '{print $1}')
vtMinorVer=$($BUSYBOX_PATH/uname -r | $AWK -F. '{print $2}')
if [ $vtMajorVer -lt 3 ]; then
$BUSYBOX_PATH/false; return
elif [ $vtMajorVer -eq 3 -a $vtMinorVer -lt 10 ]; then
$BUSYBOX_PATH/false; return
fi
$BUSYBOX_PATH/true
}
ventoy_dm_patch() {
vtMType=$($BUSYBOX_PATH/uname -m)
vtlog "######### ventoy_dm_patch ############"
if echo $vtMType | $EGREP -i -q "x86.64|amd64"; then
vtKoName=dm_patch_64.ko
else
vtlog "unsupported machine type $vtMType"
return
fi
if [ -f $VTOY_PATH/tool/$vtKoName ]; then
vtlog "/ventoy/tool/$vtKoName exist OK"
else
vtlog "/ventoy/tool/$vtKoName NOT exist"
return
fi
$CAT /proc/kallsyms | $BUSYBOX_PATH/sort > $VTOY_PATH/kallsyms
vtLine=$($VTOY_PATH/tool/vtoyksym dm_get_table_device $VTOY_PATH/kallsyms)
get_addr=$(echo $vtLine | $AWK '{print $1}')
get_size=$(echo $vtLine | $AWK '{print $2}')
vtLine=$($VTOY_PATH/tool/vtoyksym dm_put_table_device $VTOY_PATH/kallsyms)
put_addr=$(echo $vtLine | $AWK '{print $1}')
put_size=$(echo $vtLine | $AWK '{print $2}')
ro_addr=$($GREP ' set_memory_ro$' /proc/kallsyms | $AWK '{print $1}')
rw_addr=$($GREP ' set_memory_rw$' /proc/kallsyms | $AWK '{print $1}')
kprobe_reg_addr=$($GREP ' register_kprobe$' /proc/kallsyms | $AWK '{print $1}')
kprobe_unreg_addr=$($GREP ' unregister_kprobe$' /proc/kallsyms | $AWK '{print $1}')
if [ "$VTOY_DEBUG_LEVEL" = "01" ]; then
printk_addr=$($GREP ' printk$' /proc/kallsyms | $AWK '{print $1}')
vtDebug="-v"
else
printk_addr=0
fi
#printk_addr=$($GREP ' printk$' /proc/kallsyms | $AWK '{print $1}')
#vtDebug="-v"
vtlog get_addr=$get_addr get_size=$get_size
vtlog put_addr=$put_addr put_size=$put_size
vtlog kprobe_reg_addr=$kprobe_reg_addr kprobe_unreg_addr=$kprobe_unreg_addr
vtlog ro_addr=$ro_addr rw_addr=$rw_addr printk_addr=$printk_addr
if [ "$get_addr" = "0" -o "$put_addr" = "0" ]; then
vtlog "Invalid symbol address"
return
fi
if [ "$ro_addr" = "0" -o "$rw_addr" = "0" ]; then
vtlog "Invalid symbol address"
return
fi
vtKv=$($BUSYBOX_PATH/uname -r)
if [ -d /lib/modules/$vtKv/kernel/fs ]; then
vtModPath=$($FIND /lib/modules/$vtKv/kernel/fs/ -name "*.ko*" | $HEAD -n1)
else
vtModPath=$($FIND /lib/modules/$vtKv/kernel/ -name "xfs.ko*" | $HEAD -n1)
fi
if [ -z "$vtModPath" ]; then
vtModPath=$($FIND /lib/modules/$vtKv/kernel/ -name "*.ko*" | $HEAD -n1)
fi
vtModName=$($BUSYBOX_PATH/basename $vtModPath)
vtlog "template module is $vtModPath $vtModName"
if echo $vtModPath | $GREP -q "[.]ko$"; then
$BUSYBOX_PATH/cp -a $vtModPath $VTOY_PATH/$vtModName
elif echo $vtModPath | $GREP -q "[.]ko[.]xz$"; then
$BUSYBOX_PATH/xzcat $vtModPath > $VTOY_PATH/$vtModName
elif echo $vtModPath | $GREP -q "[.]ko[.]gz$"; then
$BUSYBOX_PATH/zcat $vtModPath > $VTOY_PATH/$vtModName
else
vtlog "unsupport module type"
return
fi
#step1: modify vermagic/mod crc/relocation
$VTOY_PATH/tool/vtoykmod -u $VTOY_PATH/tool/$vtKoName $VTOY_PATH/$vtModName $vtDebug
#step2: fill parameters
vtPgsize=$($VTOY_PATH/tool/vtoyksym -p)
$VTOY_PATH/tool/vtoykmod -f $VTOY_PATH/tool/$vtKoName $vtPgsize 0x$printk_addr 0x$ro_addr 0x$rw_addr $get_addr $get_size $put_addr $put_size 0x$kprobe_reg_addr 0x$kprobe_unreg_addr $vtDebug
$BUSYBOX_PATH/insmod $VTOY_PATH/tool/$vtKoName
if $GREP -q 'dm_patch' /proc/modules; then
echo "done" > $VTOY_PATH/dm_patch_done
fi
}
create_ventoy_device_mapper() {
vtlog "create_ventoy_device_mapper $*"
@@ -230,19 +360,36 @@ create_ventoy_device_mapper() {
fi
vtlog "dmsetup avaliable in system $VT_DM_BIN"
if ventoy_check_dm_module "$1"; then
vtlog "device-mapper module check success"
else
vterr "Error: no dm module avaliable"
fi
$VTOY_PATH/tool/vtoydm -p -f $VTOY_PATH/ventoy_image_map -d $1 > $VTOY_PATH/ventoy_dm_table
$VTOY_PATH/tool/vtoydm -p -f $VTOY_PATH/ventoy_image_map -d $1 > $VTOY_PATH/ventoy_dm_table
vtLevel1=$($CAT /proc/sys/kernel/printk | $AWK '{print $1}')
vtLevel2=$($CAT /proc/sys/kernel/printk | $AWK '{print $2}')
vtLevel3=$($CAT /proc/sys/kernel/printk | $AWK '{print $3}')
vtLevel4=$($CAT /proc/sys/kernel/printk | $AWK '{print $4}')
if ventoy_need_dm_patch; then
ventoy_dm_patch
#suppress printk message
echo 0 $vtLevel2 0 $vtLevel4 > /proc/sys/kernel/printk
fi
if [ -z "$2" ]; then
$VT_DM_BIN create ventoy $VTOY_PATH/ventoy_dm_table >>$VTLOG 2>&1
else
$VT_DM_BIN "$2" create ventoy $VTOY_PATH/ventoy_dm_table >>$VTLOG 2>&1
fi
fi
if ventoy_need_dm_patch; then
#recover printk level
echo $vtLevel1 $vtLevel2 $vtLevel3 $vtLevel4 > /proc/sys/kernel/printk
fi
}
create_persistent_device_mapper() {
@@ -262,8 +409,24 @@ create_persistent_device_mapper() {
vterr "Error: no dm module avaliable"
fi
$VTOY_PATH/tool/vtoydm -p -f $VTOY_PATH/ventoy_persistent_map -d $1 > $VTOY_PATH/persistent_dm_table
$VTOY_PATH/tool/vtoydm -p -f $VTOY_PATH/ventoy_persistent_map -d $1 > $VTOY_PATH/persistent_dm_table
vtLevel1=$($CAT /proc/sys/kernel/printk | $AWK '{print $1}')
vtLevel2=$($CAT /proc/sys/kernel/printk | $AWK '{print $2}')
vtLevel3=$($CAT /proc/sys/kernel/printk | $AWK '{print $3}')
vtLevel4=$($CAT /proc/sys/kernel/printk | $AWK '{print $4}')
if [ -f $VTOY_PATH/dm_patch_done ]; then
#suppress printk message
echo 0 $vtLevel2 0 $vtLevel4 > /proc/sys/kernel/printk
fi
$VT_DM_BIN create vtoy_persistent $VTOY_PATH/persistent_dm_table >>$VTLOG 2>&1
if [ -f $VTOY_PATH/dm_patch_done ]; then
#recover printk level
echo $vtLevel1 $vtLevel2 $vtLevel3 $vtLevel4 > /proc/sys/kernel/printk
fi
}
@@ -493,6 +656,22 @@ ventoy_create_persistent_link() {
fi
}
ventoy_partname_to_diskname() {
if echo $1 | $EGREP -q "nvme.*p[0-9]$|mmc.*p[0-9]$|nbd.*p[0-9]$"; then
echo -n "${1:0:-2}"
else
echo -n "${1:0:-1}"
fi
}
ventoy_diskname_to_partname() {
if echo $1 | $EGREP -q "nvme.*p[0-9]$|mmc.*p[0-9]$|nbd.*p[0-9]$"; then
echo -n "${1}p$2"
else
echo -n "${1}$2"
fi
}
ventoy_udev_disk_common_hook() {
if echo $1 | $EGREP -q "nvme.*p[0-9]$|mmc.*p[0-9]$|nbd.*p[0-9]$"; then
VTDISK="${1:0:-2}"
@@ -541,6 +720,10 @@ ventoy_udev_disk_common_hook() {
create_persistent_device_mapper "/dev/$VTDISK"
ventoy_create_persistent_link
fi
if $GREP -q 'dm_patch' /proc/modules; then
$BUSYBOX_PATH/rmmod dm_patch
fi
}
ventoy_create_dev_ventoy_part() {
@@ -550,6 +733,15 @@ ventoy_create_dev_ventoy_part() {
if [ -e /vtoy_dm_table ]; then
vtPartid=1
vtLevel1=$($CAT /proc/sys/kernel/printk | $AWK '{print $1}')
vtLevel2=$($CAT /proc/sys/kernel/printk | $AWK '{print $2}')
vtLevel3=$($CAT /proc/sys/kernel/printk | $AWK '{print $3}')
vtLevel4=$($CAT /proc/sys/kernel/printk | $AWK '{print $4}')
if [ -f $VTOY_PATH/dm_patch_done ]; then
#suppress printk message
echo 0 $vtLevel2 0 $vtLevel4 > /proc/sys/kernel/printk
fi
$CAT /vtoy_dm_table | while read vtline; do
echo $vtline > /ventoy/dm_table_part${vtPartid}
$VTOY_PATH/tool/dmsetup create ventoy${vtPartid} /ventoy/dm_table_part${vtPartid}
@@ -558,7 +750,12 @@ ventoy_create_dev_ventoy_part() {
$BUSYBOX_PATH/mknod -m 0666 /dev/ventoy${vtPartid} b $blkdev_num
vtPartid=$(expr $vtPartid + 1)
done
done
if [ -f $VTOY_PATH/dm_patch_done ]; then
#recover printk level
echo $vtLevel1 $vtLevel2 $vtLevel3 $vtLevel4 > /proc/sys/kernel/printk
fi
fi
}

View File

@@ -0,0 +1,47 @@
#!/ventoy/busybox/sh
#************************************************************************************
# Copyright (c) 2020, longpanda <admin@ventoy.net>
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation; either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, see <http://www.gnu.org/licenses/>.
#
#************************************************************************************
. /ventoy/hook/ventoy-hook-lib.sh
if is_ventoy_hook_finished; then
exit 0
fi
vtlog "####### $0 $* ########"
VTPATH_OLD=$PATH; PATH=$BUSYBOX_PATH:$VTOY_PATH/tool:$PATH
wait_for_usb_disk_ready
vtdiskname=$(get_ventoy_disk_name)
if [ "$vtdiskname" = "unknown" ]; then
vtlog "ventoy disk not found"
PATH=$VTPATH_OLD
exit 0
fi
ventoy_udev_disk_common_hook "${vtdiskname#/dev/}2" "noreplace"
ventoy_create_dev_ventoy_part
ln -s "../../ventoy1" /dev/disk/by-label/ESYSRESCUE
PATH=$VTPATH_OLD
set_ventoy_hook_finish

View File

@@ -0,0 +1,26 @@
#!/ventoy/busybox/sh
#************************************************************************************
# Copyright (c) 2020, longpanda <admin@ventoy.net>
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation; either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, see <http://www.gnu.org/licenses/>.
#
#************************************************************************************
. $VTOY_PATH/hook/ventoy-os-lib.sh
$SED "/maybe_break premount/i\ $BUSYBOX_PATH/sh $VTOY_PATH/loop/esysrescue/ventoy-disk.sh" -i /init
if [ -f /scripts/casper-bottom/09format_esr_data_partition ]; then
$SED '/mkfs.vfat.*edev.3/icp -a /dev/dm-3 /dev/ventoy3' -i /scripts/casper-bottom/09format_esr_data_partition
fi

Binary file not shown.

View File

@@ -1,4 +1,4 @@
#!/bin/sh
#!/bin/bash
size=1024
fstype=ext4
@@ -7,13 +7,14 @@ config=''
outputfile=persistence.dat
print_usage() {
echo 'Usage: CreatePersistentImg.sh [ -s size ] [ -t fstype ] [ -l LABEL ] [ -c CFG ]'
echo 'Usage: sudo ./CreatePersistentImg.sh [ -s size ] [ -t fstype ] [ -l LABEL ] [ -c CFG ] [ -e ]'
echo ' OPTION: (optional)'
echo ' -s size in MB, default is 1024'
echo ' -t filesystem type, default is ext4 ext2/ext3/ext4/xfs are supported now'
echo ' -l label, default is casper-rw'
echo ' -c configfile name inside the persistence file. File content is "/ union"'
echo ' -o outputfile name, default is persistence.dat'
echo ' -e enable encryption, disabled by default (only few distros support this)'
echo ''
}
@@ -33,6 +34,9 @@ while [ -n "$1" ]; do
elif [ "$1" = "-o" ]; then
shift
outputfile=$1
elif [ "$1" = "-e" ]; then
read -s -p "Encryption passphrase: " passphrase
echo
elif [ "$1" = "-h" ] || [ "$1" = "--help" ]; then
print_usage
exit 0
@@ -86,6 +90,13 @@ freeloop=$(losetup -f)
losetup $freeloop "$outputfile"
if [ ! -z "$passphrase" ]; then
printf "$passphrase" | cryptsetup -q --verbose luksFormat $freeloop -
printf "$passphrase" | cryptsetup -q --verbose luksOpen $freeloop persist_decrypted -
_freeloop=$freeloop
freeloop="/dev/mapper/persist_decrypted"
fi
mkfs -t $fstype $fsopt -L $label $freeloop
sync
@@ -104,4 +115,9 @@ if [ -n "$config" ]; then
rm -rf ./persist_tmp_mnt
fi
if [ ! -z "$passphrase" ]; then
cryptsetup luksClose $freeloop
freeloop=$_freeloop
fi
losetup -d $freeloop

12
INSTALL/FOR_X64_ARM.txt Normal file
View File

@@ -0,0 +1,12 @@
============ Ventoy2Disk.exe for x86_64/ARM/ARM64 =================
Ventoy2Disk.exe is a x86_32 application and supports both 32-bit and 64-bit Windows PC with intel/amd processor.
Since 1.0.58, Ventoy also provides Ventoy2Disk_X64.exe/Ventoy2Disk_ARM.exe/Ventoy2Disk_ARM64.exe you can use them if needed.
These exe files are in altexe directory of the installation package.
You must copy them to the upper directory to use them. (The same location with Ventoy2Disk.exe)
============ x86_64/ARM/ARM64 版本 Ventoy2Disk.exe =================
默认的 Ventoy2Disk.exe 是32位x86程序同时支持最常见的32位和64位Windows系统绝大部分情况下使用它就可以。
从1.0.58版本开始Ventoy还同时提供了 Ventoy2Disk_X64.exe/Ventoy2Disk_ARM.exe/Ventoy2Disk_ARM64.exe 可以根据需要使用。
这些文件位于安装包内的altexe目录下使用时需要将其拷贝到上一层目录即和 Ventoy2Disk.exe 同一位置)。

View File

@@ -22,6 +22,11 @@ Please refer https://www.ventoy.net/en/doc_start.html for details.
2. open your browser and visit http://127.0.0.1:24680
========== VentoyPlugson.sh ===============
1. sudo sh VentoyPlugson.sh
2. open your browser and visit http://127.0.0.1:24681
========= VentoyGUI ===================
VentoyGUI is native GUI program for Linux (GTK/QT)
1. Just double-click the file (e.g. VentoyGUI.x86_64)

Binary file not shown.

View File

@@ -46,23 +46,25 @@ echo "############# Ventoy2Disk $* [$TOOLDIR] ################" >> ./log.txt
date >> ./log.txt
#decompress tool
if [ -f ./tool/$TOOLDIR/ash ]; then
echo "no need to decompress tools" >> ./log.txt
else
cd ./tool/$TOOLDIR
echo "decompress tools" >> ./log.txt
cd ./tool/$TOOLDIR
ls *.xz > /dev/null 2>&1
if [ $? -eq 0 ]; then
[ -f ./xzcat ] && chmod +x ./xzcat
for file in $(ls *.xz); do
echo "decompress $file" >> ./log.txt
xzcat $file > ${file%.xz}
[ -f ./${file%.xz} ] && chmod +x ./${file%.xz}
[ -f ./$file ] && rm -f ./$file
done
cd ../../
chmod +x -R ./tool/$TOOLDIR
fi
cd ../../
chmod +x -R ./tool/$TOOLDIR
if [ -f /bin/bash ]; then
/bin/bash ./tool/VentoyWorker.sh $*
else

BIN
INSTALL/Ventoy2Disk_ARM.exe Normal file

Binary file not shown.

Binary file not shown.

BIN
INSTALL/Ventoy2Disk_X64.exe Normal file

Binary file not shown.

218
INSTALL/VentoyPlugson.sh Normal file
View File

@@ -0,0 +1,218 @@
#!/bin/sh
. ./tool/ventoy_lib.sh
print_usage() {
echo 'Usage: sudo sh VentoyPlugson.sh [OPTION] /dev/sdX'
echo ' OPTION: (optional)'
echo ' -H x.x.x.x http server IP address (default is 127.0.0.1)'
echo ' -P PORT http server PORT (default is 24681)'
echo ' -h print this help'
echo ''
}
uid=$(id -u)
if [ $uid -ne 0 ]; then
echo "Please use sudo or run the script as root."
exit 1
fi
OLDDIR=$(pwd)
machine=$(uname -m)
if echo $machine | egrep -q 'aarch64|arm64'; then
TOOLDIR=aarch64
elif echo $machine | egrep -q 'x86_64|amd64'; then
TOOLDIR=x86_64
elif echo $machine | egrep -q 'mips64'; then
TOOLDIR=mips64el
elif echo $machine | egrep -q 'i[3-6]86'; then
TOOLDIR=i386
else
echo "Unsupported machine type $machine"
exit 1
fi
if ! [ -f "$OLDDIR/tool/plugson.tar.xz" ]; then
echo "Please run under the correct directory!"
exit 1
fi
echo "############# VentoyPlugson $* [$TOOLDIR] ################" >> ./VentoyPlugson.log
date >> ./VentoyPlugson.log
echo "decompress tools" >> ./VentoyPlugson.log
cd ./tool/$TOOLDIR
ls *.xz > /dev/null 2>&1
if [ $? -eq 0 ]; then
[ -f ./xzcat ] && chmod +x ./xzcat
for file in $(ls *.xz); do
echo "decompress $file" >> ./VentoyPlugson.log
xzcat $file > ${file%.xz}
[ -f ./${file%.xz} ] && chmod +x ./${file%.xz}
[ -f ./$file ] && rm -f ./$file
done
fi
cd ../../
chmod +x -R ./tool/$TOOLDIR
if ! [ -f "$OLDDIR/tool/$TOOLDIR/Plugson" ]; then
echo "$OLDDIR/tool/$TOOLDIR/Plugson does not exist!"
exit 1
fi
PATH=./tool/$TOOLDIR:$PATH
HOST="127.0.0.1"
PORT=24681
while [ -n "$1" ]; do
if [ "$1" = "-h" ] || [ "$1" = "--help" ]; then
print_usage
exit 0
elif [ "$1" = "-H" ]; then
shift
if echo $1 | grep -q '[0-9]*\.[0-9]*\.[0-9]*\.[0-9]*'; then
HOST="$1"
else
echo "Invalid host $1"
exit 1
fi
elif [ "$1" = "-P" ]; then
shift
if [ $1 -gt 0 -a $1 -le 65535 ]; then
PORT="$1"
else
echo "Invalid port $1"
exit 1
fi
else
DISK=$1
fi
shift
done
if [ -z "$DISK" ]; then
print_usage
exit 0
fi
if ps -ef | grep "tool/$TOOLDIR/Plugson.*$HOST.*$PORT" | grep -q -v grep; then
echo "Another ventoy server is running now, please close it first."
exit 1
fi
if echo $DISK | grep -q "[a-z]d[a-z][1-9]"; then
DISK=${DISK:0:-1}
fi
if echo $DISK | egrep -q "/dev/nvme|/dev/mmcblk/dev/nbd"; then
if echo $DISK | grep -q "p[1-9]$"; then
DISK=${DISK:0:-2}
fi
fi
if [ ! -b "$DISK" ]; then
echo "$DISK does NOT exist."
exit 1
fi
version=$(get_disk_ventoy_version $DISK)
if [ $? -eq 0 ]; then
echo "Ventoy version in Disk: $version"
vtPart1Type=$(dd if=$DISK bs=1 count=1 skip=450 status=none | hexdump -n1 -e '1/1 "%02X"')
if [ "$vtPart1Type" = "EE" ]; then
echo "Disk Partition Style : GPT"
partstyle=1
else
echo "Disk Partition Style : MBR"
partstyle=0
fi
if check_disk_secure_boot $DISK; then
echo "Secure Boot Support : YES"
secureboot=1
else
echo "Secure Boot Support : NO"
secureboot=0
fi
else
echo "$DISK is NOT Ventoy disk."
exit 1
fi
PART1=$(get_disk_part_name $DISK 1)
if grep -q "^$PART1 " /proc/mounts; then
mtpnt=$(grep "^$PART1 " /proc/mounts | awk '{print $2}')
fstype=$(grep "^$PART1 " /proc/mounts | awk '{print $3}')
if echo $fstype | grep -q -i 'fuse'; then
if hexdump -C -n 16 $PART1 | grep -q -i "EXFAT"; then
fstype="exFAT"
elif hexdump -C -n 16 $PART1 | grep -q -i "NTFS"; then
fstype="NTFS"
fi
fi
echo "$PART1 is mounted at $mtpnt $fstype"
else
echo "$PART1 is NOT mounted, please mount it first!"
exit 1
fi
if [ -d "$mtpnt/ventoy" ]; then
echo "ventoy directory exist OK"
else
echo "create ventoy directory"
mkdir -p "$mtpnt/ventoy"
if [ -d "$mtpnt/ventoy" ]; then
chmod -R 0755 "$mtpnt/ventoy"
else
echo "Failed to create directory $mtpnt/ventoy"
exit 1
fi
fi
#change current directory to Ventoy disk
cd "$mtpnt"
$OLDDIR/tool/$TOOLDIR/Plugson "$HOST" "$PORT" "$OLDDIR" "$DISK" $version "$fstype" $partstyle $secureboot &
wID=$!
sleep 1
if [ -f /proc/$wID/maps ]; then
echo ""
echo "==============================================================="
if [ "$LANG" = "zh_CN.UTF-8" ]; then
echo " Ventoy Plugson Server 已经启动 ..."
echo " 请打开浏览器,访问 http://${HOST}:${PORT}"
else
echo " Ventoy Plugson Server is running ..."
echo " Please open your browser and visit http://${HOST}:${PORT}"
fi
echo "==============================================================="
echo ""
echo "################## Press Ctrl + C to exit #####################"
echo ""
wait $wID
fi
if [ -n "$OLDDIR" ]; then
CURDIR=$(pwd)
if [ "$CURDIR" != "$OLDDIR" ]; then
cd "$OLDDIR"
fi
fi

View File

@@ -38,13 +38,10 @@ sh buildedk.sh >> $LOG 2>&1 || exit 1
#cd $VTOY_PATH/VtoyTool
#sh build.sh || exit 1
#cd $VTOY_PATH/vtoyfat/fat_io_lib
#cd $VTOY_PATH/vtoycli/fat_io_lib
#sh buildlib.sh
#cd $VTOY_PATH/vtoyfat
#sh build.sh || exit 1
#cd $VTOY_PATH/vtoygpt
#cd $VTOY_PATH/vtoycli
#sh build.sh || exit 1
#cd $VTOY_PATH/FUSEISO

117
INSTALL/grub/checksum.cfg Normal file
View File

@@ -0,0 +1,117 @@
if [ -e "${vtoy_iso_part}${VTOY_CHKSUM_FILE_PATH}.md5" ]; then
set default=0
menuentry "Calculate and check md5sum" --class=checksum_md5 {
md5sum "${vtoy_iso_part}${VTOY_CHKSUM_FILE_PATH}"
vt_1st_line "${vtoy_iso_part}${VTOY_CHKSUM_FILE_PATH}.md5" vtReadChecksum
if vt_str_casebegin "$vtReadChecksum" "$VT_LAST_CHECK_SUM"; then
echo -e "\n\nCheck MD5 value with .md5 file. [ OK ]"
else
echo -e "\n\nCheck MD5 value with .md5 file. [ FAIL ]"
echo "The MD5 value in .md5 file is:"
echo "$vtReadChecksum"
fi
echo -e "\n\npress ENTER to exit ..."
read vtInputKey
}
else
menuentry "Calculate md5sum" --class=checksum_md5 {
md5sum "${vtoy_iso_part}${VTOY_CHKSUM_FILE_PATH}"
echo -e "\n\npress ENTER to exit ..."
read vtInputKey
}
fi
if [ -e "${vtoy_iso_part}${VTOY_CHKSUM_FILE_PATH}.sha1" ]; then
set default=1
menuentry "Calculate and check sha1sum" --class=checksum_sha1 {
sha1sum "${vtoy_iso_part}${VTOY_CHKSUM_FILE_PATH}"
vt_1st_line "${vtoy_iso_part}${VTOY_CHKSUM_FILE_PATH}.sha1" vtReadChecksum
if vt_str_casebegin "$vtReadChecksum" "$VT_LAST_CHECK_SUM"; then
echo -e "\n\nCheck SHA1 value with .sha1 file. [ OK ]"
else
echo -e "\n\nCheck SHA1 value with .sha1 file. [ FAIL ]"
echo "The SHA1 value in .sha1 file is:"
echo "$vtReadChecksum"
fi
echo -e "\n\npress ENTER to exit ..."
read vtInputKey
}
else
menuentry "Calculate sha1sum" --class=checksum_sha1 {
sha1sum "${vtoy_iso_part}${VTOY_CHKSUM_FILE_PATH}"
echo -e "\n\npress ENTER to exit ..."
read vtInputKey
}
fi
if [ -e "${vtoy_iso_part}${VTOY_CHKSUM_FILE_PATH}.sha256" ]; then
set default=2
menuentry "Calculate and check sha256sum" --class=checksum_sha256 {
sha256sum "${vtoy_iso_part}${VTOY_CHKSUM_FILE_PATH}"
vt_1st_line "${vtoy_iso_part}${VTOY_CHKSUM_FILE_PATH}.sha256" vtReadChecksum
if vt_str_casebegin "$vtReadChecksum" "$VT_LAST_CHECK_SUM"; then
echo -e "\n\nCheck SHA256 value with .sha256 file. [ OK ]"
else
echo -e "\n\nCheck SHA256 value with .sha256 file. [ FAIL ]"
echo "The SHA256 value in .sha256 file is:"
echo "$vtReadChecksum"
fi
echo -e "\n\npress ENTER to exit ..."
read vtInputKey
}
else
menuentry "Calculate sha256sum" --class=checksum_sha256 {
sha256sum "${vtoy_iso_part}${VTOY_CHKSUM_FILE_PATH}"
echo -e "\n\npress ENTER to exit ..."
read vtInputKey
}
fi
if [ -e "${vtoy_iso_part}${VTOY_CHKSUM_FILE_PATH}.sha512" ]; then
set default=3
menuentry "Calculate and check sha512sum" --class=checksum_sha512{
sha512sum "${vtoy_iso_part}${VTOY_CHKSUM_FILE_PATH}"
vt_1st_line "${vtoy_iso_part}${VTOY_CHKSUM_FILE_PATH}.sha512" vtReadChecksum
if vt_str_casebegin "$vtReadChecksum" "$VT_LAST_CHECK_SUM"; then
echo -e "\n\nCheck SHA512 value with .sha512 file. [ OK ]"
else
echo -e "\n\nCheck SHA512 value with .sha512 file. [ FAIL ]"
echo "The SHA512 value in .sha512 file is:"
echo "$vtReadChecksum"
fi
echo -e "\n\npress ENTER to exit ..."
read vtInputKey
}
else
menuentry "Calculate sha512sum" --class=checksum_sha512{
sha512sum "${vtoy_iso_part}${VTOY_CHKSUM_FILE_PATH}"
echo -e "\n\npress ENTER to exit ..."
read vtInputKey
}
fi
menuentry 'Return to previous menu [Esc]' --class=vtoyret VTOY_RET {
echo 'Return ...'
}

View File

@@ -38,6 +38,12 @@ submenu "Screen Display Mode" --class=debug_screen_mode --class=F5tool {
}
}
if [ $VTOY_THEME_COUNT -gt 1 ]; then
submenu "Theme Select" --class=debug_theme_select --class=F5tool {
vt_select_theme_cfg
}
fi
if [ "$grub_platform" != "pc" ]; then
submenu 'Ventoy UEFI Utilities' --class=debug_util --class=F5tool {
menuentry 'Show EFI Drivers' --class=debug_util_efidrv --class=debug_util --class=F5tool {

View File

@@ -90,6 +90,28 @@ function ventoy_ext_menu {
fi
}
function ventoy_checksum {
if [ -f "${vtoy_iso_part}${VTOY_CHKSUM_FILE_PATH}" ]; then
configfile $prefix/checksum.cfg
fi
}
function ventoy_show_help {
if [ -f $prefix/help.tar.gz ]; then
if [ -z "$vtoy_help_txt_mem_addr" ]; then
vt_load_file_to_mem "auto" $prefix/help.tar.gz vtoy_help_txt_mem
fi
loopback vt_help_tarfs mem:${vtoy_help_txt_mem_addr}:size:${vtoy_help_txt_mem_size}
if [ -f "(vt_help_tarfs)/help/${VTOY_HELP_TXT_LANGUAGE}.txt" ]; then
cat "(vt_help_tarfs)/help/${VTOY_HELP_TXT_LANGUAGE}.txt"
else
cat "(vt_help_tarfs)/help/en_US.txt"
fi
loopback -d vt_help_tarfs
fi
}
function get_os_type {
set vtoy_os=Linux
@@ -107,6 +129,9 @@ function get_os_type {
elif [ -e (loop)/bin/freebsd-version ]; then
set vtoy_os=Unix
set vt_unix_type=FreeBSD
elif [ -e (loop)/boot/kernel/geom_ventoy.ko ]; then
set vtoy_os=Unix
set vt_unix_type=FreeBSD
elif vt_str_begin "$vt_system_id" "DragonFly"; then
set vtoy_os=Unix
set vt_unix_type=DragonFly
@@ -132,7 +157,7 @@ function vt_check_compatible_pe {
#Check for PE without external tools
#set compatible if ISO file is less than 80MB
if [ $vt_chosen_size -gt 33554432 -a $vt_chosen_size -le 83886080 ]; then
set ventoy_compatible=YES
set ventoy_compatible=YES
fi
return
@@ -141,6 +166,8 @@ function vt_check_compatible_pe {
function vt_check_compatible_linux {
if vt_str_begin "$vt_volume_id" "embootkit"; then
set ventoy_compatible=YES
elif [ -e "$1/casper/tinycore.gz" ]; then
set ventoy_compatible=YES
fi
return
@@ -209,6 +236,8 @@ function distro_specify_initrd_file {
vt_linux_specify_initrd_file /initrd.gz
elif [ -e (loop)/slax/boot/initrfs.img ]; then
vt_linux_specify_initrd_file /slax/boot/initrfs.img
elif [ -e (loop)/minios/boot/initrfs.img ]; then
vt_linux_specify_initrd_file /minios/boot/initrfs.img
elif [ -e (loop)/pmagic/initrd.img ]; then
vt_linux_specify_initrd_file /pmagic/initrd.img
elif [ -e (loop)/boot/initrd.xz ]; then
@@ -223,7 +252,8 @@ function distro_specify_initrd_file {
vt_linux_specify_initrd_file /boot/initramfs-x86_64.img
elif [ -f (loop)/boot/isolinux/initramfs_data64.cpio.gz ]; then
vt_linux_specify_initrd_file /boot/isolinux/initramfs_data64.cpio.gz
elif [ -f (loop)/boot/initrd.img ]; then
vt_linux_specify_initrd_file /boot/initrd.img
fi
@@ -328,6 +358,10 @@ function distro_specify_initrd_file_phase2 {
vt_linux_specify_initrd_file /360Disk/initrd.gz
elif [ -f (loop)/porteus/initrd.xz ]; then
vt_linux_specify_initrd_file /porteus/initrd.xz
elif [ -f (loop)/pyabr/boot/initrfs.img ]; then
vt_linux_specify_initrd_file /pyabr/boot/initrfs.img
elif [ -f (loop)/initrd0.img ]; then
vt_linux_specify_initrd_file /initrd0.img
fi
}
@@ -389,6 +423,11 @@ function ventoy_freebsd_proc {
set vtFreeBsdDistro=FreeBSD
set vt_freebsd_ver=xx
if [ -e (loop)/boot/kernel/geom_ventoy.ko ]; then
vt_unix_ko_fillmap /boot/kernel/geom_ventoy.ko
return
fi
if vt_strstr "$vt_volume_id" "GHOSTBSD"; then
ventoy_get_ghostbsd_ver "$1" "${chosen_path}"
elif vt_strstr "$vt_volume_id" "FREENAS"; then
@@ -684,7 +723,9 @@ function uefi_linux_menu_func {
elif [ -e (loop)/syslinux/alt0/full.cz ]; then
vt_add_replace_file 0 "EFI\\BOOT\\full.cz"
set FirstTryBootFile='@EFI@BOOT@grubx64.efi'
elif vt_str_begin "$vt_volume_id" "SolusLive"; then
vt_add_replace_file 0 "initrd"
fi
@@ -988,14 +1029,13 @@ function legacy_linux_menu_func {
loopback loop "$1$2"
fi
if [ -f (loop)/isolinux/isolinux.cfg ]; then
if vt_iso9660_isjoliet; then
vt_iso9660_nojoliet 1
loopback -d loop
loopback loop "$1$2"
fi
if vt_syslinux_need_nojoliet "$1$2"; then
vt_iso9660_nojoliet 1
loopback -d loop
loopback loop "$1$2"
fi
vt_load_cpio $vtoy_path "$2" "$1" "busybox=$ventoy_busybox_ver"
vt_linux_clear_initrd
@@ -1664,6 +1704,23 @@ function ventoy_img_recalbox {
vt_unset_boot_opt
}
function ventoy_img_esysrescue {
vt_load_cpio $vtoy_path "${vt_chosen_path}" ${vtoy_iso_part} "busybox=$ventoy_busybox_ver"
vt_trailer_cpio ${vtoy_iso_part} "${vt_chosen_path}" noinit
ventoy_debug_pause
#boot image file
vt_set_boot_opt rdinit=/vtoy/vtoy ventoyos=esysrescue
vt_img_hook_root
set root=(vtimghd,1)
configfile (vtimghd,1)/boot/grub/grub.cfg
vt_img_unhook_root
vt_unset_boot_opt
}
function ventoy_img_batocera {
vt_load_cpio $vtoy_path "${vt_chosen_path}" ${vtoy_iso_part} "busybox=$ventoy_busybox_ver"
vt_trailer_cpio ${vtoy_iso_part} "${vt_chosen_path}" noinit
@@ -1916,6 +1973,8 @@ function img_common_menuentry {
ventoy_img_tails
elif [ "$vtImgHd2Label" = "RECALBOX" ]; then
ventoy_img_recalbox
elif [ "$vtImgHd1Label" = "ESYSRESCUE" ]; then
ventoy_img_esysrescue
elif [ -e (vtimghd,1)/easy.sfs ]; then
ventoy_img_easyos
elif [ -e (vtimghd,1)/volumio.initrd ]; then
@@ -1963,7 +2022,7 @@ function img_unsupport_menuentry {
#############################################################
#############################################################
set VENTOY_VERSION="1.0.54"
set VENTOY_VERSION="1.0.64"
#ACPI not compatible with Window7/8, so disable by default
set VTOY_PARAM_NO_ACPI=1
@@ -1983,6 +2042,11 @@ set VTOY_F2_CMD="ventoy_power"
set VTOY_F4_CMD="ventoy_localboot"
set VTOY_F5_CMD="ventoy_diagnosis"
set VTOY_F6_CMD="ventoy_ext_menu"
set VTOY_HELP_CMD="ventoy_show_help"
set VTOY_CHKSUM_CMD="ventoy_checksum"
set VTOY_HELP_TXT_LANGUAGE="en_US"
set VTOY_CHKSUM_FILE_PATH="X"
if [ "$grub_platform" = "pc" ]; then
set VTOY_TEXT_MENU_VER="Ventoy $VENTOY_VERSION BIOS www.ventoy.net"
@@ -2072,10 +2136,10 @@ fi
if [ $VTOY_DEFAULT_MENU_MODE -eq 0 ]; then
set VTOY_F3_CMD="vt_dynamic_menu 1 1"
set VTOY_HOTKEY_TIP="F1:Memdisk F2:Power F3:TreeView F4:Localboot F5:Tools F6:ExMenu"
set VTOY_HOTKEY_TIP="h:Help F1:Memdisk F2:Power F3:TreeView F4:Localboot F5:Tools F6:ExMenu"
else
set VTOY_F3_CMD="vt_dynamic_menu 1 0"
set VTOY_HOTKEY_TIP="F1:Memdisk F2:Power F3:ListView F4:Localboot F5:Tools F6:ExMenu"
set VTOY_HOTKEY_TIP="h:Help F1:Memdisk F2:Power F3:ListView F4:Localboot F5:Tools F6:ExMenu"
fi
@@ -2126,12 +2190,19 @@ fi
if [ -n "$VTOY_PLUGIN_SYNTAX_ERROR" ]; then
clear
echo -e "\n Syntax error detected in ventoy.json, please check! \n"
echo -e " ventoy.json 文件中有语法错误,所有配置都不会生效,请检查!\n"
if [ -n "$VTOY_PLUGIN_ENCODE_ERROR" ]; then
echo -e "\n Encoding type for ventoy.json is not supported, please convert to UTF-8.\n"
echo -e " ventoy.json 文件编码格式不支持,请转换为 UTF-8 编码格式!\n"
else
echo -e "\n Syntax error detected in ventoy.json, please check! \n"
echo -e " ventoy.json 文件中有语法错误,所有配置都不会生效,请检查!\n"
fi
echo -e "\n press ENTER to continue (请按 回车 键继续) ..."
read vtInputKey
read vtInputKey
fi
for vtTFile in ventoy.json ventoy_grub.cfg; do
if [ -f $vtoy_efi_part/ventoy/$vtTFile ]; then
clear
@@ -2163,6 +2234,14 @@ export VTOY_ISO_RAW_STR
export VTOY_GRUB2_MODE_STR
export VTOY_WIMBOOT_MODE_STR
export VTOY_ISO_UEFI_DRV_STR
export VTOY_F2_CMD
export VTOY_F4_CMD
export VTOY_F5_CMD
export VTOY_F6_CMD
export VTOY_HELP_CMD
export VTOY_CHKSUM_CMD
export VTOY_HELP_TXT_LANGUAGE
export VTOY_CHKSUM_FILE_PATH
#special VTOY_DEFAULT_IMAGE process

View File

@@ -0,0 +1,18 @@
h - Zeigt dieses Hilfe Menu
F1 - Memdisk Modus (Nur für kleine WinPE/LiveCD ISO/IMG)
F2 - Neustarten/Herunterfahren
F3 - Menu wechsel zwischen Baum <-> Listen Ansicht
F4 - Windows/Linux vom lokalem Datenträger starten
F5 - Dienstprogramme
F6 - Benutzerdefiniertes Grub2-Menü laden
F7 - Wechseln zwischen GUI-Modus <-> TEXT-Modus
m - Prüfsummencheck Image Dateien (md5/sha1/sha256/sha512)
Ctrl+w - WIMBOOT Modus (Nur für Standard Windows ISO)
Ctrl+r - Grub2 Modus (Nur für einige Linux distros)
Ctrl+i - Kompatibilitäts Modus (Nur für Fehleranalyse)
Ctrl+u - Lade ISO efi Treiber (Nur für Fehleranalyse, darf nicht offiziel benutzt werden)
Drücke ESC für Zurück ......

View File

@@ -0,0 +1,18 @@
h - Display this help information
F1 - Memdisk Mode (Only for small WinPE/LiveCD ISO/IMG)
F2 - Reboot/Power off
F3 - Switch menu mode between Treeview <-> ListView
F4 - Boot Windows/Linux in local disk
F5 - Utilities
F6 - Load Custom Grub2 Menu
F7 - Switch between GUI Mode <-> TEXT Mode
m - Checksum image files (md5/sha1/sha256/sha512)
Ctrl+w - WIMBOOT Mode (Only for standard Windows ISO)
Ctrl+r - Grub2 Mode (Only for some Linux distros)
Ctrl+i - Compatible Mode (Just only for debug)
Ctrl+u - Load ISO efi driver (Just only for debug, can not be used officially)
Press ESC to return ......

View File

@@ -0,0 +1,16 @@
h - Afficher cette aide
F1 - Mode Memdisk (Seulement pour WinPE/LiveCD ISO/IMG)
F2 - Redémarrer/arrêter
F3 - Basculer l'affichage 'Vue en arbre' <-> 'Vue en liste'
F4 - Démarrer le système Windows/Linux local
F5 - Utilitaires
F6 - Charger le menu Grub2 personnalisé
F7 - Basculer entre le mode graphique <-> mode texte
m - Somme de contrôle des images (md5/sha1/sha256/sha512)
Ctrl+w - Mode WIMBOOT (seulement pour les images standards Windows)
Ctrl+r - Mode Grub2 (seulement pour quelques Linux)
Ctrl+i - Mode Compatible (seulement à fins de tests)
Ctrl+u - Load ISO efi driver (Just only for debug, can not be used officially)
Appuyer sur Echap pour sortir ......

View File

@@ -0,0 +1,17 @@
h - Prikazuje ove informacije
F1 - Memdisk način rada (samo za male WinPE/LiveCD imidž fajlove)
F2 - Ponovno pokretanje/isključivanje
F3 - Mijenja meni između TreeView <-> ListView
F4 - Pokreće Windows/Linux na lokalnom disku
F5 - Postavke
F6 - Učitava prilagođen GRUB2 meni
F7 - Mijenja između GUI načina rada <-> TEXT načina rada
m - Generira kontrolnu sumu odabranog imidž fajla (md5/sha1/sha256/sha512)
Ctrl + w - WIMBOOT način rada (samo za standardne Windows imidž fajlove)
Ctrl + r - GRUB2 način rada (samo za neke Linux distribucije)
Ctrl + i - Kompatibilni način rada (samo za testiranje)
Ctrl + u - Load ISO efi driver (Just only for debug, can not be used officially)
Pritisnite ESC za povratak...

View File

@@ -0,0 +1,18 @@
h - Tampilkan bantuan informasi ini
F1 - Mode Memdisk (Hanya untuk ukuran WinPE/LiveCD ISO/IMG yang kecil)
F2 - Mulai ulang/Matikan
F3 - Beralih mode menu antara Treeview <-> ListView
F4 - Jalankan (boot) Windows/Linux pada disk lokal
F5 - Alat Utilitas
F6 - Memuat ubah suai Grub2 Menu
F7 - Beralih antara mode GUI <-> Mode TEXT
m - Periksa berkas files (md5/sha1/sha256/sha512)
Ctrl+w - Mode WIMBOOT (Hanya untuk berkas ISO Windows standar)
Ctrl+r - Mode Grub2 (Hanya untuk distro Linux tertentu)
Ctrl+i - Mode Kompatibel/Compatible (Hanya untuk debug saja)
Ctrl+u - Memuat ISO efi driver (Hanya untuk debug saja, tidak dapat dipakai secara umum)
Tekan ESC untuk kembali ......

View File

@@ -0,0 +1,18 @@
h - この画面を表示する
F1 - 主記憶装置上に記憶域を作成する容量の小さなWinPE・LiveCD専用
F2 - 再起動・電源断
F3 - 表示形式を切り替える(一覧 ↔ 階層)
F4 - 手元の記憶装置にあるOSを起動する
F5 - 諸機能
F6 - Grub2の構成を読み込む
F7 - 操作形式を切り替えるGUI ↔ CUI
m - イメージの検査合計を計算する (md5/sha1/sha256/sha512)
Ctrl+w - WIMBOOTモード標準的なWindows ISO専用
Ctrl+r - Grub2モード一部のLinuxディストリビューション専用
Ctrl+i - 互換モード(開発用)
Ctrl+u - ISO efiドライバーを読み取る開発用非公式
この画面を閉じるにはESCを押してください

View File

@@ -0,0 +1,17 @@
h - Mostra esta informação de ajuda
F1 - Modo Memdisk (Apenas para pequenos WinPE/LiveCD ISO/IMG)
F2 - Reiniciar/Desligar
F3 - Alternar o modo menu entre Vista de árvore <-> Vista de lista
F4 - Arrancar o Windows/Linux em disco local
F5 - Utilitários
F6 - Carregar menu Grub2 personalizado
F7 - Alternar entre Modo GUI <-> Modo TEXTO
m - Checksum ficheiros de imagem (md5/sha1/sha256/sha512)
Ctrl+w - Modo WIMBOOT (Apenas para Windows ISO padrão)
Ctrl+r - Modo Grub2 (Apenas para algumas distros Linux)
Ctrl+i - Modo Compatível (Apenas para depuração)
Ctrl+u - Carregar o controlador ISO efi (Apenas para depuração, não pode ser utilizado oficialmente)
Prima ESC para voltar ......

View File

@@ -0,0 +1,17 @@
h - Приказује ове информације
F1 - Memdisk начин рада (само за мале WinPE/LiveCD имиџ фајлове)
F2 - Поновно покретање/искључивање
F3 - Мијења мени између TreeView <-> ListView
F4 - Покреће Windows/Linux на локалном диску
F5 - Поставке
F6 - Учитава прилагођен GRUB2 мени
F7 - Мијења између GUI начина рада <-> TEXT начина рада
m - Генерира контролну суму одабраног имиџ фајла (md5/sha1/sha256/sha512)
Ctrl + w - WIMBOOT начин рада (само за стандардне Windows имиџ фајлове)
Ctrl + r - GRUB2 начин рада (само за неке Linux дистрибуције)
Ctrl + i - Компатибилни начин рада (само за тестиранје)
Ctrl + u - Load ISO efi driver (Just only for debug, can not be used officially)
Притисните ESC за повратак...

View File

@@ -0,0 +1,17 @@
h - Prikazuje ove informacije
F1 - Memdisk način rada (samo za male WinPE/LiveCD imidž fajlove)
F2 - Ponovno pokretanje/isključivanje
F3 - Mijenja meni između TreeView <-> ListView
F4 - Pokreće Windows/Linux na lokalnom disku
F5 - Postavke
F6 - Učitava prilagođen GRUB2 meni
F7 - Mijenja između GUI načina rada <-> TEXT načina rada
m - Generira kontrolnu sumu odabranog imidž fajla (md5/sha1/sha256/sha512)
Ctrl + w - WIMBOOT način rada (samo za standardne Windows imidž fajlove)
Ctrl + r - GRUB2 način rada (samo za neke Linux distribucije)
Ctrl + i - Kompatibilni način rada (samo za testiranje)
Ctrl+u - Load ISO efi driver (Just only for debug, can not be used officially)
Pritisnite ESC za povratak...

View File

@@ -0,0 +1,17 @@
h - Yardım bilgilerini göster
F1 - Memdisk Modu başlatır(Yalnızca küçük WinPE/LiveCD ISO/IMG ler için bu modu kullanabilirsiniz)
F2 - Bilgisayarı Yeniden Başlat/Kapat
F3 - Ventoy Menü modu olarak,Klasör görünümü(Treeview) ile Liste görünümü(ListView) arasında geçiş yapmayı sağlar.
F4 - Bilgisayarınızda yüklü olan Windows yada Linux işletim sistemini, sabit diskten başlatır.
F5 - Ventoy Araçlar menüsü
F6 - Özelleştirilmiş Grub2 menüsünü yükler
F7 - Grafik Modu(GUI Mode) ile Metin Modu(Text Mode) arasında geçiş yapmayı sağlar
m - İndirilen imaj dosyalarının hatasız indirildiğini teyit etmek için "md5/sha1/sha256/sha512" değerlerini kontrol etmeyi sağlar
Ctrl+w - WIMBOOT Modu çalıştırmayı sağlar(Sadece normal Windows ISO ları için)
Ctrl+r - Grub2 Modu çalıştırmayı sağlar (Sadece bazı Linux dağıtımları için)
Ctrl+i - Uyumluluk Modu'nu (Compatible Mode) çalıştırmayı sağlar (Sadece hata ayıklama için bu modu kullanabilirsiniz)
Ctrl+u - ISO efi sürücüsünü yükler(Sadece hata ayıklama için bu mod kullanılabilir, resmi olarak kullanılamaz)
Geriye dönmek için ESC tuşuna basınız......

View File

@@ -0,0 +1,17 @@
h - 显示本帮助信息
F1 - 把文件加载到内存启动(只适用于文件很小的 WinPE/LiveCD等
F2 - 电源操作 (重启、关机)
F3 - 菜单显示模式切换。可在列表模式和目录模式之间自由切换。
F4 - 启动本地硬盘上的 Windows/Linux 等系统。
F5 - 各类工具
F6 - 加载自定义 GRUB2 菜单。
F7 - 界面在文本模式和图形模式之间切换。
m - 计算文件校验值md5/sha1/sha256/sha512
Ctrl+w - WIMBOOT 模式 (只适用于标准的 Windows ISO文件
Ctrl+r - Grub2 模式 (只适用于常见的一些 Linux 系统ISO文件
Ctrl+i - 兼容模式 (只用作调试目的,不能正式使用)
Ctrl+u - 加载 ISO efi 驱动(只用作调试目的,不能正式使用)
按 ESC 键返回 ......

View File

@@ -76,6 +76,11 @@ else
terminal_output console
chainloader /EFI/Microsoft/Boot/bootmgfw.efi
boot
elif [ -f ($vtoydev,$partid)/efi/Microsoft/Boot/bootmgfw.efi ]; then
set root=($vtoydev,$partid)
terminal_output console
chainloader /efi/Microsoft/Boot/bootmgfw.efi
boot
fi
else
break
@@ -87,6 +92,10 @@ else
terminal_output console
chainloader /EFI/Microsoft/Boot/bootmgfw.efi
boot
elif search -n -s -f /efi/Microsoft/Boot/bootmgfw.efi; then
terminal_output console
chainloader /efi/Microsoft/Boot/bootmgfw.efi
boot
else
echo "Windows NOT found ..."
fi

View File

@@ -46,7 +46,7 @@ terminal-box: "terminal_box_*.png"
}
+ hbox{
left = 30%
left = 28%
top = 95%
width = 10%
height = 25

View File

@@ -16,6 +16,7 @@ print_usage() {
echo ' -s/-S enable/disable secure boot support (default is disabled)'
echo ' -g use GPT partition style, default is MBR (only for install)'
echo ' -L Label of the 1st exfat partition (default is Ventoy)'
echo ' -n try non-destructive installation (only for install)'
echo ''
}
@@ -28,6 +29,8 @@ while [ -n "$1" ]; do
elif [ "$1" = "-I" ]; then
MODE="install"
FORCE="Y"
elif [ "$1" = "-n" ]; then
NONDESTRUCTIVE="Y"
elif [ "$1" = "-u" ]; then
MODE="update"
elif [ "$1" = "-l" ]; then
@@ -162,7 +165,7 @@ if [ -d ./tmp_mnt ]; then
fi
if [ "$MODE" = "install" ]; then
if [ "$MODE" = "install" -a -z "$NONDESTRUCTIVE" ]; then
vtdebug "install Ventoy ..."
if [ -n "$VTGPT" ]; then
@@ -255,7 +258,10 @@ if [ "$MODE" = "install" ]; then
exit 1
fi
if ! dd if=/dev/zero of=$DISK bs=1 count=512 status=none conv=fsync; then
# check and umount
check_umount_disk "$DISK"
if ! dd if=/dev/zero of=$DISK bs=64 count=512 status=none conv=fsync; then
vterr "Write data to $DISK failed, please check whether it's in use."
exit 1
fi
@@ -281,10 +287,29 @@ if [ "$MODE" = "install" ]; then
PART1=$(get_disk_part_name $DISK 1)
PART2=$(get_disk_part_name $DISK 2)
mkexfatfs -n "$VTNEW_LABEL" -s $cluster_sectors ${PART1}
#clean part2
dd status=none conv=fsync if=/dev/zero of=$DISK bs=512 count=32 seek=$part2_start_sector
vtinfo "writing data to disk ..."
#format part1
wait_and_create_part ${PART1} ${PART2}
if [ -b ${PART1} ]; then
vtinfo "Format partition 1 ${PART1} ..."
mkexfatfs -n "$VTNEW_LABEL" -s $cluster_sectors ${PART1}
if [ $? -ne 0 ]; then
echo "mkexfatfs failed, now retry..."
mkexfatfs -n "$VTNEW_LABEL" -s $cluster_sectors ${PART1}
if [ $? -ne 0 ]; then
echo "######### mkexfatfs failed, exit ########"
exit 1
fi
else
echo "mkexfatfs success"
fi
else
vterr "${PART1} NOT exist"
fi
vtinfo "writing data to disk ..."
dd status=none conv=fsync if=./boot/boot.img of=$DISK bs=1 count=446
if [ -n "$VTGPT" ]; then
@@ -314,51 +339,181 @@ if [ "$MODE" = "install" ]; then
sync
vtinfo "esp partition processing ..."
sleep 1
check_umount_disk "$DISK"
if [ "$SECUREBOOT" != "YES" ]; then
mkdir ./tmp_mnt
vtdebug "mounting part2 ...."
for tt in 1 2 3 4 5; do
if mount ${PART2} ./tmp_mnt > /dev/null 2>&1; then
vtdebug "mounting part2 success"
break
fi
check_umount_disk "$DISK"
sleep 2
done
rm -f ./tmp_mnt/EFI/BOOT/BOOTX64.EFI
rm -f ./tmp_mnt/EFI/BOOT/grubx64.efi
rm -f ./tmp_mnt/EFI/BOOT/BOOTIA32.EFI
rm -f ./tmp_mnt/EFI/BOOT/grubia32.efi
rm -f ./tmp_mnt/EFI/BOOT/MokManager.efi
rm -f ./tmp_mnt/EFI/BOOT/mmia32.efi
rm -f ./tmp_mnt/ENROLL_THIS_KEY_IN_MOKMANAGER.cer
mv ./tmp_mnt/EFI/BOOT/grubx64_real.efi ./tmp_mnt/EFI/BOOT/BOOTX64.EFI
mv ./tmp_mnt/EFI/BOOT/grubia32_real.efi ./tmp_mnt/EFI/BOOT/BOOTIA32.EFI
sync
for tt in 1 2 3; do
if umount ./tmp_mnt; then
vtdebug "umount part2 success"
rm -rf ./tmp_mnt
break
else
vtdebug "umount part2 failed, now retry..."
sleep 1
fi
done
if [ "$SECUREBOOT" != "YES" ]; then
sleep 2
check_umount_disk "$DISK"
vtoycli partresize -s $DISK $part2_start_sector
fi
echo ""
vtinfo "Install Ventoy to $DISK successfully finished."
echo ""
elif [ "$MODE" = "install" -a -n "$NONDESTRUCTIVE" ]; then
vtdebug "non-destructive install Ventoy ..."
version=$(get_disk_ventoy_version $DISK)
if [ $? -eq 0 ]; then
if [ -z "$FORCE" ]; then
vtwarn "$DISK already contains a Ventoy with version $version."
vtwarn "You can not do and don not need non-destructive installation."
vtwarn ""
exit 1
fi
fi
disk_sector_num=$(cat /sys/block/${DISK#/dev/}/size)
disk_size_gb=$(expr $disk_sector_num / 2097152)
if vtoycli partresize -t $DISK; then
OldStyle="GPT"
else
OldStyle="MBR"
fi
#Print disk info
echo "Disk : $DISK"
parted -s $DISK p 2>&1 | grep Model
echo "Size : $disk_size_gb GB"
echo "Style: $OldStyle"
echo ''
vtwarn "Attention:"
vtwarn "Ventoy will try non-destructive installation on $DISK if possible."
echo ""
read -p 'Continue? (y/n) ' Answer
if [ "$Answer" != "y" ]; then
if [ "$Answer" != "Y" ]; then
exit 0
fi
fi
if [ $disk_sector_num -le $VENTOY_SECTOR_NUM ]; then
vterr "No enough space in disk $DISK"
exit 1
fi
PART1=$(get_disk_part_name $DISK 1)
PART2=$(get_disk_part_name $DISK 2)
#Part1 size in MB aligned with 4KB
PART1_SECTORS=$(cat /sys/class/block/${PART1#/dev/}/size)
PART1_4K=$(expr $PART1_SECTORS / 8)
PART1_MB=$(expr $PART1_4K / 256)
PART1_NEW_MB=$(expr $PART1_MB - 32)
echo "$PART1 is ${PART1_MB}MB"
#check partition layout
echo "check partition layout ..."
vtoycli partresize -c $DISK
vtRet=$?
if [ $vtRet -eq 0 ]; then
exit 1
else
# check and umount
check_umount_disk "$DISK"
sleep 1
check_umount_disk "$DISK"
if [ $vtRet -eq 1 ]; then
echo "Free space enough, start install..."
part2_start_sector=$(expr $PART1_SECTORS + 2048)
elif [ $vtRet -eq 2 ]; then
echo "We need to shrink partition 1 firstly ..."
PART1_BLKID=$(blkid $PART1)
blkid $PART1
if echo $PART1_BLKID | egrep -q -i 'TYPE=ntfs|TYPE=.ntfs'; then
echo "Partition 1 contains NTFS filesystem"
which ntfsresize
if [ $? -ne 0 ]; then
echo "###[FAIL] ntfsresize not found. Please install ntfs-3g package."
exit 1
fi
echo "ntfsfix -b -d $PART1 ..."
ntfsfix -b -d $PART1
echo "ntfsresize --size ${PART1_NEW_MB}Mi $PART1 ..."
ntfsresize -f --size ${PART1_NEW_MB}Mi $PART1
if [ $? -ne 0 ]; then
echo "###[FAIL] ntfsresize failed."
exit 1
fi
elif echo $PART1_BLKID | egrep -q -i 'TYPE=ext[2-4]|TYPE=.ext[2-4]'; then
echo "Partition 1 contains EXT filesystem"
which resize2fs
if [ $? -ne 0 ]; then
echo "###[FAIL] resize2fs not found. Please install e2fsprogs package."
exit 1
fi
echo "e2fsck -f $PART1 ..."
e2fsck -f $PART1
echo "resize2fs $PART1 ${PART1_NEW_MB}M ..."
resize2fs $PART1 ${PART1_NEW_MB}M
if [ $? -ne 0 ]; then
echo "###[FAIL] resize2fs failed."
exit 1
fi
else
echo "###[FAIL] Unsupported filesystem in partition 1."
exit 1
fi
sync
PART1_NEW_END_MB=$(expr $PART1_NEW_MB + 1)
part2_start_sector=$(expr $PART1_NEW_END_MB \* 2048)
fi
fi
vtinfo "writing data to disk part2_start=$part2_start_sector ..."
dd status=none conv=fsync if=./boot/boot.img of=$DISK bs=1 count=440
if [ "$OldStyle" = "GPT" ]; then
echo -en '\x22' | dd status=none of=$DISK conv=fsync bs=1 count=1 seek=92
xzcat ./boot/core.img.xz | dd status=none conv=fsync of=$DISK bs=512 count=2014 seek=34
echo -en '\x23' | dd of=$DISK conv=fsync bs=1 count=1 seek=17908 status=none
else
xzcat ./boot/core.img.xz | dd status=none conv=fsync of=$DISK bs=512 count=2047 seek=1
fi
xzcat ./ventoy/ventoy.disk.img.xz | dd status=none conv=fsync of=$DISK bs=512 count=$VENTOY_SECTOR_NUM seek=$part2_start_sector
#test UUID
testUUIDStr=$(vtoy_gen_uuid | hexdump -C)
vtdebug "test uuid: $testUUIDStr"
#disk uuid
vtoy_gen_uuid | dd status=none conv=fsync of=${DISK} seek=384 bs=1 count=16
vtinfo "sync data ..."
sync
vtinfo "esp partition processing ..."
if [ "$SECUREBOOT" != "YES" ]; then
vtoycli partresize -s $DISK $part2_start_sector
fi
vtinfo "update partition table $DISK $part2_start_sector ..."
vtoycli partresize -p $DISK $part2_start_sector
if [ $? -eq 0 ]; then
sync
echo ""
vtinfo "Ventoy non-destructive installation on $DISK successfully finished."
echo ""
else
echo ""
vterr "Ventoy non-destructive installation on $DISK failed."
echo ""
fi
else
vtdebug "update Ventoy ..."
@@ -441,47 +596,13 @@ else
check_umount_disk "$DISK"
xzcat ./ventoy/ventoy.disk.img.xz | dd status=none conv=fsync of=$DISK bs=512 count=$VENTOY_SECTOR_NUM seek=$part2_start
sync
vtinfo "esp partition processing ..."
if [ "$SECUREBOOT" != "YES" ]; then
mkdir ./tmp_mnt
vtdebug "mounting part2 ...."
for tt in 1 2 3 4 5; do
check_umount_disk "$DISK"
if mount ${PART2} ./tmp_mnt > /dev/null 2>&1; then
vtdebug "mounting part2 success"
break
else
vtdebug "mounting part2 failed, now wait and retry..."
fi
sleep 2
done
rm -f ./tmp_mnt/EFI/BOOT/BOOTX64.EFI
rm -f ./tmp_mnt/EFI/BOOT/grubx64.efi
rm -f ./tmp_mnt/EFI/BOOT/BOOTIA32.EFI
rm -f ./tmp_mnt/EFI/BOOT/grubia32.efi
rm -f ./tmp_mnt/EFI/BOOT/MokManager.efi
rm -f ./tmp_mnt/EFI/BOOT/mmia32.efi
rm -f ./tmp_mnt/ENROLL_THIS_KEY_IN_MOKMANAGER.cer
mv ./tmp_mnt/EFI/BOOT/grubx64_real.efi ./tmp_mnt/EFI/BOOT/BOOTX64.EFI
mv ./tmp_mnt/EFI/BOOT/grubia32_real.efi ./tmp_mnt/EFI/BOOT/BOOTIA32.EFI
sync
for tt in 1 2 3; do
if umount ./tmp_mnt > /dev/null 2>&1; then
vtdebug "umount part2 success"
rm -rf ./tmp_mnt
break
else
vtdebug "umount part2 failed, now retry..."
sleep 1
fi
done
sleep 2
check_umount_disk "$DISK"
vtoycli partresize -s $DISK $part2_start
fi
echo ""

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

BIN
INSTALL/tool/i386/vtoycli Normal file

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@@ -68,10 +68,10 @@ check_tool_work_ok() {
return
fi
if vtoyfat -T; then
vtdebug "vtoyfat test ok ..."
if vtoycli fat -T; then
vtdebug "vtoycli fat test ok ..."
else
vtdebug "vtoyfat test fail ..."
vtdebug "vtoycli fat test fail ..."
ventoy_false
return
fi
@@ -183,7 +183,7 @@ check_disk_secure_boot() {
PART2=$(get_disk_part_name $1 2)
vtoyfat -s $PART2
vtoycli fat -s $PART2
}
get_disk_ventoy_version() {
@@ -195,7 +195,7 @@ get_disk_ventoy_version() {
PART2=$(get_disk_part_name $1 2)
ParseVer=$(vtoyfat $PART2)
ParseVer=$(vtoycli fat $PART2)
if [ $? -eq 0 ]; then
vtdebug "Ventoy version in $PART2 is $ParseVer"
echo $ParseVer
@@ -206,6 +206,48 @@ get_disk_ventoy_version() {
ventoy_false
}
wait_and_create_part() {
vPART1=$1
vPART2=$2
echo 'Wait for partitions ...'
for i in 0 1 2 3 4 5 6 7 8 9; do
if ls -l $vPART1 2>/dev/null | grep -q '^b'; then
if ls -l $vPART2 2>/dev/null | grep -q '^b'; then
break
fi
else
echo "Wait for $vPART1/$vPART2 ..."
sleep 1
fi
done
if ls -l $vPART1 2>/dev/null | grep -q '^b'; then
echo "$vPART1 exist OK"
else
MajorMinor=$(sed "s/:/ /" /sys/class/block/${vPART1#/dev/}/dev)
echo "mknod -m 0660 $vPART1 b $MajorMinor ..."
mknod -m 0660 $vPART1 b $MajorMinor
fi
if ls -l $vPART2 2>/dev/null | grep -q '^b'; then
echo "$vPART2 exist OK"
else
MajorMinor=$(sed "s/:/ /" /sys/class/block/${vPART2#/dev/}/dev)
echo "mknod -m 0660 $vPART2 b $MajorMinor ..."
mknod -m 0660 $vPART2 b $MajorMinor
fi
if ls -l $vPART1 2>/dev/null | grep -q '^b'; then
if ls -l $vPART2 2>/dev/null | grep -q '^b'; then
echo "partition exist OK"
fi
else
echo "[FAIL] $vPART1/$vPART2 does not exist"
exit 1
fi
}
format_ventoy_disk_mbr() {
reserve_mb=$1
DISK=$2
@@ -241,6 +283,11 @@ format_ventoy_disk_mbr() {
vtdebug "part1_start_sector=$part1_start_sector part1_end_sector=$part1_end_sector"
vtdebug "part2_start_sector=$part2_start_sector part2_end_sector=$part2_end_sector"
if [ -e $PART1 ]; then
echo "delete $PART1"
rm -f $PART1
fi
if [ -e $PART2 ]; then
echo "delete $PART2"
rm -f $PART2
@@ -293,27 +340,34 @@ EOF
sleep 3
echo "Done"
echo 'mkfs on disk partitions ...'
for i in 1 2 3 4 5 6 7; do
if [ -b $PART2 ]; then
echo 'Wait for partitions ...'
for i in 0 1 2 3 4 5 6 7 8 9; do
if [ -b $PART1 -a -b $PART2 ]; then
break
else
echo "wait $PART2 ..."
echo "Wait for $PART1/$PART2 ..."
sleep 1
fi
done
if ! [ -b $PART1 ]; then
MajorMinor=$(sed "s/:/ /" /sys/class/block/${PART1#/dev/}/dev)
echo "mknod -m 0660 $PART1 b $MajorMinor ..."
mknod -m 0660 $PART1 b $MajorMinor
fi
if ! [ -b $PART2 ]; then
MajorMinor=$(sed "s/:/ /" /sys/class/block/${PART2#/dev/}/dev)
echo "mknod -m 0660 $PART2 b $MajorMinor ..."
mknod -m 0660 $PART2 b $MajorMinor
if ! [ -b $PART1 ]; then
MajorMinor=$(sed "s/:/ /" /sys/class/block/${PART1#/dev/}/dev)
echo "mknod -m 0660 $PART1 b $MajorMinor ..."
mknod -m 0660 $PART1 b $MajorMinor
fi
mknod -m 0660 $PART2 b $MajorMinor
fi
if [ -b $PART1 -a -b $PART2 ]; then
echo "partition exist OK"
else
echo "[FAIL] $PART1/$PART2 does not exist"
exit 1
fi
echo "create efi fat fs $PART2 ..."
@@ -366,6 +420,11 @@ format_ventoy_disk_gpt() {
vtdebug "part1_start_sector=$part1_start_sector part1_end_sector=$part1_end_sector"
vtdebug "part2_start_sector=$part2_start_sector part2_end_sector=$part2_end_sector"
if [ -e $PART1 ]; then
echo "delete $PART1"
rm -f $PART1
fi
if [ -e $PART2 ]; then
echo "delete $PART2"
rm -f $PART2
@@ -391,7 +450,7 @@ format_ventoy_disk_gpt() {
sync
vtoygpt -f $DISK
vtoycli gpt -f $DISK
sync
udevadm trigger --name-match=$DISK >/dev/null 2>&1
@@ -399,27 +458,33 @@ format_ventoy_disk_gpt() {
sleep 3
echo "Done"
echo 'mkfs on disk partitions ...'
for i in 1 2 3 4 5 6 7; do
if [ -b $PART2 ]; then
echo 'Wait for partitions ...'
for i in 0 1 2 3 4 5 6 7 8 9; do
if [ -b $PART1 -a -b $PART2 ]; then
break
else
echo "wait $PART2 ..."
echo "Wait for $PART1/$PART2 ..."
sleep 1
fi
done
if ! [ -b $PART1 ]; then
MajorMinor=$(sed "s/:/ /" /sys/class/block/${PART1#/dev/}/dev)
echo "mknod -m 0660 $PART1 b $MajorMinor ..."
mknod -m 0660 $PART1 b $MajorMinor
fi
if ! [ -b $PART2 ]; then
MajorMinor=$(sed "s/:/ /" /sys/class/block/${PART2#/dev/}/dev)
echo "mknod -m 0660 $PART2 b $MajorMinor ..."
mknod -m 0660 $PART2 b $MajorMinor
if ! [ -b $PART1 ]; then
MajorMinor=$(sed "s/:/ /" /sys/class/block/${PART1#/dev/}/dev)
echo "mknod -m 0660 $PART1 b $MajorMinor ..."
mknod -m 0660 $PART1 b $MajorMinor
fi
mknod -m 0660 $PART2 b $MajorMinor
fi
if [ -b $PART1 -a -b $PART2 ]; then
echo "partition exist OK"
else
echo "[FAIL] $PART1/$PART2 does not exist"
exit 1
fi
echo "create efi fat fs $PART2 ..."

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

BIN
INSTALL/tool/x86_64/vtoycli Normal file

Binary file not shown.

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