diff options
author | bde <bde@FreeBSD.org> | 1998-07-20 13:39:45 +0000 |
---|---|---|
committer | bde <bde@FreeBSD.org> | 1998-07-20 13:39:45 +0000 |
commit | 79b1340c5bd1addb9d5b7a030c618f7c862d359b (patch) | |
tree | 12b8852a5f926f33ae246ba6825dbf9d4362b3c8 /sys/kern/subr_diskslice.c | |
parent | fc4d618c2d94df027354a981a312a2bca44c7131 (diff) | |
download | FreeBSD-src-79b1340c5bd1addb9d5b7a030c618f7c862d359b.zip FreeBSD-src-79b1340c5bd1addb9d5b7a030c618f7c862d359b.tar.gz |
Moved allocation of the slices struct to the right place. Initialize
everything in it (the devsw pointers were not initialized early or at
all for the !DEVFS case, but this was harmless on i386's).
Diffstat (limited to 'sys/kern/subr_diskslice.c')
-rw-r--r-- | sys/kern/subr_diskslice.c | 37 |
1 files changed, 36 insertions, 1 deletions
diff --git a/sys/kern/subr_diskslice.c b/sys/kern/subr_diskslice.c index 4dc2343..a0e09cf 100644 --- a/sys/kern/subr_diskslice.c +++ b/sys/kern/subr_diskslice.c @@ -43,11 +43,13 @@ * from: wd.c,v 1.55 1994/10/22 01:57:12 phk Exp $ * from: @(#)ufs_disksubr.c 7.16 (Berkeley) 5/4/91 * from: ufs_disksubr.c,v 1.8 1994/06/07 01:21:39 phk Exp $ - * $Id: subr_diskslice.c,v 1.48 1998/07/11 07:45:42 bde Exp $ + * $Id: subr_diskslice.c,v 1.49 1998/07/20 12:37:59 bde Exp $ */ #include "opt_devfs.h" +#include <stddef.h> + #include <sys/param.h> #include <sys/buf.h> #include <sys/conf.h> @@ -556,6 +558,32 @@ dsisopen(ssp) return (0); } +/* + * Allocate a slices "struct" and initialize it to contain only an empty + * compatibility slice (pointing to itself), a whole disk slice (covering + * the disk as described by the label), and (nslices - BASE_SLICES) empty + * slices beginning at BASE_SLICE. + */ +struct diskslices * +dsmakeslicestruct(nslices, lp) + int nslices; + struct disklabel *lp; +{ + struct diskslice *sp; + struct diskslices *ssp; + + ssp = malloc(offsetof(struct diskslices, dss_slices) + + nslices * sizeof *sp, M_DEVBUF, M_WAITOK); + ssp->dss_bdevsw = NULL; + ssp->dss_cdevsw = NULL; + ssp->dss_first_bsd_slice = COMPATIBILITY_SLICE; + ssp->dss_nslices = nslices; + sp = &ssp->dss_slices[0]; + bzero(sp, nslices * sizeof *sp); + sp[WHOLE_DISK_SLICE].ds_size = lp->d_secperunit; + return (ssp); +} + char * dsname(dname, unit, slice, part, partname) char *dname; @@ -623,6 +651,13 @@ dsopen(dname, dev, mode, sspp, lp, strat, setgeom, bdevsw, cdevsw) if (ssp != NULL && need_init) dsgone(sspp); if (need_init) { + /* + * Allocate a minimal slices "struct". This will become + * the final slices "struct" if we don't want real slices + * or if we can't find any real slices. + */ + *sspp = dsmakeslicestruct(BASE_SLICE, lp); + TRACE(("dsinit\n")); error = dsinit(dname, dev, strat, lp, sspp); if (error != 0) { |