Commit ebaa4d95 authored by longpanda's avatar longpanda
Browse files

IA32 ARM64 support

parent 2936666a
...@@ -26,6 +26,8 @@ fi ...@@ -26,6 +26,8 @@ fi
if uname -a | egrep -q 'x86_64|amd64'; then if uname -a | egrep -q 'x86_64|amd64'; then
name=unsquashfs_64 name=unsquashfs_64
elif uname -a | egrep -q 'aarch64'; then
name=unsquashfs_aa64
else else
name=unsquashfs_32 name=unsquashfs_32
fi fi
......
...@@ -4,8 +4,9 @@ rm -f vblade_* ...@@ -4,8 +4,9 @@ rm -f vblade_*
gcc linux.c aoe.c ata.c bpf.c -Os -o vblade_64 gcc linux.c aoe.c ata.c bpf.c -Os -o vblade_64
gcc linux.c aoe.c ata.c bpf.c -Os -m32 -o vblade_32 gcc linux.c aoe.c ata.c bpf.c -Os -m32 -o vblade_32
aarch64-buildroot-linux-uclibc-gcc linux.c aoe.c ata.c bpf.c -Os -static -o vblade_aa64
if [ -e vblade_64 ] && [ -e vblade_32 ]; then if [ -e vblade_64 ] && [ -e vblade_32 ] && [ -e vblade_aa64 ]; then
echo -e '\n################## SUCCESS ######################\n' echo -e '\n################## SUCCESS ######################\n'
else else
echo -e '\n################## FAILED ######################\n' echo -e '\n################## FAILED ######################\n'
......
...@@ -798,10 +798,11 @@ static int VentoyFatDiskRead(uint32 Sector, uint8 *Buffer, uint32 SectorCount) ...@@ -798,10 +798,11 @@ static int VentoyFatDiskRead(uint32 Sector, uint8 *Buffer, uint32 SectorCount)
} }
int GetVentoyVerInPhyDrive(const PHY_DRIVE_INFO *pDriveInfo, UINT64 Part2StartSector, CHAR *VerBuf, size_t BufLen) int GetVentoyVerInPhyDrive(const PHY_DRIVE_INFO *pDriveInfo, UINT64 Part2StartSector, CHAR *VerBuf, size_t BufLen, BOOL *pSecureBoot)
{ {
int rc = 0; int rc = 0;
HANDLE hDrive; HANDLE hDrive;
void *flfile;
hDrive = GetPhysicalHandle(pDriveInfo->PhyDrive, FALSE, FALSE, FALSE); hDrive = GetPhysicalHandle(pDriveInfo->PhyDrive, FALSE, FALSE, FALSE);
if (hDrive == INVALID_HANDLE_VALUE) if (hDrive == INVALID_HANDLE_VALUE)
...@@ -831,6 +832,13 @@ int GetVentoyVerInPhyDrive(const PHY_DRIVE_INFO *pDriveInfo, UINT64 Part2StartSe ...@@ -831,6 +832,13 @@ int GetVentoyVerInPhyDrive(const PHY_DRIVE_INFO *pDriveInfo, UINT64 Part2StartSe
if (rc == 0) if (rc == 0)
{ {
Log("VentoyVerInPhyDrive %d is <%s>...", pDriveInfo->PhyDrive, VerBuf); Log("VentoyVerInPhyDrive %d is <%s>...", pDriveInfo->PhyDrive, VerBuf);
flfile = fl_fopen("/EFI/BOOT/grubx64_real.efi", "rb");
if (flfile)
{
*pSecureBoot = TRUE;
fl_fclose(flfile);
}
} }
fl_shutdown(); fl_shutdown();
...@@ -962,6 +970,50 @@ int VentoyProcSecureBoot(BOOL SecureBoot) ...@@ -962,6 +970,50 @@ int VentoyProcSecureBoot(BOOL SecureBoot)
free(filebuf); free(filebuf);
} }
} }
file = fl_fopen("/EFI/BOOT/grubia32_real.efi", "rb");
Log("Open ventoy efi file %p ", file);
if (file)
{
fl_fseek(file, 0, SEEK_END);
size = (int)fl_ftell(file);
fl_fseek(file, 0, SEEK_SET);
Log("ventoy efi file size %d ...", size);
filebuf = (char *)malloc(size);
if (filebuf)
{
fl_fread(filebuf, 1, size, file);
}
fl_fclose(file);
Log("Now delete all efi files ...");
fl_remove("/EFI/BOOT/BOOTIA32.EFI");
fl_remove("/EFI/BOOT/grubia32.efi");
fl_remove("/EFI/BOOT/grubia32_real.efi");
fl_remove("/EFI/BOOT/mmia32.efi");
file = fl_fopen("/EFI/BOOT/BOOTIA32.EFI", "wb");
Log("Open bootia32 efi file %p ", file);
if (file)
{
if (filebuf)
{
fl_fwrite(filebuf, 1, size, file);
}
fl_fflush(file);
fl_fclose(file);
}
if (filebuf)
{
free(filebuf);
}
}
} }
else else
{ {
...@@ -1627,6 +1679,7 @@ int InstallVentoy2PhyDrive(PHY_DRIVE_INFO *pPhyDrive, int PartStyle) ...@@ -1627,6 +1679,7 @@ int InstallVentoy2PhyDrive(PHY_DRIVE_INFO *pPhyDrive, int PartStyle)
} }
Log("Write GPT Info OK ..."); Log("Write GPT Info OK ...");
memcpy(&(pPhyDrive->MBR), &MBR, 512);
} }
else else
{ {
...@@ -1637,8 +1690,8 @@ int InstallVentoy2PhyDrive(PHY_DRIVE_INFO *pPhyDrive, int PartStyle) ...@@ -1637,8 +1690,8 @@ int InstallVentoy2PhyDrive(PHY_DRIVE_INFO *pPhyDrive, int PartStyle)
goto End; goto End;
} }
Log("Write MBR OK ..."); Log("Write MBR OK ...");
memcpy(&(pPhyDrive->MBR), &MBR, 512);
} }
//Refresh Drive Layout //Refresh Drive Layout
DeviceIoControl(hDrive, IOCTL_DISK_UPDATE_PROPERTIES, NULL, 0, NULL, 0, &dwSize, NULL); DeviceIoControl(hDrive, IOCTL_DISK_UPDATE_PROPERTIES, NULL, 0, NULL, 0, &dwSize, NULL);
...@@ -1719,6 +1772,7 @@ int UpdateVentoy2PhyDrive(PHY_DRIVE_INFO *pPhyDrive) ...@@ -1719,6 +1772,7 @@ int UpdateVentoy2PhyDrive(PHY_DRIVE_INFO *pPhyDrive)
MBR_HEAD BootImg; MBR_HEAD BootImg;
MBR_HEAD MBR; MBR_HEAD MBR;
VTOY_GPT_INFO *pGptInfo = NULL; VTOY_GPT_INFO *pGptInfo = NULL;
UINT8 ReservedData[4096];
Log("UpdateVentoy2PhyDrive %s PhyDrive%d <<%s %s %dGB>>", Log("UpdateVentoy2PhyDrive %s PhyDrive%d <<%s %s %dGB>>",
pPhyDrive->PartStyle ? "GPT" : "MBR", pPhyDrive->PhyDrive, pPhyDrive->VendorId, pPhyDrive->ProductId, pPhyDrive->PartStyle ? "GPT" : "MBR", pPhyDrive->PhyDrive, pPhyDrive->VendorId, pPhyDrive->ProductId,
...@@ -1771,6 +1825,10 @@ int UpdateVentoy2PhyDrive(PHY_DRIVE_INFO *pPhyDrive) ...@@ -1771,6 +1825,10 @@ int UpdateVentoy2PhyDrive(PHY_DRIVE_INFO *pPhyDrive)
Log("MBR Reserved Disk Space:%llu MB", (ULONGLONG)ReservedMB); Log("MBR Reserved Disk Space:%llu MB", (ULONGLONG)ReservedMB);
} }
//Read Reserved Data
SetFilePointer(hDrive, 512 * 2040, NULL, FILE_BEGIN);
ReadFile(hDrive, ReservedData, sizeof(ReservedData), &dwSize, NULL);
GetLettersBelongPhyDrive(pPhyDrive->PhyDrive, DriveLetters, sizeof(DriveLetters)); GetLettersBelongPhyDrive(pPhyDrive->PhyDrive, DriveLetters, sizeof(DriveLetters));
if (DriveLetters[0] == 0) if (DriveLetters[0] == 0)
...@@ -1895,6 +1953,11 @@ int UpdateVentoy2PhyDrive(PHY_DRIVE_INFO *pPhyDrive) ...@@ -1895,6 +1953,11 @@ int UpdateVentoy2PhyDrive(PHY_DRIVE_INFO *pPhyDrive)
goto End; goto End;
} }
//write reserved data
SetFilePointer(hDrive, 512 * 2040, NULL, FILE_BEGIN);
bRet = WriteFile(hDrive, ReservedData, sizeof(ReservedData), &dwSize, NULL);
Log("Write resv data ret:%u dwSize:%u Error:%u", bRet, dwSize, LASTERR);
// Boot Image // Boot Image
VentoyGetLocalBootImg(&BootImg); VentoyGetLocalBootImg(&BootImg);
......
...@@ -231,13 +231,6 @@ static int FilterPhysicalDrive(PHY_DRIVE_INFO *pDriveList, DWORD DriveCount) ...@@ -231,13 +231,6 @@ static int FilterPhysicalDrive(PHY_DRIVE_INFO *pDriveList, DWORD DriveCount)
CurDrive->Id = -1; CurDrive->Id = -1;
memset(CurDrive->DriveLetters, 0, sizeof(CurDrive->DriveLetters)); memset(CurDrive->DriveLetters, 0, sizeof(CurDrive->DriveLetters));
// Too big for MBR
if (CurDrive->SizeInBytes > 2199023255552ULL)
{
Log("<%s %s> is filtered for too big for MBR.", CurDrive->VendorId, CurDrive->ProductId);
continue;
}
if (g_FilterRemovable && (!CurDrive->RemovableMedia)) if (g_FilterRemovable && (!CurDrive->RemovableMedia))
{ {
Log("<%s %s> is filtered for not removable.", CurDrive->VendorId, CurDrive->ProductId); Log("<%s %s> is filtered for not removable.", CurDrive->VendorId, CurDrive->ProductId);
...@@ -266,8 +259,10 @@ static int FilterPhysicalDrive(PHY_DRIVE_INFO *pDriveList, DWORD DriveCount) ...@@ -266,8 +259,10 @@ static int FilterPhysicalDrive(PHY_DRIVE_INFO *pDriveList, DWORD DriveCount)
if (IsVentoyPhyDrive(CurDrive->PhyDrive, CurDrive->SizeInBytes, &MBR, &Part2StartSector)) if (IsVentoyPhyDrive(CurDrive->PhyDrive, CurDrive->SizeInBytes, &MBR, &Part2StartSector))
{ {
memcpy(&(CurDrive->MBR), &MBR, sizeof(MBR));
CurDrive->PartStyle = (MBR.PartTbl[0].FsFlag == 0xEE) ? 1 : 0; CurDrive->PartStyle = (MBR.PartTbl[0].FsFlag == 0xEE) ? 1 : 0;
GetVentoyVerInPhyDrive(CurDrive, Part2StartSector, CurDrive->VentoyVersion, sizeof(CurDrive->VentoyVersion)); GetVentoyVerInPhyDrive(CurDrive, Part2StartSector, CurDrive->VentoyVersion, sizeof(CurDrive->VentoyVersion), &(CurDrive->SecureBootSupport));
Log("PhyDrive %d is Ventoy Disk ver:%s SecureBoot:%u", CurDrive->PhyDrive, CurDrive->VentoyVersion, CurDrive->SecureBootSupport);
} }
} }
......
...@@ -116,6 +116,18 @@ typedef struct VTOY_GPT_INFO ...@@ -116,6 +116,18 @@ typedef struct VTOY_GPT_INFO
VTOY_GPT_PART_TBL PartTbl[128]; VTOY_GPT_PART_TBL PartTbl[128];
}VTOY_GPT_INFO; }VTOY_GPT_INFO;
typedef struct ventoy_secure_data
{
UINT8 magic1[16]; /* VENTOY_GUID */
UINT8 diskuuid[16];
UINT8 Checksum[16];
UINT8 adminSHA256[32];
UINT8 reserved[4000];
UINT8 magic2[16]; /* VENTOY_GUID */
}ventoy_secure_data;
#pragma pack() #pragma pack()
#define VENTOY_MAX_PHY_DRIVE 128 #define VENTOY_MAX_PHY_DRIVE 128
...@@ -138,6 +150,8 @@ typedef struct PHY_DRIVE_INFO ...@@ -138,6 +150,8 @@ typedef struct PHY_DRIVE_INFO
CHAR VentoyVersion[32]; CHAR VentoyVersion[32];
BOOL SecureBootSupport;
MBR_HEAD MBR;
}PHY_DRIVE_INFO; }PHY_DRIVE_INFO;
typedef enum PROGRESS_POINT typedef enum PROGRESS_POINT
...@@ -186,7 +200,7 @@ int GetRegDwordValue(HKEY Key, LPCSTR SubKey, LPCSTR ValueName, DWORD *pValue); ...@@ -186,7 +200,7 @@ int GetRegDwordValue(HKEY Key, LPCSTR SubKey, LPCSTR ValueName, DWORD *pValue);
int GetPhysicalDriveCount(void); int GetPhysicalDriveCount(void);
int GetAllPhysicalDriveInfo(PHY_DRIVE_INFO *pDriveList, DWORD *pDriveCount); int GetAllPhysicalDriveInfo(PHY_DRIVE_INFO *pDriveList, DWORD *pDriveCount);
int GetPhyDriveByLogicalDrive(int DriveLetter); int GetPhyDriveByLogicalDrive(int DriveLetter);
int GetVentoyVerInPhyDrive(const PHY_DRIVE_INFO *pDriveInfo, UINT64 Part2StartSector, CHAR *VerBuf, size_t BufLen); int GetVentoyVerInPhyDrive(const PHY_DRIVE_INFO *pDriveInfo, UINT64 Part2StartSector, CHAR *VerBuf, size_t BufLen, BOOL *pSecureBoot);
int Ventoy2DiskInit(void); int Ventoy2DiskInit(void);
int Ventoy2DiskDestroy(void); int Ventoy2DiskDestroy(void);
PHY_DRIVE_INFO * GetPhyDriveInfoById(int Id); PHY_DRIVE_INFO * GetPhyDriveInfoById(int Id);
......
File suppressed by a .gitattributes entry or the file's encoding is unsupported.
...@@ -5,12 +5,16 @@ rm -f vtoytool/00/* ...@@ -5,12 +5,16 @@ rm -f vtoytool/00/*
/opt/diet64/bin/diet -Os gcc -D_FILE_OFFSET_BITS=64 *.c BabyISO/*.c -IBabyISO -Wall -DBUILD_VTOY_TOOL -DUSE_DIET_C -o vtoytool_64 /opt/diet64/bin/diet -Os gcc -D_FILE_OFFSET_BITS=64 *.c BabyISO/*.c -IBabyISO -Wall -DBUILD_VTOY_TOOL -DUSE_DIET_C -o vtoytool_64
/opt/diet32/bin/diet -Os gcc -D_FILE_OFFSET_BITS=64 -m32 *.c BabyISO/*.c -IBabyISO -Wall -DBUILD_VTOY_TOOL -DUSE_DIET_C -o vtoytool_32 /opt/diet32/bin/diet -Os gcc -D_FILE_OFFSET_BITS=64 -m32 *.c BabyISO/*.c -IBabyISO -Wall -DBUILD_VTOY_TOOL -DUSE_DIET_C -o vtoytool_32
aarch64-buildroot-linux-uclibc-gcc -Os -static -D_FILE_OFFSET_BITS=64 *.c BabyISO/*.c -IBabyISO -Wall -DBUILD_VTOY_TOOL -o vtoytool_aa64
#gcc -D_FILE_OFFSET_BITS=64 -static -Wall -DBUILD_VTOY_TOOL *.c BabyISO/*.c -IBabyISO -o vtoytool_64 #gcc -D_FILE_OFFSET_BITS=64 -static -Wall -DBUILD_VTOY_TOOL *.c BabyISO/*.c -IBabyISO -o vtoytool_64
#gcc -D_FILE_OFFSET_BITS=64 -Wall -DBUILD_VTOY_TOOL -m32 *.c BabyISO/*.c -IBabyISO -o vtoytool_32 #gcc -D_FILE_OFFSET_BITS=64 -Wall -DBUILD_VTOY_TOOL -m32 *.c BabyISO/*.c -IBabyISO -o vtoytool_32
if [ -e vtoytool_64 ] && [ -e vtoytool_32 ]; then if [ -e vtoytool_64 ] && [ -e vtoytool_32 ] && [ -e vtoytool_aa64 ]; then
echo -e '\n############### SUCCESS ###############\n' echo -e '\n############### SUCCESS ###############\n'
aarch64-buildroot-linux-uclibc-strip --strip-all vtoytool_aa64
mv vtoytool_aa64 vtoytool/00/
mv vtoytool_64 vtoytool/00/ mv vtoytool_64 vtoytool/00/
mv vtoytool_32 vtoytool/00/ mv vtoytool_32 vtoytool/00/
else else
......
Build a static linked, small zstdcat tool Build a static linked, small zstdcat tool
======== Source Code ======== ======== Source Code ========
use an old version of zstd use an old version of zstd
https://codeload.github.com/facebook/zstd/zip/v1.0.0 https://codeload.github.com/facebook/zstd/zip/v1.0.0
======== Build Envrioment ======== ======== Build Envrioment ========
build for 32bit, static linked with dietlibc build for 32bit, static linked with dietlibc
1. install centos 6.10 i386 with CentOS-6.10-i386-bin-DVD1.iso 1. install centos 6.10 i386 with CentOS-6.10-i386-bin-DVD1.iso
2. yum install gcc gettext gettext-devel 2. yum install gcc gettext gettext-devel
3. install dietc libc (just make && make install) 3. install dietc libc (just make && make install)
4. export PATH=$PATH:/opt/diet/bin 4. export PATH=$PATH:/opt/diet/bin
======== Build Step ======== ======== Build i386 Step ========
1. extract zstd source code 1. extract zstd source code
2. cd programs 2. cd programs
3. diet -Os gcc -pipe -nostdinc -falign-loops=32 -I../lib -I../lib/common -I../lib/dictBuilder -I../lib/legacy -O3 -Wall -Wextra -Wcast-qual -Wcast-align -Wshadow -Wstrict-aliasing=1 -Wswitch-enum -Wdeclaration-after-statement -Wstrict-prototypes -Wundef -DZSTD_LEGACY_SUPPORT=1 ../lib/decompress/zstd_decompress.c -c -o ../lib/decompress/zstd_decompress.o 3. diet -Os gcc -pipe -nostdinc -falign-loops=32 -I../lib -I../lib/common -I../lib/dictBuilder -I../lib/legacy -O3 -Wall -Wextra -Wcast-qual -Wcast-align -Wshadow -Wstrict-aliasing=1 -Wswitch-enum -Wdeclaration-after-statement -Wstrict-prototypes -Wundef -DZSTD_LEGACY_SUPPORT=1 ../lib/decompress/zstd_decompress.c -c -o ../lib/decompress/zstd_decompress.o
diet -Os gcc -pipe -nostdinc -I../lib -I../lib/common -I../lib/dictBuilder -I../lib/legacy -O3 -Wall -Wextra -Wcast-qual -Wcast-align -Wshadow -Wstrict-aliasing=1 -Wswitch-enum -Wdeclaration-after-statement -Wstrict-prototypes -Wundef -DZSTD_LEGACY_SUPPORT=1 ../lib/decompress/zstd_decompress.o ../lib/decompress/huf_decompress.c ../lib/common/entropy_common.c ../lib/common/fse_decompress.c ../lib/common/xxhash.c ../lib/common/zstd_common.c ../lib/compress/zstd_compress.c ../lib/compress/fse_compress.c ../lib/compress/huf_compress.c ../lib/legacy/zstd_v01.c ../lib/legacy/zstd_v02.c ../lib/legacy/zstd_v03.c ../lib/legacy/zstd_v04.c ../lib/legacy/zstd_v05.c ../lib/legacy/zstd_v06.c ../lib/legacy/zstd_v07.c ../lib/dictBuilder/divsufsort.c ../lib/dictBuilder/zdict.c zstdcli.c fileio.c bench.c datagen.c dibio.c -o zstd diet -Os gcc -pipe -nostdinc -I../lib -I../lib/common -I../lib/dictBuilder -I../lib/legacy -O3 -Wall -Wextra -Wcast-qual -Wcast-align -Wshadow -Wstrict-aliasing=1 -Wswitch-enum -Wdeclaration-after-statement -Wstrict-prototypes -Wundef -DZSTD_LEGACY_SUPPORT=1 ../lib/decompress/zstd_decompress.o ../lib/decompress/huf_decompress.c ../lib/common/entropy_common.c ../lib/common/fse_decompress.c ../lib/common/xxhash.c ../lib/common/zstd_common.c ../lib/compress/zstd_compress.c ../lib/compress/fse_compress.c ../lib/compress/huf_compress.c ../lib/legacy/zstd_v01.c ../lib/legacy/zstd_v02.c ../lib/legacy/zstd_v03.c ../lib/legacy/zstd_v04.c ../lib/legacy/zstd_v05.c ../lib/legacy/zstd_v06.c ../lib/legacy/zstd_v07.c ../lib/dictBuilder/divsufsort.c ../lib/dictBuilder/zdict.c zstdcli.c fileio.c bench.c datagen.c dibio.c -o zstd
4. strip --strip-all zstd 4. strip --strip-all zstd
5. rename zstd to zstdcat 5. rename zstd to zstdcat
======== Build x86_64 Step ========
1. extract zstd source code
2. cd programs
3. /opt/diet64/bin/diet -Os gcc -pipe -nostdinc -falign-loops=32 -I../lib -I../lib/common -I../lib/dictBuilder -I../lib/legacy -O3 -Wall -Wextra -Wcast-qual -Wcast-align -Wshadow -Wstrict-aliasing=1 -Wswitch-enum -Wdeclaration-after-statement -Wstrict-prototypes -Wundef -DZSTD_LEGACY_SUPPORT=1 ../lib/decompress/zstd_decompress.c -c -o ../lib/decompress/zstd_decompress.o
/opt/diet64/bin/diet -Os gcc -pipe -nostdinc -I../lib -I../lib/common -I../lib/dictBuilder -I../lib/legacy -O3 -Wall -Wextra -Wcast-qual -Wcast-align -Wshadow -Wstrict-aliasing=1 -Wswitch-enum -Wdeclaration-after-statement -Wstrict-prototypes -Wundef -DZSTD_LEGACY_SUPPORT=1 ../lib/decompress/zstd_decompress.o ../lib/decompress/huf_decompress.c ../lib/common/entropy_common.c ../lib/common/fse_decompress.c ../lib/common/xxhash.c ../lib/common/zstd_common.c ../lib/compress/zstd_compress.c ../lib/compress/fse_compress.c ../lib/compress/huf_compress.c ../lib/legacy/zstd_v01.c ../lib/legacy/zstd_v02.c ../lib/legacy/zstd_v03.c ../lib/legacy/zstd_v04.c ../lib/legacy/zstd_v05.c ../lib/legacy/zstd_v06.c ../lib/legacy/zstd_v07.c ../lib/dictBuilder/divsufsort.c ../lib/dictBuilder/zdict.c zstdcli.c fileio.c bench.c datagen.c dibio.c -o zstd
4. strip --strip-all zstd
5. rename zstd to zstdcat
======== Build ARM64 Step ========
1. extract zstd source code
2. cd programs
3. aarch64-linux-gcc -static -falign-loops=32 -I../lib -I../lib/common -I../lib/dictBuilder -I../lib/legacy -O3 -Wall -Wextra -Wcast-qual -Wcast-align -Wshadow -Wstrict-aliasing=1 -Wswitch-enum -Wdeclaration-after-statement -Wstrict-prototypes -Wundef -DZSTD_LEGACY_SUPPORT=1 ../lib/decompress/zstd_decompress.c -c -o ../lib/decompress/zstd_decompress.o
aarch64-linux-gcc -static -I../lib -I../lib/common -I../lib/dictBuilder -I../lib/legacy -O3 -Wall -Wextra -Wcast-qual -Wcast-align -Wshadow -Wstrict-aliasing=1 -Wswitch-enum -Wdeclaration-after-statement -Wstrict-prototypes -Wundef -DZSTD_LEGACY_SUPPORT=1 ../lib/decompress/zstd_decompress.o ../lib/decompress/huf_decompress.c ../lib/common/entropy_common.c ../lib/common/fse_decompress.c ../lib/common/xxhash.c ../lib/common/zstd_common.c ../lib/compress/zstd_compress.c ../lib/compress/fse_compress.c ../lib/compress/huf_compress.c ../lib/legacy/zstd_v01.c ../lib/legacy/zstd_v02.c ../lib/legacy/zstd_v03.c ../lib/legacy/zstd_v04.c ../lib/legacy/zstd_v05.c ../lib/legacy/zstd_v06.c ../lib/legacy/zstd_v07.c ../lib/dictBuilder/divsufsort.c ../lib/dictBuilder/zdict.c zstdcli.c fileio.c bench.c datagen.c dibio.c -o zstd
4. aarch64-linux-strip --strip-all zstd
5. rename zstd to zstdcat
File added
...@@ -2,13 +2,22 @@ ...@@ -2,13 +2,22 @@
rm -f vtoyfat_64 rm -f vtoyfat_64
rm -f vtoyfat_32 rm -f vtoyfat_32
rm -f vtoyfat_aa64
gcc -O2 -D_FILE_OFFSET_BITS=64 vtoyfat_linux.c -Ifat_io_lib/include fat_io_lib/lib/libfat_io_64.a -o vtoyfat_64 gcc -O2 -D_FILE_OFFSET_BITS=64 vtoyfat_linux.c -Ifat_io_lib/include fat_io_lib/lib/libfat_io_64.a -o vtoyfat_64
gcc -m32 -O2 -D_FILE_OFFSET_BITS=64 vtoyfat_linux.c -Ifat_io_lib/include fat_io_lib/lib/libfat_io_32.a -o vtoyfat_32 gcc -m32 -O2 -D_FILE_OFFSET_BITS=64 vtoyfat_linux.c -Ifat_io_lib/include fat_io_lib/lib/libfat_io_32.a -o vtoyfat_32
aarch64-buildroot-linux-uclibc-gcc -static -O2 -D_FILE_OFFSET_BITS=64 vtoyfat_linux.c -Ifat_io_lib/include fat_io_lib/lib/libfat_io_aa64.a -o vtoyfat_aa64
if [ -e vtoyfat_64 ] && [ -e vtoyfat_32 ]; then if [ -e vtoyfat_64 ] && [ -e vtoyfat_32 ] && [ -e vtoyfat_aa64 ]; then
echo -e "\n===== success $name =======\n" echo -e "\n===== success $name =======\n"
[ -d ../INSTALL/tool/ ] && mv vtoyfat_32 ../INSTALL/tool/ && mv vtoyfat_64 ../INSTALL/tool/
strip --strip-all vtoyfat_32
strip --strip-all vtoyfat_64
aarch64-buildroot-linux-uclibc-strip --strip-all vtoyfat_aa64
[ -d ../INSTALL/tool/i386/ ] && mv vtoyfat_32 ../INSTALL/tool/i386/vtoyfat
[ -d ../INSTALL/tool/x86_64/ ] && mv vtoyfat_64 ../INSTALL/tool/x86_64/vtoyfat
[ -d ../INSTALL/tool/aarch64/ ] && mv vtoyfat_aa64 ../INSTALL/tool/aarch64/vtoyfat
else else
echo -e "\n===== failed =======\n" echo -e "\n===== failed =======\n"
exit 1 exit 1
......
...@@ -22,8 +22,14 @@ ar -rc libfat_io_32.a *.o ...@@ -22,8 +22,14 @@ ar -rc libfat_io_32.a *.o
rm -f *.o rm -f *.o
aarch64-linux-gnu-gcc -O2 -D_FILE_OFFSET_BITS=64 fat*.c -c
ar -rc libfat_io_aa64.a *.o
rm -f *.o
cd - cd -
mkdir lib mkdir lib
mkdir include mkdir include
......
...@@ -37,6 +37,20 @@ static int vtoy_disk_read(uint32 sector, uint8 *buffer, uint32 sector_count) ...@@ -37,6 +37,20 @@ static int vtoy_disk_read(uint32 sector, uint8 *buffer, uint32 sector_count)
return 1; return 1;
} }
static int check_secure_boot(void)
{
void *flfile = NULL;
flfile = fl_fopen("/EFI/BOOT/grubx64_real.efi", "rb");
if (flfile)
{
fl_fclose(flfile);
return 0;
}
return 1;
}
static int get_ventoy_version(void) static int get_ventoy_version(void)
{ {
int rc = 1; int rc = 1;
...@@ -91,11 +105,14 @@ static int get_ventoy_version(void) ...@@ -91,11 +105,14 @@ static int get_ventoy_version(void)
int main(int argc, char **argv) int main(int argc, char **argv)
{ {
int op = 0;
int rc = 1; int rc = 1;
char *disk;
if (argc != 2) if (argc != 2 && argc != 3)
{ {
printf("Usage: vtoyfat /dev/sdb \n"); printf("Usage: vtoyfat /dev/sdbs \n");
printf("Usage: vtoyfat -s /dev/sdbs \n");
return 1; return 1;
} }
...@@ -104,10 +121,17 @@ int main(int argc, char **argv) ...@@ -104,10 +121,17 @@ int main(int argc, char **argv)
return 0; return 0;
} }
g_disk_fd = open(argv[1], O_RDONLY); disk = argv[1];
if (argv[1][0] == '-' && argv[1][1] == 's')
{
op = 1;
disk = argv[2];
}
g_disk_fd = open(disk, O_RDONLY);
if (g_disk_fd < 0) if (g_disk_fd < 0)
{ {
printf("Failed to open %s\n", argv[1]); printf("Failed to open %s\n", disk);
return 1; return 1;
} }
...@@ -115,7 +139,14 @@ int main(int argc, char **argv) ...@@ -115,7 +139,14 @@ int main(int argc, char **argv)
if (0 == fl_attach_media(vtoy_disk_read, NULL)) if (0 == fl_attach_media(vtoy_disk_read, NULL))
{ {
rc = get_ventoy_version(); if (op == 0)
{
rc = get_ventoy_version();
}
else
{
rc = check_secure_boot();
}
} }
fl_shutdown(); fl_shutdown();
......
#!/bin/bash #!/bin/bash
rm -f vtoytool/00/* rm -f vtoygpt_64
rm -f vtoygpt_32
rm -f vtoygpt_aa64
/opt/diet64/bin/diet -Os gcc -D_FILE_OFFSET_BITS=64 vtoygpt.c crc32.c -o vtoygpt_64 /opt/diet64/bin/diet -Os gcc -D_FILE_OFFSET_BITS=64 vtoygpt.c crc32.c -o vtoygpt_64
/opt/diet32/bin/diet -Os gcc -D_FILE_OFFSET_BITS=64 -m32 vtoygpt.c crc32.c -o vtoygpt_32 /opt/diet32/bin/diet -Os gcc -D_FILE_OFFSET_BITS=64 -m32 vtoygpt.c crc32.c -o vtoygpt_32
aarch64-buildroot-linux-uclibc-gcc -Os -static -D_FILE_OFFSET_BITS=64 vtoygpt.c crc32.c -o vtoygpt_aa64
#gcc -D_FILE_OFFSET_BITS=64 -static -Wall vtoygpt.c -o vtoytool_64 #gcc -D_FILE_OFFSET_BITS=64 -static -Wall vtoygpt.c -o vtoytool_64
#gcc -D_FILE_OFFSET_BITS=64 -Wall -m32 vtoygpt.c -o vtoytool_32 #gcc -D_FILE_OFFSET_BITS=64 -Wall -m32 vtoygpt.c -o vtoytool_32
if [ -e vtoygpt_64 ] && [ -e vtoygpt_32 ]; then if [ -e vtoygpt_64 ] && [ -e vtoygpt_32 ] && [ -e vtoygpt_aa64 ]; then
echo -e '\n############### SUCCESS ###############\n' echo -e '\n############### SUCCESS ###############\n'
mv vtoygpt_64 ../INSTALL/tool/ mv vtoygpt_64 ../INSTALL/tool/x86_64/vtoygpt
mv vtoygpt_32 ../INSTALL/tool/ mv vtoygpt_32 ../INSTALL/tool/i386/vtoygpt
aarch64-buildroot-linux-uclibc-strip --strip-all vtoygpt_aa64
mv vtoygpt_aa64 ../INSTALL/tool/aarch64/vtoygpt
else else
echo -e '\n############### FAILED ################\n' echo -e '\n############### FAILED ################\n'
exit 1 exit 1
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment