diff options
author | sos <sos@FreeBSD.org> | 2000-02-18 16:36:28 +0000 |
---|---|---|
committer | sos <sos@FreeBSD.org> | 2000-02-18 16:36:28 +0000 |
commit | 3ed5b16740c29afba12eb03786ca5c2b42a74b21 (patch) | |
tree | 6c663e9973b786efb5bca471e9bae44b8c2c2931 /usr.sbin | |
parent | f7be466376e8fb2fe6ae93701cb3569fc0f7f717 (diff) | |
download | FreeBSD-src-3ed5b16740c29afba12eb03786ca5c2b42a74b21.zip FreeBSD-src-3ed5b16740c29afba12eb03786ca5c2b42a74b21.tar.gz |
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 <billf@FreeBSD.org>)
Diffstat (limited to 'usr.sbin')
-rw-r--r-- | usr.sbin/burncd/burncd.c | 15 |
1 files changed, 9 insertions, 6 deletions
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); |