X-Git-Url: https://git.openpandora.org/cgi-bin/gitweb.cgi?p=openpandora.oe.git;a=blobdiff_plain;f=recipes%2Fpandora-system%2Fpandora-scripts%2Fop_storage.sh;h=3994003cfcc2d345219cc60fbce4f43c94157de4;hp=a280f2a7884105d3f7aa4136e19750791a0c435c;hb=2fa0121c257f7e0032383eaf3b5aa588ec99889d;hpb=6abe5a959df73b97c99c6318420e11013e273344 diff --git a/recipes/pandora-system/pandora-scripts/op_storage.sh b/recipes/pandora-system/pandora-scripts/op_storage.sh index a280f2a..3994003 100755 --- a/recipes/pandora-system/pandora-scripts/op_storage.sh +++ b/recipes/pandora-system/pandora-scripts/op_storage.sh @@ -1,30 +1,47 @@ #!/bin/bash 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 $device2 - - then - # switch to mass storage - if lsmod | grep g_cdc &>/dev/null - then - echo Found g_cdc - removing... - rmmod g_cdc - sleep 2 - ethernet=1 - fi - 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 - mount $device2 "$selection" -o $options - else - 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 +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 $device2; then + delay=0 + + # remove other gadget modules + modules="$(lsmod | awk '{print $1}' | xargs echo)" + blacklist="g_zero g_audio g_ether g_serial g_midi gadgetfs g_file_storage + g_mass_storage g_printer g_cdc g_multi g_hid g_dbgp g_nokia g_webcam g_ncm g_acm_ms" + restore_list="" + for mod in $modules; do + if echo $blacklist | grep -q "\<$mod\>"; then + restore_list="$restore_list $mod" + rmmod $mod + delay=1 # enough? + fi + done + + # driver race condition workaround (some kernels crash without wait) + sleep $delay + + # switch to mass storage + modprobe g_file_storage file=$device stall=0 removable=1 + + 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 [ ! -d "$selection" ]; then + mkdir "$selection" + fi + mount $device2 "$selection" -o $options + + if [ -n "$restore_list" ]; then + sleep $delay + modprobe $restore_list + fi +else + 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 + +done