fix usb eject with virtual-disk2

git-svn-id: file:///root/webif/svn/humax/pkg/src/webif/trunk@2092 2a923420-c742-0410-a762-8d5b09965624
This commit is contained in:
hummypkg 2014-12-30 14:56:45 +00:00
parent 5d0939d8de
commit 51aded3d2d
5 changed files with 51 additions and 12 deletions

View File

@ -1,10 +1,10 @@
Package: webif Package: webif
Priority: optional Priority: optional
Section: web Section: web
Version: 1.0.18-4 Version: 1.0.18-5
Architecture: mipsel Architecture: mipsel
Maintainer: af123@hummypkg.org.uk Maintainer: af123@hummypkg.org.uk
Depends: webif-channelicons(>=1.1.14),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(>=2.1),busybox(>=1.20.2-1),lsof(>=4.87),epg(>=1.0.14),hmt(>=1.1.21),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),tcpping(>=1.1),mongoose Depends: webif-channelicons(>=1.1.14),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(>=2.1),busybox(>=1.20.2-1),lsof(>=4.87),epg(>=1.0.14),hmt(>=1.1.21),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),tcpping(>=1.1),e2fsprogs,mongoose
Suggests: Suggests:
Description: An evolving web interface for the Humax. Description: An evolving web interface for the Humax.
Tags: http://hummy.tv/forum/threads/5866/ Tags: http://hummy.tv/forum/threads/5866/

View File

@ -5,9 +5,19 @@ require system.class
httpheader "application/json" httpheader "application/json"
set fsg {File-Stor Gadget}
set ignoredev {}
if {[file isdirectory /mnt/hd2]} {
file stat /mnt/hd2 st
lappend ignoredev $st(dev)
}
puts "\[" puts "\["
set flag 0 set flag 0
foreach usb [system usbmounts 1] { foreach usb [system usbmounts 1] {
file stat $usb(MP) st
if {$usb(MODEL) ne $fsg && $st(dev) in $ignoredev} continue
if {$flag} { puts "," } else { set flag 1 } if {$flag} { puts "," } else { set flag 1 }
puts " {" puts " {"

View File

@ -30,7 +30,11 @@ $('#usbeject').on('click', function(e) {
var num = 0; var num = 0;
$.each(data, function(k,v) { $.each(data, function(k,v) {
num++; num++;
var size = (v.SIZE / 1000000000).toFixed(1); var size = (v.SIZE / 1000000000);
if (size > 1000)
size = (size / 1000).toFixed(1) + "TB";
else
size = size.toFixed(1) + "GB";
var type = v.TYPE; var type = v.TYPE;
var drive = v.MP.split(/[/]/).pop().capitalise(); var drive = v.MP.split(/[/]/).pop().capitalise();
switch (type) switch (type)
@ -48,7 +52,7 @@ $('#usbeject').on('click', function(e) {
'<td class=usblabel>' + v.LABEL + '</td>' + '<td class=usblabel>' + v.LABEL + '</td>' +
'<td class=blood>(' + drive + '&nbsp;-&nbsp;' + '<td class=blood>(' + drive + '&nbsp;-&nbsp;' +
type + '&nbsp;' + '&nbsp;-&nbsp;' + type + '&nbsp;' + '&nbsp;-&nbsp;' +
size + 'GB)</td>' + size + ')</td>' +
'<td><img class="va eject" border=0 height=20' + '<td><img class="va eject" border=0 height=20' +
' drive=' + v.MP + ' drive=' + v.MP +
' label="' + v.LABEL + '"' + ' label="' + v.LABEL + '"' +

View File

@ -66,12 +66,23 @@ proc {file tdelete} {target} {
} }
} }
proc {file read} {target} {
if {[file readable $target]} {
set fd [open $target]
set ret [$fd read]
$fd close
return $ret
}
error "Cannot read $target"
}
local proc file {cmd args} { local proc file {cmd args} {
switch $cmd { switch $cmd {
"rename" { tailcall {file rename} {*}$args } rename { tailcall {file rename} {*}$args }
"copy" { tailcall {file copy} {*}$args } copy { tailcall {file copy} {*}$args }
"touch" { tailcall {file touch} {*}$args } touch { tailcall {file touch} {*}$args }
"tdelete" { tailcall {file tdelete} {*}$args } tdelete { tailcall {file tdelete} {*}$args }
read { tailcall {file read} {*}$args }
default { tailcall upcall file $cmd {*}$args } default { tailcall upcall file $cmd {*}$args }
} }
} }

View File

@ -29,6 +29,7 @@ proc {system ip} {} {
} else { } else {
set ipl [lindex [split [$fp read] "\n"] 1] set ipl [lindex [split [$fp read] "\n"] 1]
regsub -- {[[:space:]].*} $ipl "" ip regsub -- {[[:space:]].*} $ipl "" ip
$fp close
} }
return $ip return $ip
} }
@ -49,12 +50,10 @@ proc {system modversion} {{short 0}} {{modver ""}} {
proc {system modbuild} {} {{modbuild ""}} { proc {system modbuild} {} {{modbuild ""}} {
if {$modbuild ne ""} { return $modbuild } if {$modbuild ne ""} { return $modbuild }
if {[catch {set fp [open /etc/modbuild r]}]} { if {[catch {set modbuild [string trim [file read /etc/modbuild]]}]} {
set modbuild 0 set modbuild 0
} else {
set modbuild [string trim [read $fp]]
close $fp
} }
return $modbuild
} }
proc {system fhtcpversion} {} {{ver ""}} { proc {system fhtcpversion} {} {{ver ""}} {
@ -409,6 +408,21 @@ proc {system usbmounts} {{full 0}} {
lassign $line dev mp lassign $line dev mp
set rec "DEV $dev MP $mp LABEL {NO NAME} TYPE Unknown" set rec "DEV $dev MP $mp LABEL {NO NAME} TYPE Unknown"
set rec(VENDOR) Unknown
set rec(MODEL) Unknown
if {[regexp {/dev/(sd[a-z])} $dev x rdev]} {
set rec(RDEV) $rdev
if {[file readable [
set f /sys/block/$rdev/device/vendor]]} {
set rec(VENDOR) [string trim [file read $f]]
}
if {[file readable [
set f /sys/block/$rdev/device/model]]} {
set rec(MODEL) [string trim [file read $f]]
}
}
lassign [exec stat -f -c {%b %S} $mp] blockc blocks lassign [exec stat -f -c {%b %S} $mp] blockc blocks
set rec(SIZE) $($blockc * $blocks) set rec(SIZE) $($blockc * $blocks)