mirror of
https://github.com/ventoy/Ventoy.git
synced 2025-09-16 09:01:15 +00:00
Compare commits
15 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
c84855bbee | ||
|
f2ed81b004 | ||
|
6434e453b2 | ||
|
041ccb7435 | ||
|
bfe194c190 | ||
|
fb7008f49a | ||
|
463d0b2004 | ||
|
4707b76bb2 | ||
|
ff0ad76d8d | ||
|
c8b2cca7c2 | ||
|
afbeba7cf5 | ||
|
bb3789f6fc | ||
|
ea8a9e83ab | ||
|
8b9901a6a5 | ||
|
0ac83bffda |
@@ -1,20 +1,36 @@
|
||||
======== Build busybox 1.32 for aarch64 ========
|
||||
|
||||
ARCH=arm64 CROSS_COMPILE=aarch64-linux- make defconfig
|
||||
ARCH=arm64 CROSS_COMPILE=aarch64-linux- make menuconfig
|
||||
----> enable static build
|
||||
----> enable ar
|
||||
----> enable inotifyd
|
||||
|
||||
======== How to build ash/hexdump/xzcat for aarch64 ========
|
||||
#How to get ash.config/hexdump.cofig/xzcat.config
|
||||
#ARCH=arm64 CROSS_COMPILE=aarch64-linux- make allnoconfig
|
||||
#ARCH=arm64 CROSS_COMPILE=aarch64-linux- make menuconfig
|
||||
#----> enable static build
|
||||
#----> enable xzcat
|
||||
#get aarch64_xzcat.config
|
||||
|
||||
tar xf busybox-1.32.0.tar.bz2
|
||||
cd busybox-1.32.0
|
||||
copy aarch64_xzcat.config as .config
|
||||
ARCH=arm64 CROSS_COMPILE=aarch64-linux- make
|
||||
rename ./busybox to xzcat
|
||||
|
||||
|
||||
|
||||
|
||||
ARCH=arm64 CROSS_COMPILE=aarch64-linux- make allnoconfig
|
||||
======== How to build ash/hexdump/xzcat for x86_64 ==========
|
||||
#How to get ash.config/hexdump.cofig/xzcat.config
|
||||
#make allnoconfig
|
||||
#make menuconfig
|
||||
#----> enable static build
|
||||
#----> enable xzcat
|
||||
#get x86_64_xzcat.config
|
||||
|
||||
|
||||
======== use mini-native-x86_64 uclibc to build ash/hexdump/busybox for x86_64 ==========
|
||||
tar xf busybox-1.32.0.tar.bz2
|
||||
cd busybox-1.32.0
|
||||
copy x86_64_xzcat.config as .config
|
||||
modify Makefile
|
||||
CC = gcc -specs "/usr/local/musl/lib/musl-gcc.specs"
|
||||
MODFLAGS = -DMODULE -specs "/usr/local/musl/lib/musl-gcc.specs"
|
||||
make
|
||||
rename ./busybox to xzcat
|
||||
|
||||
|
||||
|
||||
|
@@ -2,7 +2,7 @@
|
||||
|
||||
DSTDIR=../../IMG/cpio/ventoy/busybox
|
||||
|
||||
rm -f vtchmod32 vtchmod64 vtchmodaa64
|
||||
rm -f vtchmod32 vtchmod64 vtchmod64_musl vtchmodaa64
|
||||
rm -f $DSTDIR/vtchmod32 $DSTDIR/vtchmod64 $DSTDIR/vtchmodaa64
|
||||
|
||||
/opt/diet32/bin/diet gcc -Os -m32 vtchmod.c -o vtchmod32
|
||||
@@ -10,12 +10,16 @@ rm -f $DSTDIR/vtchmod32 $DSTDIR/vtchmod64 $DSTDIR/vtchmodaa64
|
||||
aarch64-linux-gcc -Os -static vtchmod.c -o vtchmodaa64
|
||||
aarch64-linux-strip --strip-all vtchmodaa64
|
||||
|
||||
gcc -specs "/usr/local/musl/lib/musl-gcc.specs" -Os -static vtchmod.c -o vtchmod64_musl
|
||||
strip --strip-all vtchmod64_musl
|
||||
|
||||
chmod 777 vtchmod32
|
||||
chmod 777 vtchmod64
|
||||
chmod 777 vtchmodaa64
|
||||
chmod 777 vtchmod64_musl
|
||||
|
||||
cp -a vtchmod32 $DSTDIR/
|
||||
cp -a vtchmod64 $DSTDIR/
|
||||
cp -a vtchmodaa64 $DSTDIR/
|
||||
cp -a vtchmod64_musl $DSTDIR/
|
||||
|
||||
|
BIN
BUSYBOX/chmod/vtchmod64_musl
Normal file
BIN
BUSYBOX/chmod/vtchmod64_musl
Normal file
Binary file not shown.
@@ -36,20 +36,16 @@ build for 32bit, static linked with dietlibc
|
||||
|
||||
|
||||
======================== Build for 64bit dmsetup =========================
|
||||
https://www.uclibc.org/downloads/binaries/0.9.30.1/mini-native-x86_64.tar.bz2
|
||||
1. extract device mapper source code
|
||||
2. extract mini-native-x86_64.tar.bz2
|
||||
3. chroot to mini-native-x86_64
|
||||
3. ./configure --disable-nls --disable-selinux --disable-shared --enable-static_link
|
||||
2. ./configure --disable-nls --disable-selinux --disable-shared --enable-static_link CC='gcc -specs /usr/local/musl/lib/musl-gcc.specs'
|
||||
3. touch include/linux/limits.h include/linux/types.h
|
||||
echo '#include <sys/mount.h>' > include/linux/fs.h
|
||||
4. make
|
||||
5. strip dmsetup/dmsetup.static
|
||||
5. strip --strip-all dmsetup/dmsetup.static
|
||||
6. get dmsetup/dmsetup.static as the dmsetup64 binary file
|
||||
|
||||
|
||||
|
||||
|
||||
======================== Build for arm64 dmsetup =========================
|
||||
https://www.uclibc.org/downloads/binaries/0.9.30.1/mini-native-x86_64.tar.bz2
|
||||
1. extract device mapper source code
|
||||
2. ./configure CC=aarch64-linux-gcc --target=arm --host=x86_64-linux-gnu --disable-nls --disable-selinux --disable-shared --enable-static_link
|
||||
3. modify include/configure.h file
|
||||
|
Binary file not shown.
@@ -27,6 +27,7 @@
|
||||
2.2 Download third-part source code
|
||||
|
||||
https://www.fefe.de/dietlibc/dietlibc-0.34.tar.xz ===> /home/Ventoy-master/DOC/dietlibc-0.34.tar.xz
|
||||
https://musl.libc.org/releases/musl-1.2.1.tar.gz ===> /home/Ventoy-master/DOC/musl-1.2.1.tar.gz
|
||||
https://ftp.gnu.org/gnu/grub/grub-2.04.tar.xz ===> /home/Ventoy-master/GRUB2/grub-2.04.tar.xz
|
||||
https://codeload.github.com/tianocore/edk2/zip/edk2-stable201911 ===> /home/Ventoy-master/EDK2/edk2-edk2-stable201911.zip
|
||||
https://codeload.github.com/relan/exfat/zip/v1.3.0 ===> /home/Ventoy-master/ExFAT/exfat-1.3.0.zip
|
||||
@@ -34,6 +35,19 @@
|
||||
https://releases.linaro.org/components/toolchain/binaries/7.4-2019.02/aarch64-linux-gnu/gcc-linaro-7.4.1-2019.02-x86_64_aarch64-linux-gnu.tar.xz ===> /opt/gcc-linaro-7.4.1-2019.02-x86_64_aarch64-linux-gnu.tar.xz
|
||||
https://toolchains.bootlin.com/downloads/releases/toolchains/aarch64/tarballs/aarch64--uclibc--stable-2020.08-1.tar.bz2 ===> /opt/aarch64--uclibc--stable-2020.08-1.tar.bz2
|
||||
|
||||
2.3 Prepare third-part tools
|
||||
cd /home/Ventoy-master/DOC/
|
||||
tar xf musl-1.2.1.tar.gz
|
||||
cd musl-1.2.1
|
||||
./configure && make install
|
||||
|
||||
tar xf /opt/gcc-linaro-7.4.1-2019.02-x86_64_aarch64-linux-gnu.tar.xz -C /opt
|
||||
tar xf /opt/aarch64--uclibc--stable-2020.08-1.tar.bz2 -C /opt
|
||||
|
||||
2.4 Set PATH envrioment
|
||||
export PATH=$PATH:/opt/gcc-linaro-7.4.1-2019.02-x86_64_aarch64-linux-gnu/bin:/opt/aarch64--uclibc--stable-2020.08-1/bin
|
||||
better to add this line to /root/.bashrc and relogin as root
|
||||
|
||||
|
||||
==========================================
|
||||
3. All in one script
|
||||
|
@@ -1597,6 +1597,7 @@ module = {
|
||||
common = ventoy/lzx.c;
|
||||
common = ventoy/xpress.c;
|
||||
common = ventoy/huffman.c;
|
||||
common = ventoy/miniz.c;
|
||||
};
|
||||
|
||||
module = {
|
||||
|
@@ -43,8 +43,10 @@
|
||||
#include <grub/acpi.h>
|
||||
#include <grub/charset.h>
|
||||
#include <grub/crypto.h>
|
||||
#include <grub/lib/crc.h>
|
||||
#include <grub/ventoy.h>
|
||||
#include "ventoy_def.h"
|
||||
#include "miniz.h"
|
||||
|
||||
GRUB_MOD_LICENSE ("GPLv3+");
|
||||
|
||||
@@ -105,6 +107,7 @@ int g_conf_replace_new_len = 0;
|
||||
int g_conf_replace_new_len_align = 0;
|
||||
|
||||
ventoy_gpt_info *g_ventoy_part_info = NULL;
|
||||
grub_uint64_t g_ventoy_disk_size = 0;
|
||||
|
||||
static char *g_tree_script_buf = NULL;
|
||||
static int g_tree_script_pos = 0;
|
||||
@@ -1709,6 +1712,7 @@ int ventoy_check_device_result(int ret)
|
||||
|
||||
int ventoy_check_device(grub_device_t dev)
|
||||
{
|
||||
int workaround = 0;
|
||||
grub_file_t file;
|
||||
grub_uint64_t offset;
|
||||
char devname[64];
|
||||
@@ -1726,11 +1730,29 @@ int ventoy_check_device(grub_device_t dev)
|
||||
0 == ventoy_check_file_exist("(%s,2)/grub/localboot.cfg", dev->disk->name) ||
|
||||
0 == ventoy_check_file_exist("(%s,2)/tool/mount.exfat-fuse_aarch64", dev->disk->name))
|
||||
{
|
||||
return ventoy_check_device_result(2 | 0x1000);
|
||||
#ifndef GRUB_MACHINE_EFI
|
||||
if (0 == ventoy_check_file_exist("(ventoydisk)/ventoy/ventoy.cpio", dev->disk->name) ||
|
||||
0 == ventoy_check_file_exist("(ventoydisk)/grub/localboot.cfg", dev->disk->name) ||
|
||||
0 == ventoy_check_file_exist("(ventoydisk)/tool/mount.exfat-fuse_aarch64", dev->disk->name))
|
||||
{
|
||||
return ventoy_check_device_result(2 | 0x1000);
|
||||
}
|
||||
else
|
||||
{
|
||||
workaround = 1;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
/* We must have partition 2 */
|
||||
file = ventoy_grub_file_open(VENTOY_FILE_TYPE, "(%s,2)/ventoy/ventoy.cpio", dev->disk->name);
|
||||
if (workaround)
|
||||
{
|
||||
file = ventoy_grub_file_open(VENTOY_FILE_TYPE, "%s", "(ventoydisk)/ventoy/ventoy.cpio");
|
||||
}
|
||||
else
|
||||
{
|
||||
file = ventoy_grub_file_open(VENTOY_FILE_TYPE, "(%s,2)/ventoy/ventoy.cpio", dev->disk->name);
|
||||
}
|
||||
if (!file)
|
||||
{
|
||||
return ventoy_check_device_result(3 | 0x1000);
|
||||
@@ -1748,37 +1770,55 @@ int ventoy_check_device(grub_device_t dev)
|
||||
return ventoy_check_device_result(5);
|
||||
}
|
||||
|
||||
offset = partition->start + partition->len;
|
||||
partition = file->device->disk->partition;
|
||||
if ((partition->number != 1) || (partition->len != 65536) || (offset != partition->start))
|
||||
if (workaround)
|
||||
{
|
||||
grub_file_close(file);
|
||||
return ventoy_check_device_result(6);
|
||||
ventoy_part_table *PartTbl = g_ventoy_part_info->MBR.PartTbl;
|
||||
if (PartTbl[1].StartSectorId != PartTbl[0].StartSectorId + PartTbl[0].SectorCount ||
|
||||
PartTbl[1].SectorCount != 65536)
|
||||
{
|
||||
grub_file_close(file);
|
||||
return ventoy_check_device_result(6);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
offset = partition->start + partition->len;
|
||||
partition = file->device->disk->partition;
|
||||
if ((partition->number != 1) || (partition->len != 65536) || (offset != partition->start))
|
||||
{
|
||||
grub_file_close(file);
|
||||
return ventoy_check_device_result(7);
|
||||
}
|
||||
}
|
||||
|
||||
grub_file_close(file);
|
||||
|
||||
grub_snprintf(devname, sizeof(devname), "%s,2", dev->disk->name);
|
||||
dev2 = grub_device_open(devname);
|
||||
if (!dev2)
|
||||
if (workaround == 0)
|
||||
{
|
||||
return ventoy_check_device_result(7);
|
||||
}
|
||||
grub_snprintf(devname, sizeof(devname), "%s,2", dev->disk->name);
|
||||
dev2 = grub_device_open(devname);
|
||||
if (!dev2)
|
||||
{
|
||||
return ventoy_check_device_result(8);
|
||||
}
|
||||
|
||||
fs = grub_fs_probe(dev2);
|
||||
if (!fs)
|
||||
{
|
||||
grub_device_close(dev2);
|
||||
return ventoy_check_device_result(8);
|
||||
}
|
||||
fs = grub_fs_probe(dev2);
|
||||
if (!fs)
|
||||
{
|
||||
grub_device_close(dev2);
|
||||
return ventoy_check_device_result(9);
|
||||
}
|
||||
|
||||
fs->fs_label(dev2, &label);
|
||||
if ((!label) || grub_strncmp("VTOYEFI", label, 7))
|
||||
{
|
||||
grub_device_close(dev2);
|
||||
return ventoy_check_device_result(9);
|
||||
}
|
||||
fs->fs_label(dev2, &label);
|
||||
if ((!label) || grub_strncmp("VTOYEFI", label, 7))
|
||||
{
|
||||
grub_device_close(dev2);
|
||||
return ventoy_check_device_result(10);
|
||||
}
|
||||
|
||||
grub_device_close(dev2);
|
||||
grub_device_close(dev2);
|
||||
}
|
||||
|
||||
return ventoy_check_device_result(0);
|
||||
}
|
||||
|
||||
@@ -3400,6 +3440,22 @@ static grub_err_t ventoy_cmd_pop_last_entry(grub_extcmd_context_t ctxt, int argc
|
||||
return 0;
|
||||
}
|
||||
|
||||
grub_uint64_t ventoy_get_part1_size(ventoy_gpt_info *gpt)
|
||||
{
|
||||
grub_uint64_t sectors;
|
||||
|
||||
if (grub_strncmp(gpt->Head.Signature, "EFI PART", 8) == 0)
|
||||
{
|
||||
sectors = gpt->PartTbl[0].LastLBA + 1 - gpt->PartTbl[0].StartLBA;
|
||||
}
|
||||
else
|
||||
{
|
||||
sectors = gpt->MBR.PartTbl[0].SectorCount;
|
||||
}
|
||||
|
||||
return sectors * 512;
|
||||
}
|
||||
|
||||
static int ventoy_lib_module_callback(const char *filename, const struct grub_dirhook_info *info, void *data)
|
||||
{
|
||||
const char *pos = filename + 1;
|
||||
@@ -3502,6 +3558,8 @@ static grub_err_t ventoy_cmd_load_part_table(grub_extcmd_context_t ctxt, int arg
|
||||
return 1;
|
||||
}
|
||||
|
||||
g_ventoy_disk_size = disk->total_sectors * (1U << disk->log_sector_size);
|
||||
|
||||
grub_disk_read(disk, 0, 0, sizeof(ventoy_gpt_info), g_ventoy_part_info);
|
||||
grub_disk_close(disk);
|
||||
|
||||
@@ -3889,6 +3947,47 @@ int ventoy_is_dir_exist(const char *fmt, ...)
|
||||
return 0;
|
||||
}
|
||||
|
||||
int ventoy_gzip_compress(void *mem_in, int mem_in_len, void *mem_out, int mem_out_len)
|
||||
{
|
||||
mz_stream s;
|
||||
grub_uint8_t *outbuf;
|
||||
grub_uint8_t gzHdr[10] =
|
||||
{
|
||||
0x1F, 0x8B, /* magic */
|
||||
8, /* z method */
|
||||
0, /* flags */
|
||||
0,0,0,0, /* mtime */
|
||||
4, /* xfl */
|
||||
3, /* OS */
|
||||
};
|
||||
|
||||
grub_memset(&s, 0, sizeof(mz_stream));
|
||||
|
||||
mz_deflateInit2(&s, 1, MZ_DEFLATED, -MZ_DEFAULT_WINDOW_BITS, 6, MZ_DEFAULT_STRATEGY);
|
||||
|
||||
outbuf = (grub_uint8_t *)mem_out;
|
||||
|
||||
mem_out_len -= sizeof(gzHdr) + 8;
|
||||
grub_memcpy(outbuf, gzHdr, sizeof(gzHdr));
|
||||
outbuf += sizeof(gzHdr);
|
||||
|
||||
s.avail_in = mem_in_len;
|
||||
s.next_in = mem_in;
|
||||
|
||||
s.avail_out = mem_out_len;
|
||||
s.next_out = outbuf;
|
||||
|
||||
mz_deflate(&s, MZ_FINISH);
|
||||
|
||||
mz_deflateEnd(&s);
|
||||
|
||||
outbuf += s.total_out;
|
||||
*(grub_uint32_t *)outbuf = grub_getcrc32c(0, outbuf, s.total_out);
|
||||
*(grub_uint32_t *)(outbuf + 4) = (grub_uint32_t)(s.total_out);
|
||||
|
||||
return s.total_out + sizeof(gzHdr) + 8;
|
||||
}
|
||||
|
||||
static int ventoy_env_init(void)
|
||||
{
|
||||
char buf[64];
|
||||
@@ -4018,6 +4117,8 @@ static cmd_para ventoy_cmds[] =
|
||||
{ "vt_unix_reset", ventoy_cmd_unix_reset, 0, NULL, "", "", NULL },
|
||||
{ "vt_unix_replace_conf", ventoy_cmd_unix_replace_conf, 0, NULL, "", "", NULL },
|
||||
{ "vt_unix_replace_ko", ventoy_cmd_unix_replace_ko, 0, NULL, "", "", NULL },
|
||||
{ "vt_unix_fill_image_desc", ventoy_cmd_unix_fill_image_desc, 0, NULL, "", "", NULL },
|
||||
{ "vt_unix_gzip_new_ko", ventoy_cmd_unix_gzip_newko, 0, NULL, "", "", NULL },
|
||||
{ "vt_unix_chain_data", ventoy_cmd_unix_chain_data, 0, NULL, "", "", NULL },
|
||||
|
||||
{ "vt_img_hook_root", ventoy_cmd_img_hook_root, 0, NULL, "", "", NULL },
|
||||
|
@@ -875,6 +875,7 @@ extern conf_replace *g_conf_replace_node;
|
||||
extern grub_uint8_t *g_conf_replace_new_buf;
|
||||
extern int g_conf_replace_new_len;
|
||||
extern int g_conf_replace_new_len_align;
|
||||
extern grub_uint64_t g_ventoy_disk_size;
|
||||
|
||||
#define ventoy_unix_fill_virt(new_data, new_len) \
|
||||
{ \
|
||||
@@ -924,6 +925,8 @@ int ventoy_get_disk_guid(const char *filename, grub_uint8_t *guid, grub_uint8_t
|
||||
grub_err_t ventoy_cmd_unix_reset(grub_extcmd_context_t ctxt, int argc, char **args);
|
||||
grub_err_t ventoy_cmd_unix_replace_conf(grub_extcmd_context_t ctxt, int argc, char **args);
|
||||
grub_err_t ventoy_cmd_unix_replace_ko(grub_extcmd_context_t ctxt, int argc, char **args);
|
||||
grub_err_t ventoy_cmd_unix_fill_image_desc(grub_extcmd_context_t ctxt, int argc, char **args);
|
||||
grub_err_t ventoy_cmd_unix_gzip_newko(grub_extcmd_context_t ctxt, int argc, char **args);
|
||||
grub_err_t ventoy_cmd_unix_freebsd_ver(grub_extcmd_context_t ctxt, int argc, char **args);
|
||||
grub_err_t ventoy_cmd_parse_freenas_ver(grub_extcmd_context_t ctxt, int argc, char **args);
|
||||
int ventoy_check_device_result(int ret);
|
||||
@@ -934,6 +937,8 @@ grub_err_t ventoy_cmd_patch_vhdboot(grub_extcmd_context_t ctxt, int argc, char *
|
||||
grub_err_t ventoy_cmd_raw_chain_data(grub_extcmd_context_t ctxt, int argc, char **args);
|
||||
grub_err_t ventoy_cmd_get_vtoy_type(grub_extcmd_context_t ctxt, int argc, char **args);
|
||||
int ventoy_check_password(const vtoy_password *pwd, int retry);
|
||||
int ventoy_gzip_compress(void *mem_in, int mem_in_len, void *mem_out, int mem_out_len);
|
||||
grub_uint64_t ventoy_get_part1_size(ventoy_gpt_info *gpt);
|
||||
|
||||
#endif /* __VENTOY_DEF_H__ */
|
||||
|
||||
|
@@ -235,6 +235,21 @@ static int ventoy_freebsd_append_conf(char *buf, const char *isopath)
|
||||
return pos;
|
||||
}
|
||||
|
||||
static int ventoy_dragonfly_append_conf(char *buf, const char *isopath)
|
||||
{
|
||||
int pos = 0;
|
||||
|
||||
debug("ventoy_dragonfly_append_conf %s\n", isopath);
|
||||
|
||||
vtoy_ssprintf(buf, pos, "tmpfs_load=\"%s\"\n", "YES");
|
||||
vtoy_ssprintf(buf, pos, "dm_target_linear_load=\"%s\"\n", "YES");
|
||||
vtoy_ssprintf(buf, pos, "initrd.img_load=\"%s\"\n", "YES");
|
||||
vtoy_ssprintf(buf, pos, "initrd.img_type=\"%s\"\n", "md_image");
|
||||
vtoy_ssprintf(buf, pos, "vfs.root.mountfrom=\"%s\"\n", "ufs:md0s0");
|
||||
|
||||
return pos;
|
||||
}
|
||||
|
||||
grub_err_t ventoy_cmd_unix_reset(grub_extcmd_context_t ctxt, int argc, char **args)
|
||||
{
|
||||
(void)ctxt;
|
||||
@@ -431,6 +446,10 @@ grub_err_t ventoy_cmd_unix_replace_conf(grub_extcmd_context_t ctxt, int argc, ch
|
||||
{
|
||||
g_conf_new_len += ventoy_freebsd_append_conf(data + file->size, args[1]);
|
||||
}
|
||||
else if (grub_strcmp(args[0], "DragonFly") == 0)
|
||||
{
|
||||
g_conf_new_len += ventoy_dragonfly_append_conf(data + file->size, args[1]);
|
||||
}
|
||||
|
||||
VENTOY_CMD_RETURN(GRUB_ERR_NONE);
|
||||
}
|
||||
@@ -474,6 +493,7 @@ grub_err_t ventoy_cmd_unix_replace_ko(grub_extcmd_context_t ctxt, int argc, char
|
||||
data = grub_malloc(file->size);
|
||||
if (!data)
|
||||
{
|
||||
debug("Failed to alloc memory for new ko %d\n", (int)file->size);
|
||||
grub_file_close(file);
|
||||
return 1;
|
||||
}
|
||||
@@ -487,6 +507,105 @@ grub_err_t ventoy_cmd_unix_replace_ko(grub_extcmd_context_t ctxt, int argc, char
|
||||
VENTOY_CMD_RETURN(GRUB_ERR_NONE);
|
||||
}
|
||||
|
||||
grub_err_t ventoy_cmd_unix_fill_image_desc(grub_extcmd_context_t ctxt, int argc, char **args)
|
||||
{
|
||||
int i;
|
||||
grub_uint8_t *byte;
|
||||
grub_uint32_t memsize;
|
||||
ventoy_image_desc *desc;
|
||||
grub_uint8_t flag[32] = {
|
||||
0xFF, 0xEE, 0xDD, 0xCC, 0xBB, 0xAA, 0x99, 0x88, 0x77, 0x66, 0x55, 0x44, 0x33, 0x22, 0x11, 0x00,
|
||||
0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99, 0xAA, 0xBB, 0xCC, 0xDD, 0xEE, 0xFF
|
||||
};
|
||||
|
||||
(void)ctxt;
|
||||
(void)argc;
|
||||
(void)args;
|
||||
|
||||
debug("ventoy_cmd_unix_fill_image_desc %p\n", g_mod_new_data);
|
||||
|
||||
if (!g_mod_new_data)
|
||||
{
|
||||
goto end;
|
||||
}
|
||||
|
||||
byte = (grub_uint8_t *)g_mod_new_data;
|
||||
for (i = 0; i < g_mod_new_len - 32; i += 16)
|
||||
{
|
||||
if (byte[i] == 0xFF && byte[i + 1] == 0xEE)
|
||||
{
|
||||
if (grub_memcmp(flag, byte + i, 32) == 0)
|
||||
{
|
||||
debug("Find position flag at %d(0x%x)\n", i, i);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (i >= g_mod_new_len - 32)
|
||||
{
|
||||
debug("Failed to find position flag %d\n", i);
|
||||
goto end;
|
||||
}
|
||||
|
||||
desc = (ventoy_image_desc *)(byte + i);
|
||||
desc->disk_size = g_ventoy_disk_size;
|
||||
desc->part1_size = ventoy_get_part1_size(g_ventoy_part_info);
|
||||
grub_memcpy(desc->disk_uuid, g_ventoy_part_info->MBR.BootCode + 0x180, 16);
|
||||
grub_memcpy(desc->disk_signature, g_ventoy_part_info->MBR.BootCode + 0x1B8, 4);
|
||||
|
||||
desc->img_chunk_count = g_img_chunk_list.cur_chunk;
|
||||
memsize = g_img_chunk_list.cur_chunk * sizeof(ventoy_img_chunk);
|
||||
|
||||
debug("image chunk count:%u memsize:%u\n", desc->img_chunk_count, memsize);
|
||||
|
||||
if (memsize >= VTOY_SIZE_1MB * 8)
|
||||
{
|
||||
grub_printf("image chunk count:%u memsize:%u too big\n", desc->img_chunk_count, memsize);
|
||||
goto end;
|
||||
}
|
||||
|
||||
grub_memcpy(desc + 1, g_img_chunk_list.chunk, memsize);
|
||||
|
||||
end:
|
||||
VENTOY_CMD_RETURN(GRUB_ERR_NONE);
|
||||
}
|
||||
|
||||
grub_err_t ventoy_cmd_unix_gzip_newko(grub_extcmd_context_t ctxt, int argc, char **args)
|
||||
{
|
||||
int newlen;
|
||||
grub_uint8_t *buf;
|
||||
|
||||
(void)ctxt;
|
||||
(void)argc;
|
||||
(void)args;
|
||||
|
||||
debug("ventoy_cmd_unix_gzip_newko %p\n", g_mod_new_data);
|
||||
|
||||
if (!g_mod_new_data)
|
||||
{
|
||||
goto end;
|
||||
}
|
||||
|
||||
buf = grub_malloc(g_mod_new_len);
|
||||
if (!buf)
|
||||
{
|
||||
goto end;
|
||||
}
|
||||
|
||||
newlen = ventoy_gzip_compress(g_mod_new_data, g_mod_new_len, buf, g_mod_new_len);
|
||||
|
||||
grub_free(g_mod_new_data);
|
||||
|
||||
debug("gzip org len:%d newlen:%d\n", g_mod_new_len, newlen);
|
||||
|
||||
g_mod_new_data = (char *)buf;
|
||||
g_mod_new_len = newlen;
|
||||
|
||||
end:
|
||||
VENTOY_CMD_RETURN(GRUB_ERR_NONE);
|
||||
}
|
||||
|
||||
grub_err_t ventoy_cmd_unix_chain_data(grub_extcmd_context_t ctxt, int argc, char **args)
|
||||
{
|
||||
int ventoy_compatible = 0;
|
||||
|
@@ -342,8 +342,10 @@ static int ventoy_raw_trim_head(grub_uint64_t offset)
|
||||
grub_err_t ventoy_cmd_get_vtoy_type(grub_extcmd_context_t ctxt, int argc, char **args)
|
||||
{
|
||||
int i;
|
||||
int altboot = 0;
|
||||
int offset = -1;
|
||||
grub_file_t file;
|
||||
grub_uint8_t data = 0;
|
||||
vhd_footer_t vhdfoot;
|
||||
VDIPREHEADER vdihdr;
|
||||
char type[16] = {0};
|
||||
@@ -427,6 +429,7 @@ grub_err_t ventoy_cmd_get_vtoy_type(grub_extcmd_context_t ctxt, int argc, char *
|
||||
if (grub_memcmp(gpt->PartTbl[i].PartType, "Hah!IdontNeedEFI", 16) == 0)
|
||||
{
|
||||
debug("part %d is grub_bios part\n", i);
|
||||
altboot = 1;
|
||||
grub_env_set(args[3], "1");
|
||||
break;
|
||||
}
|
||||
@@ -436,6 +439,20 @@ grub_err_t ventoy_cmd_get_vtoy_type(grub_extcmd_context_t ctxt, int argc, char *
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!altboot)
|
||||
{
|
||||
if (gpt->MBR.BootCode[92] == 0x22)
|
||||
{
|
||||
grub_file_seek(file, offset + 17908);
|
||||
grub_file_read(file, &data, 1);
|
||||
if (data == 0x23)
|
||||
{
|
||||
altboot = 1;
|
||||
grub_env_set(args[3], "1");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -447,6 +464,7 @@ grub_err_t ventoy_cmd_get_vtoy_type(grub_extcmd_context_t ctxt, int argc, char *
|
||||
if (gpt->MBR.PartTbl[i].FsFlag == 0xEF)
|
||||
{
|
||||
debug("part %d is esp part in MBR mode\n", i);
|
||||
altboot = 1;
|
||||
grub_env_set(args[3], "1");
|
||||
break;
|
||||
}
|
||||
|
@@ -149,8 +149,6 @@ typedef struct ventoy_secure_data
|
||||
grub_uint8_t magic2[16]; /* VENTOY_GUID */
|
||||
}ventoy_secure_data;
|
||||
|
||||
|
||||
|
||||
#pragma pack()
|
||||
|
||||
// compile assert check : sizeof(ventoy_os_param) must be 512
|
||||
@@ -188,6 +186,18 @@ typedef struct ventoy_chain_head
|
||||
grub_uint32_t virt_chunk_num;
|
||||
}ventoy_chain_head;
|
||||
|
||||
typedef struct ventoy_image_desc
|
||||
{
|
||||
grub_uint64_t disk_size;
|
||||
grub_uint64_t part1_size;
|
||||
grub_uint8_t disk_uuid[16];
|
||||
grub_uint8_t disk_signature[4];
|
||||
grub_uint32_t img_chunk_count;
|
||||
/* ventoy_img_chunk list */
|
||||
}ventoy_image_desc;
|
||||
|
||||
|
||||
|
||||
typedef struct ventoy_img_chunk
|
||||
{
|
||||
grub_uint32_t img_start_sector; // sector size: 2KB
|
||||
|
@@ -47,8 +47,8 @@ if [ -e $BUSYBOX_PATH/32h ]; then
|
||||
if [ -s $BUSYBOX_PATH/busybox ]; then
|
||||
$BUSYBOX_PATH/vtchmod64 $BUSYBOX_PATH/busybox
|
||||
else
|
||||
$BUSYBOX_PATH/xzminidec64_uclibc < $BUSYBOX_PATH/busybox64.xz > $BUSYBOX_PATH/busybox
|
||||
$BUSYBOX_PATH/vtchmod64_uclibc $BUSYBOX_PATH/busybox
|
||||
$BUSYBOX_PATH/xzminidec64_musl < $BUSYBOX_PATH/busybox64.xz > $BUSYBOX_PATH/busybox
|
||||
$BUSYBOX_PATH/vtchmod64_musl $BUSYBOX_PATH/busybox
|
||||
fi
|
||||
fi
|
||||
else
|
||||
|
Binary file not shown.
BIN
IMG/cpio/ventoy/busybox/vtchmod64_musl
Normal file
BIN
IMG/cpio/ventoy/busybox/vtchmod64_musl
Normal file
Binary file not shown.
Binary file not shown.
BIN
IMG/cpio/ventoy/busybox/xzminidec64_musl
Normal file
BIN
IMG/cpio/ventoy/busybox/xzminidec64_musl
Normal file
Binary file not shown.
Binary file not shown.
48
IMG/cpio/ventoy/hook/austrumi/disk_hook.sh
Normal file
48
IMG/cpio/ventoy/hook/austrumi/disk_hook.sh
Normal file
@@ -0,0 +1,48 @@
|
||||
#!/ventoy/busybox/sh
|
||||
#************************************************************************************
|
||||
# Copyright (c) 2020, longpanda <admin@ventoy.net>
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License as
|
||||
# published by the Free Software Foundation; either version 3 of the
|
||||
# License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful, but
|
||||
# WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
# General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
#************************************************************************************
|
||||
|
||||
. /ventoy/hook/ventoy-hook-lib.sh
|
||||
|
||||
VTPATH_OLD=$PATH; PATH=$BUSYBOX_PATH:$VTOY_PATH/tool:$PATH
|
||||
|
||||
wait_for_usb_disk_ready
|
||||
|
||||
vtdiskname=$(get_ventoy_disk_name)
|
||||
if [ "$vtdiskname" = "unknown" ]; then
|
||||
vtlog "ventoy disk not found"
|
||||
PATH=$VTPATH_OLD
|
||||
exit 0
|
||||
fi
|
||||
|
||||
ventoy_udev_disk_common_hook "${vtdiskname#/dev/}2"
|
||||
|
||||
# blkdev_num=$($VTOY_PATH/tool/dmsetup ls | grep ventoy | sed 's/.*(\([0-9][0-9]*\),.*\([0-9][0-9]*\).*/\1:\2/')
|
||||
# blkdev_num_mknod=$($VTOY_PATH/tool/dmsetup ls | grep ventoy | sed 's/.*(\([0-9][0-9]*\),.*\([0-9][0-9]*\).*/\1 \2/')
|
||||
# vtDM=$(ventoy_find_dm_id ${blkdev_num})
|
||||
|
||||
# vtlog "blkdev_num=$blkdev_num blkdev_num_mknod=$blkdev_num_mknod vtDM=$vtDM"
|
||||
|
||||
# if [ -b /dev/$vtDM ]; then
|
||||
# vtlog "dev already exist ..."
|
||||
# else
|
||||
# vtlog "mknode dev ..."
|
||||
# mknod -m 660 /dev/$vtDM b $blkdev_num_mknod
|
||||
# fi
|
||||
|
||||
PATH=$VTPATH_OLD
|
24
IMG/cpio/ventoy/hook/austrumi/ventoy-hook.sh
Normal file
24
IMG/cpio/ventoy/hook/austrumi/ventoy-hook.sh
Normal file
@@ -0,0 +1,24 @@
|
||||
#!/ventoy/busybox/sh
|
||||
#************************************************************************************
|
||||
# Copyright (c) 2020, longpanda <admin@ventoy.net>
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License as
|
||||
# published by the Free Software Foundation; either version 3 of the
|
||||
# License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful, but
|
||||
# WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
# General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
#************************************************************************************
|
||||
|
||||
. $VTOY_PATH/hook/ventoy-os-lib.sh
|
||||
|
||||
$SED "/^ *mdev *-s/a $BUSYBOX_PATH/sh $VTOY_PATH/hook/austrumi/disk_hook.sh" -i /init
|
||||
$SED "s/BOOT_TYPE=livecd/BOOT_TYPE=usb/g" -i /init
|
||||
|
@@ -43,6 +43,7 @@ ventoy_os_install_dmsetup_by_unsquashfs() {
|
||||
vtoy_unsquashfs -d $VTOY_PATH/sqfs -n -q -e $VTOY_PATH/fsextract $VTOY_PATH/fsdisk
|
||||
|
||||
if ! [ -e $VTOY_PATH/sqfs${dmModPath} ]; then
|
||||
rm -rf $VTOY_PATH/sqfs
|
||||
dmModPath="/lib/modules/$vtKerVer/kernel/drivers/md/dm-mod.$vtKoPo"
|
||||
echo $dmModPath > $VTOY_PATH/fsextract
|
||||
vtoy_unsquashfs -d $VTOY_PATH/sqfs -n -q -e $VTOY_PATH/fsextract $VTOY_PATH/fsdisk
|
||||
|
@@ -23,7 +23,12 @@ elif $GREP -q '\[ "$FILTERED_LIST" \]' /init; then
|
||||
$SED '/\[ "$FILTERED_LIST" \]/i\ FILTERED_LIST="/dev/mapper/ventoy $FILTERED_LIST"' -i /init
|
||||
fi
|
||||
|
||||
$SED -i "/_search_for_boot_device_/a\ $BUSYBOX_PATH/sh $VTOY_PATH/hook/debian/antix-disk.sh" /init
|
||||
if $GREP -q '_search_for_boot_device_' /init; then
|
||||
$SED -i "/_search_for_boot_device_/a\ $BUSYBOX_PATH/sh $VTOY_PATH/hook/debian/antix-disk.sh" /init
|
||||
elif $GREP -q 'FILTERED_LIST=.*ventoy' /init; then
|
||||
$SED -i "/FILTERED_LIST=.*ventoy/i\ $BUSYBOX_PATH/sh $VTOY_PATH/hook/debian/antix-disk.sh" /init
|
||||
fi
|
||||
|
||||
|
||||
if [ -f $VTOY_PATH/ventoy_persistent_map ]; then
|
||||
$SED 's#for param in $cmdline#for param in persist_all $cmdline#g' -i /init
|
||||
|
@@ -39,7 +39,17 @@ if is_inotify_ventoy_part $3; then
|
||||
fi
|
||||
|
||||
vtlog "find ventoy partition ..."
|
||||
$BUSYBOX_PATH/sh $VTOY_PATH/hook/default/udev_disk_hook.sh $3 noreplace
|
||||
|
||||
vtReplaceOpt=noreplace
|
||||
|
||||
if $GREP -q el8 /proc/version && [ -f /etc/system-release ]; then
|
||||
vtRhel8Ver=$($SED "s#.*8\.\([0-9]*\).*#\1#" /etc/system-release)
|
||||
if [ $vtRhel8Ver -ge 3 ]; then
|
||||
vtReplaceOpt=""
|
||||
fi
|
||||
fi
|
||||
|
||||
$BUSYBOX_PATH/sh $VTOY_PATH/hook/default/udev_disk_hook.sh $3 $vtReplaceOpt
|
||||
|
||||
blkdev_num=$($VTOY_PATH/tool/dmsetup ls | grep ventoy | sed 's/.*(\([0-9][0-9]*\),.*\([0-9][0-9]*\).*/\1:\2/')
|
||||
vtDM=$(ventoy_find_dm_id ${blkdev_num})
|
||||
|
@@ -19,7 +19,13 @@
|
||||
|
||||
. $VTOY_PATH/hook/ventoy-os-lib.sh
|
||||
|
||||
$SED "/mount.*devtmpfs/a $BUSYBOX_PATH/sh $VTOY_PATH/hook/wifislax/disk_hook.sh" -i /linuxrc
|
||||
if [ -e /linuxrc ]; then
|
||||
INITFILE=/linuxrc
|
||||
elif [ -e /init ]; then
|
||||
INITFILE=/init
|
||||
fi
|
||||
|
||||
$SED "/mount.*devtmpfs/a $BUSYBOX_PATH/sh $VTOY_PATH/hook/wifislax/disk_hook.sh" -i $INITFILE
|
||||
|
||||
#replace original blkid
|
||||
$BUSYBOX_PATH/rm -f /usr/bin/blkid
|
||||
|
Binary file not shown.
@@ -309,6 +309,10 @@ ventoy_get_os_type() {
|
||||
echo 'primeos'; return
|
||||
fi
|
||||
|
||||
if $GREP -q 'austrumi' /proc/version; then
|
||||
echo 'austrumi'; return
|
||||
fi
|
||||
|
||||
echo "default"
|
||||
}
|
||||
|
||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -1,5 +1,7 @@
|
||||
#!/bin/sh
|
||||
|
||||
OLDDIR=$(pwd)
|
||||
|
||||
if ! [ -f ./tool/ventoy_lib.sh ]; then
|
||||
if [ -f ${0%Ventoy2Disk.sh}/tool/ventoy_lib.sh ]; then
|
||||
cd ${0%Ventoy2Disk.sh}
|
||||
@@ -10,8 +12,6 @@ if [ -f ./ventoy/version ]; then
|
||||
curver=$(cat ./ventoy/version)
|
||||
fi
|
||||
|
||||
OLDDIR=$(pwd)
|
||||
|
||||
if uname -a | egrep -q 'aarch64|arm64'; then
|
||||
export TOOLDIR=aarch64
|
||||
elif uname -a | egrep -q 'x86_64|amd64'; then
|
||||
@@ -53,9 +53,10 @@ else
|
||||
|
||||
for file in $(ls *.xz); do
|
||||
xzcat $file > ${file%.xz}
|
||||
[ -f ./${file%.xz} ] && chmod +x ./${file%.xz}
|
||||
[ -f ./$file ] && rm -f ./$file
|
||||
done
|
||||
cd $OLDDIR
|
||||
cd ../../
|
||||
|
||||
chmod +x -R ./tool/$TOOLDIR
|
||||
fi
|
||||
@@ -67,7 +68,8 @@ else
|
||||
fi
|
||||
|
||||
if [ -n "$OLDDIR" ]; then
|
||||
cd $OLDDIR
|
||||
CURDIR=$(pwd)
|
||||
if [ "$CURDIR" != "$OLDDIR" ]; then
|
||||
cd "$OLDDIR"
|
||||
fi
|
||||
fi
|
||||
|
||||
|
||||
|
@@ -92,7 +92,7 @@ terminal:
|
||||
div:
|
||||
crypto:
|
||||
part_bsd: part_msdos
|
||||
ventoy: ext2 fshelp font crypto gcry_md5 exfat udf extcmd normal video gcry_sha1 iso9660
|
||||
ventoy: ext2 fshelp btrfs font crypto gcry_md5 exfat udf extcmd normal video gcry_sha1 iso9660
|
||||
gcry_sha512: crypto
|
||||
password: crypto normal
|
||||
fshelp:
|
||||
|
@@ -92,6 +92,9 @@ function get_os_type {
|
||||
elif [ -e (loop)/bin/freebsd-version ]; then
|
||||
set vtoy_os=Unix
|
||||
set vt_unix_type=FreeBSD
|
||||
elif vt_str_begin "$vt_system_id" "DragonFly"; then
|
||||
set vtoy_os=Unix
|
||||
set vt_unix_type=DragonFly
|
||||
|
||||
|
||||
elif [ -e (loop)/boot/kernel/kernel ]; then
|
||||
@@ -270,6 +273,8 @@ function distro_specify_initrd_file_phase2 {
|
||||
fi
|
||||
elif [ -f (loop)/blackarch/boot/x86_64/archiso.img ]; then
|
||||
vt_linux_specify_initrd_file /blackarch/boot/x86_64/archiso.img
|
||||
elif [ -f (loop)/blackarch/boot/x86_64/initramfs-linux.img ]; then
|
||||
vt_linux_specify_initrd_file /blackarch/boot/x86_64/initramfs-linux.img
|
||||
|
||||
elif [ -f (loop)/install.amd/initrd.gz ]; then
|
||||
vt_linux_specify_initrd_file /live/initrd2.img
|
||||
@@ -277,7 +282,19 @@ function distro_specify_initrd_file_phase2 {
|
||||
vt_linux_specify_initrd_file /install.amd/gtk/initrd.gz
|
||||
elif [ -f (loop)/boot/grub/kernels.cfg ]; then
|
||||
vt_linux_parse_initrd_grub file (loop)/boot/grub/kernels.cfg
|
||||
|
||||
elif [ -f (loop)/austrumi/initrd.gz ]; then
|
||||
vt_linux_specify_initrd_file /austrumi/initrd.gz
|
||||
if [ -f (loop)/EFI/BOOT/bootx64.efi ]; then
|
||||
vt_cpio_busybox64 "64h"
|
||||
fi
|
||||
elif [ -f (loop)/boot/initfs.x86_64-efi ]; then
|
||||
vt_linux_specify_initrd_file /boot/initfs.x86_64-efi
|
||||
if [ -f (loop)/boot/initfs.i386-pc ]; then
|
||||
vt_linux_specify_initrd_file /boot/initfs.i386-pc
|
||||
fi
|
||||
elif [ -f (loop)/antiX/initrd.gz ]; then
|
||||
vt_linux_specify_initrd_file /antiX/initrd.gz
|
||||
|
||||
fi
|
||||
}
|
||||
|
||||
@@ -419,6 +436,22 @@ function ventoy_freebsd_proc {
|
||||
vt_unix_replace_conf FreeBSD "${1}${chosen_path}"
|
||||
}
|
||||
|
||||
function ventoy_dragonfly_proc {
|
||||
|
||||
unset vt_unix_mod_path
|
||||
for file in "/boot/kernel/initrd.img.gz"; do
|
||||
if [ -e (loop)${file} ]; then
|
||||
set vt_unix_mod_path=${file}
|
||||
break
|
||||
fi
|
||||
done
|
||||
|
||||
vt_unix_replace_ko $vt_unix_mod_path ${vtoy_path}/dragonfly.mfs.xz
|
||||
vt_unix_fill_image_desc
|
||||
vt_unix_gzip_new_ko
|
||||
vt_unix_replace_conf DragonFly "${1}${chosen_path}"
|
||||
}
|
||||
|
||||
function ventoy_unix_comm_proc {
|
||||
vt_unix_reset
|
||||
|
||||
@@ -427,11 +460,12 @@ function ventoy_unix_comm_proc {
|
||||
|
||||
if [ "$vt_unix_type" = "FreeBSD" ]; then
|
||||
ventoy_freebsd_proc "$1" "${chosen_path}"
|
||||
elif [ "$vt_unix_type" = "DragonFly" ]; then
|
||||
ventoy_dragonfly_proc "$1" "${chosen_path}"
|
||||
elif [ "$vt_unix_type" = "NetBSD" ]; then
|
||||
echo "NetBSD not supported"
|
||||
|
||||
|
||||
|
||||
else
|
||||
if [ -n "${vtdebug_flag}" ]; then
|
||||
echo "Unknown unix type"
|
||||
@@ -543,6 +577,12 @@ function uefi_linux_menu_func {
|
||||
elif [ -d (loop)/blackarch ]; then
|
||||
if [ -f (loop)/blackarch/boot/x86_64/archiso.img ]; then
|
||||
vt_add_replace_file $vtindex "EFI\\archiso\\archiso.img"
|
||||
elif [ -f (loop)/blackarch/boot/x86_64/initramfs-linux.img ]; then
|
||||
vt_add_replace_file $vtindex "blackarch\\boot\\x86_64\\initramfs-linux.img"
|
||||
fi
|
||||
elif [ -d (loop)/anarchy ]; then
|
||||
if [ -f (loop)/anarchy/boot/x86_64/initramfs-linux.img ]; then
|
||||
vt_add_replace_file $vtindex "anarchy\\boot\\x86_64\\initramfs-linux.img"
|
||||
fi
|
||||
elif [ -d (loop)/parabola ]; then
|
||||
if [ -f (loop)/parabola/boot/x86_64/parabolaiso.img ]; then
|
||||
@@ -748,6 +788,8 @@ function legacy_linux_menu_func {
|
||||
if [ -d (loop)/arch/boot/syslinux ]; then
|
||||
vt_linux_parse_initrd_isolinux (loop)/arch/boot/syslinux/ /arch/
|
||||
vt_linux_parse_initrd_isolinux (loop)/arch/boot/syslinux/ /arch/boot/syslinux/
|
||||
elif [ -d (loop)/anarchy/boot/syslinux ]; then
|
||||
vt_linux_parse_initrd_isolinux (loop)/anarchy/boot/syslinux/ /anarchy/
|
||||
|
||||
#manjaro
|
||||
elif [ -d (loop)/manjaro ]; then
|
||||
@@ -1432,7 +1474,7 @@ function img_unsupport_menuentry {
|
||||
#############################################################
|
||||
#############################################################
|
||||
|
||||
set VENTOY_VERSION="1.0.30"
|
||||
set VENTOY_VERSION="1.0.32"
|
||||
|
||||
#ACPI not compatible with Window7/8, so disable by default
|
||||
set VTOY_PARAM_NO_ACPI=1
|
||||
|
@@ -119,7 +119,7 @@ ehci: cs5536 usb boot
|
||||
crypto:
|
||||
part_bsd: part_msdos
|
||||
cs5536:
|
||||
ventoy: ext2 fshelp font crypto gcry_md5 exfat udf extcmd normal video gcry_sha1 iso9660
|
||||
ventoy: ext2 fshelp btrfs font crypto gcry_md5 exfat udf extcmd normal video gcry_sha1 iso9660
|
||||
gcry_sha512: crypto
|
||||
password: crypto normal
|
||||
fshelp:
|
||||
|
Binary file not shown.
@@ -122,7 +122,7 @@ crypto:
|
||||
part_bsd: part_msdos
|
||||
cs5536: pci
|
||||
biosdisk:
|
||||
ventoy: ext2 fshelp font crypto gcry_md5 exfat udf extcmd normal video gcry_sha1 iso9660 acpi
|
||||
ventoy: ext2 fshelp btrfs font crypto gcry_md5 exfat udf extcmd normal video gcry_sha1 iso9660 acpi
|
||||
lsapm:
|
||||
gcry_sha512: crypto
|
||||
password: crypto normal
|
||||
|
@@ -119,7 +119,7 @@ ehci: cs5536 usb boot
|
||||
crypto:
|
||||
part_bsd: part_msdos
|
||||
cs5536:
|
||||
ventoy: ext2 fshelp font crypto gcry_md5 exfat udf extcmd normal video gcry_sha1 iso9660
|
||||
ventoy: ext2 fshelp btrfs font crypto gcry_md5 exfat udf extcmd normal video gcry_sha1 iso9660
|
||||
gcry_sha512: crypto
|
||||
password: crypto normal
|
||||
fshelp:
|
||||
|
@@ -15,12 +15,12 @@ print_usage() {
|
||||
echo ' -r SIZE_MB preserve some space at the bottom of the disk (only for install)'
|
||||
echo ' -s/-S enable/disable secure boot support (default is disabled)'
|
||||
echo ' -g use GPT partition style, default is MBR (only for install)'
|
||||
echo ' -L Label of the 1st exfat partition (default is ventoy)'
|
||||
echo ' -L Label of the 1st exfat partition (default is Ventoy)'
|
||||
echo ''
|
||||
}
|
||||
|
||||
|
||||
VTNEW_LABEL='ventoy'
|
||||
VTNEW_LABEL='Ventoy'
|
||||
RESERVE_SIZE_MB=0
|
||||
while [ -n "$1" ]; do
|
||||
if [ "$1" = "-i" ]; then
|
||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
INSTALL/ventoy/dragonfly.mfs.xz
Normal file
BIN
INSTALL/ventoy/dragonfly.mfs.xz
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
LZIP/lz4cat64
Normal file
BIN
LZIP/lz4cat64
Normal file
Binary file not shown.
13
License/license-mini_gzip.txt
Normal file
13
License/license-mini_gzip.txt
Normal file
@@ -0,0 +1,13 @@
|
||||
|
||||
https://github.com/wkoszek/mini_gzip
|
||||
|
||||
Ventoy modify its source code, these code modified by Ventoy follow the same license as mini_gzip.
|
||||
|
||||
=====================================License=================================================
|
||||
Copyright (c) 2015, Wojciech Adam Koszek wojciech@koszek.com All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
|
||||
|
||||
Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
|
||||
Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
|
||||
THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
@@ -16,7 +16,7 @@ You can copy many image files at a time and ventoy will give you a boot menu to
|
||||
x86 Legacy BIOS, IA32 UEFI, x86_64 UEFI and ARM64 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/Vmware/Xen...) <br/>
|
||||
580+ ISO files are tested. 90%+ distros in distrowatch.com supported. <br/>
|
||||
600+ ISO files are tested. 90%+ distros in distrowatch.com supported. <br/>
|
||||
</h4>
|
||||
|
||||
# Features
|
||||
@@ -34,7 +34,7 @@ Most type of OS supported(Windows/WinPE/Linux/Unix/Vmware/Xen...) <br/>
|
||||
* 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, 580+ iso files tested
|
||||
* Most type of OS supported, 600+ iso files tested
|
||||
* Linux vDisk boot supported
|
||||
* Not only boot but also complete installation process
|
||||
* Menu dynamically switchable between List/TreeView mode
|
||||
|
@@ -4,7 +4,9 @@ VENTOY_PATH=$PWD/../
|
||||
|
||||
rm -f ventoy_unix.cpio
|
||||
|
||||
mv ./ventoy_unix/DragonFly ./
|
||||
find ./ventoy_unix | cpio -o -H newc>ventoy_unix.cpio
|
||||
mv ./DragonFly ./ventoy_unix/
|
||||
|
||||
echo '======== SUCCESS ============='
|
||||
|
||||
|
Binary file not shown.
BIN
Unix/ventoy_unix/DragonFly/dmtable
Normal file
BIN
Unix/ventoy_unix/DragonFly/dmtable
Normal file
Binary file not shown.
30
Unix/ventoy_unix/DragonFly/mkinitrd.sh
Normal file
30
Unix/ventoy_unix/DragonFly/mkinitrd.sh
Normal file
@@ -0,0 +1,30 @@
|
||||
#!/bin/bash
|
||||
|
||||
INITRD_SIZE=12
|
||||
INITRD_FILE=dragonfly.mfs
|
||||
|
||||
rm -f ${INITRD_FILE}
|
||||
rm -f ${INITRD_FILE}.xz
|
||||
|
||||
VN_DEV=$(vnconfig -c -S ${INITRD_SIZE}m -Z -T vn ${INITRD_FILE})
|
||||
newfs -i 131072 -m 0 /dev/${VN_DEV}s0
|
||||
mount_ufs /dev/${VN_DEV}s0 /mnt
|
||||
|
||||
cp -a sbin /mnt/
|
||||
chmod -R 777 /mnt/sbin
|
||||
|
||||
mkdir /mnt/dev
|
||||
mkdir /mnt/new_root
|
||||
mkdir /mnt/tmp
|
||||
|
||||
dd if=/dev/zero of=./data bs=1M count=8
|
||||
|
||||
cat ./dmtable ./data ./dmtable > /mnt/dmtable
|
||||
|
||||
umount /mnt
|
||||
|
||||
rm -f ./data
|
||||
|
||||
xz ${INITRD_FILE}
|
||||
|
||||
vnconfig -u ${VN_DEV}
|
BIN
Unix/ventoy_unix/DragonFly/sbin/dmsetup
Normal file
BIN
Unix/ventoy_unix/DragonFly/sbin/dmsetup
Normal file
Binary file not shown.
BIN
Unix/ventoy_unix/DragonFly/sbin/init
Normal file
BIN
Unix/ventoy_unix/DragonFly/sbin/init
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
13
Unix/ventoy_unix_src/DragonFly/build.sh
Normal file
13
Unix/ventoy_unix_src/DragonFly/build.sh
Normal file
@@ -0,0 +1,13 @@
|
||||
#!/bin/sh
|
||||
|
||||
rm -f init
|
||||
|
||||
gcc -DMOUNT_NOMAIN -Os -static *.c -I. -lutil -lkiconv -o init
|
||||
|
||||
strip --strip-all init
|
||||
|
||||
if [ -e init ]; then
|
||||
echo -e "\n========= SUCCESS ==============\n"
|
||||
else
|
||||
echo -e "\n========= FAILED ==============\n"
|
||||
fi
|
216
Unix/ventoy_unix_src/DragonFly/mount_cd9660.c
Normal file
216
Unix/ventoy_unix_src/DragonFly/mount_cd9660.c
Normal file
@@ -0,0 +1,216 @@
|
||||
/*
|
||||
* Copyright (c) 1992, 1993, 1994
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to Berkeley
|
||||
* by Pace Willisson (pace@blitz.com). The Rock Ridge Extension
|
||||
* Support code is derived from software contributed to Berkeley
|
||||
* by Atsushi Murai (amurai@spec.co.jp).
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of the University nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* @(#)mount_cd9660.c 8.7 (Berkeley) 5/1/95
|
||||
*
|
||||
* @(#) Copyright (c) 1992, 1993, 1994 The Regents of the University of California. All rights reserved.
|
||||
* @(#)mount_cd9660.c 8.7 (Berkeley) 5/1/95
|
||||
* $FreeBSD: src/sbin/mount_cd9660/mount_cd9660.c,v 1.15.2.3 2001/03/14 12:05:01 bp Exp $
|
||||
*/
|
||||
|
||||
#include <sys/cdio.h>
|
||||
#include <sys/param.h>
|
||||
#include <sys/mount.h>
|
||||
#include <sys/iconv.h>
|
||||
#include <sys/linker.h>
|
||||
#include <sys/module.h>
|
||||
#include <vfs/isofs/cd9660/cd9660_mount.h>
|
||||
|
||||
#include <err.h>
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
#include <mntopts.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <locale.h>
|
||||
#include <sysexits.h>
|
||||
#include <unistd.h>
|
||||
|
||||
static struct mntopt mopts[] = {
|
||||
MOPT_STDOPTS,
|
||||
MOPT_UPDATE,
|
||||
{ "extatt", 0, ISOFSMNT_EXTATT, 1 },
|
||||
{ "gens", 0, ISOFSMNT_GENS, 1 },
|
||||
{ "rrip", 1, ISOFSMNT_NORRIP, 1 },
|
||||
{ "joliet", 1, ISOFSMNT_NOJOLIET, 1 },
|
||||
{ "strictjoliet", 1, ISOFSMNT_BROKENJOLIET, 1 },
|
||||
MOPT_NULL
|
||||
};
|
||||
|
||||
static int get_ssector(const char *dev);
|
||||
static void usage(void);
|
||||
int set_charset(struct iso_args *args, const char *cs_local, const char *cs_disk);
|
||||
|
||||
int
|
||||
mount_cd9660(char *dev, char *dir)
|
||||
{
|
||||
struct iso_args args;
|
||||
int ch, mntflags, opts;
|
||||
char mntpath[MAXPATHLEN];
|
||||
struct vfsconf vfc;
|
||||
int error, verbose;
|
||||
const char *quirk;
|
||||
char *cs_local = NULL;
|
||||
|
||||
mntflags = opts = verbose = 0;
|
||||
memset(&args, 0, sizeof args);
|
||||
args.ssector = 0;
|
||||
|
||||
/*
|
||||
* Resolve the mountpoint with realpath(3) and remove unnecessary
|
||||
* slashes from the devicename if there are any.
|
||||
*/
|
||||
checkpath(dir, mntpath);
|
||||
rmslashes(dev, dev);
|
||||
|
||||
#define DEFAULT_ROOTUID -2
|
||||
/*
|
||||
* ISO 9660 filesystems are not writeable.
|
||||
*/
|
||||
mntflags |= MNT_RDONLY;
|
||||
args.export.ex_flags = MNT_EXRDONLY;
|
||||
args.fspec = dev;
|
||||
args.export.ex_root = DEFAULT_ROOTUID;
|
||||
args.flags = opts;
|
||||
|
||||
if (args.ssector == -1) {
|
||||
/*
|
||||
* The start of the session has not been specified on
|
||||
* the command line. If we can successfully read the
|
||||
* TOC of a CD-ROM, use the last data track we find.
|
||||
* Otherwise, just use 0, in order to mount the very
|
||||
* first session. This is compatible with the
|
||||
* historic behaviour of mount_cd9660(8). If the user
|
||||
* has specified -s <ssector> above, we don't get here
|
||||
* and leave the user's will.
|
||||
*/
|
||||
if ((args.ssector = get_ssector(dev)) == -1) {
|
||||
if (verbose)
|
||||
printf("could not determine starting sector, "
|
||||
"using very first session\n");
|
||||
args.ssector = 0;
|
||||
} else if (verbose)
|
||||
printf("using starting sector %d\n", args.ssector);
|
||||
}
|
||||
|
||||
error = getvfsbyname("cd9660", &vfc);
|
||||
if (error && vfsisloadable("cd9660")) {
|
||||
if (vfsload("cd9660"))
|
||||
err(EX_OSERR, "vfsload(cd9660)");
|
||||
endvfsent(); /* flush cache */
|
||||
error = getvfsbyname("cd9660", &vfc);
|
||||
}
|
||||
if (error)
|
||||
errx(1, "cd9660 filesystem is not available");
|
||||
|
||||
if (mount(vfc.vfc_name, mntpath, mntflags, &args) < 0)
|
||||
err(1, "%s", args.fspec);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
set_charset(struct iso_args *args, const char *cs_local, const char *cs_disk)
|
||||
{
|
||||
int error;
|
||||
if (modfind("cd9660_iconv") < 0) {
|
||||
if (kldload("cd9660_iconv") < 0 || modfind("cd9660_iconv") < 0)
|
||||
{
|
||||
warnx("cannot find or load \"cd9660_iconv\" kernel module");
|
||||
return (-1);
|
||||
}
|
||||
}
|
||||
snprintf(args->cs_local, ICONV_CSNMAXLEN, "%s", cs_local);
|
||||
error = kiconv_add_xlat16_cspairs(ENCODING_UNICODE, cs_local);
|
||||
if (error)
|
||||
return (-1);
|
||||
if (!cs_disk)
|
||||
cs_disk = strdup(ENCODING_UNICODE);
|
||||
snprintf(args->cs_disk, ICONV_CSNMAXLEN, "%s", cs_disk);
|
||||
error = kiconv_add_xlat16_cspairs(cs_disk, cs_local);
|
||||
if (error)
|
||||
return (-1);
|
||||
return (0);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
usage(void)
|
||||
{
|
||||
fprintf(stderr,
|
||||
"usage: mount_cd9660 [-begjrv] [-C charset] [-o options] [-s startsector] special node\n");
|
||||
exit(EX_USAGE);
|
||||
}
|
||||
|
||||
static int
|
||||
get_ssector(const char *dev)
|
||||
{
|
||||
struct ioc_toc_header h;
|
||||
struct ioc_read_toc_entry t;
|
||||
struct cd_toc_entry toc_buffer[100];
|
||||
int fd, ntocentries, i;
|
||||
|
||||
if ((fd = open(dev, O_RDONLY)) == -1)
|
||||
return -1;
|
||||
if (ioctl(fd, CDIOREADTOCHEADER, &h) == -1) {
|
||||
close(fd);
|
||||
return -1;
|
||||
}
|
||||
|
||||
ntocentries = h.ending_track - h.starting_track + 1;
|
||||
if (ntocentries > 100) {
|
||||
/* unreasonable, only 100 allowed */
|
||||
close(fd);
|
||||
return -1;
|
||||
}
|
||||
t.address_format = CD_LBA_FORMAT;
|
||||
t.starting_track = 0;
|
||||
t.data_len = ntocentries * sizeof(struct cd_toc_entry);
|
||||
t.data = toc_buffer;
|
||||
|
||||
if (ioctl(fd, CDIOREADTOCENTRYS, (char *) &t) == -1) {
|
||||
close(fd);
|
||||
return -1;
|
||||
}
|
||||
close(fd);
|
||||
|
||||
for (i = ntocentries - 1; i >= 0; i--)
|
||||
if ((toc_buffer[i].control & 4) != 0)
|
||||
/* found a data track */
|
||||
break;
|
||||
if (i < 0)
|
||||
return -1;
|
||||
|
||||
return ntohl(toc_buffer[i].addr.lba);
|
||||
}
|
106
Unix/ventoy_unix_src/DragonFly/mount_null.c
Normal file
106
Unix/ventoy_unix_src/DragonFly/mount_null.c
Normal file
@@ -0,0 +1,106 @@
|
||||
/*
|
||||
* Copyright (c) 1992, 1993, 1994
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
*
|
||||
* This code is derived from software donated to Berkeley by
|
||||
* Jan-Simon Pendry.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of the University nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* @(#) Copyright (c) 1992, 1993, 1994 The Regents of the University of California. All rights reserved.
|
||||
* @(#)mount_null.c 8.6 (Berkeley) 4/26/95
|
||||
* $FreeBSD: src/sbin/mount_null/mount_null.c,v 1.13 1999/10/09 11:54:11 phk Exp $
|
||||
*/
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/mount.h>
|
||||
#include <vfs/nullfs/null.h>
|
||||
|
||||
#include <err.h>
|
||||
#include <mntopts.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <sysexits.h>
|
||||
#include <unistd.h>
|
||||
|
||||
static struct mntopt mopts[] = {
|
||||
MOPT_STDOPTS,
|
||||
MOPT_UPDATE,
|
||||
MOPT_NULL
|
||||
};
|
||||
|
||||
static void usage(void) __dead2;
|
||||
|
||||
int
|
||||
mount_null(const char *src, const char *dst)
|
||||
{
|
||||
struct null_args args;
|
||||
int ch, mntflags;
|
||||
char source[MAXPATHLEN];
|
||||
char target[MAXPATHLEN];
|
||||
struct vfsconf vfc;
|
||||
int error;
|
||||
|
||||
bzero(&args, sizeof(args));
|
||||
mntflags = 0;
|
||||
|
||||
args.target = target;
|
||||
checkpath(src, target);
|
||||
checkpath(dst, source);
|
||||
|
||||
/*
|
||||
* Mount points that did not use distinct paths (e.g. / on /mnt)
|
||||
* used to be disallowed because mount linkages were stored in
|
||||
* vnodes and would lead to endlessly recursive trees. DragonFly
|
||||
* stores mount linkages in the namecache topology and does not
|
||||
* have this problem, so paths no longer need to be distinct.
|
||||
*/
|
||||
|
||||
error = getvfsbyname("null", &vfc);
|
||||
if (error && vfsisloadable("null")) {
|
||||
if(vfsload("null"))
|
||||
err(EX_OSERR, "vfsload(null)");
|
||||
endvfsent();
|
||||
error = getvfsbyname("null", &vfc);
|
||||
}
|
||||
if (error)
|
||||
errx(EX_OSERR, "null/loopback filesystem is not available");
|
||||
|
||||
if (mount(vfc.vfc_name, source, mntflags, &args))
|
||||
err(1, NULL);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void
|
||||
usage(void)
|
||||
{
|
||||
fprintf(stderr,
|
||||
"usage: mount_null [-o options] target_fs mount_point\n");
|
||||
fprintf(stderr,
|
||||
" mount_null -u [-o options] mount_point\n");
|
||||
exit(1);
|
||||
}
|
371
Unix/ventoy_unix_src/DragonFly/mount_tmpfs.c
Normal file
371
Unix/ventoy_unix_src/DragonFly/mount_tmpfs.c
Normal file
@@ -0,0 +1,371 @@
|
||||
/* $NetBSD: mount_tmpfs.c,v 1.24 2008/08/05 20:57:45 pooka Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2005, 2006 The NetBSD Foundation, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to The NetBSD Foundation
|
||||
* by Julio M. Merino Vidal, developed as part of Google's Summer of Code
|
||||
* 2005 program.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
|
||||
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
|
||||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/mount.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
#include <vfs/tmpfs/tmpfs_mount.h>
|
||||
|
||||
#include <ctype.h>
|
||||
#include <err.h>
|
||||
#include <errno.h>
|
||||
#include <grp.h>
|
||||
#include <mntopts.h>
|
||||
#include <pwd.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <sysexits.h>
|
||||
#include <unistd.h>
|
||||
#include <inttypes.h>
|
||||
#include <libutil.h>
|
||||
|
||||
//#include "defs.h"
|
||||
#include "mount_tmpfs.h"
|
||||
|
||||
/* --------------------------------------------------------------------- */
|
||||
|
||||
#define MOPT_TMPFSOPTS \
|
||||
{ "gid=", 0, MNT_GID, 1}, \
|
||||
{ "uid=", 0, MNT_UID, 1}, \
|
||||
{ "mode=", 0, MNT_MODE, 1}, \
|
||||
{ "inodes=", 0, MNT_INODES, 1}, \
|
||||
{ "size=", 0, MNT_SIZE, 1}, \
|
||||
{ "maxfilesize=", 0, MNT_MAXFSIZE, 1}
|
||||
|
||||
|
||||
static const struct mntopt mopts[] = {
|
||||
MOPT_STDOPTS,
|
||||
MOPT_TMPFSOPTS,
|
||||
MOPT_NULL
|
||||
};
|
||||
|
||||
static int Cflag;
|
||||
|
||||
/* --------------------------------------------------------------------- */
|
||||
|
||||
static gid_t a_gid(char *);
|
||||
static uid_t a_uid(char *);
|
||||
static mode_t a_mask(char *);
|
||||
static int64_t a_number(char *s);
|
||||
static void usage(void) __dead2;
|
||||
|
||||
/* --------------------------------------------------------------------- */
|
||||
|
||||
void
|
||||
mount_tmpfs_parseargs(int argc, char *argv[],
|
||||
struct tmpfs_mount_info *args, int *mntflags,
|
||||
char *canon_dev, char *canon_dir)
|
||||
{
|
||||
int gidset, modeset, uidset; /* Ought to be 'bool'. */
|
||||
int ch;
|
||||
gid_t gid;
|
||||
uid_t uid;
|
||||
mode_t mode;
|
||||
struct stat sb;
|
||||
int extend_flags = 0;
|
||||
char *ptr, *delim;
|
||||
|
||||
/* Set default values for mount point arguments. */
|
||||
memset(args, 0, sizeof(*args));
|
||||
args->ta_version = TMPFS_ARGS_VERSION;
|
||||
args->ta_size_max = 0;
|
||||
args->ta_nodes_max = 0;
|
||||
args->ta_maxfsize_max = 0;
|
||||
*mntflags = 0;
|
||||
|
||||
gidset = 0; gid = 0;
|
||||
uidset = 0; uid = 0;
|
||||
modeset = 0; mode = 0;
|
||||
|
||||
optind = optreset = 1;
|
||||
while ((ch = getopt(argc, argv, "Cf:g:m:n:o:s:u:")) != -1 ) {
|
||||
switch (ch) {
|
||||
case 'C':
|
||||
Cflag = 1;
|
||||
break;
|
||||
case 'f':
|
||||
args->ta_maxfsize_max = a_number(optarg);
|
||||
break;
|
||||
|
||||
case 'g':
|
||||
gid = a_gid(optarg);
|
||||
gidset = 1;
|
||||
break;
|
||||
|
||||
case 'm':
|
||||
mode = a_mask(optarg);
|
||||
modeset = 1;
|
||||
break;
|
||||
|
||||
case 'n':
|
||||
args->ta_nodes_max = a_number(optarg);
|
||||
break;
|
||||
|
||||
case 'o':
|
||||
getmntopts(optarg, mopts, mntflags, &extend_flags);
|
||||
if (extend_flags & MNT_GID) {
|
||||
ptr = strstr(optarg, "gid=");
|
||||
if(ptr) {
|
||||
delim = strstr(ptr, ",");
|
||||
if (delim) {
|
||||
*delim = '\0';
|
||||
gid = a_gid(ptr + 4);
|
||||
*delim = ',';
|
||||
} else
|
||||
gid = a_gid(ptr + 4);
|
||||
gidset = 1;
|
||||
}
|
||||
extend_flags ^= MNT_GID;
|
||||
}
|
||||
if (extend_flags & MNT_UID) {
|
||||
ptr = strstr(optarg, "uid=");
|
||||
if(ptr) {
|
||||
delim = strstr(ptr, ",");
|
||||
if (delim) {
|
||||
*delim = '\0';
|
||||
uid = a_uid(ptr + 4);
|
||||
*delim = ',';
|
||||
} else
|
||||
uid = a_uid(ptr + 4);
|
||||
uidset = 1;
|
||||
}
|
||||
extend_flags ^= MNT_UID;
|
||||
}
|
||||
if (extend_flags & MNT_MODE) {
|
||||
ptr = strstr(optarg, "mode=");
|
||||
if(ptr) {
|
||||
delim = strstr(ptr, ",");
|
||||
if (delim) {
|
||||
*delim = '\0';
|
||||
mode = a_mask(ptr + 5);
|
||||
*delim = ',';
|
||||
} else
|
||||
mode = a_mask(ptr + 5);
|
||||
modeset = 1;
|
||||
}
|
||||
extend_flags ^= MNT_MODE;
|
||||
}
|
||||
if (extend_flags & MNT_INODES) {
|
||||
ptr = strstr(optarg, "inodes=");
|
||||
if(ptr) {
|
||||
delim = strstr(ptr, ",");
|
||||
if (delim) {
|
||||
*delim = '\0';
|
||||
args->ta_nodes_max = a_number(ptr + 7);
|
||||
*delim = ',';
|
||||
} else
|
||||
args->ta_nodes_max = a_number(ptr + 7);
|
||||
}
|
||||
extend_flags ^= MNT_INODES;
|
||||
}
|
||||
if (extend_flags & MNT_SIZE) {
|
||||
ptr = strstr(optarg, "size=");
|
||||
if(ptr) {
|
||||
delim = strstr(ptr, ",");
|
||||
if (delim) {
|
||||
*delim = '\0';
|
||||
args->ta_size_max = a_number(ptr + 5);
|
||||
*delim = ',';
|
||||
} else
|
||||
args->ta_size_max = a_number(ptr + 5);
|
||||
}
|
||||
extend_flags ^= MNT_SIZE;
|
||||
}
|
||||
if (extend_flags & MNT_MAXFSIZE) {
|
||||
ptr = strstr(optarg, "maxfilesize=");
|
||||
if(ptr) {
|
||||
delim = strstr(ptr, ",");
|
||||
if (delim) {
|
||||
*delim = '\0';
|
||||
args->ta_maxfsize_max = a_number(ptr + 12);
|
||||
*delim = ',';
|
||||
} else
|
||||
args->ta_maxfsize_max = a_number(ptr + 12);
|
||||
}
|
||||
extend_flags ^= MNT_MAXFSIZE;
|
||||
}
|
||||
break;
|
||||
|
||||
case 's':
|
||||
args->ta_size_max = a_number(optarg);
|
||||
break;
|
||||
|
||||
case 'u':
|
||||
uid = a_uid(optarg);
|
||||
uidset = 1;
|
||||
break;
|
||||
|
||||
case '?':
|
||||
default:
|
||||
usage();
|
||||
}
|
||||
}
|
||||
argc -= optind;
|
||||
argv += optind;
|
||||
|
||||
if (argc != 2)
|
||||
usage();
|
||||
|
||||
strlcpy(canon_dev, argv[0], MAXPATHLEN);
|
||||
strlcpy(canon_dir, argv[1], MAXPATHLEN);
|
||||
|
||||
if (stat(canon_dir, &sb) == -1)
|
||||
err(EXIT_FAILURE, "cannot stat `%s'", canon_dir);
|
||||
|
||||
args->ta_root_uid = uidset ? uid : sb.st_uid;
|
||||
args->ta_root_gid = gidset ? gid : sb.st_gid;
|
||||
args->ta_root_mode = modeset ? mode : sb.st_mode;
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------- */
|
||||
|
||||
static gid_t
|
||||
a_gid(char *s)
|
||||
{
|
||||
struct group *gr;
|
||||
char *gname;
|
||||
gid_t gid;
|
||||
|
||||
if ((gr = getgrnam(s)) != NULL)
|
||||
gid = gr->gr_gid;
|
||||
else {
|
||||
for (gname = s; *s && isdigit(*s); ++s);
|
||||
if (!*s)
|
||||
gid = atoi(gname);
|
||||
else
|
||||
errx(EX_NOUSER, "unknown group id: %s", gname);
|
||||
}
|
||||
return (gid);
|
||||
}
|
||||
|
||||
static uid_t
|
||||
a_uid(char *s)
|
||||
{
|
||||
struct passwd *pw;
|
||||
char *uname;
|
||||
uid_t uid;
|
||||
|
||||
if ((pw = getpwnam(s)) != NULL)
|
||||
uid = pw->pw_uid;
|
||||
else {
|
||||
for (uname = s; *s && isdigit(*s); ++s);
|
||||
if (!*s)
|
||||
uid = atoi(uname);
|
||||
else
|
||||
errx(EX_NOUSER, "unknown user id: %s", uname);
|
||||
}
|
||||
return (uid);
|
||||
}
|
||||
|
||||
static mode_t
|
||||
a_mask(char *s)
|
||||
{
|
||||
int done, rv = 0;
|
||||
char *ep;
|
||||
|
||||
done = 0;
|
||||
if (*s >= '0' && *s <= '7') {
|
||||
done = 1;
|
||||
rv = strtol(s, &ep, 8);
|
||||
}
|
||||
if (!done || rv < 0 || *ep)
|
||||
errx(EX_USAGE, "invalid file mode: %s", s);
|
||||
return (rv);
|
||||
}
|
||||
|
||||
static int64_t
|
||||
a_number(char *s)
|
||||
{
|
||||
int64_t rv = 0;
|
||||
|
||||
if (dehumanize_number(s, &rv) < 0 || rv < 0)
|
||||
errx(EX_USAGE, "bad number for option: %s", s);
|
||||
return (rv);
|
||||
}
|
||||
|
||||
static void
|
||||
usage(void)
|
||||
{
|
||||
fprintf(stderr,
|
||||
"Usage: %s [-C] [-g group] [-m mode] [-n nodes] [-o options] [-s size]\n"
|
||||
" [-u user] [-f maxfilesize] tmpfs mountpoint\n", getprogname());
|
||||
exit(1);
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------- */
|
||||
|
||||
int
|
||||
mount_tmpfs(int argc, char *argv[])
|
||||
{
|
||||
struct tmpfs_mount_info args;
|
||||
char canon_dev[MAXPATHLEN], canon_dir[MAXPATHLEN];
|
||||
int mntflags;
|
||||
struct vfsconf vfc;
|
||||
int error;
|
||||
//fsnode_t copyroot = NULL;
|
||||
//fsnode_t copyhlinks = NULL;
|
||||
|
||||
mount_tmpfs_parseargs(argc, argv, &args, &mntflags,
|
||||
canon_dev, canon_dir);
|
||||
|
||||
error = getvfsbyname("tmpfs", &vfc);
|
||||
if (error && vfsisloadable("tmpfs")) {
|
||||
if(vfsload("tmpfs"))
|
||||
err(EX_OSERR, "vfsload(%s)", "tmpfs");
|
||||
endvfsent();
|
||||
error = getvfsbyname("tmpfs", &vfc);
|
||||
}
|
||||
if (error)
|
||||
errx(EX_OSERR, "%s filesystem not available", "tmpfs");
|
||||
|
||||
//if (Cflag)
|
||||
// copyroot = FSCopy(©hlinks, canon_dir);
|
||||
|
||||
if (mount(vfc.vfc_name, canon_dir, mntflags, &args) == -1)
|
||||
err(EXIT_FAILURE, "tmpfs on %s", canon_dir);
|
||||
|
||||
//if (Cflag)
|
||||
// FSPaste(canon_dir, copyroot, copyhlinks);
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
#ifndef MOUNT_NOMAIN
|
||||
int
|
||||
main(int argc, char *argv[])
|
||||
{
|
||||
setprogname(argv[0]);
|
||||
return mount_tmpfs(argc, argv);
|
||||
}
|
||||
#endif
|
37
Unix/ventoy_unix_src/DragonFly/mount_tmpfs.h
Normal file
37
Unix/ventoy_unix_src/DragonFly/mount_tmpfs.h
Normal file
@@ -0,0 +1,37 @@
|
||||
/* $NetBSD: mount_tmpfs.h,v 1.1 2008/08/05 20:57:45 pooka Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2008 The NetBSD Foundation. All Rights Reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
|
||||
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef _SBIN_MOUNT_TMPFS_MOUNT_TMPFS_H_
|
||||
#define _SBIN_MOUNT_TMPFS_MOUNT_TMPFS_H_
|
||||
|
||||
#include <vfs/tmpfs/tmpfs_mount.h>
|
||||
|
||||
int mount_tmpfs(int, char **);
|
||||
void mount_tmpfs_parseargs(int, char **, struct tmpfs_mount_info *, int *,
|
||||
char *, char *);
|
||||
|
||||
#endif /* _SBIN_MOUNT_TMPFS_MOUNT_TMPFS_H_ */
|
210
Unix/ventoy_unix_src/DragonFly/oinit.c
Normal file
210
Unix/ventoy_unix_src/DragonFly/oinit.c
Normal file
@@ -0,0 +1,210 @@
|
||||
/*-
|
||||
* Copyright (c) 1991, 1993
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to Berkeley by
|
||||
* Donn Seeley at Berkeley Software Design, Inc.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of the University nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* @(#) Copyright (c) 1991, 1993 The Regents of the University of California. All rights reserved.
|
||||
* @(#)init.c 8.1 (Berkeley) 7/15/93
|
||||
* $FreeBSD: src/sbin/init/init.c,v 1.38.2.8 2001/10/22 11:27:32 des Exp $
|
||||
*/
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <sys/mount.h>
|
||||
#include <sys/sysctl.h>
|
||||
#include <sys/wait.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
#include <db.h>
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
#include <libutil.h>
|
||||
#include <paths.h>
|
||||
#include <signal.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <syslog.h>
|
||||
#include <time.h>
|
||||
#include <ttyent.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/reboot.h>
|
||||
#include <sys/mount.h>
|
||||
#include <err.h>
|
||||
|
||||
#include <stdarg.h>
|
||||
#include <vtutil.h>
|
||||
|
||||
int boot_verbose = 0;
|
||||
|
||||
int prepare_dmtable(void);
|
||||
int mount_cd9660(char *dev, char *dir);
|
||||
int mount_null(const char *src, const char *dst);
|
||||
int mount_tmpfs(int argc, char *argv[]);
|
||||
|
||||
static int setctty(const char *name)
|
||||
{
|
||||
int fd;
|
||||
|
||||
revoke(name);
|
||||
if ((fd = open(name, O_RDWR)) == -1) {
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if (login_tty(fd) == -1) {
|
||||
exit(1);
|
||||
}
|
||||
|
||||
return fd;
|
||||
}
|
||||
|
||||
static void ventoy_init(char **argv_orig)
|
||||
{
|
||||
pid_t pid, wpid;
|
||||
int status, error;
|
||||
char arg0[MAXPATHLEN];
|
||||
char arg1[MAXPATHLEN];
|
||||
char arg2[MAXPATHLEN];
|
||||
char *argv[8];
|
||||
struct sigaction sa;
|
||||
|
||||
/* step1: mount tmpfs */
|
||||
vdebug("[VTOY] step 1: mount tmpfs ...");
|
||||
strcpy(arg0, "mount_tmpfs");
|
||||
strcpy(arg1, "tmpfs");
|
||||
strcpy(arg2, "/tmp");
|
||||
argv[0] = arg0;
|
||||
argv[1] = arg1;
|
||||
argv[2] = arg2;
|
||||
argv[3] = NULL;
|
||||
error = mount_tmpfs(3, argv);
|
||||
vdebug(" %d\n", error);
|
||||
|
||||
/* step 2: prepare dmtable */
|
||||
vdebug("[VTOY] step 2: prepare device-mapper table...\n");
|
||||
(void)prepare_dmtable();
|
||||
|
||||
/* step 3: create device mapper */
|
||||
vdebug("[VTOY] step 3: create device-mapper ...\n");
|
||||
if ((pid = fork()) == 0) {
|
||||
sigemptyset(&sa.sa_mask);
|
||||
sa.sa_flags = 0;
|
||||
sa.sa_handler = SIG_IGN;
|
||||
sigaction(SIGTSTP, &sa, NULL);
|
||||
sigaction(SIGHUP, &sa, NULL);
|
||||
|
||||
argv[0] = "dmsetup";
|
||||
argv[1] = "create";
|
||||
argv[2] = "ventoy";
|
||||
argv[3] = "/tmp/dmtable";
|
||||
argv[4] = "--readonly";
|
||||
argv[5] = NULL;
|
||||
|
||||
sigprocmask(SIG_SETMASK, &sa.sa_mask, NULL);
|
||||
execv("/sbin/dmsetup", __DECONST(char **, argv));
|
||||
exit(1); /* force single user mode */
|
||||
}
|
||||
|
||||
do {
|
||||
wpid = waitpid(-1, &status, WUNTRACED);
|
||||
} while (wpid != pid);
|
||||
|
||||
/* step 4: mount iso */
|
||||
vdebug("[VTOY] step 4: mount device-mapper ...");
|
||||
strcpy(arg0, "/dev/mapper/ventoy");
|
||||
strcpy(arg1, "/new_root");
|
||||
error = mount_cd9660(arg0, arg1);
|
||||
vdebug(" %d\n", error);
|
||||
|
||||
/* step 5: mount devfs */
|
||||
vdebug("[VTOY] step 5: mount devfs ...");
|
||||
strcpy(arg0, "/dev");
|
||||
strcpy(arg1, "/new_root/dev");
|
||||
mount_null(arg0, arg1);
|
||||
vdebug(" %d\n", error);
|
||||
|
||||
/* step 6: umount tmpfs */
|
||||
error = unmount("/tmp", 0);
|
||||
vdebug("[VTOY] step 6: unmount tmpfs %d\n", error);
|
||||
|
||||
/* step 7: swich_root */
|
||||
vdebug("[VTOY] step 7: switch root ...\n");
|
||||
error = chdir("/new_root");
|
||||
if (error)
|
||||
{
|
||||
printf("[VTOY] chdir /new_root failed %d\n", error);
|
||||
goto chroot_failed;
|
||||
}
|
||||
|
||||
error = chroot_kernel("/new_root");
|
||||
if (error)
|
||||
{
|
||||
printf("[VTOY] chroot_kernel /new_root failed %d\n", error);
|
||||
goto chroot_failed;
|
||||
}
|
||||
|
||||
error = chroot("/new_root");
|
||||
if (error)
|
||||
{
|
||||
printf("[VTOY] chroot /new_root failed %d\n", error);
|
||||
goto chroot_failed;
|
||||
}
|
||||
|
||||
vdebug("[VTOY] step 8: now run /sbin/init ...\n");
|
||||
execv("/sbin/init", __DECONST(char **, argv_orig));
|
||||
|
||||
/* We failed to exec /sbin/init in the chroot, sleep forever */
|
||||
chroot_failed:
|
||||
printf("[VTOY] ################### DEAD ################\n");
|
||||
while(1) {
|
||||
sleep(3);
|
||||
};
|
||||
}
|
||||
|
||||
int main(int argc __unused, char **argv)
|
||||
{
|
||||
size_t varsize = sizeof(int);
|
||||
|
||||
/* Dispose of random users. */
|
||||
if (getuid() != 0)
|
||||
errx(1, "%s", strerror(EPERM));
|
||||
|
||||
/* Init is not allowed to die, it would make the kernel panic */
|
||||
signal(SIGTERM, SIG_IGN);
|
||||
|
||||
setctty(_PATH_CONSOLE);
|
||||
|
||||
sysctlbyname("debug.bootverbose", &boot_verbose, &varsize, NULL, 0);
|
||||
|
||||
vdebug("======= Ventoy Init Start ========\n");
|
||||
|
||||
ventoy_init(argv);
|
||||
return 1;
|
||||
}
|
||||
|
@@ -0,0 +1,54 @@
|
||||
/*-
|
||||
* Copyright (c) 1995
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to Berkeley
|
||||
* by Pace Willisson (pace@blitz.com). The Rock Ridge Extension
|
||||
* Support code is derived from software contributed to Berkeley
|
||||
* by Atsushi Murai (amurai@spec.co.jp).
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of the University nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* @(#)cd9660_mount.h 8.1 (Berkeley) 5/24/95
|
||||
* $FreeBSD: src/sys/isofs/cd9660/cd9660_mount.h,v 1.3.2.2 2001/03/14 12:03:50 bp Exp $
|
||||
*/
|
||||
#include <sys/iconv.h>
|
||||
/*
|
||||
* Arguments to mount ISO 9660 filesystems.
|
||||
*/
|
||||
struct iso_args {
|
||||
char *fspec; /* block special device to mount */
|
||||
struct export_args export; /* network export info */
|
||||
int flags; /* mounting flags, see below */
|
||||
int ssector; /* starting sector, 0 for 1st session */
|
||||
char cs_disk[ICONV_CSNMAXLEN]; /* disk charset for Joliet cs conversion */
|
||||
char cs_local[ICONV_CSNMAXLEN]; /* local charset for Joliet cs conversion */
|
||||
};
|
||||
#define ISOFSMNT_NORRIP 0x00000001 /* disable Rock Ridge Ext.*/
|
||||
#define ISOFSMNT_GENS 0x00000002 /* enable generation numbers */
|
||||
#define ISOFSMNT_EXTATT 0x00000004 /* enable extended attributes */
|
||||
#define ISOFSMNT_NOJOLIET 0x00000008 /* disable Joliet Ext.*/
|
||||
#define ISOFSMNT_BROKENJOLIET 0x00000010 /* allow broken Joliet disks */
|
||||
#define ISOFSMNT_KICONV 0x00000020 /* Use libiconv to convert chars */
|
65
Unix/ventoy_unix_src/DragonFly/vfs/nullfs/null.h
Normal file
65
Unix/ventoy_unix_src/DragonFly/vfs/nullfs/null.h
Normal file
@@ -0,0 +1,65 @@
|
||||
/*
|
||||
* Copyright (c) 1992, 1993
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
*
|
||||
* This code is derived from software donated to Berkeley by
|
||||
* Jan-Simon Pendry.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of the University nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* @(#)null.h 8.3 (Berkeley) 8/20/94
|
||||
*
|
||||
* $FreeBSD: src/sys/miscfs/nullfs/null.h,v 1.11.2.3 2001/06/26 04:20:09 bp Exp $
|
||||
* $DragonFly: src/sys/vfs/nullfs/null.h,v 1.10 2008/09/18 16:08:32 dillon Exp $
|
||||
*/
|
||||
|
||||
struct null_args {
|
||||
char *target; /* Target of loopback */
|
||||
struct export_args export; /* Network export information */
|
||||
};
|
||||
|
||||
#if defined(_KERNEL) || defined(_KERNEL_STRUCTURES)
|
||||
|
||||
struct null_mount {
|
||||
struct mount *nullm_vfs;
|
||||
struct vnode *nullm_rootvp; /* Reference to root null_node */
|
||||
struct netexport export;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef _KERNEL
|
||||
#define MOUNTTONULLMOUNT(mp) ((struct null_mount *)((mp)->mnt_data))
|
||||
|
||||
#ifdef NULLFS_DEBUG
|
||||
#define NULLFSDEBUG(format, args...) kprintf(format ,## args)
|
||||
#else
|
||||
#define NULLFSDEBUG(format, args...)
|
||||
#endif /* NULLFS_DEBUG */
|
||||
|
||||
int nullfs_export(struct mount *mp, int op,
|
||||
const struct export_args *export);
|
||||
|
||||
#endif /* _KERNEL */
|
63
Unix/ventoy_unix_src/DragonFly/vfs/tmpfs/tmpfs_mount.h
Normal file
63
Unix/ventoy_unix_src/DragonFly/vfs/tmpfs/tmpfs_mount.h
Normal file
@@ -0,0 +1,63 @@
|
||||
/* $NetBSD: tmpfs_args.h,v 1.3 2008/07/29 09:10:09 pooka Exp $ */
|
||||
/* $DragonFly: tmpfs_mount.h,v 1.3 2017/10/29 09:10:09 markuspf Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2005, 2006, 2007 The NetBSD Foundation, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to The NetBSD Foundation
|
||||
* by Julio M. Merino Vidal, developed as part of Google's Summer of Code
|
||||
* 2005 program.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
|
||||
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
|
||||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef VFS_TMPFS_TMPFS_MOUNT_H_
|
||||
#define VFS_TMPFS_TMPFS_MOUNT_H_
|
||||
|
||||
/*
|
||||
* This structure is used to communicate mount parameters between userland
|
||||
* and kernel space.
|
||||
*/
|
||||
#define TMPFS_ARGS_VERSION 2
|
||||
struct tmpfs_mount_info {
|
||||
int ta_version;
|
||||
|
||||
/* Size counters. */
|
||||
ino_t ta_nodes_max;
|
||||
off_t ta_size_max;
|
||||
size_t ta_maxfsize_max;
|
||||
|
||||
/* Root node attributes. */
|
||||
uid_t ta_root_uid;
|
||||
gid_t ta_root_gid;
|
||||
mode_t ta_root_mode;
|
||||
};
|
||||
|
||||
#define MNT_GID 0x00000001
|
||||
#define MNT_UID 0x00000002
|
||||
#define MNT_MODE 0x00000004
|
||||
#define MNT_INODES 0x00000008
|
||||
#define MNT_SIZE 0x00000010
|
||||
#define MNT_MAXFSIZE 0x00000020
|
||||
|
||||
#endif /* VFS_TMPFS_TMPFS_MOUNT_H_ */
|
33
Unix/ventoy_unix_src/DragonFly/vtutil.h
Normal file
33
Unix/ventoy_unix_src/DragonFly/vtutil.h
Normal file
@@ -0,0 +1,33 @@
|
||||
|
||||
#ifndef __UTIL_H__
|
||||
#define __UTIL_H__
|
||||
|
||||
extern int boot_verbose;
|
||||
#define vdebug(fmt, ...) if (boot_verbose) { printf(fmt, ##__VA_ARGS__); usleep(500000); }
|
||||
#define verror printf
|
||||
|
||||
|
||||
#pragma pack(4)
|
||||
typedef struct ventoy_image_desc
|
||||
{
|
||||
uint64_t disk_size;
|
||||
uint64_t part1_size;
|
||||
uint8_t disk_uuid[16];
|
||||
uint8_t disk_signature[4];
|
||||
uint32_t img_chunk_count;
|
||||
/* ventoy_img_chunk list */
|
||||
}ventoy_image_desc;
|
||||
|
||||
typedef struct ventoy_img_chunk
|
||||
{
|
||||
uint32_t img_start_sector; // sector size: 2KB
|
||||
uint32_t img_end_sector; // included
|
||||
|
||||
uint64_t disk_start_sector; // in disk_sector_size
|
||||
uint64_t disk_end_sector; // included
|
||||
}ventoy_img_chunk;
|
||||
#pragma pack()
|
||||
|
||||
|
||||
#endif
|
||||
|
224
Unix/ventoy_unix_src/DragonFly/walk_disk.c
Normal file
224
Unix/ventoy_unix_src/DragonFly/walk_disk.c
Normal file
@@ -0,0 +1,224 @@
|
||||
/*-
|
||||
* Copyright (c) 1991, 1993
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to Berkeley by
|
||||
* Donn Seeley at Berkeley Software Design, Inc.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of the University nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* @(#) Copyright (c) 1991, 1993 The Regents of the University of California. All rights reserved.
|
||||
* @(#)init.c 8.1 (Berkeley) 7/15/93
|
||||
* $FreeBSD: src/sbin/init/init.c,v 1.38.2.8 2001/10/22 11:27:32 des Exp $
|
||||
*/
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <sys/fcntl.h>
|
||||
|
||||
#include <dirent.h>
|
||||
#include <err.h>
|
||||
#include <errno.h>
|
||||
#include <fts.h>
|
||||
#include <grp.h>
|
||||
#include <inttypes.h>
|
||||
#include <limits.h>
|
||||
#include <locale.h>
|
||||
#include <pwd.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <vtutil.h>
|
||||
|
||||
static int find_disk_by_signature(uint8_t *uuid, uint8_t *sig, uint64_t size, int *count, char *name)
|
||||
{
|
||||
int fd;
|
||||
int len;
|
||||
int cnt = 0;
|
||||
FTS *ftsp;
|
||||
FTSENT *p;
|
||||
uint8_t mbr[512];
|
||||
char devname[MAXPATHLEN];
|
||||
static char dev[] = "/dev", *devav[] = {dev, NULL};
|
||||
|
||||
vdebug("[VTOY] find_disk_by_signature %llu\n", size);
|
||||
|
||||
ftsp = fts_open(devav, FTS_PHYSICAL | FTS_NOCHDIR, NULL);
|
||||
while ((p = fts_read(ftsp)) != NULL)
|
||||
{
|
||||
if (p->fts_level == 1 && p->fts_statp && p->fts_name && p->fts_statp->st_size == size)
|
||||
{
|
||||
sprintf(devname, "/dev/%s", p->fts_name);
|
||||
|
||||
fd = open(devname, O_RDONLY);
|
||||
if (fd < 0)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
memset(mbr, 0, 512);
|
||||
read(fd, mbr, 512);
|
||||
close(fd);
|
||||
|
||||
if (memcmp(mbr + 0x180, uuid, 16) == 0 && memcmp(mbr + 0x1B8, sig, 4) == 0)
|
||||
{
|
||||
cnt++;
|
||||
strcpy(name, p->fts_name);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
*count = cnt;
|
||||
fts_close(ftsp);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int find_disk_by_size(uint64_t size, const char *prefix, int *count, char *name)
|
||||
{
|
||||
int len;
|
||||
int cnt = 0;
|
||||
FTS *ftsp;
|
||||
FTSENT *p;
|
||||
static char dev[] = "/dev", *devav[] = {dev, NULL};
|
||||
|
||||
if (prefix)
|
||||
{
|
||||
len = strlen(prefix);
|
||||
}
|
||||
|
||||
name[0] = 0;
|
||||
ftsp = fts_open(devav, FTS_PHYSICAL | FTS_NOCHDIR, NULL);
|
||||
while ((p = fts_read(ftsp)) != NULL)
|
||||
{
|
||||
if (p->fts_level == 1 && p->fts_statp && p->fts_name && p->fts_statp->st_size == size)
|
||||
{
|
||||
if (prefix)
|
||||
{
|
||||
if (strncmp(p->fts_name, prefix, len) == 0)
|
||||
{
|
||||
cnt++;
|
||||
if (name[0] == 0)
|
||||
strcpy(name, p->fts_name);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
cnt++;
|
||||
if (name[0] == 0)
|
||||
strcpy(name, p->fts_name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
*count = cnt;
|
||||
fts_close(ftsp);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int prepare_dmtable(void)
|
||||
{
|
||||
int count = 0;
|
||||
uint32_t i = 0;
|
||||
uint32_t sector_start = 0;
|
||||
uint32_t disk_sector_num = 0;
|
||||
FILE *fIn, *fOut;
|
||||
char disk[MAXPATHLEN];
|
||||
char prefix[MAXPATHLEN];
|
||||
ventoy_image_desc desc;
|
||||
ventoy_img_chunk chunk;
|
||||
|
||||
fIn = fopen("/dmtable", "rb");
|
||||
if (!fIn)
|
||||
{
|
||||
printf("Failed to open dmtable\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
fOut = fopen("/tmp/dmtable", "w+");
|
||||
if (!fOut)
|
||||
{
|
||||
printf("Failed to create /tmp/dmtable %d\n", errno);
|
||||
fclose(fIn);
|
||||
return 1;
|
||||
}
|
||||
|
||||
fread(&desc, 1, sizeof(desc), fIn);
|
||||
|
||||
vdebug("[VTOY] disksize:%lu part1size:%lu chunkcount:%u\n", desc.disk_size, desc.part1_size, desc.img_chunk_count);
|
||||
|
||||
for (i = 0; count <= 0 && i < 10; i++)
|
||||
{
|
||||
sleep(2);
|
||||
find_disk_by_size(desc.part1_size, NULL, &count, disk);
|
||||
vdebug("[VTOY] find disk by part1 size, i=%d, count=%d, %s\n", i, count, disk);
|
||||
}
|
||||
|
||||
if (count == 0)
|
||||
{
|
||||
goto end;
|
||||
}
|
||||
else if (count > 1)
|
||||
{
|
||||
find_disk_by_signature(desc.disk_uuid, desc.disk_signature, desc.disk_size, &count, prefix);
|
||||
vdebug("[VTOY] find disk by signature: %d %s\n", count, prefix);
|
||||
|
||||
if (count != 1)
|
||||
{
|
||||
printf("[VTOY] Failed to find disk by signature\n");
|
||||
goto end;
|
||||
}
|
||||
|
||||
find_disk_by_size(desc.part1_size, prefix, &count, disk);
|
||||
vdebug("[VTOY] find disk by part1 size with prefix %s : %d %s\n", prefix, count, disk);
|
||||
}
|
||||
|
||||
for (i = 0; i < desc.img_chunk_count; i++)
|
||||
{
|
||||
fread(&chunk, 1, sizeof(chunk), fIn);
|
||||
|
||||
sector_start = chunk.img_start_sector;
|
||||
disk_sector_num = (uint32_t)(chunk.disk_end_sector + 1 - chunk.disk_start_sector);
|
||||
|
||||
fprintf(fOut, "%u %u linear /dev/%s %llu\n",
|
||||
(sector_start << 2), disk_sector_num,
|
||||
disk, (unsigned long long)chunk.disk_start_sector - 2048);
|
||||
|
||||
vdebug("%u %u linear /dev/%s %llu\n",
|
||||
(sector_start << 2), disk_sector_num,
|
||||
disk, (unsigned long long)chunk.disk_start_sector - 2048);
|
||||
}
|
||||
|
||||
end:
|
||||
fclose(fIn);
|
||||
fclose(fOut);
|
||||
return 0;
|
||||
}
|
||||
|
@@ -289,7 +289,7 @@ out:
|
||||
}
|
||||
|
||||
|
||||
static DWORD GetVentoyVolumeName(int PhyDrive, UINT32 StartSectorId, CHAR *NameBuf, UINT32 BufLen, BOOL DelSlash)
|
||||
static DWORD GetVentoyVolumeName(int PhyDrive, UINT64 StartSectorId, CHAR *NameBuf, UINT32 BufLen, BOOL DelSlash)
|
||||
{
|
||||
size_t len;
|
||||
BOOL bRet;
|
||||
@@ -304,7 +304,7 @@ static DWORD GetVentoyVolumeName(int PhyDrive, UINT32 StartSectorId, CHAR *NameB
|
||||
|
||||
PartOffset = 512ULL * StartSectorId;
|
||||
|
||||
Log("GetVentoyVolumeName PhyDrive %d SectorStart:%u PartOffset:%llu", PhyDrive, StartSectorId, (ULONGLONG)PartOffset);
|
||||
Log("GetVentoyVolumeName PhyDrive %d SectorStart:%llu PartOffset:%llu", PhyDrive, (ULONGLONG)StartSectorId, (ULONGLONG)PartOffset);
|
||||
|
||||
hVolume = FindFirstVolumeA(VolumeName, sizeof(VolumeName));
|
||||
if (hVolume == INVALID_HANDLE_VALUE)
|
||||
@@ -1401,18 +1401,18 @@ int ClearVentoyFromPhyDrive(HWND hWnd, PHY_DRIVE_INFO *pPhyDrive, char *pDrvLett
|
||||
goto End;
|
||||
}
|
||||
|
||||
// clear first and last 1MB space
|
||||
pTmpBuf = malloc(SIZE_1MB);
|
||||
// clear first and last 2MB space
|
||||
pTmpBuf = malloc(SIZE_2MB);
|
||||
if (!pTmpBuf)
|
||||
{
|
||||
Log("Failed to alloc memory.");
|
||||
rc = 1;
|
||||
goto End;
|
||||
}
|
||||
memset(pTmpBuf, 0, SIZE_1MB);
|
||||
memset(pTmpBuf, 0, SIZE_2MB);
|
||||
|
||||
SET_FILE_POS(512);
|
||||
bRet = WriteFile(hDrive, pTmpBuf, SIZE_1MB - 512, &dwSize, NULL);
|
||||
bRet = WriteFile(hDrive, pTmpBuf, SIZE_2MB - 512, &dwSize, NULL);
|
||||
Log("Write fisrt 1MB ret:%d size:%u err:%d", bRet, dwSize, LASTERR);
|
||||
if (!bRet)
|
||||
{
|
||||
@@ -1420,8 +1420,8 @@ int ClearVentoyFromPhyDrive(HWND hWnd, PHY_DRIVE_INFO *pPhyDrive, char *pDrvLett
|
||||
goto End;
|
||||
}
|
||||
|
||||
SET_FILE_POS(SIZE_1MB);
|
||||
bRet = WriteFile(hDrive, pTmpBuf, SIZE_1MB, &dwSize, NULL);
|
||||
SET_FILE_POS(pPhyDrive->SizeInBytes - SIZE_2MB);
|
||||
bRet = WriteFile(hDrive, pTmpBuf, SIZE_2MB, &dwSize, NULL);
|
||||
Log("Write 2nd 1MB ret:%d size:%u err:%d", bRet, dwSize, LASTERR);
|
||||
if (!bRet)
|
||||
{
|
||||
@@ -1430,30 +1430,71 @@ int ClearVentoyFromPhyDrive(HWND hWnd, PHY_DRIVE_INFO *pPhyDrive, char *pDrvLett
|
||||
}
|
||||
|
||||
SET_FILE_POS(0);
|
||||
bRet = ReadFile(hDrive, &MBR, sizeof(MBR), &dwSize, NULL);
|
||||
Log("Read MBR ret:%d size:%u err:%d", bRet, dwSize, LASTERR);
|
||||
if (!bRet)
|
||||
|
||||
if (pPhyDrive->SizeInBytes > 2199023255552ULL)
|
||||
{
|
||||
rc = 1;
|
||||
goto End;
|
||||
VTOY_GPT_INFO *pGptInfo;
|
||||
VTOY_GPT_HDR BackupHead;
|
||||
LARGE_INTEGER liCurrentPosition;
|
||||
|
||||
pGptInfo = (VTOY_GPT_INFO *)pTmpBuf;
|
||||
|
||||
VentoyFillWholeGpt(pPhyDrive->SizeInBytes, pGptInfo);
|
||||
|
||||
SET_FILE_POS(pPhyDrive->SizeInBytes - 512);
|
||||
VentoyFillBackupGptHead(pGptInfo, &BackupHead);
|
||||
if (!WriteFile(hDrive, &BackupHead, sizeof(VTOY_GPT_HDR), &dwSize, NULL))
|
||||
{
|
||||
rc = 1;
|
||||
Log("Write GPT Backup Head Failed, dwSize:%u (%u) ErrCode:%u", dwSize, sizeof(VTOY_GPT_INFO), GetLastError());
|
||||
goto End;
|
||||
}
|
||||
|
||||
SET_FILE_POS(pPhyDrive->SizeInBytes - 512 * 33);
|
||||
if (!WriteFile(hDrive, pGptInfo->PartTbl, sizeof(pGptInfo->PartTbl), &dwSize, NULL))
|
||||
{
|
||||
rc = 1;
|
||||
Log("Write GPT Backup Part Table Failed, dwSize:%u (%u) ErrCode:%u", dwSize, sizeof(VTOY_GPT_INFO), GetLastError());
|
||||
goto End;
|
||||
}
|
||||
|
||||
SET_FILE_POS(0);
|
||||
if (!WriteFile(hDrive, pGptInfo, sizeof(VTOY_GPT_INFO), &dwSize, NULL))
|
||||
{
|
||||
rc = 1;
|
||||
Log("Write GPT Info Failed, dwSize:%u (%u) ErrCode:%u", dwSize, sizeof(VTOY_GPT_INFO), GetLastError());
|
||||
goto End;
|
||||
}
|
||||
|
||||
Log("Write GPT Info OK ...");
|
||||
}
|
||||
|
||||
//clear boot code and partition table (reserved disk signature)
|
||||
memset(MBR.BootCode, 0, 440);
|
||||
memset(MBR.PartTbl, 0, sizeof(MBR.PartTbl));
|
||||
|
||||
VentoyFillLocation(pPhyDrive->SizeInBytes, 2048, (UINT32)(pPhyDrive->SizeInBytes / 512 - 2048), MBR.PartTbl);
|
||||
|
||||
MBR.PartTbl[0].Active = 0x00; // bootable
|
||||
MBR.PartTbl[0].FsFlag = 0x07; // exFAT/NTFS/HPFS
|
||||
|
||||
SET_FILE_POS(0);
|
||||
bRet = WriteFile(hDrive, &MBR, 512, &dwSize, NULL);
|
||||
Log("Write MBR ret:%d size:%u err:%d", bRet, dwSize, LASTERR);
|
||||
if (!bRet)
|
||||
else
|
||||
{
|
||||
rc = 1;
|
||||
goto End;
|
||||
bRet = ReadFile(hDrive, &MBR, sizeof(MBR), &dwSize, NULL);
|
||||
Log("Read MBR ret:%d size:%u err:%d", bRet, dwSize, LASTERR);
|
||||
if (!bRet)
|
||||
{
|
||||
rc = 1;
|
||||
goto End;
|
||||
}
|
||||
|
||||
//clear boot code and partition table (reserved disk signature)
|
||||
memset(MBR.BootCode, 0, 440);
|
||||
memset(MBR.PartTbl, 0, sizeof(MBR.PartTbl));
|
||||
|
||||
VentoyFillMBRLocation(pPhyDrive->SizeInBytes, 2048, (UINT32)(pPhyDrive->SizeInBytes / 512 - 2048), MBR.PartTbl);
|
||||
|
||||
MBR.PartTbl[0].Active = 0x00; // bootable
|
||||
MBR.PartTbl[0].FsFlag = 0x07; // exFAT/NTFS/HPFS
|
||||
|
||||
SET_FILE_POS(0);
|
||||
bRet = WriteFile(hDrive, &MBR, 512, &dwSize, NULL);
|
||||
Log("Write MBR ret:%d size:%u err:%d", bRet, dwSize, LASTERR);
|
||||
if (!bRet)
|
||||
{
|
||||
rc = 1;
|
||||
goto End;
|
||||
}
|
||||
}
|
||||
|
||||
Log("Clear Ventoy successfully finished");
|
||||
@@ -1490,7 +1531,7 @@ End:
|
||||
if (state != 1)
|
||||
{
|
||||
Log("need to mount ventoy part1...");
|
||||
if (0 == GetVentoyVolumeName(pPhyDrive->PhyDrive, MBR.PartTbl[0].StartSectorId, DriveLetters, sizeof(DriveLetters), FALSE))
|
||||
if (0 == GetVentoyVolumeName(pPhyDrive->PhyDrive, 2048, DriveLetters, sizeof(DriveLetters), FALSE))
|
||||
{
|
||||
DriveName[0] = MountDrive;
|
||||
bRet = SetVolumeMountPointA(DriveName, DriveLetters);
|
||||
@@ -1528,6 +1569,10 @@ int InstallVentoy2PhyDrive(PHY_DRIVE_INFO *pPhyDrive, int PartStyle)
|
||||
CHAR DriveLetters[MAX_PATH] = { 0 };
|
||||
MBR_HEAD MBR;
|
||||
VTOY_GPT_INFO *pGptInfo = NULL;
|
||||
UINT64 Part1StartSector = 0;
|
||||
UINT64 Part1SectorCount = 0;
|
||||
UINT64 Part2StartSector = 0;
|
||||
|
||||
|
||||
Log("InstallVentoy2PhyDrive %s PhyDrive%d <<%s %s %dGB>>",
|
||||
PartStyle ? "GPT" : "MBR", pPhyDrive->PhyDrive, pPhyDrive->VendorId, pPhyDrive->ProductId,
|
||||
@@ -1541,10 +1586,19 @@ int InstallVentoy2PhyDrive(PHY_DRIVE_INFO *pPhyDrive, int PartStyle)
|
||||
|
||||
PROGRESS_BAR_SET_POS(PT_LOCK_FOR_CLEAN);
|
||||
|
||||
VentoyFillMBR(pPhyDrive->SizeInBytes, &MBR, PartStyle);//also used to format 1st partition in GPT mode
|
||||
if (PartStyle)
|
||||
{
|
||||
VentoyFillGpt(pPhyDrive->SizeInBytes, pGptInfo);
|
||||
Part1StartSector = pGptInfo->PartTbl[0].StartLBA;
|
||||
Part1SectorCount = pGptInfo->PartTbl[0].LastLBA - Part1StartSector + 1;
|
||||
Part2StartSector = pGptInfo->PartTbl[1].StartLBA;
|
||||
}
|
||||
else
|
||||
{
|
||||
VentoyFillMBR(pPhyDrive->SizeInBytes, &MBR, PartStyle);
|
||||
Part1StartSector = MBR.PartTbl[0].StartSectorId;
|
||||
Part1SectorCount = MBR.PartTbl[0].SectorCount;
|
||||
Part2StartSector = MBR.PartTbl[1].StartSectorId;
|
||||
}
|
||||
|
||||
Log("Lock disk for clean ............................. ");
|
||||
@@ -1608,7 +1662,7 @@ int InstallVentoy2PhyDrive(PHY_DRIVE_INFO *pPhyDrive, int PartStyle)
|
||||
//Refresh Drive Layout
|
||||
DeviceIoControl(hDrive, IOCTL_DISK_UPDATE_PROPERTIES, NULL, 0, NULL, 0, &dwSize, NULL);
|
||||
|
||||
disk_io_set_param(hDrive, MBR.PartTbl[0].StartSectorId + MBR.PartTbl[0].SectorCount);
|
||||
disk_io_set_param(hDrive, Part1StartSector + Part1SectorCount);// include the 2048 sector gap
|
||||
|
||||
PROGRESS_BAR_SET_POS(PT_FORMAT_PART1);
|
||||
|
||||
@@ -1626,9 +1680,12 @@ int InstallVentoy2PhyDrive(PHY_DRIVE_INFO *pPhyDrive, int PartStyle)
|
||||
goto End;
|
||||
}
|
||||
|
||||
|
||||
|
||||
PROGRESS_BAR_SET_POS(PT_FORMAT_PART2);
|
||||
Log("Writing part2 FAT img ...");
|
||||
if (0 != FormatPart2Fat(hDrive, MBR.PartTbl[1].StartSectorId))
|
||||
|
||||
if (0 != FormatPart2Fat(hDrive, Part2StartSector))
|
||||
{
|
||||
Log("FormatPart2Fat failed.");
|
||||
rc = 1;
|
||||
@@ -1679,7 +1736,7 @@ int InstallVentoy2PhyDrive(PHY_DRIVE_INFO *pPhyDrive, int PartStyle)
|
||||
}
|
||||
|
||||
Log("Write GPT Info OK ...");
|
||||
memcpy(&(pPhyDrive->MBR), &MBR, 512);
|
||||
memcpy(&(pPhyDrive->MBR), &(pGptInfo->MBR), 512);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1728,7 +1785,8 @@ End:
|
||||
if (state != 1)
|
||||
{
|
||||
Log("need to mount ventoy part1...");
|
||||
if (0 == GetVentoyVolumeName(pPhyDrive->PhyDrive, MBR.PartTbl[0].StartSectorId, DriveLetters, sizeof(DriveLetters), FALSE))
|
||||
|
||||
if (0 == GetVentoyVolumeName(pPhyDrive->PhyDrive, Part1StartSector, DriveLetters, sizeof(DriveLetters), FALSE))
|
||||
{
|
||||
DriveName[0] = MountDrive;
|
||||
bRet = SetVolumeMountPointA(DriveName, DriveLetters);
|
||||
@@ -1872,7 +1930,7 @@ int UpdateVentoy2PhyDrive(PHY_DRIVE_INFO *pPhyDrive)
|
||||
|
||||
Log("Lock volume for update .......................... ");
|
||||
hVolume = INVALID_HANDLE_VALUE;
|
||||
Status = GetVentoyVolumeName(pPhyDrive->PhyDrive, (UINT32)StartSector, DriveLetters, sizeof(DriveLetters), TRUE);
|
||||
Status = GetVentoyVolumeName(pPhyDrive->PhyDrive, StartSector, DriveLetters, sizeof(DriveLetters), TRUE);
|
||||
if (ERROR_SUCCESS == Status)
|
||||
{
|
||||
Log("Now lock and dismount volume <%s>", DriveLetters);
|
||||
|
@@ -382,7 +382,7 @@ BOOL IsVentoyLogicalDrive(CHAR DriveLetter)
|
||||
}
|
||||
|
||||
|
||||
int VentoyFillLocation(UINT64 DiskSizeInBytes, UINT32 StartSectorId, UINT32 SectorCount, PART_TABLE *Table)
|
||||
int VentoyFillMBRLocation(UINT64 DiskSizeInBytes, UINT32 StartSectorId, UINT32 SectorCount, PART_TABLE *Table)
|
||||
{
|
||||
BYTE Head;
|
||||
BYTE Sector;
|
||||
@@ -473,7 +473,7 @@ int VentoyFillMBR(UINT64 DiskSizeBytes, MBR_HEAD *pMBR, int PartStyle)
|
||||
//Part1
|
||||
PartStartSector = VENTOY_PART1_START_SECTOR;
|
||||
PartSectorCount = DiskSectorCount - ReservedSector - VENTOY_EFI_PART_SIZE / 512 - PartStartSector;
|
||||
VentoyFillLocation(DiskSizeBytes, PartStartSector, PartSectorCount, pMBR->PartTbl);
|
||||
VentoyFillMBRLocation(DiskSizeBytes, PartStartSector, PartSectorCount, pMBR->PartTbl);
|
||||
|
||||
pMBR->PartTbl[0].Active = 0x80; // bootable
|
||||
pMBR->PartTbl[0].FsFlag = 0x07; // exFAT/NTFS/HPFS
|
||||
@@ -481,7 +481,7 @@ int VentoyFillMBR(UINT64 DiskSizeBytes, MBR_HEAD *pMBR, int PartStyle)
|
||||
//Part2
|
||||
PartStartSector += PartSectorCount;
|
||||
PartSectorCount = VENTOY_EFI_PART_SIZE / 512;
|
||||
VentoyFillLocation(DiskSizeBytes, PartStartSector, PartSectorCount, pMBR->PartTbl + 1);
|
||||
VentoyFillMBRLocation(DiskSizeBytes, PartStartSector, PartSectorCount, pMBR->PartTbl + 1);
|
||||
|
||||
pMBR->PartTbl[1].Active = 0x00;
|
||||
pMBR->PartTbl[1].FsFlag = 0xEF; // EFI System Partition
|
||||
@@ -538,6 +538,45 @@ static int VentoyFillProtectMBR(UINT64 DiskSizeBytes, MBR_HEAD *pMBR)
|
||||
return 0;
|
||||
}
|
||||
|
||||
int VentoyFillWholeGpt(UINT64 DiskSizeBytes, VTOY_GPT_INFO *pInfo)
|
||||
{
|
||||
UINT64 Part1SectorCount = 0;
|
||||
UINT64 DiskSectorCount = DiskSizeBytes / 512;
|
||||
VTOY_GPT_HDR *Head = &pInfo->Head;
|
||||
VTOY_GPT_PART_TBL *Table = pInfo->PartTbl;
|
||||
static GUID WindowsDataPartType = { 0xebd0a0a2, 0xb9e5, 0x4433, { 0x87, 0xc0, 0x68, 0xb6, 0xb7, 0x26, 0x99, 0xc7 } };
|
||||
|
||||
VentoyFillProtectMBR(DiskSizeBytes, &pInfo->MBR);
|
||||
|
||||
Part1SectorCount = DiskSectorCount - 33 - 2048;
|
||||
|
||||
memcpy(Head->Signature, "EFI PART", 8);
|
||||
Head->Version[2] = 0x01;
|
||||
Head->Length = 92;
|
||||
Head->Crc = 0;
|
||||
Head->EfiStartLBA = 1;
|
||||
Head->EfiBackupLBA = DiskSectorCount - 1;
|
||||
Head->PartAreaStartLBA = 34;
|
||||
Head->PartAreaEndLBA = DiskSectorCount - 34;
|
||||
CoCreateGuid(&Head->DiskGuid);
|
||||
Head->PartTblStartLBA = 2;
|
||||
Head->PartTblTotNum = 128;
|
||||
Head->PartTblEntryLen = 128;
|
||||
|
||||
|
||||
memcpy(&(Table[0].PartType), &WindowsDataPartType, sizeof(GUID));
|
||||
CoCreateGuid(&(Table[0].PartGuid));
|
||||
Table[0].StartLBA = 2048;
|
||||
Table[0].LastLBA = 2048 + Part1SectorCount - 1;
|
||||
Table[0].Attr = 0;
|
||||
memcpy(Table[0].Name, L"Data", 4 * 2);
|
||||
|
||||
//Update CRC
|
||||
Head->PartTblCrc = VentoyCrc32(Table, sizeof(pInfo->PartTbl));
|
||||
Head->Crc = VentoyCrc32(Head, Head->Length);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int VentoyFillGpt(UINT64 DiskSizeBytes, VTOY_GPT_INFO *pInfo)
|
||||
{
|
||||
|
@@ -153,6 +153,8 @@ static BOOL IsVentoyPhyDrive(int PhyDrive, UINT64 SizeBytes, MBR_HEAD *pMBR, UIN
|
||||
}
|
||||
|
||||
*Part2StartSector = pGpt->PartTbl[1].StartLBA;
|
||||
|
||||
memcpy(pMBR, &(pGpt->MBR), sizeof(MBR_HEAD));
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -188,9 +190,10 @@ static BOOL IsVentoyPhyDrive(int PhyDrive, UINT64 SizeBytes, MBR_HEAD *pMBR, UIN
|
||||
}
|
||||
|
||||
*Part2StartSector = MBR.PartTbl[1].StartSectorId;
|
||||
|
||||
memcpy(pMBR, &MBR, sizeof(MBR_HEAD));
|
||||
}
|
||||
|
||||
memcpy(pMBR, &MBR, sizeof(MBR_HEAD));
|
||||
Log("PhysicalDrive%d is ventoy disk", PhyDrive);
|
||||
return TRUE;
|
||||
}
|
||||
|
@@ -24,6 +24,7 @@
|
||||
#include <stdio.h>
|
||||
|
||||
#define SIZE_1MB (1024 * 1024)
|
||||
#define SIZE_2MB (2048 * 1024)
|
||||
#define VENTOY_EFI_PART_SIZE (32 * SIZE_1MB)
|
||||
#define VENTOY_PART1_START_SECTOR 2048
|
||||
|
||||
@@ -208,6 +209,7 @@ int ParseCmdLineOption(LPSTR lpCmdLine);
|
||||
int InstallVentoy2PhyDrive(PHY_DRIVE_INFO *pPhyDrive, int PartStyle);
|
||||
int UpdateVentoy2PhyDrive(PHY_DRIVE_INFO *pPhyDrive);
|
||||
int VentoyFillBackupGptHead(VTOY_GPT_INFO *pInfo, VTOY_GPT_HDR *pHead);
|
||||
int VentoyFillWholeGpt(UINT64 DiskSizeBytes, VTOY_GPT_INFO *pInfo);
|
||||
void SetProgressBarPos(int Pos);
|
||||
int ReadWholeFileToBuf(const CHAR *FileName, int ExtLen, void **Bufer, int *BufLen);
|
||||
int INIT unxz(unsigned char *in, int in_size,
|
||||
@@ -219,7 +221,7 @@ void disk_io_set_param(HANDLE Handle, UINT64 SectorCount);
|
||||
INT_PTR CALLBACK PartDialogProc(HWND hWnd, UINT Message, WPARAM wParam, LPARAM lParam);
|
||||
int GetReservedSpaceInMB(void);
|
||||
int FindProcessOccupyDisk(HANDLE hDrive, PHY_DRIVE_INFO *pPhyDrive);
|
||||
int VentoyFillLocation(UINT64 DiskSizeInBytes, UINT32 StartSectorId, UINT32 SectorCount, PART_TABLE *Table);
|
||||
int VentoyFillMBRLocation(UINT64 DiskSizeInBytes, UINT32 StartSectorId, UINT32 SectorCount, PART_TABLE *Table);
|
||||
int ClearVentoyFromPhyDrive(HWND hWnd, PHY_DRIVE_INFO *pPhyDrive, char *pDrvLetter);
|
||||
UINT32 VentoyCrc32(void *Buffer, UINT32 Length);
|
||||
|
||||
|
@@ -475,9 +475,9 @@ static const char* const VolumeStr[FF_VOLUMES] = {FF_VOLUME_STRS}; /* Pre-define
|
||||
#endif
|
||||
|
||||
#if FF_LBA64
|
||||
#if FF_MIN_GPT > 0x100000000
|
||||
#error Wrong FF_MIN_GPT setting
|
||||
#endif
|
||||
//#if FF_MIN_GPT > 0x100000000
|
||||
//#error Wrong FF_MIN_GPT setting
|
||||
//#endif
|
||||
static const BYTE GUID_MS_Basic[16] = {0xA2,0xA0,0xD0,0xEB,0xE5,0xB9,0x33,0x44,0x87,0xC0,0x68,0xB6,0xB7,0x26,0x99,0xC7};
|
||||
#endif
|
||||
|
||||
@@ -5983,10 +5983,10 @@ FRESULT f_mkfs (
|
||||
if (sz_vol >= 0x4000000) sz_au = 256; /* >= 64Ms */
|
||||
}
|
||||
b_fat = b_vol + 32; /* FAT start at offset 32 */
|
||||
sz_fat = (DWORD)((sz_vol / sz_au + 2) * 4 + ss - 1) / ss; /* Number of FAT sectors */
|
||||
sz_fat = (DWORD)(((sz_vol / sz_au + 2) * 4 + ss - 1) / ss); /* Number of FAT sectors */
|
||||
b_data = (b_fat + sz_fat + sz_blk - 1) & ~((LBA_t)sz_blk - 1); /* Align data area to the erase block boundary */
|
||||
if (b_data - b_vol >= sz_vol / 2) LEAVE_MKFS(FR_MKFS_ABORTED); /* Too small volume? */
|
||||
n_clst = (DWORD)(sz_vol - (b_data - b_vol)) / sz_au; /* Number of clusters */
|
||||
n_clst = (DWORD)((sz_vol - (b_data - b_vol)) / sz_au); /* Number of clusters */
|
||||
if (n_clst <16) LEAVE_MKFS(FR_MKFS_ABORTED); /* Too few clusters? */
|
||||
if (n_clst > MAX_EXFAT) LEAVE_MKFS(FR_MKFS_ABORTED); /* Too many clusters? */
|
||||
|
||||
|
@@ -205,7 +205,7 @@
|
||||
/ To enable the 64-bit LBA, also exFAT needs to be enabled. (FF_FS_EXFAT == 1) */
|
||||
|
||||
|
||||
#define FF_MIN_GPT 0x100000000
|
||||
#define FF_MIN_GPT 0x10000000000000
|
||||
/* Minimum number of sectors to switch GPT format to create partition in f_mkfs and
|
||||
/ f_fdisk function. 0x100000000 max. This option has no effect when FF_LBA64 == 0. */
|
||||
|
||||
|
@@ -0,0 +1,48 @@
|
||||
#
|
||||
# Makefile
|
||||
#
|
||||
# Author: Lasse Collin <lasse.collin@tukaani.org>
|
||||
#
|
||||
# This file has been put into the public domain.
|
||||
# You can do whatever you want with this file.
|
||||
#
|
||||
|
||||
CC = gcc -specs "/usr/local/musl/lib/musl-gcc.specs" -Os -static -std=gnu89
|
||||
BCJ_CPPFLAGS = -DXZ_DEC_X86 -DXZ_DEC_POWERPC -DXZ_DEC_IA64 \
|
||||
-DXZ_DEC_ARM -DXZ_DEC_ARMTHUMB -DXZ_DEC_SPARC
|
||||
CPPFLAGS = -DXZ_USE_CRC64 -DXZ_DEC_ANY_CHECK
|
||||
CFLAGS = -ggdb3 -O2 -pedantic -Wall -Wextra
|
||||
RM = rm -f
|
||||
VPATH = ../linux/include/linux ../linux/lib/xz
|
||||
COMMON_SRCS = xz_crc32.c xz_crc64.c xz_dec_stream.c xz_dec_lzma2.c xz_dec_bcj.c
|
||||
COMMON_OBJS = $(COMMON_SRCS:.c=.o)
|
||||
XZMINIDEC_OBJS = xzminidec.o
|
||||
BYTETEST_OBJS = bytetest.o
|
||||
BUFTEST_OBJS = buftest.o
|
||||
BOOTTEST_OBJS = boottest.o
|
||||
XZ_HEADERS = xz.h xz_private.h xz_stream.h xz_lzma2.h xz_config.h
|
||||
PROGRAMS = xzminidec bytetest buftest boottest
|
||||
|
||||
ALL_CPPFLAGS = -I../linux/include/linux -I. $(BCJ_CPPFLAGS) $(CPPFLAGS)
|
||||
|
||||
all: $(PROGRAMS)
|
||||
|
||||
%.o: %.c $(XZ_HEADERS)
|
||||
$(CC) $(ALL_CPPFLAGS) $(CFLAGS) -c -o $@ $<
|
||||
|
||||
xzminidec: $(COMMON_OBJS) $(XZMINIDEC_OBJS)
|
||||
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $(COMMON_OBJS) $(XZMINIDEC_OBJS)
|
||||
|
||||
bytetest: $(COMMON_OBJS) $(BYTETEST_OBJS)
|
||||
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $(COMMON_OBJS) $(BYTETEST_OBJS)
|
||||
|
||||
buftest: $(COMMON_OBJS) $(BUFTEST_OBJS)
|
||||
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $(COMMON_OBJS) $(BUFTEST_OBJS)
|
||||
|
||||
boottest: $(BOOTTEST_OBJS) $(COMMON_SRCS)
|
||||
$(CC) $(ALL_CPPFLAGS) $(CFLAGS) $(LDFLAGS) -o $@ $(BOOTTEST_OBJS)
|
||||
|
||||
.PHONY: clean
|
||||
clean:
|
||||
-$(RM) $(COMMON_OBJS) $(XZMINIDEC_OBJS) $(BUFTEST_OBJS) \
|
||||
$(BOOTTEST_OBJS) $(PROGRAMS)
|
@@ -0,0 +1,48 @@
|
||||
#
|
||||
# Makefile
|
||||
#
|
||||
# Author: Lasse Collin <lasse.collin@tukaani.org>
|
||||
#
|
||||
# This file has been put into the public domain.
|
||||
# You can do whatever you want with this file.
|
||||
#
|
||||
|
||||
CC = /opt/aarch64--uclibc--stable-2020.08-1/bin/aarch64-linux-gcc -Os -static -std=gnu89
|
||||
BCJ_CPPFLAGS = -DXZ_DEC_X86 -DXZ_DEC_POWERPC -DXZ_DEC_IA64 \
|
||||
-DXZ_DEC_ARM -DXZ_DEC_ARMTHUMB -DXZ_DEC_SPARC
|
||||
CPPFLAGS = -DXZ_USE_CRC64 -DXZ_DEC_ANY_CHECK
|
||||
CFLAGS = -ggdb3 -O2 -pedantic -Wall -Wextra
|
||||
RM = rm -f
|
||||
VPATH = ../linux/include/linux ../linux/lib/xz
|
||||
COMMON_SRCS = xz_crc32.c xz_crc64.c xz_dec_stream.c xz_dec_lzma2.c xz_dec_bcj.c
|
||||
COMMON_OBJS = $(COMMON_SRCS:.c=.o)
|
||||
XZMINIDEC_OBJS = xzminidec.o
|
||||
BYTETEST_OBJS = bytetest.o
|
||||
BUFTEST_OBJS = buftest.o
|
||||
BOOTTEST_OBJS = boottest.o
|
||||
XZ_HEADERS = xz.h xz_private.h xz_stream.h xz_lzma2.h xz_config.h
|
||||
PROGRAMS = xzminidec bytetest buftest boottest
|
||||
|
||||
ALL_CPPFLAGS = -I../linux/include/linux -I. $(BCJ_CPPFLAGS) $(CPPFLAGS)
|
||||
|
||||
all: $(PROGRAMS)
|
||||
|
||||
%.o: %.c $(XZ_HEADERS)
|
||||
$(CC) $(ALL_CPPFLAGS) $(CFLAGS) -c -o $@ $<
|
||||
|
||||
xzminidec: $(COMMON_OBJS) $(XZMINIDEC_OBJS)
|
||||
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $(COMMON_OBJS) $(XZMINIDEC_OBJS)
|
||||
|
||||
bytetest: $(COMMON_OBJS) $(BYTETEST_OBJS)
|
||||
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $(COMMON_OBJS) $(BYTETEST_OBJS)
|
||||
|
||||
buftest: $(COMMON_OBJS) $(BUFTEST_OBJS)
|
||||
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $(COMMON_OBJS) $(BUFTEST_OBJS)
|
||||
|
||||
boottest: $(BOOTTEST_OBJS) $(COMMON_SRCS)
|
||||
$(CC) $(ALL_CPPFLAGS) $(CFLAGS) $(LDFLAGS) -o $@ $(BOOTTEST_OBJS)
|
||||
|
||||
.PHONY: clean
|
||||
clean:
|
||||
-$(RM) $(COMMON_OBJS) $(XZMINIDEC_OBJS) $(BUFTEST_OBJS) \
|
||||
$(BOOTTEST_OBJS) $(PROGRAMS)
|
@@ -484,8 +484,7 @@ static int vtoy_check_device(ventoy_os_param *param, const char *device)
|
||||
debug("param->vtoy_disk_size=%llu size=%llu\n",
|
||||
(unsigned long long)param->vtoy_disk_size, (unsigned long long)size);
|
||||
|
||||
if ((param->vtoy_disk_size == size || param->vtoy_disk_size == size + 512) &&
|
||||
memcmp(vtguid, param->vtoy_disk_guid, 16) == 0 &&
|
||||
if (memcmp(vtguid, param->vtoy_disk_guid, 16) == 0 &&
|
||||
memcmp(vtsig, param->vtoy_disk_signature, 4) == 0)
|
||||
{
|
||||
debug("<%s> is right ventoy disk\n", device);
|
||||
@@ -563,8 +562,20 @@ int vtoydump_main(int argc, char **argv)
|
||||
rc = vtoy_os_param_from_file(filename, param);
|
||||
if (rc)
|
||||
{
|
||||
debug("ventoy os param not found %d\n", rc);
|
||||
goto end;
|
||||
debug("ventoy os param not found %d %d\n", rc, ENOENT);
|
||||
if (ENOENT == rc)
|
||||
{
|
||||
debug("now try with file %s\n", "/ventoy/ventoy_os_param");
|
||||
rc = vtoy_os_param_from_file("/ventoy/ventoy_os_param", param);
|
||||
if (rc)
|
||||
{
|
||||
goto end;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
goto end;
|
||||
}
|
||||
}
|
||||
|
||||
if (verbose)
|
||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Reference in New Issue
Block a user