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
fafa92d4
Commit
fafa92d4
authored
Jan 08, 2020
by
topjohnwu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Simplify rootfs persist mount
parent
242e64d7
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
42 additions
and
41 deletions
+42
-41
init.h
native/jni/init/init.h
+1
-1
mount.cpp
native/jni/init/mount.cpp
+41
-40
No files found.
native/jni/init/init.h
View file @
fafa92d4
...
...
@@ -138,7 +138,7 @@ protected:
void
early_mount
()
override
;
public
:
RootFSInit
(
char
*
argv
[],
cmdline
*
cmd
)
:
MagiskInit
(
argv
,
cmd
)
{
persist_dir
=
"/dev/
.magisk/mirror
/persist/magisk"
;
persist_dir
=
"/dev/
mnt
/persist/magisk"
;
}
void
start
()
override
{
...
...
native/jni/init/mount.cpp
View file @
fafa92d4
...
...
@@ -94,7 +94,7 @@ static bool read_dt_fstab(cmdline *cmd, const char *name) {
char
path
[
128
];
int
fd
;
sprintf
(
path
,
"%s/fstab/%s/dev"
,
cmd
->
dt_dir
,
name
);
if
((
fd
=
x
open
(
path
,
O_RDONLY
|
O_CLOEXEC
))
>=
0
)
{
if
((
fd
=
open
(
path
,
O_RDONLY
|
O_CLOEXEC
))
>=
0
)
{
read
(
fd
,
path
,
sizeof
(
path
));
close
(
fd
);
// Some custom treble use different names, so use what we read
...
...
@@ -119,26 +119,6 @@ if (!is_lnk("/" #name) && read_dt_fstab(cmd, #name)) { \
mount_list.emplace_back("/" #name); \
}
void
RootFSInit
::
early_mount
()
{
full_read
(
"/init"
,
self
.
buf
,
self
.
sz
);
LOGD
(
"Reverting /init
\n
"
);
root
=
xopen
(
"/"
,
O_RDONLY
|
O_CLOEXEC
);
rename
(
"/.backup/init"
,
"/init"
);
// Mount sbin overlay for persist, but move it and add to cleanup list
mount_sbin
();
xmount
(
"/sbin"
,
"/dev"
,
nullptr
,
MS_MOVE
,
nullptr
);
mount_list
.
emplace_back
(
"/dev"
);
mount_list
.
emplace_back
(
"/dev/.magisk/mirror/persist"
);
mount_list
.
emplace_back
(
"/dev/.magisk/mirror/cache"
);
mount_root
(
system
);
mount_root
(
vendor
);
mount_root
(
product
);
mount_root
(
odm
);
}
static
void
switch_root
(
const
string
&
path
)
{
LOGD
(
"Switch root to %s
\n
"
,
path
.
data
());
vector
<
string
>
mounts
;
...
...
@@ -164,6 +144,45 @@ static void switch_root(const string &path) {
chroot
(
"."
);
}
static
void
mount_persist
(
const
char
*
dev_base
,
const
char
*
mnt_base
)
{
string
mnt_point
=
mnt_base
+
"/persist"
s
;
strcpy
(
partname
,
"persist"
);
sprintf
(
block_dev
,
"%s/persist"
,
dev_base
);
if
(
setup_block
(
false
)
<
0
)
{
// Fallback to cache
strcpy
(
partname
,
"cache"
);
sprintf
(
block_dev
,
"%s/cache"
,
dev_base
);
if
(
setup_block
(
false
)
<
0
)
{
// Try NVIDIA's BS
strcpy
(
partname
,
"CAC"
);
if
(
setup_block
(
false
)
<
0
)
return
;
}
xsymlink
(
"./cache"
,
mnt_point
.
data
());
mnt_point
=
mnt_base
+
"/cache"
s
;
}
xmkdir
(
mnt_point
.
data
(),
0755
);
xmount
(
block_dev
,
mnt_point
.
data
(),
"ext4"
,
0
,
nullptr
);
}
void
RootFSInit
::
early_mount
()
{
full_read
(
"/init"
,
self
.
buf
,
self
.
sz
);
LOGD
(
"Reverting /init
\n
"
);
root
=
xopen
(
"/"
,
O_RDONLY
|
O_CLOEXEC
);
rename
(
"/.backup/init"
,
"/init"
);
mount_root
(
system
);
mount_root
(
vendor
);
mount_root
(
product
);
mount_root
(
odm
);
xmkdir
(
"/dev/mnt"
,
0755
);
mount_persist
(
"/dev/block"
,
"/dev/mnt"
);
mount_list
.
emplace_back
(
"/dev/mnt/persist"
);
mount_list
.
emplace_back
(
"/dev/mnt/cache"
);
}
void
SARBase
::
backup_files
()
{
if
(
access
(
"/overlay.d"
,
F_OK
)
==
0
)
cp_afc
(
"/overlay.d"
,
"/dev/overlay.d"
);
...
...
@@ -250,23 +269,5 @@ void mount_sbin() {
xmkdir
(
MIRRDIR
,
0
);
xmkdir
(
BLOCKDIR
,
0
);
// Mount persist partition
strcpy
(
partname
,
"persist"
);
strcpy
(
block_dev
,
BLOCKDIR
"/persist"
);
const
char
*
mnt_point
=
MIRRDIR
"/persist"
;
if
(
setup_block
(
false
)
<
0
)
{
// Fallback to cache
strcpy
(
partname
,
"cache"
);
strcpy
(
block_dev
,
BLOCKDIR
"/cache"
);
if
(
setup_block
(
false
)
<
0
)
{
// Try NVIDIA's BS
strcpy
(
partname
,
"CAC"
);
if
(
setup_block
(
false
)
<
0
)
return
;
}
mnt_point
=
MIRRDIR
"/cache"
;
xsymlink
(
"./cache"
,
MIRRDIR
"/persist"
);
}
xmkdir
(
mnt_point
,
0755
);
xmount
(
block_dev
,
mnt_point
,
"ext4"
,
0
,
nullptr
);
mount_persist
(
BLOCKDIR
,
MIRRDIR
);
}
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