@@ -557,7 +557,13 @@ mount_flash() {
557557 if [ ! " $FAT32_BOOT " = " yes" ]; then
558558 mount_part " $boot " " /flash" " ro,noatime"
559559 else
560- mount_part " $boot " " /flash" " rw,noatime,umask=0000"
560+ mount_part " $boot " " /flash" " rw,noatime,umask=0000,shortname=winnt"
561+ if [ " $RUN_FSCK " = " no" ]; then
562+ # make sure flash is writable
563+ FLASH_STATUS=$( /usr/bin/busybox cat /proc/mounts | /usr/busybox grep fat | /usr/bin/busybox grep ro,)
564+ if [ ! " $FLASH_STATUS " = " " ]; then
565+ FAT32_MOUNT_ERROR=" yes"
566+ fi
561567 fi
562568
563569 if [ -f /flash/post-flash.sh ]; then
@@ -582,7 +588,7 @@ cleanup_flash() {
582588mount_storage () {
583589 progress " Mounting storage"
584590
585- if [ " $LIVE " = " yes" ]; then
591+ if [ " $LIVE " = " yes" -a ! " $DEVICE_HAS_USER " = " yes " ]; then
586592 # mount tmpfs and exit early. disk=xx is not allowed in live mode
587593 mount -t tmpfs none /storage
588594 return
@@ -591,9 +597,56 @@ mount_storage() {
591597 wakeonlan
592598
593599 if [ " $FAT32_BOOT " = " yes" ]; then
600+ if [ " $FAT32_MOUNT_ERROR " = " yes" ]; then
601+ LIVE=" yes"
602+ fi
594603 DISTRO=${IMAGE_SYSTEM% ' /' * }
595604 mkdir -p /flash/$DISTRO /storage
596- mount --bind /flash/$DISTRO /storage /storage
605+
606+ # Handle upfs stuff
607+ if [ " $DEVICE_HAS_USER " = " yes" ]; then
608+ UPFS_STORAGE_PATH=" /run/upfs_storage"
609+ else
610+ UPFS_STORAGE_PATH=" /storage"
611+ fi
612+
613+ if [ ! -d $UPFS_STORAGE_PATH -a " $UPFS_STORAGE " = " yes" -a ! " $UPFS_STORAGE_PATH " = " /storage" ]; then
614+ mkdir -p $UPFS_STORAGE_PATH
615+ fi
616+
617+ if [ " $UPFS_STORAGE " = " yes" -a " $UPFS_PERMISSIONS_IN_STORE " = " yes" ]; then
618+ if [ ! -f $UPFS_STORAGE_PATH /.upfs_store_created ]; then
619+ echo " " > $UPFS_STORAGE_PATH /.upfs_store_created
620+ CREATE_PERMISSIONS=" yes"
621+ rm -rf /flash/$DISTRO /storage/* .upfs*
622+ fi
623+ /usr/sbin/mount.upfsps /flash/$DISTRO /storage $UPFS_STORAGE_PATH
624+ elif [ " $UPFS_STORAGE " = " yes" ]; then
625+ mkdir -p " $UPFS_STORAGE_PATH " _p
626+ if [ ! -f /flash/$DISTRO /storage_p.img ]; then
627+ dd if=/dev/zero of=/flash/$DISTRO /storage_p.img bs=1024 count=10240
628+ mkfs.ext4 /flash/$DISTRO /storage_p.img
629+ CREATE_PERMISSIONS=" yes"
630+ fi
631+ /usr/bin/busybox mount -o loop /flash/$DISTRO /storage_p.img /run/upfs_storage_p
632+ /usr/sbin/mount.upfs " $UPFS_STORAGE_PATH " _p:/flash/$DISTRO /storage $UPFS_STORAGE_PATH
633+ fi
634+
635+ # Actually mount something to storage.
636+ if [ " $UPFS_STORAGE " = " yes" ]; then
637+ # Create initial permission store.
638+ if [ " $CREATE_PERMISSIONS " = " yes" ]; then
639+ /usr/bin/busybox chown -R 0:0 $UPFS_STORAGE_PATH /*
640+ fi
641+
642+ # For now bind mount to ensure updater works without more modifications,
643+ # We will handle this in prepare_sysroot
644+ if [ ! " $LIVE " = " yes" ]; then
645+ mount --bind $UPFS_STORAGE_PATH /storage
646+ fi
647+ elif [ ! " $LIVE " = " yes" ]; then
648+ mount --bind /flash/$DISTRO /storage /storage
649+ fi
597650 elif [ -n " $disk " ]; then
598651 if [ -n " $OVERLAY " ]; then
599652 OVERLAY_DIR=$( cat /sys/class/net/eth0/address | tr -d :)
@@ -969,7 +1022,20 @@ prepare_sysroot() {
9691022 progress " Preparing system"
9701023
9711024 mount --move /flash /sysroot/flash
972- mount --move /storage /sysroot/storage
1025+ if [ " $DEVICE_HAS_USER " = " yes" ]; then
1026+ if [ ! " $UPFS_STORAGE " = " yes" ]; then
1027+ if [ ! " $LIVE " = " yes" ]; then
1028+ mount --move /storage /sysroot/storage
1029+ fi
1030+ else
1031+ # properly mount via chroot before switch_root
1032+ if [ ! " $LIVE " = " yes" ]; then
1033+ umount /storage
1034+ fi
1035+ fi
1036+ else
1037+ mount --move /storage /sysroot/storage
1038+ fi
9731039
9741040 if [ ! " $FAT32_BOOT " = " yes" ]; then
9751041 if [ ! -d " /sysroot/usr/lib/kernel-overlays/base/lib/modules/$( uname -r) /" -a -f " /sysroot/usr/lib/systemd/systemd" ]; then
@@ -988,8 +1054,9 @@ prepare_sysroot() {
9881054# Do init tasks to bring up system
9891055
9901056# hide kernel log messages on console
991- echo ' 1 4 1 7' > /proc/sys/kernel/printk
992-
1057+ if [ ! " $SPLASH " = " no" ] ; then
1058+ echo ' 1 4 1 7' > /proc/sys/kernel/printk
1059+ fi
9931060# run platform_init script if exists
9941061if [ -f " ./platform_init" ]; then
9951062 ./platform_init
@@ -1090,6 +1157,17 @@ for arg in $(cat /proc/cmdline); do
10901157 ;;
10911158 fat32-boot)
10921159 FAT32_BOOT=" yes"
1160+ FAT32_MOUNT_ERROR=" no"
1161+ ;;
1162+ upfs-storage)
1163+ UPFS_STORAGE=" yes"
1164+ ;;
1165+ upfsps-storage)
1166+ UPFS_STORAGE=" yes"
1167+ UPFS_PERMISSIONS_IN_STORE=" yes"
1168+ ;;
1169+ device-has-user)
1170+ DEVICE_HAS_USER=" yes"
10931171 ;;
10941172 esac
10951173done
@@ -1153,6 +1231,15 @@ done
11531231# setup kernel overlays
11541232/usr/bin/busybox chroot /sysroot /usr/sbin/kernel-overlays-setup
11551233
1234+ # Deal with user permissions
1235+
1236+ if [ " $DEVICE_HAS_USER " = " yes" -a " $UPFS_STORAGE " = " yes" ]; then
1237+ /usr/bin/busybox chroot /sysroot /usr/bin/bindfs --map=0/1000:@0/@1000 /run/upfs_storage /storage
1238+ elif [ " $DEVICE_HAS_USER " = " yes" -a " $LIVE " = " yes" ]; then
1239+ mkdir -p /sysroot/run/tmp_storage
1240+ /usr/bin/busybox chroot /sysroot /usr/bin/bindfs --map=0/1000:@0/@1000 /sysroot/run/tmp_storage
1241+ fi
1242+
11561243# tell OE settings addon to disable updates
11571244if [ " $UPDATE_DISABLED " = " yes" ]; then
11581245 echo " " > /sysroot/dev/.update_disabled
0 commit comments