Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
M
Magisk
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
Magisk
Commits
548d70f3
Commit
548d70f3
authored
Mar 02, 2022
by
topjohnwu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Mount with original option
Fix #5481, close #5486
parent
39e714c6
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
44 additions
and
23 deletions
+44
-23
bootstages.cpp
native/jni/core/bootstages.cpp
+28
-18
misc.cpp
native/jni/utils/misc.cpp
+14
-4
misc.hpp
native/jni/utils/misc.hpp
+2
-1
No files found.
native/jni/core/bootstages.cpp
View file @
548d70f3
...
@@ -29,21 +29,31 @@ bool zygisk_enabled = false;
...
@@ -29,21 +29,31 @@ bool zygisk_enabled = false;
#define SETMIR(b, part) snprintf(b, sizeof(b), "%s/" MIRRDIR "/" #part, MAGISKTMP.data())
#define SETMIR(b, part) snprintf(b, sizeof(b), "%s/" MIRRDIR "/" #part, MAGISKTMP.data())
#define SETBLK(b, part) snprintf(b, sizeof(b), "%s/" BLOCKDIR "/" #part, MAGISKTMP.data())
#define SETBLK(b, part) snprintf(b, sizeof(b), "%s/" BLOCKDIR "/" #part, MAGISKTMP.data())
#define do_mount_mirror(part
, flag) {
\
#define do_mount_mirror(part
) {
\
SETMIR(buf1, part); \
SETMIR(buf1, part);
\
SETBLK(buf2, part); \
SETBLK(buf2, part);
\
unlink(buf2); \
unlink(buf2);
\
mknod(buf2, S_IFBLK | 0600, st.st_dev); \
mknod(buf2, S_IFBLK | 0600, st.st_dev); \
xmkdir(buf1, 0755); \
xmkdir(buf1, 0755); \
xmount(buf2, buf1, me->mnt_type, flag, nullptr); \
int flags = 0; \
LOGI("mount: %s\n", buf1); \
auto opts = split_ro(me->mnt_opts, ",");\
for (string_view s : opts) { \
if (s == "ro") { \
flags |= MS_RDONLY; \
break; \
} \
} \
xmount(buf2, buf1, me->mnt_type, flags, nullptr); \
LOGI("mount: %s\n", buf1); \
}
}
#define mount_mirror(part, flag) \
#define mount_mirror(part) \
if (MNT_DIR_IS("/" #part) && !MNT_TYPE_IS("tmpfs") && !MNT_TYPE_IS("overlay") && \
if (MNT_DIR_IS("/" #part) \
lstat(me->mnt_dir, &st) == 0) { \
&& !MNT_TYPE_IS("tmpfs") \
do_mount_mirror(part, flag); \
&& !MNT_TYPE_IS("overlay") \
break; \
&& lstat(me->mnt_dir, &st) == 0) { \
do_mount_mirror(part); \
break; \
}
}
#define link_mirror(part) \
#define link_mirror(part) \
...
@@ -73,11 +83,11 @@ static void mount_mirrors() {
...
@@ -73,11 +83,11 @@ static void mount_mirrors() {
parse_mnt
(
"/proc/mounts"
,
[
&
](
mntent
*
me
)
{
parse_mnt
(
"/proc/mounts"
,
[
&
](
mntent
*
me
)
{
struct
stat
st
{};
struct
stat
st
{};
do
{
do
{
mount_mirror
(
system
,
MS_RDONLY
)
mount_mirror
(
system
)
mount_mirror
(
vendor
,
MS_RDONLY
)
mount_mirror
(
vendor
)
mount_mirror
(
product
,
MS_RDONLY
)
mount_mirror
(
product
)
mount_mirror
(
system_ext
,
MS_RDONLY
)
mount_mirror
(
system_ext
)
mount_mirror
(
data
,
0
)
mount_mirror
(
data
)
link_orig
(
cache
)
link_orig
(
cache
)
link_orig
(
metadata
)
link_orig
(
metadata
)
link_orig
(
persist
)
link_orig
(
persist
)
...
@@ -96,7 +106,7 @@ static void mount_mirrors() {
...
@@ -96,7 +106,7 @@ static void mount_mirrors() {
parse_mnt
(
"/proc/mounts"
,
[
&
](
mntent
*
me
)
{
parse_mnt
(
"/proc/mounts"
,
[
&
](
mntent
*
me
)
{
struct
stat
st
;
struct
stat
st
;
if
(
MNT_DIR_IS
(
"/"
)
&&
me
->
mnt_type
!=
"rootfs"
sv
&&
stat
(
"/"
,
&
st
)
==
0
)
{
if
(
MNT_DIR_IS
(
"/"
)
&&
me
->
mnt_type
!=
"rootfs"
sv
&&
stat
(
"/"
,
&
st
)
==
0
)
{
do_mount_mirror
(
system_root
,
MS_RDONLY
)
do_mount_mirror
(
system_root
)
return
false
;
return
false
;
}
}
return
true
;
return
true
;
...
...
native/jni/utils/misc.cpp
View file @
548d70f3
...
@@ -189,15 +189,25 @@ string &replace_all(string &str, string_view from, string_view to) {
...
@@ -189,15 +189,25 @@ string &replace_all(string &str, string_view from, string_view to) {
return
str
;
return
str
;
}
}
vector
<
string
>
split
(
const
string
&
s
,
const
string
&
delimiters
)
{
template
<
class
T
>
vector
<
string
>
result
;
static
auto
split_impl
(
T
s
,
T
delims
)
{
vector
<
std
::
decay_t
<
T
>>
result
;
size_t
base
=
0
;
size_t
base
=
0
;
size_t
found
;
size_t
found
;
while
(
true
)
{
while
(
true
)
{
found
=
s
.
find_first_of
(
delim
iter
s
,
base
);
found
=
s
.
find_first_of
(
delims
,
base
);
result
.
push_back
(
s
.
substr
(
base
,
found
-
base
));
result
.
push_back
(
s
.
substr
(
base
,
found
-
base
));
if
(
found
==
string
::
npos
)
break
;
if
(
found
==
string
::
npos
)
break
;
base
=
found
+
1
;
base
=
found
+
1
;
}
}
return
result
;
return
result
;
}
}
vector
<
string
>
split
(
const
string
&
s
,
const
string
&
delims
)
{
return
split_impl
<
const
string
&>
(
s
,
delims
);
}
vector
<
string_view
>
split_ro
(
string_view
s
,
string_view
delims
)
{
return
split_impl
<
string_view
>
(
s
,
delims
);
}
native/jni/utils/misc.hpp
View file @
548d70f3
...
@@ -159,7 +159,8 @@ uint32_t binary_gcd(uint32_t u, uint32_t v);
...
@@ -159,7 +159,8 @@ uint32_t binary_gcd(uint32_t u, uint32_t v);
int
switch_mnt_ns
(
int
pid
);
int
switch_mnt_ns
(
int
pid
);
int
gen_rand_str
(
char
*
buf
,
int
len
,
bool
varlen
=
true
);
int
gen_rand_str
(
char
*
buf
,
int
len
,
bool
varlen
=
true
);
std
::
string
&
replace_all
(
std
::
string
&
str
,
std
::
string_view
from
,
std
::
string_view
to
);
std
::
string
&
replace_all
(
std
::
string
&
str
,
std
::
string_view
from
,
std
::
string_view
to
);
std
::
vector
<
std
::
string
>
split
(
const
std
::
string
&
s
,
const
std
::
string
&
delimiters
);
std
::
vector
<
std
::
string
>
split
(
const
std
::
string
&
s
,
const
std
::
string
&
delims
);
std
::
vector
<
std
::
string_view
>
split_ro
(
std
::
string_view
,
std
::
string_view
delims
);
struct
exec_t
{
struct
exec_t
{
bool
err
=
false
;
bool
err
=
false
;
...
...
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