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
096cc99c
Commit
096cc99c
authored
Jul 13, 2022
by
longpanda
Browse files
Fix a bug that VTOY_LINUX_REMOUNT option doesn't take effect in openSUSE.
parent
602e8c7f
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
49 additions
and
6 deletions
+49
-6
DMPATCH/dmpatch.c
DMPATCH/dmpatch.c
+34
-4
IMG/cpio/ventoy/hook/ventoy-hook-lib.sh
IMG/cpio/ventoy/hook/ventoy-hook-lib.sh
+15
-2
IMG/cpio_x86/ventoy/tool/dm_patch_32.ko
IMG/cpio_x86/ventoy/tool/dm_patch_32.ko
+0
-0
IMG/cpio_x86/ventoy/tool/dm_patch_64.ko
IMG/cpio_x86/ventoy/tool/dm_patch_64.ko
+0
-0
No files found.
DMPATCH/dmpatch.c
View file @
096cc99c
...
...
@@ -82,12 +82,34 @@ static volatile ko_param g_ko_param =
#define vdebug(fmt, args...) if(kprintf) kprintf(KERN_ERR fmt, ##args)
static
int
notrace
dmpatch_replace_code
(
unsigned
long
addr
,
unsigned
long
size
,
int
expect
,
const
char
*
desc
)
static
unsigned
char
*
g_get_patch
[
MAX_PATCH
]
=
{
NULL
};
static
unsigned
char
*
g_put_patch
[
MAX_PATCH
]
=
{
NULL
};
static
void
notrace
dmpatch_restore_code
(
unsigned
char
*
opCode
)
{
unsigned
long
align
;
if
(
opCode
)
{
align
=
(
unsigned
long
)
opCode
/
g_ko_param
.
pgsize
*
g_ko_param
.
pgsize
;
set_mem_rw
(
align
,
1
);
*
opCode
=
0x80
;
set_mem_ro
(
align
,
1
);
}
}
static
int
notrace
dmpatch_replace_code
(
unsigned
long
addr
,
unsigned
long
size
,
int
expect
,
const
char
*
desc
,
unsigned
char
**
patch
)
{
int
i
=
0
;
int
cnt
=
0
;
unsigned
long
align
;
unsigned
char
*
patch
[
MAX_PATCH
];
unsigned
char
*
opCode
=
(
unsigned
char
*
)
addr
;
vdebug
(
"patch for %s 0x%lx %d
\n
"
,
desc
,
addr
,
(
int
)
size
);
...
...
@@ -147,7 +169,7 @@ static int notrace dmpatch_init(void)
reg_kprobe
=
(
kprobe_reg_pf
)
g_ko_param
.
reg_kprobe_addr
;
unreg_kprobe
=
(
kprobe_unreg_pf
)
g_ko_param
.
unreg_kprobe_addr
;
r
=
dmpatch_replace_code
(
g_ko_param
.
sym_get_addr
,
g_ko_param
.
sym_get_size
,
2
,
"dm_get_table_device"
);
r
=
dmpatch_replace_code
(
g_ko_param
.
sym_get_addr
,
g_ko_param
.
sym_get_size
,
2
,
"dm_get_table_device"
,
g_get_patch
);
if
(
r
)
{
rc
=
-
EINVAL
;
...
...
@@ -155,7 +177,7 @@ static int notrace dmpatch_init(void)
}
vdebug
(
"patch dm_get_table_device success
\n
"
);
r
=
dmpatch_replace_code
(
g_ko_param
.
sym_put_addr
,
g_ko_param
.
sym_put_size
,
1
,
"dm_put_table_device"
);
r
=
dmpatch_replace_code
(
g_ko_param
.
sym_put_addr
,
g_ko_param
.
sym_put_size
,
1
,
"dm_put_table_device"
,
g_put_patch
);
if
(
r
)
{
rc
=
-
EINVAL
;
...
...
@@ -174,7 +196,15 @@ out:
static
void
notrace
dmpatch_exit
(
void
)
{
int
i
=
0
;
for
(
i
=
0
;
i
<
MAX_PATCH
;
i
++
)
{
dmpatch_restore_code
(
g_get_patch
[
i
]);
dmpatch_restore_code
(
g_put_patch
[
i
]);
}
vdebug
(
"dmpatch_exit success
\n
"
);
}
module_init
(
dmpatch_init
);
...
...
IMG/cpio/ventoy/hook/ventoy-hook-lib.sh
View file @
096cc99c
...
...
@@ -278,11 +278,23 @@ ventoy_dm_patch() {
$CAT
/proc/kallsyms |
$BUSYBOX_PATH
/sort
>
$VTOY_PATH
/kallsyms
vtLine
=
$(
$VTOY_PATH
/tool/vtoyksym dm_get_table_device
$VTOY_PATH
/kallsyms
)
if
$GREP
-m1
-q
'open_table_device.isra'
$VTOY_PATH
/kallsyms
;
then
vtLine
=
$(
$VTOY_PATH
/tool/vtoyksym open_table_device.isra
$VTOY_PATH
/kallsyms
)
vtlog
"get open_table_device.isra address
$vtLine
"
else
vtLine
=
$(
$VTOY_PATH
/tool/vtoyksym dm_get_table_device
$VTOY_PATH
/kallsyms
)
vtlog
"get dm_get_table_device address
$vtLine
"
fi
get_addr
=
$(
echo
$vtLine
|
$AWK
'{print $1}'
)
get_size
=
$(
echo
$vtLine
|
$AWK
'{print $2}'
)
vtLine
=
$(
$VTOY_PATH
/tool/vtoyksym dm_put_table_device
$VTOY_PATH
/kallsyms
)
if
$GREP
-m1
-q
'close_table_device.isra'
$VTOY_PATH
/kallsyms
;
then
vtLine
=
$(
$VTOY_PATH
/tool/vtoyksym close_table_device.isra
$VTOY_PATH
/kallsyms
)
vtlog
"get close_table_device.isra address
$vtLine
"
else
vtLine
=
$(
$VTOY_PATH
/tool/vtoyksym dm_put_table_device
$VTOY_PATH
/kallsyms
)
vtlog
"get dm_put_table_device address
$vtLine
"
fi
put_addr
=
$(
echo
$vtLine
|
$AWK
'{print $1}'
)
put_size
=
$(
echo
$vtLine
|
$AWK
'{print $2}'
)
...
...
@@ -738,6 +750,7 @@ ventoy_udev_disk_common_hook() {
fi
if
$GREP
-q
'dm_patch'
/proc/modules
;
then
vtlog
"remove dm_patch module."
$BUSYBOX_PATH
/rmmod dm_patch
fi
}
...
...
IMG/cpio_x86/ventoy/tool/dm_patch_32.ko
View file @
096cc99c
No preview for this file type
IMG/cpio_x86/ventoy/tool/dm_patch_64.ko
View file @
096cc99c
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