From 62c9659f0c00ec3a90305516c948342e3d5e8439 Mon Sep 17 00:00:00 2001 From: phk Date: Fri, 17 Jan 2003 14:53:53 +0000 Subject: Find places to store the previously implicityly passed unit number in the three configuration ioctls which need a unit number. Add a "ccd.ctl" device for config operations. Implement ioctls on ccd.ctl which rely on the explicityly passed unit numbers. Update ccdconfig to use the new ccd.ctl interface. Add code to the kernel to detect old ccdconfig binaries, and whine about it. Add code to ccdconfig to detect old kernels, and whine about it. These two compatibility measures will be retained only for a limited period since they are in the way of GEOM'ification of ccd. --- sbin/ccdconfig/ccdconfig.c | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) (limited to 'sbin/ccdconfig/ccdconfig.c') diff --git a/sbin/ccdconfig/ccdconfig.c b/sbin/ccdconfig/ccdconfig.c index 2908399..c1c7ad5 100644 --- a/sbin/ccdconfig/ccdconfig.c +++ b/sbin/ccdconfig/ccdconfig.c @@ -182,6 +182,7 @@ do_single(int argc, char **argv, int action) i = 1; continue; } + ccio.ccio_size = ccd; if (do_io(ccd, CCDIOCCLR, &ccio)) i = 1; else @@ -251,6 +252,7 @@ do_single(int argc, char **argv, int action) ccio.ccio_ndisks = i; ccio.ccio_ileave = ileave; ccio.ccio_flags = flags; + ccio.ccio_size = ccd; if (do_io(ccd, CCDIOCSET, &ccio)) { free(disks); @@ -379,11 +381,19 @@ do_io(int unit, u_long cmd, struct ccd_ioctl *cciop) char *cp; char *path; - asprintf(&path, "%sccd%dc", _PATH_DEV, unit); + asprintf(&path, "%s%s", _PATH_DEV, _PATH_CCDCTL); if ((fd = open(path, O_RDWR, 0640)) < 0) { - warn("open: %s", path); - return (1); + asprintf(&path, "%sccd%dc", _PATH_DEV, unit); + if ((fd = open(path, O_RDWR, 0640)) < 0) { + warn("open: %s", path); + return (1); + } + fprintf(stderr, + "***WARNING***: Kernel older than ccdconfig(8), please upgrade it.\n"); + fprintf(stderr, + "***WARNING***: Continuing in 30 seconds\n"); + sleep(30); } if (ioctl(fd, cmd, cciop) < 0) { @@ -510,19 +520,9 @@ print_ccd_info(struct ccd_s *cs) warnx("can't read component info: invalid ccd name: %s", cp); return; } - cpps.size = 0; - if (do_io(ccd, CCDCPPINFO, (struct ccd_ioctl *) &cpps)) { - printf("\n"); - warnx("can't read component info"); - return; - } + cpps.size = 1024; cpps.buffer = alloca(cpps.size); - if (cpps.buffer == NULL) { - printf("\n"); - warn("ccd%d: can't allocate memory for component info", - cs->sc_unit); - return; - } + memcpy(cpps.buffer, &ccd, sizeof ccd); if (do_io(ccd, CCDCPPINFO, (struct ccd_ioctl *) &cpps)) { printf("\n"); warnx("can't read component info"); @@ -530,11 +530,11 @@ print_ccd_info(struct ccd_s *cs) } /* Display component info. */ - for (cp = cpps.buffer; cp - cpps.buffer < cpps.size; cp += strlen(cp) + 1) { + for (cp = cpps.buffer; *cp && cp - cpps.buffer < cpps.size; cp += strlen(cp) + 1) { printf((cp + strlen(cp) + 1) < (cpps.buffer + cpps.size) ? - "%s " : "%s\n", cp); - fflush(stdout); + "%s " : "%s", cp); } + printf("\n"); return; } -- cgit v1.1