Compare commits

...

41 Commits

Author SHA1 Message Date
longpanda
392d8ef4fa 1.0.71 release 2022-03-11 21:36:42 +08:00
VenusGirl❤
d1900c75cd Create ko_KR.txt (#1462)
Korean Help
2022-03-11 21:25:01 +08:00
fa7e1d5fa0 keep up with 1.0.67 (#1464)
Modify Japanese Translation for Grub Help Text to Keep up with 1.0.67 Release
2022-03-11 21:23:51 +08:00
longpanda
6ae8bf840d Suppress the Fn hotkey when VTOY_DEFAULT_IMAGE is already Fn>xxx 2022-03-08 19:26:04 +08:00
longpanda
ce862da402 1. Fix the bug when booing Easy Recovery Essentional for Windows10.
2. Fix the bug when booting FreeBSD 13.0 by F2 browser mode.
2022-03-08 18:27:07 +08:00
longpanda
6d4f5ff00b Update FUNDING.yml 2022-03-07 00:14:40 +08:00
longpanda
ab0f25d097 Fixe the issue when booting PrimeOS 2.0.1 2022-03-06 21:04:36 +08:00
longpanda
ff14c07c4e Support Easy Recovery Essentials (#1481) 2022-03-06 19:31:18 +08:00
longpanda
f7fac26c91 Auto use memdisk mode for KolibriOS.iso 2022-02-23 23:35:57 +08:00
longpanda
ebae102f41 Fix the issue when set F2> as the default menu item. 2022-02-23 17:05:33 +08:00
longpanda
c3718d6001 Auto use memdisk mode for Memtest86+ iso file. 2022-02-22 22:23:33 +08:00
longpanda
d0744513a6 You can set { "VTOY_DEFAULT_IMAGE": "F2>" } to set F2 browser as the default menu entry. 2022-02-22 20:20:59 +08:00
longpanda
5b0fca8468 1.0.70 release 2022-02-19 10:28:09 +08:00
marcellogianola
27918eb3f9 Update languages.json (#1435) 2022-02-19 10:18:52 +08:00
Tayfun Akkoyun
7859271b20 Update tr_TR.txt (#1452) 2022-02-19 10:18:19 +08:00
longpanda
1c27c0b489 Updated help files (#1460) 2022-02-19 09:51:31 +08:00
longpanda
0f89c2767f Fix the bug when booting Windows 7 iso files in local disk. 2022-02-18 23:47:27 +08:00
longpanda
d1584c10b4 Add tip when save ventoy.json failed. 2022-02-18 09:48:57 +08:00
longpanda
43e921878b Fix a bug when creating multi-mod configuration for img_list in VentoyPlugson. 2022-02-17 20:06:18 +08:00
longpanda
23f4f18e27 Auto use grub2 mode for krd.iso 2022-02-17 12:15:57 +08:00
longpanda
53b95ae17b Support latest Qubes 4.1.0 release. 2022-02-17 11:40:54 +08:00
longpanda
e3506c0f10 Add cmdline check 2022-02-17 11:09:31 +08:00
longpanda
9118d5fe45 Add check for vlnk file suffix in save as 2022-02-17 10:49:56 +08:00
longpanda
f130325a9c Add commad line option -s in VentoyVlnk.exe. 2022-02-17 10:39:04 +08:00
longpanda
1ca48923da VentoyVlnk add cmdline mode.
VentoyVlnk.exe -i xxx.iso -o xxx.vlnk.iso
2022-02-17 10:13:27 +08:00
longpanda
730fdd5198 Update help text 2022-02-16 09:39:36 +08:00
longpanda
d0f3597b26 Fix Kiosk boot issue in latest Ventoy release. (#1446) 2022-02-15 23:59:28 +08:00
longpanda
045f53d768 1.0.69 release 2022-02-15 22:04:50 +08:00
longpanda
a173acaf17 1.0.68 release 2022-02-15 19:17:58 +08:00
longpanda
96fdd594f0 Support to F2 browse Ventoy partition self. 2022-02-15 14:42:46 +08:00
longpanda
62dc0033ad Make VTOY_TREE_VIEW_MENU_STYLE also control the browser menu style. (#1439) 2022-02-15 11:51:32 +08:00
longpanda
1c3fcbdfe9 Skip System Volume Information directory for F2 browser. 2022-02-15 11:39:09 +08:00
longpanda
7d37cab21d 1. F2 browser and vlnk support partitions in Ventoy reserved space (#1434)
2. Speedup browser
2022-02-15 11:31:03 +08:00
longpanda
a1c6fe2d24 1.0.67 release
support to browse and boot files in local disk.
2022-02-14 23:31:54 +08:00
longpanda
dbeb4023a2 Fixed to select the 1st menu item when switching between upper and lower sub-menus. 2022-02-14 14:29:50 +08:00
longpanda
58b1bbe0b5 Fix the issue when booting latest systemrescue 2022-02-14 13:28:26 +08:00
longpanda
86b13727ca Fix the issue when booting latest systemrescue 2022-02-14 12:31:06 +08:00
longpanda
006f26d07d Fix the Plugson web display issue of VTOY_DEFAULT_MENU_MODE. 2022-02-14 12:06:33 +08:00
longpanda
9203aa1ab3 Fix the issue when make vlnk for NTFS partition under Linux (#1430) 2022-02-13 21:25:58 +08:00
longpanda
5291d66736 Merge branch 'master' of https://github.com/ventoy/Ventoy 2022-02-13 17:01:10 +08:00
jakoblell
7f717a7fe9 Support /dev/disk/by-id/ symlinks in command-line installer (#1422)
* Allow symlinks as target device (for supporting /dev/disk/by-id)

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

Co-authored-by: Jakob Lell <jakob@srlabs.com>
2022-02-06 23:13:15 +08:00
69 changed files with 2159 additions and 333 deletions

2
.github/FUNDING.yml vendored
View File

@@ -6,7 +6,7 @@ open_collective: # Replace with a single Open Collective username
ko_fi: # Replace with a single Ko-fi username
tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
liberapay: # Replace with a single Liberapay username
liberapay: Ventoy
issuehunt: # Replace with a single IssueHunt username
otechie: # Replace with a single Otechie username
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.66
placeholder: 1.0.71
validations:
required: true
- type: dropdown

View File

@@ -108,10 +108,10 @@
cd /home/Ventoy-master/VtoyTool
sh build.sh
4.8 == Build vtoyfat ==
cd /home/Ventoy-master/vtoyfat/fat_io_lib
4.8 == Build vtoycli ==
cd /home/Ventoy-master/vtoycli/fat_io_lib
sh buildlib.sh
cd /home/Ventoy-master/vtoyfat
cd /home/Ventoy-master/vtoycli
sh build.sh
4.9 == Build exfat-util ==

View File

@@ -1610,6 +1610,7 @@ module = {
common = ventoy/ventoy_vhd.c;
common = ventoy/ventoy_plugin.c;
common = ventoy/ventoy_json.c;
common = ventoy/ventoy_browser.c;
common = ventoy/lzx.c;
common = ventoy/xpress.c;
common = ventoy/huffman.c;

View File

@@ -114,6 +114,7 @@ typedef struct grub_vlnk
struct grub_vlnk *next;
}grub_vlnk;
static grub_vlnk g_vtoy_vlnk;
static grub_vlnk *g_vlnk_list;
int grub_file_is_vlnk_suffix(const char *name, int len)
@@ -146,6 +147,23 @@ int grub_file_is_vlnk_suffix(const char *name, int len)
return 0;
}
int grub_file_vtoy_vlnk(const char *src, const char *dst)
{
if (src)
{
g_vtoy_vlnk.srclen = (int)grub_strlen(src);
grub_strncpy(g_vtoy_vlnk.src, src, sizeof(g_vtoy_vlnk.src) - 1);
grub_strncpy(g_vtoy_vlnk.dst, dst, sizeof(g_vtoy_vlnk.dst) - 1);
}
else
{
g_vtoy_vlnk.srclen = 0;
g_vtoy_vlnk.src[0] = 0;
g_vtoy_vlnk.dst[0] = 0;
}
return 0;
}
int grub_file_add_vlnk(const char *src, const char *dst)
{
grub_vlnk *node = NULL;
@@ -174,10 +192,17 @@ const char *grub_file_get_vlnk(const char *name, int *vlnk)
grub_vlnk *node = g_vlnk_list;
len = grub_strlen(name);
if (!grub_file_is_vlnk_suffix(name, len))
{
return name;
}
if (len == g_vtoy_vlnk.srclen && grub_strcmp(name, g_vtoy_vlnk.src) == 0)
{
*vlnk = 1;
return g_vtoy_vlnk.dst;
}
while (node)
{
@@ -207,7 +232,7 @@ grub_file_open (const char *name, enum grub_file_type type)
return grub_memfile_open(name);
}
if (g_vlnk_list && (type & GRUB_FILE_TYPE_NO_VLNK) == 0)
if ((g_vlnk_list || g_vtoy_vlnk.srclen) && (type & GRUB_FILE_TYPE_NO_VLNK) == 0)
name = grub_file_get_vlnk(name, &vlnk);
device_name = grub_file_get_device_name (name);

View File

@@ -671,9 +671,7 @@ run_menu (grub_menu_t menu, int nested, int *auto_boot)
if (g_ventoy_suppress_esc)
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;
}
/* If DEFAULT_ENTRY is not within the menu entries, fall back to
the first entry. */
else if (default_entry < 0 || default_entry >= menu->size)

View File

@@ -0,0 +1,607 @@
/******************************************************************************
* ventoy_browser.c
*
* Copyright (c) 2022, longpanda <admin@ventoy.net>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, see <http://www.gnu.org/licenses/>.
*
*/
#include <grub/types.h>
#include <grub/misc.h>
#include <grub/mm.h>
#include <grub/err.h>
#include <grub/dl.h>
#include <grub/disk.h>
#include <grub/device.h>
#include <grub/term.h>
#include <grub/partition.h>
#include <grub/file.h>
#include <grub/normal.h>
#include <grub/extcmd.h>
#include <grub/datetime.h>
#include <grub/i18n.h>
#include <grub/net.h>
#include <grub/time.h>
#include <grub/ventoy.h>
#include "ventoy_def.h"
GRUB_MOD_LICENSE ("GPLv3+");
#define BROWSER_MENU_BUF 65536
static const char *g_vtoy_dev = NULL;
static grub_fs_t g_menu_fs = NULL;
static char *g_menu_device = NULL;
static grub_device_t g_menu_dev = NULL;
static char g_menu_path_buf[1024];
static int g_menu_path_len = 0;
static browser_node *g_browser_list = NULL;
static int ventoy_browser_strcmp(char *str1, char *str2)
{
char *s1, *s2;
int c1 = 0;
int c2 = 0;
for (s1 = str1, s2 = str2; *s1 && *s2; s1++, s2++)
{
c1 = *s1;
c2 = *s2;
if (0 == g_sort_case_sensitive)
{
if (grub_islower(c1))
{
c1 = c1 - 'a' + 'A';
}
if (grub_islower(c2))
{
c2 = c2 - 'a' + 'A';
}
}
if (c1 != c2)
{
break;
}
}
return (c1 - c2);
}
static int ventoy_browser_mbuf_alloc(browser_mbuf *mbuf)
{
grub_memset(mbuf, 0, sizeof(browser_mbuf));
mbuf->buf = grub_malloc(BROWSER_MENU_BUF);
if (!mbuf->buf)
{
return 0;
}
mbuf->pos = 0;
mbuf->max = BROWSER_MENU_BUF;
return 1;
}
static inline void ventoy_browser_mbuf_free(browser_mbuf *mbuf)
{
if (mbuf)
grub_check_free(mbuf->buf)
}
static inline int ventoy_browser_mbuf_extend(browser_mbuf *mbuf)
{
if (mbuf->max - mbuf->pos <= VTOY_SIZE_1KB)
{
mbuf->max += BROWSER_MENU_BUF;
mbuf->buf = grub_realloc(mbuf->buf, mbuf->max);
}
return 0;
}
static browser_node * ventoy_browser_find_top_node(int dir)
{
browser_node *node = NULL;
browser_node *sel = NULL;
for (node = g_browser_list; node; node = node->next)
{
if (node->dir == dir)
{
if (sel)
{
if (ventoy_browser_strcmp(sel->filename, node->filename) > 0)
{
sel = node;
}
}
else
{
sel = node;
}
}
}
return sel;
}
static int ventoy_browser_iterate_partition(struct grub_disk *disk, const grub_partition_t partition, void *data)
{
char partname[64];
char title[256];
grub_device_t dev;
grub_fs_t fs;
char *Label = NULL;
browser_mbuf *mbuf = (browser_mbuf *)data;
(void)data;
if (partition->number == 1 && g_vtoy_dev && grub_strcmp(disk->name, g_vtoy_dev) == 0)
{
return 0;
}
grub_snprintf(partname, sizeof(partname) - 1, "%s,%d", disk->name, partition->number + 1);
dev = grub_device_open(partname);
if (!dev)
{
return 0;
}
fs = grub_fs_probe(dev);
if (!fs)
{
grub_device_close(dev);
return 0;
}
fs->fs_label(dev, &Label);
if (g_tree_view_menu_style == 0)
{
grub_snprintf(title, sizeof(title), "%-10s (%s,%s%d) [%s] %s %s",
"DISK", disk->name, partition->msdostype == 0xee ? "gpt" : "msdos",
partition->number + 1, (Label ? Label : ""), fs->name,
grub_get_human_size(partition->len << disk->log_sector_size, GRUB_HUMAN_SIZE_SHORT));
}
else
{
grub_snprintf(title, sizeof(title), "(%s,%s%d) [%s] %s %s",
disk->name, partition->msdostype == 0xee ? "gpt" : "msdos",
partition->number + 1, (Label ? Label : ""), fs->name,
grub_get_human_size(partition->len << disk->log_sector_size, GRUB_HUMAN_SIZE_SHORT));
}
if (ventoy_get_fs_type(fs->name) >= ventoy_fs_max)
{
browser_ssprintf(mbuf, "menuentry \"%s\" --class=vtoydisk {\n"
" echo \"unsupported file system type!\" \n"
" ventoy_pause\n"
"}\n",
title);
}
else
{
browser_ssprintf(mbuf, "menuentry \"%s\" --class=vtoydisk {\n"
" vt_browser_dir %s,%d 0x%lx /\n"
"}\n",
title, disk->name, partition->number + 1, (ulong)fs);
}
ventoy_browser_mbuf_extend(mbuf);
return 0;
}
static int ventoy_browser_iterate_disk(const char *name, void *data)
{
grub_disk_t disk;
if (name[0] != 'h')
{
return 0;
}
disk = grub_disk_open(name);
if (disk)
{
grub_partition_iterate(disk, ventoy_browser_iterate_partition, data);
grub_disk_close(disk);
}
return 0;
}
static int ventoy_browser_valid_dirname(const char *name, int len)
{
if ((len == 1 && name[0] == '.') ||
(len == 2 && name[0] == '.' && name[1] == '.'))
{
return 0;
}
if (!ventoy_img_name_valid(name, len))
{
return 0;
}
if (name[0] == '$')
{
if (0 == grub_strncmp(name, "$RECYCLE.BIN", 12) ||
0 == grub_strncasecmp(name, "$Extend", 7))
{
return 0;
}
}
if (len == 25 && grub_strncmp(name, "System Volume Information", 25) == 0)
{
return 0;
}
return 1;
}
static int ventoy_browser_valid_filename(const char *filename, int len, int *type)
{
if (len < 4)
{
return 0;
}
if (FILE_FLT(ISO) && 0 == grub_strcasecmp(filename + len - 4, ".iso"))
{
*type = img_type_iso;
}
else if (FILE_FLT(WIM) && g_wimboot_enable && (0 == grub_strcasecmp(filename + len - 4, ".wim")))
{
*type = img_type_wim;
}
else if (FILE_FLT(VHD) && g_vhdboot_enable && (0 == grub_strcasecmp(filename + len - 4, ".vhd") ||
(len >= 5 && 0 == grub_strcasecmp(filename + len - 5, ".vhdx"))))
{
*type = img_type_vhd;
}
#ifdef GRUB_MACHINE_EFI
else if (FILE_FLT(EFI) && 0 == grub_strcasecmp(filename + len - 4, ".efi"))
{
*type = img_type_efi;
}
#endif
else if (FILE_FLT(IMG) && 0 == grub_strcasecmp(filename + len - 4, ".img"))
{
if (len == 18 && grub_strncmp(filename, "ventoy_", 7) == 0)
{
if (grub_strncmp(filename + 7, "wimboot", 7) == 0 ||
grub_strncmp(filename + 7, "vhdboot", 7) == 0)
{
return 0;
}
}
*type = img_type_img;
}
else if (FILE_FLT(VTOY) && len >= 5 && 0 == grub_strcasecmp(filename + len - 5, ".vtoy"))
{
*type = img_type_vtoy;
}
else
{
return 0;
}
if (g_filt_dot_underscore_file && filename[0] == '.' && filename[1] == '_')
{
return 0;
}
return 1;
}
static int ventoy_browser_iterate_dir(const char *filename, const struct grub_dirhook_info *info, void *data)
{
int type;
int len;
browser_node *node;
(void)data;
len = grub_strlen(filename);
if (info->dir)
{
if (!ventoy_browser_valid_dirname(filename, len))
{
return 0;
}
node = grub_zalloc(sizeof(browser_node));
if (!node)
{
return 0;
}
node->dir = 1;
grub_strncpy(node->filename, filename, sizeof(node->filename));
if (g_tree_view_menu_style == 0)
{
grub_snprintf(node->menuentry, sizeof(node->menuentry),
"menuentry \"%-10s [%s]\" --class=vtoydir {\n"
" vt_browser_dir %s 0x%lx \"%s/%s\"\n"
"}\n",
"DIR", filename, g_menu_device, (ulong)g_menu_fs, g_menu_path_buf, filename);
}
else
{
grub_snprintf(node->menuentry, sizeof(node->menuentry),
"menuentry \"[%s]\" --class=vtoydir {\n"
" vt_browser_dir %s 0x%lx \"%s/%s\"\n"
"}\n",
filename, g_menu_device, (ulong)g_menu_fs, g_menu_path_buf, filename);
}
}
else
{
grub_uint64_t fsize = info->size;
if (!ventoy_browser_valid_filename(filename, len, &type))
{
return 0;
}
node = grub_zalloc(sizeof(browser_node));
if (!node)
{
return 0;
}
if (fsize == 0)
{
struct grub_file file;
grub_memset(&file, 0, sizeof(file));
file.device = g_menu_dev;
grub_snprintf(node->menuentry, sizeof(node->menuentry), "%s/%s", g_menu_path_buf, filename);
if (g_menu_fs->fs_open(&file, node->menuentry) == GRUB_ERR_NONE)
{
fsize = file.size;
g_menu_fs->fs_close(&file);
}
}
node->dir = 0;
grub_strncpy(node->filename, filename, sizeof(node->filename));
if (g_tree_view_menu_style == 0)
{
grub_snprintf(node->menuentry, sizeof(node->menuentry),
"menuentry \"%-10s %s\" --class=%s {\n"
" vt_set_fake_vlnk \"(%s)%s/%s\" %s %llu\n"
" %s_common_menuentry\n"
" vt_reset_fake_vlnk\n"
"}\n",
grub_get_human_size(fsize, GRUB_HUMAN_SIZE_SHORT), filename, g_menu_class[type],
g_menu_device, g_menu_path_buf, filename, g_menu_prefix[type], (ulonglong)fsize,
g_menu_prefix[type]);
}
else
{
grub_snprintf(node->menuentry, sizeof(node->menuentry),
"menuentry \"%s\" --class=%s {\n"
" vt_set_fake_vlnk \"(%s)%s/%s\" %s %llu\n"
" %s_common_menuentry\n"
" vt_reset_fake_vlnk\n"
"}\n",
filename, g_menu_class[type],
g_menu_device, g_menu_path_buf, filename, g_menu_prefix[type], (ulonglong)fsize,
g_menu_prefix[type]);
}
}
node->prev = NULL;
node->next = g_browser_list;
if (g_browser_list)
{
g_browser_list->prev = node;
}
g_browser_list = node;
return 0;
}
static grub_err_t ventoy_browser_iso_part(void)
{
char cfgfile[64];
char *buffer = NULL;
int pos = 0;
int buflen = 0;
int cfglen = 0;
cfglen = g_tree_script_pos - g_tree_script_pre;
buflen = cfglen + 512;
buffer = grub_malloc(buflen);
if (!buffer)
{
return 1;
}
if (g_tree_view_menu_style == 0)
{
pos = grub_snprintf(buffer, buflen, "menuentry \"%-10s [../]\" --class=\"vtoyret\" VTOY_RET {\n "
" echo 'return ...' \n}\n", "<--");
}
else
{
pos = grub_snprintf(buffer, buflen, "menuentry \"[../]\" --class=\"vtoyret\" VTOY_RET {\n "
" echo 'return ...' \n}\n");
}
grub_memcpy(buffer + pos, g_tree_script_buf + g_tree_script_pre, cfglen);
pos += cfglen;
grub_snprintf(cfgfile, sizeof(cfgfile), "configfile mem:0x%lx:size:%d", (ulong)buffer, pos);
grub_script_execute_sourcecode(cfgfile);
grub_free(buffer);
VENTOY_CMD_RETURN(GRUB_ERR_NONE);
}
grub_err_t ventoy_cmd_browser_dir(grub_extcmd_context_t ctxt, int argc, char **args)
{
int i;
grub_fs_t fs;
grub_device_t dev;
char cfgfile[64];
browser_node *node;
browser_mbuf mbuf;
(void)ctxt;
(void)argc;
if (args[2][0] == '/' && args[2][1] == 0)
{
grub_snprintf(cfgfile, sizeof(cfgfile), "(%s)", args[0]);
if (grub_strcmp(cfgfile, g_iso_path) == 0)
{
return ventoy_browser_iso_part();
}
}
if (!ventoy_browser_mbuf_alloc(&mbuf))
{
return 1;
}
fs = (grub_fs_t)grub_strtoul(args[1], NULL, 16);
if (!fs)
{
debug("Invalid fs %s\n", args[1]);
return 1;
}
dev = grub_device_open(args[0]);
if (!dev)
{
debug("Failed to open device %s\n", args[0]);
return 1;
}
g_menu_fs = fs;
g_menu_device = args[0];
g_menu_dev = dev;
g_browser_list = NULL;
if (args[2][0] == '/' && args[2][1] == 0)
{
g_menu_path_len = 0;
g_menu_path_buf[0] = 0;
fs->fs_dir(dev, "/", ventoy_browser_iterate_dir, NULL);
}
else
{
g_menu_path_len = grub_snprintf(g_menu_path_buf, sizeof(g_menu_path_buf), "%s", args[2]);
fs->fs_dir(dev, g_menu_path_buf, ventoy_browser_iterate_dir, NULL);
}
grub_device_close(dev);
if (g_tree_view_menu_style == 0)
{
browser_ssprintf(&mbuf, "menuentry \"%-10s [../]\" --class=\"vtoyret\" VTOY_RET {\n "
" echo 'return ...' \n}\n", "<--");
}
else
{
browser_ssprintf(&mbuf, "menuentry \"[../]\" --class=\"vtoyret\" VTOY_RET {\n "
" echo 'return ...' \n}\n");
}
for (i = 1; i >= 0; i--)
{
while (1)
{
node = ventoy_browser_find_top_node(i);
if (node)
{
browser_ssprintf(&mbuf, "%s", node->menuentry);
ventoy_browser_mbuf_extend(&mbuf);
if (node->prev)
{
node->prev->next = node->next;
}
if (node->next)
{
node->next->prev = node->prev;
}
if (node == g_browser_list)
{
g_browser_list = node->next;
}
grub_free(node);
}
else
{
break;
}
}
}
g_browser_list = NULL;
grub_snprintf(cfgfile, sizeof(cfgfile), "configfile mem:0x%lx:size:%d", (ulong)mbuf.buf, mbuf.pos);
grub_script_execute_sourcecode(cfgfile);
ventoy_browser_mbuf_free(&mbuf);
VENTOY_CMD_RETURN(GRUB_ERR_NONE);
}
grub_err_t ventoy_cmd_browser_disk(grub_extcmd_context_t ctxt, int argc, char **args)
{
char cfgfile[64];
browser_mbuf mbuf;
(void)ctxt;
(void)argc;
(void)args;
if (!ventoy_browser_mbuf_alloc(&mbuf))
{
return 1;
}
g_vtoy_dev = grub_env_get("vtoydev");
if (g_tree_view_menu_style == 0)
{
browser_ssprintf(&mbuf, "menuentry \"%-10s [Return]\" --class=\"vtoyret\" VTOY_RET {\n "
" echo 'return ...' \n}\n", "<--");
}
else
{
browser_ssprintf(&mbuf, "menuentry \"[Return]\" --class=\"vtoyret\" VTOY_RET {\n "
" echo 'return ...' \n}\n");
}
grub_disk_dev_iterate(ventoy_browser_iterate_disk, &mbuf);
grub_snprintf(cfgfile, sizeof(cfgfile), "configfile mem:0x%lx:size:%d", (ulong)mbuf.buf, mbuf.pos);
grub_script_execute_sourcecode(cfgfile);
ventoy_browser_mbuf_free(&mbuf);
VENTOY_CMD_RETURN(GRUB_ERR_NONE);
}

View File

@@ -117,8 +117,9 @@ ventoy_gpt_info *g_ventoy_part_info = NULL;
grub_uint64_t g_ventoy_disk_size = 0;
grub_uint64_t g_ventoy_disk_part_size[2];
static char *g_tree_script_buf = NULL;
static int g_tree_script_pos = 0;
char *g_tree_script_buf = NULL;
int g_tree_script_pos = 0;
int g_tree_script_pre = 0;
static char *g_list_script_buf = NULL;
static int g_list_script_pos = 0;
@@ -134,14 +135,18 @@ static ventoy_video_mode *g_video_mode_list = NULL;
static int g_enumerate_time_checked = 0;
static grub_uint64_t g_enumerate_start_time_ms;
static grub_uint64_t g_enumerate_finish_time_ms;
static int g_vtoy_file_flt[VTOY_FILE_FLT_BUTT] = {0};
int g_vtoy_file_flt[VTOY_FILE_FLT_BUTT] = {0};
static char g_iso_vd_id_publisher[130];
static char g_iso_vd_id_prepare[130];
static char g_iso_vd_id_application[130];
static int g_pager_flag = 0;
static char g_old_pager[32];
static const char *g_vtoy_winpeshl_ini = "[LaunchApps]\r\nvtoyjump.exe";
static const char *g_menu_class[] =
const char *g_menu_class[img_type_max] =
{
"vtoyiso", "vtoywim", "vtoyefi", "vtoyimg", "vtoyvhd", "vtoyvtoy"
};
@@ -158,7 +163,7 @@ static char g_json_case_mis_path[32];
static ventoy_vlnk_part *g_vlnk_part_list = NULL;
static int ventoy_get_fs_type(const char *fs)
int ventoy_get_fs_type(const char *fs)
{
if (NULL == fs)
{
@@ -686,10 +691,10 @@ grub_file_t ventoy_grub_file_open(enum grub_file_type type, const char *fmt, ...
{
va_list ap;
grub_file_t file;
char fullpath[256] = {0};
char fullpath[512] = {0};
va_start (ap, fmt);
grub_vsnprintf(fullpath, 255, fmt, ap);
grub_vsnprintf(fullpath, 511, fmt, ap);
va_end (ap);
file = grub_file_open(fullpath, type);
@@ -707,13 +712,13 @@ int ventoy_is_dir_exist(const char *fmt, ...)
va_list ap;
int len;
char *pos = NULL;
char buf[256] = {0};
char buf[512] = {0};
grub_snprintf(buf, sizeof(buf), "%s", "[ -d \"");
pos = buf + 6;
va_start (ap, fmt);
len = grub_vsnprintf(pos, 255, fmt, ap);
len = grub_vsnprintf(pos, 511, fmt, ap);
va_end (ap);
grub_strncpy(pos + len, "\" ]", 3);
@@ -1582,7 +1587,7 @@ void ventoy_swap_img(img_info *img1, img_info *img2)
grub_memcpy(img2, &g_img_swap_tmp, sizeof(img_info));
}
static int ventoy_img_name_valid(const char *filename, grub_size_t namelen)
int ventoy_img_name_valid(const char *filename, grub_size_t namelen)
{
(void)namelen;
@@ -1597,8 +1602,16 @@ static int ventoy_img_name_valid(const char *filename, grub_size_t namelen)
static int ventoy_vlnk_iterate_partition(struct grub_disk *disk, const grub_partition_t partition, void *data)
{
ventoy_vlnk_part *node = NULL;
grub_uint32_t SelfSig;
grub_uint32_t *pSig = (grub_uint32_t *)data;
/* skip Ventoy partition 1/2 */
grub_memcpy(&SelfSig, g_ventoy_part_info->MBR.BootCode + 0x1b8, 4);
if (partition->number < 2 && SelfSig == *pSig)
{
return 0;
}
node = grub_zalloc(sizeof(ventoy_vlnk_part));
if (node)
{
@@ -1625,13 +1638,7 @@ static int ventoy_vlnk_iterate_disk(const char *name, void *data)
if (disk)
{
grub_disk_read(disk, 0, 0x1b8, 4, &sig);
/* skip ventoy device self */
if (sig != *(grub_uint32_t *)data)
{
grub_partition_iterate(disk, ventoy_vlnk_iterate_partition, &sig);
}
grub_partition_iterate(disk, ventoy_vlnk_iterate_partition, &sig);
grub_disk_close(disk);
}
@@ -1693,7 +1700,7 @@ static int ventoy_check_vlnk_data(ventoy_vlnk *vlnk, int print, char *dst, int s
if (!g_vlnk_part_list)
{
grub_disk_dev_iterate(ventoy_vlnk_iterate_disk, g_ventoy_part_info->MBR.BootCode + 0x1b8);
grub_disk_dev_iterate(ventoy_vlnk_iterate_disk, NULL);
}
for (cur = g_vlnk_part_list; cur && filefind == 0; cur = cur->next)
@@ -2292,6 +2299,8 @@ static int ventoy_dynamic_tree_menu(img_iterator_node *node)
"}\n", "return");
}
}
g_tree_script_pre = g_tree_script_pos;
}
else
{
@@ -2564,6 +2573,40 @@ static grub_err_t ventoy_cmd_ext_select_img_path(grub_extcmd_context_t ctxt, int
VENTOY_CMD_RETURN(GRUB_ERR_NONE);
}
static char g_fake_vlnk_src[512];
static char g_fake_vlnk_dst[512];
static grub_uint64_t g_fake_vlnk_size;
static grub_err_t ventoy_cmd_set_fake_vlnk(grub_extcmd_context_t ctxt, int argc, char **args)
{
(void)ctxt;
(void)argc;
(void)args;
g_fake_vlnk_size = (grub_uint64_t)grub_strtoull(args[2], NULL, 10);
grub_strncpy(g_fake_vlnk_dst, args[0], sizeof(g_fake_vlnk_dst));
grub_snprintf(g_fake_vlnk_src, sizeof(g_fake_vlnk_src), "%s/________VENTOYVLNK.vlnk.%s", g_iso_path, args[1]);
grub_file_vtoy_vlnk(g_fake_vlnk_src, g_fake_vlnk_dst);
VENTOY_CMD_RETURN(GRUB_ERR_NONE);
}
static grub_err_t ventoy_cmd_reset_fake_vlnk(grub_extcmd_context_t ctxt, int argc, char **args)
{
(void)ctxt;
(void)argc;
(void)args;
g_fake_vlnk_src[0] = 0;
g_fake_vlnk_dst[0] = 0;
g_fake_vlnk_size = 0;
grub_file_vtoy_vlnk(NULL, NULL);
VENTOY_CMD_RETURN(GRUB_ERR_NONE);
}
static grub_err_t ventoy_cmd_chosen_img_path(grub_extcmd_context_t ctxt, int argc, char **args)
{
char value[32];
@@ -2578,6 +2621,18 @@ static grub_err_t ventoy_cmd_chosen_img_path(grub_extcmd_context_t ctxt, int arg
return grub_error(GRUB_ERR_BAD_ARGUMENT, "Usage: %s {var}", cmd_raw_name);
}
if (g_fake_vlnk_src[0] && g_fake_vlnk_dst[0])
{
grub_env_set(args[0], grub_strchr(g_fake_vlnk_src, '/'));
if (argc > 1)
{
grub_snprintf(value, sizeof(value), "%llu", (ulonglong)(g_fake_vlnk_size));
grub_env_set(args[1], value);
}
goto end;
}
id = grub_env_get("chosen");
pos = grub_strstr(id, "VID_");
@@ -2603,6 +2658,7 @@ static grub_err_t ventoy_cmd_chosen_img_path(grub_extcmd_context_t ctxt, int arg
grub_env_set(args[1], value);
}
end:
g_svd_replace_offset = 0;
VENTOY_CMD_RETURN(GRUB_ERR_NONE);
@@ -5417,6 +5473,98 @@ out:
return ret;
}
static grub_err_t ventoy_iso_vd_id_clear(grub_extcmd_context_t ctxt, int argc, char **args)
{
(void)ctxt;
(void)argc;
(void)args;
g_iso_vd_id_publisher[0] = 0;
g_iso_vd_id_prepare[0] = 0;
g_iso_vd_id_application[0] = 0;
return 0;
}
static grub_err_t ventoy_cmd_iso_vd_id_parse(grub_extcmd_context_t ctxt, int argc, char **args)
{
int ret = 1;
int offset = 318;
grub_file_t file = NULL;
(void)ctxt;
(void)argc;
file = grub_file_open(args[0], VENTOY_FILE_TYPE);
if (!file)
{
grub_printf("Failed to open %s\n", args[0]);
goto out;
}
grub_file_seek(file, 16 * 2048 + offset);
grub_file_read(file, g_iso_vd_id_publisher, 128);
offset += 128;
grub_file_seek(file, 16 * 2048 + offset);
grub_file_read(file, g_iso_vd_id_prepare, 128);
offset += 128;
grub_file_seek(file, 16 * 2048 + offset);
grub_file_read(file, g_iso_vd_id_application, 128);
out:
check_free(file, grub_file_close);
grub_errno = GRUB_ERR_NONE;
return ret;
}
static grub_err_t ventoy_cmd_iso_vd_id_begin(grub_extcmd_context_t ctxt, int argc, char **args)
{
int ret = 1;
char *id = g_iso_vd_id_publisher;
(void)ctxt;
(void)argc;
if (args[0][0] == '1')
{
id = g_iso_vd_id_prepare;
}
else if (args[0][0] == '2')
{
id = g_iso_vd_id_application;
}
if (args[1][0] == '0' && grub_strncasecmp(id, args[2], grub_strlen(args[2])) == 0)
{
ret = 0;
}
if (args[1][0] == '1' && grub_strncmp(id, args[2], grub_strlen(args[2])) == 0)
{
ret = 0;
}
grub_errno = GRUB_ERR_NONE;
return ret;
}
static grub_err_t ventoy_cmd_fn_mutex_lock(grub_extcmd_context_t ctxt, int argc, char **args)
{
(void)ctxt;
(void)argc;
g_ventoy_fn_mutex = 0;
if (argc == 1 && args[0][0] == '1' && args[0][1] == 0)
{
g_ventoy_fn_mutex = 1;
}
VENTOY_CMD_RETURN(GRUB_ERR_NONE);
}
int ventoy_env_init(void)
{
char buf[64];
@@ -5468,6 +5616,8 @@ int ventoy_env_init(void)
static cmd_para ventoy_cmds[] =
{
{ "vt_browser_disk", ventoy_cmd_browser_disk, 0, NULL, "", "", NULL },
{ "vt_browser_dir", ventoy_cmd_browser_dir, 0, NULL, "", "", NULL },
{ "vt_incr", ventoy_cmd_incr, 0, NULL, "{Var} {INT}", "Increase integer variable", NULL },
{ "vt_mod", ventoy_cmd_mod, 0, NULL, "{Int} {Int} {Var}", "mod integer variable", NULL },
{ "vt_strstr", ventoy_cmd_strstr, 0, NULL, "", "", NULL },
@@ -5576,7 +5726,9 @@ static cmd_para ventoy_cmds[] =
{ "vt_unix_parse_freebsd_ver", ventoy_cmd_unix_freebsd_ver, 0, NULL, "", "", NULL },
{ "vt_unix_parse_freebsd_ver_elf", ventoy_cmd_unix_freebsd_ver_elf, 0, NULL, "", "", NULL },
{ "vt_unix_reset", ventoy_cmd_unix_reset, 0, NULL, "", "", NULL },
{ "vt_unix_check_vlnk", ventoy_cmd_unix_check_vlnk, 0, NULL, "", "", NULL },
{ "vt_unix_replace_conf", ventoy_cmd_unix_replace_conf, 0, NULL, "", "", NULL },
{ "vt_unix_replace_grub_conf", ventoy_cmd_unix_replace_grub_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 },
@@ -5608,6 +5760,12 @@ static cmd_para ventoy_cmds[] =
{ "vt_vlnk_dump_part", grub_cmd_vlnk_dump_part, 0, NULL, "", "", NULL },
{ "vt_is_vlnk_name", grub_cmd_is_vlnk_name, 0, NULL, "", "", NULL },
{ "vt_get_vlnk_dst", grub_cmd_get_vlnk_dst, 0, NULL, "", "", NULL },
{ "vt_set_fake_vlnk", ventoy_cmd_set_fake_vlnk, 0, NULL, "", "", NULL },
{ "vt_reset_fake_vlnk", ventoy_cmd_reset_fake_vlnk, 0, NULL, "", "", NULL },
{ "vt_iso_vd_id_parse", ventoy_cmd_iso_vd_id_parse, 0, NULL, "", "", NULL },
{ "vt_iso_vd_id_clear", ventoy_iso_vd_id_clear, 0, NULL, "", "", NULL },
{ "vt_iso_vd_id_begin", ventoy_cmd_iso_vd_id_begin, 0, NULL, "", "", NULL },
{ "vt_fn_mutex_lock", ventoy_cmd_fn_mutex_lock, 0, NULL, "", "", NULL },
};
int ventoy_register_all_cmd(void)

View File

@@ -35,6 +35,7 @@
#define VTOY_SIZE_4MB (4 * 1024 * 1024)
#define VTOY_SIZE_512KB (512 * 1024)
#define VTOY_SIZE_1KB 1024
#define VTOY_SIZE_32KB (32 * 1024)
#define JSON_SUCCESS 0
#define JSON_FAILED 1
@@ -315,6 +316,9 @@ void ventoy_debug(const char *fmt, ...);
#define vtoy_ssprintf(buf, pos, fmt, ...) \
pos += grub_snprintf(buf + pos, VTOY_MAX_SCRIPT_BUF - pos, fmt, __VA_ARGS__)
#define browser_ssprintf(mbuf, fmt, args...) \
(mbuf)->pos += grub_snprintf((mbuf)->buf + (mbuf)->pos, (mbuf)->max - (mbuf)->pos, fmt, ##args)
#define FLAG_HEADER_RESERVED 0x00000001
#define FLAG_HEADER_COMPRESSION 0x00000002
#define FLAG_HEADER_READONLY 0x00000004
@@ -1015,6 +1019,7 @@ extern int g_ventoy_grub2_mode;
extern int g_ventoy_wimboot_mode;
extern int g_ventoy_iso_uefi_drv;
extern int g_ventoy_case_insensitive;
extern int g_ventoy_fn_mutex;
extern grub_uint8_t g_ventoy_chain_type;
extern int g_vhdboot_enable;
@@ -1089,7 +1094,9 @@ grub_err_t ventoy_cmd_locate_wim_patch(grub_extcmd_context_t ctxt, int argc, cha
grub_err_t ventoy_cmd_unix_chain_data(grub_extcmd_context_t ctxt, int argc, char **args);
int ventoy_get_disk_guid(const char *filename, grub_uint8_t *guid, grub_uint8_t *signature);
grub_err_t ventoy_cmd_unix_reset(grub_extcmd_context_t ctxt, int argc, char **args);
grub_err_t ventoy_cmd_unix_check_vlnk(grub_extcmd_context_t ctxt, int argc, char **args);
grub_err_t ventoy_cmd_unix_replace_conf(grub_extcmd_context_t ctxt, int argc, char **args);
grub_err_t ventoy_cmd_unix_replace_grub_conf(grub_extcmd_context_t ctxt, int argc, char **args);
grub_err_t ventoy_cmd_unix_replace_ko(grub_extcmd_context_t ctxt, int argc, char **args);
grub_err_t ventoy_cmd_unix_ko_fillmap(grub_extcmd_context_t ctxt, int argc, char **args);
grub_err_t ventoy_cmd_unix_fill_image_desc(grub_extcmd_context_t ctxt, int argc, char **args);
@@ -1166,8 +1173,38 @@ typedef struct ventoy_vlnk_part
struct ventoy_vlnk_part *next;
}ventoy_vlnk_part;
typedef struct browser_mbuf
{
int max;
int pos;
char *buf;
}browser_mbuf;
typedef struct browser_node
{
int dir;
char menuentry[1024];
char filename[512];
struct browser_node *prev;
struct browser_node *next;
}browser_node;
extern char *g_tree_script_buf;
extern int g_tree_script_pos;
extern int g_tree_script_pre;
extern int g_tree_view_menu_style;
extern int g_sort_case_sensitive;
extern int g_wimboot_enable;
extern int g_filt_dot_underscore_file;
extern int g_vtoy_file_flt[VTOY_FILE_FLT_BUTT];
extern const char *g_menu_class[img_type_max];
extern char g_iso_path[256];
int ventoy_add_vlnk_file(char *dir, const char *name);
grub_err_t ventoy_cmd_browser_dir(grub_extcmd_context_t ctxt, int argc, char **args);
grub_err_t ventoy_cmd_browser_disk(grub_extcmd_context_t ctxt, int argc, char **args);
int ventoy_get_fs_type(const char *fs);
int ventoy_img_name_valid(const char *filename, grub_size_t namelen);
#endif /* __VENTOY_DEF_H__ */

View File

@@ -48,6 +48,7 @@ int g_mod_new_len = 0;
char *g_mod_new_data = NULL;
int g_mod_search_magic = 0;
int g_unix_vlnk_boot = 0;
int g_ko_fillmap_len = 0;
char *g_ko_fillmap_data = NULL;
@@ -273,13 +274,14 @@ static void ventoy_unix_fill_virt_data( grub_uint64_t isosize, ventoy_chain_h
return;
}
static int ventoy_freebsd_append_conf(char *buf, const char *isopath)
static int ventoy_freebsd_append_conf(char *buf, const char *isopath, const char *alias)
{
int pos = 0;
grub_uint32_t i;
grub_disk_t disk;
grub_file_t isofile;
char uuid[64] = {0};
const char *val = NULL;
ventoy_img_chunk *chunk;
grub_uint8_t disk_sig[4];
grub_uint8_t disk_guid[16];
@@ -294,6 +296,22 @@ static int ventoy_freebsd_append_conf(char *buf, const char *isopath)
vtoy_ssprintf(buf, pos, "ventoy_load=\"%s\"\n", "YES");
vtoy_ssprintf(buf, pos, "ventoy_name=\"%s\"\n", g_ko_mod_path);
if (alias)
{
vtoy_ssprintf(buf, pos, "hint.ventoy.0.alias=\"%s\"\n", alias);
}
if (g_unix_vlnk_boot)
{
vtoy_ssprintf(buf, pos, "hint.ventoy.0.vlnk=%d\n", 1);
}
val = ventoy_get_env("VTOY_UNIX_REMOUNT");
if (val && val[0] == '1' && val[1] == 0)
{
vtoy_ssprintf(buf, pos, "hint.ventoy.0.remount=%d\n", 1);
}
if (g_mod_search_magic)
{
@@ -301,6 +319,8 @@ static int ventoy_freebsd_append_conf(char *buf, const char *isopath)
goto out;
}
debug("Fill hint.ventoy info\n");
disk = isofile->device->disk;
ventoy_get_disk_guid(isofile->name, disk_guid, disk_sig);
@@ -349,6 +369,7 @@ grub_err_t ventoy_cmd_unix_reset(grub_extcmd_context_t ctxt, int argc, char **ar
(void)argc;
(void)args;
g_unix_vlnk_boot = 0;
g_mod_search_magic = 0;
g_conf_new_len = 0;
g_mod_new_len = 0;
@@ -363,6 +384,27 @@ grub_err_t ventoy_cmd_unix_reset(grub_extcmd_context_t ctxt, int argc, char **ar
VENTOY_CMD_RETURN(GRUB_ERR_NONE);
}
grub_err_t ventoy_cmd_unix_check_vlnk(grub_extcmd_context_t ctxt, int argc, char **args)
{
grub_file_t file;
(void)ctxt;
if (argc != 1)
{
return 1;
}
file = grub_file_open(args[0], VENTOY_FILE_TYPE);
if (file)
{
g_unix_vlnk_boot = file->vlnk;
grub_file_close(file);
}
VENTOY_CMD_RETURN(GRUB_ERR_NONE);
}
grub_err_t ventoy_cmd_parse_freenas_ver(grub_extcmd_context_t ctxt, int argc, char **args)
{
grub_file_t file;
@@ -647,6 +689,109 @@ out:
VENTOY_CMD_RETURN(GRUB_ERR_NONE);
}
grub_err_t ventoy_cmd_unix_replace_grub_conf(grub_extcmd_context_t ctxt, int argc, char **args)
{
int len = 0;
grub_uint32_t i;
char *data;
char *pos;
const char *val = NULL;
grub_uint64_t offset;
grub_file_t file;
char extcfg[512];
const char *confile = NULL;
const char * loader_conf[] =
{
"/boot/grub/grub.cfg",
};
(void)ctxt;
if (argc != 1 && argc != 2)
{
debug("Replace conf invalid argc %d\n", argc);
return 1;
}
for (i = 0; i < sizeof(loader_conf) / sizeof(loader_conf[0]); i++)
{
if (ventoy_get_file_override(loader_conf[i], &offset) == 0)
{
confile = loader_conf[i];
g_conf_override_offset = offset;
break;
}
}
if (confile == NULL)
{
debug("Can't find grub.cfg file from %u locations\n", i);
return 1;
}
file = ventoy_grub_file_open(GRUB_FILE_TYPE_LINUX_INITRD, "(loop)/%s", confile);
if (!file)
{
debug("Failed to open %s \n", confile);
return 1;
}
debug("old grub2 conf file size:%d\n", (int)file->size);
data = grub_malloc(VTOY_MAX_SCRIPT_BUF);
if (!data)
{
grub_file_close(file);
return 1;
}
grub_file_read(file, data, file->size);
grub_file_close(file);
g_conf_new_data = data;
g_conf_new_len = (int)file->size;
pos = grub_strstr(data, "kfreebsd /boot/kernel/kernel");
if (pos)
{
pos += grub_strlen("kfreebsd /boot/kernel/kernel");
if (grub_strncmp(pos, ".gz", 3) == 0)
{
pos += 3;
}
if (argc == 2)
{
vtoy_ssprintf(extcfg, len, ";kfreebsd_module_elf %s; set kFreeBSD.hint.ventoy.0.alias=\"%s\"", args[0], args[1]);
}
else
{
vtoy_ssprintf(extcfg, len, ";kfreebsd_module_elf %s", args[0]);
}
if (g_unix_vlnk_boot)
{
vtoy_ssprintf(extcfg, len, ";set kFreeBSD.hint.ventoy.0.vlnk=%d", 1);
}
val = ventoy_get_env("VTOY_UNIX_REMOUNT");
if (val && val[0] == '1' && val[1] == 0)
{
vtoy_ssprintf(extcfg, len, ";set kFreeBSD.hint.ventoy.0.remount=%d", 1);
}
grub_memmove(pos + len, pos, (int)(file->size - (pos - data)));
grub_memcpy(pos, extcfg, len);
g_conf_new_len += len;
}
else
{
debug("no kfreebsd found\n");
}
VENTOY_CMD_RETURN(GRUB_ERR_NONE);
}
grub_err_t ventoy_cmd_unix_replace_conf(grub_extcmd_context_t ctxt, int argc, char **args)
{
grub_uint32_t i;
@@ -662,7 +807,7 @@ grub_err_t ventoy_cmd_unix_replace_conf(grub_extcmd_context_t ctxt, int argc, ch
(void)ctxt;
if (argc != 2)
if (argc != 2 && argc != 3)
{
debug("Replace conf invalid argc %d\n", argc);
return 1;
@@ -691,7 +836,7 @@ grub_err_t ventoy_cmd_unix_replace_conf(grub_extcmd_context_t ctxt, int argc, ch
return 1;
}
debug("old conf file size:%d\n", (int)file->size);
debug("old conf file <%s> size:%d\n", confile, (int)file->size);
data = grub_malloc(VTOY_MAX_SCRIPT_BUF);
if (!data)
@@ -708,7 +853,7 @@ grub_err_t ventoy_cmd_unix_replace_conf(grub_extcmd_context_t ctxt, int argc, ch
if (grub_strcmp(args[0], "FreeBSD") == 0)
{
g_conf_new_len += ventoy_freebsd_append_conf(data + file->size, args[1]);
g_conf_new_len += ventoy_freebsd_append_conf(data + file->size, args[1], (argc > 2) ? args[2] : NULL);
}
else if (grub_strcmp(args[0], "DragonFly") == 0)
{
@@ -723,13 +868,13 @@ static int ventoy_unix_search_magic(char *data, int len)
int i;
grub_uint32_t *magic = NULL;
for (i = 0; i < len; i += 65536)
for (i = 0; i < len; i += 4096)
{
magic = (grub_uint32_t *)(data + i);
if (magic[0] == VENTOY_UNIX_SEG_MAGIC0 && magic[1] == VENTOY_UNIX_SEG_MAGIC1 &&
magic[2] == VENTOY_UNIX_SEG_MAGIC2 && magic[3] == VENTOY_UNIX_SEG_MAGIC3)
{
debug("unix find search magic at 0x%x loop:%d\n", i, (i >> 16));
debug("unix find search magic at 0x%x loop:%d\n", i, (i >> 12));
g_mod_search_magic = i;
return 0;
}

View File

@@ -218,6 +218,7 @@ grub_err_t EXPORT_FUNC(grub_file_close) (grub_file_t file);
int EXPORT_FUNC(grub_file_is_vlnk_suffix)(const char *name, int len);
int EXPORT_FUNC(grub_file_add_vlnk)(const char *src, const char *dst);
int EXPORT_FUNC(grub_file_vtoy_vlnk)(const char *src, const char *dst);
const char * EXPORT_FUNC(grub_file_get_vlnk)(const char *name, int *vlnk);
/* Return value of grub_file_size() in case file size is unknown. */

View File

@@ -115,6 +115,8 @@ fi
if [ "$VTOY_ARCH" = "x86_64" ]; then
echo "Use x86_64 busybox toolkit ..." >>$VTLOG
$BUSYBOX_PATH/xzcat $BUSYBOX_PATH/xzcat64_musl.xz > $BUSYBOX_PATH/xzcat_musl
$BUSYBOX_PATH/chmod +x $BUSYBOX_PATH/xzcat_musl
ln -s $BUSYBOX_PATH/xzminidec64 $BUSYBOX_PATH/xzminidec
ln -s $VTOY_PATH/tool/dmsetup64 $VTOY_PATH/tool/dmsetup
ln -s $VTOY_PATH/tool/lunzip64 $VTOY_PATH/tool/lunzip
@@ -124,6 +126,8 @@ if [ "$VTOY_ARCH" = "x86_64" ]; then
ln -s $VTOY_PATH/tool/zstdcat64 $VTOY_PATH/tool/zstdcat
elif [ "$VTOY_ARCH" = "i386" ]; then
echo "Use i386 busybox toolkit ..." >>$VTLOG
$BUSYBOX_PATH/xzcat $BUSYBOX_PATH/xzcat32_musl.xz > $BUSYBOX_PATH/xzcat_musl
$BUSYBOX_PATH/chmod +x $BUSYBOX_PATH/xzcat_musl
ln -s $BUSYBOX_PATH/xzminidec32 $BUSYBOX_PATH/xzminidec
ln -s $VTOY_PATH/tool/dmsetup32 $VTOY_PATH/tool/dmsetup
ln -s $VTOY_PATH/tool/lunzip32 $VTOY_PATH/tool/lunzip

View File

@@ -49,7 +49,12 @@ done
if [ -n "$1" ]; then
vtlog "ln -s /dev/$vtDM $1"
ln -s /dev/$vtDM "$1"
if [ -e "$1" ]; then
vtlog "$1 already exist"
else
ln -s /dev/$vtDM "$1"
fi
else
vtLABEL=$($BUSYBOX_PATH/blkid /dev/$vtDM | $SED 's/.*LABEL="\([^"]*\)".*/\1/')
vtlog "vtLABEL is $vtLABEL"
@@ -59,7 +64,11 @@ else
vtlog "vtLABEL is $vtLABEL from cmdline"
fi
ln -s /dev/$vtDM "/dev/disk/by-label/$vtLABEL"
if [ -e "/dev/disk/by-label/$vtLABEL" ]; then
vtlog "$1 already exist"
else
ln -s /dev/$vtDM "/dev/disk/by-label/$vtLABEL"
fi
fi
# OK finish

View File

@@ -77,12 +77,16 @@ ventoy_unpack_initramfs() {
if [ "${vtx:5}" = "xzcat" ]; then
rm -f $VTOY_PATH/xzlog
${vtx:5} $vtfile 2> $VTOY_PATH/xzlog | (cpio -idmu 2>>$VTLOG; cat > $vttmp)
if grep -q 'corrupted data' $VTOY_PATH/xzlog; then
echo 'xzcat failed, now try xzminidec...' >> $VTLOG
cat $vtfile | xzminidec | (cpio -idmu 2>>$VTLOG; cat > $vttmp)
echo 'xzcat failed, now try xzminidec...' >> $VTLOG
rm -f $VTOY_PATH/xzlog
cat $vtfile | xzminidec 2> $VTOY_PATH/xzlog | (cpio -idmu 2>>$VTLOG; cat > $vttmp)
if grep -q 'limit' $VTOY_PATH/xzlog; then
echo 'xzminidec failed, now try xzcat_musl ...' >> $VTLOG
xzcat_musl $vtfile | (cpio -idmu 2>>$VTLOG; cat > $vttmp)
fi
fi
else
${vtx:5} $vtfile | (cpio -idmu 2>>$VTLOG; cat > $vttmp)
fi

View File

@@ -52,8 +52,12 @@ ventoy_get_os_type() {
fi
fi
# PrimeOS :
if $GREP -q 'PrimeOS' /proc/version; then
echo 'primeos'; return
# Debian :
if $GREP -q '[Dd]ebian' /proc/version; then
elif $GREP -q '[Dd]ebian' /proc/version; then
echo 'debian'; return
# Ubuntu : do the same process with debian

Binary file not shown.

Binary file not shown.

View File

@@ -1,4 +1,5 @@
source $prefix/power.cfg
source $prefix/keyboard.cfg
submenu "Resolution Configuration" --class=debug_resolution --class=F5tool {

View File

@@ -65,10 +65,6 @@ function ventoy_vcfg_proc {
fi
}
function ventoy_power {
configfile $prefix/power.cfg
}
function ventoy_diagnosis {
vt_enum_video_mode
configfile $prefix/debug.cfg
@@ -261,6 +257,10 @@ function distro_specify_initrd_file {
vt_linux_specify_initrd_file /isolinux/initrd.gz
fi
if vt_str_begin "$vt_volume_id" "QUBES"; then
vt_linux_specify_initrd_file /images/pxeboot/initrd.img
fi
if [ "$vt_chosen_size" = "1133375488" ]; then
if [ -d (loop)/boot/grub/x86_64-efi ]; then
vt_cpio_busybox64 "64h"
@@ -362,6 +362,9 @@ function distro_specify_initrd_file_phase2 {
vt_linux_specify_initrd_file /pyabr/boot/initrfs.img
elif [ -f (loop)/initrd0.img ]; then
vt_linux_specify_initrd_file /initrd0.img
elif [ -f (loop)/sysresccd/boot/i686/sysresccd.img ]; then
vt_linux_specify_initrd_file /sysresccd/boot/i686/sysresccd.img
fi
}
@@ -497,6 +500,8 @@ function ventoy_freebsd_proc {
if [ "$vt_freebsd_ver" = "xx" ]; then
if [ -e (loop)/boot/kernel/kernel ]; then
vt_unix_parse_freebsd_ver_elf (loop)/boot/kernel/kernel $vt_freebsd_bit vt_freebsd_ver
elif [ -e (loop)/boot/kernel/kernel.gz ]; then
vt_unix_parse_freebsd_ver_elf (loop)/boot/kernel/kernel.gz $vt_freebsd_bit vt_freebsd_ver
fi
if [ "$vt_freebsd_ver" = "xx" ]; then
@@ -516,8 +521,17 @@ function ventoy_freebsd_proc {
fi
done
vt_unix_replace_ko $vt_unix_mod_path (vtunix)/ventoy_unix/$vtFreeBsdDistro/geom_ventoy_ko/$vt_freebsd_ver/$vt_freebsd_bit/geom_ventoy.ko.xz
vt_unix_replace_conf FreeBSD "${1}${chosen_path}"
if [ -n "$vt_unix_mod_path" ]; then
vt_unix_replace_ko $vt_unix_mod_path (vtunix)/ventoy_unix/$vtFreeBsdDistro/geom_ventoy_ko/$vt_freebsd_ver/$vt_freebsd_bit/geom_ventoy.ko.xz
vt_unix_replace_conf FreeBSD "${1}${chosen_path}"
elif [ -e (loop)/easyre.ufs.uzip ]; then
vt_unix_replace_ko "/boot/grub/i386-pc/linux.mod" (vtunix)/ventoy_unix/$vtFreeBsdDistro/geom_ventoy_ko/$vt_freebsd_ver/$vt_freebsd_bit/geom_ventoy.ko.xz
if [ "$grub_platform" = "pc" ]; then
vt_unix_replace_grub_conf "/boot/grub/i386-pc/linux.mod" "cd9"
else
vt_unix_replace_conf FreeBSD "${1}${chosen_path}" "cd9"
fi
fi
}
function ventoy_dragonfly_proc {
@@ -539,6 +553,8 @@ function ventoy_dragonfly_proc {
function ventoy_unix_comm_proc {
vt_unix_reset
vt_unix_check_vlnk "${1}${chosen_path}"
if [ "$ventoy_compatible" = "NO" ]; then
loopback vtunix $vtoy_efi_part/ventoy/ventoy_unix.cpio
@@ -743,7 +759,16 @@ function uefi_linux_menu_func {
ventoy_acpi_param ${vtoy_chain_mem_addr} 2048
ventoy_cli_console
unset vtGrub2Mode
if vt_check_mode 3; then
set vtGrub2Mode=1
elif vt_str_begin "$vt_volume_id" "KRD"; then
if [ -f (loop)/boot/grub/grub.cfg.sig ]; then
set vtGrub2Mode=1
fi
fi
if [ -n "$vtGrub2Mode" ]; then
ventoy_debug_pause
else
if [ "$VTOY_EFI_ARCH" != "mips" ]; then
@@ -1291,14 +1316,32 @@ function iso_common_menuentry {
set vtcompat=1
fi
# auto memdisk mode for some special ISO files
vt_iso_vd_id_parse "${vtoy_iso_part}${vt_chosen_path}"
unset vtMemDiskBoot
if vt_check_mode 0; then
set vtMemDiskBoot=1
else
if [ "$grub_platform" = "pc" ]; then
if vt_iso_vd_id_begin 1 0 "Memtest86+"; then
set vtMemDiskBoot=1
elif vt_iso_vd_id_begin 0 1 "KolibriOS"; then
set vtMemDiskBoot=1
fi
fi
fi
vt_iso_vd_id_clear
if [ "$grub_platform" = "pc" ]; then
if vt_check_mode 0; then
if [ -n "$vtMemDiskBoot" ]; then
legacy_iso_memdisk $vtoy_iso_part "$vt_chosen_path"
else
legacy_iso_menu_func $vtoy_iso_part "$vt_chosen_path"
fi
else
if vt_check_mode 0; then
if [ -n "$vtMemDiskBoot" ]; then
uefi_iso_memdisk $vtoy_iso_part "$vt_chosen_path"
else
uefi_iso_menu_func $vtoy_iso_part "$vt_chosen_path"
@@ -2070,7 +2113,7 @@ function img_unsupport_menuentry {
#############################################################
#############################################################
set VENTOY_VERSION="1.0.66"
set VENTOY_VERSION="1.0.71"
#ACPI not compatible with Window7/8, so disable by default
set VTOY_PARAM_NO_ACPI=1
@@ -2078,7 +2121,7 @@ set VTOY_PARAM_NO_ACPI=1
# Default menu display mode, you can change it as you want.
# 0: List mode
# 1: TreeView mode
set VTOY_DEFAULT_MENU_MODE=1
set VTOY_DEFAULT_MENU_MODE=0
set VTOY_MEM_DISK_STR="[Memdisk]"
set VTOY_ISO_RAW_STR="Compatible Mode"
@@ -2086,7 +2129,7 @@ set VTOY_GRUB2_MODE_STR="GRUB2 Mode"
set VTOY_WIMBOOT_MODE_STR="WIMBOOT Mode"
set VTOY_ISO_UEFI_DRV_STR="UEFI FS"
set VTOY_F2_CMD="ventoy_power"
set VTOY_F2_CMD="vt_browser_disk"
set VTOY_F4_CMD="ventoy_localboot"
set VTOY_F5_CMD="ventoy_diagnosis"
set VTOY_F6_CMD="ventoy_ext_menu"
@@ -2184,10 +2227,10 @@ fi
if [ $VTOY_DEFAULT_MENU_MODE -eq 0 ]; then
set VTOY_F3_CMD="vt_dynamic_menu 1 1"
set VTOY_HOTKEY_TIP="h:Help F1:Memdisk F2:Power F3:TreeView F4:Localboot F5:Tools F6:ExMenu"
set VTOY_HOTKEY_TIP="h:Help F1:Memdisk F2:Browser F3:TreeView F4:Localboot F5:Tools F6:ExMenu"
else
set VTOY_F3_CMD="vt_dynamic_menu 1 0"
set VTOY_HOTKEY_TIP="h:Help F1:Memdisk F2:Power F3:ListView F4:Localboot F5:Tools F6:ExMenu"
set VTOY_HOTKEY_TIP="h:Help F1:Memdisk F2:Browser F3:ListView F4:Localboot F5:Tools F6:ExMenu"
fi
terminal_output console
@@ -2293,35 +2336,6 @@ export VTOY_HELP_TXT_LANGUAGE
export VTOY_CHKSUM_FILE_PATH
#special VTOY_DEFAULT_IMAGE process
if [ -n "$VTOY_DEFAULT_IMAGE" ]; then
if regexp --set 1:vtHotkey --set 2:vtDefault "(F[2-9])>(.*)" "$VTOY_DEFAULT_IMAGE"; then
set default="$vtDefault"
if [ -z "$VTOY_MENU_TIMEOUT" ]; then
set timeout=0
else
set timeout=$VTOY_MENU_TIMEOUT
fi
export timeout
export default
if [ "$vtHotkey" = "F2" ]; then
ventoy_power
elif [ "$vtHotkey" = "F4" ]; then
ventoy_localboot
elif [ "$vtHotkey" = "F5" ]; then
ventoy_diagnosis
elif [ "$vtHotkey" = "F6" ]; then
ventoy_ext_menu
fi
unset timeout
unset default
fi
fi
#colect all image files (iso files)
set ventoy_img_count=0
vt_list_img $vtoy_iso_part ventoy_img_count
@@ -2346,3 +2360,39 @@ else
reboot
}
fi
#special VTOY_DEFAULT_IMAGE process
if [ -n "$VTOY_DEFAULT_IMAGE" ]; then
if regexp --set 1:vtHotkey --set 2:vtDefault "(F[2-9])>(.*)" "$VTOY_DEFAULT_IMAGE"; then
set default="$vtDefault"
if [ -z "$VTOY_MENU_TIMEOUT" ]; then
set timeout=0
else
set timeout=$VTOY_MENU_TIMEOUT
fi
export timeout
export default
vt_fn_mutex_lock 1
if [ "$vtHotkey" = "F2" ]; then
unset timeout
vt_browser_disk
elif [ "$vtHotkey" = "F4" ]; then
ventoy_localboot
elif [ "$vtHotkey" = "F5" ]; then
ventoy_diagnosis
elif [ "$vtHotkey" = "F6" ]; then
ventoy_ext_menu
fi
vt_fn_mutex_lock 0
unset timeout
unset default
fi
fi

View File

@@ -1,6 +1,6 @@
h - Zeigt dieses Hilfe Menu
F1 - Memdisk Modus (Nur für kleine WinPE/LiveCD ISO/IMG)
F2 - Neustarten/Herunterfahren
F2 - Browse and boot files in local disk
F3 - Menu wechsel zwischen Baum <-> Listen Ansicht
F4 - Windows/Linux vom lokalem Datenträger starten
F5 - Dienstprogramme

View File

@@ -1,6 +1,6 @@
h - Display this help information
F1 - Memdisk Mode (Only for small WinPE/LiveCD ISO/IMG)
F2 - Reboot/Power off
F2 - Browse and boot files in local disk
F3 - Switch menu mode between Treeview <-> ListView
F4 - Boot Windows/Linux in local disk
F5 - Utilities

View File

@@ -1,6 +1,6 @@
h - Afficher cette aide
F1 - Mode Memdisk (Seulement pour WinPE/LiveCD ISO/IMG)
F2 - Redémarrer/arrêter
F2 - Browse and boot files in local disk
F3 - Basculer l'affichage 'Vue en arbre' <-> 'Vue en liste'
F4 - Démarrer le système Windows/Linux local
F5 - Utilitaires

View File

@@ -1,17 +1,18 @@
h - Prikazuje ove informacije
F1 - Memdisk način rada (samo za male WinPE/LiveCD imidž fajlove)
F2 - Ponovno pokretanje/isključivanje
F2 - Pokreće imidž fajlove na lokalnom disku
F3 - Mijenja meni između TreeView <-> ListView
F4 - Pokreće Windows/Linux na lokalnom disku
F5 - Postavke
F5 - Alati
F6 - Učitava prilagođen GRUB2 meni
F7 - Mijenja između GUI načina rada <-> TEXT načina rada
F7 - Mijenja između GUI <-> 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)
m - Generira heš 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 - Učitava EFI drajver za imidž fajlove (samo za testiranje)
Pritisnite ESC za povratak...
Pritisnite ESC za povratak ......

View File

@@ -1,6 +1,6 @@
h - Tampilkan bantuan informasi ini
F1 - Mode Memdisk (Hanya untuk ukuran WinPE/LiveCD ISO/IMG yang kecil)
F2 - Mulai ulang/Matikan
F2 - Browse and boot files in local disk
F3 - Beralih mode menu antara Treeview <-> ListView
F4 - Jalankan (boot) Windows/Linux pada disk lokal
F5 - Alat Utilitas

View File

@@ -1,8 +1,8 @@
h - この画面を表示する
F1 - 主記憶装置上に記憶域を作成する容量の小さなWinPE・LiveCD専用
F2 - 再起動・電源断
F2 - 手元の記憶装置にある起動ファイルを選択して実行する
F3 - 表示形式を切り替える(一覧 ↔ 階層)
F4 - 手元の記憶装置にあるOSを起動する
F4 - 手元の記憶装置にあるWindowsまたはLinuxを起動する
F5 - 諸機能
F6 - Grub2の構成を読み込む
F7 - 操作形式を切り替えるGUI ↔ CUI
@@ -15,4 +15,4 @@ Ctrl+u - ISO efiドライバーを読み取る開発用非公式
この画面を閉じるにはESCを押してください
この画面を閉じるにはESCを押してください ......

View File

@@ -0,0 +1,18 @@
h - 이 도움말 정보 표시
F1 - Memdisk 모드 (작은 WinPE/LiveCD ISO/IMG 전용)
F2 - 로컬 디스크에서 파일 찾아보기 및 부팅
F3 - 트리보기 <-> 목록보기 간에 메뉴 모드 전환
F4 - 로컬 디스크에서 Windows/Linux 부팅
F5 - 유틸리티
F6 - 사용자 지정 Grub2 메뉴 로드
F7 - GUI 모드 <-> TEXT 모드 간에 전환
m - 체크섬 이미지 파일 (md5/sha1/sha256/sha512)
Ctrl+w - WIMBOOT 모드 (표준 Windows ISO 전용)
Ctrl+r - Grub2 모드 (일부 Linux 배포판에만 해당)
Ctrl+i - 호환 모드 (디버그 전용)
Ctrl+u - ISO eFi 드라이버 로드 (디버그 전용, 공식적으로 사용할 수 없음)
돌아가려면 ESC를 누르십시오 ......

View File

@@ -1,6 +1,6 @@
h - Mostra esta informação de ajuda
F1 - Modo Memdisk (Apenas para pequenos WinPE/LiveCD ISO/IMG)
F2 - Reiniciar/Desligar
F2 - Browse and boot files in local disk
F3 - Alternar o modo menu entre Vista de árvore <-> Vista de lista
F4 - Arrancar o Windows/Linux em disco local
F5 - Utilitários

View File

@@ -1,17 +0,0 @@
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,18 @@
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 - Учитава EFI драјвер за имиџ фајлове (само за тестирање)
Притисните ESC за повратак ......

View File

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

@@ -1,6 +1,6 @@
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
F2 - Yerel diskteki dosyalara GÖZAT ve ÖNYÜKLE'meyi sağlar
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ü

View File

@@ -1,6 +1,6 @@
h - 显示本帮助信息
F1 - 把文件加载到内存启动(只适用于文件很小的 WinPE/LiveCD等
F2 - 电源操作 (重启、关机)
F2 - 浏览并启动本地硬盘中的镜像文件
F3 - 菜单显示模式切换。可在列表模式和目录模式之间自由切换。
F4 - 启动本地硬盘上的 Windows/Linux 等系统。
F5 - 各类工具

View File

@@ -1,15 +1,17 @@
menuentry Reboot --class=power_reboot {
echo -e '\n\nSystem is rebooting ... \n'
sleep 1
reboot
}
submenu "Power" --class=debug_power --class=F5tool {
menuentry Reboot --class=debug_reboot --class=debug_power --class=F5tool {
echo -e '\n\nSystem is rebooting ... \n'
sleep 1
reboot
}
menuentry Halt --class=power_halt {
echo -e '\n\nSystem is halting ... \n'
sleep 1
halt
}
menuentry Halt --class=debug_halt --class=debug_power --class=F5tool {
echo -e '\n\nSystem is halting ... \n'
sleep 1
halt
}
menuentry 'Return to previous menu [Esc]' --class=vtoyret VTOY_RET {
echo 'Return ...'
menuentry 'Return to previous menu [Esc]' --class=vtoyret VTOY_RET {
echo 'Return ...'
}
}

View File

@@ -60,6 +60,12 @@ while [ -n "$1" ]; do
exit 1
fi
DISK=$1
# Resolve symlinks now, will be needed to look up information about the device in
# the /sys/ filesystem, for example /sys/class/block/${DISK#/dev/}/start
# The main use case is supporting /dev/disk/by-id/ symlinks instead of raw devices
if [ -L "$DISK" ]; then
DISK=$(readlink -e -n "$DISK")
fi
fi
shift

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@@ -1157,8 +1157,8 @@
"STR_INSTALL":"Installa",
"STR_UPDATE":"Aggiorna",
"STR_UPDATE_TIP":"L'aggiornamento è sicuro, i file presenti nel dispositivo rimarranno invariati.#@Vuoi continuare?",
"STR_INSTALL_TIP":"Il disco verrà formattato e tutti i dati saranno persi.#@Vuoi continuare?",
"STR_INSTALL_TIP2":"Il disco verrà formattato e tutti i dati saranno persi.#@Vuoi continuare (seconda verifica)?",
"STR_INSTALL_TIP":"Il dispositivo verrà formattato e tutti i dati saranno persi.#@Vuoi continuare?",
"STR_INSTALL_TIP2":"Il dispositivo verrà formattato e tutti i dati saranno persi.#@Vuoi continuare (seconda verifica)?",
"STR_INSTALL_SUCCESS":"Congratulazioni!#@Installazione di Ventoy nel dispositivo completata.",
"STR_INSTALL_FAILED":"Si è verificato un errore durante l'installazione.#@Riconnetti il dispositivo e riprova.#@Per i dettagli controlla il file log.txt .",
"STR_UPDATE_SUCCESS":"Congratulazioni!#@Aggiornamento di Ventoy nel dispositivo completato",
@@ -1169,13 +1169,13 @@
"STR_MENU_PART_CFG":"Configurazione partizione",
"STR_BTN_OK":"OK",
"STR_BTN_CANCEL":"Annulla",
"STR_PRESERVE_SPACE":"Riserva spazio nella parte finale del disco",
"STR_PRESERVE_SPACE":"Riserva spazio nella parte finale del dispositivo",
"STR_SPACE_VAL_INVALID":"Quantità di spazio da riservare non valida",
"STR_MENU_CLEAR":"Rimuovi Ventoy",
"STR_CLEAR_SUCCESS":"Rimozione di Ventoy dal dispositivo completata.",
"STR_CLEAR_FAILED":"Si è verificato un errore durante la rimozione di Ventoy dal dispositivo.#@Riconnetti il dispositivo e riprova.#@Per i dettagli controlla il file log.txt.",
"STR_MENU_PART_STYLE":"Stile tabella partizioni",
"STR_DISK_2TB_MBR_ERROR":"Seleziona GPT per dischi con dimensioni maggiori di 2TB",
"STR_DISK_2TB_MBR_ERROR":"Seleziona GPT per dispositivi con dimensioni maggiori di 2TB",
"STR_SHOW_ALL_DEV":"Visualizza tutti i dispositivi",
"STR_PART_ALIGN_4KB":"Allinea le partizioni con 4KB",
"STR_WEB_COMMUNICATION_ERR":"Errore di comunicazione:",

View File

@@ -88,6 +88,7 @@ typedef struct SYSINFO
char buildtime[128];
int syntax_error;
int invalid_config;
int config_save_error;
int language;
int pathcase;

View File

@@ -325,8 +325,7 @@ static int ventoy_api_sysinfo(struct mg_connection *conn, VTOY_JSON *json)
VTOY_JSON_FMT_SINT("invalid_config", g_sysinfo.invalid_config);
g_sysinfo.invalid_config = 0;
#if defined(_MSC_VER) || defined(WIN32)
VTOY_JSON_FMT_STRN("os", "windows");
#else
@@ -349,6 +348,8 @@ static int ventoy_api_handshake(struct mg_connection *conn, VTOY_JSON *json)
VTOY_JSON_FMT_BEGIN(pos, JSON_BUFFER, JSON_BUF_MAX);
VTOY_JSON_FMT_OBJ_BEGIN();
VTOY_JSON_FMT_SINT("status", 0);
VTOY_JSON_FMT_SINT("save_error", g_sysinfo.config_save_error);
g_sysinfo.config_save_error = 0;
VTOY_JSON_FMT_OBJ_END();
VTOY_JSON_FMT_END(pos);
@@ -485,7 +486,6 @@ void ventoy_data_default_control(data_control *data)
{
memset(data, 0, sizeof(data_control));
data->default_menu_mode = 1;
data->filter_dot_underscore = 1;
data->max_search_level = -1;
data->menu_timeout = 0;
@@ -1776,7 +1776,9 @@ int ventoy_data_cmp_image_list(data_image_list *data1, data_image_list *data2)
int ventoy_data_save_image_list(data_image_list *data, const char *title, char *buf, int buflen)
{
int pos = 0;
int prelen;
path_node *node = NULL;
char newtitle[64];
(void)title;
@@ -1784,17 +1786,20 @@ int ventoy_data_save_image_list(data_image_list *data, const char *title, char *
{
return 0;
}
prelen = (int)strlen("image_list");
VTOY_JSON_FMT_BEGIN(pos, buf, buflen);
if (data->type == 0)
{
VTOY_JSON_FMT_KEY_L(L1, "image_list");
scnprintf(newtitle, sizeof(newtitle), "image_list%s", title + prelen);
}
else
{
VTOY_JSON_FMT_KEY_L(L1, "image_blacklist");
scnprintf(newtitle, sizeof(newtitle), "image_blacklist%s", title + prelen);
}
VTOY_JSON_FMT_KEY_L(L1, newtitle);
VTOY_JSON_FMT_ARY_BEGIN_N();
@@ -3573,6 +3578,7 @@ int ventoy_http_writeback(void)
if (ret)
{
vlog("Failed to write ventoy.json file.\n");
g_sysinfo.config_save_error = 1;
}
return 0;

View File

@@ -1 +1 @@
de_DEen_USfr_FRhr_HRid_IDja_JPpt_PTsr_CYsr_SRtr_TRzh_CN
de_DEen_USfr_FRhr_HRid_IDja_JPko_KRpt_PTsr_RStr_TRzh_CN

View File

@@ -723,7 +723,7 @@
<footer class="main-footer">
<div class="pull-right hidden-xs">
<b id="plugson_build_date">20220204 16:31:23</b>
<b id="plugson_build_date">20220311 21:24:51</b>
</div>
<strong><a href="https://www.ventoy.net" target="_blank">https://www.ventoy.net</a></strong>
</footer>
@@ -818,11 +818,6 @@
(function ventoy_handshake() {
if (m_syntax_error === 1) {
}
callVtoyCatchErr({
method : 'handshake'
},
@@ -844,6 +839,13 @@
m_invalid_config = 0;
}
if (data.save_error === 1) {
var title = g_current_language == 'en' ? g_vtoy_cur_language_en.STR_INFO : g_vtoy_cur_language_cn.STR_INFO;
var msg = g_current_language == 'en' ? g_vtoy_cur_language_en.STR_CONFIG_SAVE_ERROR_TIP : g_vtoy_cur_language_cn.STR_CONFIG_SAVE_ERROR_TIP;
Modal.alert({title:title,msg:msg}).on(function(e) {
});
}
setTimeout(function() {
ventoy_handshake();
}, 1000);

View File

@@ -195,7 +195,7 @@
$('input:text[id=id_tip_text_top]').val(data.top);
$('input:text[id=id_tip_text_color]').val(data.color);
FillTipTable(data.tips);
FillTipTable(data);
}

View File

@@ -480,6 +480,7 @@ var g_vtoy_cur_language_en =
"STR_SECURE_BOOT_DISABLE": "Disable",
"STR_SYNTAX_ERROR_TIP": "Syntax error detected in ventoy.json, so the configuration is not loaded!",
"STR_INVALID_CONFIG_TIP": "Invalid configuration detected in ventoy.json, so the configuration is not loaded!",
"STR_CONFIG_SAVE_ERROR_TIP": "Failed to write ventoy.json file. Check VentoyPlugson.log for more details!",
"STR_XXX": "xxx"
};
@@ -615,7 +616,7 @@ var g_vtoy_cur_language_cn =
"STR_SECURE_BOOT_DISABLE": "未开启",
"STR_SYNTAX_ERROR_TIP": "ventoy.json 文件中存在语法错误,配置未加载!",
"STR_INVALID_CONFIG_TIP": "ventoy.json 文件中存在错误配置,配置未加载!",
"STR_CONFIG_SAVE_ERROR_TIP": "ventoy.json 文件写入失败,详细信息请参考 VentoyPlugson.log 文件!",
"STR_XXX": "xxx"

View File

@@ -13,10 +13,11 @@
Ventoy is an open source tool to create bootable USB drive for ISO/WIM/IMG/VHD(x)/EFI files. <br/>
With ventoy, you don't need to format the disk over and over, you just need to copy the image files to the USB drive and boot it.
You can copy many image files at a time and ventoy will give you a boot menu to select them. <br/>
You can also browse ISO/WIM/IMG/VHD(x)/EFI files in local disk and boot them.<br/>
x86 Legacy BIOS, IA32 UEFI, x86_64 UEFI, ARM64 UEFI and MIPS64EL UEFI are supported in the same way.<br/>
Both MBR and GPT partition style are supported in the same way.<br/>
Most type of OS supported(Windows/WinPE/Linux/Unix/ChromeOS/Vmware/Xen...) <br/>
800+ ISO files are tested (<a href="https://www.ventoy.net/en/isolist.html">List</a>). 90%+ distros in <a href="https://distrowatch.com/">distrowatch.com</a> supported (<a href="https://www.ventoy.net/en/distrowatch.html">Details</a>). <br/>
830+ ISO files are tested (<a href="https://www.ventoy.net/en/isolist.html">List</a>). 90%+ distros in <a href="https://distrowatch.com/">distrowatch.com</a> supported (<a href="https://www.ventoy.net/en/distrowatch.html">Details</a>). <br/>
<br/>Official Website: <a href=https://www.ventoy.net>https://www.ventoy.net</a>
</h4>
@@ -38,6 +39,9 @@ VMware ESXi, Citrix XenServer, Xen XCP-ng
# Tested Image Report
[【How to report a successfully tested image file】](https://github.com/ventoy/Ventoy/issues/1195)
# Ventoy Browser
With Ventoy, you can also browse ISO/WIM/IMG/VHD(x)/EFI files in local disk and boot them. [Notes](https://www.ventoy.net/en/doc_browser.html)
# VentoyPlugson
A GUI Ventoy plugin configurator. [VentoyPlugson](https://www.ventoy.net/en/plugin_plugson.html)
@@ -48,6 +52,7 @@ A GUI Ventoy plugin configurator. [VentoyPlugson](https://www.ventoy.net/en/plug
* Fast (limited only by the speed of copying iso file)
* Can be installed in USB/Local Disk/SSD/NVMe/SD Card
* Directly boot from ISO/WIM/IMG/VHD(x)/EFI files, no extraction needed
* Support to browse and boot ISO/WIM/IMG/VHD(x)/EFI files in local disk
* No need to be continuous in disk for ISO/WIM/IMG/VHD(x)/EFI files
* MBR and GPT partition style supported (1.0.15+)
* x86 Legacy BIOS, IA32 UEFI, x86_64 UEFI, ARM64 UEFI, MIPS64EL UEFI supported
@@ -58,7 +63,7 @@ A GUI Ventoy plugin configurator. [VentoyPlugson](https://www.ventoy.net/en/plug
* FAT32/exFAT/NTFS/UDF/XFS/Ext2(3)(4) supported for main partition
* ISO files larger than 4GB supported
* Native boot menu style for Legacy & UEFI
* Most type of OS supported, 800+ iso files tested
* Most types of OS supported, 830+ iso files tested
* Linux vDisk boot supported
* Not only boot but also complete installation process
* Menu dynamically switchable between List/TreeView mode
@@ -117,7 +122,7 @@ See [https://www.ventoy.net/en/faq.html](https://www.ventoy.net/en/faq.html) for
# Donation
It would be much appreciated if you want to make a small donation to support my work!
Alipay, WeChat Pay, PayPal and Bitcoin are avaliable for donation. You can chose any of them.
Alipay, WeChat Pay, PayPal and Bitcoin are available for donation. You can choose any of them.
Alipay | WeChat Pay
-|-

View File

@@ -65,11 +65,22 @@ static g_taste_t g_ventoy_taste;
static g_ctl_req_t g_ventoy_config;
static g_dumpconf_t g_ventoy_dumpconf;
static const char *g_ventoy_disk_uuid = NULL;
static char g_ventoy_disk_uuid[64];
static bool g_ventoy_tasted = false;
static off_t g_ventoy_disk_size = 0;
static off_t g_disk_map_start = 0;
static off_t g_disk_map_end = 0;
static int g_ventoy_remount = 0;
struct g_ventoy_map g_ventoy_map_data __attribute__((aligned (4096))) =
{
{ VENTOY_UNIX_SEG_MAGIC0, VENTOY_UNIX_SEG_MAGIC1, VENTOY_UNIX_SEG_MAGIC2, VENTOY_UNIX_SEG_MAGIC3 },
{ 0, 0, 0, 0 },
0, 0,
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
{ { 0, 0 } },
{ VENTOY_UNIX_SEG_MAGIC0, VENTOY_UNIX_SEG_MAGIC1, VENTOY_UNIX_SEG_MAGIC2, VENTOY_UNIX_SEG_MAGIC3 }
};
struct g_class g_ventoy_class = {
.name = G_VENTOY_CLASS_NAME,
@@ -191,12 +202,19 @@ g_ventoy_access(struct g_provider *pp, int dr, int dw, int de)
g_topology_assert();
gp = pp->geom;
/* On first open, grab an extra "exclusive" bit */
if (pp->acr == 0 && pp->acw == 0 && pp->ace == 0)
de++;
/* ... and let go of it on last close */
if ((pp->acr + dr) == 0 && (pp->acw + dw) == 0 && (pp->ace + de) == 0)
de--;
if (g_ventoy_remount)
{
de = 0;
}
else
{
/* On first open, grab an extra "exclusive" bit */
if (pp->acr == 0 && pp->acw == 0 && pp->ace == 0)
de++;
/* ... and let go of it on last close */
if ((pp->acr + dr) == 0 && (pp->acw + dw) == 0 && (pp->ace + de) == 0)
de--;
}
LIST_FOREACH_SAFE(cp1, &gp->consumer, consumer, tmp) {
error = g_access(cp1, dr, dw, de);
@@ -642,24 +660,52 @@ g_ventoy_destroy_geom(struct gctl_req *req __unused,
static bool g_vtoy_check_disk(struct g_class *mp, struct g_provider *pp)
{
int i;
int vlnk = 0;
bool ret = true;
uint8_t *buf;
char uuid[64];
const char *value;
struct g_consumer *cp;
struct g_geom *gp;
uint8_t mbrdata[] = {
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,
};
if (g_ventoy_disk_size == 0)
{
if (resource_string_value("ventoy", 0, "disksize", &value) == 0)
if (VENTOY_MAP_VALID(g_ventoy_map_data.magic2))
{
G_DEBUG("ventoy.disksize: %s\n", value);
g_ventoy_disk_size = strtouq(value, NULL, 0);
}
G_DEBUG("ventoy map data is valid. [OK]\n");
if (resource_string_value("ventoy", 0, "diskuuid", &g_ventoy_disk_uuid) == 0)
{
for (i = 0; i < 16; i++)
{
sprintf(uuid + i * 2, "%02x", g_ventoy_map_data.diskuuid[i]);
}
snprintf(g_ventoy_disk_uuid, sizeof(g_ventoy_disk_uuid), "%s", uuid);
g_ventoy_disk_size = g_ventoy_map_data.disksize;
G_DEBUG("ventoy.disksize: %llu\n", (unsigned long long)g_ventoy_disk_size);
G_DEBUG("ventoy.diskuuid: <%s>\n", g_ventoy_disk_uuid);
}
else
{
G_DEBUG("ventoy map data is invalid, get from resource\n");
if (resource_string_value("ventoy", 0, "disksize", &value) == 0)
{
G_DEBUG("ventoy.disksize: %s\n", value);
g_ventoy_disk_size = strtouq(value, NULL, 0);
}
if (resource_string_value("ventoy", 0, "diskuuid", &value) == 0)
{
snprintf(g_ventoy_disk_uuid, sizeof(g_ventoy_disk_uuid), "%s", value);
G_DEBUG("ventoy.diskuuid: <%s>\n", value);
}
}
}
if (g_ventoy_disk_size != pp->mediasize)
@@ -700,14 +746,28 @@ static bool g_vtoy_check_disk(struct g_class *mp, struct g_provider *pp)
{
sprintf(uuid + i * 2, "%02x", buf[0x180 + i]);
}
g_free(buf);
if (strncmp(g_ventoy_disk_uuid, uuid, 32) == 0)
if (strncmp(g_ventoy_disk_uuid, uuid, 32))
{
return true;
ret = false;
}
return false;
if (resource_int_value("ventoy", 0, "vlnk", &vlnk) || (vlnk != 1))
{
if (memcmp(mbrdata, buf, 0x30) || memcmp(mbrdata + 0x30, buf + 0x190, 16))
{
ret = false;
}
}
g_free(buf);
if (ret)
{
G_DEBUG("ventoy disk check OK\n");
}
return ret;
}
static struct g_geom *
@@ -716,8 +776,10 @@ g_ventoy_taste(struct g_class *mp, struct g_provider *pp, int flags __unused)
int i;
int error;
int disknum;
int remount = 0;
char *endpos;
const char *value;
const char *alias = NULL;
struct g_geom *gp;
struct g_ventoy_metadata md;
struct g_ventoy_softc *sc;
@@ -741,9 +803,32 @@ g_ventoy_taste(struct g_class *mp, struct g_provider *pp, int flags __unused)
g_ventoy_tasted = true;
G_DEBUG("######### ventoy disk <%s> #############\n", pp->name);
G_DEBUG("###### ventoy disk <%s> ######\n", pp->name);
resource_int_value("ventoy", 0, "segnum", &disknum);
/* hint.ventoy.0.remount=1 */
if (resource_int_value("ventoy", 0, "remount", &remount) == 0 && remount == 1)
{
g_ventoy_remount = 1;
G_DEBUG("###### ventoy remount enabled ######\n");
}
/* hint.ventoy.0.alias=xxx */
if (resource_string_value("ventoy", 0, "alias", &alias) == 0 && alias)
{
G_DEBUG("###### ventoy alias <%s> ######\n", alias);
setenv("kern.devalias.ventoy/IMAGE", alias);
}
if (VENTOY_MAP_VALID(g_ventoy_map_data.magic2))
{
disknum = (int)g_ventoy_map_data.segnum;
G_DEBUG("segnum from map data is:<%d>\n", disknum);
}
else
{
resource_int_value("ventoy", 0, "segnum", &disknum);
G_DEBUG("segnum from resource is:<%d>\n", disknum);
}
strlcpy(md.md_magic, G_VENTOY_MAGIC, sizeof(md.md_magic));
md.md_version = G_VENTOY_VERSION;
@@ -765,18 +850,29 @@ g_ventoy_taste(struct g_class *mp, struct g_provider *pp, int flags __unused)
for (i = 0; i < disknum; i ++)
{
if (resource_string_value("ventoy", i, "seg", &value) == 0)
if (VENTOY_MAP_VALID(g_ventoy_map_data.magic2))
{
g_disk_map_start = strtouq(value, &endpos, 0);
g_disk_map_end = strtouq(endpos + 1, NULL, 0);
G_DEBUG("[map] ventoy segment%d: 0x%llx@0x%llx\n", i,
(long long)g_ventoy_map_data.seglist[i].seg_start_bytes,
(long long)g_ventoy_map_data.seglist[i].seg_end_bytes);
g_disk_map_start = (off_t)g_ventoy_map_data.seglist[i].seg_start_bytes;
g_disk_map_end = (off_t)g_ventoy_map_data.seglist[i].seg_end_bytes;
}
else
{
printf("Failed to parse ventoy seg %d\n", i);
continue;
if (resource_string_value("ventoy", i, "seg", &value) == 0)
{
g_disk_map_start = strtouq(value, &endpos, 0);
g_disk_map_end = strtouq(endpos + 1, NULL, 0);
}
else
{
printf("Failed to parse ventoy seg %d\n", i);
continue;
}
G_DEBUG("[resource] ventoy segment%d: %s\n", i, value);
}
G_DEBUG("ventoy segment%d: %s\n", i, value);
G_VENTOY_DEBUG(1, "Adding disk %s to %s.", pp->name, gp->name);
error = g_ventoy_add_disk(sc, pp, i);
@@ -792,7 +888,7 @@ g_ventoy_taste(struct g_class *mp, struct g_provider *pp, int flags __unused)
g_disk_map_end = 0;
}
return (gp);
return (gp);
}
static void

View File

@@ -76,6 +76,33 @@ struct g_ventoy_softc {
struct mtx sc_lock;
};
#define sc_name sc_geom->name
#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 {
uint64_t seg_start_bytes;
uint64_t seg_end_bytes;
};
struct g_ventoy_map{
uint32_t magic1[4];
uint32_t magic2[4];
uint64_t segnum;
uint64_t disksize;
uint8_t diskuuid[16];
struct g_ventoy_seg seglist[VENTOY_UNIX_MAX_SEGNUM];
uint32_t magic3[4];
};
#pragma pack()
#define VENTOY_MAP_VALID(magic2) \
(magic2[0] == VENTOY_UNIX_SEG_MAGIC0 && magic2[1] == VENTOY_UNIX_SEG_MAGIC1 && magic2[2] == VENTOY_UNIX_SEG_MAGIC2 && magic2[3] == VENTOY_UNIX_SEG_MAGIC3)
#endif /* _KERNEL */
struct g_ventoy_metadata {

View File

@@ -65,11 +65,22 @@ static g_taste_t g_ventoy_taste;
static g_ctl_req_t g_ventoy_config;
static g_dumpconf_t g_ventoy_dumpconf;
static const char *g_ventoy_disk_uuid = NULL;
static char g_ventoy_disk_uuid[64];
static bool g_ventoy_tasted = false;
static off_t g_ventoy_disk_size = 0;
static off_t g_disk_map_start = 0;
static off_t g_disk_map_end = 0;
static int g_ventoy_remount = 0;
struct g_ventoy_map g_ventoy_map_data __attribute__((aligned (4096))) =
{
{ VENTOY_UNIX_SEG_MAGIC0, VENTOY_UNIX_SEG_MAGIC1, VENTOY_UNIX_SEG_MAGIC2, VENTOY_UNIX_SEG_MAGIC3 },
{ 0, 0, 0, 0 },
0, 0,
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
{ { 0, 0 } },
{ VENTOY_UNIX_SEG_MAGIC0, VENTOY_UNIX_SEG_MAGIC1, VENTOY_UNIX_SEG_MAGIC2, VENTOY_UNIX_SEG_MAGIC3 }
};
struct g_class g_ventoy_class = {
.name = G_VENTOY_CLASS_NAME,
@@ -191,12 +202,19 @@ g_ventoy_access(struct g_provider *pp, int dr, int dw, int de)
g_topology_assert();
gp = pp->geom;
/* On first open, grab an extra "exclusive" bit */
if (pp->acr == 0 && pp->acw == 0 && pp->ace == 0)
de++;
/* ... and let go of it on last close */
if ((pp->acr + dr) == 0 && (pp->acw + dw) == 0 && (pp->ace + de) == 0)
de--;
if (g_ventoy_remount)
{
de = 0;
}
else
{
/* On first open, grab an extra "exclusive" bit */
if (pp->acr == 0 && pp->acw == 0 && pp->ace == 0)
de++;
/* ... and let go of it on last close */
if ((pp->acr + dr) == 0 && (pp->acw + dw) == 0 && (pp->ace + de) == 0)
de--;
}
LIST_FOREACH_SAFE(cp1, &gp->consumer, consumer, tmp) {
error = g_access(cp1, dr, dw, de);
@@ -678,24 +696,52 @@ g_ventoy_destroy_geom(struct gctl_req *req __unused,
static bool g_vtoy_check_disk(struct g_class *mp, struct g_provider *pp)
{
int i;
int vlnk = 0;
bool ret = true;
uint8_t *buf;
char uuid[64];
const char *value;
struct g_consumer *cp;
struct g_geom *gp;
uint8_t mbrdata[] = {
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,
};
if (g_ventoy_disk_size == 0)
{
if (resource_string_value("ventoy", 0, "disksize", &value) == 0)
if (VENTOY_MAP_VALID(g_ventoy_map_data.magic2))
{
G_DEBUG("ventoy.disksize: %s\n", value);
g_ventoy_disk_size = strtouq(value, NULL, 0);
}
G_DEBUG("ventoy map data is valid. [OK]\n");
if (resource_string_value("ventoy", 0, "diskuuid", &g_ventoy_disk_uuid) == 0)
{
for (i = 0; i < 16; i++)
{
sprintf(uuid + i * 2, "%02x", g_ventoy_map_data.diskuuid[i]);
}
snprintf(g_ventoy_disk_uuid, sizeof(g_ventoy_disk_uuid), "%s", uuid);
g_ventoy_disk_size = g_ventoy_map_data.disksize;
G_DEBUG("ventoy.disksize: %llu\n", (unsigned long long)g_ventoy_disk_size);
G_DEBUG("ventoy.diskuuid: <%s>\n", g_ventoy_disk_uuid);
}
else
{
G_DEBUG("ventoy map data is invalid, get from resource\n");
if (resource_string_value("ventoy", 0, "disksize", &value) == 0)
{
G_DEBUG("ventoy.disksize: %s\n", value);
g_ventoy_disk_size = strtouq(value, NULL, 0);
}
if (resource_string_value("ventoy", 0, "diskuuid", &value) == 0)
{
snprintf(g_ventoy_disk_uuid, sizeof(g_ventoy_disk_uuid), "%s", value);
G_DEBUG("ventoy.diskuuid: <%s>\n", value);
}
}
}
if (g_ventoy_disk_size != pp->mediasize)
@@ -736,14 +782,93 @@ static bool g_vtoy_check_disk(struct g_class *mp, struct g_provider *pp)
{
sprintf(uuid + i * 2, "%02x", buf[0x180 + i]);
}
g_free(buf);
if (strncmp(g_ventoy_disk_uuid, uuid, 32) == 0)
if (strncmp(g_ventoy_disk_uuid, uuid, 32))
{
return true;
ret = false;
}
return false;
if (resource_int_value("ventoy", 0, "vlnk", &vlnk) || (vlnk != 1))
{
if (memcmp(mbrdata, buf, 0x30) || memcmp(mbrdata + 0x30, buf + 0x190, 16))
{
ret = false;
}
}
g_free(buf);
if (ret)
{
G_DEBUG("ventoy disk check OK\n");
}
return ret;
}
struct g_dev_softc {
struct mtx sc_mtx;
struct cdev *sc_dev;
struct cdev *sc_alias;
int sc_open;
int sc_active;
};
static int g_ventoy_devalias(struct g_provider *pp)
{
static int firstflag = 0;
const static char *ventoy_alias = NULL;
static struct g_provider *ventoy_pp = NULL;
struct g_consumer *cp;
struct cdev *adev;
struct g_dev_softc *sc;
if (firstflag == 0)
{
/* hint.ventoy.0.alias=xxx */
if (resource_string_value("ventoy", 0, "alias", &ventoy_alias) == 0)
{
G_DEBUG("###### ventoy alias <%s> ######\n", ventoy_alias);
}
else
{
ventoy_alias = NULL;
}
firstflag = 1;
}
if (!ventoy_alias)
{
return 0;
}
if (!ventoy_pp)
{
if (strcmp(pp->name, "ventoy/IMAGE") == 0)
{
ventoy_pp = pp;
}
return 0;
}
LIST_FOREACH(cp, &ventoy_pp->consumers, consumers) {
if (cp->geom && cp->geom->class && cp->geom->class->name)
{
printf("111 cp->geom->class->name=<%s>\n", cp->geom->class->name);
if (strcmp(cp->geom->class->name, "DEV") == 0)
{
sc = cp->private;
make_dev_alias_p(MAKEDEV_CHECKNAME | MAKEDEV_WAITOK, &adev, sc->sc_dev, "%s", ventoy_alias);
G_DEBUG("Create devalias for ventoy <%s>\n", ventoy_alias);
ventoy_alias = NULL;
break;
}
}
}
return 0;
}
static struct g_geom *
@@ -752,12 +877,15 @@ g_ventoy_taste(struct g_class *mp, struct g_provider *pp, int flags __unused)
int i;
int error;
int disknum;
int remount = 0;
char *endpos;
const char *value;
struct g_geom *gp;
struct g_ventoy_metadata md;
struct g_ventoy_softc *sc;
g_ventoy_devalias(pp);
if (g_ventoy_tasted)
{
return NULL;
@@ -777,9 +905,25 @@ g_ventoy_taste(struct g_class *mp, struct g_provider *pp, int flags __unused)
g_ventoy_tasted = true;
G_DEBUG("######### ventoy disk <%s> #############\n", pp->name);
G_DEBUG("###### ventoy disk <%s> ######\n", pp->name);
resource_int_value("ventoy", 0, "segnum", &disknum);
/* hint.ventoy.0.remount=1 */
if (resource_int_value("ventoy", 0, "remount", &remount) == 0 && remount == 1)
{
g_ventoy_remount = 1;
G_DEBUG("###### ventoy remount enabled ######\n");
}
if (VENTOY_MAP_VALID(g_ventoy_map_data.magic2))
{
disknum = (int)g_ventoy_map_data.segnum;
G_DEBUG("segnum from map data is:<%d>\n", disknum);
}
else
{
resource_int_value("ventoy", 0, "segnum", &disknum);
G_DEBUG("segnum from resource is:<%d>\n", disknum);
}
strlcpy(md.md_magic, G_VENTOY_MAGIC, sizeof(md.md_magic));
md.md_version = G_VENTOY_VERSION;
@@ -801,18 +945,29 @@ g_ventoy_taste(struct g_class *mp, struct g_provider *pp, int flags __unused)
for (i = 0; i < disknum; i ++)
{
if (resource_string_value("ventoy", i, "seg", &value) == 0)
if (VENTOY_MAP_VALID(g_ventoy_map_data.magic2))
{
g_disk_map_start = strtouq(value, &endpos, 0);
g_disk_map_end = strtouq(endpos + 1, NULL, 0);
G_DEBUG("[map] ventoy segment%d: 0x%llx@0x%llx\n", i,
(long long)g_ventoy_map_data.seglist[i].seg_start_bytes,
(long long)g_ventoy_map_data.seglist[i].seg_end_bytes);
g_disk_map_start = (off_t)g_ventoy_map_data.seglist[i].seg_start_bytes;
g_disk_map_end = (off_t)g_ventoy_map_data.seglist[i].seg_end_bytes;
}
else
{
printf("Failed to parse ventoy seg %d\n", i);
continue;
if (resource_string_value("ventoy", i, "seg", &value) == 0)
{
g_disk_map_start = strtouq(value, &endpos, 0);
g_disk_map_end = strtouq(endpos + 1, NULL, 0);
}
else
{
printf("Failed to parse ventoy seg %d\n", i);
continue;
}
G_DEBUG("[resource] ventoy segment%d: %s\n", i, value);
}
G_DEBUG("ventoy segment%d: %s\n", i, value);
G_VENTOY_DEBUG(1, "Adding disk %s to %s.", pp->name, gp->name);
error = g_ventoy_add_disk(sc, pp, i);
@@ -828,7 +983,7 @@ g_ventoy_taste(struct g_class *mp, struct g_provider *pp, int flags __unused)
g_disk_map_end = 0;
}
return (gp);
return (gp);
}
static void
@@ -1066,3 +1221,4 @@ g_ventoy_dumpconf(struct sbuf *sb, const char *indent, struct g_geom *gp,
}
DECLARE_GEOM_CLASS(g_ventoy_class, g_ventoy);
//MODULE_VERSION(geom_ventoy, 0);

View File

@@ -76,6 +76,33 @@ struct g_ventoy_softc {
struct mtx sc_lock;
};
#define sc_name sc_geom->name
#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 {
uint64_t seg_start_bytes;
uint64_t seg_end_bytes;
};
struct g_ventoy_map{
uint32_t magic1[4];
uint32_t magic2[4];
uint64_t segnum;
uint64_t disksize;
uint8_t diskuuid[16];
struct g_ventoy_seg seglist[VENTOY_UNIX_MAX_SEGNUM];
uint32_t magic3[4];
};
#pragma pack()
#define VENTOY_MAP_VALID(magic2) \
(magic2[0] == VENTOY_UNIX_SEG_MAGIC0 && magic2[1] == VENTOY_UNIX_SEG_MAGIC1 && magic2[2] == VENTOY_UNIX_SEG_MAGIC2 && magic2[3] == VENTOY_UNIX_SEG_MAGIC3)
#endif /* _KERNEL */
struct g_ventoy_metadata {

View File

@@ -70,8 +70,9 @@ static bool g_ventoy_tasted = false;
static off_t g_ventoy_disk_size = 0;
static off_t g_disk_map_start = 0;
static off_t g_disk_map_end = 0;
static int g_ventoy_remount = 0;
struct g_ventoy_map g_ventoy_map_data __attribute__((aligned (65536))) =
struct g_ventoy_map g_ventoy_map_data __attribute__((aligned (4096))) =
{
{ VENTOY_UNIX_SEG_MAGIC0, VENTOY_UNIX_SEG_MAGIC1, VENTOY_UNIX_SEG_MAGIC2, VENTOY_UNIX_SEG_MAGIC3 },
{ 0, 0, 0, 0 },
@@ -200,12 +201,19 @@ g_ventoy_access(struct g_provider *pp, int dr, int dw, int de)
g_topology_assert();
gp = pp->geom;
/* On first open, grab an extra "exclusive" bit */
if (pp->acr == 0 && pp->acw == 0 && pp->ace == 0)
de++;
/* ... and let go of it on last close */
if ((pp->acr + dr) == 0 && (pp->acw + dw) == 0 && (pp->ace + de) == 0)
de--;
if (g_ventoy_remount)
{
de = 0;
}
else
{
/* On first open, grab an extra "exclusive" bit */
if (pp->acr == 0 && pp->acw == 0 && pp->ace == 0)
de++;
/* ... and let go of it on last close */
if ((pp->acr + dr) == 0 && (pp->acw + dw) == 0 && (pp->ace + de) == 0)
de--;
}
LIST_FOREACH_SAFE(cp1, &gp->consumer, consumer, tmp) {
error = g_access(cp1, dr, dw, de);
@@ -687,6 +695,7 @@ g_ventoy_destroy_geom(struct gctl_req *req __unused,
static bool g_vtoy_check_disk(struct g_class *mp, struct g_provider *pp)
{
int i;
int vlnk = 0;
bool ret = true;
uint8_t *buf;
char uuid[64];
@@ -778,9 +787,12 @@ static bool g_vtoy_check_disk(struct g_class *mp, struct g_provider *pp)
ret = false;
}
if (memcmp(mbrdata, buf, 0x30) || memcmp(mbrdata + 0x30, buf + 0x190, 16))
if (resource_int_value("ventoy", 0, "vlnk", &vlnk) || (vlnk != 1))
{
ret = false;
if (memcmp(mbrdata, buf, 0x30) || memcmp(mbrdata + 0x30, buf + 0x190, 16))
{
ret = false;
}
}
g_free(buf);
@@ -799,8 +811,10 @@ g_ventoy_taste(struct g_class *mp, struct g_provider *pp, int flags __unused)
int i;
int error;
int disknum;
int remount = 0;
char *endpos;
const char *value;
const char *alias = NULL;
struct g_geom *gp;
struct g_ventoy_metadata md;
struct g_ventoy_softc *sc;
@@ -824,7 +838,24 @@ g_ventoy_taste(struct g_class *mp, struct g_provider *pp, int flags __unused)
g_ventoy_tasted = true;
G_DEBUG("######### ventoy disk <%s> #############\n", pp->name);
G_DEBUG("###### ventoy disk <%s> ######\n", pp->name);
/* hint.ventoy.0.remount=1 */
if (resource_int_value("ventoy", 0, "remount", &remount) == 0 && remount == 1)
{
g_ventoy_remount = 1;
G_DEBUG("###### ventoy remount enabled ######\n");
}
/* hint.ventoy.0.alias=xxx */
if (resource_string_value("ventoy", 0, "alias", &alias) == 0)
{
G_DEBUG("###### ventoy alias <%s> ######\n", alias);
}
else
{
alias = NULL;
}
if (VENTOY_MAP_VALID(g_ventoy_map_data.magic2))
{
@@ -895,7 +926,12 @@ g_ventoy_taste(struct g_class *mp, struct g_provider *pp, int flags __unused)
g_disk_map_end = 0;
}
return (gp);
if (alias)
{
g_geom_add_alias(gp, alias);
}
return (gp);
}
static void

View File

@@ -70,8 +70,9 @@ static bool g_ventoy_tasted = false;
static off_t g_ventoy_disk_size = 0;
static off_t g_disk_map_start = 0;
static off_t g_disk_map_end = 0;
static int g_ventoy_remount = 0;
struct g_ventoy_map g_ventoy_map_data __attribute__((aligned (65536))) =
struct g_ventoy_map g_ventoy_map_data __attribute__((aligned (4096))) =
{
{ VENTOY_UNIX_SEG_MAGIC0, VENTOY_UNIX_SEG_MAGIC1, VENTOY_UNIX_SEG_MAGIC2, VENTOY_UNIX_SEG_MAGIC3 },
{ 0, 0, 0, 0 },
@@ -200,12 +201,19 @@ g_ventoy_access(struct g_provider *pp, int dr, int dw, int de)
g_topology_assert();
gp = pp->geom;
/* On first open, grab an extra "exclusive" bit */
if (pp->acr == 0 && pp->acw == 0 && pp->ace == 0)
de++;
/* ... and let go of it on last close */
if ((pp->acr + dr) == 0 && (pp->acw + dw) == 0 && (pp->ace + de) == 0)
de--;
if (g_ventoy_remount)
{
de = 0;
}
else
{
/* On first open, grab an extra "exclusive" bit */
if (pp->acr == 0 && pp->acw == 0 && pp->ace == 0)
de++;
/* ... and let go of it on last close */
if ((pp->acr + dr) == 0 && (pp->acw + dw) == 0 && (pp->ace + de) == 0)
de--;
}
LIST_FOREACH_SAFE(cp1, &gp->consumer, consumer, tmp) {
error = g_access(cp1, dr, dw, de);
@@ -721,6 +729,7 @@ g_ventoy_destroy_geom(struct gctl_req *req __unused,
static bool g_vtoy_check_disk(struct g_class *mp, struct g_provider *pp)
{
int i;
int vlnk = 0;
bool ret = true;
uint8_t *buf;
char uuid[64];
@@ -812,9 +821,12 @@ static bool g_vtoy_check_disk(struct g_class *mp, struct g_provider *pp)
ret = false;
}
if (memcmp(mbrdata, buf, 0x30) || memcmp(mbrdata + 0x30, buf + 0x190, 16))
if (resource_int_value("ventoy", 0, "vlnk", &vlnk) || (vlnk != 1))
{
ret = false;
if (memcmp(mbrdata, buf, 0x30) || memcmp(mbrdata + 0x30, buf + 0x190, 16))
{
ret = false;
}
}
g_free(buf);
@@ -833,8 +845,10 @@ g_ventoy_taste(struct g_class *mp, struct g_provider *pp, int flags __unused)
int i;
int error;
int disknum;
int remount = 0;
char *endpos;
const char *value;
const char *alias = NULL;
struct g_geom *gp;
struct g_ventoy_metadata md;
struct g_ventoy_softc *sc;
@@ -858,7 +872,24 @@ g_ventoy_taste(struct g_class *mp, struct g_provider *pp, int flags __unused)
g_ventoy_tasted = true;
G_DEBUG("######### ventoy disk <%s> #############\n", pp->name);
G_DEBUG("###### ventoy disk <%s> ######\n", pp->name);
/* hint.ventoy.0.remount=1 */
if (resource_int_value("ventoy", 0, "remount", &remount) == 0 && remount == 1)
{
g_ventoy_remount = 1;
G_DEBUG("###### ventoy remount enabled ######\n");
}
/* hint.ventoy.0.alias=xxx */
if (resource_string_value("ventoy", 0, "alias", &alias) == 0)
{
G_DEBUG("###### ventoy alias <%s> ######\n", alias);
}
else
{
alias = NULL;
}
if (VENTOY_MAP_VALID(g_ventoy_map_data.magic2))
{
@@ -929,7 +960,12 @@ g_ventoy_taste(struct g_class *mp, struct g_provider *pp, int flags __unused)
g_disk_map_end = 0;
}
return (gp);
if (alias && sc && sc->sc_provider)
{
g_provider_add_alias(sc->sc_provider, "%s", alias);
}
return (gp);
}
static void

View File

@@ -65,11 +65,22 @@ static g_taste_t g_ventoy_taste;
static g_ctl_req_t g_ventoy_config;
static g_dumpconf_t g_ventoy_dumpconf;
static const char *g_ventoy_disk_uuid = NULL;
static char g_ventoy_disk_uuid[64];
static bool g_ventoy_tasted = false;
static off_t g_ventoy_disk_size = 0;
static off_t g_disk_map_start = 0;
static off_t g_disk_map_end = 0;
static int g_ventoy_remount = 0;
struct g_ventoy_map g_ventoy_map_data __attribute__((aligned (4096))) =
{
{ VENTOY_UNIX_SEG_MAGIC0, VENTOY_UNIX_SEG_MAGIC1, VENTOY_UNIX_SEG_MAGIC2, VENTOY_UNIX_SEG_MAGIC3 },
{ 0, 0, 0, 0 },
0, 0,
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
{ { 0, 0 } },
{ VENTOY_UNIX_SEG_MAGIC0, VENTOY_UNIX_SEG_MAGIC1, VENTOY_UNIX_SEG_MAGIC2, VENTOY_UNIX_SEG_MAGIC3 }
};
struct g_class g_ventoy_class = {
.name = G_VENTOY_CLASS_NAME,
@@ -191,12 +202,19 @@ g_ventoy_access(struct g_provider *pp, int dr, int dw, int de)
g_topology_assert();
gp = pp->geom;
/* On first open, grab an extra "exclusive" bit */
if (pp->acr == 0 && pp->acw == 0 && pp->ace == 0)
de++;
/* ... and let go of it on last close */
if ((pp->acr + dr) == 0 && (pp->acw + dw) == 0 && (pp->ace + de) == 0)
de--;
if (g_ventoy_remount)
{
de = 0;
}
else
{
/* On first open, grab an extra "exclusive" bit */
if (pp->acr == 0 && pp->acw == 0 && pp->ace == 0)
de++;
/* ... and let go of it on last close */
if ((pp->acr + dr) == 0 && (pp->acw + dw) == 0 && (pp->ace + de) == 0)
de--;
}
LIST_FOREACH_SAFE(cp1, &gp->consumer, consumer, tmp) {
error = g_access(cp1, dr, dw, de);
@@ -642,24 +660,52 @@ g_ventoy_destroy_geom(struct gctl_req *req __unused,
static bool g_vtoy_check_disk(struct g_class *mp, struct g_provider *pp)
{
int i;
int vlnk = 0;
bool ret = true;
uint8_t *buf;
char uuid[64];
const char *value;
struct g_consumer *cp;
struct g_geom *gp;
uint8_t mbrdata[] = {
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,
};
if (g_ventoy_disk_size == 0)
{
if (resource_string_value("ventoy", 0, "disksize", &value) == 0)
if (VENTOY_MAP_VALID(g_ventoy_map_data.magic2))
{
G_DEBUG("ventoy.disksize: %s\n", value);
g_ventoy_disk_size = strtouq(value, NULL, 0);
}
G_DEBUG("ventoy map data is valid. [OK]\n");
if (resource_string_value("ventoy", 0, "diskuuid", &g_ventoy_disk_uuid) == 0)
{
for (i = 0; i < 16; i++)
{
sprintf(uuid + i * 2, "%02x", g_ventoy_map_data.diskuuid[i]);
}
snprintf(g_ventoy_disk_uuid, sizeof(g_ventoy_disk_uuid), "%s", uuid);
g_ventoy_disk_size = g_ventoy_map_data.disksize;
G_DEBUG("ventoy.disksize: %llu\n", (unsigned long long)g_ventoy_disk_size);
G_DEBUG("ventoy.diskuuid: <%s>\n", g_ventoy_disk_uuid);
}
else
{
G_DEBUG("ventoy map data is invalid, get from resource\n");
if (resource_string_value("ventoy", 0, "disksize", &value) == 0)
{
G_DEBUG("ventoy.disksize: %s\n", value);
g_ventoy_disk_size = strtouq(value, NULL, 0);
}
if (resource_string_value("ventoy", 0, "diskuuid", &value) == 0)
{
snprintf(g_ventoy_disk_uuid, sizeof(g_ventoy_disk_uuid), "%s", value);
G_DEBUG("ventoy.diskuuid: <%s>\n", value);
}
}
}
if (g_ventoy_disk_size != pp->mediasize)
@@ -700,14 +746,28 @@ static bool g_vtoy_check_disk(struct g_class *mp, struct g_provider *pp)
{
sprintf(uuid + i * 2, "%02x", buf[0x180 + i]);
}
g_free(buf);
if (strncmp(g_ventoy_disk_uuid, uuid, 32) == 0)
if (strncmp(g_ventoy_disk_uuid, uuid, 32))
{
return true;
ret = false;
}
return false;
if (resource_int_value("ventoy", 0, "vlnk", &vlnk) || (vlnk != 1))
{
if (memcmp(mbrdata, buf, 0x30) || memcmp(mbrdata + 0x30, buf + 0x190, 16))
{
ret = false;
}
}
g_free(buf);
if (ret)
{
G_DEBUG("ventoy disk check OK\n");
}
return ret;
}
static struct g_geom *
@@ -716,8 +776,10 @@ g_ventoy_taste(struct g_class *mp, struct g_provider *pp, int flags __unused)
int i;
int error;
int disknum;
int remount = 0;
char *endpos;
const char *value;
const char *alias = NULL;
struct g_geom *gp;
struct g_ventoy_metadata md;
struct g_ventoy_softc *sc;
@@ -741,9 +803,32 @@ g_ventoy_taste(struct g_class *mp, struct g_provider *pp, int flags __unused)
g_ventoy_tasted = true;
G_DEBUG("######### ventoy disk <%s> #############\n", pp->name);
G_DEBUG("###### ventoy disk <%s> ######\n", pp->name);
resource_int_value("ventoy", 0, "segnum", &disknum);
/* hint.ventoy.0.remount=1 */
if (resource_int_value("ventoy", 0, "remount", &remount) == 0 && remount == 1)
{
g_ventoy_remount = 1;
G_DEBUG("###### ventoy remount enabled ######\n");
}
/* hint.ventoy.0.alias=xxx */
if (resource_string_value("ventoy", 0, "alias", &alias) == 0 && alias)
{
G_DEBUG("###### ventoy alias <%s> ######\n", alias);
setenv("kern.devalias.ventoy/IMAGE", alias);
}
if (VENTOY_MAP_VALID(g_ventoy_map_data.magic2))
{
disknum = (int)g_ventoy_map_data.segnum;
G_DEBUG("segnum from map data is:<%d>\n", disknum);
}
else
{
resource_int_value("ventoy", 0, "segnum", &disknum);
G_DEBUG("segnum from resource is:<%d>\n", disknum);
}
strlcpy(md.md_magic, G_VENTOY_MAGIC, sizeof(md.md_magic));
md.md_version = G_VENTOY_VERSION;
@@ -765,18 +850,29 @@ g_ventoy_taste(struct g_class *mp, struct g_provider *pp, int flags __unused)
for (i = 0; i < disknum; i ++)
{
if (resource_string_value("ventoy", i, "seg", &value) == 0)
if (VENTOY_MAP_VALID(g_ventoy_map_data.magic2))
{
g_disk_map_start = strtouq(value, &endpos, 0);
g_disk_map_end = strtouq(endpos + 1, NULL, 0);
G_DEBUG("[map] ventoy segment%d: 0x%llx@0x%llx\n", i,
(long long)g_ventoy_map_data.seglist[i].seg_start_bytes,
(long long)g_ventoy_map_data.seglist[i].seg_end_bytes);
g_disk_map_start = (off_t)g_ventoy_map_data.seglist[i].seg_start_bytes;
g_disk_map_end = (off_t)g_ventoy_map_data.seglist[i].seg_end_bytes;
}
else
{
printf("Failed to parse ventoy seg %d\n", i);
continue;
if (resource_string_value("ventoy", i, "seg", &value) == 0)
{
g_disk_map_start = strtouq(value, &endpos, 0);
g_disk_map_end = strtouq(endpos + 1, NULL, 0);
}
else
{
printf("Failed to parse ventoy seg %d\n", i);
continue;
}
G_DEBUG("[resource] ventoy segment%d: %s\n", i, value);
}
G_DEBUG("ventoy segment%d: %s\n", i, value);
G_VENTOY_DEBUG(1, "Adding disk %s to %s.", pp->name, gp->name);
error = g_ventoy_add_disk(sc, pp, i);
@@ -792,7 +888,7 @@ g_ventoy_taste(struct g_class *mp, struct g_provider *pp, int flags __unused)
g_disk_map_end = 0;
}
return (gp);
return (gp);
}
static void

View File

@@ -76,6 +76,33 @@ struct g_ventoy_softc {
struct mtx sc_lock;
};
#define sc_name sc_geom->name
#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 {
uint64_t seg_start_bytes;
uint64_t seg_end_bytes;
};
struct g_ventoy_map{
uint32_t magic1[4];
uint32_t magic2[4];
uint64_t segnum;
uint64_t disksize;
uint8_t diskuuid[16];
struct g_ventoy_seg seglist[VENTOY_UNIX_MAX_SEGNUM];
uint32_t magic3[4];
};
#pragma pack()
#define VENTOY_MAP_VALID(magic2) \
(magic2[0] == VENTOY_UNIX_SEG_MAGIC0 && magic2[1] == VENTOY_UNIX_SEG_MAGIC1 && magic2[2] == VENTOY_UNIX_SEG_MAGIC2 && magic2[3] == VENTOY_UNIX_SEG_MAGIC3)
#endif /* _KERNEL */
struct g_ventoy_metadata {

View File

@@ -153,11 +153,23 @@ if [ "$CMD" = "c" ]; then
#check fs
if grep -q " ${FULLDIR} " /proc/mounts; then
DEV=$(grep " ${FULLDIR} " /proc/mounts | awk '{print $1}')
FS=$(grep " ${FULLDIR} " /proc/mounts | awk '{print $3}')
vlog "File system is $FS"
vlog "File system of $DEV is $FS"
if echo $FS | egrep -q "ext2|ext3|ext4|exfat|vfat|fat32|fat16|fat12|ntfs|xfs|udf"; then
vlog "FS OK"
elif [ "$FS" = "fuseblk" ]; then
vlog "$DEV is fuseblk"
if hexdump -C -n 8 $DEV | grep -q "NTFS"; then
vlog "$DEV is NTFS OK"
elif hexdump -C -n 8 $DEV | grep -q "EXFAT"; then
vlog "$DEV is exFAT OK"
else
echo "$DEV is not supported!"
hexdump -C -n 8 $DEV
exit 1
fi
else
echo "$FS is not supported!"
exit 1

View File

@@ -13,12 +13,18 @@ static CHAR g_LogFile[MAX_PATH];
static HWND g_create_button;
static HWND g_parse_button;
static BOOL g_ShowHelp = FALSE;
static BOOL g_SaveAs = FALSE;
static WCHAR g_CmdInFile[MAX_PATH];
static WCHAR g_CmdOutFile[MAX_PATH];
typedef enum MSGID
{
MSGID_ERROR = 0,
MSGID_INFO,
MSGID_BTN_CREATE,
MSGID_BTN_PARSE,
MSGID_SRC_NONEXIST,
MSGID_SRC_UNSUPPORTED,
MSGID_FS_UNSUPPORTED,
MSGID_SUFFIX_UNSUPPORTED,
@@ -31,6 +37,7 @@ typedef enum MSGID
MSGID_VLNK_POINT_TO,
MSGID_VLNK_NO_DST,
MSGID_FILE_NAME_TOO_LONG,
MSGID_INVALID_SUFFIX,
MSGID_BUTT
}MSGID;
@@ -42,6 +49,7 @@ const WCHAR *g_msg_cn[MSGID_BUTT] =
L"<EFBFBD><EFBFBD><EFBFBD><EFBFBD>",
L"<EFBFBD><EFBFBD><EFBFBD><EFBFBD>",
L"<EFBFBD><EFBFBD><EFBFBD><EFBFBD>",
L"ָ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>",
L"<EFBFBD><EFBFBD>֧<EFBFBD><EFBFBD>Ϊ<EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>vlnk",
L"<EFBFBD><EFBFBD>֧<EFBFBD>ֵ<EFBFBD><EFBFBD>ļ<EFBFBD>ϵͳ",
L"<EFBFBD><EFBFBD>֧<EFBFBD>ֵ<EFBFBD><EFBFBD>ļ<EFBFBD><EFBFBD><EFBFBD>׺<EFBFBD><EFBFBD>",
@@ -54,6 +62,7 @@ const WCHAR *g_msg_cn[MSGID_BUTT] =
L"<EFBFBD><EFBFBD> vlnk <20>ļ<EFBFBD>ָ<EFBFBD><D6B8> ",
L"<EFBFBD><EFBFBD> vlnk ָ<><D6B8><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڣ<EFBFBD>",
L"<EFBFBD>ļ<EFBFBD>·<EFBFBD><EFBFBD>̫<EFBFBD><EFBFBD><EFBFBD><EFBFBD>",
L"<EFBFBD>Ƿ<EFBFBD><EFBFBD><EFBFBD>vlnk<EFBFBD>ļ<EFBFBD><EFBFBD><EFBFBD>׺<EFBFBD><EFBFBD>!",
};
const WCHAR *g_msg_en[MSGID_BUTT] =
{
@@ -61,6 +70,7 @@ const WCHAR *g_msg_en[MSGID_BUTT] =
L"Info",
L"Create",
L"Parse",
L"The specified file is not exist!",
L"This file is not supported for vlnk",
L"Unsupported file system!",
L"Unsupported file suffix!",
@@ -73,11 +83,28 @@ const WCHAR *g_msg_en[MSGID_BUTT] =
L"The vlnk file point to ",
L"The file pointed by the vlnk does NOT exist!",
L"The file full path is too long!",
L"Invalid vlnk file suffix!",
};
const WCHAR **g_msg_lang = NULL;
HINSTANCE g_hInst;
static int VtoyMessageBox
(
_In_opt_ HWND hWnd,
_In_opt_ LPCWSTR lpText,
_In_opt_ LPCWSTR lpCaption,
_In_ UINT uType
)
{
if (g_CmdInFile[0] && g_CmdOutFile[0])
{
return 0;
}
return MessageBox(hWnd, lpText, lpCaption, uType);
}
static void Log2File(const char *log)
{
@@ -340,11 +367,62 @@ End:
}
static int CreateVlnk(HWND hWnd, WCHAR *Dir)
static BOOL VentoyGetSaveFileName(HWND hWnd, WCHAR *szFile)
{
OPENFILENAME ofn = { 0 };
ofn.lStructSize = sizeof(ofn);
ofn.hwndOwner = hWnd;
ofn.lpstrFilter = L"Vlnk File\0*.vlnk.iso;*.vlnk.img;*.vlnk.wim;*.vlnk.efi;*.vlnk.vhd;*.vlnk.vhdx;*.vlnk.vtoy;*.vlnk.dat\0";
ofn.nFilterIndex = 1;
ofn.lpstrFile = szFile;
ofn.nMaxFile = MAX_PATH;
ofn.Flags = OFN_EXPLORER | OFN_PATHMUSTEXIST | OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT;
ofn.lpstrFileTitle = NULL;
ofn.nMaxFileTitle = 0;
ofn.lpstrInitialDir = NULL;
return GetSaveFileName(&ofn);
}
static BOOL IsSupportedVlnkSuffix(WCHAR *FileName)
{
int len;
len = lstrlen(FileName);
if (len > 9)
{
if (lstrcmp(FileName + len - 9, L".vlnk.iso") == 0 ||
lstrcmp(FileName + len - 9, L".vlnk.img") == 0 ||
lstrcmp(FileName + len - 9, L".vlnk.wim") == 0 ||
lstrcmp(FileName + len - 9, L".vlnk.vhd") == 0 ||
lstrcmp(FileName + len - 9, L".vlnk.efi") == 0 ||
lstrcmp(FileName + len - 9, L".vlnk.dat") == 0)
{
return TRUE;
}
}
if (len > 10)
{
if (lstrcmp(FileName + len - 10, L".vlnk.vhdx") == 0 ||
lstrcmp(FileName + len - 10, L".vlnk.vtoy") == 0)
{
return TRUE;
}
}
return FALSE;
}
static int CreateVlnk(HWND hWnd, WCHAR *Dir, WCHAR *InFile, WCHAR *OutFile)
{
int i;
int end;
int len;
BOOL SetOutFile = FALSE;
UINT32 DiskSig;
DISK_EXTENT DiskExtend;
OPENFILENAME ofn = { 0 };
@@ -358,20 +436,27 @@ static int CreateVlnk(HWND hWnd, WCHAR *Dir)
WCHAR *Pos = NULL;
ventoy_vlnk *vlnk = NULL;
ofn.lStructSize = sizeof(ofn);
ofn.hwndOwner = hWnd;
ofn.lpstrFile = szFile;
ofn.nMaxFile = sizeof(szFile);
ofn.lpstrFilter = L"Vlnk Source File\0*.iso;*.img;*.wim;*.vhd;*.vhdx;*.vtoy;*.efi;*.dat\0";
ofn.nFilterIndex = 1;
ofn.lpstrFileTitle = NULL;
ofn.nMaxFileTitle = 0;
ofn.lpstrInitialDir = NULL;
ofn.Flags = OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST;
if (GetOpenFileName(&ofn) != TRUE)
if (InFile)
{
return 1;
wcscpy_s(szFile, MAX_PATH, InFile);
}
else
{
ofn.lStructSize = sizeof(ofn);
ofn.hwndOwner = hWnd;
ofn.lpstrFile = szFile;
ofn.nMaxFile = sizeof(szFile);
ofn.lpstrFilter = L"Vlnk Source File\0*.iso;*.img;*.wim;*.vhd;*.vhdx;*.vtoy;*.efi;*.dat\0";
ofn.nFilterIndex = 1;
ofn.lpstrFileTitle = NULL;
ofn.nMaxFileTitle = 0;
ofn.lpstrInitialDir = NULL;
ofn.Flags = OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST;
if (GetOpenFileName(&ofn) != TRUE)
{
return 1;
}
}
LogW(L"Create vlnk for <%ls>\n", szFile);
@@ -380,7 +465,7 @@ static int CreateVlnk(HWND hWnd, WCHAR *Dir)
if (len < 5 || szFile[0] == '.' || szFile[1] != ':')
{
MessageBox(hWnd, g_msg_lang[MSGID_SRC_UNSUPPORTED], g_msg_lang[MSGID_ERROR], MB_OK | MB_ICONERROR);
VtoyMessageBox(hWnd, g_msg_lang[MSGID_SRC_UNSUPPORTED], g_msg_lang[MSGID_ERROR], MB_OK | MB_ICONERROR);
return 1;
}
@@ -406,7 +491,7 @@ static int CreateVlnk(HWND hWnd, WCHAR *Dir)
}
else
{
MessageBox(hWnd, g_msg_lang[MSGID_FS_UNSUPPORTED], g_msg_lang[MSGID_ERROR], MB_OK | MB_ICONERROR);
VtoyMessageBox(hWnd, g_msg_lang[MSGID_FS_UNSUPPORTED], g_msg_lang[MSGID_ERROR], MB_OK | MB_ICONERROR);
return 1;
}
@@ -419,13 +504,13 @@ static int CreateVlnk(HWND hWnd, WCHAR *Dir)
if (!IsSupportedImgSuffix(suffix))
{
MessageBox(hWnd, g_msg_lang[MSGID_SUFFIX_UNSUPPORTED], g_msg_lang[MSGID_ERROR], MB_OK | MB_ICONERROR);
VtoyMessageBox(hWnd, g_msg_lang[MSGID_SUFFIX_UNSUPPORTED], g_msg_lang[MSGID_ERROR], MB_OK | MB_ICONERROR);
return 1;
}
if (IsVlnkFile(szFile, NULL))
{
MessageBox(hWnd, g_msg_lang[MSGID_ALREADY_VLNK], g_msg_lang[MSGID_ERROR], MB_OK | MB_ICONERROR);
VtoyMessageBox(hWnd, g_msg_lang[MSGID_ALREADY_VLNK], g_msg_lang[MSGID_ERROR], MB_OK | MB_ICONERROR);
return 1;
}
@@ -459,17 +544,18 @@ static int CreateVlnk(HWND hWnd, WCHAR *Dir)
if (len >= VLNK_NAME_MAX)
{
LogA("File name length %d overflow\n", len);
MessageBox(hWnd, g_msg_lang[MSGID_FILE_NAME_TOO_LONG], g_msg_lang[MSGID_ERROR], MB_OK | MB_ICONERROR);
VtoyMessageBox(hWnd, g_msg_lang[MSGID_FILE_NAME_TOO_LONG], g_msg_lang[MSGID_ERROR], MB_OK | MB_ICONERROR);
return 1;
}
DiskExtend.StartingOffset.QuadPart = 0;
if (GetPhyDiskInfo((char)szFile[0], &DiskSig, &DiskExtend))
{
MessageBox(hWnd, g_msg_lang[MSGID_DISK_INFO_ERR], g_msg_lang[MSGID_ERROR], MB_OK | MB_ICONERROR);
VtoyMessageBox(hWnd, g_msg_lang[MSGID_DISK_INFO_ERR], g_msg_lang[MSGID_ERROR], MB_OK | MB_ICONERROR);
return 1;
}
Buf = malloc(VLNK_FILE_LEN);
if (Buf)
{
@@ -477,24 +563,65 @@ static int CreateVlnk(HWND hWnd, WCHAR *Dir)
vlnk = (ventoy_vlnk *)Buf;
ventoy_create_vlnk(DiskSig, (uint64_t)DiskExtend.StartingOffset.QuadPart, UTF8Path, vlnk);
DefaultVlnkDstFullPath(Pos + 1, Dir, DstFullPath);
if (OutFile)
{
wcscpy_s(DstFullPath, MAX_PATH, OutFile);
SetOutFile = TRUE;
}
else
{
DefaultVlnkDstFullPath(Pos + 1, Dir, DstFullPath);
if (g_SaveAs)
{
wcscpy_s(szFile, MAX_PATH, DstFullPath);
if (VentoyGetSaveFileName(hWnd, szFile))
{
if (IsSupportedVlnkSuffix(szFile))
{
wcscpy_s(DstFullPath, MAX_PATH, szFile);
SetOutFile = TRUE;
}
else
{
VtoyMessageBox(hWnd, g_msg_lang[MSGID_INVALID_SUFFIX], g_msg_lang[MSGID_ERROR], MB_OK | MB_ICONERROR);
LogA("Invalid vlnk suffix\n");
goto end;
}
}
else
{
LogA("User cancel the save as diaglog, use default name\n");
}
}
}
LogW(L"vlnk output file path is <%ls>\n", DstFullPath);
if (SaveBuffer2File(DstFullPath, Buf, VLNK_FILE_LEN) == 0)
{
WCHAR Msg[1024];
swprintf_s(Msg, 1024, L"%ls\r\n\r\n%ls", g_msg_lang[MSGID_VLNK_SUCCESS], DstFullPath + lstrlen(Dir) + 1);
LogW(L"Vlnk file create success <%ls>\n", DstFullPath);
MessageBox(hWnd, Msg, g_msg_lang[MSGID_INFO], MB_OK | MB_ICONINFORMATION);
if (SetOutFile)
{
swprintf_s(Msg, 1024, L"%ls\r\n\r\n%ls", g_msg_lang[MSGID_VLNK_SUCCESS], DstFullPath);
VtoyMessageBox(hWnd, Msg, g_msg_lang[MSGID_INFO], MB_OK | MB_ICONINFORMATION);
}
else
{
swprintf_s(Msg, 1024, L"%ls\r\n\r\n%ls", g_msg_lang[MSGID_VLNK_SUCCESS], DstFullPath + lstrlen(Dir) + 1);
VtoyMessageBox(hWnd, Msg, g_msg_lang[MSGID_INFO], MB_OK | MB_ICONINFORMATION);
}
}
else
{
LogA("Vlnk file save failed\n");
MessageBox(hWnd, g_msg_lang[MSGID_CREATE_FILE_ERR], g_msg_lang[MSGID_ERROR], MB_OK | MB_ICONERROR);
VtoyMessageBox(hWnd, g_msg_lang[MSGID_CREATE_FILE_ERR], g_msg_lang[MSGID_ERROR], MB_OK | MB_ICONERROR);
}
end:
free(Buf);
}
@@ -534,7 +661,6 @@ static CHAR GetDriveLetter(UINT32 disksig, UINT64 PartOffset)
return 0;
}
static int ParseVlnk(HWND hWnd)
{
int i;
@@ -567,7 +693,7 @@ static int ParseVlnk(HWND hWnd)
if (!IsVlnkFile(szFile, &vlnk))
{
MessageBox(hWnd, g_msg_lang[MSGID_INVALID_VLNK], g_msg_lang[MSGID_ERROR], MB_OK | MB_ICONERROR);
VtoyMessageBox(hWnd, g_msg_lang[MSGID_INVALID_VLNK], g_msg_lang[MSGID_ERROR], MB_OK | MB_ICONERROR);
return 1;
}
@@ -581,7 +707,7 @@ static int ParseVlnk(HWND hWnd)
if (!IsSupportedImgSuffix(suffix))
{
MessageBox(hWnd, g_msg_lang[MSGID_SUFFIX_UNSUPPORTED], g_msg_lang[MSGID_ERROR], MB_OK | MB_ICONERROR);
VtoyMessageBox(hWnd, g_msg_lang[MSGID_SUFFIX_UNSUPPORTED], g_msg_lang[MSGID_ERROR], MB_OK | MB_ICONERROR);
return 1;
}
@@ -598,7 +724,7 @@ static int ParseVlnk(HWND hWnd)
Letter = GetDriveLetter(vlnk.disk_signature, vlnk.part_offset);
if (Letter == 0)
{
MessageBox(hWnd, g_msg_lang[MSGID_VLNK_NO_DST], g_msg_lang[MSGID_ERROR], MB_OK | MB_ICONERROR);
VtoyMessageBox(hWnd, g_msg_lang[MSGID_VLNK_NO_DST], g_msg_lang[MSGID_ERROR], MB_OK | MB_ICONERROR);
return 1;
}
@@ -609,13 +735,13 @@ static int ParseVlnk(HWND hWnd)
hFile = CreateFileW(szDst, FILE_READ_EA, FILE_SHARE_READ, 0, OPEN_EXISTING, 0, 0);
if (INVALID_HANDLE_VALUE == hFile)
{
MessageBox(hWnd, g_msg_lang[MSGID_VLNK_NO_DST], g_msg_lang[MSGID_ERROR], MB_OK | MB_ICONERROR);
VtoyMessageBox(hWnd, g_msg_lang[MSGID_VLNK_NO_DST], g_msg_lang[MSGID_ERROR], MB_OK | MB_ICONERROR);
return 1;
}
CloseHandle(hFile);
swprintf_s(Msg, 1024, L"%ls %ls", g_msg_lang[MSGID_VLNK_POINT_TO], szDst);
MessageBox(hWnd, Msg, g_msg_lang[MSGID_INFO], MB_OK | MB_ICONINFORMATION);
VtoyMessageBox(hWnd, Msg, g_msg_lang[MSGID_INFO], MB_OK | MB_ICONINFORMATION);
return 0;
}
@@ -637,7 +763,7 @@ INT_PTR CALLBACK DialogProc(HWND hWnd, UINT Message, WPARAM wParam, LPARAM lPara
if (CtrlID == IDC_BUTTON1)
{
EnableWindow(g_create_button, FALSE);
CreateVlnk(hWnd, g_CurDirW);
CreateVlnk(hWnd, g_CurDirW, NULL, NULL);
EnableWindow(g_create_button, TRUE);
}
else if (CtrlID == IDC_BUTTON2)
@@ -664,9 +790,50 @@ INT_PTR CALLBACK DialogProc(HWND hWnd, UINT Message, WPARAM wParam, LPARAM lPara
return 0;
}
int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, INT nCmdShow)
static int ParseCmdLine(LPSTR lpCmdLine)
{
int i;
int argc = 0;
LPWSTR *lpszArgv = NULL;
lpszArgv = CommandLineToArgvW(GetCommandLineW(), &argc);
for (i = 0; i < argc; i++)
{
if (lstrcmp(lpszArgv[i], L"-q") == 0 || lstrcmp(lpszArgv[i], L"-Q") == 0)
{
g_LogFile[0] = 0;
}
else if (lstrcmp(lpszArgv[i], L"-h") == 0 || lstrcmp(lpszArgv[i], L"-H") == 0)
{
g_ShowHelp = TRUE;
}
else if (lstrcmp(lpszArgv[i], L"-s") == 0 || lstrcmp(lpszArgv[i], L"-S") == 0)
{
g_SaveAs = TRUE;
}
else if (lstrcmp(lpszArgv[i], L"-i") == 0 || lstrcmp(lpszArgv[i], L"-I") == 0)
{
if (i + 1 < argc)
{
wcscpy_s(g_CmdInFile, MAX_PATH, lpszArgv[i + 1]);
}
}
else if (lstrcmp(lpszArgv[i], L"-o") == 0 || lstrcmp(lpszArgv[i], L"-O") == 0)
{
if (i + 1 < argc)
{
wcscpy_s(g_CmdOutFile, MAX_PATH, lpszArgv[i + 1]);
}
}
}
return argc;
}
int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, INT nCmdShow)
{
DWORD dwAttrib;
HANDLE hMutex;
UNREFERENCED_PARAMETER(hPrevInstance);
@@ -680,32 +847,52 @@ int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLi
g_msg_lang = g_msg_en;
}
hMutex = CreateMutexA(NULL, TRUE, "VtoyVlnkMUTEX");
if ((hMutex != NULL) && (GetLastError() == ERROR_ALREADY_EXISTS))
{
MessageBoxW(NULL, g_msg_lang[MSGID_RUNNING_TIP], g_msg_lang[MSGID_ERROR], MB_OK | MB_ICONERROR);
return 1;
}
hMutex = CreateMutexA(NULL, TRUE, "VtoyVlnkMUTEX");
if ((hMutex != NULL) && (GetLastError() == ERROR_ALREADY_EXISTS))
{
MessageBoxW(NULL, g_msg_lang[MSGID_RUNNING_TIP], g_msg_lang[MSGID_ERROR], MB_OK | MB_ICONERROR);
return 1;
}
GetCurrentDirectoryA(MAX_PATH, g_CurDirA);
GetCurrentDirectoryW(MAX_PATH, g_CurDirW);
sprintf_s(g_LogFile, sizeof(g_LogFile), "%s\\VentoyVlnk.log", g_CurDirA);
for (i = 0; i < __argc; i++)
{
if (strncmp(__argv[i], "-Q", 2) == 0 ||
strncmp(__argv[i], "-q", 2) == 0)
{
g_LogFile[0] = 0;
break;
}
}
ParseCmdLine(lpCmdLine);
LogA("========= VentoyVlnk =========\n");
g_hInst = hInstance;
DialogBoxA(hInstance, MAKEINTRESOURCEA(IDD_DIALOG1), NULL, DialogProc);
return 0;
if (g_ShowHelp)
{
VtoyMessageBox(NULL, L"VentoyVlnk.exe CMD\r\n -i Input file path\r\n -o Output vlnk file path\r\n -q Quite mode (no log)", L"Tip", MB_OK);
return 0;
}
else if (g_CmdInFile[0] && g_CmdOutFile[0])
{
LogA("========= VentoyVlnk Cmdline Mode =========\n");
dwAttrib = GetFileAttributesW(g_CmdInFile);
if (dwAttrib == INVALID_FILE_ATTRIBUTES || (dwAttrib & FILE_ATTRIBUTE_DIRECTORY))
{
LogW(L"File <<%ls>> does not exist!\n", g_CmdInFile);
VtoyMessageBox(NULL, g_msg_lang[MSGID_SRC_NONEXIST], g_msg_lang[MSGID_ERROR], MB_OK | MB_ICONERROR);
return 1;
}
if (!IsSupportedVlnkSuffix(g_CmdOutFile))
{
LogW(L"File <<%ls>> contains invalid vlnk suffix!\n", g_CmdOutFile);
VtoyMessageBox(NULL, g_msg_lang[MSGID_INVALID_SUFFIX], g_msg_lang[MSGID_ERROR], MB_OK | MB_ICONERROR);
return 1;
}
return CreateVlnk(NULL, g_CurDirW, g_CmdInFile, g_CmdOutFile);
}
else
{
LogA("========= VentoyVlnk GUI Mode =========\n");
DialogBoxA(hInstance, MAKEINTRESOURCEA(IDD_DIALOG1), NULL, DialogProc);
return 0;
}
}

View File

@@ -1418,6 +1418,40 @@ End:
return Ret;
}
static BOOL CheckVentoyDisk(DWORD DiskNum)
{
DWORD dwSize = 0;
CHAR PhyPath[128];
UINT8 SectorBuf[512];
HANDLE Handle;
UINT8 check[8] = { 0x56, 0x54, 0x00, 0x47, 0x65, 0x00, 0x48, 0x44 };
sprintf_s(PhyPath, sizeof(PhyPath), "\\\\.\\PhysicalDrive%d", DiskNum);
Handle = CreateFileA(PhyPath, GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE, 0, OPEN_EXISTING, 0, 0);
if (Handle == INVALID_HANDLE_VALUE)
{
Log("Could not open the disk<%s>, error:%u", PhyPath, GetLastError());
return FALSE;
}
if (!ReadFile(Handle, SectorBuf, sizeof(SectorBuf), &dwSize, NULL))
{
Log("ReadFile failed, dwSize:%u error:%u", dwSize, GetLastError());
CloseHandle(Handle);
return FALSE;
}
CloseHandle(Handle);
if (memcmp(SectorBuf + 0x190, check, 8) == 0)
{
return TRUE;
}
return FALSE;
}
static int VentoyHook(ventoy_os_param *param)
{
int i;
@@ -1429,6 +1463,7 @@ static int VentoyHook(ventoy_os_param *param)
CHAR VtoyLetter;
DWORD Drives;
DWORD NewDrives;
DWORD VtoyDiskNum;
UINT32 DiskSig;
UINT32 VtoySig;
DISK_EXTENT DiskExtent;
@@ -1457,6 +1492,8 @@ static int VentoyHook(ventoy_os_param *param)
if (IsFileExist("%s", IsoPath))
{
Log("File exist under %C:", Letter);
memset(UUID, 0, sizeof(UUID));
memset(&DiskExtent, 0, sizeof(DiskExtent));
if (GetPhyDiskUUID(Letter, UUID, NULL, &DiskExtent) == 0)
{
if (memcmp(UUID, param->vtoy_disk_guid, 16) == 0)
@@ -1510,6 +1547,9 @@ static int VentoyHook(ventoy_os_param *param)
{
if (Drives & 0x01)
{
memset(UUID, 0, sizeof(UUID));
memset(&VtoyDiskExtent, 0, sizeof(VtoyDiskExtent));
DiskSig = 0;
if (GetPhyDiskUUID(VtoyLetter, UUID, &DiskSig, &VtoyDiskExtent) == 0)
{
Log("DiskSig=%08X PartStart=%lld", DiskSig, VtoyDiskExtent.StartingOffset.QuadPart);
@@ -1543,17 +1583,31 @@ static int VentoyHook(ventoy_os_param *param)
Log("Failed to find ventoy disk");
return 1;
}
VtoyDiskNum = VtoyDiskExtent.DiskNumber;
}
else
{
VtoyLetter = Letter;
Log("No vlnk mode %C", Letter);
VtoyDiskNum = DiskExtent.DiskNumber;
}
if (CheckVentoyDisk(VtoyDiskNum))
{
Log("Disk check OK %C: %u", VtoyLetter, VtoyDiskNum);
}
else
{
Log("Failed to check ventoy disk %u", VtoyDiskNum);
return 1;
}
Drives = GetLogicalDrives();
Log("Drives before mount: 0x%x", Drives);
rc = MountIsoFile(IsoPath, DiskExtent.DiskNumber);
rc = MountIsoFile(IsoPath, VtoyDiskNum);
NewDrives = GetLogicalDrives();
Log("Drives after mount: 0x%x (0x%x)", NewDrives, (NewDrives ^ Drives));
@@ -1588,7 +1642,7 @@ static int VentoyHook(ventoy_os_param *param)
}
// for protect
rc = DeleteVentoyPart2MountPoint(VtoyDiskExtent.DiskNumber);
rc = DeleteVentoyPart2MountPoint(VtoyDiskNum);
Log("Delete ventoy mountpoint: %s", rc == 0 ? "SUCCESS" : "NO NEED");
if (g_windows_data.auto_install_script[0])
@@ -1615,7 +1669,7 @@ static int VentoyHook(ventoy_os_param *param)
if (IsFileExist("%s", IsoPath))
{
Log("decompress injection archive %s...", IsoPath);
DecompressInjectionArchive(IsoPath, VtoyDiskExtent.DiskNumber);
DecompressInjectionArchive(IsoPath, VtoyDiskNum);
if (IsFileExist("%s", AUTO_RUN_BAT))
{

View File

@@ -62,7 +62,9 @@ typedef struct ventoy_os_param
UINT64 vtoy_reserved[4]; // Internal use by ventoy
UINT8 reserved[31];
UINT8 vtoy_disk_signature[4];
UINT8 reserved[27];
}ventoy_os_param;
typedef struct ventoy_windows_data