diff --git a/INSTALL/Ventoy2Disk.exe b/INSTALL/Ventoy2Disk.exe index 505927dd..80161e20 100644 Binary files a/INSTALL/Ventoy2Disk.exe and b/INSTALL/Ventoy2Disk.exe differ diff --git a/INSTALL/Ventoy2Disk_ARM.exe b/INSTALL/Ventoy2Disk_ARM.exe index 83073e1d..2ded2129 100644 Binary files a/INSTALL/Ventoy2Disk_ARM.exe and b/INSTALL/Ventoy2Disk_ARM.exe differ diff --git a/INSTALL/Ventoy2Disk_ARM64.exe b/INSTALL/Ventoy2Disk_ARM64.exe index ef820063..49031c83 100644 Binary files a/INSTALL/Ventoy2Disk_ARM64.exe and b/INSTALL/Ventoy2Disk_ARM64.exe differ diff --git a/INSTALL/Ventoy2Disk_X64.exe b/INSTALL/Ventoy2Disk_X64.exe index 44fe8e4b..4271cf07 100644 Binary files a/INSTALL/Ventoy2Disk_X64.exe and b/INSTALL/Ventoy2Disk_X64.exe differ diff --git a/INSTALL/VentoyGUI.i386 b/INSTALL/VentoyGUI.i386 index 580e9281..7b53b8c1 100644 Binary files a/INSTALL/VentoyGUI.i386 and b/INSTALL/VentoyGUI.i386 differ diff --git a/INSTALL/VentoyGUI.x86_64 b/INSTALL/VentoyGUI.x86_64 index fd7c4691..f87cb147 100644 Binary files a/INSTALL/VentoyGUI.x86_64 and b/INSTALL/VentoyGUI.x86_64 differ diff --git a/INSTALL/tool/VentoyWorker.sh b/INSTALL/tool/VentoyWorker.sh index 2d18b607..0642cc6e 100644 --- a/INSTALL/tool/VentoyWorker.sh +++ b/INSTALL/tool/VentoyWorker.sh @@ -185,14 +185,27 @@ if [ "$MODE" = "install" -a -z "$NONDESTRUCTIVE" ]; then fi else if parted -v > /dev/null 2>&1; then - PARTTOOL='parted' + PARTTOOL='parted' elif fdisk -v >/dev/null 2>&1; then - PARTTOOL='fdisk' + PARTTOOL='fdisk' else vterr "Both parted and fdisk are not found in the system, Ventoy can't create new partitions." exit 1 fi fi + + if [ "$PARTTOOL" = "parted" ]; then + if parted $DISK p | grep -i -q 'sector size.*4096.*4096'; then + vterr "Currently Ventoy does not support 4K native device." + exit 1 + fi + else + if fdisk -l $DISK | grep -i -q 'sector size.*4096.*4096'; then + vterr "Currently Ventoy does not support 4K native device." + exit 1 + fi + fi + version=$(get_disk_ventoy_version $DISK) if [ $? -eq 0 ]; then diff --git a/INSTALL/tool/aarch64/Plugson b/INSTALL/tool/aarch64/Plugson index de9b9dbc..69164165 100644 Binary files a/INSTALL/tool/aarch64/Plugson and b/INSTALL/tool/aarch64/Plugson differ diff --git a/INSTALL/tool/aarch64/V2DServer b/INSTALL/tool/aarch64/V2DServer index 0b382c1c..53859bc3 100644 Binary files a/INSTALL/tool/aarch64/V2DServer and b/INSTALL/tool/aarch64/V2DServer differ diff --git a/INSTALL/tool/aarch64/Ventoy2Disk.gtk3 b/INSTALL/tool/aarch64/Ventoy2Disk.gtk3 index ed573859..ce1ae01a 100644 Binary files a/INSTALL/tool/aarch64/Ventoy2Disk.gtk3 and b/INSTALL/tool/aarch64/Ventoy2Disk.gtk3 differ diff --git a/INSTALL/tool/aarch64/Ventoy2Disk.qt5 b/INSTALL/tool/aarch64/Ventoy2Disk.qt5 index ba06df29..18ad203c 100644 Binary files a/INSTALL/tool/aarch64/Ventoy2Disk.qt5 and b/INSTALL/tool/aarch64/Ventoy2Disk.qt5 differ diff --git a/INSTALL/tool/i386/Plugson b/INSTALL/tool/i386/Plugson index 582660a5..715b9f78 100644 Binary files a/INSTALL/tool/i386/Plugson and b/INSTALL/tool/i386/Plugson differ diff --git a/INSTALL/tool/i386/V2DServer b/INSTALL/tool/i386/V2DServer index b9b6d918..5cc85c02 100644 Binary files a/INSTALL/tool/i386/V2DServer and b/INSTALL/tool/i386/V2DServer differ diff --git a/INSTALL/tool/i386/Ventoy2Disk.gtk2 b/INSTALL/tool/i386/Ventoy2Disk.gtk2 index e71a4804..dd18b8f7 100644 Binary files a/INSTALL/tool/i386/Ventoy2Disk.gtk2 and b/INSTALL/tool/i386/Ventoy2Disk.gtk2 differ diff --git a/INSTALL/tool/i386/Ventoy2Disk.gtk3 b/INSTALL/tool/i386/Ventoy2Disk.gtk3 index cdb33d19..4d0d763d 100644 Binary files a/INSTALL/tool/i386/Ventoy2Disk.gtk3 and b/INSTALL/tool/i386/Ventoy2Disk.gtk3 differ diff --git a/INSTALL/tool/i386/Ventoy2Disk.qt5 b/INSTALL/tool/i386/Ventoy2Disk.qt5 index 51bc50e9..337b2841 100644 Binary files a/INSTALL/tool/i386/Ventoy2Disk.qt5 and b/INSTALL/tool/i386/Ventoy2Disk.qt5 differ diff --git a/INSTALL/tool/i386/vlnk b/INSTALL/tool/i386/vlnk index 2d1a6f0a..81fcf3df 100644 Binary files a/INSTALL/tool/i386/vlnk and b/INSTALL/tool/i386/vlnk differ diff --git a/INSTALL/tool/mips64el/Plugson b/INSTALL/tool/mips64el/Plugson index 8870f5c0..78c74841 100644 Binary files a/INSTALL/tool/mips64el/Plugson and b/INSTALL/tool/mips64el/Plugson differ diff --git a/INSTALL/tool/mips64el/V2DServer b/INSTALL/tool/mips64el/V2DServer index 16a78cb8..fe1b1ea0 100644 Binary files a/INSTALL/tool/mips64el/V2DServer and b/INSTALL/tool/mips64el/V2DServer differ diff --git a/INSTALL/tool/mips64el/Ventoy2Disk.gtk3 b/INSTALL/tool/mips64el/Ventoy2Disk.gtk3 index c2af26b4..98d6bf26 100644 Binary files a/INSTALL/tool/mips64el/Ventoy2Disk.gtk3 and b/INSTALL/tool/mips64el/Ventoy2Disk.gtk3 differ diff --git a/INSTALL/tool/mips64el/Ventoy2Disk.qt5 b/INSTALL/tool/mips64el/Ventoy2Disk.qt5 index eee73b25..7387ae55 100644 Binary files a/INSTALL/tool/mips64el/Ventoy2Disk.qt5 and b/INSTALL/tool/mips64el/Ventoy2Disk.qt5 differ diff --git a/INSTALL/tool/ventoy_lib.sh b/INSTALL/tool/ventoy_lib.sh index dbf9475c..710cc37f 100644 --- a/INSTALL/tool/ventoy_lib.sh +++ b/INSTALL/tool/ventoy_lib.sh @@ -492,7 +492,7 @@ format_ventoy_disk_gpt() { for i in 0 1 2 3 4 5 6 7 8 9; do check_umount_disk "$PART2" - if mkfs.vfat -F 16 -n VTOYEFI $PART2; then + if mkfs.vfat -F 16 -n VTOYEFI -s 1 $PART2; then echo 'success' break else diff --git a/INSTALL/tool/x86_64/Plugson b/INSTALL/tool/x86_64/Plugson index 2358244e..0cec4c70 100644 Binary files a/INSTALL/tool/x86_64/Plugson and b/INSTALL/tool/x86_64/Plugson differ diff --git a/INSTALL/tool/x86_64/V2DServer b/INSTALL/tool/x86_64/V2DServer index e28b652d..8703fbf7 100644 Binary files a/INSTALL/tool/x86_64/V2DServer and b/INSTALL/tool/x86_64/V2DServer differ diff --git a/INSTALL/tool/x86_64/Ventoy2Disk.gtk2 b/INSTALL/tool/x86_64/Ventoy2Disk.gtk2 index f5c37958..c74a2ac9 100644 Binary files a/INSTALL/tool/x86_64/Ventoy2Disk.gtk2 and b/INSTALL/tool/x86_64/Ventoy2Disk.gtk2 differ diff --git a/INSTALL/tool/x86_64/Ventoy2Disk.gtk3 b/INSTALL/tool/x86_64/Ventoy2Disk.gtk3 index 03411cf9..089d35c9 100644 Binary files a/INSTALL/tool/x86_64/Ventoy2Disk.gtk3 and b/INSTALL/tool/x86_64/Ventoy2Disk.gtk3 differ diff --git a/INSTALL/tool/x86_64/Ventoy2Disk.qt5 b/INSTALL/tool/x86_64/Ventoy2Disk.qt5 index e3ab28e2..a7616ef2 100644 Binary files a/INSTALL/tool/x86_64/Ventoy2Disk.qt5 and b/INSTALL/tool/x86_64/Ventoy2Disk.qt5 differ diff --git a/INSTALL/tool/x86_64/vlnk b/INSTALL/tool/x86_64/vlnk index 46bc3fdd..c25e6b85 100644 Binary files a/INSTALL/tool/x86_64/vlnk and b/INSTALL/tool/x86_64/vlnk differ diff --git a/INSTALL/ventoy_pack.sh b/INSTALL/ventoy_pack.sh index 43f45ebf..e03e8b02 100644 --- a/INSTALL/ventoy_pack.sh +++ b/INSTALL/ventoy_pack.sh @@ -169,8 +169,27 @@ sed 's/.*SCRIPT_DEL_THIS \(.*\)/\1/g' -i $tmpdir/WebUI/index.html #32MB disk img dd status=none if=$LOOP of=$tmpdir/ventoy/ventoy.disk.img bs=512 count=$VENTOY_SECTOR_NUM skip=$part2_start_sector + + +#4k image +# echo "make 4K img ..." +# dd status=none if=/dev/zero of=$tmpdir/ventoy/ventoy_4k.disk.img bs=1M count=32 +# mkfs.vfat -F 16 -n VTOYEFI -s 1 -S 4096 $tmpdir/ventoy/ventoy_4k.disk.img +# vDIR1=$(mktemp -d) +# vDIR2=$(mktemp -d) +# mount $tmpdir/ventoy/ventoy.disk.img $vDIR1 +# mount $tmpdir/ventoy/ventoy_4k.disk.img $vDIR2 +# cp -a $vDIR1/* $vDIR2/ +# umount $vDIR1 +# umount $vDIR2 +# rm -rf $vDIR1 $vDIR2 + +# xz --check=crc32 $tmpdir/ventoy/ventoy_4k.disk.img + xz --check=crc32 $tmpdir/ventoy/ventoy.disk.img + + losetup -d $LOOP && rm -f img.bin rm -f ventoy-${curver}-linux.tar.gz diff --git a/LANGUAGES/languages.json b/LANGUAGES/languages.json index 352bce0a..24d83268 100644 --- a/LANGUAGES/languages.json +++ b/LANGUAGES/languages.json @@ -60,6 +60,7 @@ "STR_PART_CLUSTER":"حجم الكتلة", "STR_PART_CLUSTER_DEFAULT":"القيمة الافتراضية للنظام", "STR_DONATE":"يتبرع", + "STR_4KN_UNSUPPORTED":"Currently Ventoy does not support 4K native device.", "STRXXX":"" }, @@ -124,7 +125,8 @@ "STR_PART_CLUSTER":"Cluster Size", "STR_PART_CLUSTER_DEFAULT":"System Default Value", "STR_DONATE":"Ianə", - + "STR_4KN_UNSUPPORTED":"Currently Ventoy does not support 4K native device.", + "STRXXX":"" }, { @@ -188,6 +190,7 @@ "STR_PART_CLUSTER":"클러스터 크기", "STR_PART_CLUSTER_DEFAULT":"시스템 기본값", "STR_DONATE":"기부", + "STR_4KN_UNSUPPORTED":"Currently Ventoy does not support 4K native device.", "STRXXX":"" }, @@ -252,6 +255,7 @@ "STR_PART_CLUSTER":"簇大小", "STR_PART_CLUSTER_DEFAULT":"系统默认值", "STR_DONATE":"捐助", + "STR_4KN_UNSUPPORTED":"目前 Ventoy 不支持原生 4K 扇区的磁盘。", "STRXXX":"" }, @@ -316,7 +320,8 @@ "STR_PART_CLUSTER":"Klynge størrelse", "STR_PART_CLUSTER_DEFAULT":"System Standard Værdi", "STR_DONATE":"Donering", - + "STR_4KN_UNSUPPORTED":"Currently Ventoy does not support 4K native device.", + "STRXXX":"" }, { @@ -380,7 +385,8 @@ "STR_PART_CLUSTER":"Cluster Size", "STR_PART_CLUSTER_DEFAULT":"System Default Value", "STR_DONATE":"Donate", - + "STR_4KN_UNSUPPORTED":"Currently Ventoy does not support 4K native device.", + "STRXXX":"" }, { @@ -444,7 +450,8 @@ "STR_PART_CLUSTER":"Cluster Size", "STR_PART_CLUSTER_DEFAULT":"System Default Value", "STR_DONATE":"შემოწირულობა", - + "STR_4KN_UNSUPPORTED":"Currently Ventoy does not support 4K native device.", + "STRXXX": "" }, { @@ -508,7 +515,8 @@ "STR_PART_CLUSTER":"Cluster Size", "STR_PART_CLUSTER_DEFAULT":"System Default Value", "STR_DONATE":"اهداء", - + "STR_4KN_UNSUPPORTED":"Currently Ventoy does not support 4K native device.", + "STRXXX":"" }, { @@ -572,7 +580,8 @@ "STR_PART_CLUSTER":"Wielkość klastra", "STR_PART_CLUSTER_DEFAULT":"Wartość domyślna systemu", "STR_DONATE":"Podarować", - + "STR_4KN_UNSUPPORTED":"Currently Ventoy does not support 4K native device.", + "STRXXX":"" }, { @@ -636,7 +645,8 @@ "STR_PART_CLUSTER":"Tamanho do cluster", "STR_PART_CLUSTER_DEFAULT":"Valor padrão do sistema", "STR_DONATE":"Doar", - + "STR_4KN_UNSUPPORTED":"Currently Ventoy does not support 4K native device.", + "STRXXX":"" }, { @@ -700,7 +710,8 @@ "STR_PART_CLUSTER":"Sektör Boyutu", "STR_PART_CLUSTER_DEFAULT":"Sistem varsayılan değeri", "STR_DONATE":"Ventoy'a Bağış yap", - + "STR_4KN_UNSUPPORTED":"Currently Ventoy does not support 4K native device.", + "STRXXX":"" }, { @@ -764,7 +775,8 @@ "STR_PART_CLUSTER":"Clustergröße", "STR_PART_CLUSTER_DEFAULT":"Systemstandardwert", "STR_DONATE":"Spenden", - + "STR_4KN_UNSUPPORTED":"Currently Ventoy does not support 4K native device.", + "STRXXX":"" }, { @@ -828,7 +840,8 @@ "STR_PART_CLUSTER":"Cluster Size", "STR_PART_CLUSTER_DEFAULT":"System Default Value", "STR_DONATE":"Donate", - + "STR_4KN_UNSUPPORTED":"Currently Ventoy does not support 4K native device.", + "STRXXX":"" }, { @@ -892,7 +905,8 @@ "STR_PART_CLUSTER":"Taille de cluster", "STR_PART_CLUSTER_DEFAULT":"Valeur par défaut du système", "STR_DONATE":"Faire un don", - + "STR_4KN_UNSUPPORTED":"Currently Ventoy does not support 4K native device.", + "STRXXX":"" }, { @@ -956,7 +970,8 @@ "STR_PART_CLUSTER":"Velikost clusteru", "STR_PART_CLUSTER_DEFAULT":"Výchozí hodnota systému", "STR_DONATE":"Darovat", - + "STR_4KN_UNSUPPORTED":"Currently Ventoy does not support 4K native device.", + "STRXXX":"" }, { @@ -1019,7 +1034,8 @@ "STR_PART_CLUSTER":"Cluster Size", "STR_PART_CLUSTER_DEFAULT":"System Default Value", "STR_DONATE":"Darovať", - + "STR_4KN_UNSUPPORTED":"Currently Ventoy does not support 4K native device.", + "STRXXX":"" }, { @@ -1083,7 +1099,8 @@ "STR_PART_CLUSTER":"Tamaño de cluster", "STR_PART_CLUSTER_DEFAULT":"Valor predeterminado del sistema", "STR_DONATE":"Donar", - + "STR_4KN_UNSUPPORTED":"Currently Ventoy does not support 4K native device.", + "STRXXX":"" }, { @@ -1147,7 +1164,8 @@ "STR_PART_CLUSTER":"Tamaño de cluster", "STR_PART_CLUSTER_DEFAULT":"Valor predeterminado del sistema", "STR_DONATE":"Donar", - + "STR_4KN_UNSUPPORTED":"Currently Ventoy does not support 4K native device.", + "STRXXX":"" }, { @@ -1211,7 +1229,8 @@ "STR_PART_CLUSTER":"Размер кластера:", "STR_PART_CLUSTER_DEFAULT":"Системное значение по умолчанию", "STR_DONATE":"Пожертвовать", - + "STR_4KN_UNSUPPORTED":"Currently Ventoy does not support 4K native device.", + "STRXXX":"" }, { @@ -1275,7 +1294,8 @@ "STR_PART_CLUSTER":"ক্লাস্টারের আকার", "STR_PART_CLUSTER_DEFAULT":"সিস্টেমের ডিফল্ট মান", "STR_DONATE":"দান করুন", - + "STR_4KN_UNSUPPORTED":"Currently Ventoy does not support 4K native device.", + "STRXXX":"" }, { @@ -1339,7 +1359,8 @@ "STR_PART_CLUSTER":"क्लस्टर साइज", "STR_PART_CLUSTER_DEFAULT":"सिस्टम डिफ़ॉल्ट मान", "STR_DONATE":"दान करें", - + "STR_4KN_UNSUPPORTED":"Currently Ventoy does not support 4K native device.", + "STRXXX":"" }, { @@ -1403,6 +1424,7 @@ "STR_PART_CLUSTER":"Clustergrootte", "STR_PART_CLUSTER_DEFAULT":"Standaardwaarde systeem", "STR_DONATE":"Doneer", + "STR_4KN_UNSUPPORTED":"Currently Ventoy does not support 4K native device.", "STRXXX":"" }, @@ -1467,6 +1489,7 @@ "STR_PART_CLUSTER":"Dimensiunea clusterului", "STR_PART_CLUSTER_DEFAULT":"Valoarea implicită a sistemului", "STR_DONATE":"Donează", + "STR_4KN_UNSUPPORTED":"Currently Ventoy does not support 4K native device.", "STRXXX":"" }, @@ -1531,7 +1554,8 @@ "STR_PART_CLUSTER":"クラスターサイズ", "STR_PART_CLUSTER_DEFAULT":"システムのデフォルト値", "STR_DONATE":"寄付", - + "STR_4KN_UNSUPPORTED":"Currently Ventoy does not support 4K native device.", + "STRXXX":"" }, { @@ -1595,7 +1619,8 @@ "STR_PART_CLUSTER":"Dimensione del cluster", "STR_PART_CLUSTER_DEFAULT":"Valore predefinito di sistema", "STR_DONATE":"Donare", - + "STR_4KN_UNSUPPORTED":"Currently Ventoy does not support 4K native device.", + "STRXXX":"" }, { @@ -1659,7 +1684,8 @@ "STR_PART_CLUSTER":"Cluster Size", "STR_PART_CLUSTER_DEFAULT":"System Default Value", "STR_DONATE":"Donirajte", - + "STR_4KN_UNSUPPORTED":"Currently Ventoy does not support 4K native device.", + "STRXXX":"" }, { @@ -1723,7 +1749,8 @@ "STR_PART_CLUSTER":"Klaszter méret", "STR_PART_CLUSTER_DEFAULT":"Rendszer alapérték", "STR_DONATE":"Adományoz", - + "STR_4KN_UNSUPPORTED":"Currently Ventoy does not support 4K native device.", + "STRXXX":"" }, { @@ -1787,7 +1814,8 @@ "STR_PART_CLUSTER":"簇的大小", "STR_PART_CLUSTER_DEFAULT":"系統默認值", "STR_DONATE":"捐助", - + "STR_4KN_UNSUPPORTED":"Currently Ventoy does not support 4K native device.", + "STRXXX":"" }, { @@ -1851,7 +1879,8 @@ "STR_PART_CLUSTER":"Veličina klastera", "STR_PART_CLUSTER_DEFAULT":"Podrazumevana sistemska vrednost", "STR_DONATE":"Donirajte", - + "STR_4KN_UNSUPPORTED":"Currently Ventoy does not support 4K native device.", + "STRXXX":"" }, { @@ -1915,7 +1944,8 @@ "STR_PART_CLUSTER":"Величина кластера", "STR_PART_CLUSTER_DEFAULT":"Подразумевана системска вредност", "STR_DONATE":"Донирајте", - + "STR_4KN_UNSUPPORTED":"Currently Ventoy does not support 4K native device.", + "STRXXX":"" }, { @@ -1979,7 +2009,8 @@ "STR_PART_CLUSTER":"Cluster Size", "STR_PART_CLUSTER_DEFAULT":"System Default Value", "STR_DONATE":"บริจาค", - + "STR_4KN_UNSUPPORTED":"Currently Ventoy does not support 4K native device.", + "STRXXX":"" }, { @@ -2043,7 +2074,8 @@ "STR_PART_CLUSTER":"Cluster Size", "STR_PART_CLUSTER_DEFAULT":"System Default Value", "STR_DONATE":"donere", - + "STR_4KN_UNSUPPORTED":"Currently Ventoy does not support 4K native device.", + "STRXXX":"" }, { @@ -2107,7 +2139,8 @@ "STR_PART_CLUSTER":"Cỡ Cluster", "STR_PART_CLUSTER_DEFAULT":"Theo mặc định hệ thống", "STR_DONATE":"Thưởng tác giả", - + "STR_4KN_UNSUPPORTED":"Currently Ventoy does not support 4K native device.", + "STRXXX":"" }, { @@ -2171,7 +2204,8 @@ "STR_PART_CLUSTER":"Cluster Size", "STR_PART_CLUSTER_DEFAULT":"System Default Value", "STR_DONATE":"paaukoti", - + "STR_4KN_UNSUPPORTED":"Currently Ventoy does not support 4K native device.", + "STRXXX":"" }, { @@ -2235,7 +2269,8 @@ "STR_PART_CLUSTER":"Cluster Size", "STR_PART_CLUSTER_DEFAULT":"System Default Value", "STR_DONATE":"донира", - + "STR_4KN_UNSUPPORTED":"Currently Ventoy does not support 4K native device.", + "STRXXX":"" }, { @@ -2299,7 +2334,8 @@ "STR_PART_CLUSTER":"Cluster Size", "STR_PART_CLUSTER_DEFAULT":"System Default Value", "STR_DONATE":"לִתְרוֹם", - + "STR_4KN_UNSUPPORTED":"Currently Ventoy does not support 4K native device.", + "STRXXX":"" }, { @@ -2363,7 +2399,8 @@ "STR_PART_CLUSTER":"Tamanho do cluster", "STR_PART_CLUSTER_DEFAULT":"Valor predefinido do sistema", "STR_DONATE":"Doar", - + "STR_4KN_UNSUPPORTED":"Currently Ventoy does not support 4K native device.", + "STRXXX":"" }, { @@ -2427,7 +2464,8 @@ "STR_PART_CLUSTER":"Ukuran Kelompok", "STR_PART_CLUSTER_DEFAULT":"Nilai Standar Sistem", "STR_DONATE":"Donasi sukarela", - + "STR_4KN_UNSUPPORTED":"Currently Ventoy does not support 4K native device.", + "STRXXX":"" }, { @@ -2491,7 +2529,8 @@ "STR_PART_CLUSTER":"Cluster Size", "STR_PART_CLUSTER_DEFAULT":"System Default Value", "STR_DONATE":"Donere", - + "STR_4KN_UNSUPPORTED":"Currently Ventoy does not support 4K native device.", + "STRXXX":"" }, { @@ -2555,7 +2594,8 @@ "STR_PART_CLUSTER":"Розмір кластера", "STR_PART_CLUSTER_DEFAULT":"Системне значення за умовчанням", "STR_DONATE":"Пожертвуйте", - + "STR_4KN_UNSUPPORTED":"Currently Ventoy does not support 4K native device.", + "STRXXX":"" }, { @@ -2619,7 +2659,8 @@ "STR_PART_CLUSTER":"Μέγεθος συμπλέγματος", "STR_PART_CLUSTER_DEFAULT":"Προεπιλεγμένη τιμή συστήματος", "STR_DONATE":"Προσφέρω", - + "STR_4KN_UNSUPPORTED":"Currently Ventoy does not support 4K native device.", + "STRXXX":"" }, @@ -2684,7 +2725,8 @@ "STR_PART_CLUSTER":"Klusterstorlek", "STR_PART_CLUSTER_DEFAULT":"Systemets standardvärde", "STR_DONATE":"Donera", - + "STR_4KN_UNSUPPORTED":"Currently Ventoy does not support 4K native device.", + "STRXXX":"" }, { @@ -2748,7 +2790,8 @@ "STR_PART_CLUSTER":"Cluster Size", "STR_PART_CLUSTER_DEFAULT":"System Default Value", "STR_DONATE":"Donirajte", - + "STR_4KN_UNSUPPORTED":"Currently Ventoy does not support 4K native device.", + "STRXXX":"" }, { @@ -2812,7 +2855,8 @@ "STR_PART_CLUSTER":"Cluster Size", "STR_PART_CLUSTER_DEFAULT":"System Default Value", "STR_DONATE":"Дарете", - + "STR_4KN_UNSUPPORTED":"Currently Ventoy does not support 4K native device.", + "STRXXX":"" }, { @@ -2876,7 +2920,8 @@ "STR_PART_CLUSTER":"Cluster Size", "STR_PART_CLUSTER_DEFAULT":"System Default Value", "STR_DONATE":"Նվիրաբերել", - + "STR_4KN_UNSUPPORTED":"Currently Ventoy does not support 4K native device.", + "STRXXX":"" }, { @@ -2940,7 +2985,8 @@ "STR_PART_CLUSTER":"Cluster Size", "STR_PART_CLUSTER_DEFAULT":"System Default Value", "STR_DONATE":"Lahjoittaa", - + "STR_4KN_UNSUPPORTED":"Currently Ventoy does not support 4K native device.", + "STRXXX":"" }, { @@ -3004,7 +3050,8 @@ "STR_PART_CLUSTER":"Cluster Size", "STR_PART_CLUSTER_DEFAULT":"System Default Value", "STR_DONATE":"Doa", - + "STR_4KN_UNSUPPORTED":"Currently Ventoy does not support 4K native device.", + "STRXXX":"" }, { @@ -3068,7 +3115,8 @@ "STR_PART_CLUSTER":"Cluster Size", "STR_PART_CLUSTER_DEFAULT":"System Default Value", "STR_DONATE":"Donar", - + "STR_4KN_UNSUPPORTED":"Currently Ventoy does not support 4K native device.", + "STRXXX":"" }, @@ -3133,7 +3181,8 @@ "STR_PART_CLUSTER":"Cluster Size", "STR_PART_CLUSTER_DEFAULT":"System Default Value", "STR_DONATE":"შემოწირულობა", - + "STR_4KN_UNSUPPORTED":"Currently Ventoy does not support 4K native device.", + "STRXXX":"" }, { @@ -3197,7 +3246,8 @@ "STR_PART_CLUSTER":"கொத்து அளவு", "STR_PART_CLUSTER_DEFAULT":"கணினி இயல்புநிலை மதிப்பு", "STR_DONATE":"தானம் செய்", - + "STR_4KN_UNSUPPORTED":"Currently Ventoy does not support 4K native device.", + "STRXXX":"" }, { @@ -3261,6 +3311,7 @@ "STR_PART_CLUSTER":"Памер кластара", "STR_PART_CLUSTER_DEFAULT":"Сістэмнае значэнне па змаўчанні", "STR_DONATE":"Ахвяраваць", + "STR_4KN_UNSUPPORTED":"Currently Ventoy does not support 4K native device.", "STRXXX":"" } diff --git a/LinuxGUI/Ventoy2Disk/Core/ventoy_define.h b/LinuxGUI/Ventoy2Disk/Core/ventoy_define.h index 01c0fd87..ba1a4d28 100644 --- a/LinuxGUI/Ventoy2Disk/Core/ventoy_define.h +++ b/LinuxGUI/Ventoy2Disk/Core/ventoy_define.h @@ -137,6 +137,7 @@ typedef struct ventoy_disk char disk_model[256]; // Sandisk/Kingston ... char human_readable_size[32]; + int is4kn; int major; int minor; int type; diff --git a/LinuxGUI/Ventoy2Disk/Core/ventoy_disk.c b/LinuxGUI/Ventoy2Disk/Core/ventoy_disk.c index 04eb7f48..5d4bbff7 100644 --- a/LinuxGUI/Ventoy2Disk/Core/ventoy_disk.c +++ b/LinuxGUI/Ventoy2Disk/Core/ventoy_disk.c @@ -260,6 +260,33 @@ static int ventoy_is_possible_blkdev(const char *name) return 1; } +int ventoy_is_disk_4k_native(const char *disk) +{ + int fd; + int rc = 0; + int logsector = 0; + int physector = 0; + char diskpath[256] = {0}; + + snprintf(diskpath, sizeof(diskpath) - 1, "/dev/%s", disk); + + fd = open(diskpath, O_RDONLY | O_BINARY); + if (fd >= 0) + { + ioctl(fd, BLKSSZGET, &logsector); + ioctl(fd, BLKPBSZGET, &physector); + + if (logsector == 4096 && physector == 4096) + { + rc = 1; + } + close(fd); + } + + vdebug("is 4k native disk <%s> <%d>\n", disk, rc); + return rc; +} + uint64_t ventoy_get_disk_size_in_byte(const char *disk) { int fd; @@ -591,6 +618,7 @@ int ventoy_get_disk_info(const char *name, ventoy_disk *info) scnprintf(info->part2_path, "/dev/%s2", name); } + info->is4kn = ventoy_is_disk_4k_native(name); info->size_in_byte = ventoy_get_disk_size_in_byte(name); ventoy_get_disk_devnum(name, &info->major, &info->minor); diff --git a/LinuxGUI/Ventoy2Disk/Core/ventoy_json.h b/LinuxGUI/Ventoy2Disk/Core/ventoy_json.h index 12e6f192..32fef4b1 100644 --- a/LinuxGUI/Ventoy2Disk/Core/ventoy_json.h +++ b/LinuxGUI/Ventoy2Disk/Core/ventoy_json.h @@ -58,6 +58,7 @@ #define VTOY_JSON_NOT_READY_RET "{ \"result\" : \"notready\" }" #define VTOY_JSON_NOT_SUPPORT_RET "{ \"result\" : \"notsupport\" }" #define VTOY_JSON_MBR_2TB_RET "{ \"result\" : \"mbr2tb\" }" +#define VTOY_JSON_4KN_RET "{ \"result\" : \"4kn\" }" #define VTOY_JSON_INVALID_RSV_RET "{ \"result\" : \"reserve_invalid\" }" #define VTOY_JSON_FILE_NOT_FOUND_RET "{ \"result\" : \"file_not_found\" }" diff --git a/LinuxGUI/Ventoy2Disk/Core/ventoy_util.c b/LinuxGUI/Ventoy2Disk/Core/ventoy_util.c index cc3e5e1b..03d93192 100644 --- a/LinuxGUI/Ventoy2Disk/Core/ventoy_util.c +++ b/LinuxGUI/Ventoy2Disk/Core/ventoy_util.c @@ -579,3 +579,68 @@ int ventoy_fill_mbr(uint64_t size, uint64_t reserve, int align4k, MBR_HEAD *pMBR return 0; } +int ventoy_fill_mbr_4k(uint64_t size, uint64_t reserve, int align4k, MBR_HEAD *pMBR) +{ + ventoy_guid Guid; + uint32_t DiskSignature; + uint32_t DiskSectorCount; + uint32_t PartSectorCount; + uint32_t PartStartSector; + uint32_t ReservedSector; + + VentoyGetLocalBootImg(pMBR); + + ventoy_gen_preudo_uuid(&Guid); + + memcpy(&DiskSignature, &Guid, sizeof(uint32_t)); + + vdebug("Disk signature: 0x%08x\n", DiskSignature); + + memcpy(pMBR->BootCode + 0x1B8, &DiskSignature, 4); + memcpy(pMBR->BootCode + 0x180, &Guid, 16); + + if (size / 4096 > 0xFFFFFFFF) + { + DiskSectorCount = 0xFFFFFFFF; + } + else + { + DiskSectorCount = (uint32_t)(size / 4096); + } + + if (reserve <= 0) + { + ReservedSector = 0; + } + else + { + ReservedSector = (uint32_t)(reserve / 4096); + } + + // check aligned with 4KB + vdebug("no need to align with 4KB for 4K native disk\n"); + + vlog("ReservedSector: %u\n", ReservedSector); + + //Part1 + PartStartSector = VTOYIMG_PART_START_SECTOR >> 3; + PartSectorCount = DiskSectorCount - ReservedSector - VTOYEFI_PART_BYTES / 4096 - PartStartSector; + VentoyFillMBRLocation(size, PartStartSector, PartSectorCount, pMBR->PartTbl); + + pMBR->PartTbl[0].Active = 0x80; // bootable + pMBR->PartTbl[0].FsFlag = 0x07; // exFAT/NTFS/HPFS + + //Part2 + PartStartSector += PartSectorCount; + PartSectorCount = VTOYEFI_PART_BYTES / 4096; + VentoyFillMBRLocation(size, PartStartSector, PartSectorCount, pMBR->PartTbl + 1); + + pMBR->PartTbl[1].Active = 0x00; + pMBR->PartTbl[1].FsFlag = 0xEF; // EFI System Partition + + pMBR->Byte55 = 0x55; + pMBR->ByteAA = 0xAA; + + return 0; +} + diff --git a/LinuxGUI/Ventoy2Disk/Core/ventoy_util.h b/LinuxGUI/Ventoy2Disk/Core/ventoy_util.h index 87bdbd5e..a5e4c8bd 100644 --- a/LinuxGUI/Ventoy2Disk/Core/ventoy_util.h +++ b/LinuxGUI/Ventoy2Disk/Core/ventoy_util.h @@ -51,6 +51,7 @@ const char * ventoy_get_local_version(void); int ventoy_fill_gpt(uint64_t size, uint64_t reserve, int align4k, VTOY_GPT_INFO *gpt); int ventoy_fill_mbr(uint64_t size, uint64_t reserve, int align4k, MBR_HEAD *pMBR); int VentoyGetLocalBootImg(MBR_HEAD *pMBR); +int ventoy_fill_mbr_4k(uint64_t size, uint64_t reserve, int align4k, MBR_HEAD *pMBR); #endif /* __VENTOY_UTIL_H__ */ diff --git a/LinuxGUI/Ventoy2Disk/GTK/ventoy_gtk.c b/LinuxGUI/Ventoy2Disk/GTK/ventoy_gtk.c index a1e81988..bb9215a2 100644 --- a/LinuxGUI/Ventoy2Disk/GTK/ventoy_gtk.c +++ b/LinuxGUI/Ventoy2Disk/GTK/ventoy_gtk.c @@ -661,6 +661,12 @@ void on_button_install_clicked(GtkWidget *widget, gpointer data) cur = g_disk_list + active; + if (cur->is4kn) + { + msgbox(GTK_MESSAGE_ERROR, GTK_BUTTONS_OK, "STR_4KN_UNSUPPORTED"); + return; + } + if (ventoy_code_get_cur_part_style() == 0 && cur->size_in_byte > 2199023255552ULL) { msgbox(GTK_MESSAGE_ERROR, GTK_BUTTONS_OK, "STR_DISK_2TB_MBR_ERROR"); diff --git a/LinuxGUI/Ventoy2Disk/QT/ventoy2diskwindow.cpp b/LinuxGUI/Ventoy2Disk/QT/ventoy2diskwindow.cpp index b0307a20..3615e3b7 100644 --- a/LinuxGUI/Ventoy2Disk/QT/ventoy2diskwindow.cpp +++ b/LinuxGUI/Ventoy2Disk/QT/ventoy2diskwindow.cpp @@ -512,6 +512,14 @@ void Ventoy2DiskWindow::on_ButtonInstall_clicked() } cur = g_disk_list + index; + + if (cur->is4kn) + { + lang_string("STR_4KN_UNSUPPORTED", msg); + QMessageBox::critical(NULL, title_err, msg); + return; + } + if (ventoy_code_get_cur_part_style() == 0 && cur->size_in_byte > 2199023255552ULL) { lang_string("STR_DISK_2TB_MBR_ERROR", msg); diff --git a/LinuxGUI/Ventoy2Disk/Web/ventoy_http.c b/LinuxGUI/Ventoy2Disk/Web/ventoy_http.c index 561e0807..d221dd39 100644 --- a/LinuxGUI/Ventoy2Disk/Web/ventoy_http.c +++ b/LinuxGUI/Ventoy2Disk/Web/ventoy_http.c @@ -1122,6 +1122,13 @@ static int ventoy_api_install(struct mg_connection *conn, VTOY_JSON *json) return 0; } + if (disk->is4kn) + { + vlog("disk %s is 4k native, not supported.\n", diskname); + ventoy_json_result(conn, VTOY_JSON_4KN_RET); + return 0; + } + scnprintf(path, "/sys/block/%s", diskname); if (access(path, F_OK) < 0) { diff --git a/LinuxGUI/WebUI/index.html b/LinuxGUI/WebUI/index.html index 975ce10b..fa90c045 100644 --- a/LinuxGUI/WebUI/index.html +++ b/LinuxGUI/WebUI/index.html @@ -761,6 +761,8 @@ vtoy_in_progress = true; progressDisableItem(vtoy_in_progress); queryProgress(1); + }else if (data.result === '4kn') { + ventoy_display_alert('error', vtoy_cur_language.STR_4KN_UNSUPPORTED); } else { ventoy_display_alert('error', vtoy_cur_language.STR_INSTALL_FAILED); } diff --git a/LinuxGUI/build_gtk.sh b/LinuxGUI/build_gtk.sh index 6e7aa518..cbcadbd4 100644 --- a/LinuxGUI/build_gtk.sh +++ b/LinuxGUI/build_gtk.sh @@ -86,9 +86,10 @@ build_func() { } -build_func "gcc" '64' 'x86_64' 'gtk2' build_func "gcc" '64' 'x86_64' 'gtk3' +build_func "gcc" '64' 'x86_64' 'gtk2' + build_func "gcc -m32" '32' 'i386' 'gtk2' build_func "gcc -m32" '32' 'i386' 'gtk3' diff --git a/Ventoy2Disk/Ventoy2Disk/Language.h b/Ventoy2Disk/Ventoy2Disk/Language.h index f1fc4816..57cb0219 100644 --- a/Ventoy2Disk/Ventoy2Disk/Language.h +++ b/Ventoy2Disk/Ventoy2Disk/Language.h @@ -94,6 +94,8 @@ typedef enum STR_ID STR_DONATE, //54 + STR_4KN_UNSUPPORTED, //55 + STR_ID_MAX }STR_ID; diff --git a/Ventoy2Disk/Ventoy2Disk/PhyDrive.c b/Ventoy2Disk/Ventoy2Disk/PhyDrive.c index ff69536f..42d74d06 100644 --- a/Ventoy2Disk/Ventoy2Disk/PhyDrive.c +++ b/Ventoy2Disk/Ventoy2Disk/PhyDrive.c @@ -139,7 +139,7 @@ static DWORD GetVentoyVolumeName(int PhyDrive, UINT64 StartSectorId, CHAR *NameB return Status; } -static int GetLettersBelongPhyDrive(int PhyDrive, char *DriveLetters, size_t Length) +int GetLettersBelongPhyDrive(int PhyDrive, char *DriveLetters, size_t Length) { int n = 0; DWORD DataSize = 0; @@ -355,6 +355,7 @@ int GetAllPhysicalDriveInfo(PHY_DRIVE_INFO *pDriveList, DWORD *pDriveCount) STORAGE_PROPERTY_QUERY Query; STORAGE_DESCRIPTOR_HEADER DevDescHeader; STORAGE_DEVICE_DESCRIPTOR *pDevDesc; + STORAGE_ACCESS_ALIGNMENT_DESCRIPTOR diskAlignment; int PhyDriveId[VENTOY_MAX_PHY_DRIVE]; Count = GetPhysicalDriveCount(); @@ -468,12 +469,35 @@ int GetAllPhysicalDriveInfo(PHY_DRIVE_INFO *pDriveList, DWORD *pDriveCount) continue; } + + + memset(&Query, 0, sizeof(STORAGE_PROPERTY_QUERY)); + Query.PropertyId = StorageAccessAlignmentProperty; + Query.QueryType = PropertyStandardQuery; + memset(&diskAlignment, 0, sizeof(STORAGE_ACCESS_ALIGNMENT_DESCRIPTOR)); + + bRet = DeviceIoControl(Handle, + IOCTL_STORAGE_QUERY_PROPERTY, + &Query, + sizeof(STORAGE_PROPERTY_QUERY), + &diskAlignment, + sizeof(STORAGE_ACCESS_ALIGNMENT_DESCRIPTOR), + &dwBytes, + NULL); + if (!bRet) + { + Log("DeviceIoControl3 error:%u dwBytes:%u", LASTERR, dwBytes); + } + CurDrive->PhyDrive = i; CurDrive->SizeInBytes = LengthInfo.Length.QuadPart; CurDrive->DeviceType = pDevDesc->DeviceType; CurDrive->RemovableMedia = pDevDesc->RemovableMedia; CurDrive->BusType = pDevDesc->BusType; + CurDrive->BytesPerLogicalSector = diskAlignment.BytesPerLogicalSector; + CurDrive->BytesPerPhysicalSector = diskAlignment.BytesPerPhysicalSector; + if (pDevDesc->VendorIdOffset) { safe_strcpy(CurDrive->VendorId, (char *)pDevDesc + pDevDesc->VendorIdOffset); @@ -508,9 +532,10 @@ int GetAllPhysicalDriveInfo(PHY_DRIVE_INFO *pDriveList, DWORD *pDriveCount) for (i = 0, CurDrive = pDriveList; i < (int)DriveCount; i++, CurDrive++) { - Log("PhyDrv:%d BusType:%-4s Removable:%u Size:%dGB(%llu) Name:%s %s", + Log("PhyDrv:%d BusType:%-4s Removable:%u Size:%dGB(%llu) Sector:%u/%u Name:%s %s", CurDrive->PhyDrive, GetBusTypeString(CurDrive->BusType), CurDrive->RemovableMedia, GetHumanReadableGBSize(CurDrive->SizeInBytes), CurDrive->SizeInBytes, + CurDrive->BytesPerLogicalSector, CurDrive->BytesPerPhysicalSector, CurDrive->VendorId, CurDrive->ProductId); } @@ -2351,30 +2376,37 @@ int PartitionResizeForVentoy(PHY_DRIVE_INFO *pPhyDrive) Sleep(2000); - //Refresh disk list - PhyDrive = pPhyDrive->PhyDrive; + if (g_CLI_Mode) + { + Log("### Ventoy non-destructive CLI installation successfully finished."); + } + else + { + //Refresh disk list + PhyDrive = pPhyDrive->PhyDrive; - Log("#### Now Refresh PhyDrive ####"); - Ventoy2DiskDestroy(); - Ventoy2DiskInit(); - - pPhyDrive = GetPhyDriveInfoByPhyDrive(PhyDrive); - if (pPhyDrive) - { - if (pPhyDrive->VentoyVersion[0] == 0) - { - Log("After process the Ventoy version is still invalid"); - goto End; - } + Log("#### Now Refresh PhyDrive ####"); + Ventoy2DiskDestroy(); + Ventoy2DiskInit(); - Log("### Ventoy non-destructive installation successfully finished <%s>", pPhyDrive->VentoyVersion); - } - else - { - Log("### Ventoy non-destructive installation successfully finished "); - } + pPhyDrive = GetPhyDriveInfoByPhyDrive(PhyDrive); + if (pPhyDrive) + { + if (pPhyDrive->VentoyVersion[0] == 0) + { + Log("After process the Ventoy version is still invalid"); + goto End; + } - InitComboxCtrl(g_DialogHwnd, PhyDrive); + Log("### Ventoy non-destructive installation successfully finished <%s>", pPhyDrive->VentoyVersion); + } + else + { + Log("### Ventoy non-destructive installation successfully finished "); + } + + InitComboxCtrl(g_DialogHwnd, PhyDrive); + } rc = 0; diff --git a/Ventoy2Disk/Ventoy2Disk/Utility.c b/Ventoy2Disk/Ventoy2Disk/Utility.c index dc9464a8..daa6ecf5 100644 --- a/Ventoy2Disk/Ventoy2Disk/Utility.c +++ b/Ventoy2Disk/Ventoy2Disk/Utility.c @@ -40,6 +40,56 @@ void TraceOut(const char *Fmt, ...) } } +typedef struct LogBuf +{ + int Len; + char szBuf[1024]; + struct LogBuf* next; +}LogBuf; + +static BOOL g_LogCache = FALSE; +static LogBuf* g_LogHead = NULL; +static LogBuf* g_LogTail = NULL; + +void LogCache(BOOL cache) +{ + g_LogCache = cache; +} + +void LogFlush(void) +{ + FILE* File = NULL; + LogBuf* Node = NULL; + LogBuf* Next = NULL; + + if (g_CLI_Mode) + { + fopen_s(&File, VENTOY_CLI_LOG, "a+"); + } + else + { + fopen_s(&File, VENTOY_FILE_LOG, "a+"); + } + + if (File) + { + for (Node = g_LogHead; Node; Node = Node->next) + { + fwrite(Node->szBuf, 1, Node->Len, File); + fwrite("\n", 1, 1, File); + } + fclose(File); + } + + for (Node = g_LogHead; Node; Node = Next) + { + Next = Node->next; + free(Node); + } + + g_LogHead = g_LogTail = NULL; +} + void Log(const char *Fmt, ...) { va_list Arg; @@ -59,6 +109,30 @@ void Log(const char *Fmt, ...) Len += vsnprintf_s(szBuf + Len, sizeof(szBuf)-Len - 1, sizeof(szBuf)-Len-1, Fmt, Arg); va_end(Arg); + if (g_LogCache) + { + LogBuf* Node = NULL; + Node = malloc(sizeof(LogBuf)); + if (Node) + { + memcpy(Node->szBuf, szBuf, Len); + Node->next = NULL; + Node->Len = Len; + + if (g_LogTail) + { + g_LogTail->next = Node; + g_LogTail = Node; + } + else + { + g_LogHead = g_LogTail = Node; + } + } + + return; + } + if (g_CLI_Mode) { fopen_s(&File, VENTOY_CLI_LOG, "a+"); diff --git a/Ventoy2Disk/Ventoy2Disk/Ventoy2Disk.h b/Ventoy2Disk/Ventoy2Disk/Ventoy2Disk.h index 1a0a453f..b0947256 100644 --- a/Ventoy2Disk/Ventoy2Disk/Ventoy2Disk.h +++ b/Ventoy2Disk/Ventoy2Disk/Ventoy2Disk.h @@ -176,6 +176,9 @@ typedef struct PHY_DRIVE_INFO CHAR SerialNumber[128]; STORAGE_BUS_TYPE BusType; + DWORD BytesPerLogicalSector; + DWORD BytesPerPhysicalSector; + CHAR DriveLetters[64]; int VentoyFsClusterSize; @@ -234,6 +237,8 @@ extern int g_FilterUSB; void TraceOut(const char *Fmt, ...); void Log(const char *Fmt, ...); +void LogCache(BOOL cache); +void LogFlush(void); BOOL IsPathExist(BOOL Dir, const char *Fmt, ...); void DumpWindowsVersion(void); const CHAR* GetLocalVentoyVersion(void); @@ -370,6 +375,15 @@ BOOL IsVentoyPhyDrive(int PhyDrive, UINT64 SizeBytes, MBR_HEAD* pMBR, UINT64* Pa int GetVentoyFsNameInPhyDrive(PHY_DRIVE_INFO* CurDrive); void CLISetReserveSpace(int MB); void CLI_UpdatePercent(int Pos); +int GetLettersBelongPhyDrive(int PhyDrive, char* DriveLetters, size_t Length); +PHY_DRIVE_INFO* CLI_PhyDrvInfo(void); + +#define UTF8_Log(fmt, wstr) \ +{\ + memset(TmpPathA, 0, sizeof(TmpPathA));\ + WideCharToMultiByte(CP_UTF8, 0, wstr, -1, TmpPathA, sizeof(TmpPathA), NULL, NULL);\ + Log(fmt, TmpPathA);\ +} #define VTSI_SUPPORT 1 diff --git a/Ventoy2Disk/Ventoy2Disk/WinDialog.c b/Ventoy2Disk/Ventoy2Disk/WinDialog.c index 40a8ab63..7ae91958 100644 Binary files a/Ventoy2Disk/Ventoy2Disk/WinDialog.c and b/Ventoy2Disk/Ventoy2Disk/WinDialog.c differ diff --git a/Ventoy2Disk/Ventoy2Disk/ventoy_cli.c b/Ventoy2Disk/Ventoy2Disk/ventoy_cli.c index 10c8ffe9..8adffcae 100644 --- a/Ventoy2Disk/Ventoy2Disk/ventoy_cli.c +++ b/Ventoy2Disk/Ventoy2Disk/ventoy_cli.c @@ -17,12 +17,16 @@ typedef struct CLI_CFG int PartStyle; int ReserveMB; BOOL USBCheck; + BOOL NonDest; + int fstype; }CLI_CFG; BOOL g_CLI_Mode = FALSE; static int g_CLI_OP; static int g_CLI_PhyDrive; +static PHY_DRIVE_INFO* g_CLI_PhyDrvInfo = NULL; + static int CLI_GetPhyDriveInfo(int PhyDrive, PHY_DRIVE_INFO* pInfo) { BOOL bRet; @@ -33,6 +37,7 @@ static int CLI_GetPhyDriveInfo(int PhyDrive, PHY_DRIVE_INFO* pInfo) STORAGE_PROPERTY_QUERY Query; STORAGE_DESCRIPTOR_HEADER DevDescHeader; STORAGE_DEVICE_DESCRIPTOR* pDevDesc; + STORAGE_ACCESS_ALIGNMENT_DESCRIPTOR diskAlignment; safe_sprintf(PhyDrivePath, "\\\\.\\PhysicalDrive%d", PhyDrive); Handle = CreateFileA(PhyDrivePath, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, NULL); @@ -103,12 +108,35 @@ static int CLI_GetPhyDriveInfo(int PhyDrive, PHY_DRIVE_INFO* pInfo) return 1; } + + memset(&Query, 0, sizeof(STORAGE_PROPERTY_QUERY)); + Query.PropertyId = StorageAccessAlignmentProperty; + Query.QueryType = PropertyStandardQuery; + memset(&diskAlignment, 0, sizeof(STORAGE_ACCESS_ALIGNMENT_DESCRIPTOR)); + + bRet = DeviceIoControl(Handle, + IOCTL_STORAGE_QUERY_PROPERTY, + &Query, + sizeof(STORAGE_PROPERTY_QUERY), + &diskAlignment, + sizeof(STORAGE_ACCESS_ALIGNMENT_DESCRIPTOR), + &dwBytes, + NULL); + if (!bRet) + { + Log("DeviceIoControl3 error:%u dwBytes:%u", LASTERR, dwBytes); + } + + pInfo->PhyDrive = PhyDrive; pInfo->SizeInBytes = LengthInfo.Length.QuadPart; pInfo->DeviceType = pDevDesc->DeviceType; pInfo->RemovableMedia = pDevDesc->RemovableMedia; pInfo->BusType = pDevDesc->BusType; + pInfo->BytesPerLogicalSector = diskAlignment.BytesPerLogicalSector; + pInfo->BytesPerPhysicalSector = diskAlignment.BytesPerPhysicalSector; + if (pDevDesc->VendorIdOffset) { safe_strcpy(pInfo->VendorId, (char*)pDevDesc + pDevDesc->VendorIdOffset); @@ -143,12 +171,14 @@ static int CLI_GetPhyDriveInfo(int PhyDrive, PHY_DRIVE_INFO* pInfo) static int CLI_CheckParam(int argc, char** argv, PHY_DRIVE_INFO* pDrvInfo, CLI_CFG *pCfg) { int i; + int fstype = VTOY_FS_EXFAT; int op = -1; char* opt = NULL; int PhyDrive = -1; int PartStyle = 0; int ReserveMB = 0; BOOL USBCheck = TRUE; + BOOL NonDest = FALSE; MBR_HEAD MBR; UINT64 Part2GPTAttr = 0; UINT64 Part2StartSector = 0; @@ -176,6 +206,10 @@ static int CLI_CheckParam(int argc, char** argv, PHY_DRIVE_INFO* pDrvInfo, CLI_C { USBCheck = FALSE; } + else if (_stricmp(opt, "/NonDest") == 0) + { + NonDest = TRUE; + } else if (_strnicmp(opt, "/Drive:", 7) == 0) { Log("Get PhyDrive by logical drive %C:", opt[7]); @@ -189,6 +223,17 @@ static int CLI_CheckParam(int argc, char** argv, PHY_DRIVE_INFO* pDrvInfo, CLI_C { ReserveMB = (int)strtol(opt + 3, NULL, 10); } + else if (_strnicmp(opt, "/FS:", 4) == 0) + { + if (_stricmp(opt + 4, "NTFS") == 0) + { + fstype = VTOY_FS_NTFS; + } + else if (_stricmp(opt + 4, "FAT32") == 0) + { + fstype = VTOY_FS_FAT32; + } + } } if (op < 0 || PhyDrive < 0) @@ -197,10 +242,10 @@ static int CLI_CheckParam(int argc, char** argv, PHY_DRIVE_INFO* pDrvInfo, CLI_C return 1; } - Log("Ventoy CLI %s PhyDrive:%d %s SecureBoot:%d ReserveSpace:%dMB USBCheck:%u", + Log("Ventoy CLI %s PhyDrive:%d %s SecureBoot:%d ReserveSpace:%dMB USBCheck:%u FS:%s NonDest:%d", op == 0 ? "install" : "update", PhyDrive, PartStyle ? "GPT" : "MBR", - g_SecureBoot, ReserveMB, USBCheck + g_SecureBoot, ReserveMB, USBCheck, GetVentoyFsFmtNameByTypeA(fstype), NonDest ); if (CLI_GetPhyDriveInfo(PhyDrive, pDrvInfo)) @@ -231,14 +276,51 @@ static int CLI_CheckParam(int argc, char** argv, PHY_DRIVE_INFO* pDrvInfo, CLI_C } } + if (op == 0 && NonDest) + { + GetLettersBelongPhyDrive(PhyDrive, pDrvInfo->DriveLetters, sizeof(pDrvInfo->DriveLetters)); + } + pCfg->op = op; pCfg->PartStyle = PartStyle; pCfg->ReserveMB = ReserveMB; pCfg->USBCheck = USBCheck; + pCfg->NonDest = NonDest; + pCfg->fstype = fstype; return 0; } +static int Ventoy_CLI_NonDestInstall(PHY_DRIVE_INFO* pDrvInfo, CLI_CFG* pCfg) +{ + int rc; + int TryId = 1; + + Log("Ventoy_CLI_NonDestInstall start ..."); + + if (pDrvInfo->BytesPerLogicalSector == 4096 && pDrvInfo->BytesPerPhysicalSector == 4096) + { + Log("Ventoy does not support 4k native disk."); + rc = 1; + goto out; + } + + if (!PartResizePreCheck(NULL)) + { + Log("#### Part Resize PreCheck Failed ####"); + rc = 1; + goto out; + } + + rc = PartitionResizeForVentoy(pDrvInfo); + +out: + Log("Ventoy_CLI_NonDestInstall [%s]", rc == 0 ? "SUCCESS" : "FAILED"); + + return rc; +} + + static int Ventoy_CLI_Install(PHY_DRIVE_INFO* pDrvInfo, CLI_CFG *pCfg) { int rc; @@ -246,11 +328,20 @@ static int Ventoy_CLI_Install(PHY_DRIVE_INFO* pDrvInfo, CLI_CFG *pCfg) Log("Ventoy_CLI_Install start ..."); + if (pDrvInfo->BytesPerLogicalSector == 4096 && pDrvInfo->BytesPerPhysicalSector == 4096) + { + Log("Ventoy does not support 4k native disk."); + rc = 1; + goto out; + } + if (pCfg->ReserveMB > 0) { CLISetReserveSpace(pCfg->ReserveMB); } + SetVentoyFsType(pCfg->fstype); + rc = InstallVentoy2PhyDrive(pDrvInfo, pCfg->PartStyle, TryId++); if (rc) { @@ -274,6 +365,9 @@ static int Ventoy_CLI_Install(PHY_DRIVE_INFO* pDrvInfo, CLI_CFG *pCfg) } } + SetVentoyFsType(VTOY_FS_EXFAT); + +out: Log("Ventoy_CLI_Install [%s]", rc == 0 ? "SUCCESS" : "FAILED"); return rc; @@ -351,6 +445,11 @@ static void CLI_WriteDoneFile(int ret) } } +PHY_DRIVE_INFO* CLI_PhyDrvInfo(void) +{ + return g_CLI_PhyDrvInfo; +} + /* * Ventoy2Disk.exe VTOYCLI { /I | /U } { /Drive:F: | /PhyDrive:1 } /GPT /NoSB /R:4096 /NoUSBCheck * @@ -364,7 +463,7 @@ int VentoyCLIMain(int argc, char** argv) DeleteFileA(VENTOY_CLI_PERCENT); DeleteFileA(VENTOY_CLI_DONE); - pDrvInfo = (PHY_DRIVE_INFO*)malloc(sizeof(PHY_DRIVE_INFO)); + g_CLI_PhyDrvInfo = pDrvInfo = (PHY_DRIVE_INFO*)malloc(sizeof(PHY_DRIVE_INFO)); if (!pDrvInfo) { goto end; @@ -388,7 +487,16 @@ int VentoyCLIMain(int argc, char** argv) if (CliCfg.op == 0) { - ret = Ventoy_CLI_Install(pDrvInfo, &CliCfg); + if (CliCfg.NonDest) + { + ret = Ventoy_CLI_NonDestInstall(pDrvInfo, &CliCfg); + } + else + { + AlertSuppressInit(); + SetAlertPromptHookEnable(TRUE); + ret = Ventoy_CLI_Install(pDrvInfo, &CliCfg); + } } else {