Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

【建议】热插拔U盘中文乱码的问题 #4238

Closed
lon91ong opened this issue Apr 9, 2020 · 0 comments
Closed

【建议】热插拔U盘中文乱码的问题 #4238

lon91ong opened this issue Apr 9, 2020 · 0 comments

Comments

@lon91ong
Copy link

lon91ong commented Apr 9, 2020

#!/bin/sh

# Copyright (C) 2015 OpenWrt.org

# 0 yes blockdevice handles this - 1 no it is not there
blkdev=`dirname $DEVPATH`
basename=`basename $blkdev`
device=`basename $DEVPATH`
skip=`block info | sed 's/\(.*\): .*/\1/' | grep -q $device ; echo $?`
path=$DEVPATH

if [ $basename != "block" ] && [ -z "${device##sd*}" ] && [ $skip -eq 1 ]; then
        islabel=`blkid /dev/$device | grep -q LABEL ; echo $?`
        if [ $islabel -eq 0 ] ; then
                mntpnt=`blkid /dev/$device |sed 's/.*LABEL="\(.*\)" UUID.*/\1/'`
        else
                mntpnt=$device
        fi

        case "$ACTION" in
                add)
                        mkdir -p /export/$mntpnt
                        # Set APM value for automatic spin down
                        /sbin/hdparm -B 127 /dev/$device
                        # Try to be gentle on solid state devices
                        mount -o rw,noatime,discard /dev/$device /export/$mntpnt
                ;;
                remove)
                        # Once the device is removed, the /dev entry disappear. We need mountpoint
                        mountpoint=`mount |grep /dev/$device | sed 's/.* on \(.*\) type.*/\1/'`
                        umount -l $mountpoint
                ;;
        esac
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant