diff options
author | Poul-Henning Kamp <phk@FreeBSD.org> | 2003-01-17 14:53:53 +0000 |
---|---|---|
committer | Poul-Henning Kamp <phk@FreeBSD.org> | 2003-01-17 14:53:53 +0000 |
commit | ddbf51af0cc86b76184f366c365200ac587887b1 (patch) | |
tree | dd13acf6c70a0a5fae059a6c132989b9020d72e0 /sbin | |
parent | 3d140861529e1212c3aa68882ed2b36e46104050 (diff) | |
download | src-ddbf51af0cc86b76184f366c365200ac587887b1.tar.gz src-ddbf51af0cc86b76184f366c365200ac587887b1.zip |
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.
Notes
Notes:
svn path=/head/; revision=109421
Diffstat (limited to 'sbin')
-rw-r--r-- | sbin/ccdconfig/ccdconfig.c | 36 | ||||
-rw-r--r-- | sbin/ccdconfig/pathnames.h | 3 |
2 files changed, 21 insertions, 18 deletions
diff --git a/sbin/ccdconfig/ccdconfig.c b/sbin/ccdconfig/ccdconfig.c index 290839951606..c1c7ad5308da 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; } diff --git a/sbin/ccdconfig/pathnames.h b/sbin/ccdconfig/pathnames.h index f8da9e08e7c9..538cfeda096d 100644 --- a/sbin/ccdconfig/pathnames.h +++ b/sbin/ccdconfig/pathnames.h @@ -30,6 +30,9 @@ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. + * + * $FreeBSD$ */ #define _PATH_CCDCONF "/etc/ccd.conf" +#define _PATH_CCDCTL "ccd.ctl" |