return true;
}
+function disk_get_size($file, $realname="")
+{
+ global $BASE_DATA, $BASE_LIB, $BACULA_USER, $argv;
+
+ check_init_and_fail($argv[1]);
+
+ $changer = $argv[1];
+
+ error_reporting(E_ALL);
+
+ $dh = opendir("/dev/disk/by-uuid");
+ $amdir = conf_getVal($changer, "automountdir");
+
+ $ts = 0;
+
+ $parsed = false;
+ if(file_exists("/$amdir/$file/.")) {
+ $cmd = "/bin/df -k /$amdir/$file/. |/usr/bin/tail -1 |/usr/bin/awk '{ print $4 }'";
+ $pl = popen($cmd, "r");
+ if($pl) {
+ $f = fread($pl, 1024);
+ echo "cmd: $cmd\nf: $f\n";
+ $ts = (int)($f);
+ if($ts > 1) $parsed = true;
+ pclose($pl);
+ }
+ }
+
+ if(!$parsed && $realname != "") {
+ $fh = fopen("/sys/class/block/$realname/size", "r");
+ $lk = ((int)(fgets($fh)));
+ $ts = ($lk/1024)*512;
+ fclose($fh);
+
+ }
+
+ $realsize = (int)(($ts/1024)/1024);
+
+ return $realsize;
+}
+
function add_disk()
{
// disks get inited by going to /changer_dir/disk_uuid/ then:
check_init_and_fail($argv[1]);
+ $changer = $argv[1];
+
$dh = opendir("/dev/disk/by-uuid");
+ $amdir = conf_getVal($changer, "automountdir");
$disk = "";
$i = 0;
if($file != "." && $file != "..") {
$st = stat("/dev/disk/by-uuid/".$file);
$realname = basename(readlink("/dev/disk/by-uuid/".$file));
+ $realsize = disk_get_size($file, $realname);
- // now get the size
- $fh = fopen("/sys/class/block/$realname/size", "r");
- $rl = fgets($fh);
- fclose($fh);
- $realsize = (int)(((($rl/1024)*512)/1024)/1024);
-
+ // now get the size, first lets try and parse df output
echo "disk $i: /dev/$realname or /dev/disk/by-uuid/$file of size ".$realsize."gb\n";
$disk[$i]["real"] = "/dev/$realname";
$disk[$i]["syml"] = "/dev/disk/by-uuid/".$file;
$disk[$i]["size"] = $realsize;
$i++;
+
}
}
cp -rp bin/* $install_base/bin
cp -rp lib/* $install_base/lib
-chown -R $user_id $install_base
\ No newline at end of file
+chown -R $user_id $install_base
+chmod 755 $install_base/bin/*
\ No newline at end of file