View Single Post
Posts: 181 | Thanked: 82 times | Joined on Jan 2010
#9
Well, this is becoming a challenge for me. I have changed the dfree function to include the path to search for space in. ($1)

Code:
dfree()  
 {  
   space=`df -B 1048576 $1 | tail -1 | awk '{ print int($4) }' `  
   [ $? -ne 0 ] && return 0  
   return $space  
 }
Now it perfectly returns the value of the rootfs free space (dfree "/"), but it fails for /home space. When called from my test script, I get about 70 MiB for / free space, but only 167MiB for /home free space, even when a direct commandline call to
df -B 1048576 /home | tail -1 | awk '{ print int($4) }' shows 1447 MiB. What could be the problem? Is the problem in my test script (the echo $? command)?

Thanks.

P.D.
It seems that if I modify my test script echoing the dfree result as $space instead of $?, the value returned is correct.
Code:
#!/bin/sh
. /usr/sbin/maemo-optify-lib.sh
dfree "/home"
echo $space
However, the original maemo script (/usr/sbin/maemo-optify-auto-opt.sh) is using the method $?, and therefore it cannot get the correct value for the free space. Am I right? Why $? method works for rootfs free space (70) and not for /home free space (1447)?

Last edited by ikerrg; 2012-11-08 at 11:52.