1,将QNX imge转换成android sparse镜像
这个QNX镜像可以是直接从QNX分区读取得到或者你的刷机包中的镜像:
root@ubuntu:~/workspace/$ file qnx_img.img
qnx_img.img: DOS/MBR boot sector
使用python tools/mksparse.py $镜像文件 转换为android sparse镜像
mksparse.py通常位于QNX 源码路径下的target目录中
root@ubuntu:~/workspace/$ file qnx_img.img.sparse
qnx_img.img.sparse: Android sparse image, version: 1.0, Total of 786432 4096-byte output blocks in 1674 input chunks.
2,android sparse镜像转换为qnx6镜像,这个工具需要安装一下,通过apt-get就可以安装
simg2img $image_file.sparse $image_file.sparse.qnx6
3, 通过loop设备挂载qnx6 镜像
sudo losetup $loop_device $image_file.sparse.qnx6
sudo mount -t qnx6 $loop_device $mount_path
#!/bin/bash
# Function to display help information
display_help() {
echo "Usage: $0 mount/umount image_file loop_device mount_path"
echo "Example: $0 mount qnx.img /dev/loop27 /mnt"
echo "Example:" $0 umount /dev/loop27 /mnt
}
# Parse command line arguments
action=$1
# Perform the specified action
case $action in
"mount")
if [ "$#" -ne 4 ]; then
echo "Error: Insufficient number of arguments for 'mount'."
display_help
exit 1
fi
image_file=$2
loop_device=$3
mount_path=$4
sudo umount $mount_path
echo "================step1: create spare imge"
python tools/mksparse.py $2
echo "================step2: create qnx6 imge"
simg2img $image_file.sparse $image_file.sparse.qnx6
echo "================step3: map to loop devices"
sudo losetup -d $loop_device
sudo losetup $loop_device $image_file.sparse.qnx6
echo "================step4: mount devices!"
sudo mount -o rw -t qnx6 $loop_device $mount_path
echo "Mounted $image_file on $loop_device at $mount_path"
;;
"umount")
if [ "$#" -ne 3 ]; then
echo "Error: Insufficient number of arguments for 'mount'."
display_help
exit 1
fi
loop_device=$2
mount_path=$3
sudo umount $mount_path
sudo losetup -d $loop_device
echo "Unmounted $image_file from $loop_device at $mount_path"
;;
*)
echo "Error: Unknown action '$action'."
display_help
exit 1
;;
esac
exit 0