The Design and Implementation of the FreeBSD Operating System, Second Edition
Now available: The Design and Implementation of the FreeBSD Operating System (Second Edition)


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]

FreeBSD/Linux Kernel Cross Reference
sys/device/disk_status.h

Version: -  FREEBSD  -  FREEBSD-13-STABLE  -  FREEBSD-13-0  -  FREEBSD-12-STABLE  -  FREEBSD-12-0  -  FREEBSD-11-STABLE  -  FREEBSD-11-0  -  FREEBSD-10-STABLE  -  FREEBSD-10-0  -  FREEBSD-9-STABLE  -  FREEBSD-9-0  -  FREEBSD-8-STABLE  -  FREEBSD-8-0  -  FREEBSD-7-STABLE  -  FREEBSD-7-0  -  FREEBSD-6-STABLE  -  FREEBSD-6-0  -  FREEBSD-5-STABLE  -  FREEBSD-5-0  -  FREEBSD-4-STABLE  -  FREEBSD-3-STABLE  -  FREEBSD22  -  l41  -  OPENBSD  -  linux-2.6  -  MK84  -  PLAN9  -  xnu-8792 
SearchContext: -  none  -  3  -  10 

    1 /* 
    2  * Mach Operating System
    3  * Copyright (c) 1991,1990,1989 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:        disk_status.h,v $
   29  * Revision 2.7  93/03/09  10:54:16  danner
   30  *      Horrible alpha-specific fix.  See apologies in the code.
   31  *      [93/02/26            af]
   32  * 
   33  * Revision 2.5.1.1  92/12/10  17:33:17  af
   34  *      Changed longs into ints, which is what they are anyways.
   35  *      When we'll have a disk 1 terabyte big we'll see about it.
   36  *      [92/08/02            af]
   37  * 
   38  * Revision 2.5  92/05/21  17:09:16  jfriedl
   39  *      Appended 'U' to long constant.
   40  *      [92/05/21  15:40:18  jfriedl]
   41  * 
   42  * Revision 2.4  92/04/03  12:08:31  rpd
   43  *      We add one more partition so that we can point to the "whole"
   44  *      disk.  It is at slot MAXPARTITIONS.
   45  *      [92/04/01            rvb]
   46  * 
   47  * Revision 2.3  91/05/14  15:43:50  mrt
   48  *      Correcting copyright
   49  * 
   50  * Revision 2.2  91/05/13  06:02:21  af
   51  *      Created, starting from Reno's disklabel.h (copyright included).
   52  *      [91/05/03            af]
   53  * 
   54  */
   55 /*
   56  * Copyright (c) 1987, 1988 Regents of the University of California.
   57  * All rights reserved.
   58  *
   59  * Redistribution and use in source and binary forms are permitted
   60  * provided that the above copyright notice and this paragraph are
   61  * duplicated in all such forms and that any documentation,
   62  * advertising materials, and other materials related to such
   63  * distribution and use acknowledge that the software was developed
   64  * by the University of California, Berkeley.  The name of the
   65  * University may not be used to endorse or promote products derived
   66  * from this software without specific prior written permission.
   67  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
   68  * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
   69  * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
   70  *
   71  *      @(#)disklabel.h 7.10 (Berkeley) 6/27/88
   72  */
   73 
   74 #ifndef _DISK_STATUS_H_
   75 #define _DISK_STATUS_H_
   76 
   77 /*
   78  * Each disk has a label which includes information about the hardware
   79  * disk geometry, filesystem partitions, and drive specific information.
   80  * The label is in block 0 or 1, possibly offset from the beginning
   81  * to leave room for a bootstrap, etc.
   82  */
   83 
   84 #define LABELSECTOR     0                       /* sector containing label */
   85 #define LABELOFFSET     64                      /* offset of label in sector */
   86 #define DISKMAGIC       ((unsigned int) 0x82564557U)    /* The disk magic number */
   87 #ifndef MAXPARTITIONS
   88 #define MAXPARTITIONS   8
   89 #endif
   90 
   91 
   92 #ifndef LOCORE
   93 struct disklabel {
   94         unsigned int    d_magic;                /* the magic number */
   95         short   d_type;                 /* drive type */
   96         short   d_subtype;              /* controller/d_type specific */
   97         char    d_typename[16];         /* type name, e.g. "eagle" */
   98         /* 
   99          * d_packname contains the pack identifier and is returned when
  100          * the disklabel is read off the disk or in-core copy.
  101          * d_boot0 and d_boot1 are the (optional) names of the
  102          * primary (block 0) and secondary (block 1-15) bootstraps
  103          * as found in /usr/mdec.  These are returned when using
  104          * getdiskbyname(3) to retrieve the values from /etc/disktab.
  105          */
  106 #if defined(KERNEL) || defined(STANDALONE)
  107         char    d_packname[16];                 /* pack identifier */ 
  108 #else
  109         union {
  110                 char    un_d_packname[16];      /* pack identifier */ 
  111                 struct {
  112                         char *un_d_boot0;       /* primary bootstrap name */
  113                         char *un_d_boot1;       /* secondary bootstrap name */
  114                 } un_b; 
  115         } d_un; 
  116 #define d_packname      d_un.un_d_packname
  117 #define d_boot0         d_un.un_b.un_d_boot0
  118 #define d_boot1         d_un.un_b.un_d_boot1
  119 #endif  /* ! KERNEL or STANDALONE */
  120                         /* disk geometry: */
  121         unsigned int    d_secsize;              /* # of bytes per sector */
  122         unsigned int    d_nsectors;             /* # of data sectors per track */
  123         unsigned int    d_ntracks;              /* # of tracks per cylinder */
  124         unsigned int    d_ncylinders;           /* # of data cylinders per unit */
  125         unsigned int    d_secpercyl;            /* # of data sectors per cylinder */
  126         unsigned int    d_secperunit;           /* # of data sectors per unit */
  127         /*
  128          * Spares (bad sector replacements) below
  129          * are not counted in d_nsectors or d_secpercyl.
  130          * Spare sectors are assumed to be physical sectors
  131          * which occupy space at the end of each track and/or cylinder.
  132          */
  133         unsigned short  d_sparespertrack;       /* # of spare sectors per track */
  134         unsigned short  d_sparespercyl;         /* # of spare sectors per cylinder */
  135         /*
  136          * Alternate cylinders include maintenance, replacement,
  137          * configuration description areas, etc.
  138          */
  139         unsigned int    d_acylinders;           /* # of alt. cylinders per unit */
  140 
  141                         /* hardware characteristics: */
  142         /*
  143          * d_interleave, d_trackskew and d_cylskew describe perturbations
  144          * in the media format used to compensate for a slow controller.
  145          * Interleave is physical sector interleave, set up by the formatter
  146          * or controller when formatting.  When interleaving is in use,
  147          * logically adjacent sectors are not physically contiguous,
  148          * but instead are separated by some number of sectors.
  149          * It is specified as the ratio of physical sectors traversed
  150          * per logical sector.  Thus an interleave of 1:1 implies contiguous
  151          * layout, while 2:1 implies that logical sector 0 is separated
  152          * by one sector from logical sector 1.
  153          * d_trackskew is the offset of sector 0 on track N
  154          * relative to sector 0 on track N-1 on the same cylinder.
  155          * Finally, d_cylskew is the offset of sector 0 on cylinder N
  156          * relative to sector 0 on cylinder N-1.
  157          */
  158         unsigned short  d_rpm;                  /* rotational speed */
  159         unsigned short  d_interleave;           /* hardware sector interleave */
  160         unsigned short  d_trackskew;            /* sector 0 skew, per track */
  161         unsigned short  d_cylskew;              /* sector 0 skew, per cylinder */
  162         unsigned int    d_headswitch;           /* head switch time, usec */
  163         unsigned int    d_trkseek;              /* track-to-track seek, usec */
  164         unsigned int    d_flags;                /* generic flags */
  165 #define NDDATA 5
  166         unsigned int    d_drivedata[NDDATA];    /* drive-type specific information */
  167 #define NSPARE 5
  168         unsigned int    d_spare[NSPARE];        /* reserved for future use */
  169         unsigned int    d_magic2;               /* the magic number (again) */
  170         unsigned short  d_checksum;             /* xor of data incl. partitions */
  171 
  172                         /* filesystem and partition information: */
  173         unsigned short  d_npartitions;          /* number of partitions in following */
  174         unsigned int    d_bbsize;               /* size of boot area at sn0, bytes */
  175         unsigned int    d_sbsize;               /* max size of fs superblock, bytes */
  176         struct  partition {             /* the partition table */
  177                 unsigned int    p_size;         /* number of sectors in partition */
  178                 unsigned int    p_offset;       /* starting sector */
  179                 unsigned int    p_fsize;        /* filesystem basic fragment size */
  180                 unsigned char   p_fstype;       /* filesystem type, see below */
  181                 unsigned char   p_frag;         /* filesystem fragments per block */
  182                 unsigned short  p_cpg;          /* filesystem cylinders per group */
  183         } d_partitions[MAXPARTITIONS+1];        /* actually may be more */
  184 
  185 #if     defined(alpha) && defined(KERNEL)
  186         /*
  187          * Disgusting hack. If this structure contains a pointer,
  188          * as it does for non-kernel, then the compiler rounds
  189          * the size to make it pointer-sized properly (arrays of..).
  190          * But if I define the pointer for the kernel then instances
  191          * of this structure better be aligned otherwise picking
  192          * up a short might be done by too-smart compilers (GCC) with
  193          * a load-long instruction expecting the short to be aligned.
  194          * I bet the OSF folks stomped into this too, since they use
  195          * the same disgusting hack below.. [whatelse can I do ??]
  196          */
  197         int     bugfix;
  198 #endif
  199 };
  200 #else LOCORE
  201         /*
  202          * offsets for asm boot files.
  203          */
  204         .set    d_secsize,40
  205         .set    d_nsectors,44
  206         .set    d_ntracks,48
  207         .set    d_ncylinders,52
  208         .set    d_secpercyl,56
  209         .set    d_secperunit,60
  210         .set    d_end_,276              /* size of disk label */
  211 #endif LOCORE
  212 
  213 /* d_type values: */
  214 #define DTYPE_SMD               1               /* SMD, XSMD; VAX hp/up */
  215 #define DTYPE_MSCP              2               /* MSCP */
  216 #define DTYPE_DEC               3               /* other DEC (rk, rl) */
  217 #define DTYPE_SCSI              4               /* SCSI */
  218 #define DTYPE_ESDI              5               /* ESDI interface */
  219 #define DTYPE_ST506             6               /* ST506 etc. */
  220 #define DTYPE_FLOPPY            10              /* floppy */
  221 
  222 #ifdef DKTYPENAMES
  223 static char *dktypenames[] = {
  224         "unknown",
  225         "SMD",
  226         "MSCP",
  227         "old DEC",
  228         "SCSI",
  229         "ESDI",
  230         "type 6",
  231         "type 7",
  232         "type 8",
  233         "type 9",
  234         "floppy",
  235         0
  236 };
  237 #define DKMAXTYPES      (sizeof(dktypenames) / sizeof(dktypenames[0]) - 1)
  238 #endif
  239 
  240 /*
  241  * Filesystem type and version.
  242  * Used to interpret other filesystem-specific
  243  * per-partition information.
  244  */
  245 #define FS_UNUSED       0               /* unused */
  246 #define FS_SWAP         1               /* swap */
  247 #define FS_V6           2               /* Sixth Edition */
  248 #define FS_V7           3               /* Seventh Edition */
  249 #define FS_SYSV         4               /* System V */
  250 #define FS_V71K         5               /* V7 with 1K blocks (4.1, 2.9) */
  251 #define FS_V8           6               /* Eighth Edition, 4K blocks */
  252 #define FS_BSDFFS       7               /* 4.2BSD fast file system */
  253 
  254 #ifdef  DKTYPENAMES
  255 static char *fstypenames[] = {
  256         "unused",
  257         "swap",
  258         "Version 6",
  259         "Version 7",
  260         "System V",
  261         "4.1BSD",
  262         "Eighth Edition",
  263         "4.2BSD",
  264         0
  265 };
  266 #define FSMAXTYPES      (sizeof(fstypenames) / sizeof(fstypenames[0]) - 1)
  267 #endif
  268 
  269 /*
  270  * flags shared by various drives:
  271  */
  272 #define         D_REMOVABLE     0x01            /* removable media */
  273 #define         D_ECC           0x02            /* supports ECC */
  274 #define         D_BADSECT       0x04            /* supports bad sector forw. */
  275 #define         D_RAMDISK       0x08            /* disk emulator */
  276 #define         D_CHAIN         0x10            /* can do back-back transfers */
  277 
  278 /*
  279  * Drive data for SMD.
  280  */
  281 #define d_smdflags      d_drivedata[0]
  282 #define         D_SSE           0x1             /* supports skip sectoring */
  283 #define d_mindist       d_drivedata[1]
  284 #define d_maxdist       d_drivedata[2]
  285 #define d_sdist         d_drivedata[3]
  286 
  287 /*
  288  * Drive data for ST506.
  289  */
  290 #define d_precompcyl    d_drivedata[0]
  291 #define d_gap3          d_drivedata[1]          /* used only when formatting */
  292 
  293 /*
  294  * IBM controller info (d_precompcyl used, too)
  295  */
  296 #define d_step          d_drivedata[2]
  297 
  298 #ifndef LOCORE
  299 /*
  300  * Structure used to perform a format
  301  * or other raw operation, returning data
  302  * and/or register values.
  303  * Register identification and format
  304  * are device- and driver-dependent.
  305  */
  306 struct format_op {
  307         char    *df_buf;
  308         int     df_count;               /* value-result */
  309         recnum_t        df_startblk;
  310         int     df_reg[8];              /* result */
  311 };
  312 
  313 /*
  314  * Disk-specific ioctls.
  315  */
  316                 /* get and set disklabel; DIOCGPART used internally */
  317 #define DIOCGDINFO      _IOR('d', 101, struct disklabel)/* get */
  318 #define DIOCSDINFO      _IOW('d', 102, struct disklabel)/* set */
  319 #define DIOCWDINFO      _IOW('d', 103, struct disklabel)/* set, update disk */
  320 
  321 /* do format operation, read or write */
  322 #define DIOCRFORMAT     _IOWR('d', 105, struct format_op)
  323 #define DIOCWFORMAT     _IOWR('d', 106, struct format_op)
  324 
  325 #define DIOCSSTEP       _IOW('d', 107, int)     /* set step rate */
  326 #define DIOCSRETRIES    _IOW('d', 108, int)     /* set # of retries */
  327 #define DIOCWLABEL      _IOW('d', 109, int)     /* write en/disable label */
  328 
  329 #define DIOCSBAD        _IOW('d', 110, struct dkbad)    /* set kernel dkbad */
  330 
  331 #endif LOCORE
  332 
  333 #endif  /* _DISK_STATUS_H_ */

Cache object: 505ac5634d2406318e9360381ecd9178


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]


This page is part of the FreeBSD/Linux Linux Kernel Cross-Reference, and was automatically generated using a modified version of the LXR engine.