Corrected mandoc(1) style, thanks. Index: vnconfig.8 =================================================================== RCS file: /cvs/src/sbin/vnconfig/vnconfig.8,v retrieving revision 1.7 diff -u -p -u -p -r1.7 vnconfig.8 --- vnconfig.8 16 Aug 2022 13:59:51 -0000 1.7 +++ vnconfig.8 3 Oct 2022 16:08:54 -0000 @@ -83,8 +83,8 @@ with the regular file allowing the latter to be accessed as though it were a disk. If .Ar vnd_dev -is not specified, an unused one will be allocated and the name printed -to +is not specified, an unused one will be allocated. +The name is printed to .Va stdout . .Pp The options are as follows: @@ -147,6 +147,7 @@ Configure a CD-ROM or DVD image file as and mount the ISO 9660 file system contained in it: .Bd -literal -offset indent # vnconfig vnd0 /tmp/diskimage +vnd0 # mount -t cd9660 /dev/vnd0c /mnt .Ed .Pp @@ -160,6 +161,7 @@ a salt file with 20000 rounds: # vnconfig -K 20000 vnd0 /tmp/cryptimg Encryption key: Salt file: /tmp/cryptsalt +vnd0 # mount /dev/vnd0a /mnt .Ed .Sh SEE ALSO Index: vnconfig.c =================================================================== RCS file: /cvs/src/sbin/vnconfig/vnconfig.c,v retrieving revision 1.11 diff -u -p -u -p -r1.11 vnconfig.c --- vnconfig.c 1 Sep 2022 01:52:08 -0000 1.11 +++ vnconfig.c 3 Oct 2022 16:08:54 -0000 @@ -284,11 +284,12 @@ config(char *file, char *dev, struct dis struct vnd_ioctl vndio; char *rdev; int fd, rv = -1; - int unit; + int unit, print_dev = 0; if (dev == NULL) { if (getinfo(NULL, &unit) == -1) err(1, "no devices available"); + print_dev = 1; asprintf(&dev, "vnd%d", unit); } @@ -312,7 +313,8 @@ config(char *file, char *dev, struct dis if (rv) warn("VNDIOCSET"); else { - printf("%s\n", dev); + if (print_dev) + printf("%s\n", dev); if (verbose) fprintf(stderr, "%s: %llu bytes on %s\n", dev, vndio.vnd_size, file);
Brian On Mon, Oct 3, 2022, at 10:56 AM, Brian Conway wrote: > In d52ebfd8e572596739b84b5138ef7c090a3dc442 > (https://marc.info/?t=166199571100001), vnconfig was changed to not > print an auto-allocated device on errors, however it now prints it > unconditionally, including when passed as an argument. One might > consider this superfluous, but it is surely contrary to the manual. > > # dd if=/dev/zero of=/tmp/test.img bs=1m count=0 seek=1 > 0+0 records in > 0+0 records out > 0 bytes transferred in 0.000 secs (0 bytes/sec) > # vnconfig /tmp/test.img > > vnd0 > # vnconfig -u vnd0 > > # vnconfig vnd0 /tmp/test.img > vnd0 > > Two patches are below, one to change the printing to auto-allocation > only, and the other to update the manual to reflect the current > behavior. I suggest either or neither, but not both. Thanks. > > Brian Conway > Lead Software Engineer, Owner > RCE Software, LLC > > Index: vnconfig.8 > =================================================================== > RCS file: /cvs/src/sbin/vnconfig/vnconfig.8,v > retrieving revision 1.7 > diff -u -p -u -p -r1.7 vnconfig.8 > --- vnconfig.8 16 Aug 2022 13:59:51 -0000 1.7 > +++ vnconfig.8 3 Oct 2022 15:52:31 -0000 > @@ -83,7 +83,7 @@ with the regular file > allowing the latter to be accessed as though it were a disk. > If > .Ar vnd_dev > -is not specified, an unused one will be allocated and the name printed > +is not specified, an unused one will be allocated. The name is printed > to > .Va stdout . > .Pp > @@ -147,6 +147,7 @@ Configure a CD-ROM or DVD image file as > and mount the ISO 9660 file system contained in it: > .Bd -literal -offset indent > # vnconfig vnd0 /tmp/diskimage > +vnd0 > # mount -t cd9660 /dev/vnd0c /mnt > .Ed > .Pp > @@ -160,6 +161,7 @@ a salt file with 20000 rounds: > # vnconfig -K 20000 vnd0 /tmp/cryptimg > Encryption key: > Salt file: /tmp/cryptsalt > +vnd0 > # mount /dev/vnd0a /mnt > .Ed > .Sh SEE ALSO > Index: vnconfig.c > =================================================================== > RCS file: /cvs/src/sbin/vnconfig/vnconfig.c,v > retrieving revision 1.11 > diff -u -p -u -p -r1.11 vnconfig.c > --- vnconfig.c 1 Sep 2022 01:52:08 -0000 1.11 > +++ vnconfig.c 3 Oct 2022 15:52:31 -0000 > @@ -284,11 +284,12 @@ config(char *file, char *dev, struct dis > struct vnd_ioctl vndio; > char *rdev; > int fd, rv = -1; > - int unit; > + int unit, print_dev = 0; > > if (dev == NULL) { > if (getinfo(NULL, &unit) == -1) > err(1, "no devices available"); > + print_dev = 1; > asprintf(&dev, "vnd%d", unit); > } > > @@ -312,7 +313,8 @@ config(char *file, char *dev, struct dis > if (rv) > warn("VNDIOCSET"); > else { > - printf("%s\n", dev); > + if (print_dev) > + printf("%s\n", dev); > if (verbose) > fprintf(stderr, "%s: %llu bytes on %s\n", dev, > vndio.vnd_size, file);