From 656d6a6963ada9c574d67d89694c160915c685bb Mon Sep 17 00:00:00 2001 From: Matthew Dillon Date: Mon, 14 May 2007 20:02:45 +0000 Subject: [PATCH] Start untangling the disklabel from various bits of code with the goal of introducing support for a new 64 bit disklabel. Remove the D_* flags for disklabel.d_flags. These sorts of flags just do not belong in the disk image. Relabel the partition sub-structure in disktab.h, and remove other ancient compatibility defines in disklabel.h. --- include/disktab.h | 7 +- lib/libc/gen/disklabel.c | 11 +-- lib/libc/gen/disktab.c | 11 +-- sbin/disklabel/disklabel.c | 14 +-- sys/bus/cam/scsi/scsi_cd.c | 4 +- sys/dev/disk/ata/atapi-cd.c | 4 +- sys/dev/disk/mcd/mcd.c | 4 +- sys/dev/disk/scd/scd.c | 4 +- sys/kern/subr_diskslice.c | 8 +- sys/sys/disklabel.h | 46 +-------- sys/sys/disklabel32.h | 46 +-------- sys/sys/ndisklabel.h | 127 +++++++++++++++++++++++++ sys/sys/odisklabel.h | 180 +++--------------------------------- 13 files changed, 167 insertions(+), 299 deletions(-) create mode 100644 sys/sys/ndisklabel.h diff --git a/include/disktab.h b/include/disktab.h index 55f0f4625c..317fa6ad37 100644 --- a/include/disktab.h +++ b/include/disktab.h @@ -30,7 +30,8 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * @(#)disktab.h 8.1 (Berkeley) 6/2/93 + * @(#)disktab.h 8.1 (Berkeley) 6/2/93 + * $DragonFly: src/include/disktab.h,v 1.2 2007/05/14 20:02:40 dillon Exp $ */ #ifndef _DISKTAB_H_ @@ -39,7 +40,9 @@ /* * Disk description table, see disktab(5) */ +#ifndef DISKTAB #define DISKTAB "/etc/disktab" +#endif struct disktab { char *d_name; /* drive name */ @@ -51,7 +54,7 @@ struct disktab { int d_rpm; /* revolutions/minute */ int d_badsectforw; /* supports DEC bad144 std */ int d_sectoffset; /* use sect rather than cyl offsets */ - struct partition { + struct dt_partition { int p_size; /* #sectors in partition */ short p_bsize; /* block size in bytes */ short p_fsize; /* frag size in bytes */ diff --git a/lib/libc/gen/disklabel.c b/lib/libc/gen/disklabel.c index f435631c1e..07265f322c 100644 --- a/lib/libc/gen/disklabel.c +++ b/lib/libc/gen/disklabel.c @@ -32,7 +32,7 @@ * * @(#)disklabel.c 8.2 (Berkeley) 5/3/95 * $FreeBSD: src/lib/libc/gen/disklabel.c,v 1.9.2.1 2001/03/05 08:40:47 obrien Exp $ - * $DragonFly: src/lib/libc/gen/disklabel.c,v 1.8 2005/11/19 22:32:53 swildner Exp $ + * $DragonFly: src/lib/libc/gen/disklabel.c,v 1.9 2007/05/14 20:02:41 dillon Exp $ */ #include @@ -57,7 +57,7 @@ getdiskbyname(const char *name) struct disklabel *dp = &disk; struct partition *pp; char *buf; - char *db_array[2] = { _PATH_DISKTAB, 0 }; + char *db_array[2] = { DISKTAB, 0 }; char *cp, *cq; /* can't be register */ char p, max, psize[3], pbsize[3], pfsize[3], poffset[3], ptype[3]; @@ -82,13 +82,6 @@ getdiskbyname(const char *name) cgetstr(buf, "b0", &dp->d_boot0); cgetstr(buf, "b1", &dp->d_boot1); - if (cgetstr(buf, "ty", &cq) > 0 && strcmp(cq, "removable") == 0) - dp->d_flags |= D_REMOVABLE; - else if (cq && strcmp(cq, "simulated") == 0) - dp->d_flags |= D_RAMDISK; - if (cgetcap(buf, "sf", ':') != NULL) - dp->d_flags |= D_BADSECT; - #define getnumdflt(field, dname, dflt) \ { long f; (field) = (cgetnum(buf, dname, &f) == -1) ? (dflt) : f; } diff --git a/lib/libc/gen/disktab.c b/lib/libc/gen/disktab.c index 0b7ef8adae..c10d947301 100644 --- a/lib/libc/gen/disktab.c +++ b/lib/libc/gen/disktab.c @@ -32,7 +32,7 @@ * * @(#)disklabel.c 8.2 (Berkeley) 5/3/95 * $FreeBSD: src/lib/libc/gen/disklabel.c,v 1.9.2.1 2001/03/05 08:40:47 obrien Exp $ - * $DragonFly: src/lib/libc/gen/disktab.c,v 1.8 2005/11/19 22:32:53 swildner Exp $ + * $DragonFly: src/lib/libc/gen/disktab.c,v 1.9 2007/05/14 20:02:41 dillon Exp $ */ #include @@ -57,7 +57,7 @@ getdiskbyname(const char *name) struct disklabel *dp = &disk; struct partition *pp; char *buf; - char *db_array[2] = { _PATH_DISKTAB, 0 }; + char *db_array[2] = { DISKTAB, 0 }; char *cp, *cq; /* can't be register */ char p, max, psize[3], pbsize[3], pfsize[3], poffset[3], ptype[3]; @@ -82,13 +82,6 @@ getdiskbyname(const char *name) cgetstr(buf, "b0", &dp->d_boot0); cgetstr(buf, "b1", &dp->d_boot1); - if (cgetstr(buf, "ty", &cq) > 0 && strcmp(cq, "removable") == 0) - dp->d_flags |= D_REMOVABLE; - else if (cq && strcmp(cq, "simulated") == 0) - dp->d_flags |= D_RAMDISK; - if (cgetcap(buf, "sf", ':') != NULL) - dp->d_flags |= D_BADSECT; - #define getnumdflt(field, dname, dflt) \ { long f; (field) = (cgetnum(buf, dname, &f) == -1) ? (dflt) : f; } diff --git a/sbin/disklabel/disklabel.c b/sbin/disklabel/disklabel.c index ddfe5361ef..8009a93bc9 100644 --- a/sbin/disklabel/disklabel.c +++ b/sbin/disklabel/disklabel.c @@ -37,7 +37,7 @@ * @(#)disklabel.c 1.2 (Symmetric) 11/28/85 * @(#)disklabel.c 8.2 (Berkeley) 1/7/94 * $FreeBSD: src/sbin/disklabel/disklabel.c,v 1.28.2.15 2003/01/24 16:18:16 des Exp $ - * $DragonFly: src/sbin/disklabel/disklabel.c,v 1.12 2006/10/17 02:18:51 pavalos Exp $ + * $DragonFly: src/sbin/disklabel/disklabel.c,v 1.13 2007/05/14 20:02:43 dillon Exp $ */ #include @@ -679,12 +679,6 @@ display(FILE *f, const struct disklabel *lp) fprintf(f, "label: %.*s\n", (int)sizeof(lp->d_packname), lp->d_packname); fprintf(f, "flags:"); - if (lp->d_flags & D_REMOVABLE) - fprintf(f, " removeable"); - if (lp->d_flags & D_ECC) - fprintf(f, " ecc"); - if (lp->d_flags & D_BADSECT) - fprintf(f, " badsect"); fprintf(f, "\n"); fprintf(f, "bytes/sector: %lu\n", (u_long)lp->d_secsize); fprintf(f, "sectors/track: %lu\n", (u_long)lp->d_nsectors); @@ -928,11 +922,11 @@ getasciilabel(FILE *f, struct disklabel *lp) for (v = 0; (cp = tp) && *cp != '\0';) { tp = word(cp); if (streq(cp, "removeable")) - v |= D_REMOVABLE; + v |= 0; /* obsolete */ else if (streq(cp, "ecc")) - v |= D_ECC; + v |= 0; /* obsolete */ else if (streq(cp, "badsect")) - v |= D_BADSECT; + v |= 0; /* obsolete */ else { fprintf(stderr, "line %d: %s: bad flag\n", diff --git a/sys/bus/cam/scsi/scsi_cd.c b/sys/bus/cam/scsi/scsi_cd.c index aa38ab64ef..eeca80ee62 100644 --- a/sys/bus/cam/scsi/scsi_cd.c +++ b/sys/bus/cam/scsi/scsi_cd.c @@ -25,7 +25,7 @@ * SUCH DAMAGE. * * $FreeBSD: src/sys/cam/scsi/scsi_cd.c,v 1.31.2.16 2003/10/21 22:26:11 thomas Exp $ - * $DragonFly: src/sys/bus/cam/scsi/scsi_cd.c,v 1.27 2006/12/22 23:12:16 swildner Exp $ + * $DragonFly: src/sys/bus/cam/scsi/scsi_cd.c,v 1.28 2007/05/14 20:02:44 dillon Exp $ */ /* * Portions of this driver taken from the original FreeBSD cd driver. @@ -2791,7 +2791,7 @@ cdcheckmedia(struct cam_periph *periph) strncpy(label->d_packname, cgd.inq_data.product, min(SID_PRODUCT_SIZE, sizeof(label->d_packname))); - label->d_flags = D_REMOVABLE; + label->d_flags = 0; /* * Make partition 'a' cover the whole disk. This is a temporary * compatibility hack. The 'a' partition should not exist, so diff --git a/sys/dev/disk/ata/atapi-cd.c b/sys/dev/disk/ata/atapi-cd.c index a0e0ab4b0a..767a8f04a6 100644 --- a/sys/dev/disk/ata/atapi-cd.c +++ b/sys/dev/disk/ata/atapi-cd.c @@ -26,7 +26,7 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * $FreeBSD: src/sys/dev/ata/atapi-cd.c,v 1.48.2.20 2002/11/25 05:30:31 njl Exp $ - * $DragonFly: src/sys/dev/disk/ata/atapi-cd.c,v 1.29 2007/05/09 00:53:32 dillon Exp $ + * $DragonFly: src/sys/dev/disk/ata/atapi-cd.c,v 1.30 2007/05/14 20:02:44 dillon Exp $ */ #include "opt_ata.h" @@ -1311,7 +1311,7 @@ acd_read_toc(struct acd_softc *cdp) cdp->disklabel.d_secperunit = cdp->disk_size; cdp->disklabel.d_rpm = 300; cdp->disklabel.d_interleave = 1; - cdp->disklabel.d_flags = D_REMOVABLE; + cdp->disklabel.d_flags = 0; cdp->disklabel.d_npartitions = 1; cdp->disklabel.d_partitions[0].p_offset = 0; cdp->disklabel.d_partitions[0].p_size = cdp->disk_size; diff --git a/sys/dev/disk/mcd/mcd.c b/sys/dev/disk/mcd/mcd.c index 39c7a75e72..d96f1fcdd7 100644 --- a/sys/dev/disk/mcd/mcd.c +++ b/sys/dev/disk/mcd/mcd.c @@ -41,7 +41,7 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * $FreeBSD: src/sys/i386/isa/mcd.c,v 1.115 2000/01/29 16:17:34 peter Exp $ - * $DragonFly: src/sys/dev/disk/mcd/Attic/mcd.c,v 1.21 2006/12/22 23:26:16 swildner Exp $ + * $DragonFly: src/sys/dev/disk/mcd/Attic/mcd.c,v 1.22 2007/05/14 20:02:44 dillon Exp $ */ static const char COPYRIGHT[] = "mcd-driver (C)1993 by H.Veit & B.Moore"; @@ -662,7 +662,7 @@ static int mcd_getdisklabel(int unit) cd->dlabel.d_secperunit = cd->disksize; cd->dlabel.d_rpm = 300; cd->dlabel.d_interleave = 1; - cd->dlabel.d_flags = D_REMOVABLE; + cd->dlabel.d_flags = 0; cd->dlabel.d_npartitions= 1; cd->dlabel.d_partitions[0].p_offset = 0; cd->dlabel.d_partitions[0].p_size = cd->disksize; diff --git a/sys/dev/disk/scd/scd.c b/sys/dev/disk/scd/scd.c index 4e43bf4e04..ba87a4a065 100644 --- a/sys/dev/disk/scd/scd.c +++ b/sys/dev/disk/scd/scd.c @@ -42,7 +42,7 @@ /* $FreeBSD: src/sys/i386/isa/scd.c,v 1.54 2000/01/29 16:00:30 peter Exp $ */ -/* $DragonFly: src/sys/dev/disk/scd/Attic/scd.c,v 1.20 2006/12/22 23:26:17 swildner Exp $ */ +/* $DragonFly: src/sys/dev/disk/scd/Attic/scd.c,v 1.21 2007/05/14 20:02:44 dillon Exp $ */ /* Please send any comments to micke@dynas.se */ @@ -1253,7 +1253,7 @@ read_toc(unsigned unit) cd->dlabel.d_secperunit = cd->disksize; cd->dlabel.d_rpm = 300; cd->dlabel.d_interleave = 1; - cd->dlabel.d_flags = D_REMOVABLE; + cd->dlabel.d_flags = 0; cd->dlabel.d_npartitions= 1; cd->dlabel.d_partitions[0].p_offset = 0; cd->dlabel.d_partitions[0].p_size = cd->disksize; diff --git a/sys/kern/subr_diskslice.c b/sys/kern/subr_diskslice.c index 641e597739..eece982981 100644 --- a/sys/kern/subr_diskslice.c +++ b/sys/kern/subr_diskslice.c @@ -44,7 +44,7 @@ * 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 $ * $FreeBSD: src/sys/kern/subr_diskslice.c,v 1.82.2.6 2001/07/24 09:49:41 dd Exp $ - * $DragonFly: src/sys/kern/subr_diskslice.c,v 1.26 2006/12/23 00:35:04 swildner Exp $ + * $DragonFly: src/sys/kern/subr_diskslice.c,v 1.27 2007/05/14 20:02:45 dillon Exp $ */ #include @@ -785,12 +785,6 @@ dsopen(cdev_t dev, int mode, u_int flags, kfree(lp1, M_DEVBUF); continue; } - if (lp1->d_flags & D_BADSECT) { - log(LOG_ERR, "%s: bad sector table not supported\n", - sname); - kfree(lp1, M_DEVBUF); - continue; - } set_ds_label(ssp, slice, lp1); set_ds_wlabel(ssp, slice, FALSE); } diff --git a/sys/sys/disklabel.h b/sys/sys/disklabel.h index 682d05f1fc..7ce6195287 100644 --- a/sys/sys/disklabel.h +++ b/sys/sys/disklabel.h @@ -32,7 +32,7 @@ * * @(#)disklabel.h 8.2 (Berkeley) 7/10/94 * $FreeBSD: src/sys/sys/disklabel.h,v 1.49.2.7 2001/05/27 05:58:26 jkh Exp $ - * $DragonFly: src/sys/sys/disklabel.h,v 1.16 2007/05/08 02:31:43 dillon Exp $ + * $DragonFly: src/sys/sys/disklabel.h,v 1.17 2007/05/14 20:02:45 dillon Exp $ */ #ifndef _SYS_DISKLABEL_H_ @@ -158,7 +158,7 @@ struct disklabel { u_int16_t d_cylskew; /* sector 0 skew, per cylinder */ u_int32_t d_headswitch; /* head switch time, usec */ u_int32_t d_trkseek; /* track-to-track seek, usec */ - u_int32_t d_flags; /* generic flags */ + u_int32_t d_flags; /* generic flags (now unused) */ #define NDDATA 5 u_int32_t d_drivedata[NDDATA]; /* drive-type specific information */ #define NSPARE 5 @@ -291,51 +291,11 @@ static const char *fstypenames[] = { #define FSMAXTYPES (sizeof(fstypenames) / sizeof(fstypenames[0]) - 1) #endif -/* - * flags shared by various drives: - */ -#define D_REMOVABLE 0x01 /* removable media */ -#define D_ECC 0x02 /* supports ECC */ -#define D_BADSECT 0x04 /* supports bad sector forw. */ -#define D_RAMDISK 0x08 /* disk emulator */ -#define D_CHAIN 0x10 /* can do back-back transfers */ - -/* - * Drive data for SMD. - */ -#define d_smdflags d_drivedata[0] -#define D_SSE 0x1 /* supports skip sectoring */ -#define d_mindist d_drivedata[1] -#define d_maxdist d_drivedata[2] -#define d_sdist d_drivedata[3] - -/* - * Drive data for ST506. - */ -#define d_precompcyl d_drivedata[0] -#define d_gap3 d_drivedata[1] /* used only when formatting */ - -/* - * Drive data for SCSI. - */ -#define d_blind d_drivedata[0] - #ifndef LOCORE -/* - * Structure used to perform a format or other raw operation, returning - * data and/or register values. Register identification and format - * are device- and driver-dependent. - */ -struct format_op { - char *df_buf; - int df_count; /* value-result */ - daddr_t df_startblk; - int df_reg[8]; /* result */ -}; /* * Structure used internally to retrieve information about a partition - * on a disk. + * or disk. */ struct partinfo { struct disklabel *disklab; diff --git a/sys/sys/disklabel32.h b/sys/sys/disklabel32.h index 2a56891d10..551425f3fe 100644 --- a/sys/sys/disklabel32.h +++ b/sys/sys/disklabel32.h @@ -32,7 +32,7 @@ * * @(#)disklabel.h 8.2 (Berkeley) 7/10/94 * $FreeBSD: src/sys/sys/disklabel.h,v 1.49.2.7 2001/05/27 05:58:26 jkh Exp $ - * $DragonFly: src/sys/sys/disklabel32.h,v 1.16 2007/05/08 02:31:43 dillon Exp $ + * $DragonFly: src/sys/sys/disklabel32.h,v 1.17 2007/05/14 20:02:45 dillon Exp $ */ #ifndef _SYS_DISKLABEL_H_ @@ -158,7 +158,7 @@ struct disklabel { u_int16_t d_cylskew; /* sector 0 skew, per cylinder */ u_int32_t d_headswitch; /* head switch time, usec */ u_int32_t d_trkseek; /* track-to-track seek, usec */ - u_int32_t d_flags; /* generic flags */ + u_int32_t d_flags; /* generic flags (now unused) */ #define NDDATA 5 u_int32_t d_drivedata[NDDATA]; /* drive-type specific information */ #define NSPARE 5 @@ -291,51 +291,11 @@ static const char *fstypenames[] = { #define FSMAXTYPES (sizeof(fstypenames) / sizeof(fstypenames[0]) - 1) #endif -/* - * flags shared by various drives: - */ -#define D_REMOVABLE 0x01 /* removable media */ -#define D_ECC 0x02 /* supports ECC */ -#define D_BADSECT 0x04 /* supports bad sector forw. */ -#define D_RAMDISK 0x08 /* disk emulator */ -#define D_CHAIN 0x10 /* can do back-back transfers */ - -/* - * Drive data for SMD. - */ -#define d_smdflags d_drivedata[0] -#define D_SSE 0x1 /* supports skip sectoring */ -#define d_mindist d_drivedata[1] -#define d_maxdist d_drivedata[2] -#define d_sdist d_drivedata[3] - -/* - * Drive data for ST506. - */ -#define d_precompcyl d_drivedata[0] -#define d_gap3 d_drivedata[1] /* used only when formatting */ - -/* - * Drive data for SCSI. - */ -#define d_blind d_drivedata[0] - #ifndef LOCORE -/* - * Structure used to perform a format or other raw operation, returning - * data and/or register values. Register identification and format - * are device- and driver-dependent. - */ -struct format_op { - char *df_buf; - int df_count; /* value-result */ - daddr_t df_startblk; - int df_reg[8]; /* result */ -}; /* * Structure used internally to retrieve information about a partition - * on a disk. + * or disk. */ struct partinfo { struct disklabel *disklab; diff --git a/sys/sys/ndisklabel.h b/sys/sys/ndisklabel.h new file mode 100644 index 0000000000..617029998b --- /dev/null +++ b/sys/sys/ndisklabel.h @@ -0,0 +1,127 @@ +/* + * Copyright (c) 2007 The DragonFly Project. All rights reserved. + * + * This code is derived from software contributed to The DragonFly Project + * by Matthew Dillon + * + * 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. + * 3. Neither the name of The DragonFly Project nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific, prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS 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 + * COPYRIGHT HOLDERS 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. + * + * $DragonFly: src/sys/sys/Attic/ndisklabel.h,v 1.1 2007/05/14 20:02:45 dillon Exp $ + */ + +/* + * DragonFly disk label + */ +#ifndef _SYS_NDISKLABEL_H_ +#define _SYS_NDISKLABEL_H_ + +#ifndef _SYS_TYPES_H_ +#include +#endif + +/* + * A Dragonfly new-style disklabel always resides at byte offset 4096 + * from the beginning of the block device, regardless of the sector size. + * + * All offsets stored in the disklabel are in bytes relative to the + * beginning of the block device, not relative to the disk label. + */ +#define DFLY_LABEL_BYTE_OFFSET 4096 + +/* + * Misc constants. + * + * Disklabels are stored in native-endian format and are portable as long + * as the code checks for and properly converts the label. Only big-endian + * and little-endian formats are supported. + */ +#define DFLY_DISKMAGIC ((u_int64_t)0xc4466c7942534430) +#define DFLY_DISKMAGIC_OTHER ((u_int64_t)0x30445342796c46c4) +#define DFLY_MAXPARTITIONS 26 + +#ifndef LOCORE + +/* + * The disk label and partitions a-z. All offsets and sizes are in bytes + * but must be sector-aligned. Other then the alignment requirement, the + * disklabel doesn't care what the physical sector size of the media is. + * + * All offsets are in bytes and are relative to the beginning of the + * block device in question (raw disk, slice, whatever), NOT the beginning + * of the label. + */ +struct dfly_disklabel { + u_int64_t d_magic; /* magic number / endian check */ + u_int64_t d_serialno; /* initial disklabel creation */ + u_int64_t d_timestamp; /* timestamp of disklabel creation */ + u_int64_t d_crc; /* cyclic redundancy check for label */ + /* (after any endian translation) */ + u_int64_t d_size; /* size of block device in bytes */ + u_int32_t d_npart; /* actual number of partitions */ + u_int32_t d_labelsize; /* max size of label in bytes */ + u_int32_t d_bootpart; /* -1 if not defined */ + u_int32_t d_version; /* disklabel version control */ + char d_label[64]; /* user defined label (mandatory) */ + char d_reserved[128]; + + /* + * Partitions do not have individual labels. The filesystem or + * storage layer id is specified in ascii, 14 chars max, 0-extended. + * p_layer[15] must always be 0. + * + * All offsets and sizes are in bytes but still must be aligned to + * the native sector size of the media. + */ + struct dfly_diskpart { + u_int64_t p_offset; /* offset in bytes */ + u_int64_t p_size; /* size in bytes */ + u_int32_t p_flags; /* misc flags */ + char p_layer[16]; /* FS or storage layer ID */ + } d_partitions[DFLY_MAXPARTITIONS]; + /* might be extended further */ +}; + +#endif + +#define DFLY_PARTF_VALID 0x0001 /* partition defined */ +#define DFLY_PARTF_GOOD 0x0002 /* fs/storage formatted */ +#define DFLY_PARTF_RECURSE 0x0004 /* recursive disklabel */ + +#define DFLY_DISKLABEL_SWAP "swap" /* strcmp w/ p_layer[] */ +#define DFLY_DISKLABEL_UFS "ufs" /* strcmp w/ p_layer[] */ + +#ifndef LOCORE + +#define DFLY_DIOCGDINFO _IOR('d', 101, struct dfly_disklabel) /* get */ +#define DFLY_DIOCSDINFO _IOW('d', 102, struct dfly_disklabel) /* set */ +#define DFLY_DIOCWDINFO _IOW('d', 103, struct dfly_disklabel) /* set, update */ +#define DFLY_DIOCGDVIRGIN _IOR('d', 105, struct dfly_disklabel) /* get new */ + +#endif + +#endif /* !_SYS_NDISKLABEL_H_ */ diff --git a/sys/sys/odisklabel.h b/sys/sys/odisklabel.h index 6fb4e50be4..add7600373 100644 --- a/sys/sys/odisklabel.h +++ b/sys/sys/odisklabel.h @@ -32,11 +32,11 @@ * * @(#)disklabel.h 8.2 (Berkeley) 7/10/94 * $FreeBSD: src/sys/sys/disklabel.h,v 1.49.2.7 2001/05/27 05:58:26 jkh Exp $ - * $DragonFly: src/sys/sys/Attic/odisklabel.h,v 1.16 2007/05/08 02:31:43 dillon Exp $ + * $DragonFly: src/sys/sys/Attic/odisklabel.h,v 1.17 2007/05/14 20:02:45 dillon Exp $ */ -#ifndef _SYS_DISKLABEL_H_ -#define _SYS_DISKLABEL_H_ +#ifndef _SYS_ODISKLABEL_H_ +#define _SYS_ODISKLABEL_H_ #ifndef _SYS_TYPES_H_ #include @@ -51,12 +51,6 @@ #include /* for make_sub_dev() */ #endif -/* - * Disk description table, see disktab(5) - */ -#define _PATH_DISKTAB "/etc/disktab" -#define DISKTAB "/etc/disktab" /* deprecated */ - /* * Each disk has a label which includes information about the hardware * disk geometry, filesystem partitions, and drive specific information. @@ -88,7 +82,7 @@ #define SWAP_PART 1 /* partition normally containing swap */ #ifndef LOCORE -struct disklabel { +struct odisklabel { u_int32_t d_magic; /* the magic number */ u_int16_t d_type; /* drive type */ u_int16_t d_subtype; /* controller/d_type specific */ @@ -170,7 +164,7 @@ struct disklabel { u_int16_t d_npartitions; /* number of partitions in following */ u_int32_t d_bbsize; /* size of boot area at sn0, bytes */ u_int32_t d_sbsize; /* max size of fs superblock, bytes */ - struct partition { /* the partition table */ + struct opartition { /* the partition table */ u_int32_t p_size; /* number of sectors in partition */ u_int32_t p_offset; /* starting sector */ u_int32_t p_fsize; /* filesystem basic fragment size */ @@ -185,10 +179,10 @@ struct disklabel { } d_partitions[MAXPARTITIONS]; /* actually may be more */ }; -static u_int16_t dkcksum(struct disklabel *lp); +static u_int16_t odkcksum(struct odisklabel *lp); static __inline u_int16_t -dkcksum(struct disklabel *lp) +odkcksum(struct odisklabel *lp) { u_int16_t *start, *end; u_int16_t sum = 0; @@ -291,167 +285,17 @@ static const char *fstypenames[] = { #define FSMAXTYPES (sizeof(fstypenames) / sizeof(fstypenames[0]) - 1) #endif -/* - * flags shared by various drives: - */ -#define D_REMOVABLE 0x01 /* removable media */ -#define D_ECC 0x02 /* supports ECC */ -#define D_BADSECT 0x04 /* supports bad sector forw. */ -#define D_RAMDISK 0x08 /* disk emulator */ -#define D_CHAIN 0x10 /* can do back-back transfers */ - -/* - * Drive data for SMD. - */ -#define d_smdflags d_drivedata[0] -#define D_SSE 0x1 /* supports skip sectoring */ -#define d_mindist d_drivedata[1] -#define d_maxdist d_drivedata[2] -#define d_sdist d_drivedata[3] - -/* - * Drive data for ST506. - */ -#define d_precompcyl d_drivedata[0] -#define d_gap3 d_drivedata[1] /* used only when formatting */ - -/* - * Drive data for SCSI. - */ -#define d_blind d_drivedata[0] - #ifndef LOCORE -/* - * Structure used to perform a format or other raw operation, returning - * data and/or register values. Register identification and format - * are device- and driver-dependent. - */ -struct format_op { - char *df_buf; - int df_count; /* value-result */ - daddr_t df_startblk; - int df_reg[8]; /* result */ -}; - -/* - * Structure used internally to retrieve information about a partition - * on a disk. - */ -struct partinfo { - struct disklabel *disklab; - struct partition *part; -}; /* * Disk-specific ioctls. */ /* get and set disklabel; DIOCGPART used internally */ -#define DIOCGDINFO _IOR('d', 101, struct disklabel)/* get */ -#define DIOCSDINFO _IOW('d', 102, struct disklabel)/* set */ -#define DIOCWDINFO _IOW('d', 103, struct disklabel)/* set, update disk */ -#define DIOCGPART _IOW('d', 104, struct partinfo) /* get partition */ -#define DIOCGDVIRGIN _IOR('d', 105, struct disklabel) /* get virgin label */ - -#define DIOCWLABEL _IOW('d', 109, int) /* write en/disable label */ - -#ifdef _KERNEL - -/* - * XXX encoding of disk minor numbers, should be elsewhere. - * - * See 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. - */ - -/* - 3 2 1 0 - 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 - _________________________________________________________________ - | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | - ----------------------------------------------------------------- - | TYPE |UNIT_2 |P| SLICE | MAJOR? | UNIT |PART | - ----------------------------------------------------------------- -*/ - -#define DKMAXUNIT 0x1ff /* Highest disk unit number */ - -#define dkmakeminor(unit, slice, part) \ - (((slice) << 16) | (((unit) & 0x1e0) << 16) | \ - (((unit) & 0x1f) << 3) | (part & 7) | \ - ((part & 0x08) << 17)) - -static __inline u_int -dkunitmask(void) -{ - return (0x01e000f8); -} - -static __inline u_int -dkmakeunit(int unit) -{ - return(dkmakeminor(unit, 0, 0)); -} - -static __inline cdev_t -dkmodpart(cdev_t dev, int part) -{ - int val; - - if (part < 8) - val = (part & 7); - else - val = (part & 7) | 0x100000; - return (make_sub_dev(dev, (minor(dev) & ~0x100007) | val)); -} - -static __inline cdev_t -dkmodslice(cdev_t dev, int slice) -{ - return (make_sub_dev(dev, (minor(dev) & ~0x0f0000) | (slice << 16))); -} - -static __inline int -dkpart(cdev_t dev) -{ - return (((minor(dev) >> 17) & 0x08) | (minor(dev) & 7)); -} - -#define dkslice(dev) ((minor(dev) >> 16) & 0x0f) -#define dktype(dev) ((minor(dev) >> 25) & 0x7f) - -static __inline u_int -dkunit(cdev_t dev) -{ - return (((minor(dev) >> 16) & 0x1e0) | ((minor(dev) >> 3) & 0x1f)); -} - -struct buf; -struct bio; -struct bio_queue_head; - -struct bio *bounds_check_with_label (cdev_t dev, struct bio *bio, - struct disklabel *lp, int wlabel); -void diskerr (struct bio *bio, cdev_t dev, const char *what, int pri, - int donecnt, struct disklabel *lp); -void disksort (struct buf *ap, struct buf *bp); -char *readdisklabel (cdev_t dev, struct disklabel *lp); -void bioqdisksort (struct bio_queue_head *ap, struct bio *bio); -int setdisklabel (struct disklabel *olp, struct disklabel *nlp, - u_long openmask); -int writedisklabel (cdev_t dev, struct disklabel *lp); - -#endif /* _KERNEL */ +#define ODIOCGDINFO _IOR('d', 101, struct odisklabel)/* get */ +#define ODIOCSDINFO _IOW('d', 102, struct odisklabel)/* set */ +#define ODIOCWDINFO _IOW('d', 103, struct odisklabel)/* set, update disk */ +#define ODIOCGDVIRGIN _IOR('d', 105, struct odisklabel) /* get virgin label */ #endif /* LOCORE */ -#ifndef _KERNEL -__BEGIN_DECLS -struct disklabel *getdiskbyname (const char *); -__END_DECLS -#endif - -#endif /* !_SYS_DISKLABEL_H_ */ +#endif /* !_SYS_ODISKLABEL_H_ */ -- 2.41.0