mirror of
https://github.com/topjohnwu/Magisk.git
synced 2025-04-16 08:41:25 +00:00
Several fixes
This commit is contained in:
parent
af7b9ea898
commit
88d19a4ca4
@ -153,13 +153,13 @@ int x_property_set(const char *name, const char *value)
|
|||||||
}
|
}
|
||||||
|
|
||||||
int read_prop_file(const char* filename) {
|
int read_prop_file(const char* filename) {
|
||||||
printf(" Attempting to read props from \'%s\'\n", filename);
|
printf("Attempting to read props from \'%s\'\n", filename);
|
||||||
FILE *fp = fopen(filename, "r");
|
FILE *fp = fopen(filename, "r");
|
||||||
if (fp == NULL) {
|
if (fp == NULL) {
|
||||||
fprintf(stderr, "Cannot open \'%s\'\n", filename);
|
fprintf(stderr, "Cannot open \'%s\'\n", filename);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
char *line = NULL, *pch, name[PROP_NAME_MAX], value[PROP_VALUE_MAX];
|
char *line = NULL, *pch;
|
||||||
size_t len;
|
size_t len;
|
||||||
ssize_t read;
|
ssize_t read;
|
||||||
int comment = 0, i;
|
int comment = 0, i;
|
||||||
|
@ -374,7 +374,7 @@ esac
|
|||||||
|
|
||||||
# All ramdisk patch commands are stored in a separate script
|
# All ramdisk patch commands are stored in a separate script
|
||||||
ui_print "- Patching ramdisk"
|
ui_print "- Patching ramdisk"
|
||||||
. $COMMONDIR/ramdisk_patch.sh $BOOTTMP/ramdisk.cpio
|
source $COMMONDIR/ramdisk_patch.sh $BOOTTMP/ramdisk.cpio
|
||||||
|
|
||||||
cd $BOOTTMP
|
cd $BOOTTMP
|
||||||
# Create ramdisk backups
|
# Create ramdisk backups
|
||||||
|
@ -71,12 +71,14 @@ loopsetup() {
|
|||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
target_size_check() {
|
image_size_check() {
|
||||||
e2fsck -p -f "$1"
|
e2fsck -yf $1
|
||||||
curBlocks=`e2fsck -n $1 2>/dev/null | cut -d, -f3 | cut -d\ -f2`;
|
curBlocks=`e2fsck -n $1 2>/dev/null | cut -d, -f3 | cut -d\ -f2`;
|
||||||
curUsedM=$((`echo "$curBlocks" | cut -d/ -f1` * 4 / 1024));
|
curUsedM=`echo "$curBlocks" | cut -d/ -f1`
|
||||||
curSizeM=$((`echo "$curBlocks" | cut -d/ -f2` * 4 / 1024));
|
curSizeM=`echo "$curBlocks" | cut -d/ -f1`
|
||||||
curFreeM=$((curSizeM - curUsedM));
|
curFreeM=$(((curSizeM - curUsedM) * 4 / 1024))
|
||||||
|
curUsedM=$((curUsedM * 4 / 1024 + 1))
|
||||||
|
curSizeM=$((curSizeM * 4 / 1024))
|
||||||
}
|
}
|
||||||
|
|
||||||
run_scripts() {
|
run_scripts() {
|
||||||
@ -193,11 +195,11 @@ merge_image() {
|
|||||||
log_print "$IMG found, attempt to merge"
|
log_print "$IMG found, attempt to merge"
|
||||||
|
|
||||||
# Handle large images
|
# Handle large images
|
||||||
target_size_check $1
|
image_size_check $1
|
||||||
MERGEUSED=$curUsedM
|
mergeUsedM=$curUsedM
|
||||||
target_size_check $IMG
|
image_size_check $IMG
|
||||||
if [ "$MERGEUSED" -gt "$curFreeM" ]; then
|
if [ "$mergeUsedM" -gt "$curFreeM" ]; then
|
||||||
NEWDATASIZE=$((((MERGEUSED + curUsedM) / 32 + 2) * 32))
|
NEWDATASIZE=$(((mergeUsedM + curUsedM) / 32 * 32 + 32))
|
||||||
log_print "Expanding $IMG to ${NEWDATASIZE}M..."
|
log_print "Expanding $IMG to ${NEWDATASIZE}M..."
|
||||||
resize2fs $IMG ${NEWDATASIZE}M
|
resize2fs $IMG ${NEWDATASIZE}M
|
||||||
fi
|
fi
|
||||||
@ -358,8 +360,8 @@ case $1 in
|
|||||||
# Unmount, shrink, remount
|
# Unmount, shrink, remount
|
||||||
if umount $MOUNTPOINT; then
|
if umount $MOUNTPOINT; then
|
||||||
losetup -d $LOOPDEVICE 2>/dev/null
|
losetup -d $LOOPDEVICE 2>/dev/null
|
||||||
target_size_check $IMG
|
image_size_check $IMG
|
||||||
NEWDATASIZE=$(((curUsedM / 32 + 2) * 32))
|
NEWDATASIZE=$((curUsedM / 32 * 32 + 32))
|
||||||
if [ "$curSizeM" -gt "$NEWDATASIZE" ]; then
|
if [ "$curSizeM" -gt "$NEWDATASIZE" ]; then
|
||||||
log_print "Shrinking $IMG to ${NEWDATASIZE}M..."
|
log_print "Shrinking $IMG to ${NEWDATASIZE}M..."
|
||||||
resize2fs $IMG ${NEWDATASIZE}M
|
resize2fs $IMG ${NEWDATASIZE}M
|
||||||
@ -391,16 +393,23 @@ case $1 in
|
|||||||
mount -o ro,remount rootfs /
|
mount -o ro,remount rootfs /
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Travel through all mods
|
|
||||||
for MOD in $MOUNTPOINT/* ; do
|
for MOD in $MOUNTPOINT/* ; do
|
||||||
if [ -f $MOD/auto_mount -a -d $MOD/system -a ! -f $MOD/disable ]; then
|
if [ ! -f $MOD/disable ]; then
|
||||||
log_print "Analyzing module: $MOD"
|
# Travel through all mods
|
||||||
TRAVEL_ROOT=$MOD
|
if [ -f $MOD/auto_mount -a -d $MOD/system ]; then
|
||||||
(travel system)
|
log_print "Analyzing module: $MOD"
|
||||||
rm -f $MOD/vendor 2>/dev/null
|
TRAVEL_ROOT=$MOD
|
||||||
if [ -d $MOD/system/vendor ]; then
|
(travel system)
|
||||||
ln -s $MOD/system/vendor $MOD/vendor
|
rm -f $MOD/vendor 2>/dev/null
|
||||||
(travel vendor)
|
if [ -d $MOD/system/vendor ]; then
|
||||||
|
ln -s $MOD/system/vendor $MOD/vendor
|
||||||
|
(travel vendor)
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
# Read in defined system props
|
||||||
|
if [ -f $MOD/system.prop ]; then
|
||||||
|
log_print "* Reading props from $MOD/system.prop"
|
||||||
|
$BINPATH/resetprop --file $MOD/system.prop
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
@ -487,14 +496,6 @@ case $1 in
|
|||||||
rm -f /data/magisk/magisk.apk 2>/dev/null
|
rm -f /data/magisk/magisk.apk 2>/dev/null
|
||||||
fi
|
fi
|
||||||
|
|
||||||
for MOD in $MOUNTPOINT/* ; do
|
|
||||||
# Read in defined system props
|
|
||||||
if [ -f $MOD/system.prop ]; then
|
|
||||||
log_print "* Reading props from $MOD/system.prop"
|
|
||||||
/data/magisk/resetprop --file $MOD/system.prop
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
|
|
||||||
# Expose busybox
|
# Expose busybox
|
||||||
[ "`getprop persist.magisk.busybox`" = "1" ] && sh /sbin/magic_mask.sh mount_busybox
|
[ "`getprop persist.magisk.busybox`" = "1" ] && sh /sbin/magic_mask.sh mount_busybox
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user