From 3ed5b16740c29afba12eb03786ca5c2b42a74b21 Mon Sep 17 00:00:00 2001 From: sos Date: Fri, 18 Feb 2000 16:36:28 +0000 Subject: Dont allow burn when format not selected. Use the right format in printfs. Fix the partial write error (the res variable). Reminder by: (Bill Fumerola ) --- usr.sbin/burncd/burncd.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'usr.sbin/burncd') diff --git a/usr.sbin/burncd/burncd.c b/usr.sbin/burncd/burncd.c index 32747f7..0f5e154 100644 --- a/usr.sbin/burncd/burncd.c +++ b/usr.sbin/burncd/burncd.c @@ -52,7 +52,7 @@ main(int argc, char **argv) char *devname = "/dev/acd0c"; char buf[2352*BLOCKS]; int arg, file, addr, count; - int block_size, cdopen = 0, size, tot_size = 0; + int block_size = 0, cdopen = 0, size, tot_size = 0; struct cdr_track track; while ((ch = getopt(argc, argv, "ef:pqs:t")) != -1) { @@ -142,9 +142,12 @@ main(int argc, char **argv) block_size = 2048; continue; } - if ((file = open(argv[arg], O_RDONLY, 0)) < 0) { + if (!block_size) + err(EX_NOINPUT, "no data format selected"); + + if ((file = open(argv[arg], O_RDONLY, 0)) < 0) err(EX_NOINPUT, "open(%s)", argv[arg]); - } + if (!cdopen) { if (ioctl(fd, CDRIOCOPENDISK) < 0) err(EX_IOERR, "ioctl(CDRIOCOPENDISK)"); @@ -162,20 +165,20 @@ main(int argc, char **argv) if (fstat(file, &stat) < 0) err(EX_IOERR, "fstat(%s)", argv[arg]); fprintf(stderr, "next writeable LBA %d\n", addr); - fprintf(stderr, "writing from file %s size %d KB\n", + fprintf(stderr, "writing from file %s size %qd KB\n", argv[arg], stat.st_size / 1024); } lseek(fd, addr * block_size, SEEK_SET); size = 0; while ((count = read(file, buf, block_size * BLOCKS)) > 0) { + int res; if (count % block_size) { /* pad file to % block_size */ bzero(&buf[count], block_size * BLOCKS - count); count = ((count / block_size) + 1) * block_size; } - if (write(fd, buf, count) != count) { - int res; + if ((res = write(fd, buf, count)) != count) { fprintf(stderr, "\nonly wrote %d of %d bytes\n", res, count); -- cgit v1.1