From 9ca48b18f6b71e451d1bd0cc3ff9afc30f3a9f44 Mon Sep 17 00:00:00 2001 From: Michael Mrozek Date: Tue, 29 Jun 2010 03:55:19 +0200 Subject: [PATCH] op_storage.sh: Fixed script to use proper device name for mass storage --- .../pandora-scripts/op_storage.sh | 50 ++++++------------- 1 file changed, 14 insertions(+), 36 deletions(-) diff --git a/recipes/pandora-system/pandora-scripts/op_storage.sh b/recipes/pandora-system/pandora-scripts/op_storage.sh index d293cb5..fd2b568 100755 --- a/recipes/pandora-system/pandora-scripts/op_storage.sh +++ b/recipes/pandora-system/pandora-scripts/op_storage.sh @@ -1,51 +1,29 @@ #!/bin/bash -while mainsel=$(zenity --title="SD Card Mass Storage" --width="380" --height="200" --list --column "id" --column "Please select" --hide-column=1 --text="What do you want to do?" "sd1" "Switch SD Card 1 to Mass Storage Mode" "sd2" "Switch SD Card 2 to Mass Storage Mode" ); do - case $mainsel in - "sd1") - remount=$(cat /proc/mounts | grep /dev/mmcblk0p1 | awk '{print "mount " $1 " " $2 " -o " $4}' | sed "s/,codepage=[A-Za-z0-9]*,/,/g") - if umount /dev/mmcblk0p1 +while selection=$(grep "/dev/mmcblk" /proc/mounts | cut -f 2 -d " " | sed 's/\\040/ /g' | zenity --title="SD Card Mass Storage" --width="380" --height="200" --list --text="Enable mass storage" --column="Select card"); do +selection2=$(echo $selection | sed 's/ /\\\\040/g') +options=$(grep ${selection2} /proc/mounts | awk '{print $4}' | sed "s/,codepage=[A-Za-z0-9]*,/,/g" | sed 's/\\040/\\ /g' ) +device=$(grep ${selection2} /proc/mounts | awk '{print substr($1,1,12)}') +device2=$(grep ${selection2} /proc/mounts | awk '{print $1}') + +if umount $device + then # switch to mass storage - if lsmod | grep g_cdc &>/dev/null + if lsmod | grep g_cdc &>/dev/null then echo Found g_cdc - removing... rmmod g_cdc ethernet=1 fi - modprobe g_file_storage file=/dev/mmcblk0p1 stall=0 - zenity --title="SD Card 1 Mass Storage Mode" --info --text="SD Card Slot 1 is currently in Mass Storage Mode.\n\nClick on OK when you're finished with your data transfer\nand want to go back to normal mode." + modprobe g_file_storage file=$device stall=0 + zenity --title="Mass Storage Mode" --info --text="SD Card $selection is currently in Mass Storage Mode.\n\nClick on OK when you're finished with your data transfer\nand want to go back to normal mode." rmmod g_file_storage if [ $ethernet=1 ]; then echo Reloading g_cdc... modprobe g_cdc fi - $remount + mount $device2 "$selection" -o $options else - zenity --title="Error" --error --text="Error.\nEither there is no card in SD Slot 1 or some program\nis currently accessing the card.\n\nPlease make sure to close any programs that currently access te SD Card." --timeout 6 - fi - ;; - "sd2") - remount=$(cat /proc/mounts | grep /dev/mmcblk0p1 | awk '{print "mount " $1 " " $2 " -o " $4}' | sed "s/,codepage=[A-Za-z0-9]*,/,/g") - if umount /dev/mmcblk1p1 - then - # switch to mass storage - if lsmod | grep g_cdc &>/dev/null - then - echo Found g_cdc - removing... - rmmod g_cdc - ethernet=1 - fi - modprobe g_file_storage file=/dev/mmcblk1p1 stall=0 - zenity --title="SD Card 2 Mass Storage Mode" --info --text="SD Card Slot 2 is currently in Mass Storage Mode.\n\nClick on OK when you're finished with your data transfer\nand want to go back to normal mode." - rmmod g_file_storage - if [ $ethernet=1 ]; then - echo Reloading g_cdc... - modprobe g_cdc - fi - $remount - else - zenity --title="Error" --error --text="Error.\nEither there is no card in SD Slot 2 or some program\nis currently accessing the card.\n\nPlease make sure to close any programs that currently access te SD Card." --timeout 6 - fi - ;; - esac + zenity --title="Error" --error --text="Error.\nThe card could not be unmounted.\n\nPlease make sure to close any programs that currently access the SD Card." --timeout 10 +fi done \ No newline at end of file -- 2.39.2