summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbde <bde@FreeBSD.org>1998-07-30 15:16:06 +0000
committerbde <bde@FreeBSD.org>1998-07-30 15:16:06 +0000
commit2c362dc181b2013d9ce19d506a6fd532076fb722 (patch)
treec2df5b29bba20de2b98999f17767275415afeaf5
parent524b03458c184ad22eb4f862e1bfbb8c7729c0f4 (diff)
downloadFreeBSD-src-2c362dc181b2013d9ce19d506a6fd532076fb722.zip
FreeBSD-src-2c362dc181b2013d9ce19d506a6fd532076fb722.tar.gz
Added a flags arg to dsopen() and updated drivers. The DSO_ONESLICE
and DSO_NOLABELS flags prevent searching for slices and labels respectively. Current drivers don't set these flags. When DSO_NOLABELS is set, the in-core label for the whole disk is cloned to create an in-core label for each slice. This gives the correct result (a good in-core label for the compatibility slice) if DSO_ONESLICE is set or only one slice is found, but usually gives broken labels otherwise, so DSO_ONESLICE should be set if DSO_NOLABELS is set.
-rw-r--r--sys/dev/vn/vn.c6
-rw-r--r--sys/i386/isa/wd.c4
-rw-r--r--sys/i386/isa/wfd.c7
-rw-r--r--sys/kern/subr_diskslice.c38
-rw-r--r--sys/pc98/pc98/wd.c4
-rw-r--r--sys/pc98/pc98/wfd.c7
-rw-r--r--sys/scsi/od.c4
-rw-r--r--sys/scsi/sd.c4
-rw-r--r--sys/sys/diskslice.h15
9 files changed, 53 insertions, 36 deletions
diff --git a/sys/dev/vn/vn.c b/sys/dev/vn/vn.c
index 8a586d2..b4b278a 100644
--- a/sys/dev/vn/vn.c
+++ b/sys/dev/vn/vn.c
@@ -38,7 +38,7 @@
* from: Utah Hdr: vn.c 1.13 94/04/02
*
* from: @(#)vn.c 8.6 (Berkeley) 4/1/94
- * $Id: vn.c,v 1.65 1998/07/11 07:45:22 bde Exp $
+ * $Id: vn.c,v 1.66 1998/07/13 08:22:58 julian Exp $
*/
/*
@@ -232,8 +232,8 @@ vnopen(dev_t dev, int flags, int mode, struct proc *p)
label.d_partitions[RAW_PART].p_size =
vn->sc_size;
- return (dsopen("vn", dev, mode, &vn->sc_slices, &label,
- vnstrategy, (ds_setgeom_t *)NULL,
+ return (dsopen("vn", dev, mode, 0, &vn->sc_slices,
+ &label, vnstrategy, (ds_setgeom_t *)NULL,
&vn_cdevsw, &vn_cdevsw));
}
if (dkslice(dev) != WHOLE_DISK_SLICE ||
diff --git a/sys/i386/isa/wd.c b/sys/i386/isa/wd.c
index 636ea03..009e4a7 100644
--- a/sys/i386/isa/wd.c
+++ b/sys/i386/isa/wd.c
@@ -34,7 +34,7 @@
* SUCH DAMAGE.
*
* from: @(#)wd.c 7.2 (Berkeley) 5/9/91
- * $Id: wd.c,v 1.171 1998/07/11 07:45:35 bde Exp $
+ * $Id: wd.c,v 1.172 1998/07/13 08:23:01 julian Exp $
*/
/* TODO:
@@ -1500,7 +1500,7 @@ wdopen(dev_t dev, int flags, int fmt, struct proc *p)
label.d_ncylinders = du->dk_dd.d_ncylinders;
label.d_secpercyl = du->dk_dd.d_secpercyl;
label.d_secperunit = du->dk_dd.d_secperunit;
- error = dsopen("wd", dev, fmt, &du->dk_slices, &label, wdstrategy1,
+ error = dsopen("wd", dev, fmt, 0, &du->dk_slices, &label, wdstrategy1,
(ds_setgeom_t *)NULL, &wd_cdevsw, &wd_cdevsw);
}
du->dk_flags &= ~DKFL_LABELLING;
diff --git a/sys/i386/isa/wfd.c b/sys/i386/isa/wfd.c
index 7f66c48..31ee4c2 100644
--- a/sys/i386/isa/wfd.c
+++ b/sys/i386/isa/wfd.c
@@ -23,7 +23,7 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
- * $Id: wfd.c,v 1.12 1998/07/04 22:30:19 julian Exp $
+ * $Id: wfd.c,v 1.13 1998/07/13 09:53:03 bde Exp $
*/
/*
@@ -374,8 +374,9 @@ int wfdopen (dev_t dev, int flags, int fmt, struct proc *p)
label.d_secperunit = label.d_secpercyl * t->cap.cyls;
/* Initialize slice tables. */
- errcode = dsopen("wfd", dev, fmt, &t->dk_slices, &label, wfdstrategy1,
- (ds_setgeom_t *)NULL, &wfd_cdevsw, &wfd_cdevsw);
+ errcode = dsopen("wfd", dev, fmt, 0, &t->dk_slices, &label,
+ wfdstrategy1, (ds_setgeom_t *)NULL, &wfd_cdevsw,
+ &wfd_cdevsw);
if (errcode != 0)
return errcode;
diff --git a/sys/kern/subr_diskslice.c b/sys/kern/subr_diskslice.c
index 0b2e13d..644f136 100644
--- a/sys/kern/subr_diskslice.c
+++ b/sys/kern/subr_diskslice.c
@@ -43,7 +43,7 @@
* 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.54 1998/07/29 08:24:23 bde Exp $
+ * $Id: subr_diskslice.c,v 1.55 1998/07/29 11:15:48 bde Exp $
*/
#include "opt_devfs.h"
@@ -507,8 +507,8 @@ dsioctl(dname, dev, cmd, data, flags, sspp, strat, setgeom)
error = dsopen(dname, dev,
ssp->dss_slices[WHOLE_DISK_SLICE].ds_copenmask
& (1 << RAW_PART) ? S_IFCHR : S_IFBLK,
- sspp, lp, strat, setgeom, ssp->dss_bdevsw,
- ssp->dss_cdevsw);
+ ssp->dss_oflags, sspp, lp, strat, setgeom,
+ ssp->dss_bdevsw, ssp->dss_cdevsw);
if (error != 0) {
free(lp, M_DEVBUF);
*sspp = ssp;
@@ -528,8 +528,9 @@ dsioctl(dname, dev, cmd, data, flags, sspp, strat, setgeom)
error = dsopen(dname,
dkmodslice(dkmodpart(dev, part),
slice),
- S_IFBLK, sspp, lp, strat,
- setgeom, ssp->dss_bdevsw,
+ S_IFBLK, ssp->dss_oflags, sspp,
+ lp, strat, setgeom,
+ ssp->dss_bdevsw,
ssp->dss_cdevsw);
if (error != 0) {
/* XXX should free devfs toks. */
@@ -546,8 +547,9 @@ dsioctl(dname, dev, cmd, data, flags, sspp, strat, setgeom)
error = dsopen(dname,
dkmodslice(dkmodpart(dev, part),
slice),
- S_IFCHR, sspp, lp, strat,
- setgeom, ssp->dss_bdevsw,
+ S_IFCHR, ssp->dss_oflags, sspp,
+ lp, strat, setgeom,
+ ssp->dss_bdevsw,
ssp->dss_cdevsw);
if (error != 0) {
/* XXX should free devfs toks. */
@@ -652,6 +654,7 @@ dsmakeslicestruct(nslices, lp)
ssp->dss_cdevsw = NULL;
ssp->dss_first_bsd_slice = COMPATIBILITY_SLICE;
ssp->dss_nslices = nslices;
+ ssp->dss_oflags = 0;
ssp->dss_secmult = lp->d_secsize / DEV_BSIZE;
if (ssp->dss_secmult & (ssp->dss_secmult - 1))
ssp->dss_secshift = -1;
@@ -693,10 +696,11 @@ dsname(dname, unit, slice, part, partname)
* strategy routine must be special to allow activity.
*/
int
-dsopen(dname, dev, mode, sspp, lp, strat, setgeom, bdevsw, cdevsw)
+dsopen(dname, dev, mode, flags, sspp, lp, strat, setgeom, bdevsw, cdevsw)
char *dname;
dev_t dev;
int mode;
+ u_int flags;
struct diskslices **sspp;
struct disklabel *lp;
d_strategy_t *strat;
@@ -741,13 +745,16 @@ dsopen(dname, dev, mode, sspp, lp, strat, setgeom, bdevsw, cdevsw)
*/
*sspp = dsmakeslicestruct(BASE_SLICE, lp);
- TRACE(("dsinit\n"));
- error = dsinit(dname, dev, strat, lp, sspp);
- if (error != 0) {
- dsgone(sspp);
- return (error);
+ if (!(flags & DSO_ONESLICE)) {
+ TRACE(("dsinit\n"));
+ error = dsinit(dname, dev, strat, lp, sspp);
+ if (error != 0) {
+ dsgone(sspp);
+ return (error);
+ }
}
ssp = *sspp;
+ ssp->dss_oflags = flags;
#ifdef DEVFS
ssp->dss_bdevsw = bdevsw;
ssp->dss_cdevsw = cdevsw;
@@ -820,7 +827,10 @@ dsopen(dname, dev, mode, sspp, lp, strat, setgeom, bdevsw, cdevsw)
set_ds_wlabel(ssp, slice, TRUE); /* XXX invert */
lp1 = clone_label(lp);
TRACE(("readdisklabel\n"));
- msg = readdisklabel(dev1, strat, lp1);
+ if (flags & DSO_NOLABELS)
+ msg = NULL;
+ else
+ msg = readdisklabel(dev1, strat, lp1);
#if 0 /* XXX */
if (msg == NULL && setgeom != NULL && setgeom(lp1) != 0)
msg = "setgeom failed";
diff --git a/sys/pc98/pc98/wd.c b/sys/pc98/pc98/wd.c
index b61954a..51cfbd5 100644
--- a/sys/pc98/pc98/wd.c
+++ b/sys/pc98/pc98/wd.c
@@ -34,7 +34,7 @@
* SUCH DAMAGE.
*
* from: @(#)wd.c 7.2 (Berkeley) 5/9/91
- * $Id: wd.c,v 1.58 1998/07/11 17:02:48 kato Exp $
+ * $Id: wd.c,v 1.59 1998/07/13 09:29:25 kato Exp $
*/
/* TODO:
@@ -1618,7 +1618,7 @@ wdopen(dev_t dev, int flags, int fmt, struct proc *p)
label.d_ncylinders = du->dk_dd.d_ncylinders;
label.d_secpercyl = du->dk_dd.d_secpercyl;
label.d_secperunit = du->dk_dd.d_secperunit;
- error = dsopen("wd", dev, fmt, &du->dk_slices, &label, wdstrategy1,
+ error = dsopen("wd", dev, fmt, 0, &du->dk_slices, &label, wdstrategy1,
(ds_setgeom_t *)NULL, &wd_cdevsw, &wd_cdevsw);
}
du->dk_flags &= ~DKFL_LABELLING;
diff --git a/sys/pc98/pc98/wfd.c b/sys/pc98/pc98/wfd.c
index 7f66c48..31ee4c2 100644
--- a/sys/pc98/pc98/wfd.c
+++ b/sys/pc98/pc98/wfd.c
@@ -23,7 +23,7 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
- * $Id: wfd.c,v 1.12 1998/07/04 22:30:19 julian Exp $
+ * $Id: wfd.c,v 1.13 1998/07/13 09:53:03 bde Exp $
*/
/*
@@ -374,8 +374,9 @@ int wfdopen (dev_t dev, int flags, int fmt, struct proc *p)
label.d_secperunit = label.d_secpercyl * t->cap.cyls;
/* Initialize slice tables. */
- errcode = dsopen("wfd", dev, fmt, &t->dk_slices, &label, wfdstrategy1,
- (ds_setgeom_t *)NULL, &wfd_cdevsw, &wfd_cdevsw);
+ errcode = dsopen("wfd", dev, fmt, 0, &t->dk_slices, &label,
+ wfdstrategy1, (ds_setgeom_t *)NULL, &wfd_cdevsw,
+ &wfd_cdevsw);
if (errcode != 0)
return errcode;
diff --git a/sys/scsi/od.c b/sys/scsi/od.c
index 4769406..cfccdb9 100644
--- a/sys/scsi/od.c
+++ b/sys/scsi/od.c
@@ -28,7 +28,7 @@
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
- * $Id: od.c,v 1.43 1998/07/28 18:59:49 bde Exp $
+ * $Id: od.c,v 1.44 1998/07/29 11:15:51 bde Exp $
*/
/*
@@ -385,7 +385,7 @@ od_open(dev, mode, fmt, p, sc_link)
label.d_secperunit = od->params.disksize;
/* Initialize slice tables. */
- errcode = dsopen("od", dev, fmt, &od->dk_slices, &label, odstrategy1,
+ errcode = dsopen("od", dev, fmt, 0, &od->dk_slices, &label, odstrategy1,
(ds_setgeom_t *)NULL, &od_cdevsw, &od_cdevsw);
if (errcode != 0)
goto bad;
diff --git a/sys/scsi/sd.c b/sys/scsi/sd.c
index 8043704..1ddc16d 100644
--- a/sys/scsi/sd.c
+++ b/sys/scsi/sd.c
@@ -14,7 +14,7 @@
*
* Ported to run under 386BSD by Julian Elischer (julian@dialix.oz.au) Sept 1992
*
- * $Id: sd.c,v 1.136 1998/07/28 18:59:49 bde Exp $
+ * $Id: sd.c,v 1.137 1998/07/29 11:15:51 bde Exp $
*/
#include "opt_bounce.h"
@@ -486,7 +486,7 @@ sd_open(dev_t dev, int mode, int fmt, struct proc *p, struct scsi_link *sc_link)
label.d_secperunit = sd->params.disksize;
/* Initialize slice tables. */
- errcode = dsopen("sd", dev, fmt, &sd->dk_slices, &label, sdstrategy1,
+ errcode = dsopen("sd", dev, fmt, 0, &sd->dk_slices, &label, sdstrategy1,
(ds_setgeom_t *)NULL, &sd_cdevsw, &sd_cdevsw);
if (errcode != 0)
goto close;
diff --git a/sys/sys/diskslice.h b/sys/sys/diskslice.h
index e6aca57..45ddbf0 100644
--- a/sys/sys/diskslice.h
+++ b/sys/sys/diskslice.h
@@ -23,7 +23,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: diskslice.h,v 1.24 1998/07/20 13:39:45 bde Exp $
+ * $Id: diskslice.h,v 1.25 1998/07/29 11:15:54 bde Exp $
*/
#ifndef _SYS_DISKSLICE_H_
@@ -73,6 +73,7 @@ struct diskslices {
struct cdevsw *dss_cdevsw; /* for containing device */
int dss_first_bsd_slice; /* COMPATIBILITY_SLICE is mapped here */
u_int dss_nslices; /* actual dimension of dss_slices[] */
+ u_int dss_oflags; /* copy of flags for "first" open */
int dss_secmult; /* block to sector multiplier */
int dss_secshift; /* block to sector shift (or -1) */
int dss_secsize; /* sector size */
@@ -82,6 +83,10 @@ struct diskslices {
#ifdef KERNEL
+/* Flags for dsopen(). */
+#define DSO_NOLABELS 1
+#define DSO_ONESLICE 2
+
#define dsgetbad(dev, ssp) (ssp->dss_slices[dkslice(dev)].ds_bad)
#define dsgetlabel(dev, ssp) (ssp->dss_slices[dkslice(dev)].ds_label)
@@ -102,10 +107,10 @@ int dsisopen __P((struct diskslices *ssp));
struct diskslices *dsmakeslicestruct __P((int nslices, struct disklabel *lp));
char *dsname __P((char *dname, int unit, int slice, int part,
char *partname));
-int dsopen __P((char *dname, dev_t dev, int mode, struct diskslices **sspp,
- struct disklabel *lp, void (*strat)(struct buf *bp),
- ds_setgeom_t *setgeom, struct cdevsw *bdevsw,
- struct cdevsw *cdevsw));
+int dsopen __P((char *dname, dev_t dev, int mode, u_int flags,
+ struct diskslices **sspp, struct disklabel *lp,
+ void (*strat)(struct buf *bp), ds_setgeom_t *setgeom,
+ struct cdevsw *bdevsw, struct cdevsw *cdevsw));
int dssize __P((dev_t dev, struct diskslices **sspp,
int (*dopen)(dev_t dev, int oflags, int devtype,
struct proc *p),
OpenPOWER on IntegriCloud