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
3ebd58c9
Commit
3ebd58c9
authored
Oct 22, 2020
by
longpanda
Browse files
support original order in image_list plugin
parent
ce6d3795
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
73 additions
and
61 deletions
+73
-61
GRUB2/MOD_SRC/grub-2.04/grub-core/ventoy/ventoy.c
GRUB2/MOD_SRC/grub-2.04/grub-core/ventoy/ventoy.c
+45
-52
GRUB2/MOD_SRC/grub-2.04/grub-core/ventoy/ventoy_def.h
GRUB2/MOD_SRC/grub-2.04/grub-core/ventoy/ventoy_def.h
+4
-1
GRUB2/MOD_SRC/grub-2.04/grub-core/ventoy/ventoy_plugin.c
GRUB2/MOD_SRC/grub-2.04/grub-core/ventoy/ventoy_plugin.c
+24
-8
No files found.
GRUB2/MOD_SRC/grub-2.04/grub-core/ventoy/ventoy.c
View file @
3ebd58c9
...
@@ -1020,6 +1020,11 @@ int ventoy_cmp_img(img_info *img1, img_info *img2)
...
@@ -1020,6 +1020,11 @@ int ventoy_cmp_img(img_info *img1, img_info *img2)
int
c1
=
0
;
int
c1
=
0
;
int
c2
=
0
;
int
c2
=
0
;
if
(
g_plugin_image_list
)
{
return
(
img1
->
plugin_list_index
-
img2
->
plugin_list_index
);
}
for
(
s1
=
img1
->
name
,
s2
=
img2
->
name
;
*
s1
&&
*
s2
;
s1
++
,
s2
++
)
for
(
s1
=
img1
->
name
,
s2
=
img2
->
name
;
*
s1
&&
*
s2
;
s1
++
,
s2
++
)
{
{
c1
=
*
s1
;
c1
=
*
s1
;
...
@@ -1047,13 +1052,18 @@ int ventoy_cmp_img(img_info *img1, img_info *img2)
...
@@ -1047,13 +1052,18 @@ int ventoy_cmp_img(img_info *img1, img_info *img2)
return
(
c1
-
c2
);
return
(
c1
-
c2
);
}
}
static
int
ventoy_cmp_subdir
(
char
*
n
am
e1
,
char
*
n
am
e2
)
static
int
ventoy_cmp_subdir
(
img_iterator_node
*
n
od
e1
,
img_iterator_node
*
n
od
e2
)
{
{
char
*
s1
,
*
s2
;
char
*
s1
,
*
s2
;
int
c1
=
0
;
int
c1
=
0
;
int
c2
=
0
;
int
c2
=
0
;
for
(
s1
=
name1
,
s2
=
name2
;
*
s1
&&
*
s2
;
s1
++
,
s2
++
)
if
(
g_plugin_image_list
)
{
return
(
node1
->
plugin_list_index
-
node2
->
plugin_list_index
);
}
for
(
s1
=
node1
->
dir
,
s2
=
node2
->
dir
;
*
s1
&&
*
s2
;
s1
++
,
s2
++
)
{
{
c1
=
*
s1
;
c1
=
*
s1
;
c2
=
*
s2
;
c2
=
*
s2
;
...
@@ -1137,6 +1147,7 @@ static int ventoy_colect_img_files(const char *filename, const struct grub_dirho
...
@@ -1137,6 +1147,7 @@ static int ventoy_colect_img_files(const char *filename, const struct grub_dirho
int
i
=
0
;
int
i
=
0
;
int
type
=
0
;
int
type
=
0
;
int
ignore
=
0
;
int
ignore
=
0
;
int
index
=
0
;
grub_size_t
len
;
grub_size_t
len
;
img_info
*
img
;
img_info
*
img
;
img_info
*
tail
;
img_info
*
tail
;
...
@@ -1164,9 +1175,21 @@ static int ventoy_colect_img_files(const char *filename, const struct grub_dirho
...
@@ -1164,9 +1175,21 @@ static int ventoy_colect_img_files(const char *filename, const struct grub_dirho
return
0
;
return
0
;
}
}
if
(
g_plugin_image_list
)
{
grub_snprintf
(
g_img_swap_tmp_buf
,
sizeof
(
g_img_swap_tmp_buf
),
"%s%s/"
,
node
->
dir
,
filename
);
index
=
ventoy_plugin_get_image_list_index
(
vtoy_class_directory
,
g_img_swap_tmp_buf
);
if
(
index
==
0
)
{
debug
(
"Directory %s not found in image_list plugin config...
\n
"
,
g_img_swap_tmp_buf
);
return
0
;
}
}
new_node
=
grub_zalloc
(
sizeof
(
img_iterator_node
));
new_node
=
grub_zalloc
(
sizeof
(
img_iterator_node
));
if
(
new_node
)
if
(
new_node
)
{
{
new_node
->
plugin_list_index
=
index
;
new_node
->
dirlen
=
grub_snprintf
(
new_node
->
dir
,
sizeof
(
new_node
->
dir
),
"%s%s/"
,
node
->
dir
,
filename
);
new_node
->
dirlen
=
grub_snprintf
(
new_node
->
dir
,
sizeof
(
new_node
->
dir
),
"%s%s/"
,
node
->
dir
,
filename
);
g_enum_fs
->
fs_dir
(
g_enum_dev
,
new_node
->
dir
,
ventoy_check_ignore_flag
,
&
ignore
);
g_enum_fs
->
fs_dir
(
g_enum_dev
,
new_node
->
dir
,
ventoy_check_ignore_flag
,
&
ignore
);
...
@@ -1253,9 +1276,11 @@ static int ventoy_colect_img_files(const char *filename, const struct grub_dirho
...
@@ -1253,9 +1276,11 @@ static int ventoy_colect_img_files(const char *filename, const struct grub_dirho
if
(
g_plugin_image_list
)
if
(
g_plugin_image_list
)
{
{
grub_snprintf
(
g_img_swap_tmp_buf
,
sizeof
(
g_img_swap_tmp_buf
),
"%s%s"
,
node
->
dir
,
filename
);
grub_snprintf
(
g_img_swap_tmp_buf
,
sizeof
(
g_img_swap_tmp_buf
),
"%s%s"
,
node
->
dir
,
filename
);
if
(
ventoy_plugin_check_image_list
(
g_img_swap_tmp_buf
)
==
0
)
index
=
ventoy_plugin_get_image_list_index
(
vtoy_class_image_file
,
g_img_swap_tmp_buf
);
if
(
index
==
0
)
{
{
return
0
;
debug
(
"File %s not found in image_list plugin config...
\n
"
,
g_img_swap_tmp_buf
);
return
0
;
}
}
}
}
...
@@ -1263,6 +1288,7 @@ static int ventoy_colect_img_files(const char *filename, const struct grub_dirho
...
@@ -1263,6 +1288,7 @@ static int ventoy_colect_img_files(const char *filename, const struct grub_dirho
if
(
img
)
if
(
img
)
{
{
img
->
type
=
type
;
img
->
type
=
type
;
img
->
plugin_list_index
=
index
;
grub_snprintf
(
img
->
name
,
sizeof
(
img
->
name
),
"%s"
,
filename
);
grub_snprintf
(
img
->
name
,
sizeof
(
img
->
name
),
"%s"
,
filename
);
for
(
i
=
0
;
i
<
(
int
)
len
;
i
++
)
for
(
i
=
0
;
i
<
(
int
)
len
;
i
++
)
...
@@ -1422,28 +1448,13 @@ static img_info * ventoy_get_min_iso(img_iterator_node *node)
...
@@ -1422,28 +1448,13 @@ static img_info * ventoy_get_min_iso(img_iterator_node *node)
img_info
*
minimg
=
NULL
;
img_info
*
minimg
=
NULL
;
img_info
*
img
=
(
img_info
*
)(
node
->
firstiso
);
img_info
*
img
=
(
img_info
*
)(
node
->
firstiso
);
if
(
g_plugin_image_list
)
while
(
img
&&
(
img_iterator_node
*
)(
img
->
parent
)
==
node
)
{
{
while
(
img
&&
(
img_iterator_node
*
)(
img
->
parent
)
==
node
)
if
(
img
->
select
==
0
&&
(
NULL
==
minimg
||
ventoy_cmp_img
(
img
,
minimg
)
<
0
)
)
{
{
if
(
img
->
select
==
0
)
minimg
=
img
;
{
minimg
=
img
;
break
;
}
img
=
img
->
next
;
}
}
else
{
while
(
img
&&
(
img_iterator_node
*
)(
img
->
parent
)
==
node
)
{
if
(
img
->
select
==
0
&&
(
NULL
==
minimg
||
ventoy_cmp_img
(
img
,
minimg
)
<
0
))
{
minimg
=
img
;
}
img
=
img
->
next
;
}
}
img
=
img
->
next
;
}
}
if
(
minimg
)
if
(
minimg
)
...
@@ -1459,28 +1470,13 @@ static img_iterator_node * ventoy_get_min_child(img_iterator_node *node)
...
@@ -1459,28 +1470,13 @@ static img_iterator_node * ventoy_get_min_child(img_iterator_node *node)
img_iterator_node
*
Minchild
=
NULL
;
img_iterator_node
*
Minchild
=
NULL
;
img_iterator_node
*
child
=
node
->
firstchild
;
img_iterator_node
*
child
=
node
->
firstchild
;
if
(
g_plugin_image_list
)
while
(
child
&&
child
->
parent
==
node
)
{
while
(
child
&&
child
->
parent
==
node
)
{
if
(
child
->
select
==
0
)
{
Minchild
=
child
;
break
;
}
child
=
child
->
next
;
}
}
else
{
{
while
(
child
&&
child
->
parent
==
node
)
if
(
child
->
select
==
0
&&
(
NULL
==
Minchild
||
ventoy_cmp_subdir
(
child
,
Minchild
)
<
0
)
)
{
{
if
(
child
->
select
==
0
&&
(
NULL
==
Minchild
||
ventoy_cmp_subdir
(
child
->
dir
,
Minchild
->
dir
)
<
0
))
Minchild
=
child
;
{
Minchild
=
child
;
}
child
=
child
->
next
;
}
}
child
=
child
->
next
;
}
}
if
(
Minchild
)
if
(
Minchild
)
...
@@ -1880,7 +1876,7 @@ static grub_err_t ventoy_cmd_list_img(grub_extcmd_context_t ctxt, int argc, char
...
@@ -1880,7 +1876,7 @@ static grub_err_t ventoy_cmd_list_img(grub_extcmd_context_t ctxt, int argc, char
grub_snprintf
(
g_iso_path
,
sizeof
(
g_iso_path
),
"%s"
,
args
[
0
]);
grub_snprintf
(
g_iso_path
,
sizeof
(
g_iso_path
),
"%s"
,
args
[
0
]);
strdata
=
ventoy_get_env
(
"VTOY_DEFAULT_SEARCH_ROOT"
);
strdata
=
ventoy_get_env
(
"VTOY_DEFAULT_SEARCH_ROOT"
);
if
(
0
==
g_plugin_image_list
&&
strdata
&&
strdata
[
0
]
==
'/'
)
if
(
strdata
&&
strdata
[
0
]
==
'/'
)
{
{
len
=
grub_snprintf
(
g_img_iterator_head
.
dir
,
sizeof
(
g_img_iterator_head
.
dir
)
-
1
,
"%s"
,
strdata
);
len
=
grub_snprintf
(
g_img_iterator_head
.
dir
,
sizeof
(
g_img_iterator_head
.
dir
)
-
1
,
"%s"
,
strdata
);
if
(
g_img_iterator_head
.
dir
[
len
-
1
]
!=
'/'
)
if
(
g_img_iterator_head
.
dir
[
len
-
1
]
!=
'/'
)
...
@@ -1924,17 +1920,14 @@ static grub_err_t ventoy_cmd_list_img(grub_extcmd_context_t ctxt, int argc, char
...
@@ -1924,17 +1920,14 @@ static grub_err_t ventoy_cmd_list_img(grub_extcmd_context_t ctxt, int argc, char
node
=
tmp
;
node
=
tmp
;
}
}
/* sort image list by image name
if image_list is not set in ventoy.json
*/
/* sort image list by image name */
if
(
0
==
g_plugin_image_lis
t
)
for
(
cur
=
g_ventoy_img_list
;
cur
;
cur
=
cur
->
nex
t
)
{
{
for
(
cur
=
g_ventoy_img_list
;
cur
;
cur
=
cur
->
next
)
for
(
tail
=
cur
->
next
;
tail
;
tail
=
tail
->
next
)
{
{
for
(
tail
=
cur
->
next
;
tail
;
tail
=
tail
->
next
)
if
(
ventoy_cmp_img
(
cur
,
tail
)
>
0
)
{
{
if
(
ventoy_cmp_img
(
cur
,
tail
)
>
0
)
ventoy_swap_img
(
cur
,
tail
);
{
ventoy_swap_img
(
cur
,
tail
);
}
}
}
}
}
}
}
...
@@ -2738,7 +2731,7 @@ static grub_err_t ventoy_cmd_dump_img_list(grub_extcmd_context_t ctxt, int argc,
...
@@ -2738,7 +2731,7 @@ static grub_err_t ventoy_cmd_dump_img_list(grub_extcmd_context_t ctxt, int argc,
while
(
cur
)
while
(
cur
)
{
{
grub_printf
(
"path:<%s> id=%d
\n
"
,
cur
->
path
,
cur
->
id
);
grub_printf
(
"path:<%s> id=%d
list_index=%d
\n
"
,
cur
->
path
,
cur
->
id
,
cur
->
plugin_list_index
);
grub_printf
(
"name:<%s>
\n\n
"
,
cur
->
name
);
grub_printf
(
"name:<%s>
\n\n
"
,
cur
->
name
);
cur
=
cur
->
next
;
cur
=
cur
->
next
;
}
}
...
...
GRUB2/MOD_SRC/grub-2.04/grub-core/ventoy/ventoy_def.h
View file @
3ebd58c9
...
@@ -172,6 +172,7 @@ typedef struct img_info
...
@@ -172,6 +172,7 @@ typedef struct img_info
int
id
;
int
id
;
int
type
;
int
type
;
int
plugin_list_index
;
grub_uint64_t
size
;
grub_uint64_t
size
;
int
select
;
int
select
;
int
unsupport
;
int
unsupport
;
...
@@ -192,6 +193,8 @@ typedef struct img_iterator_node
...
@@ -192,6 +193,8 @@ typedef struct img_iterator_node
int
done
;
int
done
;
int
select
;
int
select
;
int
plugin_list_index
;
struct
img_iterator_node
*
parent
;
struct
img_iterator_node
*
parent
;
struct
img_iterator_node
*
firstchild
;
struct
img_iterator_node
*
firstchild
;
...
@@ -828,7 +831,7 @@ const char * ventoy_plugin_get_injection(const char *isopath);
...
@@ -828,7 +831,7 @@ const char * ventoy_plugin_get_injection(const char *isopath);
const
char
*
ventoy_plugin_get_menu_alias
(
int
type
,
const
char
*
isopath
);
const
char
*
ventoy_plugin_get_menu_alias
(
int
type
,
const
char
*
isopath
);
const
char
*
ventoy_plugin_get_menu_class
(
int
type
,
const
char
*
name
);
const
char
*
ventoy_plugin_get_menu_class
(
int
type
,
const
char
*
name
);
int
ventoy_plugin_check_memdisk
(
const
char
*
isopath
);
int
ventoy_plugin_check_memdisk
(
const
char
*
isopath
);
int
ventoy_plugin_
check
_image_list
(
const
char
*
isopath
);
int
ventoy_plugin_
get
_image_list
_index
(
int
type
,
const
char
*
name
);
int
ventoy_get_block_list
(
grub_file_t
file
,
ventoy_img_chunk_list
*
chunklist
,
grub_disk_addr_t
start
);
int
ventoy_get_block_list
(
grub_file_t
file
,
ventoy_img_chunk_list
*
chunklist
,
grub_disk_addr_t
start
);
int
ventoy_check_block_list
(
grub_file_t
file
,
ventoy_img_chunk_list
*
chunklist
,
grub_disk_addr_t
start
);
int
ventoy_check_block_list
(
grub_file_t
file
,
ventoy_img_chunk_list
*
chunklist
,
grub_disk_addr_t
start
);
void
ventoy_plugin_dump_persistence
(
void
);
void
ventoy_plugin_dump_persistence
(
void
);
...
...
GRUB2/MOD_SRC/grub-2.04/grub-core/ventoy/ventoy_plugin.c
View file @
3ebd58c9
...
@@ -1102,6 +1102,7 @@ static int ventoy_plugin_image_list_entry(VTOY_JSON *json, const char *isodisk)
...
@@ -1102,6 +1102,7 @@ static int ventoy_plugin_image_list_entry(VTOY_JSON *json, const char *isodisk)
VTOY_JSON
*
pNode
=
NULL
;
VTOY_JSON
*
pNode
=
NULL
;
image_list
*
node
=
NULL
;
image_list
*
node
=
NULL
;
image_list
*
next
=
NULL
;
image_list
*
next
=
NULL
;
image_list
*
tail
=
NULL
;
(
void
)
isodisk
;
(
void
)
isodisk
;
...
@@ -1135,10 +1136,13 @@ static int ventoy_plugin_image_list_entry(VTOY_JSON *json, const char *isodisk)
...
@@ -1135,10 +1136,13 @@ static int ventoy_plugin_image_list_entry(VTOY_JSON *json, const char *isodisk)
if
(
g_image_list_head
)
if
(
g_image_list_head
)
{
{
node
->
next
=
g_image_list_head
;
tail
->
next
=
node
;
}
}
else
g_image_list_head
=
node
;
{
g_image_list_head
=
node
;
}
tail
=
node
;
}
}
}
}
}
}
...
@@ -1558,9 +1562,10 @@ int ventoy_plugin_check_memdisk(const char *isopath)
...
@@ -1558,9 +1562,10 @@ int ventoy_plugin_check_memdisk(const char *isopath)
return
0
;
return
0
;
}
}
int
ventoy_plugin_
check
_image_list
(
const
char
*
isopath
)
int
ventoy_plugin_
get
_image_list
_index
(
int
type
,
const
char
*
name
)
{
{
int
len
;
int
len
;
int
index
=
1
;
image_list
*
node
=
NULL
;
image_list
*
node
=
NULL
;
if
(
!
g_image_list_head
)
if
(
!
g_image_list_head
)
...
@@ -1568,12 +1573,23 @@ int ventoy_plugin_check_image_list(const char *isopath)
...
@@ -1568,12 +1573,23 @@ int ventoy_plugin_check_image_list(const char *isopath)
return
0
;
return
0
;
}
}
len
=
(
int
)
grub_strlen
(
isopath
);
len
=
(
int
)
grub_strlen
(
name
);
for
(
node
=
g_image_list_head
;
node
;
node
=
node
->
next
)
for
(
node
=
g_image_list_head
;
node
;
node
=
node
->
next
,
index
++
)
{
{
if
(
node
->
pathlen
==
len
&&
grub_strncmp
(
isopath
,
node
->
isopath
,
len
)
==
0
)
if
(
vtoy_class_directory
==
type
)
{
{
return
1
;
if
(
len
<
node
->
pathlen
&&
grub_strncmp
(
name
,
node
->
isopath
,
len
)
==
0
)
{
return
index
;
}
}
else
{
if
(
len
==
node
->
pathlen
&&
grub_strncmp
(
name
,
node
->
isopath
,
len
)
==
0
)
{
return
index
;
}
}
}
}
}
...
...
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