diff --git a/kernel b/kernel index dee0af5..cfc4077 100755 Binary files a/kernel and b/kernel differ diff --git a/rootfs/etc/udev/automount.sh b/rootfs/etc/udev/automount.sh index eec66c4..1111a85 100644 --- a/rootfs/etc/udev/automount.sh +++ b/rootfs/etc/udev/automount.sh @@ -1,5 +1,11 @@ #!/bin/sh -/bin/umount /root/usb -/bin/mount -t vfat -o codepage=936,utf8 /dev/sda1 /root/usb -/bin/mount -t ext4 /dev/sda1 /root/usb -/usr/bin/ntfs-3g /dev/sda1 /root/usb +. /link/shell/util/func.sh +jopen /link/config/misc/disk.json +enable=`jget enable` + +if [ $enable == "true" ];then + used=`jget used` + if [ $used == "local" ];then + /link/shell/mount.sh + fi +fi diff --git a/rootfs/etc/udev/autounmount.sh b/rootfs/etc/udev/autounmount.sh index 2c1b795..e2d3e05 100644 --- a/rootfs/etc/udev/autounmount.sh +++ b/rootfs/etc/udev/autounmount.sh @@ -1,2 +1,11 @@ #!/bin/sh -umount -l /root/usb +. /link/shell/util/func.sh +jopen /link/config/misc/disk.json +enable=`jget enable` + +if [ $enable == "true" ];then + used=`jget used` + if [ $used == "local" ];then + umount -l -f /root/usb + fi +fi diff --git a/rootfs/link/bin/Encoder b/rootfs/link/bin/Encoder index 6609257..3624b0a 100644 Binary files a/rootfs/link/bin/Encoder and b/rootfs/link/bin/Encoder differ diff --git a/rootfs/link/config/misc/disk.json b/rootfs/link/config/misc/disk.json new file mode 100644 index 0000000..790b838 --- /dev/null +++ b/rootfs/link/config/misc/disk.json @@ -0,0 +1,16 @@ +{ + "enable": true, + "used": "local", + "shared": { + "ip": "", + "type": "cifs", + "path": "", + "auth": { + "uname": "", + "passwd": "" + } + }, + "local": { + "device": "/dev/sda1" + } +} \ No newline at end of file diff --git a/rootfs/link/config/verLogs.json b/rootfs/link/config/verLogs.json index cdac07d..30ee973 100644 --- a/rootfs/link/config/verLogs.json +++ b/rootfs/link/config/verLogs.json @@ -1,4 +1,14 @@ [ + { + "version": "2.4.0 build 20230731", + "logs": [ + "修正挂载大容量存储设备时,磁盘空间显示不准确问题", + "修正ENC5V2机型,恢复出厂设置小概率异常问题", + "SDI输入支持Level B标准", + "ENC1V3,ENC4SS,ENCSHV2机型新增遥控器支持", + "扩展功能下新增存储挂载设置,支持nfs挂载,windows共享目录挂载,以及磁盘指定分区挂载" + ] + }, { "version": "2.3.0 build 20230630", "logs": [ diff --git a/rootfs/link/config/version.json b/rootfs/link/config/version.json index 3002c78..32d7550 100644 --- a/rootfs/link/config/version.json +++ b/rootfs/link/config/version.json @@ -1,5 +1,5 @@ { "app": "2.0.0 build 20220512_869", "sdk": "2.0.0 build 20220518_20716", - "sys": "2.3.0 build 20230630" + "sys": "2.4.0 build 20230731" } diff --git a/rootfs/link/shell/enc.sh b/rootfs/link/shell/enc.sh index 8826897..236bbab 100644 --- a/rootfs/link/shell/enc.sh +++ b/rootfs/link/shell/enc.sh @@ -1,10 +1,17 @@ while [ true ] do if [ -f "/root/usb/Tester" ]; then -chmod 777 /root/usb/Tester -/root/usb/Tester + chmod 777 /root/usb/Tester + /root/usb/Tester else -/link/bin/Encoder + if [ -f "/link/bin/Monitor" ];then + pkill Monitor + fi + if [ -f "/root/usb/config.json" ];then + /link/bin/Encoder -c /root/usb/config.json + else + /link/bin/Encoder + fi fi sleep 2 done diff --git a/rootfs/link/shell/init.sh b/rootfs/link/shell/init.sh index beb03d4..8e00209 100644 --- a/rootfs/link/shell/init.sh +++ b/rootfs/link/shell/init.sh @@ -5,13 +5,14 @@ /link/shell/update.sh ifconfig lo 127.0.0.1 /sbin/sysctl -p /etc/sysctl.conf -/link/shell/init/filesystem.sh /link/shell/init/chip.sh if nfsBoot ;then +/link/shell/init/filesystem.sh /link/shell/init/service.sh else /link/shell/netManager.sh +/link/shell/init/filesystem.sh /link/shell/init/service.sh /link/shell/app.sh fi diff --git a/rootfs/link/shell/init/filesystem.sh b/rootfs/link/shell/init/filesystem.sh index 479ccba..c7ace2b 100644 --- a/rootfs/link/shell/init/filesystem.sh +++ b/rootfs/link/shell/init/filesystem.sh @@ -4,7 +4,6 @@ mkdir /tmp/log if [ ! -d /root/usb ]; then mkdir /root/usb fi -/link/shell/mountUsb.sh if [ -b /dev/mmcblk0p5 ]; then /bin/mount -o remount,rw,sync,barrier=0 /dev/mmcblk0p5 / @@ -20,9 +19,6 @@ if [ -b /dev/mmcblk0p6 ]; then echo -e "\ny" | mkfs.ext4 -T largefile /dev/mmcblk0p6 fi fi - umount -f /root/usb/ - if [ ! -b /dev/sda1 ];then - /bin/mount -o rw,sync,barrier=0 /dev/mmcblk0p6 /root/usb - fi + /link/shell/mount.sh fi diff --git a/rootfs/link/shell/mount.sh b/rootfs/link/shell/mount.sh new file mode 100644 index 0000000..2efe6c5 --- /dev/null +++ b/rootfs/link/shell/mount.sh @@ -0,0 +1,61 @@ +#!/bin/sh + +. /link/shell/util/func.sh +jopen /link/config/misc/disk.json +enable=`jget enable` + +umount_disk(){ + mnt=`df -h | grep /root/usb | wc -l` + count=0 + while [ $mnt -eq 1 -a $count -le 5 ] + do + umount -l -f /root/usb + mnt=`df -h | grep /root/usb | wc -l` + count=`expr $count + 1` + sleep 1 + if [ $count -ge 5 ];then + exit + fi + done +} + +had_mounted() { + if [ $enable == "true" ];then + mnt=`df -h | grep /root/usb | wc -l` + echo $mnt + return + fi + echo 0 +} + +umount_disk + +if [ $enable == "true" ];then + used=`jget used` + if [ $used == "shared" ];then + ip=`jget shared.ip` + type=`jget shared.type` + uname=`jget shared.auth.uname` + passwd=`jget shared.auth.passwd` + path=`jget shared.path` + if [ $type == "cifs" ];then + target=//$ip$path + if [ -z $uname ];then + uname="x" + passwd="x" + fi + mount -t $type -o nolock,username=$uname,password=$passwd $target /root/usb + else + target=$ip:$path + mount -t $type -o nolock,tcp $target /root/usb + fi + fi + if [ $used == "local" ];then + device=`jget local.device` + mount -t vfat -o rw,relatime,codepage=936,utf8 $device /root/usb + mount -t ext4 $device /root/usb + /usr/bin/ntfs-3g $device /root/usb + fi +fi + +had_mounted diff --git a/rootfs/link/shell/mountUsb.sh b/rootfs/link/shell/mountUsb.sh index d88b56a..1111a85 100644 --- a/rootfs/link/shell/mountUsb.sh +++ b/rootfs/link/shell/mountUsb.sh @@ -1,13 +1,11 @@ #!/bin/sh -if [ -e "/dev/sda" ]; then -umount /root/usb -if [ -e "/dev/sda1" ]; then -/bin/mount -t vfat -o rw,relatime,codepage=936,utf8 /dev/sda1 /root/usb -/bin/mount -t ext4 /dev/sda1 /root/usb -/usr/bin/ntfs-3g /dev/sda1 /root/usb -else -/bin/mount -t vfat -o rw,relatime,codepage=936,utf8 /dev/sda /root/usb -/bin/mount -t ext4 /dev/sda /root/usb -/usr/bin/ntfs-3g /dev/sda /root/usb -fi +. /link/shell/util/func.sh +jopen /link/config/misc/disk.json +enable=`jget enable` + +if [ $enable == "true" ];then + used=`jget used` + if [ $used == "local" ];then + /link/shell/mount.sh + fi fi diff --git a/rootfs/link/web/disk.php b/rootfs/link/web/disk.php new file mode 100644 index 0000000..df1ad91 --- /dev/null +++ b/rootfs/link/web/disk.php @@ -0,0 +1,263 @@ + +
+ + + + + + + diff --git a/rootfs/link/web/explorer.php b/rootfs/link/web/explorer.php index a8408a2..3f0aeb4 100644 --- a/rootfs/link/web/explorer.php +++ b/rootfs/link/web/explorer.php @@ -358,12 +358,12 @@ include( "head.php" ); }) } ); - rpc( "rec.getState", null, function ( data ) { - if($.isEmptyObject(data)) + func("getDiskSpace",[],function (data) { + if(data.total == 0) $('#space').text("--/--"); else $('#space').text(data.used + " / " + data.total); - } ); + }); } ); function formatDate(fmt,date) { diff --git a/rootfs/link/web/func.php b/rootfs/link/web/func.php index 7785524..1367546 100644 --- a/rootfs/link/web/func.php +++ b/rootfs/link/web/func.php @@ -396,24 +396,78 @@ function formatDisk() { $result->result = "OK"; } +function getMountedPath() { + global $result; + exec("df -h /root/usb | awk 'NR==2 {print $1}' | grep -v '/dev/root\|ubi0:ubifs'",$output); + $result->result = $output[0]; +} + +function getLocalDisk() { + global $result; + $output = shell_exec("ls /dev/sd*"); + $arys = explode("\n",$output); + + $hardware = json_decode(file_get_contents("/link/config/hardware.json")); + $chip = $hardware->chip; + if($chip == "SS524V100" || $chip == "SS528V100") + $arys[] = "/dev/mmcblk0p6"; + + $retList = array(); + for($i=0;$i 1) + continue; + $size = shell_exec("blockdev --getsize64 ".$item); + $diskInfo = array( + "name" => $item, + "size" => formatBytes($size) + ); + $retList[] = $diskInfo; + } + $result->result = $retList; +} + function mountDisk() { global $result; - $output=array(); - exec( "ls /dev/sda",$output); - if(count($output) == 0) - { - $result->error = "没有检测到外部存储设备No external storage device is detected"; - return; - } - unset($output); - exec("mount -t vfat -o rw,relatime,codepage=936,utf8 /dev/sda1 /root/usb"); - exec("mount -t ext4 /dev/sda1 /root/usb"); - exec("ntfs-3g /dev/sda1 /root/usb"); - exec("df -h | grep /root/usb",$output); - if(count($output) == 1) - $result->result = "OK"; - else - $result->error = "外部存储设备挂载失败The external storage device failed to be mounted"; + exec("/link/shell/mount.sh",$output); + $result->result = $output[0]; + if($output[0] == "0") + $result->error = "外部存储设备挂载失败The external storage device failed to be mounted"; +} + +function formatBytes($total) { + $config = [ + '4' => 'TB', + '3' => 'GB', + '2' => 'MB', + '1' => 'KB' + ]; + foreach ($config as $key => $value) { + if ($total >= pow(1024, $key)) { + return number_format($total / pow(1024, $key), 2) . $value; + } + } + return '0KB'; +} + +function getDiskSpace() { + global $result; + $mountDir = '/root/usb'; + $output = shell_exec('df ' . $mountDir); + + if(strpos($output, $mountDir) != false) { + $totalSpace = disk_total_space($mountDir); + $freeSpace = disk_free_space($mountDir); + $usedSpace = $totalSpace - $freeSpace; + + $result->total = formatBytes($totalSpace); + $result->free = formatBytes($freeSpace); + $result->used = formatBytes($usedSpace); + } else { + $result->total = 0; + $result->free = 0; + $result->used = 0; + } } function setTimeZone() { diff --git a/rootfs/link/web/head.php b/rootfs/link/web/head.php index 5050545..f4c60f6 100644 --- a/rootfs/link/web/head.php +++ b/rootfs/link/web/head.php @@ -120,6 +120,12 @@ include("headhead.php"); +
  • + + 存储挂载 + Mount Disk + +