#36 free disk space check fails in some cases

open
nobody
None
5
2007-05-30
2007-05-30
Bob McGowan
No

You use 'df -Tm' to determine available space for processing. This works OK in most cases but fails in some, due to device name length.

I have a system that uses software raid, and the created raid device name is too long, so 'df -Tm' prints the name on one line followed by the details on a second line. This changes the number of fields from 7 to 6, for the last line, and selects the percent used value for the 'size'.

I don't see anyplace where the extra 'Type' value is used so I removed the 'T' option and changed the awk command to print '$4' rather than '$5'. This seems to work fine for getting disk size only.

You might want to consider testing for the number of fields in the last line:

... | awk '{if($NF == 7) # it's one line
print $2
else
print $1}'`

in any2vob line 294.

Discussion

  • Elias Probst

    Elias Probst - 2008-11-26

    It is better using just the -P option for 'df'....
    Solving the problems instead of working around them.

    Patch against any2vob from any2dvd-0.34

    --- any2dvd-0.34.orig/any2vob 2008-11-26 11:38:02.000000000 +0100
    +++ any2dvd-0.34/any2vob 2007-03-01 23:24:54.000000000 +0100
    @@ -291,7 +291,7 @@
    --preformat=yes) PREFORMAT_FRC="yes"; shift ;;
    --calc) shift; CALC="yes" ;;
    --workdir=*) WORKDIR=`echo "$1" | sed 's/--workdir=/ /' | sed 's/^[ \t]*//'`
    - FILESYS=`df -PTh "$WORKDIR" | tail -n1 | awk '{print $2}'`
    + FILESYS=`df -Th "$WORKDIR" | tail -n1 | awk '{print $2}'`
    if [ "$FILESYS" = "vfat" ]; then
    warn WARNING: Your workdir \'"$WORKDIR"\' resides on a FAT Windows partition
    echo -e "\e[33;01m Be aware that this may well cause problems as there is a 2GB filesize limit\e[m"
    @@ -984,13 +984,13 @@
    echo
    fi
    fi
    - DISKSPACE_AVAIL_MB=`df -PTm "$WORKDIR" | tail -n1 | awk '{print $5}'`
    + DISKSPACE_AVAIL_MB=`df -Tm "$WORKDIR" | tail -n1 | awk '{print $5}'`
    DISKSPACE_AVAIL_GB=`perl -le "printf ('%.2f', $DISKSPACE_AVAIL_MB / 1024)"`
    DISKSPACE_NEEDED_MB=`perl -le "print int($TOTAL_SIZEMB * 2)"`
    DISKSPACE_NEEDED_GB=`perl -le "printf ('%.2f', $DISKSPACE_NEEDED_MB / 1024)"`
    [ "$ISO" != "no" ] && [ "$ANY2DVD" = "yes" ] && DISKSPACE_NEEDED_MB=`perl -le "print int($TOTAL_SIZEMB * 3)"`
    if [ "$DISKSPACE_NEEDED_MB" -ge "$DISKSPACE_AVAIL_MB" ]; then
    - errmsg WARNING: "Not enough diskspace available, $DISKSPACE_NEEDED_GB GB needed, but only $DISKSPACE_AVAIL_GBGB available on `df -PT "$WORKDIR" | tail -n1 | awk '{print $1}'`"
    + errmsg WARNING: "Not enough diskspace available, $DISKSPACE_NEEDED_GB GB needed, but only $DISKSPACE_AVAIL_GBGB available on `df -T "$WORKDIR" | tail -n1 | awk '{print $1}'`"
    echo -en " Are you sure you want to continue ? \033[1m(yes/no)\e[m "
    read continue
    [ "$continue" != "yes" ] && echo -e "\nENCODING ERROR" >> $VAR_DATAFILE && exit

     

Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks