]> git.sur5r.net Git - bacula/bacula/blobdiff - bacula/scripts/dvd-handler.in
update
[bacula/bacula] / bacula / scripts / dvd-handler.in
index f51e9473d0d4331ad0945ba82acd3c65bfa89237..a02878eaf23aa9fff542ae3e6f0e1844a2c1a09b 100644 (file)
@@ -6,14 +6,34 @@
 #
 #  called:  dvd-handler <dvd-device-name> operation args
 #
-#  where operation is one of
-#    free
-#    write
+#  operations used by Bacula:
+#
+#   free  (no arguments)
+#            Scan the device and report the available space. It 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.
+#
+#   write  op filename
+#             Write a part file to disk.
+#             This operation needs two additional arguments.
+#             The first (op) indicates to
+#                 0 -- append
+#                 1 -- first write to a blank disk
+#                 2 -- blank or truncate a disk
+#
+#              The second is the filename to write
+#
+#   operations available but not used by Bacula:
+#
+#   test      Scan the device and report the information found.
+#             This operation needs no further arguments.
+#   prepare   Prepare a DVD+/-RW for being used by Bacula.
+#             Note: This is only useful if you already have some
+#             non-Bacula data on a medium, and you want to use
+#             it with Bacula. Don't run this on blank media, it
+#             is useless.
 #
-# in case of operation ``free'' 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$
 #
@@ -68,7 +88,7 @@ class disk:
 #               This method should also prepare a blank disk so that a
 #               certain part of the disk is used to allow detection of a
 #               used disk by all / more disk drives.
-# blank         Blank the device
+# prepare       Blank the device
 #
 ###############################################################################
    def __init__(self, devicename):
@@ -266,10 +286,10 @@ class disk:
       
       cmd = self.growcmd + self.growparams
       if newvol:
-        cmd += " -Z "
         # Ignore any existing iso9660 filesystem - used for truncate
         if newvol == 2:
-            cmd += "-use-the-force-luke=tty "
+            cmd += " -use-the-force-luke=tty"
+        cmd += " -Z "
       else:
         cmd += " -M "
       cmd += self.device + " " + str(partfile)
@@ -288,6 +308,8 @@ class disk:
       self.pid = 0
       print
       signal.signal(signal.SIGTERM, oldsig)
+      if not os.WIFEXITED(status):
+        raise DVDError(0, cmd + " process did not exit correctly, signal/status " + str(status))
       if os.WEXITSTATUS(status) != 0:
         raise DVDError(os.WEXITSTATUS(status), cmd + " exited with status " + str(os.WEXITSTATUS(status)) + ", signal/status " + str(status))
 
@@ -390,7 +412,7 @@ Usage:
 dvd-handler DEVICE test
 dvd-handler DEVICE free
 dvd-handler DEVICE write APPEND FILE
-dvd-handler DEVICE blank
+dvd-handler DEVICE prepare
 
 where DEVICE is a device name like /dev/sr0 or /dev/dvd.
 
@@ -430,7 +452,7 @@ if "free" == sys.argv[2]:
         print free
         print "No Error reported."
    else:
-      print "Wrong number of arguments for free operation."
+      print "Wrong number of arguments for free operation. Wanted 3 got", len(sys.argv)
       usage()
 elif "prepare" == sys.argv[2]:
    if len(sys.argv) == 3:
@@ -445,7 +467,7 @@ elif "prepare" == sys.argv[2]:
       else:
         print "Medium prepared successfully."
    else:
-      print "Wrong number of arguments for prepare operation."
+      print "Wrong number of arguments for prepare operation. Wanted 3 got", len(sys.argv)
       usage()
 elif "test" == sys.argv[2]:
    try:
@@ -467,7 +489,7 @@ elif "write" == sys.argv[2]:
       else:
         print "Part file " + sys.argv[4] + " successfully written to disk."
    else:
-      print "Wrong number of arguments for write operation."
+      print "Wrong number of arguments for write operation. Wanted 5 got", len(sys.argv)
       usage()
       sys.exit(1)
 else: