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
b347c1b5
Commit
b347c1b5
authored
Jun 25, 2021
by
longpanda
Browse files
Optimization for booting OpenWrt
parent
da746c60
Changes
8
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
96 additions
and
42 deletions
+96
-42
GRUB2/MOD_SRC/grub-2.04/grub-core/ventoy/ventoy_cmd.c
GRUB2/MOD_SRC/grub-2.04/grub-core/ventoy/ventoy_cmd.c
+26
-5
IMG/cpio/ventoy/loop/openwrt/ventoy-disk.sh
IMG/cpio/ventoy/loop/openwrt/ventoy-disk.sh
+53
-0
IMG/cpio/ventoy/loop/openwrt/ventoy-hook.sh
IMG/cpio/ventoy/loop/openwrt/ventoy-hook.sh
+0
-29
INSTALL/grub/grub.cfg
INSTALL/grub/grub.cfg
+17
-8
INSTALL/tool/aarch64/vtoygpt
INSTALL/tool/aarch64/vtoygpt
+0
-0
INSTALL/tool/i386/vtoygpt
INSTALL/tool/i386/vtoygpt
+0
-0
INSTALL/tool/mips64el/vtoygpt
INSTALL/tool/mips64el/vtoygpt
+0
-0
INSTALL/tool/x86_64/vtoygpt
INSTALL/tool/x86_64/vtoygpt
+0
-0
No files found.
GRUB2/MOD_SRC/grub-2.04/grub-core/ventoy/ventoy_cmd.c
View file @
b347c1b5
...
@@ -4204,8 +4204,18 @@ static int ventoy_fs_enum_1st_file(const char *filename, const struct grub_dirho
...
@@ -4204,8 +4204,18 @@ static int ventoy_fs_enum_1st_file(const char *filename, const struct grub_dirho
return
0
;
return
0
;
}
}
static
int
ventoy_fs_enum_1st_dir
(
const
char
*
filename
,
const
struct
grub_dirhook_info
*
info
,
void
*
data
)
{
if
(
info
->
dir
&&
filename
&&
filename
[
0
]
!=
'.'
)
{
grub_snprintf
((
char
*
)
data
,
256
,
"%s"
,
filename
);
return
1
;
}
static
grub_err_t
ventoy_cmd_fs_enum_1st_file
(
grub_extcmd_context_t
ctxt
,
int
argc
,
char
**
args
)
return
0
;
}
static
grub_err_t
ventoy_fs_enum_1st_child
(
int
argc
,
char
**
args
,
grub_fs_dir_hook_t
hook
)
{
{
int
rc
=
1
;
int
rc
=
1
;
char
*
device_name
=
NULL
;
char
*
device_name
=
NULL
;
...
@@ -4213,11 +4223,9 @@ static grub_err_t ventoy_cmd_fs_enum_1st_file(grub_extcmd_context_t ctxt, int ar
...
@@ -4213,11 +4223,9 @@ static grub_err_t ventoy_cmd_fs_enum_1st_file(grub_extcmd_context_t ctxt, int ar
grub_fs_t
fs
=
NULL
;
grub_fs_t
fs
=
NULL
;
char
name
[
256
]
=
{
0
};
char
name
[
256
]
=
{
0
};
(
void
)
ctxt
;
if
(
argc
!=
3
)
if
(
argc
!=
3
)
{
{
debug
(
"ventoy_
cmd_
fs_enum_1st_
f
il
e
, invalid param num %d
\n
"
,
argc
);
debug
(
"ventoy_fs_enum_1st_
ch
il
d
, invalid param num %d
\n
"
,
argc
);
return
1
;
return
1
;
}
}
...
@@ -4242,7 +4250,7 @@ static grub_err_t ventoy_cmd_fs_enum_1st_file(grub_extcmd_context_t ctxt, int ar
...
@@ -4242,7 +4250,7 @@ static grub_err_t ventoy_cmd_fs_enum_1st_file(grub_extcmd_context_t ctxt, int ar
goto
end
;
goto
end
;
}
}
fs
->
fs_dir
(
dev
,
args
[
1
],
ventoy_fs_enum_1st_file
,
name
);
fs
->
fs_dir
(
dev
,
args
[
1
],
hook
,
name
);
if
(
name
[
0
])
if
(
name
[
0
])
{
{
ventoy_set_env
(
args
[
2
],
name
);
ventoy_set_env
(
args
[
2
],
name
);
...
@@ -4258,6 +4266,18 @@ end:
...
@@ -4258,6 +4266,18 @@ end:
return
rc
;
return
rc
;
}
}
static
grub_err_t
ventoy_cmd_fs_enum_1st_file
(
grub_extcmd_context_t
ctxt
,
int
argc
,
char
**
args
)
{
(
void
)
ctxt
;
return
ventoy_fs_enum_1st_child
(
argc
,
args
,
ventoy_fs_enum_1st_file
);
}
static
grub_err_t
ventoy_cmd_fs_enum_1st_dir
(
grub_extcmd_context_t
ctxt
,
int
argc
,
char
**
args
)
{
(
void
)
ctxt
;
return
ventoy_fs_enum_1st_child
(
argc
,
args
,
ventoy_fs_enum_1st_dir
);
}
static
grub_err_t
ventoy_cmd_basename
(
grub_extcmd_context_t
ctxt
,
int
argc
,
char
**
args
)
static
grub_err_t
ventoy_cmd_basename
(
grub_extcmd_context_t
ctxt
,
int
argc
,
char
**
args
)
{
{
char
c
;
char
c
;
...
@@ -4491,6 +4511,7 @@ static cmd_para ventoy_cmds[] =
...
@@ -4491,6 +4511,7 @@ static cmd_para ventoy_cmds[] =
{
"vt_check_part_exist"
,
ventoy_cmd_part_exist
,
0
,
NULL
,
""
,
""
,
NULL
},
{
"vt_check_part_exist"
,
ventoy_cmd_part_exist
,
0
,
NULL
,
""
,
""
,
NULL
},
{
"vt_get_fs_label"
,
ventoy_cmd_get_fs_label
,
0
,
NULL
,
""
,
""
,
NULL
},
{
"vt_get_fs_label"
,
ventoy_cmd_get_fs_label
,
0
,
NULL
,
""
,
""
,
NULL
},
{
"vt_fs_enum_1st_file"
,
ventoy_cmd_fs_enum_1st_file
,
0
,
NULL
,
""
,
""
,
NULL
},
{
"vt_fs_enum_1st_file"
,
ventoy_cmd_fs_enum_1st_file
,
0
,
NULL
,
""
,
""
,
NULL
},
{
"vt_fs_enum_1st_dir"
,
ventoy_cmd_fs_enum_1st_dir
,
0
,
NULL
,
""
,
""
,
NULL
},
{
"vt_file_basename"
,
ventoy_cmd_basename
,
0
,
NULL
,
""
,
""
,
NULL
},
{
"vt_file_basename"
,
ventoy_cmd_basename
,
0
,
NULL
,
""
,
""
,
NULL
},
{
"vt_file_basefile"
,
ventoy_cmd_basefile
,
0
,
NULL
,
""
,
""
,
NULL
},
{
"vt_file_basefile"
,
ventoy_cmd_basefile
,
0
,
NULL
,
""
,
""
,
NULL
},
{
"vt_enum_video_mode"
,
ventoy_cmd_enum_video_mode
,
0
,
NULL
,
""
,
""
,
NULL
},
{
"vt_enum_video_mode"
,
ventoy_cmd_enum_video_mode
,
0
,
NULL
,
""
,
""
,
NULL
},
...
...
IMG/cpio/ventoy/loop/openwrt/ventoy-disk.sh
View file @
b347c1b5
...
@@ -27,6 +27,59 @@ vtlog "####### $0 $* ########"
...
@@ -27,6 +27,59 @@ vtlog "####### $0 $* ########"
VTPATH_OLD
=
$PATH
;
PATH
=
$BUSYBOX_PATH
:
$VTOY_PATH
/tool:
$PATH
VTPATH_OLD
=
$PATH
;
PATH
=
$BUSYBOX_PATH
:
$VTOY_PATH
/tool:
$PATH
check_insmod
()
{
if
[
-f
"
$1
"
]
;
then
vtlog
"insmod
$1
"
insmod
"
$1
"
>>
$VTOY_PATH
/log 2>&1
else
vtlog
"
$1
not exist"
fi
}
wrt_insmod
()
{
kbit
=
$1
kv
=
$(
uname
-r
)
vtlog
"insmod
$kv
$kbit
"
check_insmod /ventoy_openwrt/
$kv
/
$kbit
/dax.ko
check_insmod /ventoy_openwrt/
$kv
/
$kbit
/dm-mod.ko
}
insmod_dm_mod
()
{
if
grep
-q
"device-mapper"
/proc/devices
;
then
vtlog
"device-mapper enabled by system 0"
return
fi
check_insmod /ventoy/modules/dax.ko
check_insmod /ventoy/modules/dm-mod.ko
if
grep
-q
"device-mapper"
/proc/devices
;
then
vtlog
"device-mapper enabled by system 1"
return
fi
if
[
-f
/ventoy_openwrt.xz
]
;
then
tar
xf /ventoy_openwrt.xz
-C
/
rm
-f
/ventoy_openwrt.xz
fi
if
uname
-m
| egrep
-q
"amd64|x86_64"
;
then
wrt_insmod 64
else
wrt_insmod generic
if
lsmod |
grep
-q
'dm-mod'
;
then
vterr
"insmod generic failed"
else
wrt_insmod legacy
fi
fi
}
insmod_dm_mod
for
i
in
$(
ls
/sys/class/block/
)
;
do
for
i
in
$(
ls
/sys/class/block/
)
;
do
if
!
[
-e
/dev/
$i
]
;
then
if
!
[
-e
/dev/
$i
]
;
then
blkdev_num
=
$(
sed
's/:/ /g'
/sys/class/block/
$i
/dev
)
blkdev_num
=
$(
sed
's/:/ /g'
/sys/class/block/
$i
/dev
)
...
...
IMG/cpio/ventoy/loop/openwrt/ventoy-hook.sh
View file @
b347c1b5
...
@@ -21,37 +21,8 @@
...
@@ -21,37 +21,8 @@
VTPATH_OLD
=
$PATH
;
PATH
=
$BUSYBOX_PATH
:
$VTOY_PATH
/tool:
$PATH
VTPATH_OLD
=
$PATH
;
PATH
=
$BUSYBOX_PATH
:
$VTOY_PATH
/tool:
$PATH
wrt_insmod
()
{
kbit
=
$1
kv
=
$(
uname
-r
)
echo
"insmod
$kv
$kbit
"
>>
$VTOY_PATH
/log
[
-f
/ventoy_openwrt/
$kv
/
$kbit
/dax.ko
]
&&
insmod /ventoy_openwrt/
$kv
/
$kbit
/dax.ko
>
/dev/null 2>&1
[
-f
/ventoy_openwrt/
$kv
/
$kbit
/dm-mod.ko
]
&&
insmod /ventoy_openwrt/
$kv
/
$kbit
/dm-mod.ko
>
/dev/null 2>&1
}
mkdir
/sys
mkdir
/sys
mount
-t
sysfs sys /sys
mount
-t
sysfs sys /sys
mdev
-s
mdev
-s
if
[
-f
/ventoy_openwrt.xz
]
;
then
tar
xf /ventoy_openwrt.xz
-C
/
rm
-f
/ventoy_openwrt.xz
fi
if
uname
-m
| egrep
-q
"amd64|x86_64"
;
then
wrt_insmod 64
else
wrt_insmod generic
if
lsmod |
grep
-q
'dm-mod'
;
then
echo
"insmod generic failed"
>>
$VTOY_PATH
/log
else
wrt_insmod legacy
fi
fi
sh
$VTOY_PATH
/loop/openwrt/ventoy-disk.sh
sh
$VTOY_PATH
/loop/openwrt/ventoy-disk.sh
INSTALL/grub/grub.cfg
View file @
b347c1b5
...
@@ -1626,6 +1626,14 @@ function ventoy_img_openwrt {
...
@@ -1626,6 +1626,14 @@ function ventoy_img_openwrt {
set ventoy_busybox_ver=64
set ventoy_busybox_ver=64
fi
fi
vt_fs_enum_1st_dir (vtimghd,2) /lib/modules/ vt_dir_name
if [ -f (vtimghd,2)/lib/modules/$vt_dir_name/dm-mod.ko ]; then
vt_img_extra_initrd_append (vtimghd,2)/lib/modules/$vt_dir_name/dm-mod.ko
if [ -f (vtimghd,2)/lib/modules/$vt_dir_name/dax.ko ]; then
vt_img_extra_initrd_append (vtimghd,2)/lib/modules/$vt_dir_name/dax.ko
fi
else
if [ ! -f ${vtoy_iso_part}/ventoy/ventoy_openwrt.xz ]; then
if [ ! -f ${vtoy_iso_part}/ventoy/ventoy_openwrt.xz ]; then
ventoy_gui_console
ventoy_gui_console
echo -e "\n ventoy_openwrt.xz not found. Please refer https://www.ventoy.net/en/doc_openwrt.html.\n"
echo -e "\n ventoy_openwrt.xz not found. Please refer https://www.ventoy.net/en/doc_openwrt.html.\n"
...
@@ -1635,6 +1643,7 @@ function ventoy_img_openwrt {
...
@@ -1635,6 +1643,7 @@ function ventoy_img_openwrt {
ventoy_cli_console
ventoy_cli_console
return
return
fi
fi
fi
if vt_img_check_range "${vtoy_iso_part}${vt_chosen_path}"; then
if vt_img_check_range "${vtoy_iso_part}${vt_chosen_path}"; then
ventoy_debug_pause
ventoy_debug_pause
...
...
INSTALL/tool/aarch64/vtoygpt
View file @
b347c1b5
No preview for this file type
INSTALL/tool/i386/vtoygpt
View file @
b347c1b5
No preview for this file type
INSTALL/tool/mips64el/vtoygpt
View file @
b347c1b5
No preview for this file type
INSTALL/tool/x86_64/vtoygpt
View file @
b347c1b5
No preview for this file type
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