@@ -557,7 +557,13 @@ mount_flash() {
557
557
if [ ! " $FAT32_BOOT " = " yes" ]; then
558
558
mount_part " $boot " " /flash" " ro,noatime"
559
559
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
561
567
fi
562
568
563
569
if [ -f /flash/post-flash.sh ]; then
@@ -582,7 +588,7 @@ cleanup_flash() {
582
588
mount_storage () {
583
589
progress " Mounting storage"
584
590
585
- if [ " $LIVE " = " yes" ]; then
591
+ if [ " $LIVE " = " yes" -a ! " $DEVICE_HAS_USER " = " yes " ]; then
586
592
# mount tmpfs and exit early. disk=xx is not allowed in live mode
587
593
mount -t tmpfs none /storage
588
594
return
@@ -591,9 +597,56 @@ mount_storage() {
591
597
wakeonlan
592
598
593
599
if [ " $FAT32_BOOT " = " yes" ]; then
600
+ if [ " $FAT32_MOUNT_ERROR " = " yes" ]; then
601
+ LIVE=" yes"
602
+ fi
594
603
DISTRO=${IMAGE_SYSTEM% ' /' * }
595
604
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
597
650
elif [ -n " $disk " ]; then
598
651
if [ -n " $OVERLAY " ]; then
599
652
OVERLAY_DIR=$( cat /sys/class/net/eth0/address | tr -d :)
@@ -969,7 +1022,20 @@ prepare_sysroot() {
969
1022
progress " Preparing system"
970
1023
971
1024
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
973
1039
974
1040
if [ ! " $FAT32_BOOT " = " yes" ]; then
975
1041
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() {
988
1054
# Do init tasks to bring up system
989
1055
990
1056
# 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
993
1060
# run platform_init script if exists
994
1061
if [ -f " ./platform_init" ]; then
995
1062
./platform_init
@@ -1090,6 +1157,17 @@ for arg in $(cat /proc/cmdline); do
1090
1157
;;
1091
1158
fat32-boot)
1092
1159
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"
1093
1171
;;
1094
1172
esac
1095
1173
done
@@ -1153,6 +1231,15 @@ done
1153
1231
# setup kernel overlays
1154
1232
/usr/bin/busybox chroot /sysroot /usr/sbin/kernel-overlays-setup
1155
1233
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
+
1156
1243
# tell OE settings addon to disable updates
1157
1244
if [ " $UPDATE_DISABLED " = " yes" ]; then
1158
1245
echo " " > /sysroot/dev/.update_disabled
0 commit comments