summaryrefslogtreecommitdiffstats
path: root/sbin/ccdconfig
diff options
context:
space:
mode:
authorphk <phk@FreeBSD.org>2003-01-17 14:53:53 +0000
committerphk <phk@FreeBSD.org>2003-01-17 14:53:53 +0000
commit62c9659f0c00ec3a90305516c948342e3d5e8439 (patch)
treedd13acf6c70a0a5fae059a6c132989b9020d72e0 /sbin/ccdconfig
parent50943df945bc1de45023640285136b28ab2eadef (diff)
downloadFreeBSD-src-62c9659f0c00ec3a90305516c948342e3d5e8439.zip
FreeBSD-src-62c9659f0c00ec3a90305516c948342e3d5e8439.tar.gz
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.
Diffstat (limited to 'sbin/ccdconfig')
-rw-r--r--sbin/ccdconfig/ccdconfig.c36
-rw-r--r--sbin/ccdconfig/pathnames.h3
2 files changed, 21 insertions, 18 deletions
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;
}
diff --git a/sbin/ccdconfig/pathnames.h b/sbin/ccdconfig/pathnames.h
index f8da9e0..538cfed 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"
OpenPOWER on IntegriCloud