From 46618a68e43698423d7d332d713e92bacacd6e4a Mon Sep 17 00:00:00 2001 From: Nicolas Boichat Date: Sun, 16 Oct 2005 21:35:48 +0000 Subject: [PATCH] Remove scripts/dvd-freespace and scripts/dvd-writepart, as they are now merged into scripts/dvd-handler. Note: Documentation needs to be updated. git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@2453 91ce42f0-d328-0410-95d8-f526ca767f89 --- bacula/nb-1.37 | 2 + bacula/scripts/.cvsignore | 2 - bacula/scripts/dvd-freespace.in | 120 -------------------------------- bacula/scripts/dvd-writepart.in | 119 ------------------------------- 4 files changed, 2 insertions(+), 241 deletions(-) delete mode 100755 bacula/scripts/dvd-freespace.in delete mode 100644 bacula/scripts/dvd-writepart.in diff --git a/bacula/nb-1.37 b/bacula/nb-1.37 index a936e1b36f..1beab53b96 100644 --- a/bacula/nb-1.37 +++ b/bacula/nb-1.37 @@ -5,6 +5,8 @@ General: Changes to 1.37.*: 16Oct05 + - Remove scripts/dvd-freespace and scripts/dvd-writepart, as they are now + merged into scripts/dvd-handler. Note: Documentation needs to be updated. - scripts/dvd-handler: "zero" brand-new DVD+/-RW to fix a problem with some DVD-writers, thanks to Arno Lehmann for reporting this, and providing the way to fix it. diff --git a/bacula/scripts/.cvsignore b/bacula/scripts/.cvsignore index c0ba40d074..f1c514e9e1 100644 --- a/bacula/scripts/.cvsignore +++ b/bacula/scripts/.cvsignore @@ -9,8 +9,6 @@ bconsole devel_bacula gconsole mtx-changer -dvd-writepart -dvd-freespace dvd-handler Makefile bacula diff --git a/bacula/scripts/dvd-freespace.in b/bacula/scripts/dvd-freespace.in deleted file mode 100755 index c40f067a8a..0000000000 --- a/bacula/scripts/dvd-freespace.in +++ /dev/null @@ -1,120 +0,0 @@ -#!@PYTHON@ -# -# Check the free space available on a writable DVD -# Should always exit with 0 status, otherwise it indicates a serious error. -# (wrong number of arguments, Python exception...) -# -# called: dvd-freespace -# -# -# returns: -# Prints on the first output line the free space available in bytes. -# If an error occurs, prints a negative number (-errno), followed, -# on the second line, by an error message. -# -# $Id$ - -# Configurable values: -growcmd = "@GROWISOFS@" - -growcmd += " -use-the-force-luke=tty" -growcmd += " -quiet" - -margin=10485760 # 10 mb security margin - -#### You should probably not modify anything below this line - -# Example : -# growisofs -F /dev/your_device -# -# Executing 'mkisofs | builtin_dd of=/dev/hde obs=32k seek=0' -# next_session=0 -# capacity=4700372992 - -import popen2 -import os -import errno -import sys -import re - -if len(sys.argv) < 2: - print "Wrong number of arguments." - sys.exit(1) - -device=sys.argv[1] - -def is4gbsupported(): - processi = popen2.Popen4("uname -s -r") - status = processi.wait() - if not os.WIFEXITED(status): -# print "dvd-writepart: Cannot execute uname, allowing to cross the 4gb boundary." - return 1 - if os.WEXITSTATUS(status) != 0: -# print "dvd-writepart: Cannot execute uname, allowing to cross the 4gb boundary." - return 1 - strres = processi.fromchild.readline()[0:-1] - res = strres.split(" ") - if len(res) != 2: -# print "dvd-writepart: Unable to parse uname (" + strres + "), allowing to cross the 4gb boundary." - return 1 - if res[0] != "Linux": -# print "dvd-writepart: The current OS is no Linux, allowing to cross the 4gb boundary." - return 1 - ver = res[1].split(".") - if len(ver) < 3: -# print "dvd-writepart: Unable to parse version string (" + res[1] + "), allowing to cross the 4gb boundary." - return 1 - subver = ver[2].split("-") - - if ((not ver[0].isdigit()) or (not ver[1].isdigit()) or (not subver[0].isdigit())): -# print "dvd-writepart: Unable to parse version string (" + res[1] + "), allowing to cross the 4gb boundary." - return 1 - - if (int(ver[0]) > 2) or (int(ver[1]) > 6) or ((int(ver[0]) == 2) and (int(ver[1]) == 6) and (int(subver[0]) >= 8)): -# print "dvd-writepart: Kernel version >=2.6.8, allowing to cross the 4gb boundary." - return 1 - else: -# print "dvd-writepart: Kernel version <2.6.8, not allowing to cross the 4gb boundary." - return 0 - -def getfreespace(): - processi = popen2.Popen4(growcmd) - status = processi.wait() - if not os.WIFEXITED(status): - print -errno.EPIPE - print growcmd + " process did not exit correctly." - sys.exit(0) - result = processi.fromchild.read() - if os.WEXITSTATUS(status) != 0: - if (os.WEXITSTATUS(status) & 0x7F) == errno.ENOSPC: - print 0 - print growcmd + " returned with an errno.ENOSPC" - else: - print -os.WEXITSTATUS(status) - print growcmd + " returned with an error" - print result - sys.exit(0) - next_session = re.search(r"\snext_session=(\d+)\s", result, re.MULTILINE) - capacity = re.search(r"\capacity=(\d+)\s", result, re.MULTILINE) - - if next_session and capacity: - # testing cheat (emulate 4GB boundary at 100MB) - if long(next_session.group(1)) > 100000000: - return 0 - return long(capacity.group(1))-long(next_session.group(1)) - else: - print -errno.EPIPE - print "Cannot get media lead-out index from " + dvdrwmediainfo - sys.exit(0) - -if is4gbsupported(): - growcmd += " -use-the-force-luke=4gms" - -growcmd += " -F " + device - -size = getfreespace()-margin -if size < 0: - size = 0 -print size -print "No error occurred" -sys.exit(0) diff --git a/bacula/scripts/dvd-writepart.in b/bacula/scripts/dvd-writepart.in deleted file mode 100644 index a80ddfd7e8..0000000000 --- a/bacula/scripts/dvd-writepart.in +++ /dev/null @@ -1,119 +0,0 @@ -#!@PYTHON@ -# -# Bacula interface to growisofs, used to write to DVD+/-R(W) -# -# $Id$ -# -# If you set in your Device resource -# -# Write Part Command = "path-to-this-script/dvd-writepart %e %a %v" -# you will have the following input to this script: -# -# dvd-writepart "erase" "device" "part_filename" -# 1 2 3 -# -# for example: -# -# dvd-writepart 0 /dev/hda File-0001 - -mkisofs = "@MKISOFS@" -growcmd = "@GROWISOFS@" - -growcmd += " -use-the-force-luke=tty" -growcmd += " -quiet" - -# Comment the following line if you want the tray to be reloaded -# when writing ends. -growcmd += " -use-the-force-luke=notray" - -#### You should probably not modify anything below this line - -import popen2 -import os -import sys -import time -import signal - -pid=0 - -def is4gbsupported(): - processi = popen2.Popen4("uname -s -r") - status = processi.wait() - if not os.WIFEXITED(status): - print "dvd-writepart: Cannot execute uname, allowing to cross the 4gb boundary." - return 1 - if os.WEXITSTATUS(status) != 0: - print "dvd-writepart: Cannot execute uname, allowing to cross the 4gb boundary." - return 1 - strres = processi.fromchild.readline()[0:-1] - res = strres.split(" ") - if len(res) != 2: - print "dvd-writepart: Unable to parse uname (" + strres + "), allowing to cross the 4gb boundary." - return 1 - if res[0] != "Linux": - print "dvd-writepart: The current OS is no Linux, allowing to cross the 4gb boundary." - return 1 - ver = res[1].split(".") - if len(ver) < 3: - print "dvd-writepart: Unable to parse version string (" + res[1] + "), allowing to cross the 4gb boundary." - return 1 - subver = ver[2].split("-") - - if ((not ver[0].isdigit()) or (not ver[1].isdigit()) or (not subver[0].isdigit())): - print "dvd-writepart: Unable to parse version string (" + res[1] + "), allowing to cross the 4gb boundary." - return 1 - - if (int(ver[0]) > 2) or (int(ver[1]) > 6) or ((int(ver[0]) == 2) and (int(ver[1]) == 6) and (int(subver[0]) >= 8)): - print "dvd-writepart: Kernel version >=2.6.8, allowing to cross the 4gb boundary." - return 1 - else: - print "dvd-writepart: Kernel version <2.6.8, not allowing to cross the 4gb boundary." - return 0 - -def term_handler(signum, frame): - print 'dvd-writepart: Signal term_handler called with signal', signum - if pid != 0: - print "dvd-writepart: Sending SIGTERM to pid", pid - os.kill(pid, signal.SIGTERM) - time.sleep(3) - print "dvd-writepart: Sending SIGKILL to pid", pid - os.kill(pid, signal.SIGKILL) - sys.exit(1) - -if len(sys.argv) != 4: - print "dvd-writepart: Wrong number of arguments." - sys.exit(1) - -if is4gbsupported(): - growcmd += " -use-the-force-luke=4gms" - -if sys.argv[1] == "0": - growcmd += " -M" -else: - growcmd += " -Z" - -growcmd += " " + sys.argv[2] # device -growcmd += " -R " + sys.argv[3] # filename - -#Test cmd: -#growcmd = "bash -c \"while [ 1 ]; do echo \"G\"; sleep 5; done\"" - -print "dvd-writepart: executing: " + growcmd - -signal.signal(signal.SIGTERM, term_handler) - -processi = popen2.Popen4(growcmd) -pid = processi.pid -status = processi.poll() -while status == -1: - line = processi.fromchild.readline() - while len(line) > 0: - print line, - line = processi.fromchild.readline() - time.sleep(1) - status = processi.poll() - -if os.WEXITSTATUS(status) != 0: - print "dvd-writepart: Bad exit status " + str(os.WEXITSTATUS(status)) - sys.exit(os.WEXITSTATUS(status)) - -- 2.39.5