netbsd fsck driver import
. fsck driver parses /etc/fstab and invokes sub-fscks . further simplifies fs handling in rc
This commit is contained in:
@@ -4,5 +4,6 @@
|
||||
INCS+= archtypes.h bios.h cmos.h cpu.h diskparm.h fpu.h int86.h \
|
||||
interrupt.h memory.h multiboot.h partition.h \
|
||||
pci.h pci_amd.h pci_intel.h pci_sis.h pci_via.h \
|
||||
ports.h stackframe.h vm.h elf.h elf_machdep.h
|
||||
ports.h stackframe.h vm.h elf.h elf_machdep.h mutex.h \
|
||||
disklabel.h
|
||||
|
||||
|
||||
75
common/include/arch/i386/disklabel.h
Normal file
75
common/include/arch/i386/disklabel.h
Normal file
@@ -0,0 +1,75 @@
|
||||
/* $NetBSD: disklabel.h,v 1.16 2011/08/30 12:39:55 bouyer Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1994 Christopher G. Demetriou
|
||||
* 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.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by Christopher G. Demetriou.
|
||||
* 4. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#ifndef _I386_DISKLABEL_H_
|
||||
#define _I386_DISKLABEL_H_
|
||||
|
||||
#define LABELUSESMBR 1 /* use MBR partitionning */
|
||||
#define LABELSECTOR 1 /* sector containing label */
|
||||
#define LABELOFFSET 0 /* offset of label in sector */
|
||||
#define MAXPARTITIONS 16 /* number of partitions */
|
||||
#define OLDMAXPARTITIONS 8 /* number of partitions before 1.6 */
|
||||
#define RAW_PART 3 /* raw partition: XX?d (XXX) */
|
||||
|
||||
/*
|
||||
* We use the highest bit of the minor number for the partition number.
|
||||
* This maintains backward compatibility with device nodes created before
|
||||
* MAXPARTITIONS was increased.
|
||||
*/
|
||||
#define __I386_MAXDISKS ((1 << 20) / MAXPARTITIONS)
|
||||
#define DISKUNIT(dev) ((minor(dev) / OLDMAXPARTITIONS) % __I386_MAXDISKS)
|
||||
#define DISKPART(dev) ((minor(dev) % OLDMAXPARTITIONS) + \
|
||||
((minor(dev) / (__I386_MAXDISKS * OLDMAXPARTITIONS)) * OLDMAXPARTITIONS))
|
||||
#define DISKMINOR(unit, part) \
|
||||
(((unit) * OLDMAXPARTITIONS) + ((part) % OLDMAXPARTITIONS) + \
|
||||
((part) / OLDMAXPARTITIONS) * (__I386_MAXDISKS * OLDMAXPARTITIONS))
|
||||
|
||||
/* Pull in MBR partition definitions. */
|
||||
#if HAVE_NBTOOL_CONFIG_H
|
||||
#include <nbinclude/sys/bootblock.h>
|
||||
#else
|
||||
#include <sys/bootblock.h>
|
||||
#endif /* HAVE_NBTOOL_CONFIG_H */
|
||||
|
||||
#ifndef __ASSEMBLER__
|
||||
#if HAVE_NBTOOL_CONFIG_H
|
||||
#include <nbinclude/sys/dkbad.h>
|
||||
#else
|
||||
#include <sys/dkbad.h>
|
||||
#endif /* HAVE_NBTOOL_CONFIG_H */
|
||||
struct cpu_disklabel {
|
||||
#define __HAVE_DISKLABEL_DKBAD
|
||||
struct dkbad bad;
|
||||
};
|
||||
#endif
|
||||
|
||||
#endif /* _I386_DISKLABEL_H_ */
|
||||
3
common/include/arch/i386/mutex.h
Normal file
3
common/include/arch/i386/mutex.h
Normal file
@@ -0,0 +1,3 @@
|
||||
/* $NetBSD: mutex.h,v 1.2 2007/02/09 21:55:05 ad Exp $ */
|
||||
|
||||
#include <x86/mutex.h>
|
||||
@@ -5,5 +5,7 @@
|
||||
INCS+= elf32.h elf64.h elf_common.h elf_generic.h \
|
||||
ioc_block.h ioc_fbd.h ioc_file.h ioc_tape.h ioc_disk.h \
|
||||
ioc_memory.h ioc_sound.h ioc_tty.h \
|
||||
kbdio.h mtio.h svrctl.h video.h vm.h procfs.h elf_core.h exec_elf.h
|
||||
kbdio.h mtio.h svrctl.h video.h vm.h procfs.h elf_core.h exec_elf.h \
|
||||
disk.h dkio.h ioccom.h mutex.h iostat.h disklabel.h bootblock.h \
|
||||
dkbad.h
|
||||
|
||||
|
||||
1442
common/include/sys/bootblock.h
Normal file
1442
common/include/sys/bootblock.h
Normal file
File diff suppressed because it is too large
Load Diff
538
common/include/sys/disk.h
Normal file
538
common/include/sys/disk.h
Normal file
@@ -0,0 +1,538 @@
|
||||
/* $NetBSD: disk.h,v 1.55 2011/11/13 22:07:00 christos Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1996, 1997, 2004 The NetBSD Foundation, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to The NetBSD Foundation
|
||||
* by Jason R. Thorpe of the Numerical Aerospace Simulation Facility,
|
||||
* NASA Ames Research Center.
|
||||
*
|
||||
* 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 NETBSD FOUNDATION, INC. 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 FOUNDATION 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 1992, 1993
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
*
|
||||
* This software was developed by the Computer Systems Engineering group
|
||||
* at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and
|
||||
* contributed to Berkeley.
|
||||
*
|
||||
* All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by the University of
|
||||
* California, Lawrence Berkeley Laboratories.
|
||||
*
|
||||
* 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 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.
|
||||
*
|
||||
* from: Header: disk.h,v 1.5 92/11/19 04:33:03 torek Exp (LBL)
|
||||
*
|
||||
* @(#)disk.h 8.2 (Berkeley) 1/9/95
|
||||
*/
|
||||
|
||||
#ifndef _SYS_DISK_H_
|
||||
#define _SYS_DISK_H_
|
||||
|
||||
/*
|
||||
* Disk device structures.
|
||||
*/
|
||||
|
||||
#ifdef _KERNEL
|
||||
#include <sys/device.h>
|
||||
#endif
|
||||
#include <sys/dkio.h>
|
||||
#include <sys/time.h>
|
||||
#include <sys/queue.h>
|
||||
#include <sys/mutex.h>
|
||||
#include <sys/iostat.h>
|
||||
|
||||
#include <prop/proplib.h>
|
||||
|
||||
struct buf;
|
||||
struct disk;
|
||||
struct disklabel;
|
||||
struct cpu_disklabel;
|
||||
struct lwp;
|
||||
struct vnode;
|
||||
|
||||
/*
|
||||
* Disk information dictionary.
|
||||
*
|
||||
* This contains general infomation for disk devices.
|
||||
*
|
||||
* <dict>
|
||||
* <key>type</key>
|
||||
* <string>...</string>
|
||||
* <key>geometry</key>
|
||||
* <dict>
|
||||
* <!-- See below for disk geometry dictionary
|
||||
* contents. -->
|
||||
* </dict>
|
||||
*
|
||||
* <!-- optional information -->
|
||||
* <key>rpm</key>
|
||||
* <integer>...</integer>
|
||||
* <key>sector-interleave</key>
|
||||
* <integer>...</integer>
|
||||
* <key>track-skew</key>
|
||||
* <integer>...</integer>
|
||||
* <key>cylinder-skew</key>
|
||||
* <integer>...</integer>
|
||||
* <key>head-switch-usecs</key>
|
||||
* <integer>...</integer>
|
||||
* <key>track-seek-usecs</key>
|
||||
* <integer>...</integer>
|
||||
* <key>removable</key>
|
||||
* <false/>
|
||||
* <key>ecc</key>
|
||||
* <false/>
|
||||
* <key>bad-sector-forwarding</key>
|
||||
* <true/>
|
||||
* <key>ramdisk</key>
|
||||
* <false/>
|
||||
* <key>back-to-back-transfers</key>
|
||||
* <true/>
|
||||
*
|
||||
* <!-- additional information for SMD drives -->
|
||||
* <key>smd-skip-sectoring</key>
|
||||
* <false/>
|
||||
* <!-- XXX better names for these properties -->
|
||||
* <key>smd-mindist</key>
|
||||
* <integer>...</integer>
|
||||
* <key>smd-maxdist</key>
|
||||
* <integer>...</integer>
|
||||
* <key>smd-sdist</key>
|
||||
* <integer>...</integer>
|
||||
*
|
||||
* <!-- additional information for ST506 drives -->
|
||||
* <!-- XXX better names for these properties -->
|
||||
* <key>st506-precompcyl</key>
|
||||
* <integer>...</integer>
|
||||
* <key>st506-gap3</key>
|
||||
* <integer>...</integer>
|
||||
*
|
||||
* <!-- additional information for ATA drives -->
|
||||
* <!-- XXX -->
|
||||
*
|
||||
* <!-- additional information for SCSI drives -->
|
||||
* <!-- XXX -->
|
||||
* </dict>
|
||||
*/
|
||||
|
||||
/*
|
||||
* dkwedge_info:
|
||||
*
|
||||
* Information needed to configure (or query configuration of) a
|
||||
* disk wedge.
|
||||
*/
|
||||
struct dkwedge_info {
|
||||
char dkw_devname[16];/* device-style name (e.g. "dk0") */
|
||||
uint8_t dkw_wname[128]; /* wedge name (Unicode, UTF-8) */
|
||||
char dkw_parent[16]; /* parent disk device name */
|
||||
daddr_t dkw_offset; /* LBA offset of wedge in parent */
|
||||
uint64_t dkw_size; /* size of wedge in blocks */
|
||||
char dkw_ptype[32]; /* partition type string */
|
||||
};
|
||||
|
||||
/*
|
||||
* dkwedge_list:
|
||||
*
|
||||
* Structure used to query a list of wedges.
|
||||
*/
|
||||
struct dkwedge_list {
|
||||
void *dkwl_buf; /* storage for dkwedge_info array */
|
||||
size_t dkwl_bufsize; /* size of that buffer */
|
||||
u_int dkwl_nwedges; /* total number of wedges */
|
||||
u_int dkwl_ncopied; /* number actually copied */
|
||||
};
|
||||
|
||||
#ifdef _KERNEL
|
||||
/*
|
||||
* dkwedge_discovery_method:
|
||||
*
|
||||
* Structure used to describe partition map parsing schemes
|
||||
* used for wedge autodiscovery.
|
||||
*/
|
||||
struct dkwedge_discovery_method {
|
||||
/* link in wedge driver's list */
|
||||
LIST_ENTRY(dkwedge_discovery_method) ddm_list;
|
||||
const char *ddm_name; /* name of this method */
|
||||
int ddm_priority; /* search priority */
|
||||
int (*ddm_discover)(struct disk *, struct vnode *);
|
||||
};
|
||||
|
||||
#define DKWEDGE_DISCOVERY_METHOD_DECL(name, prio, discover) \
|
||||
static struct dkwedge_discovery_method name ## _ddm = { \
|
||||
{ NULL, NULL }, \
|
||||
#name, \
|
||||
prio, \
|
||||
discover \
|
||||
}; \
|
||||
__link_set_add_data(dkwedge_methods, name ## _ddm)
|
||||
#endif /* _KERNEL */
|
||||
|
||||
/* Some common partition types */
|
||||
#define DKW_PTYPE_UNKNOWN ""
|
||||
#define DKW_PTYPE_UNUSED "unused"
|
||||
#define DKW_PTYPE_SWAP "swap"
|
||||
#define DKW_PTYPE_V6 "v6"
|
||||
#define DKW_PTYPE_V7 "v7"
|
||||
#define DKW_PTYPE_SYSV "sysv"
|
||||
#define DKW_PTYPE_V71K "v71k"
|
||||
#define DKW_PTYPE_V8 "v8"
|
||||
#define DKW_PTYPE_FFS "ffs"
|
||||
#define DKW_PTYPE_FAT "msdos"
|
||||
#define DKW_PTYPE_LFS "lfs"
|
||||
#define DKW_PTYPE_OTHER "other"
|
||||
#define DKW_PTYPE_HPFS "hpfs"
|
||||
#define DKW_PTYPE_ISO9660 "cd9660"
|
||||
#define DKW_PTYPE_BOOT "boot"
|
||||
#define DKW_PTYPE_AMIGADOS "ados"
|
||||
#define DKW_PTYPE_HFS "hfs"
|
||||
#define DKW_PTYPE_FILECORE "filecore"
|
||||
#define DKW_PTYPE_EXT2FS "ext2fs"
|
||||
#define DKW_PTYPE_NTFS "ntfs"
|
||||
#define DKW_PTYPE_RAIDFRAME "raidframe"
|
||||
#define DKW_PTYPE_CCD "ccd"
|
||||
#define DKW_PTYPE_JFS2 "jfs2"
|
||||
#define DKW_PTYPE_APPLEUFS "appleufs"
|
||||
#define DKW_PTYPE_VINUM "vinum"
|
||||
#define DKW_PTYPE_UDF "udf"
|
||||
#define DKW_PTYPE_APPLEHFS "hfs"
|
||||
#define DKW_PTYPE_SYSVBFS "sysvbfs"
|
||||
#define DKW_PTYPE_EFS "efs"
|
||||
#define DKW_PTYPE_NILFS "nilfs"
|
||||
#define DKW_PTYPE_CGD "cgd"
|
||||
|
||||
/*
|
||||
* Disk geometry dictionary.
|
||||
*
|
||||
* NOTE: Not all geometry information is relevant for every kind of disk.
|
||||
*
|
||||
* <dict>
|
||||
* <key>sectors-per-unit</key>
|
||||
* <integer>...</integer>
|
||||
* <key>sector-size</key>
|
||||
* <integer>...</integer>
|
||||
* <key>sectors-per-track</key>
|
||||
* <integer>...</integer>
|
||||
* <key>tracks-per-cylinder</key>
|
||||
* <integer>...</integer>
|
||||
* <key>cylinders-per-unit</key>
|
||||
* <integer>...</integer>
|
||||
* <key>physical-cylinders-per-unit</key>
|
||||
* <integer>...</integer>
|
||||
* <key>spare-sectors-per-track</key>
|
||||
* <integer>...</integer>
|
||||
* <key>spare-sectors-per-cylinder</key>
|
||||
* <integer>...</integer>
|
||||
* <key>alternative-cylinders</key>
|
||||
* <integer>...</integer>
|
||||
* </dict>
|
||||
* NOTE: Not all geometry information is relevant for every kind of disk.
|
||||
*/
|
||||
|
||||
struct disk_geom {
|
||||
int64_t dg_secperunit; /* # of data sectors per unit */
|
||||
uint32_t dg_secsize; /* # of bytes per sector */
|
||||
uint32_t dg_nsectors; /* # of data sectors per track */
|
||||
uint32_t dg_ntracks; /* # of tracks per cylinder */
|
||||
uint32_t dg_ncylinders; /* # of data cylinders per unit */
|
||||
uint32_t dg_secpercyl; /* # of data sectors per cylinder */
|
||||
uint32_t dg_pcylinders; /* # of physical cylinders per unit */
|
||||
|
||||
/*
|
||||
* Spares (bad sector replacements) below are not counted in
|
||||
* dg_nsectors or dg_secpercyl. Spare sectors are assumed to
|
||||
* be physical sectors which occupy space at the end of each
|
||||
* track and/or cylinder.
|
||||
*/
|
||||
uint32_t dg_sparespertrack;
|
||||
uint32_t dg_sparespercyl;
|
||||
/*
|
||||
* Alternative cylinders include maintenance, replacement,
|
||||
* configuration description areas, etc.
|
||||
*/
|
||||
uint32_t dg_acylinders;
|
||||
};
|
||||
|
||||
/*
|
||||
* Disk partition dictionary.
|
||||
*
|
||||
* A partition is represented as a dictionary containing generic partition
|
||||
* properties (such as starting block and block count), as well as information
|
||||
* that is specific to individual partition map formats.
|
||||
*
|
||||
* <dict>
|
||||
* <key>start-block</key>
|
||||
* <integer>...</integer>
|
||||
* <key>block-count</key>
|
||||
* <integer>...</integer>
|
||||
* <!-- DKW_PTYPE strings ("" or missing if unknown) -->
|
||||
* <key>type</type>
|
||||
* <string>...</string>
|
||||
* <!-- optional -->
|
||||
* <key>name</key>
|
||||
* <string>...</string>
|
||||
*
|
||||
* <!-- these are valid for GPT partition maps -->
|
||||
* <key>gpt-type-guid</key>
|
||||
* <string>...</string>
|
||||
* <key>gpt-partition-guid</key>
|
||||
* <string>...</string>
|
||||
* <key>gpt-platform-required</key>
|
||||
* <false/>
|
||||
*
|
||||
* <!-- these are valid for 4.4BSD partition maps -->
|
||||
* <key>bsd44-partition-type</key>
|
||||
* <integer>...</integer>
|
||||
* <key>bsd44-fs-fragment-size</key>
|
||||
* <integer>...</integer>
|
||||
* <key>bsd44-iso9660-session-offset</key>
|
||||
* <integer>...</integer>
|
||||
* <key>bsd44-ffs-cylinders-per-group</key>
|
||||
* <integer>...</integer>
|
||||
* <key>bsd44-lfs-segment-shift</key>
|
||||
* <integer>...</integer>
|
||||
*
|
||||
* <!-- these are valid for NeXT partition maps -->
|
||||
* <key>next-block-size</key>
|
||||
* <integer>...</integer>
|
||||
* <key>next-fs-fragment-size</key>
|
||||
* <integer>...</integer>
|
||||
* <key>next-fs-optimization</key>
|
||||
* <string>...</string> <!-- "space" or "time" -->
|
||||
* <key>next-fs-cylinders-per-group</key>
|
||||
* <integer>...</integer>
|
||||
* <key>next-bytes-per-inode-density</key>
|
||||
* <integer>...</integer>
|
||||
* <key>next-minfree-percentage</key>
|
||||
* <integer>...</integer>
|
||||
* <key>next-run-newfs-during-init</key>
|
||||
* <false/>
|
||||
* <key>next-mount-point</key>
|
||||
* <string>...</string>
|
||||
* <key>next-automount</key>
|
||||
* <true/>
|
||||
* <key>next-partition-type</key>
|
||||
* <string>...</string>
|
||||
*
|
||||
* <!-- these are valid for MBR partition maps -->
|
||||
* <key>mbr-start-head</key>
|
||||
* <integer>...</integer>
|
||||
* <key>mbr-start-sector</key>
|
||||
* <integer>...</integer>
|
||||
* <key>mbr-start-cylinder</key>
|
||||
* <integer>...</integer>
|
||||
* <key>mbr-partition-type</key>
|
||||
* <integer>...</integer>
|
||||
* <key>mbr-end-head</key>
|
||||
* <integer>...</integer>
|
||||
* <key>mbr-end-sector</key>
|
||||
* <integer>...</integer>
|
||||
* <key>mbr-end-cylinder</key>
|
||||
* <integer>...</integer>
|
||||
* <key>mbr-active-partition</key>
|
||||
* <false/>
|
||||
*
|
||||
* <!-- these are valid for Apple partition maps -->
|
||||
* <key>apple-partition-type</key>
|
||||
* <string>...</string>
|
||||
* <!-- XXX What else do we need? wrstuden? -->
|
||||
*
|
||||
* <!-- these are valid for RISCiX partition maps -->
|
||||
* <key>riscix-partition-type</key>
|
||||
* <integer>...</integer>
|
||||
*
|
||||
* <!-- these are valid for MIPS/SGI partition maps -->
|
||||
* <key>mips-partition-type</key>
|
||||
* <integer>...</integer>
|
||||
*
|
||||
* <!-- SunOS 4 partition maps have no specific
|
||||
* additional information. Note, however,
|
||||
* that SunOS 4 partitions must begin on
|
||||
* cylinder boundaries. -->
|
||||
*
|
||||
* <!-- XXX Need Amiga partition map info -->
|
||||
*
|
||||
* <!-- these are valid for VTOC partition maps -->
|
||||
* <key>vtoc-tag</key>
|
||||
* <integer>...</integer>
|
||||
* <key>vtoc-unmount</key>
|
||||
* <false/>
|
||||
* <key>vtoc-read-only</key>
|
||||
* <false/>
|
||||
* <!-- XXX is this really part of the partition info? -->
|
||||
* <key>vtoc-timestamp</key>
|
||||
* <integer>...</integer>
|
||||
*
|
||||
* <!-- mvme68k partition maps use 4.4BSD partition
|
||||
* info stuffed into two different areas of the
|
||||
* disk information label recognized by BUG. -->
|
||||
*
|
||||
* <!-- XXX What else? -->
|
||||
* </dict>
|
||||
*/
|
||||
|
||||
struct disk {
|
||||
TAILQ_ENTRY(disk) dk_link; /* link in global disklist */
|
||||
const char *dk_name; /* disk name */
|
||||
prop_dictionary_t dk_info; /* reference to disk-info dictionary */
|
||||
int dk_bopenmask; /* block devices open */
|
||||
int dk_copenmask; /* character devices open */
|
||||
int dk_openmask; /* composite (bopen|copen) */
|
||||
int dk_state; /* label state ### */
|
||||
int dk_blkshift; /* shift to convert DEV_BSIZE to blks */
|
||||
int dk_byteshift; /* shift to convert bytes to blks */
|
||||
|
||||
/*
|
||||
* Metrics data; note that some metrics may have no meaning
|
||||
* on certain types of disks.
|
||||
*/
|
||||
struct io_stats *dk_stats;
|
||||
|
||||
const struct dkdriver *dk_driver; /* pointer to driver */
|
||||
|
||||
/*
|
||||
* Information required to be the parent of a disk wedge.
|
||||
*/
|
||||
kmutex_t dk_rawlock; /* lock on these fields */
|
||||
u_int dk_rawopens; /* # of openes of rawvp */
|
||||
struct vnode *dk_rawvp; /* vnode for the RAW_PART bdev */
|
||||
|
||||
kmutex_t dk_openlock; /* lock on these and openmask */
|
||||
u_int dk_nwedges; /* # of configured wedges */
|
||||
/* all wedges on this disk */
|
||||
LIST_HEAD(, dkwedge_softc) dk_wedges;
|
||||
|
||||
/*
|
||||
* Disk label information. Storage for the in-core disk label
|
||||
* must be dynamically allocated, otherwise the size of this
|
||||
* structure becomes machine-dependent.
|
||||
*/
|
||||
daddr_t dk_labelsector; /* sector containing label */
|
||||
struct disklabel *dk_label; /* label */
|
||||
struct cpu_disklabel *dk_cpulabel;
|
||||
};
|
||||
|
||||
struct dkdriver {
|
||||
void (*d_strategy)(struct buf *);
|
||||
void (*d_minphys)(struct buf *);
|
||||
#ifdef notyet
|
||||
int (*d_open)(dev_t, int, int, struct proc *);
|
||||
int (*d_close)(dev_t, int, int, struct proc *);
|
||||
int (*d_ioctl)(dev_t, u_long, void *, int, struct proc *);
|
||||
int (*d_dump)(dev_t);
|
||||
void (*d_start)(struct buf *, daddr_t);
|
||||
int (*d_mklabel)(struct disk *);
|
||||
#endif
|
||||
};
|
||||
|
||||
/* states */
|
||||
#define DK_CLOSED 0 /* drive is closed */
|
||||
#define DK_WANTOPEN 1 /* drive being opened */
|
||||
#define DK_WANTOPENRAW 2 /* drive being opened */
|
||||
#define DK_RDLABEL 3 /* label being read */
|
||||
#define DK_OPEN 4 /* label read, drive open */
|
||||
#define DK_OPENRAW 5 /* open without label */
|
||||
|
||||
/*
|
||||
* Bad sector lists per fixed disk
|
||||
*/
|
||||
struct disk_badsectors {
|
||||
SLIST_ENTRY(disk_badsectors) dbs_next;
|
||||
daddr_t dbs_min; /* min. sector number */
|
||||
daddr_t dbs_max; /* max. sector number */
|
||||
struct timeval dbs_failedat; /* first failure at */
|
||||
};
|
||||
|
||||
struct disk_badsecinfo {
|
||||
uint32_t dbsi_bufsize; /* size of region pointed to */
|
||||
uint32_t dbsi_skip; /* how many to skip past */
|
||||
uint32_t dbsi_copied; /* how many got copied back */
|
||||
uint32_t dbsi_left; /* remaining to copy */
|
||||
void * dbsi_buffer; /* region to copy disk_badsectors to */
|
||||
};
|
||||
|
||||
#define DK_STRATEGYNAMELEN 32
|
||||
struct disk_strategy {
|
||||
char dks_name[DK_STRATEGYNAMELEN]; /* name of strategy */
|
||||
char *dks_param; /* notyet; should be NULL */
|
||||
size_t dks_paramlen; /* notyet; should be 0 */
|
||||
};
|
||||
|
||||
#define DK_BSIZE2BLKSHIFT(b) ((ffs((b) / DEV_BSIZE)) - 1)
|
||||
#define DK_BSIZE2BYTESHIFT(b) (ffs((b)) - 1)
|
||||
|
||||
#ifdef _KERNEL
|
||||
extern int disk_count; /* number of disks in global disklist */
|
||||
|
||||
struct proc;
|
||||
|
||||
void disk_attach(struct disk *);
|
||||
int disk_begindetach(struct disk *, int (*)(device_t), device_t, int);
|
||||
void disk_detach(struct disk *);
|
||||
void disk_init(struct disk *, const char *, const struct dkdriver *);
|
||||
void disk_destroy(struct disk *);
|
||||
void disk_busy(struct disk *);
|
||||
void disk_unbusy(struct disk *, long, int);
|
||||
bool disk_isbusy(struct disk *);
|
||||
void disk_blocksize(struct disk *, int);
|
||||
struct disk *disk_find(const char *);
|
||||
int disk_ioctl(struct disk *, u_long, void *, int, struct lwp *);
|
||||
|
||||
void dkwedge_init(void);
|
||||
int dkwedge_add(struct dkwedge_info *);
|
||||
int dkwedge_del(struct dkwedge_info *);
|
||||
void dkwedge_delall(struct disk *);
|
||||
int dkwedge_list(struct disk *, struct dkwedge_list *, struct lwp *);
|
||||
void dkwedge_discover(struct disk *);
|
||||
void dkwedge_set_bootwedge(device_t, daddr_t, uint64_t);
|
||||
int dkwedge_read(struct disk *, struct vnode *, daddr_t, void *, size_t);
|
||||
device_t dkwedge_find_by_wname(const char *);
|
||||
void dkwedge_print_wnames(void);
|
||||
#endif
|
||||
|
||||
#endif /* _SYS_DISK_H_ */
|
||||
475
common/include/sys/disklabel.h
Normal file
475
common/include/sys/disklabel.h
Normal file
@@ -0,0 +1,475 @@
|
||||
/* $NetBSD: disklabel.h,v 1.111 2011/11/13 22:19:09 christos Exp $ */
|
||||
|
||||
/*
|
||||
* 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.
|
||||
* 3. 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
|
||||
*/
|
||||
|
||||
#ifndef _SYS_DISKLABEL_H_
|
||||
#define _SYS_DISKLABEL_H_
|
||||
|
||||
/*
|
||||
* We need <machine/types.h> for __HAVE_OLD_DISKLABEL
|
||||
*/
|
||||
#ifndef _LOCORE
|
||||
#include <sys/types.h>
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Each disk has a label which includes information about the hardware
|
||||
* disk geometry, filesystem partitions, and drive specific information.
|
||||
* The location of the label, as well as the number of partitions the
|
||||
* label can describe and the number of the "whole disk" (raw)
|
||||
* paritition are machine dependent.
|
||||
*/
|
||||
#if HAVE_NBTOOL_CONFIG_H
|
||||
#include <nbinclude/machine/disklabel.h>
|
||||
#else
|
||||
#include <machine/disklabel.h>
|
||||
#endif /* HAVE_NBTOOL_CONFIG_H */
|
||||
|
||||
/*
|
||||
* The absolute maximum number of disk partitions allowed.
|
||||
* This is the maximum value of MAXPARTITIONS for which 'struct disklabel'
|
||||
* is <= DEV_BSIZE bytes long. If MAXPARTITIONS is greater than this, beware.
|
||||
*/
|
||||
#define MAXMAXPARTITIONS 22
|
||||
#if MAXPARTITIONS > MAXMAXPARTITIONS
|
||||
#warning beware: MAXPARTITIONS bigger than MAXMAXPARTITIONS
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Ports can switch their MAXPARTITIONS once, as follows:
|
||||
*
|
||||
* - define OLDMAXPARTITIONS in <machine/disklabel.h> as the old number
|
||||
* - define MAXPARTITIONS as the new number
|
||||
* - define DISKUNIT, DISKPART and DISKMINOR macros in <machine/disklabel.h>
|
||||
* as appropriate for the port (see the i386 one for an example).
|
||||
* - define __HAVE_OLD_DISKLABEL in <machine/types.h>
|
||||
*/
|
||||
|
||||
#if defined(_KERNEL) && defined(__HAVE_OLD_DISKLABEL) && \
|
||||
(MAXPARTITIONS < OLDMAXPARTITIONS)
|
||||
#error "can only grow disklabel size"
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
* Translate between device numbers and major/disk unit/disk partition.
|
||||
*/
|
||||
#ifndef __HAVE_OLD_DISKLABEL
|
||||
#if !HAVE_NBTOOL_CONFIG_H
|
||||
#define DISKUNIT(dev) (minor(dev) / MAXPARTITIONS)
|
||||
#define DISKPART(dev) (minor(dev) % MAXPARTITIONS)
|
||||
#define DISKMINOR(unit, part) \
|
||||
(((unit) * MAXPARTITIONS) + (part))
|
||||
#endif /* !HAVE_NBTOOL_CONFIG_H */
|
||||
#endif
|
||||
#define MAKEDISKDEV(maj, unit, part) \
|
||||
(makedev((maj), DISKMINOR((unit), (part))))
|
||||
|
||||
#define DISKMAGIC ((uint32_t)0x82564557) /* The disk magic number */
|
||||
|
||||
#ifndef _LOCORE
|
||||
struct disklabel {
|
||||
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" */
|
||||
|
||||
/*
|
||||
* d_packname contains the pack identifier and is returned when
|
||||
* the disklabel is read off the disk or in-core copy.
|
||||
* d_boot0 and d_boot1 are the (optional) names of the
|
||||
* primary (block 0) and secondary (block 1-15) bootstraps
|
||||
* as found in /usr/mdec. These are returned when using
|
||||
* getdiskbyname(3) to retrieve the values from /etc/disktab.
|
||||
*/
|
||||
union {
|
||||
char un_d_packname[16]; /* pack identifier */
|
||||
struct {
|
||||
char *un_d_boot0; /* primary bootstrap name */
|
||||
char *un_d_boot1; /* secondary bootstrap name */
|
||||
} un_b;
|
||||
uint64_t un_d_pad; /* force 8 byte alignment */
|
||||
} d_un;
|
||||
#define d_packname d_un.un_d_packname
|
||||
#define d_boot0 d_un.un_b.un_d_boot0
|
||||
#define d_boot1 d_un.un_b.un_d_boot1
|
||||
|
||||
/* disk geometry: */
|
||||
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
|
||||
* 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.
|
||||
*/
|
||||
uint16_t d_sparespertrack; /* # of spare sectors per track */
|
||||
uint16_t d_sparespercyl; /* # of spare sectors per cylinder */
|
||||
/*
|
||||
* Alternative cylinders include maintenance, replacement,
|
||||
* configuration description areas, etc.
|
||||
*/
|
||||
uint32_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.
|
||||
*/
|
||||
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 */
|
||||
#define NDDATA 5
|
||||
uint32_t d_drivedata[NDDATA]; /* drive-type specific information */
|
||||
#define NSPARE 5
|
||||
uint32_t d_spare[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: */
|
||||
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 */
|
||||
uint32_t p_size; /* number of sectors in partition */
|
||||
uint32_t p_offset; /* starting sector */
|
||||
union {
|
||||
uint32_t fsize; /* FFS, ADOS:
|
||||
filesystem basic fragment size */
|
||||
uint32_t cdsession; /* ISO9660: session offset */
|
||||
} __partition_u2;
|
||||
#define p_fsize __partition_u2.fsize
|
||||
#define p_cdsession __partition_u2.cdsession
|
||||
uint8_t p_fstype; /* filesystem type, see below */
|
||||
uint8_t p_frag; /* filesystem fragments per block */
|
||||
union {
|
||||
uint16_t cpg; /* UFS: FS cylinders per group */
|
||||
uint16_t sgs; /* LFS: FS segment shift */
|
||||
} __partition_u1;
|
||||
#define p_cpg __partition_u1.cpg
|
||||
#define p_sgs __partition_u1.sgs
|
||||
} d_partitions[MAXPARTITIONS]; /* actually may be more */
|
||||
};
|
||||
|
||||
#if defined(__HAVE_OLD_DISKLABEL) && !HAVE_NBTOOL_CONFIG_H
|
||||
/*
|
||||
* Same as above, but with OLDMAXPARTITIONS partitions. For use in
|
||||
* the old DIOC* ioctl calls.
|
||||
*/
|
||||
struct olddisklabel {
|
||||
uint32_t d_magic;
|
||||
uint16_t d_type;
|
||||
uint16_t d_subtype;
|
||||
char d_typename[16];
|
||||
union {
|
||||
char un_d_packname[16];
|
||||
struct {
|
||||
char *un_d_boot0;
|
||||
char *un_d_boot1;
|
||||
} un_b;
|
||||
} d_un;
|
||||
uint32_t d_secsize;
|
||||
uint32_t d_nsectors;
|
||||
uint32_t d_ntracks;
|
||||
uint32_t d_ncylinders;
|
||||
uint32_t d_secpercyl;
|
||||
uint32_t d_secperunit;
|
||||
uint16_t d_sparespertrack;
|
||||
uint16_t d_sparespercyl;
|
||||
uint32_t d_acylinders;
|
||||
uint16_t d_rpm;
|
||||
uint16_t d_interleave;
|
||||
uint16_t d_trackskew;
|
||||
uint16_t d_cylskew;
|
||||
uint32_t d_headswitch;
|
||||
uint32_t d_trkseek;
|
||||
uint32_t d_flags;
|
||||
uint32_t d_drivedata[NDDATA];
|
||||
uint32_t d_spare[NSPARE];
|
||||
uint32_t d_magic2;
|
||||
uint16_t d_checksum;
|
||||
uint16_t d_npartitions;
|
||||
uint32_t d_bbsize;
|
||||
uint32_t d_sbsize;
|
||||
struct opartition {
|
||||
uint32_t p_size;
|
||||
uint32_t p_offset;
|
||||
union {
|
||||
uint32_t fsize;
|
||||
uint32_t cdsession;
|
||||
} __partition_u2;
|
||||
uint8_t p_fstype;
|
||||
uint8_t p_frag;
|
||||
union {
|
||||
uint16_t cpg;
|
||||
uint16_t sgs;
|
||||
} __partition_u1;
|
||||
} d_partitions[OLDMAXPARTITIONS];
|
||||
};
|
||||
#endif /* __HAVE_OLD_DISKLABEL */
|
||||
#else /* _LOCORE */
|
||||
/*
|
||||
* offsets for asm boot files.
|
||||
*/
|
||||
.set d_secsize,40
|
||||
.set d_nsectors,44
|
||||
.set d_ntracks,48
|
||||
.set d_ncylinders,52
|
||||
.set d_secpercyl,56
|
||||
.set d_secperunit,60
|
||||
.set d_end_,276 /* size of disk label */
|
||||
#endif /* _LOCORE */
|
||||
|
||||
/*
|
||||
* We normally use C99 initialisers (just in case the lists below are out
|
||||
* of sequence, or have gaps), but lint doesn't grok them.
|
||||
* Maybe some host compilers don't either, but many have for quite some time.
|
||||
*/
|
||||
|
||||
#ifndef lint
|
||||
#define ARRAY_INIT(element,value) [element]=value
|
||||
#else
|
||||
#define ARRAY_INIT(element,value) value
|
||||
#endif
|
||||
|
||||
/* Use pre-processor magic to get all the parameters one one line... */
|
||||
|
||||
/* d_type values: */
|
||||
#define DKTYPE_DEFN(x) \
|
||||
x(UNKNOWN, 0, "unknown") \
|
||||
x(SMD, 1, "SMD") /* SMD, XSMD; VAX hp/up */ \
|
||||
x(MSCP, 2, "MSCP") /* MSCP */ \
|
||||
x(DEC, 3, "old DEC") /* other DEC (rk, rl) */ \
|
||||
x(SCSI, 4, "SCSI") /* SCSI */ \
|
||||
x(ESDI, 5, "ESDI") /* ESDI interface */ \
|
||||
x(ST506, 6, "ST506") /* ST506 etc. */ \
|
||||
x(HPIB, 7, "HP-IB") /* CS/80 on HP-IB */ \
|
||||
x(HPFL, 8, "HP-FL") /* HP Fiber-link */ \
|
||||
x(TYPE_9, 9, "type 9") \
|
||||
x(FLOPPY, 10, "floppy") /* floppy */ \
|
||||
x(CCD, 11, "ccd") /* concatenated disk device */ \
|
||||
x(VND, 12, "vnd") /* uvnode pseudo-disk */ \
|
||||
x(ATAPI, 13, "ATAPI") /* ATAPI */ \
|
||||
x(RAID, 14, "RAID") /* RAIDframe */ \
|
||||
x(LD, 15, "ld") /* logical disk */ \
|
||||
x(JFS2, 16, "jfs") /* IBM JFS2 */ \
|
||||
x(CGD, 17, "cgd") /* cryptographic pseudo-disk */ \
|
||||
x(VINUM, 18, "vinum") /* vinum volume */ \
|
||||
x(FLASH, 19, "flash") /* flash memory devices */ \
|
||||
x(DM, 20, "dm") /* device-mapper pseudo-disk devices */\
|
||||
x(RUMPD, 21, "rumpd") /* rump virtual disk */ \
|
||||
|
||||
#ifndef _LOCORE
|
||||
#define DKTYPE_NUMS(tag, number, name) __CONCAT(DTYPE_,tag=number),
|
||||
#ifndef DKTYPE_ENUMNAME
|
||||
#define DKTYPE_ENUMNAME
|
||||
#endif
|
||||
enum DKTYPE_ENUMNAME { DKTYPE_DEFN(DKTYPE_NUMS) DKMAXTYPES };
|
||||
#undef DKTYPE_NUMS
|
||||
#endif
|
||||
|
||||
#ifdef DKTYPENAMES
|
||||
#define DKTYPE_NAMES(tag, number, name) ARRAY_INIT(number,name),
|
||||
static const char *const dktypenames[] = { DKTYPE_DEFN(DKTYPE_NAMES) NULL };
|
||||
#undef DKTYPE_NAMES
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Partition type names, numbers, label-names, fsck prog, and mount prog
|
||||
*/
|
||||
#define FSTYPE_DEFN(x) \
|
||||
x(UNUSED, 0, "unused", NULL, NULL) /* unused */ \
|
||||
x(SWAP, 1, "swap", NULL, NULL) /* swap */ \
|
||||
x(V6, 2, "Version 6", NULL, NULL) /* Sixth Edition */ \
|
||||
x(V7, 3, "Version 7", "v7fs", "v7fs") /* Seventh Edition */ \
|
||||
x(SYSV, 4, "System V", NULL, NULL) /* System V */ \
|
||||
x(V71K, 5, "4.1BSD", NULL, NULL) /* V7, 1K blocks (4.1, 2.9) */ \
|
||||
x(V8, 6, "Eighth Edition",NULL, NULL) /* Eighth Edition, 4K blocks */ \
|
||||
x(BSDFFS, 7, "4.2BSD", "ffs", "ffs") /* 4.2BSD fast file system */ \
|
||||
x(MSDOS, 8, "MSDOS", "msdos", "msdos") /* MSDOS file system */ \
|
||||
x(BSDLFS, 9, "4.4LFS", "lfs", "lfs") /* 4.4BSD log-structured FS */ \
|
||||
x(OTHER, 10, "unknown", NULL, NULL) /* in use, unknown/unsupported */\
|
||||
x(HPFS, 11, "HPFS", NULL, NULL) /* OS/2 high-performance FS */ \
|
||||
x(ISO9660, 12, "ISO9660", NULL, "cd9660")/* ISO 9660, normally CD-ROM */ \
|
||||
x(BOOT, 13, "boot", NULL, NULL) /* bootstrap code in partition */\
|
||||
x(ADOS, 14, "ADOS", NULL, "ados") /* AmigaDOS fast file system */ \
|
||||
x(HFS, 15, "HFS", NULL, NULL) /* Macintosh HFS */ \
|
||||
x(FILECORE,16, "FILECORE", NULL, "filecore")/* Acorn Filecore FS */ \
|
||||
x(EX2FS, 17, "Linux Ext2","ext2fs","ext2fs")/* Linux Extended 2 FS */ \
|
||||
x(NTFS, 18, "NTFS", NULL, "ntfs") /* Windows/NT file system */ \
|
||||
x(RAID, 19, "RAID", NULL, NULL) /* RAIDframe component */ \
|
||||
x(CCD, 20, "ccd", NULL, NULL) /* concatenated disk component */\
|
||||
x(JFS2, 21, "jfs", NULL, NULL) /* IBM JFS2 */ \
|
||||
x(APPLEUFS,22, "Apple UFS", "ffs", "ffs") /* Apple UFS */ \
|
||||
/* XXX this is not the same as FreeBSD. How to solve? */ \
|
||||
x(VINUM, 23, "vinum", NULL, NULL) /* Vinum */ \
|
||||
x(UDF, 24, "UDF", NULL, "udf") /* UDF */ \
|
||||
x(SYSVBFS, 25, "SysVBFS", NULL, "sysvbfs")/* System V boot file system */ \
|
||||
x(EFS, 26, "EFS", NULL, "efs") /* SGI's Extent Filesystem */ \
|
||||
x(NILFS, 27, "NiLFS", NULL, "nilfs") /* NTT's NiLFS(2) */ \
|
||||
x(CGD, 28, "cgd", NULL, NULL) /* Cryptographic disk */
|
||||
|
||||
|
||||
#ifndef _LOCORE
|
||||
#define FS_TYPENUMS(tag, number, name, fsck, mount) __CONCAT(FS_,tag=number),
|
||||
#ifndef FSTYPE_ENUMNAME
|
||||
#define FSTYPE_ENUMNAME
|
||||
#endif
|
||||
enum FSTYPE_ENUMNAME { FSTYPE_DEFN(FS_TYPENUMS) FSMAXTYPES };
|
||||
#undef FS_TYPENUMS
|
||||
#endif
|
||||
|
||||
#ifdef FSTYPENAMES
|
||||
#define FS_TYPENAMES(tag, number, name, fsck, mount) ARRAY_INIT(number,name),
|
||||
static const char *const fstypenames[] = { FSTYPE_DEFN(FS_TYPENAMES) NULL };
|
||||
#undef FS_TYPENAMES
|
||||
#endif
|
||||
|
||||
#ifdef FSCKNAMES
|
||||
/* These are the names MOUNT_XXX from <sys/mount.h> */
|
||||
#define FS_FSCKNAMES(tag, number, name, fsck, mount) ARRAY_INIT(number,fsck),
|
||||
static const char *const fscknames[] = { FSTYPE_DEFN(FS_FSCKNAMES) NULL };
|
||||
#undef FS_FSCKNAMES
|
||||
#define FSMAXNAMES FSMAXTYPES
|
||||
#endif
|
||||
|
||||
#ifdef MOUNTNAMES
|
||||
/* These are the names MOUNT_XXX from <sys/mount.h> */
|
||||
#define FS_MOUNTNAMES(tag, number, name, fsck, mount) ARRAY_INIT(number,mount),
|
||||
static const char *const mountnames[] = { FSTYPE_DEFN(FS_MOUNTNAMES) NULL };
|
||||
#undef FS_MOUNTNAMES
|
||||
#define FSMAXMOUNTNAMES FSMAXTYPES
|
||||
#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 */
|
||||
#define D_SCSI_MMC 0x20 /* SCSI MMC sessioned media */
|
||||
|
||||
/*
|
||||
* 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. Currently unused.
|
||||
*/
|
||||
struct format_op {
|
||||
char *df_buf;
|
||||
int df_count; /* value-result */
|
||||
daddr_t df_startblk;
|
||||
int df_reg[8]; /* result */
|
||||
};
|
||||
|
||||
#ifdef _KERNEL
|
||||
/*
|
||||
* Structure used internally to retrieve information about a partition
|
||||
* on a disk.
|
||||
*/
|
||||
struct partinfo {
|
||||
struct disklabel *disklab;
|
||||
struct partition *part;
|
||||
};
|
||||
|
||||
struct disk;
|
||||
|
||||
int disk_read_sectors(void (*)(struct buf *), const struct disklabel *,
|
||||
struct buf *, unsigned int, int);
|
||||
void diskerr(const struct buf *, const char *, const char *, int,
|
||||
int, const struct disklabel *);
|
||||
u_int dkcksum(struct disklabel *);
|
||||
u_int dkcksum_sized(struct disklabel *, size_t);
|
||||
int setdisklabel(struct disklabel *, struct disklabel *, u_long,
|
||||
struct cpu_disklabel *);
|
||||
const char *readdisklabel(dev_t, void (*)(struct buf *),
|
||||
struct disklabel *, struct cpu_disklabel *);
|
||||
int writedisklabel(dev_t, void (*)(struct buf *), struct disklabel *,
|
||||
struct cpu_disklabel *);
|
||||
const char *convertdisklabel(struct disklabel *, void (*)(struct buf *),
|
||||
struct buf *, uint32_t);
|
||||
int bounds_check_with_label(struct disk *, struct buf *, int);
|
||||
int bounds_check_with_mediasize(struct buf *, int, uint64_t);
|
||||
const char *getfstypename(int);
|
||||
#endif
|
||||
#endif /* _LOCORE */
|
||||
|
||||
#if !defined(_KERNEL) && !defined(_LOCORE)
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
|
||||
#endif
|
||||
|
||||
#endif /* !_SYS_DISKLABEL_H_ */
|
||||
82
common/include/sys/dkbad.h
Normal file
82
common/include/sys/dkbad.h
Normal file
@@ -0,0 +1,82 @@
|
||||
/* $NetBSD: dkbad.h,v 1.15 2005/12/26 18:41:36 perry Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1982, 1986, 1993, 1994
|
||||
* 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.
|
||||
* 3. 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.
|
||||
*
|
||||
* @(#)dkbad.h 8.2 (Berkeley) 7/10/94
|
||||
*/
|
||||
|
||||
#ifndef _SYS_DKBAD_H_
|
||||
#define _SYS_DKBAD_H_
|
||||
|
||||
/*
|
||||
* Definitions needed to perform bad sector revectoring ala DEC STD 144.
|
||||
*
|
||||
* The bad sector information is located in the first 5 even numbered
|
||||
* sectors of the last track of the disk pack. There are five identical
|
||||
* copies of the information, described by the dkbad structure.
|
||||
*
|
||||
* Replacement sectors are allocated starting with the first sector before
|
||||
* the bad sector information and working backwards towards the beginning of
|
||||
* the disk. A maximum of 126 bad sectors are supported. The position of
|
||||
* the bad sector in the bad sector table determines which replacement sector
|
||||
* it corresponds to.
|
||||
*
|
||||
* The bad sector information and replacement sectors are conventionally
|
||||
* only accessible through the 'c' file system partition of the disk. If
|
||||
* that partition is used for a file system, the user is responsible for
|
||||
* making sure that it does not overlap the bad sector information or any
|
||||
* replacement sectors.
|
||||
*/
|
||||
#define NBT_BAD 126
|
||||
|
||||
struct dkbad {
|
||||
int32_t bt_csn; /* cartridge serial number */
|
||||
uint16_t bt_mbz; /* unused; should be 0 */
|
||||
uint16_t bt_flag; /* -1 => alignment cartridge */
|
||||
struct bt_bad {
|
||||
uint16_t bt_cyl; /* cylinder number of bad sector */
|
||||
uint16_t bt_trksec; /* track and sector number */
|
||||
} bt_bad[NBT_BAD];
|
||||
};
|
||||
|
||||
/*
|
||||
* An indicator that the bad block handling is available. This is used
|
||||
* to conditionally enable code that performs badblock re-mapping.
|
||||
*/
|
||||
#define HAS_BAD144_HANDLING
|
||||
|
||||
#define ECC 0
|
||||
#define SSE 1
|
||||
#define BSE 2
|
||||
#define CONT 3
|
||||
|
||||
#ifdef _KERNEL
|
||||
int isbad(struct dkbad *, int, int, int);
|
||||
#endif
|
||||
#endif /* _SYS_DKBAD_H_ */
|
||||
112
common/include/sys/dkio.h
Normal file
112
common/include/sys/dkio.h
Normal file
@@ -0,0 +1,112 @@
|
||||
/* $NetBSD: dkio.h,v 1.17 2011/01/18 19:52:24 matt Exp $ */
|
||||
|
||||
/*
|
||||
* 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.
|
||||
* 3. 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.
|
||||
*/
|
||||
|
||||
#ifndef _SYS_DKIO_H_
|
||||
#define _SYS_DKIO_H_
|
||||
|
||||
#include <sys/ioccom.h>
|
||||
#include <prop/plistref.h>
|
||||
|
||||
/*
|
||||
* 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 */
|
||||
|
||||
#ifdef _KERNEL
|
||||
#define DIOCGDINFO32 (DIOCGDINFO - (sizeof(uint32_t) << IOCPARM_SHIFT))
|
||||
#define DIOCGPART _IOW('d', 104, struct partinfo) /* get partition */
|
||||
#endif
|
||||
|
||||
#if defined(__HAVE_OLD_DISKLABEL) && defined(_KERNEL)
|
||||
#define ODIOCGDINFO _IOR('d', 101, struct olddisklabel)/* get */
|
||||
#define ODIOCSDINFO _IOW('d', 102, struct olddisklabel)/* set */
|
||||
#define ODIOCWDINFO _IOW('d', 103, struct olddisklabel)/* set, update dk */
|
||||
#endif
|
||||
|
||||
/* do format operation, read or write */
|
||||
#define DIOCRFORMAT _IOWR('d', 105, struct format_op)
|
||||
#define DIOCWFORMAT _IOWR('d', 106, struct format_op)
|
||||
|
||||
#define DIOCSSTEP _IOW('d', 107, int) /* set step rate */
|
||||
#define DIOCSRETRIES _IOW('d', 108, int) /* set # of retries */
|
||||
#define DIOCKLABEL _IOW('d', 119, int) /* keep/drop label on close? */
|
||||
#define DIOCWLABEL _IOW('d', 109, int) /* write en/disable label */
|
||||
|
||||
#define DIOCSBAD _IOW('d', 110, struct dkbad) /* set kernel dkbad */
|
||||
#define DIOCEJECT _IOW('d', 112, int) /* eject removable disk */
|
||||
#define ODIOCEJECT _IO('d', 112) /* eject removable disk */
|
||||
#define DIOCLOCK _IOW('d', 113, int) /* lock/unlock pack */
|
||||
|
||||
/* get default label, clear label */
|
||||
#define DIOCGDEFLABEL _IOR('d', 114, struct disklabel)
|
||||
#define DIOCCLRLABEL _IO('d', 115)
|
||||
|
||||
#if defined(__HAVE_OLD_DISKLABEL) && defined(_KERNEL)
|
||||
#define ODIOCGDEFLABEL _IOR('d', 114, struct olddisklabel)
|
||||
#endif
|
||||
|
||||
/* disk cache enable/disable */
|
||||
#define DIOCGCACHE _IOR('d', 116, int) /* get cache enables */
|
||||
#define DIOCSCACHE _IOW('d', 117, int) /* set cache enables */
|
||||
|
||||
#define DKCACHE_READ 0x000001 /* read cache enabled */
|
||||
#define DKCACHE_WRITE 0x000002 /* write(back) cache enabled */
|
||||
#define DKCACHE_RCHANGE 0x000100 /* read enable is changeable */
|
||||
#define DKCACHE_WCHANGE 0x000200 /* write enable is changeable */
|
||||
#define DKCACHE_SAVE 0x010000 /* cache parameters are savable/save them */
|
||||
|
||||
/* sync disk cache */
|
||||
#define DIOCCACHESYNC _IOW('d', 118, int) /* sync cache (force?) */
|
||||
|
||||
/* bad sector list */
|
||||
#define DIOCBSLIST _IOWR('d', 119, struct disk_badsecinfo) /* get list */
|
||||
#define DIOCBSFLUSH _IO('d', 120) /* flush list */
|
||||
|
||||
/* wedges */
|
||||
#define DIOCAWEDGE _IOWR('d', 121, struct dkwedge_info) /* add wedge */
|
||||
#define DIOCGWEDGEINFO _IOR('d', 122, struct dkwedge_info) /* get wedge inf */
|
||||
#define DIOCDWEDGE _IOW('d', 123, struct dkwedge_info) /* del wedge */
|
||||
#define DIOCLWEDGES _IOWR('d', 124, struct dkwedge_list) /* list wedges */
|
||||
|
||||
/* disk buffer queue strategy */
|
||||
#define DIOCGSTRATEGY _IOR('d', 125, struct disk_strategy)
|
||||
#define DIOCSSTRATEGY _IOW('d', 126, struct disk_strategy)
|
||||
|
||||
/* get disk-info dictionary */
|
||||
#define DIOCGDISKINFO _IOR('d', 127, struct plistref)
|
||||
|
||||
|
||||
#define DIOCTUR _IOR('d', 128, int) /* test unit ready */
|
||||
|
||||
#endif /* _SYS_DKIO_H_ */
|
||||
75
common/include/sys/ioccom.h
Normal file
75
common/include/sys/ioccom.h
Normal file
@@ -0,0 +1,75 @@
|
||||
/* $NetBSD: ioccom.h,v 1.11 2011/10/19 10:53:12 yamt Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1982, 1986, 1990, 1993, 1994
|
||||
* 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.
|
||||
* 3. 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.
|
||||
*
|
||||
* @(#)ioccom.h 8.3 (Berkeley) 1/9/95
|
||||
*/
|
||||
|
||||
#ifndef _SYS_IOCCOM_H_
|
||||
#define _SYS_IOCCOM_H_
|
||||
|
||||
/*
|
||||
* Ioctl's have the command encoded in the lower word, and the size of
|
||||
* any in or out parameters in the upper word. The high 3 bits of the
|
||||
* upper word are used to encode the in/out status of the parameter.
|
||||
*
|
||||
* 31 29 28 16 15 8 7 0
|
||||
* +---------------------------------------------------------------+
|
||||
* | I/O | Parameter Length | Command Group | Command |
|
||||
* +---------------------------------------------------------------+
|
||||
*/
|
||||
#define IOCPARM_MASK 0x1fff /* parameter length, at most 13 bits */
|
||||
#define IOCPARM_SHIFT 16
|
||||
#define IOCGROUP_SHIFT 8
|
||||
#define IOCPARM_LEN(x) (((x) >> IOCPARM_SHIFT) & IOCPARM_MASK)
|
||||
#define IOCBASECMD(x) ((x) & ~(IOCPARM_MASK << IOCPARM_SHIFT))
|
||||
#define IOCGROUP(x) (((x) >> IOCGROUP_SHIFT) & 0xff)
|
||||
|
||||
#define IOCPARM_MAX NBPG /* max size of ioctl args, mult. of NBPG */
|
||||
/* no parameters */
|
||||
#define IOC_VOID (unsigned long)0x20000000
|
||||
/* copy parameters out */
|
||||
#define IOC_OUT (unsigned long)0x40000000
|
||||
/* copy parameters in */
|
||||
#define IOC_IN (unsigned long)0x80000000
|
||||
/* copy parameters in and out */
|
||||
#define IOC_INOUT (IOC_IN|IOC_OUT)
|
||||
/* mask for IN/OUT/VOID */
|
||||
#define IOC_DIRMASK (unsigned long)0xe0000000
|
||||
|
||||
#define _IOC(inout, group, num, len) \
|
||||
((inout) | (((len) & IOCPARM_MASK) << IOCPARM_SHIFT) | \
|
||||
((group) << IOCGROUP_SHIFT) | (num))
|
||||
#define _IO(g,n) _IOC(IOC_VOID, (g), (n), 0)
|
||||
#define _IOR(g,n,t) _IOC(IOC_OUT, (g), (n), sizeof(t))
|
||||
#define _IOW(g,n,t) _IOC(IOC_IN, (g), (n), sizeof(t))
|
||||
/* this should be _IORW, but stdio got there first */
|
||||
#define _IOWR(g,n,t) _IOC(IOC_INOUT, (g), (n), sizeof(t))
|
||||
|
||||
#endif /* !_SYS_IOCCOM_H_ */
|
||||
108
common/include/sys/iostat.h
Normal file
108
common/include/sys/iostat.h
Normal file
@@ -0,0 +1,108 @@
|
||||
/* $NetBSD: iostat.h,v 1.10 2009/04/04 07:30:09 ad Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1996, 1997, 2004, 2009 The NetBSD Foundation, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to The NetBSD Foundation
|
||||
* by Jason R. Thorpe of the Numerical Aerospace Simulation Facility,
|
||||
* NASA Ames Research Center.
|
||||
*
|
||||
* 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 NETBSD FOUNDATION, INC. 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 FOUNDATION 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.
|
||||
*/
|
||||
|
||||
#ifndef _SYS_IOSTAT_H_
|
||||
#define _SYS_IOSTAT_H_
|
||||
|
||||
/*
|
||||
* Disk device structures.
|
||||
*/
|
||||
|
||||
#include <sys/time.h>
|
||||
#include <sys/queue.h>
|
||||
|
||||
#define IOSTATNAMELEN 16
|
||||
|
||||
/* types of drives we can have */
|
||||
#define IOSTAT_DISK 0
|
||||
#define IOSTAT_TAPE 1
|
||||
#define IOSTAT_NFS 2
|
||||
|
||||
/* The following structure is 64-bit alignment safe */
|
||||
struct io_sysctl {
|
||||
char name[IOSTATNAMELEN];
|
||||
int32_t busy;
|
||||
int32_t type;
|
||||
u_int64_t xfer;
|
||||
u_int64_t seek;
|
||||
u_int64_t bytes;
|
||||
u_int32_t attachtime_sec;
|
||||
u_int32_t attachtime_usec;
|
||||
u_int32_t timestamp_sec;
|
||||
u_int32_t timestamp_usec;
|
||||
u_int32_t time_sec;
|
||||
u_int32_t time_usec;
|
||||
/* New separate read/write stats */
|
||||
u_int64_t rxfer;
|
||||
u_int64_t rbytes;
|
||||
u_int64_t wxfer;
|
||||
u_int64_t wbytes;
|
||||
};
|
||||
|
||||
/*
|
||||
* Structure for keeping the in-kernel drive stats - these are linked
|
||||
* together in drivelist.
|
||||
*/
|
||||
|
||||
struct io_stats {
|
||||
char io_name[IOSTATNAMELEN]; /* device name */
|
||||
void *io_parent; /* pointer to what we are attached to */
|
||||
int io_type; /* type of device the state belong to */
|
||||
int io_busy; /* busy counter */
|
||||
u_int64_t io_rxfer; /* total number of read transfers */
|
||||
u_int64_t io_wxfer; /* total number of write transfers */
|
||||
u_int64_t io_seek; /* total independent seek operations */
|
||||
u_int64_t io_rbytes; /* total bytes read */
|
||||
u_int64_t io_wbytes; /* total bytes written */
|
||||
struct timeval io_attachtime; /* time disk was attached */
|
||||
struct timeval io_timestamp; /* timestamp of last unbusy */
|
||||
struct timeval io_time; /* total time spent busy */
|
||||
TAILQ_ENTRY(io_stats) io_link;
|
||||
};
|
||||
|
||||
/*
|
||||
* drivelist_head is defined here so that user-land has access to it.
|
||||
*/
|
||||
TAILQ_HEAD(iostatlist_head, io_stats); /* the iostatlist is a TAILQ */
|
||||
|
||||
#ifdef _KERNEL
|
||||
void iostat_init(void);
|
||||
void iostat_busy(struct io_stats *);
|
||||
void iostat_unbusy(struct io_stats *, long, int);
|
||||
bool iostat_isbusy(struct io_stats *);
|
||||
struct io_stats *iostat_find(const char *);
|
||||
struct io_stats *iostat_alloc(int32_t, void *, const char *);
|
||||
void iostat_free(struct io_stats *);
|
||||
void iostat_seek(struct io_stats *);
|
||||
#endif
|
||||
|
||||
#endif /* _SYS_IOSTAT_H_ */
|
||||
216
common/include/sys/mutex.h
Normal file
216
common/include/sys/mutex.h
Normal file
@@ -0,0 +1,216 @@
|
||||
/* $NetBSD: mutex.h,v 1.20 2010/02/08 09:54:27 skrll Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2002, 2006, 2007, 2008, 2009 The NetBSD Foundation, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to The NetBSD Foundation
|
||||
* by Jason R. Thorpe and Andrew Doran.
|
||||
*
|
||||
* 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 NETBSD FOUNDATION, INC. 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 FOUNDATION 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.
|
||||
*/
|
||||
|
||||
#ifndef _SYS_MUTEX_H_
|
||||
#define _SYS_MUTEX_H_
|
||||
|
||||
/*
|
||||
* There are 2 types of mutexes:
|
||||
*
|
||||
* * Adaptive -- If the lock is already held, the thread attempting
|
||||
* to acquire the lock determines if the thread that holds it is
|
||||
* currently running. If so, it spins, else it sleeps.
|
||||
*
|
||||
* * Spin -- If the lock is already held, the thread attempting to
|
||||
* acquire the lock spins. The IPL will be raised on entry.
|
||||
*
|
||||
* Machine dependent code must provide the following:
|
||||
*
|
||||
* struct mutex
|
||||
* The actual mutex structure. This structure is mostly
|
||||
* opaque to machine-independent code; most access are done
|
||||
* through macros. However, machine-independent code must
|
||||
* be able to access the following members:
|
||||
*
|
||||
* uintptr_t mtx_owner
|
||||
* ipl_cookie_t mtx_ipl
|
||||
* __cpu_simple_lock_t mtx_lock
|
||||
*
|
||||
* If an architecture can be considered 'simple' (no interlock required in
|
||||
* the MP case, or no MP) it need only define __HAVE_SIMPLE_MUTEXES and
|
||||
* provide the following:
|
||||
*
|
||||
* struct mutex
|
||||
*
|
||||
* [additionally:]
|
||||
* volatile integer mtx_id
|
||||
*
|
||||
* MUTEX_RECEIVE(mtx)
|
||||
* Post a load fence after acquiring the mutex, if necessary.
|
||||
*
|
||||
* MUTEX_GIVE(mtx)
|
||||
* Post a load/store fence after releasing the mutex, if
|
||||
* necessary.
|
||||
*
|
||||
* MUTEX_CAS(ptr, old, new)
|
||||
* Perform an atomic "compare and swap" operation and
|
||||
* evaluate to true or false according to the success
|
||||
*
|
||||
* Otherwise, the following must be defined:
|
||||
*
|
||||
* MUTEX_INITIALIZE_SPIN(mtx, dodebug, minipl)
|
||||
* Initialize a spin mutex.
|
||||
*
|
||||
* MUTEX_INITIALIZE_ADAPTIVE(mtx, dodebug)
|
||||
* Initialize an adaptive mutex.
|
||||
*
|
||||
* MUTEX_DESTROY(mtx)
|
||||
* Tear down a mutex.
|
||||
*
|
||||
* MUTEX_ADAPTIVE_P(mtx)
|
||||
* Evaluates to true if the mutex is an adaptive mutex.
|
||||
*
|
||||
* MUTEX_SPIN_P(mtx)
|
||||
* Evaluates to true if the mutex is a spin mutex.
|
||||
*
|
||||
* MUTEX_OWNER(owner)
|
||||
* Returns the owner of the adaptive mutex (LWP address).
|
||||
*
|
||||
* MUTEX_OWNED(owner)
|
||||
* Returns non-zero if an adaptive mutex is currently
|
||||
* held by an LWP.
|
||||
*
|
||||
* MUTEX_HAS_WAITERS(mtx)
|
||||
* Returns true if the mutex has waiters.
|
||||
*
|
||||
* MUTEX_SET_WAITERS(mtx)
|
||||
* Mark the mutex has having waiters.
|
||||
*
|
||||
* MUTEX_ACQUIRE(mtx, owner)
|
||||
* Try to acquire an adaptive mutex such that:
|
||||
* if (lock held OR waiters)
|
||||
* return 0;
|
||||
* else
|
||||
* return 1;
|
||||
* Must be MP/interrupt atomic.
|
||||
*
|
||||
* MUTEX_RELEASE(mtx)
|
||||
* Release the lock and clear the "has waiters" indication.
|
||||
* Must be interrupt atomic, need not be MP safe.
|
||||
*
|
||||
* MUTEX_DEBUG_P(mtx)
|
||||
* Evaluates to true if the mutex is initialized with
|
||||
* dodebug==true. Only used in the LOCKDEBUG case.
|
||||
*
|
||||
* Machine dependent code may optionally provide stubs for the following
|
||||
* functions to implement the easy (unlocked / no waiters) cases. If
|
||||
* these stubs are provided, __HAVE_MUTEX_STUBS should be defined.
|
||||
*
|
||||
* mutex_enter()
|
||||
* mutex_exit()
|
||||
*
|
||||
* Two additional stubs may be implemented that handle only the spinlock
|
||||
* case, primarily for the scheduler. __HAVE_SPIN_MUTEX_STUBS should be
|
||||
* defined if these are provided:
|
||||
*
|
||||
* mutex_spin_enter()
|
||||
* mutex_spin_exit()
|
||||
*/
|
||||
|
||||
#if defined(_KERNEL_OPT)
|
||||
#include "opt_lockdebug.h"
|
||||
#endif
|
||||
|
||||
#if !defined(_KERNEL)
|
||||
#include <sys/types.h>
|
||||
#include <sys/inttypes.h>
|
||||
#endif
|
||||
|
||||
typedef enum kmutex_type_t {
|
||||
MUTEX_SPIN = 0, /* To get a spin mutex at IPL_NONE */
|
||||
MUTEX_ADAPTIVE = 1, /* For porting code written for Solaris */
|
||||
MUTEX_DEFAULT = 2, /* The only native, endorsed type */
|
||||
MUTEX_DRIVER = 3, /* For porting code written for Solaris */
|
||||
MUTEX_NODEBUG = 4 /* Disables LOCKDEBUG; use with care */
|
||||
} kmutex_type_t;
|
||||
|
||||
typedef struct kmutex kmutex_t;
|
||||
|
||||
#if defined(__MUTEX_PRIVATE)
|
||||
|
||||
#define MUTEX_THREAD ((uintptr_t)-16L)
|
||||
|
||||
#define MUTEX_BIT_SPIN 0x01
|
||||
#define MUTEX_BIT_WAITERS 0x02
|
||||
|
||||
#if defined(LOCKDEBUG)
|
||||
#define MUTEX_BIT_NODEBUG 0x04 /* LOCKDEBUG disabled */
|
||||
#else
|
||||
#define MUTEX_BIT_NODEBUG 0x00 /* do nothing */
|
||||
#endif /* LOCKDEBUG */
|
||||
|
||||
#define MUTEX_SPIN_IPL(mtx) ((mtx)->mtx_ipl)
|
||||
#define MUTEX_SPIN_OLDSPL(ci) ((ci)->ci_mtx_oldspl)
|
||||
|
||||
void mutex_vector_enter(kmutex_t *);
|
||||
void mutex_vector_exit(kmutex_t *);
|
||||
void mutex_spin_retry(kmutex_t *);
|
||||
void mutex_wakeup(kmutex_t *);
|
||||
|
||||
#endif /* __MUTEX_PRIVATE */
|
||||
|
||||
#ifdef _KERNEL
|
||||
#include <sys/intr.h>
|
||||
#endif
|
||||
|
||||
#include <machine/mutex.h>
|
||||
|
||||
/*
|
||||
* Return true if no spin mutexes are held by the current CPU.
|
||||
*/
|
||||
#ifndef MUTEX_NO_SPIN_ACTIVE_P
|
||||
#define MUTEX_NO_SPIN_ACTIVE_P(ci) ((ci)->ci_mtx_count == 0)
|
||||
#endif
|
||||
|
||||
#ifdef _KERNEL
|
||||
|
||||
void mutex_init(kmutex_t *, kmutex_type_t, int);
|
||||
void mutex_destroy(kmutex_t *);
|
||||
|
||||
void mutex_enter(kmutex_t *);
|
||||
void mutex_exit(kmutex_t *);
|
||||
|
||||
void mutex_spin_enter(kmutex_t *);
|
||||
void mutex_spin_exit(kmutex_t *);
|
||||
|
||||
int mutex_tryenter(kmutex_t *);
|
||||
|
||||
int mutex_owned(kmutex_t *);
|
||||
lwp_t *mutex_owner(kmutex_t *);
|
||||
|
||||
void mutex_obj_init(void);
|
||||
kmutex_t *mutex_obj_alloc(kmutex_type_t, int);
|
||||
void mutex_obj_hold(kmutex_t *);
|
||||
bool mutex_obj_free(kmutex_t *);
|
||||
|
||||
#endif /* _KERNEL */
|
||||
|
||||
#endif /* _SYS_MUTEX_H_ */
|
||||
Reference in New Issue
Block a user