Commit 3105b752 authored by Oleg Dzhimiev's avatar Oleg Dzhimiev

set camogm raw recording back to lba_start

parent 408939d2
...@@ -31,7 +31,17 @@ else if (isset($argv[1])) ...@@ -31,7 +31,17 @@ else if (isset($argv[1]))
#hardcoded for eyesis4pi #hardcoded for eyesis4pi
$symlink = "/www/pages/ssd"; $symlink = "/www/pages/ssd";
$mountpoint = "/mnt/sda1"; $mountpoint = "/mnt/sda1";
$camogmdisk = "/home/root/camogm.disk"; $camogmdisk = "/home/root/camogm.disk";
$nandbootpath = "/tmp/rootfs.ro";
if (is_dir($nandbootpath)) $camogmdisk = $nandbootpath.$camogmdisk;
$sysfs_lba_path = "/sys/devices/soc0/amba@0/80000000.elphel-ahci/";
$file_lba_start = $sysfs_lba_path."lba_start";
$file_lba_current = $sysfs_lba_path."lba_current";
$file_lba_end = $sysfs_lba_path."lba_end";
switch($cmd){ switch($cmd){
case "symlink": case "symlink":
...@@ -45,7 +55,22 @@ switch($cmd){ ...@@ -45,7 +55,22 @@ switch($cmd){
$sda1 .= "G"; $sda1 .= "G";
} }
//sda2 //sda2
$lba_start = 0;
$lba_current = 0;
$lba_end = 0;
if (is_file($file_lba_start)) $lba_start = intval(trim(file_get_contents($file_lba_start)));
if (is_file($file_lba_current)) $lba_current = intval(trim(file_get_contents($file_lba_current)));
if (is_file($file_lba_end)) $lba_end = intval(trim(file_get_contents($file_lba_end)));
if (($lba_start!=0)&&($lba_current!=0)&&($lba_end!=0)){
$size = ($lba_end - $lba_current)/2/1024/1024;
$sda2 = round($size,2);
$sda2 .= "G";
}else{
// camogm.disk not found
if (!is_file($camogmdisk)){ if (!is_file($camogmdisk)){
$devices = get_raw_dev(); $devices = get_raw_dev();
foreach($devices as $device=>$size){ foreach($devices as $device=>$size){
...@@ -57,6 +82,18 @@ switch($cmd){ ...@@ -57,6 +82,18 @@ switch($cmd){
} }
}else{ }else{
//read camogm.disk file //read camogm.disk file
$content = file_get_contents($camogmdisk);
$content = trim(preg_replace('/\n|\t{2,}/',"\t",$content));
$content_arr = explode("\t",$content);
if (count($content_arr)>=8){
$device = $content_arr[4];
$lba_current = $content_arr[6];
$lba_end = $content_arr[7];
$size = ($lba_end - $lba_current)/2/1024/1024;
$sda2 = round($size,2);
$sda2 .= "G";
}else{
//tmp //tmp
$devices = get_raw_dev(); $devices = get_raw_dev();
foreach($devices as $device=>$size){ foreach($devices as $device=>$size){
...@@ -67,9 +104,18 @@ switch($cmd){ ...@@ -67,9 +104,18 @@ switch($cmd){
} }
} }
} }
}
}
respond_xml("{$sda1} {$sda2}"); respond_xml("{$sda1} {$sda2}");
break;
case "reset_camogm_fastrec":
//remove file
if (is_file($camogmdisk)){
unlink($camogmdisk);
}
file_put_contents($file_lba_current,file_get_contents($file_lba_start));
print("reset fastrec: ok");
break; break;
case "free_space_bkp": case "free_space_bkp":
// results are in GB // results are in GB
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment