fi
PART_USER=$("$BLKID" --match-token PARTLABEL=user -o device -l || "$BLKID" --match-token LABEL=user -o device -l)
+
+ return 0
}
mount_bow_partition() {
DM_NUMBER=$(($("${STAT}" -c "0x%T" $(readlink -f "${BOWDEV_PATH}"))))
echo 1 > /sys/block/dm-${DM_NUMBER}/bow/state
log "[Debug] Mounted ${PARTITION} as DM-BOW" "${INT_LOG_FILE}"
+
+ return 0
}
mount_f2fs_partition() {
return 1
fi
log "[Debug] Mounted ${PARTITION} as F2FS checkpoint=disable" "${INT_LOG_FILE}"
+
+ return 0
}
mount_checkpoint_partition() {
"${MOUNT}" "${PARTITION}" "${DIRECTORY}"
log "[Info] Unsupported filesystem ${FSTYPE} on ${PARTITION}" "${INT_LOG_FILE}"
fi
+
+ return 0
}
commit_bow_partition()
DM_NUMBER=$(($("${STAT}" -c "0x%T" $(readlink -f "${BOWDEV_PATH}"))))
echo 2 > /sys/block/dm-${DM_NUMBER}/bow/state
log "[Info] Changes on partition ${LABEL} commited (dm-bow)" "${INT_LOG_FILE}"
+
+ return 0
}
commit_f2fs_partition()
PART_SYSTEM_DATA=$(blkid --match-token PARTLABEL="${LABEL}" -o device -l || blkid --match-token LABEL="${LABEL}" -o device -l)
"${MOUNT}" -o remount,checkpoint=enable "${PART_SYSTEM_DATA}"
log "[Info] Changes on partition ${LABEL} commited (f2fs)" "${INT_LOG_FILE}"
+
+ return 0
}
commit_partition()
MNT_POINT=${2}
TYPE=$(blkid --match-token PARTLABEL="${LABEL}" -o value -s TYPE || blkid --match-token LABEL="${LABEL}" -o value -s TYPE | tail -n 1)
if [ "${TYPE}" = "ext4" ]; then
- commit_bow_partition "${LABEL}"
+ if ! commit_bow_partition "${LABEL}"; then
+ return 1
+ fi
elif [ "${TYPE}" = "f2fs" ]; then
- commit_f2fs_partition "${LABEL}"
+ if ! commit_f2fs_partition "${LABEL}"; then
+ return 1
+ fi
else
log "[Info] Cannot commit ${LABEL}: Unsupported filesystem ${TYPE}" "${INT_LOG_FILE}"
fi
+
+ return 0
}
mount_rootfs()
echo "verifyboot: disabling"
;;
esac
- "$MOUNT" -o ro "${PART_ROOTFS}" "${FAKE_ROOT}"
+
+ if ! "$MOUNT" -o ro "${PART_ROOTFS}" "${FAKE_ROOT}"; then
+ return 1
+ fi
+
+ return 0
}
#------------------------------------------------
# Therefore rootfs should be mounted as RO.
# We cannot mount rootfs as RW because mount timestamp would
# change and dmverity data would become incorrect
- mount_rootfs
+ if ! mount_rootfs; then
+ return 1
+ fi
else
if ! mount_checkpoint_partition rootfs "${PART_ROOTFS}" "${FAKE_ROOT}"; then
return 1
return 1
fi
else
- "$MOUNT" -o ro "${PART_HAL}" "${FAKE_ROOT}/${HAL_MNT}"
+ if ! "$MOUNT" -o ro "${PART_HAL}" "${FAKE_ROOT}/${HAL_MNT}"; then
+ return 1
+ fi
fi
fi
- "$MOUNT" -t proc none "${FAKE_ROOT}/proc"
- "$MOUNT" -t sysfs none "${FAKE_ROOT}/sys"
- "$MOUNT" -t devtmpfs devtmpfs "${FAKE_ROOT}/dev"
+ "$MOUNT" -t proc none "${FAKE_ROOT}/proc" &&
+ "$MOUNT" -t sysfs none "${FAKE_ROOT}/sys" &&
+ "$MOUNT" -t devtmpfs devtmpfs "${FAKE_ROOT}/dev" &&
"$MOUNT" -t devpts devpts "${FAKE_ROOT}/dev/pts"
+
+ if [ $? -ne 0 ]; then
+ return 1
+ fi
+
+ return 0
}
umount_bow_partition()
LABEL=${1}
PART=${2}
- "$UMOUNT" "${PART}"
+ if ! "$UMOUNT" "${PART}"; then
+ return 1
+ fi
BOWDEV_NAME=bowdev_${LABEL}
- "${DMSETUP}" remove ${BOWDEV_NAME}
+ if ! "${DMSETUP}" remove ${BOWDEV_NAME}; then
+ return 1
+ fi
+
+ return 0
}
umount_partition()
TYPE=$(blkid --match-token PARTLABEL="${LABEL}" -o value -s TYPE || blkid --match-token LABEL="${LABEL}" -o value -s TYPE | tail -n 1)
if [ "${TYPE}" = "ext4" ]; then
- umount_bow_partition "${LABEL}" "${DIRECTORY}"
+ if ! umount_bow_partition "${LABEL}" "${DIRECTORY}"; then
+ return 1
+ fi
else
- "$UMOUNT" "${DIRECTORY}"
+ if ! "$UMOUNT" "${DIRECTORY}"; then
+ return 1
+ fi
fi
+
+ return 0
}
#------------------------------------------------
if [ "${P_SUFFIX}" == "" ]; then
if [ ! "z${PART_HAL}" = "z" ]; then
if [ "${UPGRADE_SUCCESS}" = "1" ]; then
- commit_partition hal "${FAKE_ROOT}/${HAL_MNT}"
+ if ! commit_partition hal "${FAKE_ROOT}/${HAL_MNT}"; then
+ return 1
+ fi
+ fi
+ if ! umount_partition hal "${FAKE_ROOT}/${HAL_MNT}"; then
+ return 1
fi
- umount_partition hal "${FAKE_ROOT}/${HAL_MNT}"
fi
else
- "$UMOUNT" "${FAKE_ROOT}/${HAL_MNT}"
+ if ! "$UMOUNT" "${FAKE_ROOT}/${HAL_MNT}"; then
+ return 1
+ fi
fi
if [ ! "z${PART_USER}" = "z" ]; then
if [ "${UPGRADE_SUCCESS}" = "1" ]; then
- commit_partition user "${FAKE_ROOT}/${USER_MNT}"
+ if ! commit_partition user "${FAKE_ROOT}/${USER_MNT}"; then
+ return 1
+ fi
+ fi
+ if ! umount_partition user "${FAKE_ROOT}/${USER_MNT}"; then
+ return 1
fi
- umount_partition user "${FAKE_ROOT}/${USER_MNT}"
fi
if [ "${UPGRADE_SUCCESS}" = "1" ]; then
- commit_partition system-data "${FAKE_ROOT}/${SYSTEM_DATA_MNT}"
+ if ! commit_partition system-data "${FAKE_ROOT}/${SYSTEM_DATA_MNT}"; then
+ return 1
+ fi
+ fi
+ if ! umount_partition system-data "${FAKE_ROOT}/${SYSTEM_DATA_MNT}"; then
+ return 1
fi
- umount_partition system-data "${FAKE_ROOT}/${SYSTEM_DATA_MNT}"
if [[ "${P_SLOT}" != "" ]]
then
- "$UMOUNT" "${FAKE_ROOT}"
+ if ! "$UMOUNT" "${FAKE_ROOT}"; then
+ return 1
+ fi
else
if [ "${UPGRADE_SUCCESS}" = "1" ]; then
- commit_partition rootfs "${FAKE_ROOT}"
+ if ! commit_partition rootfs "${FAKE_ROOT}"; then
+ return 1
+ fi
+ fi
+ if ! umount_partition rootfs "${FAKE_ROOT}"; then
+ return 1
fi
- umount_partition rootfs "${FAKE_ROOT}"
fi
# close dm-verity
- /usr/bin/verityctl close rootfs
+ if ! /usr/bin/verityctl close rootfs; then
+ return 1
+ fi
+
+ return 0
}
#------------------------------------------------
#------------------------------------------------
handle_no_delta() {
log "[Error] delta does not exist ..." "${INT_LOG_FILE}"
-
echo "${UPI_NO_DELTA_ERROR}" > "${RESULT_FILE}"
+
+ return 0
}
#------------------------------------------------
#------------------------------------------------
handle_no_ua() {
log "[Error] ua does not exist ..." "${INT_LOG_FILE}"
-
echo "${UPI_NO_UA_ERROR}" > "${RESULT_FILE}"
+
+ return 0
}
#------------------------------------------------
echo "$PART_NUM" > "${PART_TBL_PATH}"
echo "$PART_LIST" >> "${PART_TBL_PATH}"
"$SYNC"
+
+ return 0
}
#------------------------------------------------
if [ -e "${INT_LOG_FILE}" ]; then
/bin/rm -fr "${INT_LOG_FILE}"
fi
+
+ return 0
}
fi
fi
done
+
+ return 0
}
#------------------------------------------------
umount_partitions
exec /sbin/fus_rw-init
fi
+
+ return 1
}
#------------------------------------------------
log "[Info] GUI Enabled" "${INT_LOG_FILE}"
FOTA_GUI_ENABLE=1
fi
+
+ return 0
}
#------------------------------------------------
log "[Info] Warning: somebody made non-root debug mode file... ignore it"
fi
fi
+
+ return 0
}
#------------------------------------------------
#------------------------------------------------
mark_rw_update() {
echo "start" > ${STATUS_FILE}
+ return 0
}
#------------------------------------------------
#------------------------------------------------
prepare_fakeroot() {
mkdir -p ${FAKE_ROOT}
+ return 0
}
#------------------------------------------------
CMDLINE_PARTITION_AB=$([[ $(</proc/cmdline) =~ (partition_ab=[ab]) ]]; echo ${BASH_REMATCH[1]})
CMDLINE_BOOTMODE=$([[ $(</proc/cmdline) =~ (bootmode=[^ ]*) ]]; echo ${BASH_REMATCH[1]})
log "[Info] Initrd-fota booting (/proc/cmdline $CMDLINE_BOOTMODE $CMDLINE_PARTITION_AB $CMDLINE_ROOT)"
+ return 0
}
#------------------------------------------------
fi
PART_USER=$("$BLKID" --match-token PARTLABEL=user -o device -l || "$BLKID" --match-token LABEL=user -o device -l)
+
+ return 0
}
#------------------------------------------------
echo "verifyboot: disabling"
;;
esac
- "$MOUNT" -o ro "${PART_ROOTFS}" "${FAKE_ROOT}"
+
+ if ! "$MOUNT" -o ro "${PART_ROOTFS}" "${FAKE_ROOT}"; then
+ return 1
+ fi
+
+ return 0
}
mount_hal() {
if [ "z${PART_HAL}" = "z" ]; then
# No hal partition
- return
+ return 2
fi
- "$MOUNT" -o ro "${PART_HAL}" "${FAKE_ROOT}/${HAL_MNT}"
+ if ! "$MOUNT" -o ro "${PART_HAL}" "${FAKE_ROOT}/${HAL_MNT}"; then
+ return 1
+ fi
+
+ return 0
}
#------------------------------------------------
# mount_partitions
#------------------------------------------------
mount_partitions() {
- get_partition_id
-
- mount_rootfs
- mount_hal
- "$MOUNT" -t proc none ${FAKE_ROOT}/proc
- "$MOUNT" -t sysfs none ${FAKE_ROOT}/sys
- "$MOUNT" -t devtmpfs devtmpfs ${FAKE_ROOT}/dev
- "$MOUNT" -t devpts devpts ${FAKE_ROOT}/dev/pts
+ get_partition_id &&
+ mount_rootfs &&
+ mount_hal &&
+ "$MOUNT" -t proc none ${FAKE_ROOT}/proc &&
+ "$MOUNT" -t sysfs none ${FAKE_ROOT}/sys &&
+ "$MOUNT" -t devtmpfs devtmpfs ${FAKE_ROOT}/dev &&
+ "$MOUNT" -t devpts devpts ${FAKE_ROOT}/dev/pts &&
"$MOUNT" -t tmpfs tmpfs ${FAKE_ROOT}/tmp
+
+ if [ $? -ne 0 ]; then
+ return 1
+ fi
+
+ return 0
}
#------------------------------------------------
#------------------------------------------------
prepare_fakeroot() {
mkdir -p ${FAKE_ROOT}
+ return 0
}
#------------------------------------------------