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
2a7e2c70
Commit
2a7e2c70
authored
Aug 11, 2017
by
topjohnwu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Extract functions
parent
8d431b67
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
44 additions
and
43 deletions
+44
-43
bootstages.c
jni/daemon/bootstages.c
+44
-34
utils.h
jni/include/utils.h
+0
-1
misc.c
jni/utils/misc.c
+0
-8
No files found.
jni/daemon/bootstages.c
View file @
2a7e2c70
...
...
@@ -24,6 +24,7 @@
static
char
*
buf
,
*
buf2
;
static
struct
vector
module_list
;
static
int
seperate_vendor
=
0
;
#ifdef MAGISK_DEBUG
static
int
debug_log_pid
,
debug_log_fd
;
...
...
@@ -363,6 +364,48 @@ static void simple_mount(const char *path) {
closedir
(
dir
);
}
/*****************
* Miscellaneous *
*****************/
static
void
mount_mirrors
()
{
LOGI
(
"* Mounting mirrors"
);
struct
vector
mounts
;
vec_init
(
&
mounts
);
file_to_vector
(
"/proc/mounts"
,
&
mounts
);
char
*
line
;
vec_for_each
(
&
mounts
,
line
)
{
if
(
strstr
(
line
,
" /system "
))
{
sscanf
(
line
,
"%s"
,
buf
);
xmkdir_p
(
MIRRDIR
"/system"
,
0755
);
xmount
(
buf
,
MIRRDIR
"/system"
,
"ext4"
,
MS_RDONLY
,
NULL
);
LOGI
(
"mount: %s -> %s
\n
"
,
buf
,
MIRRDIR
"/system"
);
continue
;
}
if
(
strstr
(
line
,
" /vendor "
))
{
seperate_vendor
=
1
;
sscanf
(
line
,
"%s"
,
buf
);
xmkdir_p
(
MIRRDIR
"/vendor"
,
0755
);
xmount
(
buf
,
MIRRDIR
"/vendor"
,
"ext4"
,
MS_RDONLY
,
NULL
);
LOGI
(
"mount: %s -> %s
\n
"
,
buf
,
MIRRDIR
"/vendor"
);
continue
;
}
}
vec_deep_destroy
(
&
mounts
);
if
(
!
seperate_vendor
)
{
symlink
(
MIRRDIR
"/system/vendor"
,
MIRRDIR
"/vendor"
);
LOGI
(
"link: %s -> %s
\n
"
,
MIRRDIR
"/system/vendor"
,
MIRRDIR
"/vendor"
);
}
}
static
void
link_busybox
()
{
mkdir_p
(
BBPATH
,
0755
);
char
*
const
command
[]
=
{
"busybox"
,
"--install"
,
"-s"
,
BBPATH
,
NULL
};
int
pid
=
run_command
(
0
,
NULL
,
NULL
,
BBBIN
,
command
);
if
(
pid
!=
-
1
)
waitpid
(
pid
,
NULL
,
0
);
}
/****************
* Entry points *
****************/
...
...
@@ -454,6 +497,7 @@ void post_fs_data(int client) {
}
// Link busybox
mount_mirrors
();
link_busybox
();
// uninstaller
...
...
@@ -568,40 +612,6 @@ void post_fs_data(int client) {
free
(
magiskloop
);
if
(
has_modules
)
{
// Mount mirrors
LOGI
(
"* Mounting system/vendor mirrors"
);
int
seperate_vendor
=
0
;
struct
vector
mounts
;
vec_init
(
&
mounts
);
file_to_vector
(
"/proc/mounts"
,
&
mounts
);
char
*
line
;
vec_for_each
(
&
mounts
,
line
)
{
if
(
strstr
(
line
,
" /system "
))
{
sscanf
(
line
,
"%s"
,
buf
);
snprintf
(
buf2
,
PATH_MAX
,
"%s/system"
,
MIRRDIR
);
xmkdir_p
(
buf2
,
0755
);
xmount
(
buf
,
buf2
,
"ext4"
,
MS_RDONLY
,
NULL
);
LOGI
(
"mount: %s -> %s
\n
"
,
buf
,
buf2
);
continue
;
}
if
(
strstr
(
line
,
" /vendor "
))
{
seperate_vendor
=
1
;
sscanf
(
line
,
"%s"
,
buf
);
snprintf
(
buf2
,
PATH_MAX
,
"%s/vendor"
,
MIRRDIR
);
xmkdir_p
(
buf2
,
0755
);
xmount
(
buf
,
buf2
,
"ext4"
,
MS_RDONLY
,
NULL
);
LOGI
(
"mount: %s -> %s
\n
"
,
buf
,
buf2
);
continue
;
}
}
vec_deep_destroy
(
&
mounts
);
if
(
!
seperate_vendor
)
{
snprintf
(
buf
,
PATH_MAX
,
"%s/system/vendor"
,
MIRRDIR
);
snprintf
(
buf2
,
PATH_MAX
,
"%s/vendor"
,
MIRRDIR
);
symlink
(
buf
,
buf2
);
LOGI
(
"link: %s -> %s
\n
"
,
buf
,
buf2
);
}
// Extract the vendor node out of system tree and swap with placeholder
vec_for_each
(
sys_root
->
children
,
child
)
{
if
(
strcmp
(
child
->
name
,
"vendor"
)
==
0
)
{
...
...
jni/include/utils.h
View file @
2a7e2c70
...
...
@@ -93,7 +93,6 @@ void fclone_attr(const int sourcefd, const int targetfd);
void
clone_attr
(
const
char
*
source
,
const
char
*
target
);
void
get_client_cred
(
int
fd
,
struct
ucred
*
cred
);
int
switch_mnt_ns
(
int
pid
);
void
link_busybox
();
// img.c
...
...
jni/utils/misc.c
View file @
2a7e2c70
...
...
@@ -409,11 +409,3 @@ int switch_mnt_ns(int pid) {
close
(
fd
);
return
ret
;
}
void
link_busybox
()
{
mkdir_p
(
BBPATH
,
0755
);
char
*
const
command
[]
=
{
"busybox"
,
"--install"
,
"-s"
,
BBPATH
,
NULL
};
int
pid
=
run_command
(
0
,
NULL
,
NULL
,
BBBIN
,
command
);
if
(
pid
!=
-
1
)
waitpid
(
pid
,
NULL
,
0
);
}
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