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
12831675
Commit
12831675
authored
Jul 06, 2018
by
topjohnwu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Maintain our own set of loop devices
parent
23c2e229
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
32 additions
and
11 deletions
+32
-11
bootstages.c
native/jni/core/bootstages.c
+1
-0
magisk.h
native/jni/include/magisk.h
+1
-0
img.c
native/jni/utils/img.c
+30
-11
No files found.
native/jni/core/bootstages.c
View file @
12831675
...
@@ -612,6 +612,7 @@ void startup() {
...
@@ -612,6 +612,7 @@ void startup() {
xmkdir
(
MIRRDIR
"/bin"
,
0755
);
xmkdir
(
MIRRDIR
"/bin"
,
0755
);
xmkdir
(
BBPATH
,
0755
);
xmkdir
(
BBPATH
,
0755
);
xmkdir
(
MOUNTPOINT
,
0755
);
xmkdir
(
MOUNTPOINT
,
0755
);
xmkdir
(
BLOCKDIR
,
0755
);
LOGI
(
"* Mounting mirrors"
);
LOGI
(
"* Mounting mirrors"
);
struct
vector
mounts
;
struct
vector
mounts
;
...
...
native/jni/include/magisk.h
View file @
12831675
...
@@ -19,6 +19,7 @@
...
@@ -19,6 +19,7 @@
#define UNBLOCKFILE "/dev/.magisk.unblock"
#define UNBLOCKFILE "/dev/.magisk.unblock"
#define DISABLEFILE "/cache/.disable_magisk"
#define DISABLEFILE "/cache/.disable_magisk"
#define MAGISKTMP "/sbin/.core"
#define MAGISKTMP "/sbin/.core"
#define BLOCKDIR MAGISKTMP "/block"
#define MIRRDIR MAGISKTMP "/mirror"
#define MIRRDIR MAGISKTMP "/mirror"
#define BBPATH MAGISKTMP "/busybox"
#define BBPATH MAGISKTMP "/busybox"
#define MOUNTPOINT MAGISKTMP "/img"
#define MOUNTPOINT MAGISKTMP "/img"
...
...
native/jni/utils/img.c
View file @
12831675
...
@@ -9,6 +9,7 @@
...
@@ -9,6 +9,7 @@
#include <sys/mount.h>
#include <sys/mount.h>
#include <sys/sendfile.h>
#include <sys/sendfile.h>
#include <sys/statvfs.h>
#include <sys/statvfs.h>
#include <sys/sysmacros.h>
#include <linux/loop.h>
#include <linux/loop.h>
#include "magisk.h"
#include "magisk.h"
...
@@ -26,23 +27,41 @@ struct fs_info {
...
@@ -26,23 +27,41 @@ struct fs_info {
};
};
static
char
*
loopsetup
(
const
char
*
img
)
{
static
char
*
loopsetup
(
const
char
*
img
)
{
char
device
[
20
];
char
device
[
32
];
struct
loop_info64
info
;
struct
loop_info64
info
;
int
i
,
lfd
,
ffd
;
int
lfd
=
-
1
,
ffd
;
memset
(
&
info
,
0
,
sizeof
(
info
));
memset
(
&
info
,
0
,
sizeof
(
info
));
// First get an empty loop device
if
(
access
(
BLOCKDIR
,
F_OK
)
==
0
)
{
for
(
i
=
0
;
i
<=
7
;
++
i
)
{
for
(
int
i
=
8
;
i
<
100
;
++
i
)
{
sprintf
(
device
,
BLOCKDIR
"/loop%02d"
,
i
);
if
(
access
(
device
,
F_OK
)
!=
0
)
mknod
(
device
,
S_IFBLK
|
0600
,
makedev
(
7
,
i
*
8
));
lfd
=
open
(
device
,
O_RDWR
);
if
(
lfd
<
0
)
/* Kernel does not support this */
break
;
if
(
ioctl
(
lfd
,
LOOP_GET_STATUS64
,
&
info
)
==
-
1
)
break
;
close
(
lfd
);
lfd
=
-
1
;
}
}
// Fallback to existing loop in dev, but in reverse order
if
(
lfd
<
0
)
{
for
(
int
i
=
7
;
i
>=
0
;
--
i
)
{
sprintf
(
device
,
"/dev/block/loop%d"
,
i
);
sprintf
(
device
,
"/dev/block/loop%d"
,
i
);
lfd
=
xopen
(
device
,
O_RDWR
);
lfd
=
xopen
(
device
,
O_RDWR
);
if
(
ioctl
(
lfd
,
LOOP_GET_STATUS64
,
&
info
)
==
-
1
)
if
(
ioctl
(
lfd
,
LOOP_GET_STATUS64
,
&
info
)
==
-
1
)
break
;
break
;
close
(
lfd
);
close
(
lfd
);
lfd
=
-
1
;
}
}
if
(
i
==
8
)
return
NULL
;
}
if
(
lfd
<
0
)
return
NULL
;
ffd
=
xopen
(
img
,
O_RDWR
);
ffd
=
xopen
(
img
,
O_RDWR
);
if
(
ioctl
(
lfd
,
LOOP_SET_FD
,
ffd
)
==
-
1
)
if
(
ioctl
(
lfd
,
LOOP_SET_FD
,
ffd
)
==
-
1
)
return
NULL
;
return
NULL
;
str
cpy
((
char
*
)
info
.
lo_file_name
,
img
);
str
ncpy
((
char
*
)
info
.
lo_file_name
,
img
,
sizeof
(
info
.
lo_file_name
)
);
ioctl
(
lfd
,
LOOP_SET_STATUS64
,
&
info
);
ioctl
(
lfd
,
LOOP_SET_STATUS64
,
&
info
);
close
(
lfd
);
close
(
lfd
);
close
(
ffd
);
close
(
ffd
);
...
...
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