usb_Storage

If your problem doesn't fall into one of the other categories, report it here.

Moderator: Moderators

Post Reply
cinnex
Posts: 3
Joined: Wed Dec 29, 2010 8:42 pm

usb_Storage

Post by cinnex »

I'm using a dir-825 with a custom compiled image.

When I first plug a drive into the usb (after an install or firstboot) things work great. but after a reboot the init script fails to work. The problem is the line where it tries to turn the MB size into GB

Code: Select all

 
share_size=$(df | grep "$d" | awk '{ print $2 }')
if [ -z "$share_size" ] ; then share_size="-" ; fi
if [ -n "$share_size" ] ; then  share_size=$[(($share_size*1024)) ; fi
The shell can't do the math. (no matter how I try to get it to) That stops the /tmp/mounted_usb_storage.tab from being created, which stops my disks showing up in the web page.
I've had to change the line to

Code: Select all

share_size=$(df -h| grep "$d" | awk '{ print $2 }')
if [ -z "$share_size" ] ; then share_size="-" ; fi
if [ -n "$share_size" ] ; then  share_size=$share_size ; fi

[edit]
df -h doesn't work. it converts from bytes to mb so it would need an extra if to see if it was G or M then divide it back? I can't figure out how the web page comes up with its file size: share_size=$(df -h | grep "$d" | awk '{ print $2 }' |sed 's/\(.*\)./\1/' )
comes up with a size in kb.
[/edit]
I
I think that also the /tmp/usb_restart.lock is broken. It never gets removed?

Code: Select all

stop()
{
        got_lock=$(usb_lock)
        if [ "$got_lock" = "1" ] ; then 
                do_stop
                usb_unlock
        fi
}
needs to be

Code: Select all

stop()
{
        got_lock=$(usb_lock)
        if [ "$got_lock" = "0" ] ; then 
                do_stop
                usb_unlock
        fi
}
I think the same is true for the restart option.
Last edited by cinnex on Fri Feb 18, 2011 6:19 am, edited 1 time in total.

cinnex
Posts: 3
Joined: Wed Dec 29, 2010 8:42 pm

Re: usb_Storage

Post by cinnex »

Code: Select all

restart()
{
        got_lock=$(usb_lock)
        if [ "$got_lock" = "1" ] ; then
                 do_stop
                do_start
                usb_unlock #will remove the lock file
        fi
}
to

Code: Select all

{
        got_lock=$(usb_lock)
        if [ "$got_lock" = "0" ] ; then
                 do_stop
                do_start
        fi
}

doritos
Posts: 45
Joined: Mon May 02, 2011 2:02 pm

Re: usb_Storage

Post by doritos »

+1 for this bug, also happens to me

Post Reply