[Midnightbsd-cvs] src [9845] update burncd

laffer1 at midnightbsd.org laffer1 at midnightbsd.org
Tue May 22 21:37:38 EDT 2018


Revision: 9845
          http://svnweb.midnightbsd.org/src/?rev=9845
Author:   laffer1
Date:     2018-05-22 21:37:37 -0400 (Tue, 22 May 2018)
Log Message:
-----------
update burncd

Modified Paths:
--------------
    trunk/usr.sbin/burncd/burncd.8
    trunk/usr.sbin/burncd/burncd.c

Property Changed:
----------------
    trunk/usr.sbin/burncd/burncd.8

Modified: trunk/usr.sbin/burncd/burncd.8
===================================================================
--- trunk/usr.sbin/burncd/burncd.8	2018-05-15 20:52:32 UTC (rev 9844)
+++ trunk/usr.sbin/burncd/burncd.8	2018-05-23 01:37:37 UTC (rev 9845)
@@ -28,12 +28,19 @@
 .\" $FreeBSD: src/usr.sbin/burncd/burncd.8,v 1.37.2.1 2005/07/17 15:03:36 brueffer Exp $
 .\" $MidnightBSD$
 .\"
-.Dd May 2, 2005
+.Dd October 9, 2011
+.Dt BURNCD 8
 .Os
-.Dt BURNCD 8
 .Sh NAME
 .Nm burncd
 .Nd control the ATAPI CD-R/RW driver
+.Pp
+This utility was
+.Em deprecated
+in
+.Fx 9.0 .
+See
+.Sx NOTES .
 .Sh SYNOPSIS
 .Nm
 .Op Fl deFlmnpqtv
@@ -47,7 +54,6 @@
 utility is used to burn CD-R/RW media using the ATAPI cd driver.
 .Pp
 Available options and operands:
-.Pp
 .Bl -tag -width XXXXXXXXXXXX
 .It Fl d
 burn the CD-R/RW in DAO (disk at once) mode.
@@ -81,7 +87,6 @@
 .Pp
 .Ar command
 may be one of:
-.Pp
 .Bl -tag -width XXXXXXXXXXXX
 .It Cm msinfo
 Show the first LBA of the last track on the media
@@ -159,7 +164,11 @@
 .Sh ENVIRONMENT
 The following environment variables affect the execution of
 .Nm :
-.Bl -tag -width ".Ev CDROM"
+.Bl -tag -width ".Ev BURNCD_SPEED"
+.It Ev BURNCD_SPEED
+The write speed to use if one is not specified with the
+.Fl s
+flag.
 .It Ev CDROM
 The CD device to use if one is not specified with the
 .Fl f
@@ -210,6 +219,10 @@
 .Nm
 utility appeared in
 .Fx 4.0 .
+.Pp
+.Nm
+was deprecated in
+.Fx 9.0 .
 .Sh AUTHORS
 The
 .Nm
@@ -219,3 +232,19 @@
 .Aq sos at FreeBSD.org .
 .Sh BUGS
 Probably, please report when found.
+.Sh NOTES
+When
+.Bd -ragged -offset indent
+.Cd "options ATA_CAM"
+.Ed
+.Pp
+is compiled into the kernel, then
+.Xr cdrecord 1 ,
+available in the
+.Mx
+Ports Collection as part of the
+.Pa sysutils/cdrtools
+port, must be used instead.
+Refer to:
+.Pp
+http://www.freebsd.org/doc/handbook/creating-cds.html#CDRECORD


Property changes on: trunk/usr.sbin/burncd/burncd.8
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Modified: trunk/usr.sbin/burncd/burncd.c
===================================================================
--- trunk/usr.sbin/burncd/burncd.c	2018-05-15 20:52:32 UTC (rev 9844)
+++ trunk/usr.sbin/burncd/burncd.c	2018-05-23 01:37:37 UTC (rev 9845)
@@ -30,6 +30,7 @@
  */
 
 #include <unistd.h>
+#include <signal.h>
 #include <stdint.h>
 #include <stdio.h>
 #include <stdlib.h>
@@ -58,7 +59,8 @@
 	int	addr;
 };
 static struct track_info tracks[100];
-static int global_fd_for_cleanup, quiet, verbose, saved_block_size, notracks;
+static int quiet, verbose, saved_block_size, notracks;
+static volatile sig_atomic_t global_fd_for_cleanup;
 
 void add_track(char *, int, int, int);
 void do_DAO(int fd, int, int);
@@ -68,6 +70,8 @@
 int roundup_blocks(struct track_info *);
 void cue_ent(struct cdr_cue_entry *, int, int, int, int, int, int, int);
 void cleanup(int);
+void cleanup_flush(void);
+void cleanup_signal(int);
 void usage(void);
 
 int
@@ -77,11 +81,20 @@
 	int dao = 0, eject = 0, fixate = 0, list = 0, multi = 0, preemp = 0;
 	int nogap = 0, speed = 4 * 177, test_write = 0, force = 0;
 	int block_size = 0, block_type = 0, cdopen = 0, dvdrw = 0;
-	const char *dev;
+	const char *dev, *env_speed;
 
+	if (feature_present("ata_cam")) {
+		errx(1, "\nATA_CAM option is enabled in kernel.\n"
+		    "Install the sysutils/cdrtools port and use cdrecord instead.\n\n"
+		    "Please refer to:\n"
+		    "http://www.freebsd.org/doc/handbook/creating-cds.html#CDRECORD");
+	}
+
 	if ((dev = getenv("CDROM")) == NULL)
 		dev = "/dev/acd0";
 
+	env_speed = getenv("BURNCD_SPEED");
+
 	while ((ch = getopt(argc, argv, "def:Flmnpqs:tv")) != -1) {
 		switch (ch) {
 		case 'd':
@@ -121,12 +134,7 @@
 			break;
 
 		case 's':
-			if (strcasecmp("max", optarg) == 0)
-				speed = CDR_MAX_SPEED;
-			else
-				speed = atoi(optarg) * 177;
-			if (speed <= 0)
-				errx(EX_USAGE, "Invalid speed: %s", optarg);
+			env_speed = optarg;
 			break;
 
 		case 't':
@@ -144,6 +152,15 @@
 	argc -= optind;
 	argv += optind;
 
+	if (env_speed == NULL)
+		;
+	else if (strcasecmp("max", env_speed) == 0)
+		speed = CDR_MAX_SPEED;
+	else
+		speed = atoi(env_speed) * 177;
+	if (speed <= 0)
+		errx(EX_USAGE, "Invalid speed: %s", env_speed);
+
 	if (argc == 0)
 		usage();
 
@@ -158,6 +175,9 @@
 
 	global_fd_for_cleanup = fd;
 	err_set_exit(cleanup);
+	signal(SIGHUP, cleanup_signal);
+	signal(SIGINT, cleanup_signal);
+	signal(SIGTERM, cleanup_signal);
 
 	for (arg = 0; arg < argc; arg++) {
 		if (!strcasecmp(argv[arg], "fixate")) {
@@ -189,7 +209,6 @@
 		if ((!strcasecmp(argv[arg], "erase") ||
 		     !strcasecmp(argv[arg], "blank")) && !test_write) {
 			int blank, pct, last = 0;
-			int sec = 0;
 
 			if (!strcasecmp(argv[arg], "erase"))
 				blank = CDR_B_ALL;
@@ -202,19 +221,15 @@
 			if (ioctl(fd, CDRIOCBLANK, &blank) < 0)
 				err(EX_IOERR, "ioctl(CDRIOCBLANK)");
 			while (1) {
-				int done = -1;
 				sleep(1);
-				sec++;
-				pct = 0;
 				if (ioctl(fd, CDRIOCGETPROGRESS, &pct) == -1)
-					err(EX_IOERR,"ioctl(CDRIOGETPROGRESS)");				if (pct == 0)
-					done = ioctl(fd, CDIOCRESET, NULL);
-				if (!quiet)
+					err(EX_IOERR,"ioctl(CDRIOGETPROGRESS)");
+				if (pct > 0 && !quiet)
 					fprintf(stderr,
-						"%sing CD - %3dsec %d %% done %d    \r",
+						"%sing CD - %d %% done     \r",
 						blank == CDR_B_ALL ?
-						"eras" : "blank", sec, pct, done);
-				if (pct == 100 || (pct == 0 && last > 90) || done == 0)
+						"eras" : "blank", pct);
+				if (pct == 100 || (pct == 0 && last > 90))
 					break;
 				last = pct;
 			}
@@ -325,6 +340,10 @@
 	if (eject)
 		if (ioctl(fd, CDIOCEJECT) < 0)
 			err(EX_IOERR, "ioctl(CDIOCEJECT)");
+
+	signal(SIGHUP, SIG_DFL);
+	signal(SIGINT, SIG_DFL);
+	signal(SIGTERM, SIG_DFL);
 	close(fd);
 	exit(EX_OK);
 }
@@ -475,8 +494,10 @@
 		err(EX_IOERR, "ioctl(CDRIOCSENDCUE)");
 
 	for (i = 0; i < notracks; i++) {
-		if (write_file(fd, &tracks[i]))
+		if (write_file(fd, &tracks[i])) {
+			cleanup_flush();
 			err(EX_IOERR, "write_file");
+		}
 	}
 
 	ioctl(fd, CDRIOCFLUSH);
@@ -505,8 +526,10 @@
 		if (!quiet)
 			fprintf(stderr, "next writeable LBA %d\n",
 				tracks[i].addr);
-		if (write_file(fd, &tracks[i]))
+		if (write_file(fd, &tracks[i])) {
+			cleanup_flush();
 			err(EX_IOERR, "write_file");
+		}
 		if (ioctl(fd, CDRIOCFLUSH) < 0)
 			err(EX_IOERR, "ioctl(CDRIOCFLUSH)");
 	}
@@ -636,9 +659,11 @@
 				track_info->block_size;
 		}
 		if ((res = write(fd, buf, count)) != count) {
-			if (res == -1)
-				fprintf(stderr, "\n%s\n", strerror(errno));
-			else
+			if (res == -1) {
+				fprintf(stderr, "\n");
+				close(track_info->file);
+				return errno;
+			} else
 				fprintf(stderr, "\nonly wrote %d of %jd"
 				    " bytes\n", res, (intmax_t)count);
 			break;
@@ -699,6 +724,22 @@
 }
 
 void
+cleanup_flush(void)
+{
+	if (ioctl(global_fd_for_cleanup, CDRIOCFLUSH) < 0)
+		err(EX_IOERR, "ioctl(CDRIOCFLUSH)");
+}
+
+void
+cleanup_signal(int sig)
+{
+	signal(sig, SIG_IGN);
+	ioctl(global_fd_for_cleanup, CDRIOCFLUSH);
+	write(STDERR_FILENO, "\nAborted\n", 10);
+	_exit(EXIT_FAILURE);
+}
+
+void
 usage(void)
 {
 	fprintf(stderr,



More information about the Midnightbsd-cvs mailing list