+struct cd_softc *cd_softc;
+int numcd;
+
+/*
+ * Since this is called after auto-configuration of devices,
+ * we can handle the initialization here.
+ *
+ * XXX this will not work if you want to use a cd as your primary
+ * swap device since swapconf() has been called before now.
+ */
+void
+cdattach(num)
+ int num;
+{
+ char *mem;
+ register u_long size;
+ register struct cddevice *cd;
+ extern int dkn;
+
+ if (num <= 0)
+ return;
+ size = num * sizeof(struct cd_softc);
+ mem = malloc(size, M_DEVBUF, M_NOWAIT);
+ if (mem == NULL) {
+ printf("WARNING: no memory for concatonated disks\n");
+ return;
+ }
+ bzero(mem, size);
+ cd_softc = (struct cd_softc *)mem;
+ numcd = num;
+ for (cd = cddevice; cd->cd_unit >= 0; cd++) {
+ /*
+ * XXX
+ * Assign disk index first so that init routine
+ * can use it (saves having the driver drag around
+ * the cddevice pointer just to set up the dk_*
+ * info in the open routine).
+ */
+ if (dkn < DK_NDRIVE)
+ cd->cd_dk = dkn++;
+ else
+ cd->cd_dk = -1;
+ if (cdinit(cd))
+ printf("cd%d configured\n", cd->cd_unit);
+ else if (cd->cd_dk >= 0) {
+ cd->cd_dk = -1;
+ dkn--;
+ }
+ }
+}
+