From: Kichan Kwon Date: Fri, 10 Jul 2020 03:34:35 +0000 (+0900) Subject: Mount USB storage X-Git-Tag: submit/tizen/20200722.064325~4 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=bd754bbc9eb6e77146b3689530f55076c5b6bc32;p=platform%2Fcore%2Fsystem%2Fsystem-recovery.git Mount USB storage - Mount /dev/sdXX - Mount only ext4 or vfat file system - Mountpoint : /opt/media/USBDriveXX - Same with storaged Change-Id: I7c2fb5b83f0c63a39979189bfe0bddc8a4273f03 Signed-off-by: Kichan Kwon --- diff --git a/src/system-recovery/recovery-init.in b/src/system-recovery/recovery-init.in index bdf5338..df9988b 100644 --- a/src/system-recovery/recovery-init.in +++ b/src/system-recovery/recovery-init.in @@ -9,6 +9,11 @@ BLKID="/usr/sbin/blkid" REBOOT="@INITRD_RECOVERY_LIBEXEC_DIR@/minireboot" SYNC="/usr/bin/sync" UMOUNT="/usr/bin/umount" +CUT="/usr/bin/cut" +LS="/usr/bin/ls" +MKDIR="/usr/bin/mkdir" +RMDIR="/usr/bin/rmdir" +TR="/usr/bin/tr" #------------------------------------------------ # get partition id @@ -20,6 +25,30 @@ get_partition_id() { } #------------------------------------------------ +# mount_usb_partitions +#------------------------------------------------ +USB_MOUNTPOINT_PREFIX=${FAKE_ROOT}/opt/media/USBDrive +mount_usb_partitions() { + echo "mount USB partitions" + DEVICE_TYPE_LIST=( + ext4 + vfat + ) + + for DEVICE_TYPE in ${DEVICE_TYPE_LIST[@]} + do + DEVICES=$("$BLKID" /dev/sd?? -t TYPE="${DEVICE_TYPE}" -o device) + for DEVICE in ${DEVICES} + do + USB_MOUNTPOINT_INDEX=$(echo ${DEVICE} | "$CUT" -b 8- | "$TR" '[:lower:]' '[:upper:]') + USB_MOUNTPOINT=${USB_MOUNTPOINT_PREFIX}${USB_MOUNTPOINT_INDEX} + "$MKDIR" ${USB_MOUNTPOINT} + "$MOUNT" -t ${DEVICE_TYPE} ${DEVICE} ${USB_MOUNTPOINT} + done + done +} + +#------------------------------------------------ # mount_partitions #------------------------------------------------ mount_partitions() { @@ -36,6 +65,21 @@ mount_partitions() { "$MOUNT" -t devtmpfs devtmpfs ${FAKE_ROOT}/dev "$MOUNT" -t devpts devpts ${FAKE_ROOT}/dev/pts "$MOUNT" -t tmpfs tmpfs ${FAKE_ROOT}/tmp -o mode=1777,smackfsroot=* + + mount_usb_partitions +} + +#------------------------------------------------ +# umount_usb_partitions +#------------------------------------------------ +umount_usb_partitions() { + echo "umount USB partitions" + USB_MOUNTPOINTS=$("$LS" -d ${USB_MOUNTPOINT_PREFIX}*) + for USB_MOUNTPOINT in ${USB_MOUNTPOINTS} + do + "$UMOUNT" ${USB_MOUNTPOINT} + "$RMDIR" ${USB_MOUNTPOINT} + done } #------------------------------------------------ @@ -45,6 +89,8 @@ umount_partitions() { echo "umount partitions" "$SYNC" + umount_usb_partitions + "$UMOUNT" ${FAKE_ROOT}/opt/usr "$UMOUNT" ${FAKE_ROOT}/opt "$UMOUNT" ${FAKE_ROOT}