fedf45c
Patch adding support for bacula by Luigi Gangitano <luigi@debian.org>
fedf45c
fedf45c
 * Allow session to cross 4GB boundary regardless of medium type
fedf45c
 * Add a -F option (used instead of -M or -Z), which displays 
fedf45c
   next_session offset and capacity
fedf45c
fedf45c
fedf45c
diff -Naur dvd+rw-tools-7.0.orig/growisofs.c dvd+rw-tools-7.0/growisofs.c
fedf45c
--- dvd+rw-tools-7.0.orig/growisofs.c	2006-09-24 17:28:53.000000000 +0000
fedf45c
+++ dvd+rw-tools-7.0/growisofs.c	2006-10-29 14:18:35.000000000 +0000
fedf45c
@@ -370,6 +370,11 @@
fedf45c
  *   upon Layer Break command, therefore longer timeout is required;
fedf45c
  * - Linux: deploy BLKFLSBUF to avoid media reloads when possible;
fedf45c
  * - add unit buffer utilization indicator [by request from K3b];
fedf45c
+ * Additions by Nicolas Boichat, Bacula project
fedf45c
+ * - Allow session to cross 4GB boundary regardless of medium type
fedf45c
+ *   (don't need to have a DL media)
fedf45c
+ * - Add a -F option (used instead of -M or -Z), which displays next_session
fedf45c
+ *   offset and capacity (free space = next_session - capacity).
fedf45c
  */
fedf45c
 #define PRINT_VERSION(cmd)	do {			\
fedf45c
     char *s=strrchr((cmd),'/');				\
fedf45c
@@ -2773,6 +2778,18 @@
fedf45c
 		else          in_device = argv[++i];
fedf45c
 		dev_found = 'Z';
fedf45c
 	    }
fedf45c
+	    else if (argv[i][1] == 'F')
fedf45c
+	    {	if (len > 2) in_device = argv[i]+2;
fedf45c
+		else	     in_device = argv[++i];
fedf45c
+		dev_found = 'F';
fedf45c
+		dry_run = 1; /* NEVER write anything with -F */
fedf45c
+	    }
fedf45c
+	    else if (!strncmp(opt,"-free-space",11))
fedf45c
+	    {	if (len > 11) in_device = opt+11;
fedf45c
+		else          in_device = argv[++i];
fedf45c
+		dev_found = 'F';
fedf45c
+		dry_run = 1; /* NEVER write anything with -F */
fedf45c
+	    }
fedf45c
 	    else if (!strcmp(opt,"-poor-man"))
fedf45c
 	    {	if (poor_man<0) poor_man = 1;
fedf45c
 		continue;
fedf45c
@@ -2993,7 +3010,9 @@
fedf45c
 		fprintf (stderr,"    you most likely want to use -Z option.\n"), 
fedf45c
 		exit (FATAL_START(errno));
fedf45c
 
fedf45c
-	    if (dev_found == 'M')
fedf45c
+		if ((dev_found == 'M') || 
fedf45c
+			((dev_found == 'F') && !(mmc_profile&0x10000)) && (saved_descriptors[0].type[0] || saved_descriptors[0].type[1] || saved_descriptors[0].type[2]))
fedf45c
+				/* -F : The medium is not blank, there is a fs on it (the_buffer[0,1 or 2] != 0), so compute next_session. */
fedf45c
 	    {	if (memcmp (saved_descriptors[0].type,"\1CD001",6))
fedf45c
 	            fprintf (stderr,":-( %s doesn't look like isofs...\n",
fedf45c
 		    		in_device), exit(FATAL_START(EMEDIUMTYPE));
fedf45c
@@ -3016,8 +3035,7 @@
fedf45c
 			exit(FATAL_START(EINVAL));
fedf45c
 		}
fedf45c
 		else if (next_session > (0x200000-0x5000)) /* 4GB/2K-40MB/2K */
fedf45c
-		    if ((mmc_profile&0xFFFF)<0x20 ||
fedf45c
-			((mmc_profile&0xFFFF)<0x40 && !no_4gb_check))
fedf45c
+		    if (!no_4gb_check)
fedf45c
 			fprintf (stderr,":-( next session would cross 4GB "
fedf45c
 					"boundary, aborting...\n"),
fedf45c
 			exit (FATAL_START(ENOSPC));
fedf45c
@@ -3060,7 +3078,7 @@
fedf45c
 	exit (FATAL_START(EINVAL));
fedf45c
 
fedf45c
     if (imgfd<0)
fedf45c
-    {	if (mkisofs_argc==1)
fedf45c
+    {	if ((mkisofs_argc==1) && (dev_found != 'F'))
fedf45c
 	    fprintf (stderr,"%s: no mkisofs options specified, "
fedf45c
 			    "aborting...\n",argv[0]),
fedf45c
 	    exit (FATAL_START(EINVAL));
fedf45c
@@ -3244,6 +3262,15 @@
fedf45c
 	}
fedf45c
     }
fedf45c
 
fedf45c
+	if (dev_found == 'F') {
fedf45c
+		off64_t capacity = 0;
fedf45c
+		printf("next_session=%lld\n", next_session*CD_BLOCK);
fedf45c
+		if (ioctl_handle!=INVALID_HANDLE)
fedf45c
+			capacity = get_capacity (ioctl_handle);
fedf45c
+		printf("capacity=%lld\n", capacity);
fedf45c
+		exit(0);
fedf45c
+	}
fedf45c
+
fedf45c
     if (imgfd>=0)
fedf45c
     {	quiet--;
fedf45c
 	if (builtin_dd (imgfd,out_fd,next_session*CD_BLOCK) < 0)