SYSTEM_DATA_MNT="opt"
USER_MNT="opt/usr"
-
+BTRFS="/usr/sbin/btrfs"
get_partition_id() {
PART_ROOTFS=$("$BLKID" --match-token PARTLABEL=rootfs -o device || "$BLKID" --match-token LABEL=rootfs -o device)
echo "[Debug] Mounted ${PARTITION} as F2FS checkpoint=disable"
}
+mount_btrfs_partition() {
+ LABEL=${1}
+ PARTITION=${2}
+ DIRECTORY=${3}
+ "${MOUNT}" -o rw ${PARTITION} ${DIRECTORY}
+ mkdir -p "${DIRECTORY}/fota"
+ "$BTRFS" subvolume snapshot "$DIRECTORY" "$DIRECTORY/fota/RO_update"
+ echo "[Debug] Mounted ${PARTITION} as btrfs"
+}
+
mount_checkpoint_partition() {
LABEL=${1}
PARTITION=${2}
mount_bow_partition ${LABEL} ${PARTITION} ${DIRECTORY}
elif [ "${FSTYPE}" = "f2fs" ]; then
mount_f2fs_partition ${LABEL} ${PARTITION} ${DIRECTORY}
+ elif [ "${FSTYPE}" = "btrfs" ]; then
+ mount_btrfs_partition ${LABEL} ${PARTITION} ${DIRECTORY}
else
mount ${PARTITION} ${DIRECTORY}
fi
NOTIFY "Changes on partition ${LABEL} commited (f2fs)"
}
+DELETE_BTRFS_PARTITION() {
+ PART="$1"
+ MNT_POINT="$("$FINDMNT" "$PART" -o TARGET)"
+ if [ "$MNT_POINT" = "" ]; then
+ ERROR "Unable to find btrfs mountpoint for: $PART"
+ return
+ fi
+ NOTIFY "Deleting btrfs snapshot"
+ mount -o remount,rw "${MNT_POINT}"
+ btrfs subvolume delete "$MNT_POINT"/fota/RO_update
+ rm -rf "$MNT_POINT/fota/RO_update"
+}
+
+
+COMMIT_BTRFS_PARTITION()
+{
+ LABEL=${1}
+ PART_SYSTEM_DATA=$(blkid --match-token PARTLABEL="${LABEL}" -o device || blkid --match-token LABEL="${LABEL}" -o device)
+ DELETE_BTRFS_PARTITION "${PART_SYSTEM_DATA}"
+ NOTIFY "Changes on partition ${LABEL} commited (btrfs)"
+}
+
COMMIT_PARTITION()
{
LABEL=${1}
COMMIT_BOW_PARTITION "${LABEL}"
elif [ "${TYPE}" = "f2fs" ]; then
COMMIT_F2FS_PARTITION "${LABEL}" ${PART_DEVICE}
+ elif [ "${TYPE}" = "btrfs" ]; then
+ COMMIT_BTRFS_PARTITION "${LABEL}"
else
ERROR "ERROR: Cannot commit ${LABEL}: Unsupported filesystem ${TYPE}"
fi