home *** CD-ROM | disk | FTP | other *** search
/ Otherware / Otherware_1_SB_Development.iso / amiga / os / bsdss4.tz / bsdss4 / bsdss / server / sys / disklabel.h < prev    next >
Encoding:
C/C++ Source or Header  |  1992-04-22  |  11.3 KB  |  350 lines

  1. /* 
  2.  * Mach Operating System
  3.  * Copyright (c) 1992 Carnegie Mellon University
  4.  * All Rights Reserved.
  5.  * 
  6.  * Permission to use, copy, modify and distribute this software and its
  7.  * documentation is hereby granted, provided that both the copyright
  8.  * notice and this permission notice appear in all copies of the
  9.  * software, derivative works or modified versions, and any portions
  10.  * thereof, and that both notices appear in supporting documentation.
  11.  * 
  12.  * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
  13.  * CONDITION.  CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
  14.  * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
  15.  * 
  16.  * Carnegie Mellon requests users of this software to return to
  17.  * 
  18.  *  Software Distribution Coordinator  or  Software.Distribution@CS.CMU.EDU
  19.  *  School of Computer Science
  20.  *  Carnegie Mellon University
  21.  *  Pittsburgh PA 15213-3890
  22.  * 
  23.  * any improvements or extensions that they make and grant Carnegie Mellon 
  24.  * the rights to redistribute these changes.
  25.  */
  26. /*
  27.  * HISTORY
  28.  * $Log:    disklabel.h,v $
  29.  * Revision 2.1  92/04/21  17:17:11  rwd
  30.  * BSDSS
  31.  * 
  32.  *
  33.  */
  34.  
  35. /*
  36.  * Copyright (c) 1987, 1988 Regents of the University of California.
  37.  * All rights reserved.
  38.  *
  39.  * Redistribution and use in source and binary forms, with or without
  40.  * modification, are permitted provided that the following conditions
  41.  * are met:
  42.  * 1. Redistributions of source code must retain the above copyright
  43.  *    notice, this list of conditions and the following disclaimer.
  44.  * 2. Redistributions in binary form must reproduce the above copyright
  45.  *    notice, this list of conditions and the following disclaimer in the
  46.  *    documentation and/or other materials provided with the distribution.
  47.  * 3. All advertising materials mentioning features or use of this software
  48.  *    must display the following acknowledgement:
  49.  *    This product includes software developed by the University of
  50.  *    California, Berkeley and its contributors.
  51.  * 4. Neither the name of the University nor the names of its contributors
  52.  *    may be used to endorse or promote products derived from this software
  53.  *    without specific prior written permission.
  54.  *
  55.  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
  56.  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  57.  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  58.  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
  59.  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  60.  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  61.  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  62.  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  63.  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  64.  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  65.  * SUCH DAMAGE.
  66.  *
  67.  *    @(#)disklabel.h    7.19 (Berkeley) 5/7/91
  68.  */
  69.  
  70. /*
  71.  * Disk description table, see disktab(5)
  72.  */
  73. #define    _PATH_DISKTAB    "/etc/disktab"
  74. #define    DISKTAB        "/etc/disktab"        /* deprecated */
  75.  
  76. /*
  77.  * Each disk has a label which includes information about the hardware
  78.  * disk geometry, filesystem partitions, and drive specific information.
  79.  * The label is in block 0 or 1, possibly offset from the beginning
  80.  * to leave room for a bootstrap, etc.
  81.  */
  82.  
  83. /* XXX these should be defined per controller (or drive) elsewhere, not here! */
  84. #ifdef i386
  85. #define LABELSECTOR    1            /* sector containing label */
  86. #define LABELOFFSET    0            /* offset of label in sector */
  87. #endif
  88.  
  89. #ifndef    LABELSECTOR
  90. #define LABELSECTOR    0            /* sector containing label */
  91. #endif
  92.  
  93. #ifndef    LABELOFFSET
  94. #define LABELOFFSET    64            /* offset of label in sector */
  95. #endif
  96.  
  97. #define DISKMAGIC    ((u_long) 0x82564557)    /* The disk magic number */
  98. #ifndef MAXPARTITIONS
  99. #define    MAXPARTITIONS    8
  100. #endif
  101.  
  102.  
  103. #ifndef LOCORE
  104. struct disklabel {
  105.     u_long    d_magic;        /* the magic number */
  106.     short    d_type;            /* drive type */
  107.     short    d_subtype;        /* controller/d_type specific */
  108.     char    d_typename[16];        /* type name, e.g. "eagle" */
  109.     /* 
  110.      * d_packname contains the pack identifier and is returned when
  111.      * the disklabel is read off the disk or in-core copy.
  112.      * d_boot0 and d_boot1 are the (optional) names of the
  113.      * primary (block 0) and secondary (block 1-15) bootstraps
  114.      * as found in /usr/mdec.  These are returned when using
  115.      * getdiskbyname(3) to retrieve the values from /etc/disktab.
  116.      */
  117. #if defined(KERNEL) || defined(STANDALONE)
  118.     char    d_packname[16];            /* pack identifier */ 
  119. #else
  120.     union {
  121.         char    un_d_packname[16];    /* pack identifier */ 
  122.         struct {
  123.             char *un_d_boot0;    /* primary bootstrap name */
  124.             char *un_d_boot1;    /* secondary bootstrap name */
  125.         } un_b; 
  126.     } d_un; 
  127. #define d_packname    d_un.un_d_packname
  128. #define d_boot0        d_un.un_b.un_d_boot0
  129. #define d_boot1        d_un.un_b.un_d_boot1
  130. #endif    /* ! KERNEL or STANDALONE */
  131.             /* disk geometry: */
  132.     u_long    d_secsize;        /* # of bytes per sector */
  133.     u_long    d_nsectors;        /* # of data sectors per track */
  134.     u_long    d_ntracks;        /* # of tracks per cylinder */
  135.     u_long    d_ncylinders;        /* # of data cylinders per unit */
  136.     u_long    d_secpercyl;        /* # of data sectors per cylinder */
  137.     u_long    d_secperunit;        /* # of data sectors per unit */
  138.     /*
  139.      * Spares (bad sector replacements) below
  140.      * are not counted in d_nsectors or d_secpercyl.
  141.      * Spare sectors are assumed to be physical sectors
  142.      * which occupy space at the end of each track and/or cylinder.
  143.      */
  144.     u_short    d_sparespertrack;    /* # of spare sectors per track */
  145.     u_short    d_sparespercyl;        /* # of spare sectors per cylinder */
  146.     /*
  147.      * Alternate cylinders include maintenance, replacement,
  148.      * configuration description areas, etc.
  149.      */
  150.     u_long    d_acylinders;        /* # of alt. cylinders per unit */
  151.  
  152.             /* hardware characteristics: */
  153.     /*
  154.      * d_interleave, d_trackskew and d_cylskew describe perturbations
  155.      * in the media format used to compensate for a slow controller.
  156.      * Interleave is physical sector interleave, set up by the formatter
  157.      * or controller when formatting.  When interleaving is in use,
  158.      * logically adjacent sectors are not physically contiguous,
  159.      * but instead are separated by some number of sectors.
  160.      * It is specified as the ratio of physical sectors traversed
  161.      * per logical sector.  Thus an interleave of 1:1 implies contiguous
  162.      * layout, while 2:1 implies that logical sector 0 is separated
  163.      * by one sector from logical sector 1.
  164.      * d_trackskew is the offset of sector 0 on track N
  165.      * relative to sector 0 on track N-1 on the same cylinder.
  166.      * Finally, d_cylskew is the offset of sector 0 on cylinder N
  167.      * relative to sector 0 on cylinder N-1.
  168.      */
  169.     u_short    d_rpm;            /* rotational speed */
  170.     u_short    d_interleave;        /* hardware sector interleave */
  171.     u_short    d_trackskew;        /* sector 0 skew, per track */
  172.     u_short    d_cylskew;        /* sector 0 skew, per cylinder */
  173.     u_long    d_headswitch;        /* head switch time, usec */
  174.     u_long    d_trkseek;        /* track-to-track seek, usec */
  175.     u_long    d_flags;        /* generic flags */
  176. #define NDDATA 5
  177.     u_long    d_drivedata[NDDATA];    /* drive-type specific information */
  178. #define NSPARE 5
  179.     u_long    d_spare[NSPARE];    /* reserved for future use */
  180.     u_long    d_magic2;        /* the magic number (again) */
  181.     u_short    d_checksum;        /* xor of data incl. partitions */
  182.  
  183.             /* filesystem and partition information: */
  184.     u_short    d_npartitions;        /* number of partitions in following */
  185.     u_long    d_bbsize;        /* size of boot area at sn0, bytes */
  186.     u_long    d_sbsize;        /* max size of fs superblock, bytes */
  187.     struct    partition {        /* the partition table */
  188.         u_long    p_size;        /* number of sectors in partition */
  189.         u_long    p_offset;    /* starting sector */
  190.         u_long    p_fsize;    /* filesystem basic fragment size */
  191.         u_char    p_fstype;    /* filesystem type, see below */
  192.         u_char    p_frag;        /* filesystem fragments per block */
  193.         u_short    p_cpg;        /* filesystem cylinders per group */
  194.     } d_partitions[MAXPARTITIONS];    /* actually may be more */
  195. };
  196. #else LOCORE
  197.     /*
  198.      * offsets for asm boot files.
  199.      */
  200.     .set    d_secsize,40
  201.     .set    d_nsectors,44
  202.     .set    d_ntracks,48
  203.     .set    d_ncylinders,52
  204.     .set    d_secpercyl,56
  205.     .set    d_secperunit,60
  206.     .set    d_end_,276        /* size of disk label */
  207. #endif LOCORE
  208.  
  209. /* d_type values: */
  210. #define    DTYPE_SMD        1        /* SMD, XSMD; VAX hp/up */
  211. #define    DTYPE_MSCP        2        /* MSCP */
  212. #define    DTYPE_DEC        3        /* other DEC (rk, rl) */
  213. #define    DTYPE_SCSI        4        /* SCSI */
  214. #define    DTYPE_ESDI        5        /* ESDI interface */
  215. #define    DTYPE_ST506        6        /* ST506 etc. */
  216. #define    DTYPE_FLOPPY        10        /* floppy */
  217.  
  218. #ifdef DKTYPENAMES
  219. static char *dktypenames[] = {
  220.     "unknown",
  221.     "SMD",
  222.     "MSCP",
  223.     "old DEC",
  224.     "SCSI",
  225.     "ESDI",
  226.     "ST506",
  227.     "type 7",
  228.     "type 8",
  229.     "type 9",
  230.     "floppy",
  231.     0
  232. };
  233. #define DKMAXTYPES    (sizeof(dktypenames) / sizeof(dktypenames[0]) - 1)
  234. #endif
  235.  
  236. /*
  237.  * Filesystem type and version.
  238.  * Used to interpret other filesystem-specific
  239.  * per-partition information.
  240.  */
  241. #define    FS_UNUSED    0        /* unused */
  242. #define    FS_SWAP        1        /* swap */
  243. #define    FS_V6        2        /* Sixth Edition */
  244. #define    FS_V7        3        /* Seventh Edition */
  245. #define    FS_SYSV        4        /* System V */
  246. #define    FS_V71K        5        /* V7 with 1K blocks (4.1, 2.9) */
  247. #define    FS_V8        6        /* Eighth Edition, 4K blocks */
  248. #define    FS_BSDFFS    7        /* 4.2BSD fast file system */
  249. #define    FS_MSDOS    8        /* MSDOS file system */
  250.  
  251. #ifdef    DKTYPENAMES
  252. static char *fstypenames[] = {
  253.     "unused",
  254.     "swap",
  255.     "Version 6",
  256.     "Version 7",
  257.     "System V",
  258.     "4.1BSD",
  259.     "Eighth Edition",
  260.     "4.2BSD",
  261.     "MSDOS",
  262.     0
  263. };
  264. #define FSMAXTYPES    (sizeof(fstypenames) / sizeof(fstypenames[0]) - 1)
  265. #endif
  266.  
  267. /*
  268.  * flags shared by various drives:
  269.  */
  270. #define        D_REMOVABLE    0x01        /* removable media */
  271. #define        D_ECC        0x02        /* supports ECC */
  272. #define        D_BADSECT    0x04        /* supports bad sector forw. */
  273. #define        D_RAMDISK    0x08        /* disk emulator */
  274. #define        D_CHAIN        0x10        /* can do back-back transfers */
  275.  
  276. /*
  277.  * Drive data for SMD.
  278.  */
  279. #define    d_smdflags    d_drivedata[0]
  280. #define        D_SSE        0x1        /* supports skip sectoring */
  281. #define    d_mindist    d_drivedata[1]
  282. #define    d_maxdist    d_drivedata[2]
  283. #define    d_sdist        d_drivedata[3]
  284.  
  285. /*
  286.  * Drive data for ST506.
  287.  */
  288. #define d_precompcyl    d_drivedata[0]
  289. #define d_gap3        d_drivedata[1]        /* used only when formatting */
  290.  
  291. /*
  292.  * Drive data for SCSI.
  293.  */
  294. #define    d_blind        d_drivedata[0]
  295.  
  296. #ifndef LOCORE
  297. /*
  298.  * Structure used to perform a format
  299.  * or other raw operation, returning data
  300.  * and/or register values.
  301.  * Register identification and format
  302.  * are device- and driver-dependent.
  303.  */
  304. struct format_op {
  305.     char    *df_buf;
  306.     int    df_count;        /* value-result */
  307.     daddr_t    df_startblk;
  308.     int    df_reg[8];        /* result */
  309. };
  310.  
  311. /*
  312.  * Structure used internally to retrieve
  313.  * information about a partition on a disk.
  314.  */
  315. struct partinfo {
  316.     struct disklabel *disklab;
  317.     struct partition *part;
  318. };
  319.  
  320. /*
  321.  * Disk-specific ioctls.
  322.  */
  323.         /* get and set disklabel; DIOCGPART used internally */
  324. #define DIOCGDINFO    _IOR('d', 101, struct disklabel)/* get */
  325. #define DIOCSDINFO    _IOW('d', 102, struct disklabel)/* set */
  326. #define DIOCWDINFO    _IOW('d', 103, struct disklabel)/* set, update disk */
  327. #define DIOCGPART    _IOW('d', 104, struct partinfo)    /* get partition */
  328.  
  329. /* do format operation, read or write */
  330. #define DIOCRFORMAT    _IOWR('d', 105, struct format_op)
  331. #define DIOCWFORMAT    _IOWR('d', 106, struct format_op)
  332.  
  333. #define DIOCSSTEP    _IOW('d', 107, int)    /* set step rate */
  334. #define DIOCSRETRIES    _IOW('d', 108, int)    /* set # of retries */
  335. #define DIOCWLABEL    _IOW('d', 109, int)    /* write en/disable label */
  336.  
  337. #define DIOCSBAD    _IOW('d', 110, struct dkbad)    /* set kernel dkbad */
  338.  
  339. #endif LOCORE
  340.  
  341. #if !defined(KERNEL) && !defined(LOCORE)
  342.  
  343. #include <sys/cdefs.h>
  344.  
  345. __BEGIN_DECLS
  346. struct disklabel *getdiskbyname __P((const char *));
  347. __END_DECLS
  348.  
  349. #endif
  350.