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
9820296e
Commit
9820296e
authored
Apr 02, 2020
by
topjohnwu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update files.cpp in libutils
parent
dbfde74c
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
132 additions
and
158 deletions
+132
-158
rootdir.cpp
native/jni/init/rootdir.cpp
+2
-5
file.cpp
native/jni/utils/file.cpp
+111
-140
files.hpp
native/jni/utils/files.hpp
+14
-13
missing.hpp
native/jni/utils/missing.hpp
+5
-0
No files found.
native/jni/init/rootdir.cpp
View file @
9820296e
...
@@ -107,7 +107,7 @@ void RootFSInit::setup_rootfs() {
...
@@ -107,7 +107,7 @@ void RootFSInit::setup_rootfs() {
if
(
access
(
"/overlay.d"
,
F_OK
)
==
0
)
{
if
(
access
(
"/overlay.d"
,
F_OK
)
==
0
)
{
LOGD
(
"Merge overlay.d
\n
"
);
LOGD
(
"Merge overlay.d
\n
"
);
load_overlay_rc
(
"/overlay.d"
);
load_overlay_rc
(
"/overlay.d"
);
mv_
f
(
"/overlay.d"
,
"/"
);
mv_
path
(
"/overlay.d"
,
"/"
);
}
}
// Patch init.rc
// Patch init.rc
...
@@ -120,10 +120,7 @@ void RootFSInit::setup_rootfs() {
...
@@ -120,10 +120,7 @@ void RootFSInit::setup_rootfs() {
// Create hardlink mirror of /sbin to /root
// Create hardlink mirror of /sbin to /root
mkdir
(
"/root"
,
0750
);
mkdir
(
"/root"
,
0750
);
clone_attr
(
"/sbin"
,
"/root"
);
clone_attr
(
"/sbin"
,
"/root"
);
int
rootdir
=
xopen
(
"/root"
,
O_RDONLY
|
O_CLOEXEC
);
link_path
(
"/sbin"
,
"/root"
);
int
sbin
=
xopen
(
"/sbin"
,
O_RDONLY
|
O_CLOEXEC
);
link_dir
(
sbin
,
rootdir
);
close
(
sbin
);
// Dump magiskinit as magisk
// Dump magiskinit as magisk
int
fd
=
xopen
(
"/sbin/magisk"
,
O_WRONLY
|
O_CREAT
,
0755
);
int
fd
=
xopen
(
"/sbin/magisk"
,
O_WRONLY
|
O_CREAT
,
0755
);
...
...
native/jni/utils/file.cpp
View file @
9820296e
This diff is collapsed.
Click to expand it.
native/jni/utils/files.hpp
View file @
9820296e
...
@@ -41,20 +41,21 @@ struct raw_file {
...
@@ -41,20 +41,21 @@ struct raw_file {
ssize_t
fd_path
(
int
fd
,
char
*
path
,
size_t
size
);
ssize_t
fd_path
(
int
fd
,
char
*
path
,
size_t
size
);
int
fd_pathat
(
int
dirfd
,
const
char
*
name
,
char
*
path
,
size_t
size
);
int
fd_pathat
(
int
dirfd
,
const
char
*
name
,
char
*
path
,
size_t
size
);
int
mkdirs
(
const
char
*
pathname
,
mode_t
mode
);
int
mkdirs
(
std
::
string
path
,
mode_t
mode
);
void
rm_rf
(
const
char
*
path
);
void
rm_rf
(
const
char
*
path
);
void
mv_
f
(
const
char
*
source
,
const
char
*
destination
);
void
mv_
path
(
const
char
*
src
,
const
char
*
dest
);
void
mv_dir
(
int
src
,
int
dest
);
void
mv_dir
(
int
src
,
int
dest
);
void
cp_afc
(
const
char
*
source
,
const
char
*
destination
);
void
cp_afc
(
const
char
*
src
,
const
char
*
dest
);
void
link_path
(
const
char
*
src
,
const
char
*
dest
);
void
link_dir
(
int
src
,
int
dest
);
void
link_dir
(
int
src
,
int
dest
);
int
getattr
(
const
char
*
path
,
struct
file_attr
*
a
);
int
getattr
(
const
char
*
path
,
file_attr
*
a
);
int
getattrat
(
int
dirfd
,
const
char
*
name
,
struct
file_attr
*
a
);
int
getattrat
(
int
dirfd
,
const
char
*
name
,
file_attr
*
a
);
int
fgetattr
(
int
fd
,
struct
file_attr
*
a
);
int
fgetattr
(
int
fd
,
file_attr
*
a
);
int
setattr
(
const
char
*
path
,
struct
file_attr
*
a
);
int
setattr
(
const
char
*
path
,
file_attr
*
a
);
int
setattrat
(
int
dirfd
,
const
char
*
name
,
struct
file_attr
*
a
);
int
setattrat
(
int
dirfd
,
const
char
*
name
,
file_attr
*
a
);
int
fsetattr
(
int
fd
,
struct
file_attr
*
a
);
int
fsetattr
(
int
fd
,
file_attr
*
a
);
void
fclone_attr
(
int
s
ourcefd
,
int
targetfd
);
void
fclone_attr
(
int
s
rc
,
int
dest
);
void
clone_attr
(
const
char
*
s
ource
,
const
char
*
targe
t
);
void
clone_attr
(
const
char
*
s
rc
,
const
char
*
des
t
);
void
fd_full_read
(
int
fd
,
void
**
buf
,
size_t
*
size
);
void
fd_full_read
(
int
fd
,
void
**
buf
,
size_t
*
size
);
void
full_read
(
const
char
*
filename
,
void
**
buf
,
size_t
*
size
);
void
full_read
(
const
char
*
filename
,
void
**
buf
,
size_t
*
size
);
void
write_zero
(
int
fd
,
size_t
size
);
void
write_zero
(
int
fd
,
size_t
size
);
...
@@ -64,10 +65,10 @@ static inline void file_readline(const char *file,
...
@@ -64,10 +65,10 @@ static inline void file_readline(const char *file,
file_readline
(
false
,
file
,
fn
);
file_readline
(
false
,
file
,
fn
);
}
}
void
parse_prop_file
(
const
char
*
file
,
void
parse_prop_file
(
const
char
*
file
,
const
std
::
function
<
bool
(
std
::
string_view
,
std
::
string_view
)
>
&
fn
);
const
std
::
function
<
bool
(
std
::
string_view
,
std
::
string_view
)
>
&
&
fn
);
void
*
__mmap
(
const
char
*
filename
,
size_t
*
size
,
bool
rw
);
void
*
__mmap
(
const
char
*
filename
,
size_t
*
size
,
bool
rw
);
void
frm_rf
(
int
dirfd
);
void
frm_rf
(
int
dirfd
);
void
clone_dir
(
int
src
,
int
dest
,
bool
overwrite
=
true
);
void
clone_dir
(
int
src
,
int
dest
);
void
parse_mnt
(
const
char
*
file
,
const
std
::
function
<
bool
(
mntent
*
)
>
&
fn
);
void
parse_mnt
(
const
char
*
file
,
const
std
::
function
<
bool
(
mntent
*
)
>
&
fn
);
void
backup_folder
(
const
char
*
dir
,
std
::
vector
<
raw_file
>
&
files
);
void
backup_folder
(
const
char
*
dir
,
std
::
vector
<
raw_file
>
&
files
);
void
restore_folder
(
const
char
*
dir
,
std
::
vector
<
raw_file
>
&
files
);
void
restore_folder
(
const
char
*
dir
,
std
::
vector
<
raw_file
>
&
files
);
...
...
native/jni/utils/missing.hpp
View file @
9820296e
...
@@ -18,6 +18,7 @@
...
@@ -18,6 +18,7 @@
#define setmntent __setmntent
#define setmntent __setmntent
#define endmntent __endmntent
#define endmntent __endmntent
#define hasmntopt __hasmntopt
#define hasmntopt __hasmntopt
#define faccessat __faccessat
ssize_t
__getline
(
char
**
lineptr
,
size_t
*
n
,
FILE
*
stream
);
ssize_t
__getline
(
char
**
lineptr
,
size_t
*
n
,
FILE
*
stream
);
ssize_t
__getdelim
(
char
**
lineptr
,
size_t
*
n
,
int
delim
,
FILE
*
stream
);
ssize_t
__getdelim
(
char
**
lineptr
,
size_t
*
n
,
int
delim
,
FILE
*
stream
);
...
@@ -58,3 +59,7 @@ static inline int __linkat(int olddirfd, const char *oldpath,
...
@@ -58,3 +59,7 @@ static inline int __linkat(int olddirfd, const char *oldpath,
static
inline
int
__inotify_init1
(
int
flags
)
{
static
inline
int
__inotify_init1
(
int
flags
)
{
return
syscall
(
__NR_inotify_init1
,
flags
);
return
syscall
(
__NR_inotify_init1
,
flags
);
}
}
static
inline
int
__faccessat
(
int
dirfd
,
const
char
*
pathname
,
int
mode
,
int
flags
)
{
return
syscall
(
__NR_faccessat
,
dirfd
,
pathname
,
mode
,
flags
);
}
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