improve diskspace check

git-svn-id: file:///root/webif/svn/humax/pkg/src/webif/trunk@1920 2a923420-c742-0410-a762-8d5b09965624
This commit is contained in:
hummypkg 2014-05-28 18:10:58 +00:00
parent bfd099a82e
commit f029ab1ce6
2 changed files with 65 additions and 14 deletions

View File

@ -1,7 +1,7 @@
Package: webif
Priority: optional
Section: web
Version: 1.0.13-2
Version: 1.0.13-3
Architecture: mipsel
Maintainer: af123@hummypkg.org.uk
Depends: webif-channelicons(>=1.1.11),lighttpd(>=1.4.35-2),jim(>=0.75-1),jim-oo,jim-sqlite3(>=0.75),jim-cgi(>=0.7),jim-binary(>=0.75),service-control(>=1.2),busybox(>=1.20.2-1),lsof,epg(>=1.0.13),hmt(>=1.1.14),ssmtp,anacron,trm(>=1.1),openssl-command,nicesplice,id3v2,file,rsvsync(>=1.0.2),webif-charts(>=1.2-1),stripts(>=1.2.5-3),smartmontools,tmenu(>=1.08),ffmpeg,id3v2,multienv(>=1.6),mongoose

View File

@ -144,18 +144,72 @@ proc {system dustbin} {{short 0}} {
return "[system mediaroot]/$dustbin"
}
proc {system diskspace} {} {
proc {system diskdev} {} {
switch [system model] {
HDR { set part /mnt/hd2 }
HD { set part /media/drive1 }
}
foreach line [split [\
exec /mod/bin/busybox/df $part 2>>/dev/null] "\n\r"] {
if {[string match "/*" $line]} {
lassign [split $line] dev
break
}
}
return $dev
}
proc {system disk} {} {
return [string range [system diskdev] 0 end-1]
}
if {[file exists /sbin/tune2fs]} {
# New version of diskspace functions that ignores reserved blocks.
# Only supported on firmwares with tune2fs in the root filesystem.
require pretty_size
proc {system diskspace} {{raw 0}} {
set dev [system diskdev]
foreach line [split [exec /sbin/tune2fs -l $dev] "\n\r"] {
lassign [split $line ":"] key val
switch $key {
"Block size" { set bsize $val }
"Block count" { set blocks $val }
"Free blocks" { set fblocks $val }
}
}
set size $($bsize * $blocks)
set free $($bsize * $fblocks)
set used $($size - $free)
set perc $($used * 100 / $size)
set fperc $(100 - $perc)
if {!$raw} {
set size [pretty_size $size]
set free [pretty_size $free]
set used [pretty_size $used]
}
return [list $size $used $perc $free $fperc $dev]
}
proc {system diskfree} {} {
return [lindex [system diskspace 1] 3]
}
} else {
proc {system diskspace} {} {
switch [system model] {
HDR { set part /mnt/hd2 }
HD { set part /media/drive1 }
}
set size 0
set used 0
set free 0
set perc 0
set dev 0
foreach line [split [exec /mod/bin/busybox/df -h $part 2>>/dev/null] "\n\r"] {
foreach line [split [\
exec /mod/bin/busybox/df -h $part 2>>/dev/null] "\n\r"] {
if {[string match "/*" $line]} {
regsub -all -- {[[:space:]]+} $line " " line
set fields [split $line]
@ -170,13 +224,9 @@ proc {system diskspace} {} {
}
return [list $size $used $perc $free $fperc $dev]
}
}
proc {system disk} {} {
return [string range [lindex [system diskspace] 5] 0 end-1]
}
proc {system diskfree} {} {
proc {system diskfree} {} {
switch [system model] {
HDR { set part /mnt/hd2 }
HD { set part /media/drive1 }
@ -194,6 +244,7 @@ proc {system diskfree} {} {
}
return $free
}
}
proc {system busy} {} {