Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
dadigang
Ventoy
Commits
d5b829f8
"vscode:/vscode.git/clone" did not exist on "c61a1b6f97c61ebd80bada10c60c8ab75d2745b9"
Commit
d5b829f8
authored
Apr 24, 2020
by
longpanda
Browse files
1.0.07 release
parent
d551fc2e
Changes
52
Show whitespace changes
Inline
Side-by-side
Showing
20 changed files
with
1219 additions
and
63 deletions
+1219
-63
EDK2/edk2-edk2-stable201911/MdeModulePkg/Application/Ventoy/Ventoy.c
...dk2-stable201911/MdeModulePkg/Application/Ventoy/Ventoy.c
+216
-56
EDK2/edk2-edk2-stable201911/MdeModulePkg/Application/Ventoy/Ventoy.h
...dk2-stable201911/MdeModulePkg/Application/Ventoy/Ventoy.h
+60
-0
EDK2/edk2-edk2-stable201911/MdeModulePkg/Application/Ventoy/Ventoy.inf
...2-stable201911/MdeModulePkg/Application/Ventoy/Ventoy.inf
+29
-0
EDK2/edk2-edk2-stable201911/MdeModulePkg/Application/Ventoy/VentoyDebug.c
...table201911/MdeModulePkg/Application/Ventoy/VentoyDebug.c
+325
-0
GRUB2/grub-2.04/grub-core/fs/fat.c
GRUB2/grub-2.04/grub-core/fs/fat.c
+2
-2
GRUB2/grub-2.04/grub-core/ventoy/ventoy.c
GRUB2/grub-2.04/grub-core/ventoy/ventoy.c
+41
-5
GRUB2/grub-2.04/include/grub/ventoy.h
GRUB2/grub-2.04/include/grub/ventoy.h
+13
-0
IMG/cpio/ventoy/hook/alt/udev_disk_hook.sh
IMG/cpio/ventoy/hook/alt/udev_disk_hook.sh
+46
-0
IMG/cpio/ventoy/hook/alt/ventoy-hook.sh
IMG/cpio/ventoy/hook/alt/ventoy-hook.sh
+24
-0
IMG/cpio/ventoy/hook/clear/disk-hook.sh
IMG/cpio/ventoy/hook/clear/disk-hook.sh
+43
-0
IMG/cpio/ventoy/hook/clear/ventoy-hook.sh
IMG/cpio/ventoy/hook/clear/ventoy-hook.sh
+22
-0
IMG/cpio/ventoy/hook/debian/deepin-disk.sh
IMG/cpio/ventoy/hook/debian/deepin-disk.sh
+47
-0
IMG/cpio/ventoy/hook/debian/deepin-hook.sh
IMG/cpio/ventoy/hook/debian/deepin-hook.sh
+47
-0
IMG/cpio/ventoy/hook/debian/knoppix-disk.sh
IMG/cpio/ventoy/hook/debian/knoppix-disk.sh
+43
-0
IMG/cpio/ventoy/hook/debian/knoppix-hook.sh
IMG/cpio/ventoy/hook/debian/knoppix-hook.sh
+23
-0
IMG/cpio/ventoy/hook/debian/porteus-disk.sh
IMG/cpio/ventoy/hook/debian/porteus-disk.sh
+77
-0
IMG/cpio/ventoy/hook/debian/porteus-hook.sh
IMG/cpio/ventoy/hook/debian/porteus-hook.sh
+48
-0
IMG/cpio/ventoy/hook/debian/puppy-disk.sh
IMG/cpio/ventoy/hook/debian/puppy-disk.sh
+48
-0
IMG/cpio/ventoy/hook/debian/puppy-hook.sh
IMG/cpio/ventoy/hook/debian/puppy-hook.sh
+22
-0
IMG/cpio/ventoy/hook/debian/pve-disk.sh
IMG/cpio/ventoy/hook/debian/pve-disk.sh
+43
-0
No files found.
EDK2/edk2-edk2-stable201911/MdeModulePkg/Application/Ventoy/Ventoy.c
View file @
d5b829f8
...
...
@@ -53,15 +53,27 @@ ventoy_sector_flag *g_sector_flag = NULL;
UINT32
g_sector_flag_num
=
0
;
static
grub_env_get_pf
grub_env_get
=
NULL
;
EFI_FILE_OPEN
g_original_fopen
=
NULL
;
EFI_FILE_CLOSE
g_original_fclose
=
NULL
;
EFI_SIMPLE_FILE_SYSTEM_PROTOCOL_OPEN_VOLUME
g_original_open_volume
=
NULL
;
ventoy_grub_param_file_replace
*
g_file_replace_list
=
NULL
;
ventoy_efi_file_replace
g_efi_file_replace
;
CHAR16
gFirstTryBootFile
[
256
]
=
{
0
};
CONST
CHAR16
gIso9660EfiDriverPath
[]
=
ISO9660_EFI_DRIVER_PATH
;
/* Boot filename */
UINTN
gBootFileStartIndex
=
1
;
CONST
CHAR16
*
gEfiBootFileName
[]
=
{
L"@"
,
EFI_REMOVABLE_MEDIA_FILE_NAME
,
L"
\\
EFI
\\
BOOT
\\
GRUBX64.EFI"
,
L"
\\
EFI
\\
BOOT
\\
BOOTx64.EFI"
,
L"
\\
EFI
\\
BOOT
\\
bootx64.efi"
,
L"
\\
efi
\\
boot
\\
bootx64.efi"
,
};
/* EFI block device vendor device path GUID */
...
...
@@ -886,6 +898,7 @@ static int ventoy_update_image_location(ventoy_os_param *param)
STATIC
EFI_STATUS
EFIAPI
ventoy_parse_cmdline
(
IN
EFI_HANDLE
ImageHandle
)
{
UINT32
i
=
0
;
UINT32
old_cnt
=
0
;
UINTN
size
=
0
;
UINT8
chksum
=
0
;
CHAR16
*
pPos
=
NULL
;
...
...
@@ -915,8 +928,33 @@ STATIC EFI_STATUS EFIAPI ventoy_parse_cmdline(IN EFI_HANDLE ImageHandle)
gLoadIsoEfi
=
TRUE
;
}
pPos
=
StrStr
(
pCmdLine
,
L"FirstTry=@"
);
if
(
pPos
)
{
pPos
+=
StrLen
(
L"FirstTry="
);
for
(
i
=
0
;
i
<
ARRAY_SIZE
(
gFirstTryBootFile
);
i
++
,
pPos
++
)
{
if
(
*
pPos
!=
L' '
&&
*
pPos
!=
L'\t'
&&
*
pPos
)
{
gFirstTryBootFile
[
i
]
=
(
*
pPos
==
'@'
)
?
'\\'
:
*
pPos
;
}
else
{
break
;
}
}
gEfiBootFileName
[
0
]
=
gFirstTryBootFile
;
gBootFileStartIndex
=
0
;
}
debug
(
"cmdline:<%s>"
,
pCmdLine
);
if
(
gFirstTryBootFile
[
0
])
{
debug
(
"First Try:<%s>"
,
gFirstTryBootFile
);
}
pPos
=
StrStr
(
pCmdLine
,
L"env_param="
);
if
(
!
pPos
)
{
...
...
@@ -926,6 +964,18 @@ STATIC EFI_STATUS EFIAPI ventoy_parse_cmdline(IN EFI_HANDLE ImageHandle)
pGrubParam
=
(
ventoy_grub_param
*
)
StrHexToUintn
(
pPos
+
StrLen
(
L"env_param="
));
grub_env_get
=
pGrubParam
->
grub_env_get
;
g_file_replace_list
=
&
pGrubParam
->
file_replace
;
old_cnt
=
g_file_replace_list
->
old_file_cnt
;
debug
(
"file replace: magic:0x%x virtid:%u name count:%u <%a> <%a> <%a> <%a>"
,
g_file_replace_list
->
magic
,
g_file_replace_list
->
new_file_virtual_id
,
old_cnt
,
old_cnt
>
0
?
g_file_replace_list
->
old_file_name
[
0
]
:
""
,
old_cnt
>
1
?
g_file_replace_list
->
old_file_name
[
1
]
:
""
,
old_cnt
>
2
?
g_file_replace_list
->
old_file_name
[
2
]
:
""
,
old_cnt
>
3
?
g_file_replace_list
->
old_file_name
[
3
]
:
""
);
pPos
=
StrStr
(
pCmdLine
,
L"mem:"
);
g_chain
=
(
ventoy_chain_head
*
)
StrHexToUintn
(
pPos
+
4
);
...
...
@@ -970,8 +1020,85 @@ STATIC EFI_STATUS EFIAPI ventoy_parse_cmdline(IN EFI_HANDLE ImageHandle)
return
EFI_SUCCESS
;
}
EFI_STATUS
EFIAPI
ventoy_wrapper_file_open
(
EFI_FILE_HANDLE
This
,
EFI_FILE_HANDLE
*
New
,
CHAR16
*
Name
,
UINT64
Mode
,
UINT64
Attributes
)
{
UINT32
i
=
0
;
UINT32
j
=
0
;
UINT64
Sectors
=
0
;
EFI_STATUS
Status
=
EFI_SUCCESS
;
CHAR8
TmpName
[
256
];
ventoy_virt_chunk
*
virt
=
NULL
;
Status
=
g_original_fopen
(
This
,
New
,
Name
,
Mode
,
Attributes
);
if
(
EFI_ERROR
(
Status
))
{
return
Status
;
}
if
(
g_file_replace_list
&&
g_file_replace_list
->
magic
==
GRUB_FILE_REPLACE_MAGIC
&&
g_file_replace_list
->
new_file_virtual_id
<
g_virt_chunk_num
)
{
AsciiSPrint
(
TmpName
,
sizeof
(
TmpName
),
"%s"
,
Name
);
for
(
j
=
0
;
j
<
4
;
j
++
)
{
if
(
0
==
AsciiStrCmp
(
g_file_replace_list
[
i
].
old_file_name
[
j
],
TmpName
))
{
g_original_fclose
(
*
New
);
*
New
=
&
g_efi_file_replace
.
WrapperHandle
;
ventoy_wrapper_file_procotol
(
*
New
);
virt
=
g_virt_chunk
+
g_file_replace_list
->
new_file_virtual_id
;
Sectors
=
(
virt
->
mem_sector_end
-
virt
->
mem_sector_start
)
+
(
virt
->
remap_sector_end
-
virt
->
remap_sector_start
);
g_efi_file_replace
.
BlockIoSectorStart
=
virt
->
mem_sector_start
;
g_efi_file_replace
.
FileSizeBytes
=
Sectors
*
2048
;
if
(
gDebugPrint
)
{
debug
(
"## ventoy_wrapper_file_open <%s> BlockStart:%lu Sectors:%lu Bytes:%lu"
,
Name
,
g_efi_file_replace
.
BlockIoSectorStart
,
Sectors
,
Sectors
*
2048
);
sleep
(
3
);
}
return
Status
;
}
}
}
return
Status
;
}
EFI_STATUS
EFIAPI
ventoy_wrapper_open_volume
(
IN
EFI_SIMPLE_FILE_SYSTEM_PROTOCOL
*
This
,
OUT
EFI_FILE_PROTOCOL
**
Root
)
{
EFI_STATUS
Status
=
EFI_SUCCESS
;
Status
=
g_original_open_volume
(
This
,
Root
);
if
(
!
EFI_ERROR
(
Status
))
{
g_original_fopen
=
(
*
Root
)
->
Open
;
g_original_fclose
=
(
*
Root
)
->
Close
;
(
*
Root
)
->
Open
=
ventoy_wrapper_file_open
;
}
return
Status
;
}
EFI_STATUS
EFIAPI
ventoy_boot
(
IN
EFI_HANDLE
ImageHandle
)
{
UINTN
t
=
0
;
UINTN
i
=
0
;
UINTN
j
=
0
;
UINTN
Find
=
0
;
...
...
@@ -982,6 +1109,11 @@ EFI_STATUS EFIAPI ventoy_boot(IN EFI_HANDLE ImageHandle)
EFI_SIMPLE_FILE_SYSTEM_PROTOCOL
*
pFile
=
NULL
;
EFI_DEVICE_PATH_PROTOCOL
*
pDevPath
=
NULL
;
for
(
t
=
0
;
t
<
3
;
t
++
)
{
Count
=
0
;
Handles
=
NULL
;
Status
=
gBS
->
LocateHandleBuffer
(
ByProtocol
,
&
gEfiSimpleFileSystemProtocolGuid
,
NULL
,
&
Count
,
&
Handles
);
if
(
EFI_ERROR
(
Status
))
...
...
@@ -999,6 +1131,8 @@ EFI_STATUS EFIAPI ventoy_boot(IN EFI_HANDLE ImageHandle)
continue
;
}
debug
(
"FS:%u Protocol:%p OpenVolume:%p"
,
i
,
pFile
,
pFile
->
OpenVolume
);
Status
=
gBS
->
OpenProtocol
(
Handles
[
i
],
&
gEfiDevicePathProtocolGuid
,
(
VOID
**
)
&
pDevPath
,
ImageHandle
,
...
...
@@ -1017,7 +1151,7 @@ EFI_STATUS EFIAPI ventoy_boot(IN EFI_HANDLE ImageHandle)
continue
;
}
for
(
j
=
0
;
j
<
ARRAY_SIZE
(
gEfiBootFileName
);
j
++
)
for
(
j
=
gBootFileStartIndex
;
j
<
ARRAY_SIZE
(
gEfiBootFileName
);
j
++
)
{
Status
=
ventoy_load_image
(
ImageHandle
,
pDevPath
,
gEfiBootFileName
[
j
],
StrSize
(
gEfiBootFileName
[
j
]),
&
Image
);
...
...
@@ -1040,6 +1174,13 @@ EFI_STATUS EFIAPI ventoy_boot(IN EFI_HANDLE ImageHandle)
if
(
gDebugPrint
)
{
gST
->
ConIn
->
Reset
(
gST
->
ConIn
,
FALSE
);
//ventoy_wrapper_system();
}
if
(
g_file_replace_list
&&
g_file_replace_list
->
magic
==
GRUB_FILE_REPLACE_MAGIC
)
{
g_original_open_volume
=
pFile
->
OpenVolume
;
pFile
->
OpenVolume
=
ventoy_wrapper_open_volume
;
}
Status
=
gBS
->
StartImage
(
Image
,
NULL
,
NULL
);
...
...
@@ -1054,6 +1195,13 @@ EFI_STATUS EFIAPI ventoy_boot(IN EFI_HANDLE ImageHandle)
FreePool
(
Handles
);
if
(
Find
==
0
)
{
debug
(
"Fs not found, now wait and retry..."
);
sleep
(
2
);
}
}
if
(
Find
==
0
)
{
return
EFI_NOT_FOUND
;
...
...
@@ -1188,11 +1336,23 @@ EFI_STATUS EFIAPI VentoyEfiMain
ventoy_debug_pause
();
Status
=
ventoy_boot
(
ImageHandle
);
if
(
EFI_NOT_FOUND
==
Status
)
{
if
(
!
gLoadIsoEfi
)
{
gLoadIsoEfi
=
TRUE
;
ventoy_find_iso_disk_fs
(
ImageHandle
);
ventoy_load_isoefi_driver
(
ImageHandle
);
Status
=
ventoy_boot
(
ImageHandle
);
}
if
(
EFI_NOT_FOUND
==
Status
)
{
gST
->
ConOut
->
OutputString
(
gST
->
ConOut
,
L"No bootfile found for UEFI!
\r\n
"
);
gST
->
ConOut
->
OutputString
(
gST
->
ConOut
,
L"Maybe the image does not support "
VENTOY_UEFI_DESC
L"!
\r\n
"
);
sleep
(
300
);
sleep
(
60
);
}
}
ventoy_clean_env
();
...
...
EDK2/edk2-edk2-stable201911/MdeModulePkg/Application/Ventoy/Ventoy.h
View file @
d5b829f8
...
...
@@ -205,6 +205,7 @@ typedef struct vtoy_block_data
#define ISO9660_EFI_DRIVER_PATH L"\\ventoy\\iso9660_x64.efi"
#define debug(expr, ...) if (gDebugPrint) VtoyDebug("[VTOY] "expr"\r\n", ##__VA_ARGS__)
#define trace(expr, ...) VtoyDebug("[VTOY] "expr"\r\n", ##__VA_ARGS__)
#define sleep(sec) gBS->Stall(1000000 * (sec))
#define ventoy_debug_pause() \
...
...
@@ -219,9 +220,32 @@ if (gDebugPrint) \
typedef
const
char
*
(
*
grub_env_get_pf
)(
const
char
*
name
);
#pragma pack(1)
#define GRUB_FILE_REPLACE_MAGIC 0x1258BEEF
typedef
struct
ventoy_efi_file_replace
{
UINT64
BlockIoSectorStart
;
UINT64
CurPos
;
UINT64
FileSizeBytes
;
EFI_FILE_PROTOCOL
WrapperHandle
;
}
ventoy_efi_file_replace
;
typedef
struct
ventoy_grub_param_file_replace
{
UINT32
magic
;
char
old_file_name
[
4
][
256
];
UINT32
old_file_cnt
;
UINT32
new_file_virtual_id
;
}
ventoy_grub_param_file_replace
;
typedef
struct
ventoy_grub_param
{
grub_env_get_pf
grub_env_get
;
ventoy_grub_param_file_replace
file_replace
;
}
ventoy_grub_param
;
typedef
struct
ventoy_ram_disk
...
...
@@ -233,8 +257,44 @@ typedef struct ventoy_ram_disk
#pragma pack()
typedef
struct
well_known_guid
{
EFI_GUID
*
guid
;
const
char
*
name
;
}
well_known_guid
;
typedef
struct
ventoy_system_wrapper
{
EFI_LOCATE_PROTOCOL
NewLocateProtocol
;
EFI_LOCATE_PROTOCOL
OriLocateProtocol
;
EFI_HANDLE_PROTOCOL
NewHandleProtocol
;
EFI_HANDLE_PROTOCOL
OriHandleProtocol
;
EFI_OPEN_PROTOCOL
NewOpenProtocol
;
EFI_OPEN_PROTOCOL
OriOpenProtocol
;
}
ventoy_system_wrapper
;
#define ventoy_wrapper(bs, wrapper, func, newfunc) \
{\
wrapper.Ori##func = bs->func;\
wrapper.New##func = newfunc;\
bs->func = wrapper.New##func;\
}
extern
ventoy_efi_file_replace
g_efi_file_replace
;
extern
BOOLEAN
gDebugPrint
;
VOID
EFIAPI
VtoyDebug
(
IN
CONST
CHAR8
*
Format
,
...);
EFI_STATUS
EFIAPI
ventoy_wrapper_system
(
VOID
);
EFI_STATUS
EFIAPI
ventoy_wrapper_file_procotol
(
EFI_FILE_PROTOCOL
*
File
);
EFI_STATUS
EFIAPI
ventoy_block_io_read
(
IN
EFI_BLOCK_IO_PROTOCOL
*
This
,
IN
UINT32
MediaId
,
IN
EFI_LBA
Lba
,
IN
UINTN
BufferSize
,
OUT
VOID
*
Buffer
);
#endif
EDK2/edk2-edk2-stable201911/MdeModulePkg/Application/Ventoy/Ventoy.inf
View file @
d5b829f8
...
...
@@ -28,6 +28,7 @@
[Sources]
Ventoy.h
Ventoy.c
VentoyDebug.c
[Packages]
MdePkg/MdePkg.dec
...
...
@@ -42,6 +43,7 @@
[Guids]
gShellVariableGuid
gEfiVirtualCdGuid
gEfiFileInfoGuid
[Protocols]
gEfiLoadedImageProtocolGuid
...
...
@@ -49,3 +51,30 @@
gEfiDevicePathProtocolGuid
gEfiSimpleFileSystemProtocolGuid
gEfiRamDiskProtocolGuid
gEfiAbsolutePointerProtocolGuid
gEfiAcpiTableProtocolGuid
gEfiBlockIo2ProtocolGuid
gEfiBusSpecificDriverOverrideProtocolGuid
gEfiComponentNameProtocolGuid
gEfiComponentName2ProtocolGuid
gEfiDriverBindingProtocolGuid
gEfiDiskIoProtocolGuid
gEfiDiskIo2ProtocolGuid
gEfiGraphicsOutputProtocolGuid
gEfiHiiConfigAccessProtocolGuid
gEfiHiiFontProtocolGuid
gEfiLoadFileProtocolGuid
gEfiLoadFile2ProtocolGuid
gEfiLoadedImageProtocolGuid
gEfiLoadedImageDevicePathProtocolGuid
gEfiPciIoProtocolGuid
gEfiSerialIoProtocolGuid
gEfiSimpleTextInProtocolGuid
gEfiSimpleTextInputExProtocolGuid
gEfiSimpleTextOutProtocolGuid
EDK2/edk2-edk2-stable201911/MdeModulePkg/Application/Ventoy/VentoyDebug.c
0 → 100644
View file @
d5b829f8
/******************************************************************************
* Ventoy.c
*
* 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/>.
*
*/
#include <Uefi.h>
#include <Library/DebugLib.h>
#include <Library/PrintLib.h>
#include <Library/UefiLib.h>
#include <Library/BaseMemoryLib.h>
#include <Library/DevicePathLib.h>
#include <Library/MemoryAllocationLib.h>
#include <Library/UefiBootServicesTableLib.h>
#include <Library/UefiRuntimeServicesTableLib.h>
#include <Library/UefiApplicationEntryPoint.h>
#include <Protocol/LoadedImage.h>
#include <Guid/FileInfo.h>
#include <Guid/FileSystemInfo.h>
#include <Protocol/BlockIo.h>
#include <Protocol/RamDisk.h>
#include <Protocol/SimpleFileSystem.h>
#include <Ventoy.h>
STATIC
ventoy_system_wrapper
g_system_wrapper
;
static
struct
well_known_guid
g_efi_well_known_guids
[]
=
{
{
&
gEfiAbsolutePointerProtocolGuid
,
"AbsolutePointer"
},
{
&
gEfiAcpiTableProtocolGuid
,
"AcpiTable"
},
{
&
gEfiBlockIoProtocolGuid
,
"BlockIo"
},
{
&
gEfiBlockIo2ProtocolGuid
,
"BlockIo2"
},
{
&
gEfiBusSpecificDriverOverrideProtocolGuid
,
"BusSpecificDriverOverride"
},
{
&
gEfiComponentNameProtocolGuid
,
"ComponentName"
},
{
&
gEfiComponentName2ProtocolGuid
,
"ComponentName2"
},
{
&
gEfiDevicePathProtocolGuid
,
"DevicePath"
},
{
&
gEfiDriverBindingProtocolGuid
,
"DriverBinding"
},
{
&
gEfiDiskIoProtocolGuid
,
"DiskIo"
},
{
&
gEfiDiskIo2ProtocolGuid
,
"DiskIo2"
},
{
&
gEfiGraphicsOutputProtocolGuid
,
"GraphicsOutput"
},
{
&
gEfiHiiConfigAccessProtocolGuid
,
"HiiConfigAccess"
},
{
&
gEfiHiiFontProtocolGuid
,
"HiiFont"
},
{
&
gEfiLoadFileProtocolGuid
,
"LoadFile"
},
{
&
gEfiLoadFile2ProtocolGuid
,
"LoadFile2"
},
{
&
gEfiLoadedImageProtocolGuid
,
"LoadedImage"
},
{
&
gEfiLoadedImageDevicePathProtocolGuid
,
"LoadedImageDevicePath"
},
{
&
gEfiPciIoProtocolGuid
,
"PciIo"
},
{
&
gEfiSerialIoProtocolGuid
,
"SerialIo"
},
{
&
gEfiSimpleFileSystemProtocolGuid
,
"SimpleFileSystem"
},
{
&
gEfiSimpleTextInProtocolGuid
,
"SimpleTextInput"
},
{
&
gEfiSimpleTextInputExProtocolGuid
,
"SimpleTextInputEx"
},
{
&
gEfiSimpleTextOutProtocolGuid
,
"SimpleTextOutput"
},
};
STATIC
CHAR8
gEfiGuidName
[
128
];
static
const
char
*
ventoy_get_guid_name
(
EFI_GUID
*
guid
)
{
UINTN
i
;
for
(
i
=
0
;
i
<
ARRAY_SIZE
(
g_efi_well_known_guids
);
i
++
)
{
if
(
CompareGuid
(
g_efi_well_known_guids
[
i
].
guid
,
guid
))
{
return
g_efi_well_known_guids
[
i
].
name
;
}
}
AsciiSPrint
(
gEfiGuidName
,
sizeof
(
gEfiGuidName
),
"%g"
,
guid
);
return
gEfiGuidName
;
}
EFI_STATUS
EFIAPI
ventoy_wrapper_fs_open
(
EFI_FILE_HANDLE
This
,
EFI_FILE_HANDLE
*
New
,
CHAR16
*
Name
,
UINT64
Mode
,
UINT64
Attributes
)
{
(
VOID
)
This
;
(
VOID
)
New
;
(
VOID
)
Name
;
(
VOID
)
Mode
;
(
VOID
)
Attributes
;
return
EFI_SUCCESS
;
}
EFI_STATUS
EFIAPI
ventoy_wrapper_file_open_ex
(
EFI_FILE_HANDLE
This
,
EFI_FILE_HANDLE
*
New
,
CHAR16
*
Name
,
UINT64
Mode
,
UINT64
Attributes
,
EFI_FILE_IO_TOKEN
*
Token
)
{
return
ventoy_wrapper_fs_open
(
This
,
New
,
Name
,
Mode
,
Attributes
);
}
EFI_STATUS
EFIAPI
ventoy_wrapper_file_delete
(
EFI_FILE_HANDLE
This
)
{
(
VOID
)
This
;
return
EFI_SUCCESS
;
}
EFI_STATUS
EFIAPI
ventoy_wrapper_file_set_info
(
EFI_FILE_HANDLE
This
,
EFI_GUID
*
Type
,
UINTN
Len
,
VOID
*
Data
)
{
return
EFI_SUCCESS
;
}
EFI_STATUS
EFIAPI
ventoy_wrapper_file_flush
(
EFI_FILE_HANDLE
This
)
{
(
VOID
)
This
;
return
EFI_SUCCESS
;
}
/* Ex version */
EFI_STATUS
EFIAPI
ventoy_wrapper_file_flush_ex
(
EFI_FILE_HANDLE
This
,
EFI_FILE_IO_TOKEN
*
Token
)
{
(
VOID
)
This
;
(
VOID
)
Token
;
return
EFI_SUCCESS
;
}
EFI_STATUS
EFIAPI
ventoy_wrapper_file_write
(
EFI_FILE_HANDLE
This
,
UINTN
*
Len
,
VOID
*
Data
)
{
(
VOID
)
This
;
(
VOID
)
Len
;
(
VOID
)
Data
;
return
EFI_WRITE_PROTECTED
;
}
EFI_STATUS
EFIAPI
ventoy_wrapper_file_write_ex
(
IN
EFI_FILE_PROTOCOL
*
This
,
IN
OUT
EFI_FILE_IO_TOKEN
*
Token
)
{
return
ventoy_wrapper_file_write
(
This
,
&
(
Token
->
BufferSize
),
Token
->
Buffer
);
}
static
EFI_STATUS
EFIAPI
ventoy_wrapper_file_close
(
EFI_FILE_HANDLE
This
)
{
(
VOID
)
This
;
return
EFI_SUCCESS
;
}
static
EFI_STATUS
EFIAPI
ventoy_wrapper_file_set_pos
(
EFI_FILE_HANDLE
This
,
UINT64
Position
)
{
(
VOID
)
This
;
g_efi_file_replace
.
CurPos
=
Position
;
return
EFI_SUCCESS
;
}
static
EFI_STATUS
EFIAPI
ventoy_wrapper_file_get_pos
(
EFI_FILE_HANDLE
This
,
UINT64
*
Position
)
{
(
VOID
)
This
;
*
Position
=
g_efi_file_replace
.
CurPos
;
return
EFI_SUCCESS
;
}
static
EFI_STATUS
EFIAPI
ventoy_wrapper_file_get_info
(
EFI_FILE_HANDLE
This
,
EFI_GUID
*
Type
,
UINTN
*
Len
,
VOID
*
Data
)
{
EFI_FILE_INFO
*
Info
=
(
EFI_FILE_INFO
*
)
Data
;
debug
(
"ventoy_wrapper_file_get_info ... %u"
,
*
Len
);
if
(
!
CompareGuid
(
Type
,
&
gEfiFileInfoGuid
))
{
return
EFI_INVALID_PARAMETER
;
}
if
(
*
Len
==
0
)
{
*
Len
=
384
;
return
EFI_BUFFER_TOO_SMALL
;
}
ZeroMem
(
Data
,
sizeof
(
EFI_FILE_INFO
));
Info
->
Size
=
sizeof
(
EFI_FILE_INFO
);
Info
->
FileSize
=
g_efi_file_replace
.
FileSizeBytes
;
Info
->
PhysicalSize
=
g_efi_file_replace
.
FileSizeBytes
;
Info
->
Attribute
=
EFI_FILE_READ_ONLY
;
//Info->FileName = EFI_FILE_READ_ONLY;
*
Len
=
Info
->
Size
;
return
EFI_SUCCESS
;
}
static
EFI_STATUS
EFIAPI
ventoy_wrapper_file_read
(
EFI_FILE_HANDLE
This
,
UINTN
*
Len
,
VOID
*
Data
)
{
EFI_LBA
Lba
;
UINTN
ReadLen
=
*
Len
;
(
VOID
)
This
;
debug
(
"ventoy_wrapper_file_read ... %u"
,
*
Len
);
if
(
g_efi_file_replace
.
CurPos
+
ReadLen
>
g_efi_file_replace
.
FileSizeBytes
)
{
ReadLen
=
g_efi_file_replace
.
FileSizeBytes
-
g_efi_file_replace
.
CurPos
;
}
Lba
=
g_efi_file_replace
.
CurPos
/
2048
+
g_efi_file_replace
.
BlockIoSectorStart
;
ventoy_block_io_read
(
NULL
,
0
,
Lba
,
ReadLen
,
Data
);
*
Len
=
ReadLen
;
g_efi_file_replace
.
CurPos
+=
ReadLen
;
return
EFI_SUCCESS
;
}
EFI_STATUS
EFIAPI
ventoy_wrapper_file_read_ex
(
IN
EFI_FILE_PROTOCOL
*
This
,
IN
OUT
EFI_FILE_IO_TOKEN
*
Token
)
{
return
ventoy_wrapper_file_read
(
This
,
&
(
Token
->
BufferSize
),
Token
->
Buffer
);
}
EFI_STATUS
EFIAPI
ventoy_wrapper_file_procotol
(
EFI_FILE_PROTOCOL
*
File
)
{
File
->
Revision
=
EFI_FILE_PROTOCOL_REVISION2
;
File
->
Open
=
ventoy_wrapper_fs_open
;
File
->
Close
=
ventoy_wrapper_file_close
;
File
->
Delete
=
ventoy_wrapper_file_delete
;
File
->
Read
=
ventoy_wrapper_file_read
;
File
->
Write
=
ventoy_wrapper_file_write
;
File
->
GetPosition
=
ventoy_wrapper_file_get_pos
;
File
->
SetPosition
=
ventoy_wrapper_file_set_pos
;
File
->
GetInfo
=
ventoy_wrapper_file_get_info
;
File
->
SetInfo
=
ventoy_wrapper_file_set_info
;
File
->
Flush
=
ventoy_wrapper_file_flush
;
File
->
OpenEx
=
ventoy_wrapper_file_open_ex
;
File
->
ReadEx
=
ventoy_wrapper_file_read_ex
;
File
->
WriteEx
=
ventoy_wrapper_file_write_ex
;
File
->
FlushEx
=
ventoy_wrapper_file_flush_ex
;
return
EFI_SUCCESS
;
}
STATIC
EFI_STATUS
EFIAPI
ventoy_handle_protocol
(
IN
EFI_HANDLE
Handle
,
IN
EFI_GUID
*
Protocol
,
OUT
VOID
**
Interface
)
{
EFI_STATUS
Status
=
EFI_SUCCESS
;
debug
(
"ventoy_handle_protocol:%a"
,
ventoy_get_guid_name
(
Protocol
));
Status
=
g_system_wrapper
.
OriHandleProtocol
(
Handle
,
Protocol
,
Interface
);
if
(
CompareGuid
(
Protocol
,
&
gEfiSimpleFileSystemProtocolGuid
))
{
EFI_FILE_PROTOCOL
*
FileProtocol
=
NULL
;
EFI_SIMPLE_FILE_SYSTEM_PROTOCOL
*
pFile
=
*
((
EFI_SIMPLE_FILE_SYSTEM_PROTOCOL
**
)(
Interface
));
pFile
->
OpenVolume
(
pFile
,
&
FileProtocol
);
debug
(
"Handle FS Protocol: %p OpenVolume:%p, FileProtocol:%p, Open:%p"
,
pFile
,
pFile
->
OpenVolume
,
FileProtocol
,
FileProtocol
->
Open
);
sleep
(
3
);
}
return
Status
;
}
STATIC
EFI_STATUS
EFIAPI
ventoy_open_protocol
(
IN
EFI_HANDLE
Handle
,
IN
EFI_GUID
*
Protocol
,
OUT
VOID
**
Interface
,
OPTIONAL
IN
EFI_HANDLE
AgentHandle
,
IN
EFI_HANDLE
ControllerHandle
,
IN
UINT32
Attributes
)
{
debug
(
"ventoy_open_protocol:%a"
,
ventoy_get_guid_name
(
Protocol
));
return
g_system_wrapper
.
OriOpenProtocol
(
Handle
,
Protocol
,
Interface
,
AgentHandle
,
ControllerHandle
,
Attributes
);
}
STATIC
EFI_STATUS
EFIAPI
ventoy_locate_protocol
(
IN
EFI_GUID
*
Protocol
,
IN
VOID
*
Registration
,
OPTIONAL
OUT
VOID
**
Interface
)
{
debug
(
"ventoy_locate_protocol:%a"
,
ventoy_get_guid_name
(
Protocol
));
return
g_system_wrapper
.
OriLocateProtocol
(
Protocol
,
Registration
,
Interface
);
}
EFI_STATUS
EFIAPI
ventoy_wrapper_system
(
VOID
)
{
ventoy_wrapper
(
gBS
,
g_system_wrapper
,
LocateProtocol
,
ventoy_locate_protocol
);
ventoy_wrapper
(
gBS
,
g_system_wrapper
,
HandleProtocol
,
ventoy_handle_protocol
);
ventoy_wrapper
(
gBS
,
g_system_wrapper
,
OpenProtocol
,
ventoy_open_protocol
);
return
EFI_SUCCESS
;
}
GRUB2/grub-2.04/grub-core/fs/fat.c
View file @
d5b829f8
...
...
@@ -558,7 +558,7 @@ grub_fat_read_data (grub_disk_t disk, grub_fshelp_node_t node,
if
(
next_cluster
>=
node
->
data
->
cluster_eof_mark
)
return
ret
;
if
(
next_cluster
<
2
||
next_cluster
>=
node
->
data
->
num_clusters
)
if
(
next_cluster
<
2
||
(
next_cluster
-
2
)
>=
node
->
data
->
num_clusters
)
{
grub_error
(
GRUB_ERR_BAD_FS
,
"invalid cluster %u"
,
next_cluster
);
...
...
@@ -1409,7 +1409,7 @@ int grub_fat_get_file_chunk(grub_uint64_t part_start, grub_file_t file, ventoy_i
return
0
;
}
if
(
next_cluster
<
2
||
next_cluster
>=
node
->
data
->
num_clusters
)
if
(
next_cluster
<
2
||
(
next_cluster
-
2
)
>=
node
->
data
->
num_clusters
)
{
grub_error
(
GRUB_ERR_BAD_FS
,
"invalid cluster %u"
,
next_cluster
);
return
-
1
;
...
...
GRUB2/grub-2.04/grub-core/ventoy/ventoy.c
View file @
d5b829f8
...
...
@@ -65,7 +65,7 @@ grub_uint32_t g_ventoy_cpio_size = 0;
cpio_newc_header
*
g_ventoy_initrd_head
=
NULL
;
grub_uint8_t
*
g_ventoy_runtime_buf
=
NULL
;
ventoy_grub_param
g_grub_param
;
ventoy_grub_param
*
g_grub_param
=
NULL
;
ventoy_guid
g_ventoy_guid
=
VENTOY_GUID
;
...
...
@@ -1085,6 +1085,8 @@ static grub_err_t ventoy_cmd_img_sector(grub_extcmd_context_t ctxt, int argc, ch
grub_file_close
(
file
);
grub_memset
(
&
g_grub_param
->
file_replace
,
0
,
sizeof
(
g_grub_param
->
file_replace
));
VENTOY_CMD_RETURN
(
GRUB_ERR_NONE
);
}
...
...
@@ -1109,6 +1111,33 @@ static grub_err_t ventoy_cmd_dump_img_sector(grub_extcmd_context_t ctxt, int arg
VENTOY_CMD_RETURN
(
GRUB_ERR_NONE
);
}
static
grub_err_t
ventoy_cmd_add_replace_file
(
grub_extcmd_context_t
ctxt
,
int
argc
,
char
**
args
)
{
int
i
;
ventoy_grub_param_file_replace
*
replace
=
NULL
;
(
void
)
ctxt
;
(
void
)
argc
;
(
void
)
args
;
if
(
argc
>=
2
)
{
replace
=
&
(
g_grub_param
->
file_replace
);
replace
->
magic
=
GRUB_FILE_REPLACE_MAGIC
;
replace
->
old_name_cnt
=
0
;
for
(
i
=
0
;
i
<
4
&&
i
+
1
<
argc
;
i
++
)
{
replace
->
old_name_cnt
++
;
grub_snprintf
(
replace
->
old_file_name
[
i
],
sizeof
(
replace
->
old_file_name
[
i
]),
"%s"
,
args
[
i
+
1
]);
}
replace
->
new_file_virtual_id
=
(
grub_uint32_t
)
grub_strtoul
(
args
[
0
],
NULL
,
10
);
}
VENTOY_CMD_RETURN
(
GRUB_ERR_NONE
);
}
grub_file_t
ventoy_grub_file_open
(
enum
grub_file_type
type
,
const
char
*
fmt
,
...)
{
va_list
ap
;
...
...
@@ -1163,9 +1192,13 @@ static int ventoy_env_init(void)
ventoy_filt_register
(
0
,
ventoy_wrapper_open
);
g_grub_param
.
grub_env_get
=
grub_env_get
;
grub_snprintf
(
buf
,
sizeof
(
buf
),
"%p"
,
&
g_grub_param
);
g_grub_param
=
(
ventoy_grub_param
*
)
grub_zalloc
(
sizeof
(
ventoy_grub_param
));
if
(
g_grub_param
)
{
g_grub_param
->
grub_env_get
=
grub_env_get
;
grub_snprintf
(
buf
,
sizeof
(
buf
),
"%p"
,
g_grub_param
);
grub_env_set
(
"env_param"
,
buf
);
}
return
0
;
}
...
...
@@ -1205,6 +1238,9 @@ static cmd_para ventoy_cmds[] =
{
"vt_windows_locate_wim"
,
ventoy_cmd_wimdows_locate_wim
,
0
,
NULL
,
""
,
""
,
NULL
},
{
"vt_windows_chain_data"
,
ventoy_cmd_windows_chain_data
,
0
,
NULL
,
""
,
""
,
NULL
},
{
"vt_add_replace_file"
,
ventoy_cmd_add_replace_file
,
0
,
NULL
,
""
,
""
,
NULL
},
{
"vt_load_plugin"
,
ventoy_cmd_load_plugin
,
0
,
NULL
,
""
,
""
,
NULL
},
};
...
...
GRUB2/grub-2.04/include/grub/ventoy.h
View file @
d5b829f8
...
...
@@ -183,9 +183,22 @@ typedef struct ventoy_img_chunk_list
typedef
const
char
*
(
*
grub_env_get_pf
)(
const
char
*
name
);
#pragma pack(1)
#define GRUB_FILE_REPLACE_MAGIC 0x1258BEEF
typedef
struct
ventoy_grub_param_file_replace
{
grub_uint32_t
magic
;
char
old_file_name
[
4
][
256
];
grub_uint32_t
old_name_cnt
;
grub_uint32_t
new_file_virtual_id
;
}
ventoy_grub_param_file_replace
;
typedef
struct
ventoy_grub_param
{
grub_env_get_pf
grub_env_get
;
ventoy_grub_param_file_replace
file_replace
;
}
ventoy_grub_param
;
#pragma pack()
...
...
IMG/cpio/ventoy/hook/alt/udev_disk_hook.sh
0 → 100644
View file @
d5b829f8
#!/ventoy/busybox/sh
#************************************************************************************
# Copyright (c) 2020, longpanda <admin@ventoy.net>
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation; either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, see <http://www.gnu.org/licenses/>.
#
#************************************************************************************
.
/ventoy/hook/ventoy-hook-lib.sh
if
is_ventoy_hook_finished
||
not_ventoy_disk
"
${
1
:0:-1
}
"
;
then
exit
0
fi
ventoy_udev_disk_common_hook
$*
"noreplace"
if
!
[
-e
$VTOY_DM_PATH
]
;
then
blkdev_num
=
$(
$VTOY_PATH
/tool/dmsetup
ls
|
grep
ventoy |
sed
's/.*(\([0-9][0-9]*\),.*\([0-9][0-9]*\).*/\1 \2/'
)
mknod
-m
0666
$VTOY_DM_PATH
b
$blkdev_num
fi
#
# We do a trick for ATL series here.
# Use /dev/loop7 and wapper it as a cdrom with bind mount.
# Then the installer will accept /dev/loop7 as the install medium.
#
ventoy_copy_device_mapper /dev/loop7
$BUSYBOX_PATH
/mkdir
-p
/tmp/loop7/device/
echo
5
>
/tmp/loop7/device/type
$BUSYBOX_PATH
/mount
--bind
/tmp/loop7 /sys/block/loop7
>>
$VTLOG
2>&1
# OK finish
set_ventoy_hook_finish
IMG/cpio/ventoy/hook/alt/ventoy-hook.sh
0 → 100644
View file @
d5b829f8
#!/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
ventoy_systemd_udevd_work_around
ventoy_add_udev_rule
"
$VTOY_PATH
/hook/alt/udev_disk_hook.sh %k"
IMG/cpio/ventoy/hook/clear/disk-hook.sh
0 → 100644
View file @
d5b829f8
#!/ventoy/busybox/sh
#************************************************************************************
# Copyright (c) 2020, longpanda <admin@ventoy.net>
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation; either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, see <http://www.gnu.org/licenses/>.
#
#************************************************************************************
.
/ventoy/hook/ventoy-hook-lib.sh
if
is_ventoy_hook_finished
;
then
exit
0
fi
vtlog
"#######
$0
$*
########"
VTPATH_OLD
=
$PATH
;
PATH
=
$BUSYBOX_PATH
:
$VTOY_PATH
/tool:
$PATH
wait_for_usb_disk_ready
vtdiskname
=
$(
get_ventoy_disk_name
)
if
[
"
$vtdiskname
"
=
"unknown"
]
;
then
vtlog
"ventoy disk not found"
PATH
=
$VTPATH_OLD
exit
0
fi
ventoy_udev_disk_common_hook
"
${
vtdiskname
#/dev/
}
2"
"noreplace"
PATH
=
$VTPATH_OLD
set_ventoy_hook_finish
IMG/cpio/ventoy/hook/clear/ventoy-hook.sh
0 → 100644
View file @
d5b829f8
#!/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
"/find_and_mount_installer *
$/
i
\
$BUSYBOX_PATH
/sh
$VTOY_PATH
/hook/clear/disk-hook.sh"
-i
/init
IMG/cpio/ventoy/hook/debian/deepin-disk.sh
0 → 100644
View file @
d5b829f8
#!/ventoy/busybox/sh
#************************************************************************************
# Copyright (c) 2020, longpanda <admin@ventoy.net>
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation; either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, see <http://www.gnu.org/licenses/>.
#
#************************************************************************************
.
/ventoy/hook/ventoy-hook-lib.sh
vtlog
"#######
$0
$*
########"
VTPATH_OLD
=
$PATH
;
PATH
=
$BUSYBOX_PATH
:
$VTOY_PATH
/tool:
$PATH
vtmountpoint
=
$1
if
is_ventoy_hook_finished
;
then
PATH
=
$VTPATH_OLD
exit
0
fi
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"
$BUSYBOX_PATH
/mount
-t
iso9660
$VTOY_DM_PATH
$vtmountpoint
# OK finish
set_ventoy_hook_finish
IMG/cpio/ventoy/hook/debian/deepin-hook.sh
0 → 100644
View file @
d5b829f8
#!/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/>.
#
#************************************************************************************
drop_initramfs_workaround
()
{
mainfilelist
=
$(
$FIND
/
-name
9990-main.sh
)
echo
"mainfilelist=
$mainfilelist
"
>>
$VTLOG
if
[
-z
"
$mainfilelist
"
]
;
then
return
fi
for
vtfile
in
$mainfilelist
;
do
vtcnt
=
$(
$GREP
-c
'panic.*Unable to find a medium'
$vtfile
)
if
[
$vtcnt
-ne
1
]
;
then
return
fi
done
echo
"direct_hook insert ..."
>>
$VTLOG
for
vtfile
in
$mainfilelist
;
do
$SED
"s#panic.*Unable to find a medium.*#
$BUSYBOX_PATH
/sh
$VTOY_PATH
/hook/debian/deepin-disk.sh
\$
mountpoint; livefs_root=
\$
mountpoint#"
-i
$vtfile
done
}
ventoy_systemd_udevd_work_around
ventoy_add_udev_rule
"
$VTOY_PATH
/hook/debian/udev_disk_hook.sh %k"
drop_initramfs_workaround
IMG/cpio/ventoy/hook/debian/knoppix-disk.sh
0 → 100644
View file @
d5b829f8
#!/ventoy/busybox/sh
#************************************************************************************
# Copyright (c) 2020, longpanda <admin@ventoy.net>
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation; either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, see <http://www.gnu.org/licenses/>.
#
#************************************************************************************
.
/ventoy/hook/ventoy-hook-lib.sh
vtlog
"#######
$0
$*
########"
VTPATH_OLD
=
$PATH
;
PATH
=
$BUSYBOX_PATH
:
$VTOY_PATH
/tool:
$PATH
wait_for_usb_disk_ready
vtdiskname
=
$(
get_ventoy_disk_name
)
if
[
"
$vtdiskname
"
=
"unknown"
]
;
then
vtlog
"ventoy disk not found"
PATH
=
$VTPATH_OLD
exit
0
fi
ventoy_udev_disk_common_hook
"
${
vtdiskname
#/dev/
}
2"
"noreplace"
if
!
[
-e
$VTOY_DM_PATH
]
;
then
blkdev_num
=
$(
$VTOY_PATH
/tool/dmsetup
ls
|
grep
ventoy |
sed
's/.*(\([0-9][0-9]*\),.*\([0-9][0-9]*\).*/\1 \2/'
)
mknod
-m
0666
$VTOY_DM_PATH
b
$blkdev_num
fi
PATH
=
$VTPATH_OLD
IMG/cpio/ventoy/hook/debian/knoppix-hook.sh
0 → 100644
View file @
d5b829f8
#!/ventoy/busybox/sh
#************************************************************************************
# Copyright (c) 2020, longpanda <admin@ventoy.net>
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation; either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, see <http://www.gnu.org/licenses/>.
#
#************************************************************************************
$SED
'/^findknoppix/a\ return 0'
-i
/init
$SED
'/^findknoppix/a\ trymount $ROOTDEV /mnt-system >/dev/null 2>&1'
-i
/init
$SED
'/^findknoppix/a\ ROOTDEV=/dev/mapper/ventoy'
-i
/init
$SED
"/^findknoppix/a
\
$BUSYBOX_PATH
/sh
$VTOY_PATH
/hook/debian/knoppix-disk.sh"
-i
/init
IMG/cpio/ventoy/hook/debian/porteus-disk.sh
0 → 100644
View file @
d5b829f8
#!/ventoy/busybox/sh
#************************************************************************************
# Copyright (c) 2020, longpanda <admin@ventoy.net>
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation; either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, see <http://www.gnu.org/licenses/>.
#
#************************************************************************************
.
/ventoy/hook/ventoy-hook-lib.sh
vtlog
"#######
$0
$*
########"
VTPATH_OLD
=
$PATH
;
PATH
=
$BUSYBOX_PATH
:
$VTOY_PATH
/tool:
$PATH
ventoy_os_install_dmsetup_by_fuse
()
{
vtlog
"ventoy_os_install_dmsetup_by_fuse
$*
"
mkdir
-p
$VTOY_PATH
/mnt/fuse
$VTOY_PATH
/mnt/iso
$VTOY_PATH
/mnt/squashfs
vtoydm
-p
-f
$VTOY_PATH
/ventoy_image_map
-d
$1
>
$VTOY_PATH
/ventoy_dm_table
vtoy_fuse_iso
-f
$VTOY_PATH
/ventoy_dm_table
-m
$VTOY_PATH
/mnt/fuse
mount
-t
iso9660
$VTOY_PATH
/mnt/fuse/ventoy.iso
$VTOY_PATH
/mnt/iso
sfsfile
=
$(
ls
$VTOY_PATH
/mnt/iso/porteus/base/
*
kernel.xzm
)
mount
-t
squashfs
$sfsfile
$VTOY_PATH
/mnt/squashfs
KoName
=
$(
ls
$VTOY_PATH
/mnt/squashfs/lib/modules/
$2
/kernel/drivers/md/dm-mod.ko
*
)
vtlog
"insmod
$KoName
"
insmod
$KoName
umount
$VTOY_PATH
/mnt/squashfs
umount
$VTOY_PATH
/mnt/iso
umount
$VTOY_PATH
/mnt/fuse
}
ventoy_os_install_dmsetup
()
{
vtlog
"ventoy_os_install_dmsetup"
if
grep
-q
'device-mapper'
/proc/devices
;
then
vtlog
"device-mapper module already loaded"
return
;
fi
vtKerVer
=
$(
uname
-r
)
ventoy_os_install_dmsetup_by_fuse
$1
$vtKerVer
}
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_os_install_dmsetup
$vtdiskname
ventoy_udev_disk_common_hook
"
${
vtdiskname
#/dev/
}
2"
"noreplace"
PATH
=
$VTPATH_OLD
IMG/cpio/ventoy/hook/debian/porteus-hook.sh
0 → 100644
View file @
d5b829f8
#!/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/>.
#
#************************************************************************************
porteus_hook
()
{
$SED
"/searching *for *
\$
SGN *file/i
\
$BUSYBOX_PATH
/sh
$VTOY_PATH
/hook/debian/porteus-disk.sh"
-i
$1
$SED
"/searching *for *
\$
CFG *file/i
\
$BUSYBOX_PATH
/sh
$VTOY_PATH
/hook/debian/porteus-disk.sh"
-i
$1
}
if
$GREP
-q
exfat /proc/filesystems
;
then
vtPath
=
$(
$VTOY_PATH
/tool/vtoydump
-p
$VTOY_PATH
/ventoy_os_param
)
$GREP
'`value from`'
/usr/
*
-r
|
$AWK
-F
:
'{print $1}'
|
while
read
vtline
;
do
echo
"hooking
$vtline
..."
>>
$VTLOG
$SED
"s#
\`
value from
\`
#
$vtPath
#g"
-i
$vtline
done
else
for
vtfile
in
'/init'
'/linuxrc'
;
do
if
[
-e
$vtfile
]
;
then
if
!
$GREP
-q
ventoy
$vtfile
;
then
echo
"hooking
$vtfile
..."
>>
$VTLOG
porteus_hook
$vtfile
fi
fi
done
fi
# replace blkid in system
vtblkid
=
$(
$BUSYBOX_PATH
/which blkid
)
$BUSYBOX_PATH
/rm
-f
$vtblkid
$BUSYBOX_PATH
/cp
-a
$BUSYBOX_PATH
/blkid
$vtblkid
IMG/cpio/ventoy/hook/debian/puppy-disk.sh
0 → 100644
View file @
d5b829f8
#!/ventoy/busybox/sh
#************************************************************************************
# Copyright (c) 2020, longpanda <admin@ventoy.net>
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation; either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, see <http://www.gnu.org/licenses/>.
#
#************************************************************************************
.
/ventoy/hook/ventoy-hook-lib.sh
if
is_ventoy_hook_finished
;
then
exit
0
fi
vtlog
"#######
$0
$*
########"
VTPATH_OLD
=
$PATH
;
PATH
=
$BUSYBOX_PATH
:
$VTOY_PATH
/tool:
$PATH
wait_for_usb_disk_ready
vtdiskname
=
$(
get_ventoy_disk_name
)
if
[
"
$vtdiskname
"
=
"unknown"
]
;
then
vtlog
"ventoy disk not found"
PATH
=
$VTPATH_OLD
exit
0
fi
ventoy_udev_disk_common_hook
"
${
vtdiskname
#/dev/
}
2"
"noreplace"
if
!
[
-e
$VTOY_DM_PATH
]
;
then
blkdev_num
=
$(
$VTOY_PATH
/tool/dmsetup
ls
|
grep
ventoy |
sed
's/.*(\([0-9][0-9]*\),.*\([0-9][0-9]*\).*/\1 \2/'
)
mknod
-m
0666
$VTOY_DM_PATH
b
$blkdev_num
fi
PATH
=
$VTPATH_OLD
set_ventoy_hook_finish
IMG/cpio/ventoy/hook/debian/puppy-hook.sh
0 → 100644
View file @
d5b829f8
#!/ventoy/busybox/sh
#************************************************************************************
# Copyright (c) 2020, longpanda <admin@ventoy.net>
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation; either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, see <http://www.gnu.org/licenses/>.
#
#************************************************************************************
$SED
'1 apmedia=usbhd'
-i
/init
$SED
"/^ *HAVE_PARTS=/a
\
$BUSYBOX_PATH
/sh
$VTOY_PATH
/hook/debian/puppy-disk.sh"
-i
/init
$SED
"/^ *HAVE_PARTS=/a
\
HAVE_PARTS='mapper/ventoy|iso9660'"
-i
/init
IMG/cpio/ventoy/hook/debian/pve-disk.sh
0 → 100644
View file @
d5b829f8
#!/ventoy/busybox/sh
#************************************************************************************
# Copyright (c) 2020, longpanda <admin@ventoy.net>
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation; either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, see <http://www.gnu.org/licenses/>.
#
#************************************************************************************
.
/ventoy/hook/ventoy-hook-lib.sh
if
is_ventoy_hook_finished
;
then
exit
0
fi
vtlog
"#######
$0
$*
########"
VTPATH_OLD
=
$PATH
;
PATH
=
$BUSYBOX_PATH
:
$VTOY_PATH
/tool:
$PATH
wait_for_usb_disk_ready
vtdiskname
=
$(
get_ventoy_disk_name
)
if
[
"
$vtdiskname
"
=
"unknown"
]
;
then
vtlog
"ventoy disk not found"
PATH
=
$VTPATH_OLD
exit
0
fi
ventoy_udev_disk_common_hook
"
${
vtdiskname
#/dev/
}
2"
"noreplace"
PATH
=
$VTPATH_OLD
set_ventoy_hook_finish
Prev
1
2
3
Next
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment