+ /*
+ * Find the next empty slot; we recognize an empty slot by a
+ * NULL-valued ->vfc_vfsops, so if we delete a VFS, we must
+ * ensure we set the entry back to NULL.
+ */
+ for (slot = 0; slot < maxvfsslots; slot++) {
+ if (vfsconf[slot].vfc_vfsops == NULL)
+ break;
+ }
+ if (slot == maxvfsslots) {
+ /* out of static slots; allocate one instead */
+ MALLOC(slotp, struct vfsconf *, sizeof(struct vfsconf),
+ M_TEMP, M_WAITOK);
+ } else {
+ slotp = &vfsconf[slot];
+ }
+
+ /*
+ * Replace the contents of the next empty slot with the contents
+ * of the provided nvfsp.
+ *
+ * Note; Takes advantage of the fact that 'slot' was left
+ * with the value of 'maxvfslots' in the allocation case.
+ */
+ bcopy(nvfsp, slotp, sizeof(struct vfsconf));
+ if (slot != 0) {
+ slotp->vfc_next = vfsconf[slot - 1].vfc_next;
+ vfsconf[slot - 1].vfc_next = slotp;
+ } else {
+ slotp->vfc_next = NULL;
+ }