svn commit: r307386 - in head: etc/mtree include sys/sys sys/sys/disk
Marcel Moolenaar
marcel at FreeBSD.org
Sun Oct 16 02:43:54 UTC 2016
Author: marcel
Date: Sun Oct 16 02:43:51 2016
New Revision: 307386
URL: https://svnweb.freebsd.org/changeset/base/307386
Log:
Re-apply change 306811 or alternatively, revert change 307385.
Added:
head/sys/sys/disk/
head/sys/sys/disk/apm.h
- copied, changed from r307385, head/sys/sys/apm.h
head/sys/sys/disk/bsd.h
- copied, changed from r307385, head/sys/sys/disklabel.h
head/sys/sys/disk/gpt.h
- copied, changed from r307385, head/sys/sys/gpt.h
head/sys/sys/disk/mbr.h
- copied, changed from r307385, head/sys/sys/diskmbr.h
head/sys/sys/disk/pc98.h
- copied, changed from r307385, head/sys/sys/diskpc98.h
head/sys/sys/disk/vtoc.h
- copied, changed from r307385, head/sys/sys/vtoc.h
Modified:
head/etc/mtree/BSD.include.dist
head/include/Makefile
head/sys/sys/apm.h
head/sys/sys/disklabel.h
head/sys/sys/diskmbr.h
head/sys/sys/diskpc98.h
head/sys/sys/gpt.h
head/sys/sys/vtoc.h
Modified: head/etc/mtree/BSD.include.dist
==============================================================================
--- head/etc/mtree/BSD.include.dist Sun Oct 16 02:05:22 2016 (r307385)
+++ head/etc/mtree/BSD.include.dist Sun Oct 16 02:43:51 2016 (r307386)
@@ -336,6 +336,8 @@
ssp
..
sys
+ disk
+ ..
..
teken
..
Modified: head/include/Makefile
==============================================================================
--- head/include/Makefile Sun Oct 16 02:05:22 2016 (r307385)
+++ head/include/Makefile Sun Oct 16 02:43:51 2016 (r307386)
@@ -59,6 +59,7 @@ LSUBDIRS= cam/ata cam/nvme cam/scsi \
security/audit \
security/mac_biba security/mac_bsdextended security/mac_lomac \
security/mac_mls security/mac_partition \
+ sys/disk \
ufs/ffs ufs/ufs
LSUBSUBDIRS= dev/mpt/mpilib
Modified: head/sys/sys/apm.h
==============================================================================
--- head/sys/sys/apm.h Sun Oct 16 02:05:22 2016 (r307385)
+++ head/sys/sys/apm.h Sun Oct 16 02:43:51 2016 (r307386)
@@ -1,69 +1,5 @@
/*-
- * Copyright (c) 2007 Marcel Moolenaar
- * 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 ``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 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.
- *
- * $FreeBSD$
+ * This file is in the public domain.
*/
-
-#ifndef _SYS_APM_H_
-#define _SYS_APM_H_
-
-/* Driver Descriptor Record. */
-struct apm_ddr {
- uint16_t ddr_sig;
-#define APM_DDR_SIG 0x4552
- uint16_t ddr_blksize;
- uint32_t ddr_blkcount;
-};
-
-#define APM_ENT_NAMELEN 32
-#define APM_ENT_TYPELEN 32
-
-/* Partition Map Entry Record. */
-struct apm_ent {
- uint16_t ent_sig;
-#define APM_ENT_SIG 0x504d
- uint16_t _pad_;
- uint32_t ent_pmblkcnt;
- uint32_t ent_start;
- uint32_t ent_size;
- char ent_name[APM_ENT_NAMELEN];
- char ent_type[APM_ENT_TYPELEN];
-};
-
-#define APM_ENT_TYPE_SELF "Apple_partition_map"
-#define APM_ENT_TYPE_UNUSED "Apple_Free"
-
-#define APM_ENT_TYPE_FREEBSD "FreeBSD"
-#define APM_ENT_TYPE_FREEBSD_NANDFS "FreeBSD-nandfs"
-#define APM_ENT_TYPE_FREEBSD_SWAP "FreeBSD-swap"
-#define APM_ENT_TYPE_FREEBSD_UFS "FreeBSD-UFS"
-#define APM_ENT_TYPE_FREEBSD_VINUM "FreeBSD-Vinum"
-#define APM_ENT_TYPE_FREEBSD_ZFS "FreeBSD-ZFS"
-
-#define APM_ENT_TYPE_APPLE_BOOT "Apple_Bootstrap"
-#define APM_ENT_TYPE_APPLE_HFS "Apple_HFS"
-#define APM_ENT_TYPE_APPLE_UFS "Apple_UNIX_SVR2"
-
-#endif /* _SYS_APM_H_ */
+/* $FreeBSD$ */
+#include <sys/disk/apm.h>
Copied and modified: head/sys/sys/disk/apm.h (from r307385, head/sys/sys/apm.h)
==============================================================================
--- head/sys/sys/apm.h Sun Oct 16 02:05:22 2016 (r307385, copy source)
+++ head/sys/sys/disk/apm.h Sun Oct 16 02:43:51 2016 (r307386)
@@ -26,8 +26,8 @@
* $FreeBSD$
*/
-#ifndef _SYS_APM_H_
-#define _SYS_APM_H_
+#ifndef _SYS_DISK_APM_H_
+#define _SYS_DISK_APM_H_
/* Driver Descriptor Record. */
struct apm_ddr {
@@ -66,4 +66,4 @@ struct apm_ent {
#define APM_ENT_TYPE_APPLE_HFS "Apple_HFS"
#define APM_ENT_TYPE_APPLE_UFS "Apple_UNIX_SVR2"
-#endif /* _SYS_APM_H_ */
+#endif /* _SYS_DISK_APM_H_ */
Copied and modified: head/sys/sys/disk/bsd.h (from r307385, head/sys/sys/disklabel.h)
==============================================================================
--- head/sys/sys/disklabel.h Sun Oct 16 02:05:22 2016 (r307385, copy source)
+++ head/sys/sys/disk/bsd.h Sun Oct 16 02:43:51 2016 (r307386)
@@ -30,60 +30,45 @@
* $FreeBSD$
*/
-#ifndef _SYS_DISKLABEL_H_
-#define _SYS_DISKLABEL_H_
+#ifndef _SYS_DISK_BSD_H_
+#define _SYS_DISK_BSD_H_
-#ifndef _KERNEL
-#include <sys/types.h>
-#endif
-#include <sys/ioccom.h>
+/* The disk magic number */
+#define BSD_MAGIC 0x82564557U
-/*
- * Disk description table, see disktab(5)
- */
-#define _PATH_DISKTAB "/etc/disktab"
+#define BSD_NPARTS_MIN 8
+#define BSD_NPARTS_MAX 20
-/*
- * Each disk has a label which includes information about the hardware
- * disk geometry, filesystem partitions, and drive specific information.
- * The label is in block 0 or 1, possibly offset from the beginning
- * to leave room for a bootstrap, etc.
- */
+/* Size of bootblock area in sector-size neutral bytes */
+#define BSD_BOOTBLOCK_SIZE 8192
-/* XXX these should be defined per controller (or drive) elsewhere, not here! */
-#if defined(__i386__) || defined(__amd64__) || defined(__arm__) || \
- defined(__powerpc__) || defined(__mips__)
-#define LABELSECTOR 1 /* sector containing label */
-#define LABELOFFSET 0 /* offset of label in sector */
-#endif
+/* partition containing whole disk */
+#define BSD_PART_RAW 2
-#define DISKMAGIC ((u_int32_t)0x82564557) /* The disk magic number */
-#ifndef MAXPARTITIONS
-#define MAXPARTITIONS 8
-#endif
+/* partition normally containing swap */
+#define BSD_PART_SWAP 1
-/* Size of bootblock area in sector-size neutral bytes */
-#define BBSIZE 8192
+/* Drive-type specific data size (in number of 32-bit inegrals) */
+#define BSD_NDRIVEDATA 5
-#define LABEL_PART 2 /* partition containing label */
-#define RAW_PART 2 /* partition containing whole disk */
-#define SWAP_PART 1 /* partition normally containing swap */
+/* Number of spare 32-bit integrals following drive-type data */
+#define BSD_NSPARE 5
struct disklabel {
- u_int32_t d_magic; /* the magic number */
- u_int16_t d_type; /* drive type */
- u_int16_t d_subtype; /* controller/d_type specific */
- char d_typename[16]; /* type name, e.g. "eagle" */
+ uint32_t d_magic; /* the magic number */
+ uint16_t d_type; /* drive type */
+ uint16_t d_subtype; /* controller/d_type specific */
+ char d_typename[16]; /* type name, e.g. "eagle" */
- char d_packname[16]; /* pack identifier */
+ char d_packname[16]; /* pack identifier */
/* disk geometry: */
- u_int32_t d_secsize; /* # of bytes per sector */
- u_int32_t d_nsectors; /* # of data sectors per track */
- u_int32_t d_ntracks; /* # of tracks per cylinder */
- u_int32_t d_ncylinders; /* # of data cylinders per unit */
- u_int32_t d_secpercyl; /* # of data sectors per cylinder */
- u_int32_t d_secperunit; /* # of data sectors per unit */
+ uint32_t d_secsize; /* # of bytes per sector */
+ uint32_t d_nsectors; /* # of data sectors per track */
+ uint32_t d_ntracks; /* # of tracks per cylinder */
+ uint32_t d_ncylinders; /* # of data cylinders per unit */
+ uint32_t d_secpercyl; /* # of data sectors per cylinder */
+ uint32_t d_secperunit; /* # of data sectors per unit */
/*
* Spares (bad sector replacements) below are not counted in
@@ -91,13 +76,13 @@ struct disklabel {
* be physical sectors which occupy space at the end of each
* track and/or cylinder.
*/
- u_int16_t d_sparespertrack; /* # of spare sectors per track */
- u_int16_t d_sparespercyl; /* # of spare sectors per cylinder */
+ uint16_t d_sparespertrack; /* # of spare sectors per track */
+ uint16_t d_sparespercyl; /* # of spare sectors per cylinder */
/*
* Alternate cylinders include maintenance, replacement, configuration
* description areas, etc.
*/
- u_int32_t d_acylinders; /* # of alt. cylinders per unit */
+ uint32_t d_acylinders; /* # of alt. cylinders per unit */
/* hardware characteristics: */
/*
@@ -116,53 +101,35 @@ struct disklabel {
* is the offset of sector 0 on cylinder N relative to sector 0
* on cylinder N-1.
*/
- u_int16_t d_rpm; /* rotational speed */
- u_int16_t d_interleave; /* hardware sector interleave */
- u_int16_t d_trackskew; /* sector 0 skew, per track */
- 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 */
-#define NDDATA 5
- u_int32_t d_drivedata[NDDATA]; /* drive-type specific information */
-#define NSPARE 5
- u_int32_t d_spare[NSPARE]; /* reserved for future use */
- u_int32_t d_magic2; /* the magic number (again) */
- u_int16_t d_checksum; /* xor of data incl. partitions */
+ uint16_t d_rpm; /* rotational speed */
+ uint16_t d_interleave; /* hardware sector interleave */
+ uint16_t d_trackskew; /* sector 0 skew, per track */
+ uint16_t d_cylskew; /* sector 0 skew, per cylinder */
+ uint32_t d_headswitch; /* head switch time, usec */
+ uint32_t d_trkseek; /* track-to-track seek, usec */
+ uint32_t d_flags; /* generic flags */
+ uint32_t d_drivedata[BSD_NDRIVEDATA]; /* drive-type specific data */
+ uint32_t d_spare[BSD_NSPARE]; /* reserved for future use */
+ uint32_t d_magic2; /* the magic number (again) */
+ uint16_t d_checksum; /* xor of data incl. partitions */
/* filesystem and partition information: */
- 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 */
+ uint16_t d_npartitions; /* number of partitions in following */
+ uint32_t d_bbsize; /* size of boot area at sn0, bytes */
+ uint32_t d_sbsize; /* max size of fs superblock, bytes */
struct partition { /* 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 */
- u_int8_t p_fstype; /* filesystem type, see below */
- u_int8_t p_frag; /* filesystem fragments per block */
- u_int16_t p_cpg; /* filesystem cylinders per group */
- } d_partitions[MAXPARTITIONS]; /* actually may be more */
+ uint32_t p_size; /* number of sectors in partition */
+ uint32_t p_offset; /* starting sector */
+ uint32_t p_fsize; /* filesystem basic fragment size */
+ uint8_t p_fstype; /* filesystem type, see below */
+ uint8_t p_frag; /* filesystem fragments per block */
+ uint16_t p_cpg; /* filesystem cylinders per group */
+ } d_partitions[BSD_NPARTS_MIN]; /* actually may be more */
};
-
#ifdef CTASSERT
-CTASSERT(sizeof(struct disklabel) == 148 + MAXPARTITIONS * 16);
+CTASSERT(sizeof(struct disklabel) == 148 + BSD_NPARTS_MIN * 16);
#endif
-static __inline u_int16_t dkcksum(struct disklabel *lp);
-static __inline u_int16_t
-dkcksum(struct disklabel *lp)
-{
- u_int16_t *start, *end;
- u_int16_t sum = 0;
-
- start = (u_int16_t *)lp;
- end = (u_int16_t *)&lp->d_partitions[lp->d_npartitions];
- while (start < end)
- sum ^= *start++;
- return (sum);
-}
-
-
/* d_type values: */
#define DTYPE_SMD 1 /* SMD, XSMD; VAX hp/up */
#define DTYPE_MSCP 2 /* MSCP */
@@ -179,30 +146,6 @@ dkcksum(struct disklabel *lp)
#define DTYPE_RAID 14 /* CMU RAIDFrame */
#define DTYPE_JFS2 16 /* IBM JFS 2 */
-#ifdef DKTYPENAMES
-static const char *dktypenames[] = {
- "unknown",
- "SMD",
- "MSCP",
- "old DEC",
- "SCSI",
- "ESDI",
- "ST506",
- "HP-IB",
- "HP-FL",
- "type 9",
- "floppy",
- "CCD",
- "Vinum",
- "DOC2K",
- "Raid",
- "?",
- "jfs",
- NULL
-};
-#define DKMAXTYPES (sizeof(dktypenames) / sizeof(dktypenames[0]) - 1)
-#endif
-
/*
* Filesystem type and version.
* Used to interpret other filesystem-specific
@@ -236,44 +179,6 @@ static const char *dktypenames[] = {
#define FS_ZFS 27 /* Sun's ZFS */
#define FS_NANDFS 30 /* FreeBSD nandfs (NiLFS derived) */
-#ifdef FSTYPENAMES
-static const char *fstypenames[] = {
- "unused",
- "swap",
- "Version 6",
- "Version 7",
- "System V",
- "4.1BSD",
- "Eighth Edition",
- "4.2BSD",
- "MSDOS",
- "4.4LFS",
- "unknown",
- "HPFS",
- "ISO9660",
- "boot",
- "vinum",
- "raid",
- "Filecore",
- "EXT2FS",
- "NTFS",
- "?",
- "ccd",
- "jfs",
- "HAMMER",
- "HAMMER2",
- "UDF",
- "?",
- "EFS",
- "ZFS",
- "?",
- "?",
- "nandfs",
- NULL
-};
-#define FSMAXTYPES (sizeof(fstypenames) / sizeof(fstypenames[0]) - 1)
-#endif
-
/*
* flags shared by various drives:
*/
@@ -283,23 +188,4 @@ static const char *fstypenames[] = {
#define D_RAMDISK 0x08 /* disk emulator */
#define D_CHAIN 0x10 /* can do back-back transfers */
-/*
- * NB: <sys/disk.h> defines ioctls from 'd'/128 and up.
- */
-
-/*
- * Functions for proper encoding/decoding of struct disklabel into/from
- * bytestring.
- */
-void bsd_partition_le_dec(u_char *ptr, struct partition *d);
-int bsd_disklabel_le_dec(u_char *ptr, struct disklabel *d, int maxpart);
-void bsd_partition_le_enc(u_char *ptr, struct partition *d);
-void bsd_disklabel_le_enc(u_char *ptr, struct disklabel *d);
-
-#ifndef _KERNEL
-__BEGIN_DECLS
-struct disklabel *getdiskbyname(const char *);
-__END_DECLS
-#endif
-
-#endif /* !_SYS_DISKLABEL_H_ */
+#endif /* !_SYS_DISK_BSD_H_ */
Copied and modified: head/sys/sys/disk/gpt.h (from r307385, head/sys/sys/gpt.h)
==============================================================================
--- head/sys/sys/gpt.h Sun Oct 16 02:05:22 2016 (r307385, copy source)
+++ head/sys/sys/disk/gpt.h Sun Oct 16 02:43:51 2016 (r307386)
@@ -26,10 +26,31 @@
* $FreeBSD$
*/
-#ifndef _SYS_GPT_H_
-#define _SYS_GPT_H_
+#ifndef _SYS_DISK_GPT_H_
+#define _SYS_DISK_GPT_H_
-#include <sys/uuid.h>
+/*
+ * Applications can define GPT_UUID_TYPE if they want the GPT structures
+ * to use a particular type definition for UUIDs/GUIDs. This header uses
+ * a generic (DCE 1.1 compatible) definition otherwise.
+ */
+#ifndef GPT_UUID_TYPE
+struct gpt_uuid {
+ uint32_t time_low;
+ uint16_t time_mid;
+ uint16_t time_hi_and_version;
+ uint8_t clock_seq_hi_and_reserved;
+ uint8_t clock_seq_low;
+ uint8_t node[6];
+};
+#define GPT_UUID_TYPE struct gpt_uuid
+#endif /* !GPT_UUID_TYPE */
+
+typedef GPT_UUID_TYPE gpt_uuid_t;
+
+#ifdef CTASSERT
+CTASSERT(sizeof(gpt_uuid_t) == 16);
+#endif
struct gpt_hdr {
char hdr_sig[8];
@@ -43,7 +64,7 @@ struct gpt_hdr {
uint64_t hdr_lba_alt;
uint64_t hdr_lba_start;
uint64_t hdr_lba_end;
- struct uuid hdr_uuid;
+ gpt_uuid_t hdr_uuid;
uint64_t hdr_lba_table;
uint32_t hdr_entries;
uint32_t hdr_entsz;
@@ -57,10 +78,13 @@ struct gpt_hdr {
*/
uint32_t padding;
};
+#ifdef CTASSERT
+CTASSERT(offsetof(struct gpt_hdr, padding) == 92);
+#endif
struct gpt_ent {
- struct uuid ent_type;
- struct uuid ent_uuid;
+ gpt_uuid_t ent_type;
+ gpt_uuid_t ent_uuid;
uint64_t ent_lba_start;
uint64_t ent_lba_end;
uint64_t ent_attr;
@@ -70,6 +94,9 @@ struct gpt_ent {
#define GPT_ENT_ATTR_BOOTFAILED (1ULL << 57)
uint16_t ent_name[36]; /* UTF-16. */
};
+#ifdef CTASSERT
+CTASSERT(sizeof(struct gpt_ent) == 128);
+#endif /* CTASSERT */
#define GPT_ENT_TYPE_UNUSED \
{0x00000000,0x0000,0x0000,0x00,0x00,{0x00,0x00,0x00,0x00,0x00,0x00}}
@@ -207,4 +234,4 @@ struct gpt_ent {
#define GPT_ENT_TYPE_BIOS_BOOT \
{0x21686148,0x6449,0x6e6f,0x74,0x4e,{0x65,0x65,0x64,0x45,0x46,0x49}}
-#endif /* _SYS_GPT_H_ */
+#endif /* _SYS_DISK_GPT_H_ */
Copied and modified: head/sys/sys/disk/mbr.h (from r307385, head/sys/sys/diskmbr.h)
==============================================================================
--- head/sys/sys/diskmbr.h Sun Oct 16 02:05:22 2016 (r307385, copy source)
+++ head/sys/sys/disk/mbr.h Sun Oct 16 02:43:51 2016 (r307386)
@@ -30,10 +30,8 @@
* $FreeBSD$
*/
-#ifndef _SYS_DISKMBR_H_
-#define _SYS_DISKMBR_H_
-
-#include <sys/ioccom.h>
+#ifndef _SYS_DISK_MBR_H_
+#define _SYS_DISK_MBR_H_
#define DOSBBSECTOR 0 /* DOS boot block relative sector number */
#define DOSDSNOFF 440 /* WinNT/2K/XP Drive Serial Number offset */
@@ -73,19 +71,14 @@ struct dos_partition {
unsigned char dp_ehd; /* end head */
unsigned char dp_esect; /* end sector */
unsigned char dp_ecyl; /* end cylinder */
- u_int32_t dp_start; /* absolute starting sector number */
- u_int32_t dp_size; /* partition size in sectors */
+ uint32_t dp_start; /* absolute starting sector number */
+ uint32_t dp_size; /* partition size in sectors */
};
#ifdef CTASSERT
CTASSERT(sizeof (struct dos_partition) == DOSPARTSIZE);
#endif
-void dos_partition_dec(void const *pp, struct dos_partition *d);
-void dos_partition_enc(void *pp, struct dos_partition *d);
-
#define DPSECT(s) ((s) & 0x3f) /* isolate relevant bits of sector */
#define DPCYL(c, s) ((c) + (((s) & 0xc0)<<2)) /* and those that are cylinder */
-#define DIOCSMBR _IOW('M', 129, u_char[512])
-
-#endif /* !_SYS_DISKMBR_H_ */
+#endif /* !_SYS_DISK_MBR_H_ */
Copied and modified: head/sys/sys/disk/pc98.h (from r307385, head/sys/sys/diskpc98.h)
==============================================================================
--- head/sys/sys/diskpc98.h Sun Oct 16 02:05:22 2016 (r307385, copy source)
+++ head/sys/sys/disk/pc98.h Sun Oct 16 02:43:51 2016 (r307386)
@@ -30,10 +30,8 @@
* $FreeBSD$
*/
-#ifndef _SYS_DISKPC98_H_
-#define _SYS_DISKPC98_H_
-
-#include <sys/ioccom.h>
+#ifndef _SYS_DISK_PC98_H_
+#define _SYS_DISK_PC98_H_
#define PC98_BBSECTOR 1 /* DOS boot block relative sector number */
#define PC98_PARTOFF 0
@@ -50,12 +48,12 @@
#define PC98_SID_MASK 0x7f
#define PC98_SID_386BSD 0x44
-#define DOSMID_386BSD (PC98_MID_386BSD | PC98_MID_BOOTABLE)
-#define DOSSID_386BSD (PC98_SID_386BSD | PC98_SID_ACTIVE)
-#define PC98_PTYP_386BSD (DOSSID_386BSD << 8 | DOSMID_386BSD)
+#define __DOSMID_386BSD (PC98_MID_386BSD | PC98_MID_BOOTABLE)
+#define __DOSSID_386BSD (PC98_SID_386BSD | PC98_SID_ACTIVE)
+#define PC98_PTYP_386BSD (__DOSSID_386BSD << 8 | __DOSMID_386BSD)
struct pc98_partition {
- unsigned char dp_mid;
+ unsigned char dp_mid;
unsigned char dp_sid;
unsigned char dp_dum1;
unsigned char dp_dum2;
@@ -74,9 +72,4 @@ struct pc98_partition {
CTASSERT(sizeof (struct pc98_partition) == PC98_PARTSIZE);
#endif
-void pc98_partition_dec(void const *pp, struct pc98_partition *d);
-void pc98_partition_enc(void *pp, struct pc98_partition *d);
-
-#define DIOCSPC98 _IOW('M', 129, u_char[8192])
-
-#endif /* !_SYS_DISKPC98_H_ */
+#endif /* !_SYS_DISK_PC98_H_ */
Copied and modified: head/sys/sys/disk/vtoc.h (from r307385, head/sys/sys/vtoc.h)
==============================================================================
--- head/sys/sys/vtoc.h Sun Oct 16 02:05:22 2016 (r307385, copy source)
+++ head/sys/sys/disk/vtoc.h Sun Oct 16 02:43:51 2016 (r307386)
@@ -26,8 +26,8 @@
* $FreeBSD$
*/
-#ifndef _SYS_VTOC_H_
-#define _SYS_VTOC_H_
+#ifndef _SYS_DISK_VTOC_H_
+#define _SYS_DISK_VTOC_H_
#define VTOC_TAG_UNASSIGNED 0x00
#define VTOC_TAG_BOOT 0x01
@@ -74,7 +74,7 @@ struct vtoc8 {
struct {
uint16_t tag;
uint16_t flag;
- } part[VTOC8_NPARTS] __packed;
+ } part[VTOC8_NPARTS];
uint16_t __alignment;
uint32_t bootinfo[3];
uint32_t sanity;
@@ -99,10 +99,10 @@ struct vtoc8 {
} map[VTOC8_NPARTS];
uint16_t magic;
uint16_t cksum;
-} __packed;
+};
#ifdef CTASSERT
CTASSERT(sizeof(struct vtoc8) == 512);
#endif
-#endif /* _SYS_VTOC_H_ */
+#endif /* _SYS_DISK_VTOC_H_ */
Modified: head/sys/sys/disklabel.h
==============================================================================
--- head/sys/sys/disklabel.h Sun Oct 16 02:05:22 2016 (r307385)
+++ head/sys/sys/disklabel.h Sun Oct 16 02:43:51 2016 (r307386)
@@ -38,115 +38,38 @@
#endif
#include <sys/ioccom.h>
-/*
- * Disk description table, see disktab(5)
- */
+#include <sys/disk/bsd.h>
+
+/* Disk description table, see disktab(5) */
#define _PATH_DISKTAB "/etc/disktab"
/*
- * Each disk has a label which includes information about the hardware
- * disk geometry, filesystem partitions, and drive specific information.
* The label is in block 0 or 1, possibly offset from the beginning
* to leave room for a bootstrap, etc.
+ * XXX these should be defined per controller (or drive) elsewhere, not here!
+ * XXX in actuality it can't even be per controller or drive. It should be
+ * constant/fixed across storage hardware and CPU architectures. Disks can
+ * travel from one machine to another and a label created on one machine
+ * should be detectable and understood by the other.
*/
-
-/* XXX these should be defined per controller (or drive) elsewhere, not here! */
-#if defined(__i386__) || defined(__amd64__) || defined(__arm__) || \
- defined(__powerpc__) || defined(__mips__)
#define LABELSECTOR 1 /* sector containing label */
#define LABELOFFSET 0 /* offset of label in sector */
-#endif
-#define DISKMAGIC ((u_int32_t)0x82564557) /* The disk magic number */
+#define DISKMAGIC BSD_MAGIC /* The disk magic number */
+
#ifndef MAXPARTITIONS
-#define MAXPARTITIONS 8
+#define MAXPARTITIONS BSD_NPARTS_MIN
#endif
/* Size of bootblock area in sector-size neutral bytes */
-#define BBSIZE 8192
+#define BBSIZE BSD_BOOTBLOCK_SIZE
-#define LABEL_PART 2 /* partition containing label */
-#define RAW_PART 2 /* partition containing whole disk */
-#define SWAP_PART 1 /* partition normally containing swap */
-
-struct disklabel {
- u_int32_t d_magic; /* the magic number */
- u_int16_t d_type; /* drive type */
- u_int16_t d_subtype; /* controller/d_type specific */
- char d_typename[16]; /* type name, e.g. "eagle" */
-
- char d_packname[16]; /* pack identifier */
-
- /* disk geometry: */
- u_int32_t d_secsize; /* # of bytes per sector */
- u_int32_t d_nsectors; /* # of data sectors per track */
- u_int32_t d_ntracks; /* # of tracks per cylinder */
- u_int32_t d_ncylinders; /* # of data cylinders per unit */
- u_int32_t d_secpercyl; /* # of data sectors per cylinder */
- u_int32_t d_secperunit; /* # of data sectors per unit */
-
- /*
- * Spares (bad sector replacements) below are not counted in
- * d_nsectors or d_secpercyl. Spare sectors are assumed to
- * be physical sectors which occupy space at the end of each
- * track and/or cylinder.
- */
- u_int16_t d_sparespertrack; /* # of spare sectors per track */
- u_int16_t d_sparespercyl; /* # of spare sectors per cylinder */
- /*
- * Alternate cylinders include maintenance, replacement, configuration
- * description areas, etc.
- */
- u_int32_t d_acylinders; /* # of alt. cylinders per unit */
-
- /* hardware characteristics: */
- /*
- * d_interleave, d_trackskew and d_cylskew describe perturbations
- * in the media format used to compensate for a slow controller.
- * Interleave is physical sector interleave, set up by the
- * formatter or controller when formatting. When interleaving is
- * in use, logically adjacent sectors are not physically
- * contiguous, but instead are separated by some number of
- * sectors. It is specified as the ratio of physical sectors
- * traversed per logical sector. Thus an interleave of 1:1
- * implies contiguous layout, while 2:1 implies that logical
- * sector 0 is separated by one sector from logical sector 1.
- * d_trackskew is the offset of sector 0 on track N relative to
- * sector 0 on track N-1 on the same cylinder. Finally, d_cylskew
- * is the offset of sector 0 on cylinder N relative to sector 0
- * on cylinder N-1.
- */
- u_int16_t d_rpm; /* rotational speed */
- u_int16_t d_interleave; /* hardware sector interleave */
- u_int16_t d_trackskew; /* sector 0 skew, per track */
- 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 */
-#define NDDATA 5
- u_int32_t d_drivedata[NDDATA]; /* drive-type specific information */
-#define NSPARE 5
- u_int32_t d_spare[NSPARE]; /* reserved for future use */
- u_int32_t d_magic2; /* the magic number (again) */
- u_int16_t d_checksum; /* xor of data incl. partitions */
-
- /* filesystem and partition information: */
- 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 */
- 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 */
- u_int8_t p_fstype; /* filesystem type, see below */
- u_int8_t p_frag; /* filesystem fragments per block */
- u_int16_t p_cpg; /* filesystem cylinders per group */
- } d_partitions[MAXPARTITIONS]; /* actually may be more */
-};
+#define LABEL_PART BSD_PART_RAW
+#define RAW_PART BSD_PART_RAW
+#define SWAP_PART BSD_PART_SWAP
-#ifdef CTASSERT
-CTASSERT(sizeof(struct disklabel) == 148 + MAXPARTITIONS * 16);
-#endif
+#define NDDATA BSD_NDRIVEDATA
+#define NSPARE BSD_NSPARE
static __inline u_int16_t dkcksum(struct disklabel *lp);
static __inline u_int16_t
@@ -162,23 +85,6 @@ dkcksum(struct disklabel *lp)
return (sum);
}
-
-/* d_type values: */
-#define DTYPE_SMD 1 /* SMD, XSMD; VAX hp/up */
-#define DTYPE_MSCP 2 /* MSCP */
-#define DTYPE_DEC 3 /* other DEC (rk, rl) */
-#define DTYPE_SCSI 4 /* SCSI */
-#define DTYPE_ESDI 5 /* ESDI interface */
-#define DTYPE_ST506 6 /* ST506 etc. */
-#define DTYPE_HPIB 7 /* CS/80 on HP-IB */
-#define DTYPE_HPFL 8 /* HP Fiber-link */
-#define DTYPE_FLOPPY 10 /* floppy */
-#define DTYPE_CCD 11 /* concatenated disk */
-#define DTYPE_VINUM 12 /* vinum volume */
-#define DTYPE_DOC2K 13 /* Msys DiskOnChip */
-#define DTYPE_RAID 14 /* CMU RAIDFrame */
-#define DTYPE_JFS2 16 /* IBM JFS 2 */
-
#ifdef DKTYPENAMES
static const char *dktypenames[] = {
"unknown",
@@ -203,39 +109,6 @@ static const char *dktypenames[] = {
#define DKMAXTYPES (sizeof(dktypenames) / sizeof(dktypenames[0]) - 1)
#endif
-/*
- * Filesystem type and version.
- * Used to interpret other filesystem-specific
- * per-partition information.
- */
-#define FS_UNUSED 0 /* unused */
-#define FS_SWAP 1 /* swap */
-#define FS_V6 2 /* Sixth Edition */
-#define FS_V7 3 /* Seventh Edition */
-#define FS_SYSV 4 /* System V */
-#define FS_V71K 5 /* V7 with 1K blocks (4.1, 2.9) */
-#define FS_V8 6 /* Eighth Edition, 4K blocks */
-#define FS_BSDFFS 7 /* 4.2BSD fast filesystem */
-#define FS_MSDOS 8 /* MSDOS filesystem */
-#define FS_BSDLFS 9 /* 4.4BSD log-structured filesystem */
-#define FS_OTHER 10 /* in use, but unknown/unsupported */
-#define FS_HPFS 11 /* OS/2 high-performance filesystem */
-#define FS_ISO9660 12 /* ISO 9660, normally CD-ROM */
-#define FS_BOOT 13 /* partition contains bootstrap */
-#define FS_VINUM 14 /* Vinum drive */
-#define FS_RAID 15 /* RAIDFrame drive */
-#define FS_FILECORE 16 /* Acorn Filecore Filing System */
-#define FS_EXT2FS 17 /* ext2fs */
-#define FS_NTFS 18 /* Windows/NT file system */
-#define FS_CCD 20 /* concatenated disk component */
-#define FS_JFS2 21 /* IBM JFS2 */
-#define FS_HAMMER 22 /* DragonFlyBSD Hammer FS */
-#define FS_HAMMER2 23 /* DragonFlyBSD Hammer2 FS */
-#define FS_UDF 24 /* UDF */
-#define FS_EFS 26 /* SGI's Extent File system */
-#define FS_ZFS 27 /* Sun's ZFS */
-#define FS_NANDFS 30 /* FreeBSD nandfs (NiLFS derived) */
-
#ifdef FSTYPENAMES
static const char *fstypenames[] = {
"unused",
@@ -275,15 +148,6 @@ static const char *fstypenames[] = {
#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 */
-
-/*
* NB: <sys/disk.h> defines ioctls from 'd'/128 and up.
*/
Modified: head/sys/sys/diskmbr.h
==============================================================================
--- head/sys/sys/diskmbr.h Sun Oct 16 02:05:22 2016 (r307385)
+++ head/sys/sys/diskmbr.h Sun Oct 16 02:43:51 2016 (r307386)
@@ -33,59 +33,12 @@
#ifndef _SYS_DISKMBR_H_
#define _SYS_DISKMBR_H_
+#include <sys/disk/mbr.h>
#include <sys/ioccom.h>
-#define DOSBBSECTOR 0 /* DOS boot block relative sector number */
-#define DOSDSNOFF 440 /* WinNT/2K/XP Drive Serial Number offset */
-#define DOSPARTOFF 446
-#define DOSPARTSIZE 16
-#define NDOSPART 4
-#define NEXTDOSPART 32
-#define DOSMAGICOFFSET 510
-#define DOSMAGIC 0xAA55
-
-#define DOSPTYP_EXT 0x05 /* DOS extended partition */
-#define DOSPTYP_FAT16 0x06 /* FAT16 partition */
-#define DOSPTYP_NTFS 0x07 /* NTFS partition */
-#define DOSPTYP_FAT32 0x0b /* FAT32 partition */
-#define DOSPTYP_EXTLBA 0x0f /* DOS extended partition */
-#define DOSPTYP_PPCBOOT 0x41 /* PReP/CHRP boot partition */
-#define DOSPTYP_LDM 0x42 /* Win2k dynamic extended partition */
-#define DOSPTYP_LINSWP 0x82 /* Linux swap partition */
-#define DOSPTYP_LINUX 0x83 /* Linux partition */
-#define DOSPTYP_LINLVM 0x8e /* Linux LVM partition */
-#define DOSPTYP_386BSD 0xa5 /* 386BSD partition type */
-#define DOSPTYP_APPLE_UFS 0xa8 /* Apple Mac OS X boot */
-#define DOSPTYP_APPLE_BOOT 0xab /* Apple Mac OS X UFS */
-#define DOSPTYP_HFS 0xaf /* HFS/HFS+ partition type */
-#define DOSPTYP_PMBR 0xee /* GPT Protective MBR */
-#define DOSPTYP_EFI 0xef /* EFI FAT parition */
-#define DOSPTYP_VMFS 0xfb /* VMware VMFS partition */
-#define DOSPTYP_VMKDIAG 0xfc /* VMware vmkDiagnostic partition */
-#define DOSPTYP_LINRAID 0xfd /* Linux raid partition */
-
-struct dos_partition {
- unsigned char dp_flag; /* bootstrap flags */
- unsigned char dp_shd; /* starting head */
- unsigned char dp_ssect; /* starting sector */
- unsigned char dp_scyl; /* starting cylinder */
- unsigned char dp_typ; /* partition type */
- unsigned char dp_ehd; /* end head */
- unsigned char dp_esect; /* end sector */
- unsigned char dp_ecyl; /* end cylinder */
- u_int32_t dp_start; /* absolute starting sector number */
- u_int32_t dp_size; /* partition size in sectors */
-};
-#ifdef CTASSERT
-CTASSERT(sizeof (struct dos_partition) == DOSPARTSIZE);
-#endif
-
void dos_partition_dec(void const *pp, struct dos_partition *d);
void dos_partition_enc(void *pp, struct dos_partition *d);
-#define DPSECT(s) ((s) & 0x3f) /* isolate relevant bits of sector */
-#define DPCYL(c, s) ((c) + (((s) & 0xc0)<<2)) /* and those that are cylinder */
-
#define DIOCSMBR _IOW('M', 129, u_char[512])
#endif /* !_SYS_DISKMBR_H_ */
Modified: head/sys/sys/diskpc98.h
==============================================================================
--- head/sys/sys/diskpc98.h Sun Oct 16 02:05:22 2016 (r307385)
+++ head/sys/sys/diskpc98.h Sun Oct 16 02:43:51 2016 (r307386)
@@ -33,46 +33,11 @@
#ifndef _SYS_DISKPC98_H_
#define _SYS_DISKPC98_H_
+#include <sys/disk/pc98.h>
#include <sys/ioccom.h>
-#define PC98_BBSECTOR 1 /* DOS boot block relative sector number */
-#define PC98_PARTOFF 0
-#define PC98_PARTSIZE 32
-#define PC98_NPARTS 16
-#define PC98_MAGICOFS 510
-#define PC98_MAGIC 0xAA55
-
-#define PC98_MID_BOOTABLE 0x80
-#define PC98_MID_MASK 0x7f
-#define PC98_MID_386BSD 0x14
-
-#define PC98_SID_ACTIVE 0x80
-#define PC98_SID_MASK 0x7f
-#define PC98_SID_386BSD 0x44
-
-#define DOSMID_386BSD (PC98_MID_386BSD | PC98_MID_BOOTABLE)
-#define DOSSID_386BSD (PC98_SID_386BSD | PC98_SID_ACTIVE)
-#define PC98_PTYP_386BSD (DOSSID_386BSD << 8 | DOSMID_386BSD)
-
-struct pc98_partition {
- unsigned char dp_mid;
- unsigned char dp_sid;
- unsigned char dp_dum1;
- unsigned char dp_dum2;
- unsigned char dp_ipl_sct;
- unsigned char dp_ipl_head;
- unsigned short dp_ipl_cyl;
- unsigned char dp_ssect; /* starting sector */
- unsigned char dp_shd; /* starting head */
- unsigned short dp_scyl; /* starting cylinder */
- unsigned char dp_esect; /* end sector */
- unsigned char dp_ehd; /* end head */
- unsigned short dp_ecyl; /* end cylinder */
- unsigned char dp_name[16];
-};
-#ifdef CTASSERT
-CTASSERT(sizeof (struct pc98_partition) == PC98_PARTSIZE);
-#endif
+#define DOSMID_386BSD __DOSMID_386BSD
+#define DOSSID_386BSD __DOSSID_386BSD
void pc98_partition_dec(void const *pp, struct pc98_partition *d);
void pc98_partition_enc(void *pp, struct pc98_partition *d);
Modified: head/sys/sys/gpt.h
==============================================================================
--- head/sys/sys/gpt.h Sun Oct 16 02:05:22 2016 (r307385)
+++ head/sys/sys/gpt.h Sun Oct 16 02:43:51 2016 (r307386)
@@ -31,180 +31,7 @@
#include <sys/uuid.h>
-struct gpt_hdr {
- char hdr_sig[8];
-#define GPT_HDR_SIG "EFI PART"
- uint32_t hdr_revision;
-#define GPT_HDR_REVISION 0x00010000
- uint32_t hdr_size;
- uint32_t hdr_crc_self;
- uint32_t __reserved;
- uint64_t hdr_lba_self;
- uint64_t hdr_lba_alt;
- uint64_t hdr_lba_start;
- uint64_t hdr_lba_end;
- struct uuid hdr_uuid;
- uint64_t hdr_lba_table;
- uint32_t hdr_entries;
- uint32_t hdr_entsz;
- uint32_t hdr_crc_table;
- /*
- * The header as defined in the EFI spec is not a multiple of 8 bytes
- * and given that the alignment requirement is on an 8 byte boundary,
- * padding will happen. We make the padding explicit so that we can
- * correct the value returned by sizeof() when we put the size of the
- * header in field hdr_size, or otherwise use offsetof().
- */
- uint32_t padding;
-};
-
-struct gpt_ent {
- struct uuid ent_type;
- struct uuid ent_uuid;
- uint64_t ent_lba_start;
- uint64_t ent_lba_end;
- uint64_t ent_attr;
-#define GPT_ENT_ATTR_PLATFORM (1ULL << 0)
-#define GPT_ENT_ATTR_BOOTME (1ULL << 59)
-#define GPT_ENT_ATTR_BOOTONCE (1ULL << 58)
-#define GPT_ENT_ATTR_BOOTFAILED (1ULL << 57)
- uint16_t ent_name[36]; /* UTF-16. */
-};
-
-#define GPT_ENT_TYPE_UNUSED \
- {0x00000000,0x0000,0x0000,0x00,0x00,{0x00,0x00,0x00,0x00,0x00,0x00}}
-#define GPT_ENT_TYPE_EFI \
- {0xc12a7328,0xf81f,0x11d2,0xba,0x4b,{0x00,0xa0,0xc9,0x3e,0xc9,0x3b}}
-#define GPT_ENT_TYPE_MBR \
- {0x024dee41,0x33e7,0x11d3,0x9d,0x69,{0x00,0x08,0xc7,0x81,0xf3,0x9f}}
-#define GPT_ENT_TYPE_FREEBSD \
- {0x516e7cb4,0x6ecf,0x11d6,0x8f,0xf8,{0x00,0x02,0x2d,0x09,0x71,0x2b}}
-#define GPT_ENT_TYPE_FREEBSD_BOOT \
- {0x83bd6b9d,0x7f41,0x11dc,0xbe,0x0b,{0x00,0x15,0x60,0xb8,0x4f,0x0f}}
-#define GPT_ENT_TYPE_FREEBSD_NANDFS \
- {0x74ba7dd9,0xa689,0x11e1,0xbd,0x04,{0x00,0xe0,0x81,0x28,0x6a,0xcf}}
-#define GPT_ENT_TYPE_FREEBSD_SWAP \
- {0x516e7cb5,0x6ecf,0x11d6,0x8f,0xf8,{0x00,0x02,0x2d,0x09,0x71,0x2b}}
-#define GPT_ENT_TYPE_FREEBSD_UFS \
- {0x516e7cb6,0x6ecf,0x11d6,0x8f,0xf8,{0x00,0x02,0x2d,0x09,0x71,0x2b}}
-#define GPT_ENT_TYPE_FREEBSD_VINUM \
- {0x516e7cb8,0x6ecf,0x11d6,0x8f,0xf8,{0x00,0x02,0x2d,0x09,0x71,0x2b}}
-#define GPT_ENT_TYPE_FREEBSD_ZFS \
- {0x516e7cba,0x6ecf,0x11d6,0x8f,0xf8,{0x00,0x02,0x2d,0x09,0x71,0x2b}}
-#define GPT_ENT_TYPE_PREP_BOOT \
- {0x9e1a2d38,0xc612,0x4316,0xaa,0x26,{0x8b,0x49,0x52,0x1e,0x5a,0x8b}}
-
-/*
- * The following are unused but documented here to avoid reuse.
- *
- * GPT_ENT_TYPE_FREEBSD_UFS2 \
- * {0x516e7cb7,0x6ecf,0x11d6,0x8f,0xf8,{0x00,0x02,0x2d,0x09,0x71,0x2b}}
- */
-
-/*
*** DIFF OUTPUT TRUNCATED AT 1000 LINES ***
More information about the svn-src-all
mailing list