395898
diff -up cdrkit-1.1.11/wodim/drv_mmc.c.format cdrkit-1.1.11/wodim/drv_mmc.c
395898
--- cdrkit-1.1.11/wodim/drv_mmc.c.format	2011-05-18 16:49:14.591822130 +0200
395898
+++ cdrkit-1.1.11/wodim/drv_mmc.c	2011-05-18 16:49:14.596822130 +0200
395898
@@ -1507,6 +1507,11 @@ getdisktype_mdvd(SCSI *usalp, cdr_t *dp)
395898
 	dstat_t	*dsp = dp->cdr_dstat;
395898
 
395898
 	struct track_info track_info;
395898
+
395898
+	extern char *buf;
395898
+	struct disk_info *dip;
395898
+	int profile;
395898
+
395898
     if(lverbose)
395898
         printf("HINT: use dvd+rw-mediainfo from dvd+rw-tools for information extraction.\n");
395898
 	/* if(getdisktype_mmc(usalp, dp)<0)
395898
@@ -1521,6 +1526,18 @@ getdisktype_mdvd(SCSI *usalp, cdr_t *dp)
395898
 	dsp->ds_disktype&= ~DT_CD;
395898
 	dsp->ds_disktype|= DT_DVD;
395898
 
395898
+	profile = get_curprofile(usalp);
395898
+	if (profile == 0x1A) {
395898
+		dip = (struct disk_info *)buf;
395898
+		if (get_diskinfo(usalp, dip) < 0)
395898
+			return (-1);
395898
+		if (dip->disk_status == DS_EMPTY) {	/* Unformatted	    */
395898
+			dsp->ds_flags |= DSF_NEED_FORMAT;
395898
+			if(lverbose)
395898
+				printf("The medium is empty, it will be auto formatted.\n");
395898
+		}
395898
+	}
395898
+	
395898
 	return (ret);
395898
 
395898
 }
395898
diff -up cdrkit-1.1.11/wodim/scsi_cdr.c.format cdrkit-1.1.11/wodim/scsi_cdr.c
395898
--- cdrkit-1.1.11/wodim/scsi_cdr.c.format	2011-05-18 16:49:14.601822130 +0200
395898
+++ cdrkit-1.1.11/wodim/scsi_cdr.c	2011-05-18 16:49:14.600822130 +0200
395898
@@ -1328,7 +1328,7 @@ scsi_format(SCSI *usalp, caddr_t addr, i
395898
 	}
395898
 	sleep(10);
395898
 	printf("\rFormating in progress: 100.00 %% done.        \n");
395898
-	if (pid) exit (0);
395898
+	if (pid > 0) exit (0);
395898
 	return ret;
395898
 }
395898
 
395898
diff -up cdrkit-1.1.11/wodim/wodim.c.format cdrkit-1.1.11/wodim/wodim.c
395898
--- cdrkit-1.1.11/wodim/wodim.c.format	2011-05-18 16:49:14.584822130 +0200
395898
+++ cdrkit-1.1.11/wodim/wodim.c	2011-05-18 17:21:59.510821630 +0200
395898
@@ -946,6 +946,40 @@ int main(int argc, char *argv[])
395898
 		print_toc(usalp, dp);
395898
 		comexit(0);
395898
 	}
395898
+	
395898
+	if ((flags & F_FORMAT) || (dp->cdr_dstat->ds_flags & DSF_NEED_FORMAT)) {
395898
+		printf("wodim: media format asked\n");
395898
+		/*
395898
+		* Do not abort if OPC failes. Just give it a chance
395898
+		* for better laser power calibration than without OPC.
395898
+		*
395898
+		* Ricoh drives return with a vendor unique sense code.
395898
+		* This is most likely because they refuse to do OPC
395898
+		* on a non blank media.
395898
+		*/
395898
+		usalp->silent++;
395898
+		do_opc(usalp, dp, flags);
395898
+		usalp->silent--;
395898
+		wait_unit_ready(usalp, 120);
395898
+		if (gettimeofday(&starttime, (struct timezone *)0) < 0)
395898
+			errmsg("Cannot get start time\n");
395898
+		
395898
+		if ((*dp->cdr_format)(usalp, dp, formattype) < 0) {
395898
+			errmsgno(EX_BAD, "Cannot format disk, aborting.\n");
395898
+			comexit(EX_BAD);
395898
+		}
395898
+		if (gettimeofday(&fixtime, (struct timezone *)0) < 0)
395898
+			errmsg("Cannot get format time\n");
395898
+		if (lverbose)
395898
+			prtimediff("Formatting time: ", &starttime, &fixtime);
395898
+
395898
+		if (!wait_unit_ready(usalp, 240) || tracks == 0) {
395898
+			comexit(0);
395898
+		}
395898
+		if (gettimeofday(&starttime, (struct timezone *)0) < 0)
395898
+			errmsg("Cannot get start time\n");
395898
+	}
395898
+	
395898
 #ifdef	XXX
395898
 	if ((*dp->cdr_check_session)() < 0) {
395898
 		comexit(EX_BAD);
395898
@@ -1230,38 +1264,6 @@ int main(int argc, char *argv[])
395898
 			comexit(0);
395898
 		}
395898
 	}
395898
-	if (flags & F_FORMAT) {
395898
-		printf("wodim: media format asked\n");
395898
-		/*
395898
-		* Do not abort if OPC failes. Just give it a chance
395898
-		* for better laser power calibration than without OPC.
395898
-		*
395898
-		* Ricoh drives return with a vendor unique sense code.
395898
-		* This is most likely because they refuse to do OPC
395898
-		* on a non blank media.
395898
-		*/
395898
-		usalp->silent++;
395898
-		do_opc(usalp, dp, flags);
395898
-		usalp->silent--;
395898
-		wait_unit_ready(usalp, 120);
395898
-		if (gettimeofday(&starttime, (struct timezone *)0) < 0)
395898
-			errmsg("Cannot get start time\n");
395898
-
395898
-		if ((*dp->cdr_format)(usalp, dp, formattype) < 0) {
395898
-			errmsgno(EX_BAD, "Cannot format disk, aborting.\n");
395898
-			comexit(EX_BAD);
395898
-		}
395898
-		if (gettimeofday(&fixtime, (struct timezone *)0) < 0)
395898
-			errmsg("Cannot get format time\n");
395898
-		if (lverbose)
395898
-			prtimediff("Formatting time: ", &starttime, &fixtime);
395898
-
395898
-		if (!wait_unit_ready(usalp, 240) || tracks == 0) {
395898
-			comexit(0);
395898
-		}
395898
-		if (gettimeofday(&starttime, (struct timezone *)0) < 0)
395898
-			errmsg("Cannot get start time\n");
395898
-	}
395898
 	/*
395898
 	* Reset start time so we will not see blanking time and
395898
 	* writing time counted together.