Several fixes

This commit is contained in:
topjohnwu 2017-03-18 16:57:04 +08:00
parent af7b9ea898
commit 88d19a4ca4
3 changed files with 33 additions and 32 deletions

View File

@ -153,13 +153,13 @@ int x_property_set(const char *name, const char *value)
}
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");
if (fp == NULL) {
fprintf(stderr, "Cannot open \'%s\'\n", filename);
return 1;
}
char *line = NULL, *pch, name[PROP_NAME_MAX], value[PROP_VALUE_MAX];
char *line = NULL, *pch;
size_t len;
ssize_t read;
int comment = 0, i;

View File

@ -374,7 +374,7 @@ esac
# All ramdisk patch commands are stored in a separate script
ui_print "- Patching ramdisk"
. $COMMONDIR/ramdisk_patch.sh $BOOTTMP/ramdisk.cpio
source $COMMONDIR/ramdisk_patch.sh $BOOTTMP/ramdisk.cpio
cd $BOOTTMP
# Create ramdisk backups

View File

@ -71,12 +71,14 @@ loopsetup() {
done
}
target_size_check() {
e2fsck -p -f "$1"
image_size_check() {
e2fsck -yf $1
curBlocks=`e2fsck -n $1 2>/dev/null | cut -d, -f3 | cut -d\ -f2`;
curUsedM=$((`echo "$curBlocks" | cut -d/ -f1` * 4 / 1024));
curSizeM=$((`echo "$curBlocks" | cut -d/ -f2` * 4 / 1024));
curFreeM=$((curSizeM - curUsedM));
curUsedM=`echo "$curBlocks" | cut -d/ -f1`
curSizeM=`echo "$curBlocks" | cut -d/ -f1`
curFreeM=$(((curSizeM - curUsedM) * 4 / 1024))
curUsedM=$((curUsedM * 4 / 1024 + 1))
curSizeM=$((curSizeM * 4 / 1024))
}
run_scripts() {
@ -193,11 +195,11 @@ merge_image() {
log_print "$IMG found, attempt to merge"
# Handle large images
target_size_check $1
MERGEUSED=$curUsedM
target_size_check $IMG
if [ "$MERGEUSED" -gt "$curFreeM" ]; then
NEWDATASIZE=$((((MERGEUSED + curUsedM) / 32 + 2) * 32))
image_size_check $1
mergeUsedM=$curUsedM
image_size_check $IMG
if [ "$mergeUsedM" -gt "$curFreeM" ]; then
NEWDATASIZE=$(((mergeUsedM + curUsedM) / 32 * 32 + 32))
log_print "Expanding $IMG to ${NEWDATASIZE}M..."
resize2fs $IMG ${NEWDATASIZE}M
fi
@ -358,8 +360,8 @@ case $1 in
# Unmount, shrink, remount
if umount $MOUNTPOINT; then
losetup -d $LOOPDEVICE 2>/dev/null
target_size_check $IMG
NEWDATASIZE=$(((curUsedM / 32 + 2) * 32))
image_size_check $IMG
NEWDATASIZE=$((curUsedM / 32 * 32 + 32))
if [ "$curSizeM" -gt "$NEWDATASIZE" ]; then
log_print "Shrinking $IMG to ${NEWDATASIZE}M..."
resize2fs $IMG ${NEWDATASIZE}M
@ -391,16 +393,23 @@ case $1 in
mount -o ro,remount rootfs /
fi
# Travel through all mods
for MOD in $MOUNTPOINT/* ; do
if [ -f $MOD/auto_mount -a -d $MOD/system -a ! -f $MOD/disable ]; then
log_print "Analyzing module: $MOD"
TRAVEL_ROOT=$MOD
(travel system)
rm -f $MOD/vendor 2>/dev/null
if [ -d $MOD/system/vendor ]; then
ln -s $MOD/system/vendor $MOD/vendor
(travel vendor)
if [ ! -f $MOD/disable ]; then
# Travel through all mods
if [ -f $MOD/auto_mount -a -d $MOD/system ]; then
log_print "Analyzing module: $MOD"
TRAVEL_ROOT=$MOD
(travel system)
rm -f $MOD/vendor 2>/dev/null
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
done
@ -487,14 +496,6 @@ case $1 in
rm -f /data/magisk/magisk.apk 2>/dev/null
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
[ "`getprop persist.magisk.busybox`" = "1" ] && sh /sbin/magic_mask.sh mount_busybox