X-Git-Url: http://git.pjr.cc/?p=php-bacula-disk-changer.git;a=blobdiff_plain;f=bin%2Fpbdc-bacula.php;h=c86a4bcb4553b6ea596324d893b4c96c3592a5ed;hp=5a365262c55ab90bb586ebe50958c3652c213e84;hb=832062ed9a2f52a60d48c739e3ea8a68012cf19c;hpb=95682a89442421c2ae8bfbf729c255c993874d7c diff --git a/bin/pbdc-bacula.php b/bin/pbdc-bacula.php index 5a36526..c86a4bc 100644 --- a/bin/pbdc-bacula.php +++ b/bin/pbdc-bacula.php @@ -114,25 +114,17 @@ function loaded_tape() } $ret = false; - $i=1; + $i=-1; + + $sql = "select slot_no from slots where tape_name=='$rl'"; + $res = $db->query($sql); + foreach($res as $row) { - //echo "Listing tapes for disk ".$row["disk_id"].", ".$row["disk_name"]."\n"; - //echo "dir: $amloc/".$row["disk_name"]."/pbdc/".$argv[1]."/tapes/\n"; - //exit(0); - $dh = opendir("$amloc/".$row["disk_name"]."/pbdc/".$argv[1]."/tapes/"); - while(($file = readdir($dh)) !== false) { - if(ereg("d[0-9]+_vol[0-9]+", $file)!=false) { - if($rl == $file) { - echo "$i\n"; - exit(0); - } - $i++; - } else { - //echo "didnt match: $file\n"; - } - //exit(0); - } - closedir($dh); + $i = $row[0]; + } + if($i != -1) { + echo "$i\n"; + return; } echo "0\n";