svn commit: r306811 - in head: etc/mtree include sys/sys sys/sys/disk

Marcel Moolenaar marcel at FreeBSD.org
Fri Oct 7 15:42:23 UTC 2016


Author: marcel
Date: Fri Oct  7 15:42:20 2016
New Revision: 306811
URL: https://svnweb.freebsd.org/changeset/base/306811

Log:
  In order to allow mkimg(1) (and other tools) to become a build tool
  that can be compiled on various OSes (including on older versions
  of FreeBSD), make it possible to have it include the partitioning
  scheme definitions without pulling in FreeBSD specifics.
  In particular this means:
   o  move the scheme definitions iand related defines to header files
      under sys/disk,
   o  make them (more) portable by using uint#_t (where applicable)
      and renaming defines so that they at least have a good prefix,
   o  make the new headers stand-alone so that they don't need FreeBSD
      definitions, like struct uuid(*)
   o  keep the original headers for compatibility, but rewrite them to
      get the scheme definitions from <sys/disk/$scheme.h>.
  
  (*) since UUID/GUID type definitions are non-portable and the GPT
  scheme uses them, make it possible to have the scheme definitions
  use an external type by allowing consumers of the header to set
  GPT_UUID_TYPE. When GPT_UUID_TYPE has not been defined, the header
  will use it's own type definition, which is the same as struct uuid.
  The gpt_uuid_t typedef is created to abstract the details and allows
  consumers to refer to a single type.
  
  There is not conflict between the partitioning scheme headers and
  what is defined in them. All headers can be included in the same
  source files.
  
  Note: consumers of the old headers have not been changed yet. Such
  will be done if and when needed/beneficial.
  
  Reviewed by:	imp, jhb
  MFC after:	1 month
  Sponsored by:	Bracket Computing

Added:
  head/sys/sys/disk/
  head/sys/sys/disk/apm.h
     - copied, changed from r306810, head/sys/sys/apm.h
  head/sys/sys/disk/bsd.h
     - copied, changed from r306810, head/sys/sys/disklabel.h
  head/sys/sys/disk/gpt.h
     - copied, changed from r306810, head/sys/sys/gpt.h
  head/sys/sys/disk/mbr.h
     - copied, changed from r306810, head/sys/sys/diskmbr.h
  head/sys/sys/disk/pc98.h
     - copied, changed from r306810, head/sys/sys/diskpc98.h
  head/sys/sys/disk/vtoc.h
     - copied, changed from r306810, head/sys/sys/vtoc.h
Replaced:
  head/sys/sys/apm.h   (contents, props changed)
  head/sys/sys/disklabel.h   (contents, props changed)
  head/sys/sys/diskmbr.h   (contents, props changed)
  head/sys/sys/diskpc98.h   (contents, props changed)
  head/sys/sys/gpt.h   (contents, props changed)
  head/sys/sys/vtoc.h   (contents, props changed)
Modified:
  head/etc/mtree/BSD.include.dist
  head/include/Makefile

Modified: head/etc/mtree/BSD.include.dist
==============================================================================
--- head/etc/mtree/BSD.include.dist	Fri Oct  7 14:54:16 2016	(r306810)
+++ head/etc/mtree/BSD.include.dist	Fri Oct  7 15:42:20 2016	(r306811)
@@ -336,6 +336,8 @@
     ssp
     ..
     sys
+        disk
+        ..
     ..
     teken
     ..

Modified: head/include/Makefile
==============================================================================
--- head/include/Makefile	Fri Oct  7 14:54:16 2016	(r306810)
+++ head/include/Makefile	Fri Oct  7 15:42:20 2016	(r306811)
@@ -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

Added: head/sys/sys/apm.h
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/sys/sys/apm.h	Fri Oct  7 15:42:20 2016	(r306811)
@@ -0,0 +1,5 @@
+/*-
+ * This file is in the public domain.
+ */
+/* $FreeBSD$ */
+#include <sys/disk/apm.h>

Copied and modified: head/sys/sys/disk/apm.h (from r306810, head/sys/sys/apm.h)
==============================================================================
--- head/sys/sys/apm.h	Fri Oct  7 14:54:16 2016	(r306810, copy source)
+++ head/sys/sys/disk/apm.h	Fri Oct  7 15:42:20 2016	(r306811)
@@ -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 r306810, head/sys/sys/disklabel.h)
==============================================================================
--- head/sys/sys/disklabel.h	Fri Oct  7 14:54:16 2016	(r306810, copy source)
+++ head/sys/sys/disk/bsd.h	Fri Oct  7 15:42:20 2016	(r306811)
@@ -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 r306810, head/sys/sys/gpt.h)
==============================================================================
--- head/sys/sys/gpt.h	Fri Oct  7 14:54:16 2016	(r306810, copy source)
+++ head/sys/sys/disk/gpt.h	Fri Oct  7 15:42:20 2016	(r306811)
@@ -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 r306810, head/sys/sys/diskmbr.h)
==============================================================================
--- head/sys/sys/diskmbr.h	Fri Oct  7 14:54:16 2016	(r306810, copy source)
+++ head/sys/sys/disk/mbr.h	Fri Oct  7 15:42:20 2016	(r306811)
@@ -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 r306810, head/sys/sys/diskpc98.h)
==============================================================================
--- head/sys/sys/diskpc98.h	Fri Oct  7 14:54:16 2016	(r306810, copy source)
+++ head/sys/sys/disk/pc98.h	Fri Oct  7 15:42:20 2016	(r306811)
@@ -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 r306810, head/sys/sys/vtoc.h)
==============================================================================
--- head/sys/sys/vtoc.h	Fri Oct  7 14:54:16 2016	(r306810, copy source)
+++ head/sys/sys/disk/vtoc.h	Fri Oct  7 15:42:20 2016	(r306811)
@@ -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_ */

Added: head/sys/sys/disklabel.h
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/sys/sys/disklabel.h	Fri Oct  7 15:42:20 2016	(r306811)
@@ -0,0 +1,169 @@
+/*-
+ * Copyright (c) 1987, 1988, 1993
+ *	The Regents of the University of California.  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.
+ * 4. Neither the name of the University 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 REGENTS 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 REGENTS 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.
+ *
+ *	@(#)disklabel.h	8.2 (Berkeley) 7/10/94
+ * $FreeBSD$
+ */
+
+#ifndef _SYS_DISKLABEL_H_
+#define	_SYS_DISKLABEL_H_
+
+#ifndef _KERNEL
+#include <sys/types.h>
+#endif
+#include <sys/ioccom.h>
+
+#include <sys/disk/bsd.h>
+
+/* Disk description table, see disktab(5) */
+#define	_PATH_DISKTAB	"/etc/disktab"
+
+/*
+ * 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.
+ */
+#define LABELSECTOR	1			/* sector containing label */
+#define LABELOFFSET	0			/* offset of label in sector */
+
+#define DISKMAGIC	BSD_MAGIC		/* The disk magic number */
+
+#ifndef MAXPARTITIONS
+#define	MAXPARTITIONS	BSD_NPARTS_MIN
+#endif
+
+/* Size of bootblock area in sector-size neutral bytes */
+#define BBSIZE		BSD_BOOTBLOCK_SIZE
+
+#define	LABEL_PART	BSD_PART_RAW
+#define	RAW_PART	BSD_PART_RAW
+#define	SWAP_PART	BSD_PART_SWAP
+
+#define NDDATA		BSD_NDRIVEDATA
+#define NSPARE		BSD_NSPARE
+
+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);
+}
+
+#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
+
+#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
+
+/*
+ * 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_ */

Added: head/sys/sys/diskmbr.h
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/sys/sys/diskmbr.h	Fri Oct  7 15:42:20 2016	(r306811)
@@ -0,0 +1,44 @@
+/*-
+ * Copyright (c) 1987, 1988, 1993
+ *	The Regents of the University of California.  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.
+ * 4. Neither the name of the University 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 REGENTS 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 REGENTS 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.
+ *
+ *	@(#)disklabel.h	8.2 (Berkeley) 7/10/94
+ * $FreeBSD$
+ */
+
+#ifndef _SYS_DISKMBR_H_
+#define	_SYS_DISKMBR_H_
+
+#include <sys/disk/mbr.h>
+#include <sys/ioccom.h>
+
+void dos_partition_dec(void const *pp, struct dos_partition *d);
+void dos_partition_enc(void *pp, struct dos_partition *d);
+
+#define DIOCSMBR 	_IOW('M', 129, u_char[512])
+
+#endif /* !_SYS_DISKMBR_H_ */

Added: head/sys/sys/diskpc98.h
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/sys/sys/diskpc98.h	Fri Oct  7 15:42:20 2016	(r306811)
@@ -0,0 +1,47 @@
+/*-
+ * Copyright (c) 1987, 1988, 1993
+ *	The Regents of the University of California.  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.
+ * 4. Neither the name of the University 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 REGENTS 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 REGENTS 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.
+ *
+ *	@(#)disklabel.h	8.2 (Berkeley) 7/10/94
+ * $FreeBSD$
+ */
+
+#ifndef _SYS_DISKPC98_H_
+#define	_SYS_DISKPC98_H_
+
+#include <sys/disk/pc98.h>
+#include <sys/ioccom.h>
+
+#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);
+
+#define DIOCSPC98	_IOW('M', 129, u_char[8192])
+
+#endif /* !_SYS_DISKPC98_H_ */

Added: head/sys/sys/gpt.h
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/sys/sys/gpt.h	Fri Oct  7 15:42:20 2016	(r306811)
@@ -0,0 +1,37 @@
+/*-
+ * Copyright (c) 2002 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$
+ */
+
+#ifndef _SYS_GPT_H_
+#define	_SYS_GPT_H_
+
+#include <sys/uuid.h>
+
+#define	GPT_UUID_TYPE	struct uuid
+#include <sys/disk/gpt.h>
+
+#endif /* _SYS_GPT_H_ */

Added: head/sys/sys/vtoc.h
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/sys/sys/vtoc.h	Fri Oct  7 15:42:20 2016	(r306811)
@@ -0,0 +1,5 @@
+/*-
+ * This file is in the public domain.
+ */
+/* $FreeBSD$ */
+#include <sys/disk/vtoc.h>


More information about the svn-src-head mailing list