1 1.3 pooka /* $NetBSD: ukfs_int_disklabel.h,v 1.3 2011/02/22 15:42:15 pooka Exp $ */ 2 1.1 pooka 3 1.1 pooka /* 4 1.1 pooka * Modified copy of disklabel.h so that ukfs doesn't have to depend 5 1.1 pooka * on NetBSD headers. Contains just about only "struct disklabel". 6 1.1 pooka * The on-disk disklabel doesn't really change format, so no need 7 1.1 pooka * to track this against NetBSD changes. 8 1.1 pooka */ 9 1.1 pooka 10 1.1 pooka /* 11 1.1 pooka * Copyright (c) 1987, 1988, 1993 12 1.1 pooka * The Regents of the University of California. All rights reserved. 13 1.1 pooka * 14 1.1 pooka * Redistribution and use in source and binary forms, with or without 15 1.1 pooka * modification, are permitted provided that the following conditions 16 1.1 pooka * are met: 17 1.1 pooka * 1. Redistributions of source code must retain the above copyright 18 1.1 pooka * notice, this list of conditions and the following disclaimer. 19 1.1 pooka * 2. Redistributions in binary form must reproduce the above copyright 20 1.1 pooka * notice, this list of conditions and the following disclaimer in the 21 1.1 pooka * documentation and/or other materials provided with the distribution. 22 1.1 pooka * 3. Neither the name of the University nor the names of its contributors 23 1.1 pooka * may be used to endorse or promote products derived from this software 24 1.1 pooka * without specific prior written permission. 25 1.1 pooka * 26 1.1 pooka * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 27 1.1 pooka * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 28 1.1 pooka * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 29 1.1 pooka * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 30 1.1 pooka * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 31 1.1 pooka * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 32 1.1 pooka * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 33 1.1 pooka * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 34 1.1 pooka * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 35 1.1 pooka * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 36 1.1 pooka * SUCH DAMAGE. 37 1.1 pooka * 38 1.1 pooka * @(#)disklabel.h 8.2 (Berkeley) 7/10/94 39 1.1 pooka */ 40 1.1 pooka 41 1.1 pooka #ifndef LIB_UKFS_DISKLABEL_H_ 42 1.1 pooka #define LIB_UKFS_DISKLABEL_H_ 43 1.1 pooka 44 1.1 pooka #include <sys/types.h> 45 1.1 pooka 46 1.1 pooka #include <stdint.h> 47 1.1 pooka 48 1.1 pooka #define UKFS_MAXPARTITIONS 22 49 1.1 pooka #define UKFS_DISKMAGIC ((uint32_t)0x82564557) /* The disk magic number */ 50 1.1 pooka 51 1.2 pooka struct ukfs__disklabel { 52 1.1 pooka uint32_t d_magic; /* the magic number */ 53 1.1 pooka uint16_t d_type; /* drive type */ 54 1.1 pooka uint16_t d_subtype; /* controller/d_type specific */ 55 1.1 pooka char d_typename[16]; /* type name, e.g. "eagle" */ 56 1.1 pooka 57 1.1 pooka /* 58 1.1 pooka * d_packname contains the pack identifier and is returned when 59 1.1 pooka * the disklabel is read off the disk or in-core copy. 60 1.1 pooka * d_boot0 and d_boot1 are the (optional) names of the 61 1.1 pooka * primary (block 0) and secondary (block 1-15) bootstraps 62 1.1 pooka * as found in /usr/mdec. These are returned when using 63 1.1 pooka * getdiskbyname(3) to retrieve the values from /etc/disktab. 64 1.1 pooka */ 65 1.1 pooka union { 66 1.1 pooka char un_d_packname[16]; /* pack identifier */ 67 1.1 pooka struct { 68 1.1 pooka char *un_d_boot0; /* primary bootstrap name */ 69 1.1 pooka char *un_d_boot1; /* secondary bootstrap name */ 70 1.1 pooka } un_b; 71 1.1 pooka } d_un; 72 1.1 pooka #define d_packname d_un.un_d_packname 73 1.1 pooka #define d_boot0 d_un.un_b.un_d_boot0 74 1.1 pooka #define d_boot1 d_un.un_b.un_d_boot1 75 1.1 pooka 76 1.1 pooka /* disk geometry: */ 77 1.1 pooka uint32_t d_secsize; /* # of bytes per sector */ 78 1.1 pooka uint32_t d_nsectors; /* # of data sectors per track */ 79 1.1 pooka uint32_t d_ntracks; /* # of tracks per cylinder */ 80 1.1 pooka uint32_t d_ncylinders; /* # of data cylinders per unit */ 81 1.1 pooka uint32_t d_secpercyl; /* # of data sectors per cylinder */ 82 1.1 pooka uint32_t d_secperunit; /* # of data sectors per unit */ 83 1.1 pooka 84 1.1 pooka /* 85 1.1 pooka * Spares (bad sector replacements) below are not counted in 86 1.1 pooka * d_nsectors or d_secpercyl. Spare sectors are assumed to 87 1.1 pooka * be physical sectors which occupy space at the end of each 88 1.1 pooka * track and/or cylinder. 89 1.1 pooka */ 90 1.1 pooka uint16_t d_sparespertrack; /* # of spare sectors per track */ 91 1.1 pooka uint16_t d_sparespercyl; /* # of spare sectors per cylinder */ 92 1.1 pooka /* 93 1.1 pooka * Alternative cylinders include maintenance, replacement, 94 1.1 pooka * configuration description areas, etc. 95 1.1 pooka */ 96 1.1 pooka uint32_t d_acylinders; /* # of alt. cylinders per unit */ 97 1.1 pooka 98 1.1 pooka /* hardware characteristics: */ 99 1.1 pooka /* 100 1.1 pooka * d_interleave, d_trackskew and d_cylskew describe perturbations 101 1.1 pooka * in the media format used to compensate for a slow controller. 102 1.1 pooka * Interleave is physical sector interleave, set up by the 103 1.1 pooka * formatter or controller when formatting. When interleaving is 104 1.1 pooka * in use, logically adjacent sectors are not physically 105 1.1 pooka * contiguous, but instead are separated by some number of 106 1.1 pooka * sectors. It is specified as the ratio of physical sectors 107 1.1 pooka * traversed per logical sector. Thus an interleave of 1:1 108 1.1 pooka * implies contiguous layout, while 2:1 implies that logical 109 1.1 pooka * sector 0 is separated by one sector from logical sector 1. 110 1.1 pooka * d_trackskew is the offset of sector 0 on track N relative to 111 1.1 pooka * sector 0 on track N-1 on the same cylinder. Finally, d_cylskew 112 1.1 pooka * is the offset of sector 0 on cylinder N relative to sector 0 113 1.1 pooka * on cylinder N-1. 114 1.1 pooka */ 115 1.1 pooka uint16_t d_rpm; /* rotational speed */ 116 1.1 pooka uint16_t d_interleave; /* hardware sector interleave */ 117 1.1 pooka uint16_t d_trackskew; /* sector 0 skew, per track */ 118 1.1 pooka uint16_t d_cylskew; /* sector 0 skew, per cylinder */ 119 1.1 pooka uint32_t d_headswitch; /* head switch time, usec */ 120 1.1 pooka uint32_t d_trkseek; /* track-to-track seek, usec */ 121 1.1 pooka uint32_t d_flags; /* generic flags */ 122 1.1 pooka #define NDDATA 5 123 1.1 pooka uint32_t d_drivedata[NDDATA]; /* drive-type specific information */ 124 1.1 pooka #define NSPARE 5 125 1.1 pooka uint32_t d_spare[NSPARE]; /* reserved for future use */ 126 1.1 pooka uint32_t d_magic2; /* the magic number (again) */ 127 1.1 pooka uint16_t d_checksum; /* xor of data incl. partitions */ 128 1.1 pooka 129 1.1 pooka /* filesystem and partition information: */ 130 1.1 pooka uint16_t d_npartitions; /* number of partitions in following */ 131 1.1 pooka uint32_t d_bbsize; /* size of boot area at sn0, bytes */ 132 1.1 pooka uint32_t d_sbsize; /* max size of fs superblock, bytes */ 133 1.2 pooka struct ukfs__partition { /* the partition table */ 134 1.1 pooka uint32_t p_size; /* number of sectors in partition */ 135 1.1 pooka uint32_t p_offset; /* starting sector */ 136 1.1 pooka union { 137 1.1 pooka uint32_t fsize; /* FFS, ADOS: 138 1.1 pooka filesystem basic fragment size */ 139 1.1 pooka uint32_t cdsession; /* ISO9660: session offset */ 140 1.1 pooka } __partition_u2; 141 1.1 pooka #define p_fsize __partition_u2.fsize 142 1.1 pooka #define p_cdsession __partition_u2.cdsession 143 1.1 pooka uint8_t p_fstype; /* filesystem type, see below */ 144 1.1 pooka uint8_t p_frag; /* filesystem fragments per block */ 145 1.1 pooka union { 146 1.1 pooka uint16_t cpg; /* UFS: FS cylinders per group */ 147 1.1 pooka uint16_t sgs; /* LFS: FS segment shift */ 148 1.1 pooka } __partition_u1; 149 1.1 pooka #define p_cpg __partition_u1.cpg 150 1.1 pooka #define p_sgs __partition_u1.sgs 151 1.1 pooka } d_partitions[UKFS_MAXPARTITIONS]; /* actually may be more */ 152 1.1 pooka }; 153 1.1 pooka 154 1.3 pooka uint16_t ukfs__disklabel_dkcksum(struct ukfs__disklabel *, int); 155 1.3 pooka int ukfs__disklabel_scan(struct ukfs__disklabel *, int *, 156 1.3 pooka char *, size_t); 157 1.1 pooka 158 1.1 pooka #endif /* !LIB_UKFS_DISKLABEL_H_ */ 159