aboutsummaryrefslogtreecommitdiff
path: root/sys/sys
diff options
context:
space:
mode:
Diffstat (limited to 'sys/sys')
-rw-r--r--sys/sys/disklabel.h76
-rw-r--r--sys/sys/diskmbr.h76
-rw-r--r--sys/sys/diskpc98.h76
-rw-r--r--sys/sys/diskslice.h78
-rw-r--r--sys/sys/dkbad.h31
5 files changed, 271 insertions, 66 deletions
diff --git a/sys/sys/disklabel.h b/sys/sys/disklabel.h
index 859192e7e374..4e4b4aa571b9 100644
--- a/sys/sys/disklabel.h
+++ b/sys/sys/disklabel.h
@@ -35,7 +35,7 @@
*/
#ifndef _SYS_DISKLABEL_H_
-#define _SYS_DISKLABEL_H_
+#define _SYS_DISKLABEL_H_
/*
* Disk description table, see disktab(5)
@@ -50,6 +50,12 @@
* to leave room for a bootstrap, etc.
*/
+/*
+ * XXX the following will go away when conversion to the slice version is
+ * complete: OURPART, RAWPART, readMSPtolabel, readMBRtolabel, dkminor,
+ * the DOSified readdisklabel, DOS stuff in this file.
+ */
+
/* XXX these should be defined per controller (or drive) elsewhere, not here! */
#ifdef __i386__
#define LABELSECTOR 1 /* sector containing label */
@@ -88,6 +94,9 @@
#define MAXPARTITIONS 8
#endif
+#define LABEL_PART 2 /* partition containing label */
+#define RAW_PART 2 /* partition containing whole disk */
+#define SWAP_PART 1 /* partition normally containing swap */
#ifndef LOCORE
struct disklabel {
@@ -375,21 +384,55 @@ extern struct dos_partition dos_partitions[NDOSPART];
#define DIOCSBAD _IOW('d', 110, struct dkbad) /* set kernel dkbad */
-#endif /* LOCORE */
+/*
+ * XXX encoding of disk minor numbers, should be elsewhere.
+ *
+ * See <sys/reboot.h> for a possibly better encoding.
+ *
+ * "cpio -H newc" can be used to back up device files with large minor
+ * numbers (but not ones >= 2^31). Old cpio formats and all tar formats
+ * don't have enough bits, and cpio and tar don't notice the lossage.
+ * There are also some sign extension bugs.
+ */
+#define dkmakeminor(unit, slice, part) \
+ (((slice) << 16) | ((unit) << 3) | (part))
+#define dkminor(unit, part) dkmakeminor((unit), 0, (part))
+#define dkmodpart(dev, part) (((dev) & ~(dev_t)7) | (part))
+#define dkmodslice(dev, slice) (((dev) & ~(dev_t)0x1f0000) | ((slice) << 16))
+#define dkpart(dev) (minor(dev) & 7)
+#define dkslice(dev) ((minor(dev) >> 16) & 0x1f)
+#define dktype(dev) ((minor(dev) >> 21) & 0x7ff)
+#define dkunit(dev) ((minor(dev) >> 3) & 0x1f)
#ifdef KERNEL
-struct dkbad;
+/*
+ * We're not ready to use <sys/disk.h>.
+ */
+#include <sys/conf.h>
-u_int dkcksum __P((struct disklabel *));
-int writedisklabel __P((dev_t dev, void (*strat)(), struct disklabel *lp));
-char * readdisklabel __P((dev_t dev, void (*strat)(), struct disklabel *lp, struct dos_partition *dp, struct dkbad *bdp));
-int setdisklabel __P((struct disklabel *olp, struct disklabel *nlp, u_long openmask));
+char *correct_readdisklabel __P((dev_t dev, d_strategy_t *strat,
+ struct disklabel *lp));
+void diskerr __P((struct buf *bp, char *dname, char *what, int pri,
+ int blkdone, struct disklabel *lp));
void disksort __P((struct buf *ap, struct buf *bp));
-void diskerr __P((struct buf *, char *, char *, int, int, struct disklabel *));
-#ifdef __i386
-char * readMBRtolabel __P(( dev_t dev , void (*strat)(), register struct disklabel *lp, struct dos_partition *dp, int *cyl));
-#endif
+u_int dkcksum __P((struct disklabel *lp));
+struct dkbad;
+char *readdisklabel __P((dev_t dev, d_strategy_t *strat,
+ struct disklabel *lp,
+ struct dos_partition *dp, struct dkbad *bdp));
+#ifdef __i386__
+char *readMBRtolabel __P((dev_t dev, d_strategy_t *strat,
+ struct disklabel *lp, struct dos_partition *dp,
+ int *cyl));
#endif
+int setdisklabel __P((struct disklabel *olp, struct disklabel *nlp,
+ u_long openmask));
+int writedisklabel __P((dev_t dev, d_strategy_t *strat,
+ struct disklabel *lp));
+
+#endif /* KERNEL */
+
+#endif /* LOCORE */
#if !defined(KERNEL) && !defined(LOCORE)
@@ -401,13 +444,4 @@ __END_DECLS
#endif
-#ifdef __i386
-/* encoding of disk minor numbers, should be elsewhere... */
-#define dkunit(dev) (minor(dev) >> 3)
-#define dkpart(dev) (minor(dev) & 07)
-#define dkminor(unit, part) (((unit) << 3) | (part))
-#endif
-
-#endif
-
-
+#endif /* !_SYS_DISKLABEL_H_ */
diff --git a/sys/sys/diskmbr.h b/sys/sys/diskmbr.h
index 859192e7e374..4e4b4aa571b9 100644
--- a/sys/sys/diskmbr.h
+++ b/sys/sys/diskmbr.h
@@ -35,7 +35,7 @@
*/
#ifndef _SYS_DISKLABEL_H_
-#define _SYS_DISKLABEL_H_
+#define _SYS_DISKLABEL_H_
/*
* Disk description table, see disktab(5)
@@ -50,6 +50,12 @@
* to leave room for a bootstrap, etc.
*/
+/*
+ * XXX the following will go away when conversion to the slice version is
+ * complete: OURPART, RAWPART, readMSPtolabel, readMBRtolabel, dkminor,
+ * the DOSified readdisklabel, DOS stuff in this file.
+ */
+
/* XXX these should be defined per controller (or drive) elsewhere, not here! */
#ifdef __i386__
#define LABELSECTOR 1 /* sector containing label */
@@ -88,6 +94,9 @@
#define MAXPARTITIONS 8
#endif
+#define LABEL_PART 2 /* partition containing label */
+#define RAW_PART 2 /* partition containing whole disk */
+#define SWAP_PART 1 /* partition normally containing swap */
#ifndef LOCORE
struct disklabel {
@@ -375,21 +384,55 @@ extern struct dos_partition dos_partitions[NDOSPART];
#define DIOCSBAD _IOW('d', 110, struct dkbad) /* set kernel dkbad */
-#endif /* LOCORE */
+/*
+ * XXX encoding of disk minor numbers, should be elsewhere.
+ *
+ * See <sys/reboot.h> for a possibly better encoding.
+ *
+ * "cpio -H newc" can be used to back up device files with large minor
+ * numbers (but not ones >= 2^31). Old cpio formats and all tar formats
+ * don't have enough bits, and cpio and tar don't notice the lossage.
+ * There are also some sign extension bugs.
+ */
+#define dkmakeminor(unit, slice, part) \
+ (((slice) << 16) | ((unit) << 3) | (part))
+#define dkminor(unit, part) dkmakeminor((unit), 0, (part))
+#define dkmodpart(dev, part) (((dev) & ~(dev_t)7) | (part))
+#define dkmodslice(dev, slice) (((dev) & ~(dev_t)0x1f0000) | ((slice) << 16))
+#define dkpart(dev) (minor(dev) & 7)
+#define dkslice(dev) ((minor(dev) >> 16) & 0x1f)
+#define dktype(dev) ((minor(dev) >> 21) & 0x7ff)
+#define dkunit(dev) ((minor(dev) >> 3) & 0x1f)
#ifdef KERNEL
-struct dkbad;
+/*
+ * We're not ready to use <sys/disk.h>.
+ */
+#include <sys/conf.h>
-u_int dkcksum __P((struct disklabel *));
-int writedisklabel __P((dev_t dev, void (*strat)(), struct disklabel *lp));
-char * readdisklabel __P((dev_t dev, void (*strat)(), struct disklabel *lp, struct dos_partition *dp, struct dkbad *bdp));
-int setdisklabel __P((struct disklabel *olp, struct disklabel *nlp, u_long openmask));
+char *correct_readdisklabel __P((dev_t dev, d_strategy_t *strat,
+ struct disklabel *lp));
+void diskerr __P((struct buf *bp, char *dname, char *what, int pri,
+ int blkdone, struct disklabel *lp));
void disksort __P((struct buf *ap, struct buf *bp));
-void diskerr __P((struct buf *, char *, char *, int, int, struct disklabel *));
-#ifdef __i386
-char * readMBRtolabel __P(( dev_t dev , void (*strat)(), register struct disklabel *lp, struct dos_partition *dp, int *cyl));
-#endif
+u_int dkcksum __P((struct disklabel *lp));
+struct dkbad;
+char *readdisklabel __P((dev_t dev, d_strategy_t *strat,
+ struct disklabel *lp,
+ struct dos_partition *dp, struct dkbad *bdp));
+#ifdef __i386__
+char *readMBRtolabel __P((dev_t dev, d_strategy_t *strat,
+ struct disklabel *lp, struct dos_partition *dp,
+ int *cyl));
#endif
+int setdisklabel __P((struct disklabel *olp, struct disklabel *nlp,
+ u_long openmask));
+int writedisklabel __P((dev_t dev, d_strategy_t *strat,
+ struct disklabel *lp));
+
+#endif /* KERNEL */
+
+#endif /* LOCORE */
#if !defined(KERNEL) && !defined(LOCORE)
@@ -401,13 +444,4 @@ __END_DECLS
#endif
-#ifdef __i386
-/* encoding of disk minor numbers, should be elsewhere... */
-#define dkunit(dev) (minor(dev) >> 3)
-#define dkpart(dev) (minor(dev) & 07)
-#define dkminor(unit, part) (((unit) << 3) | (part))
-#endif
-
-#endif
-
-
+#endif /* !_SYS_DISKLABEL_H_ */
diff --git a/sys/sys/diskpc98.h b/sys/sys/diskpc98.h
index 859192e7e374..4e4b4aa571b9 100644
--- a/sys/sys/diskpc98.h
+++ b/sys/sys/diskpc98.h
@@ -35,7 +35,7 @@
*/
#ifndef _SYS_DISKLABEL_H_
-#define _SYS_DISKLABEL_H_
+#define _SYS_DISKLABEL_H_
/*
* Disk description table, see disktab(5)
@@ -50,6 +50,12 @@
* to leave room for a bootstrap, etc.
*/
+/*
+ * XXX the following will go away when conversion to the slice version is
+ * complete: OURPART, RAWPART, readMSPtolabel, readMBRtolabel, dkminor,
+ * the DOSified readdisklabel, DOS stuff in this file.
+ */
+
/* XXX these should be defined per controller (or drive) elsewhere, not here! */
#ifdef __i386__
#define LABELSECTOR 1 /* sector containing label */
@@ -88,6 +94,9 @@
#define MAXPARTITIONS 8
#endif
+#define LABEL_PART 2 /* partition containing label */
+#define RAW_PART 2 /* partition containing whole disk */
+#define SWAP_PART 1 /* partition normally containing swap */
#ifndef LOCORE
struct disklabel {
@@ -375,21 +384,55 @@ extern struct dos_partition dos_partitions[NDOSPART];
#define DIOCSBAD _IOW('d', 110, struct dkbad) /* set kernel dkbad */
-#endif /* LOCORE */
+/*
+ * XXX encoding of disk minor numbers, should be elsewhere.
+ *
+ * See <sys/reboot.h> for a possibly better encoding.
+ *
+ * "cpio -H newc" can be used to back up device files with large minor
+ * numbers (but not ones >= 2^31). Old cpio formats and all tar formats
+ * don't have enough bits, and cpio and tar don't notice the lossage.
+ * There are also some sign extension bugs.
+ */
+#define dkmakeminor(unit, slice, part) \
+ (((slice) << 16) | ((unit) << 3) | (part))
+#define dkminor(unit, part) dkmakeminor((unit), 0, (part))
+#define dkmodpart(dev, part) (((dev) & ~(dev_t)7) | (part))
+#define dkmodslice(dev, slice) (((dev) & ~(dev_t)0x1f0000) | ((slice) << 16))
+#define dkpart(dev) (minor(dev) & 7)
+#define dkslice(dev) ((minor(dev) >> 16) & 0x1f)
+#define dktype(dev) ((minor(dev) >> 21) & 0x7ff)
+#define dkunit(dev) ((minor(dev) >> 3) & 0x1f)
#ifdef KERNEL
-struct dkbad;
+/*
+ * We're not ready to use <sys/disk.h>.
+ */
+#include <sys/conf.h>
-u_int dkcksum __P((struct disklabel *));
-int writedisklabel __P((dev_t dev, void (*strat)(), struct disklabel *lp));
-char * readdisklabel __P((dev_t dev, void (*strat)(), struct disklabel *lp, struct dos_partition *dp, struct dkbad *bdp));
-int setdisklabel __P((struct disklabel *olp, struct disklabel *nlp, u_long openmask));
+char *correct_readdisklabel __P((dev_t dev, d_strategy_t *strat,
+ struct disklabel *lp));
+void diskerr __P((struct buf *bp, char *dname, char *what, int pri,
+ int blkdone, struct disklabel *lp));
void disksort __P((struct buf *ap, struct buf *bp));
-void diskerr __P((struct buf *, char *, char *, int, int, struct disklabel *));
-#ifdef __i386
-char * readMBRtolabel __P(( dev_t dev , void (*strat)(), register struct disklabel *lp, struct dos_partition *dp, int *cyl));
-#endif
+u_int dkcksum __P((struct disklabel *lp));
+struct dkbad;
+char *readdisklabel __P((dev_t dev, d_strategy_t *strat,
+ struct disklabel *lp,
+ struct dos_partition *dp, struct dkbad *bdp));
+#ifdef __i386__
+char *readMBRtolabel __P((dev_t dev, d_strategy_t *strat,
+ struct disklabel *lp, struct dos_partition *dp,
+ int *cyl));
#endif
+int setdisklabel __P((struct disklabel *olp, struct disklabel *nlp,
+ u_long openmask));
+int writedisklabel __P((dev_t dev, d_strategy_t *strat,
+ struct disklabel *lp));
+
+#endif /* KERNEL */
+
+#endif /* LOCORE */
#if !defined(KERNEL) && !defined(LOCORE)
@@ -401,13 +444,4 @@ __END_DECLS
#endif
-#ifdef __i386
-/* encoding of disk minor numbers, should be elsewhere... */
-#define dkunit(dev) (minor(dev) >> 3)
-#define dkpart(dev) (minor(dev) & 07)
-#define dkminor(unit, part) (((unit) << 3) | (part))
-#endif
-
-#endif
-
-
+#endif /* !_SYS_DISKLABEL_H_ */
diff --git a/sys/sys/diskslice.h b/sys/sys/diskslice.h
new file mode 100644
index 000000000000..13c39a63ada5
--- /dev/null
+++ b/sys/sys/diskslice.h
@@ -0,0 +1,78 @@
+/*-
+ * Copyright (c) 1994 Bruce D. Evans.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, 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.
+ *
+ * $Id:
+ */
+
+#ifndef _SYS_DISKSLICE_H_
+#define _SYS_DISKSLICE_H_
+
+#define MAX_SLICES 32
+#define WHOLE_DISK_SLICE 0
+
+struct diskslice {
+ u_long ds_offset; /* starting sector */
+ u_long ds_size; /* number of sectors */
+ struct dkbad_intern *ds_bad; /* bad sector table, if any */
+ struct disklabel *ds_label; /* BSD label, if any */
+ u_char ds_bopenmask; /* bdevs open */
+ u_char ds_copenmask; /* cdevs open */
+ u_char ds_openmask; /* [bc]devs open */
+ u_char ds_wlabel; /* nonzero if label is writable */
+};
+
+struct diskslices {
+ u_int dss_nslices; /* actual dimension of dss_slices[] */
+ struct diskslice
+ dss_slices[MAX_SLICES]; /* actually usually less */
+};
+
+#ifdef KERNEL
+
+#include <sys/conf.h>
+
+#define dsgetbad(dev, ssp) (ssp->dss_slices[dkslice(dev)].ds_bad)
+#define dsgetlabel(dev, ssp) (ssp->dss_slices[dkslice(dev)].ds_label)
+
+struct buf;
+struct disklabel;
+
+typedef int ds_setgeom_t __P((struct disklabel *lp));
+
+int dscheck __P((struct buf *bp, struct diskslices *ssp));
+void dsclose __P((dev_t dev, int mode, struct diskslices *ssp));
+int dsinit __P((char *dname, dev_t dev, d_strategy_t *strat,
+ struct disklabel *lp, struct diskslices **sspp));
+int dsioctl __P((dev_t dev, int cmd, caddr_t data, int flags,
+ struct diskslices *ssp, d_strategy_t *strat,
+ ds_setgeom_t *setgeom));
+int dsopen __P((char *dname, dev_t dev, int mode, struct diskslices **sspp,
+ struct disklabel *lp, d_strategy_t *strat,
+ ds_setgeom_t *setgeom));
+int dswlabel __P((dev_t dev, struct diskslices *ssp, int wlabel));
+
+#endif /* KERNEL */
+
+#endif /* !_SYS_DISKSLICE_H_ */
diff --git a/sys/sys/dkbad.h b/sys/sys/dkbad.h
index 5daecded032f..be5af911b12c 100644
--- a/sys/sys/dkbad.h
+++ b/sys/sys/dkbad.h
@@ -31,11 +31,11 @@
* SUCH DAMAGE.
*
* @(#)dkbad.h 8.1 (Berkeley) 6/2/93
- * $Id: dkbad.h,v 1.2 1994/08/02 07:52:50 davidg Exp $
+ * $Id: dkbad.h,v 1.3 1994/08/21 04:41:40 paul Exp $
*/
#ifndef _SYS_DKBAD_H_
-#define _SYS_DKBAD_H_
+#define _SYS_DKBAD_H_
/*
* Definitions needed to perform bad sector revectoring ala DEC STD 144.
@@ -56,6 +56,11 @@
* making sure that it does not overlap the bad sector information or any
* replacement sectors.
*/
+
+#define DKBAD_MAGIC 0x4321 /* normal value for bt_flag */
+#define DKBAD_MAXBAD 126 /* maximum bad sectors supported */
+#define DKBAD_NOCYL 0xffff /* cylinder to mark end of disk table */
+
struct dkbad {
long bt_csn; /* cartridge serial number */
u_short bt_mbz; /* unused; should be 0 */
@@ -63,7 +68,7 @@ struct dkbad {
struct bt_bad {
u_short bt_cyl; /* cylinder number of bad sector */
u_short bt_trksec; /* track and sector number */
- } bt_bad[126];
+ } bt_bad[DKBAD_MAXBAD];
};
#define ECC 0
@@ -71,4 +76,24 @@ struct dkbad {
#define BSE 2
#define CONT 3
+#ifdef KERNEL
+#include <sys/conf.h>
+
+#define DKBAD_NOSECT (-1) /* sector to mark end of core table */
+
+struct dkbad_intern {
+ daddr_t bi_maxspare; /* last spare sector */
+ u_int bi_nbad; /* actual dimension of bi_badsect[] */
+ long bi_bad[DKBAD_MAXBAD + 1]; /* actually usually less */
+};
+
+struct disklabel;
+
+struct dkbad_intern *internbad144 __P((struct dkbad *btp,
+ struct disklabel *lp));
+char *readbad144 __P((dev_t dev, d_strategy_t *strat,
+ struct disklabel *lp, struct dkbad *btp));
+daddr_t transbad144 __P((struct dkbad_intern *bip, daddr_t blkno));
#endif
+
+#endif /* !_SYS_DKBAD_H_ */