Sure.
Klemens Nanni <[email protected]> wrote:
> Noticed by mistake (wanted `-l'):
>
> # vnconfig l
> vnd0
> vnconfig: VNDIOCSET: No such file or directory
>
> Same happens if you try to load a bogus file:
>
> # vnconfig ./empty
> vnd0
> vnconfig: VNDIOCSET: Input/output error
>
> In both cases, the info on stdout is useless as vnd0 is not used.
> Defer printing the device until after the file is set up:
>
> # vnconfig l
> vnconfig: VNDIOCSET: No such file or directory
> # ./obj/vnconfig ./empty
> vnconfig: VNDIOCSET: Input/output error
>
> OK?
>
>
> Index: vnconfig.c
> ===================================================================
> RCS file: /cvs/src/sbin/vnconfig/vnconfig.c,v
> retrieving revision 1.10
> diff -u -p -r1.10 vnconfig.c
> --- vnconfig.c 20 Aug 2022 06:39:24 -0000 1.10
> +++ vnconfig.c 1 Sep 2022 01:29:56 -0000
> @@ -289,7 +289,6 @@ config(char *file, char *dev, struct dis
> if (dev == NULL) {
> if (getinfo(NULL, &unit) == -1)
> err(1, "no devices available");
> - printf("vnd%d\n", unit);
> asprintf(&dev, "vnd%d", unit);
> }
>
> @@ -312,9 +311,12 @@ config(char *file, char *dev, struct dis
> rv = ioctl(fd, VNDIOCSET, &vndio);
> if (rv)
> warn("VNDIOCSET");
> - else if (verbose)
> - fprintf(stderr, "%s: %llu bytes on %s\n", dev, vndio.vnd_size,
> - file);
> + else {
> + printf("%s\n", dev);
> + if (verbose)
> + fprintf(stderr, "%s: %llu bytes on %s\n", dev,
> + vndio.vnd_size, file);
> + }
>
> close(fd);
> fflush(stdout);
>