diskslice.h

00001 /*-
00002  * Copyright (c) 1994 Bruce D. Evans.
00003  * All rights reserved.
00004  *
00005  * Redistribution and use in source and binary forms, with or without
00006  * modification, are permitted provided that the following conditions
00007  * are met:
00008  * 1. Redistributions of source code must retain the above copyright
00009  *    notice, this list of conditions and the following disclaimer.
00010  * 2. Redistributions in binary form must reproduce the above copyright
00011  *    notice, this list of conditions and the following disclaimer in the
00012  *    documentation and/or other materials provided with the distribution.
00013  *
00014  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
00015  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00016  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
00017  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
00018  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
00019  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
00020  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
00021  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
00022  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
00023  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
00024  * SUCH DAMAGE.
00025  *
00026  * $FreeBSD: src/sys/sys/diskslice.h,v 1.36.2.1 2001/01/29 01:50:50 ken Exp $
00027  */
00028 
00029 #ifndef _SYS_DISKSLICE_H_
00030 #define _SYS_DISKSLICE_H_
00031 
00032 #ifndef _KERNEL
00033 #include <sys/types.h>
00034 #endif
00035 #include <sys/ioccom.h>
00036 
00037 #define BASE_SLICE              2
00038 #define COMPATIBILITY_SLICE     0
00039 #define DIOCGSLICEINFO          _IOR('d', 111, struct diskslices)
00040 #define DIOCSYNCSLICEINFO       _IOW('d', 112, int)
00041 #define MAX_SLICES              32
00042 #define WHOLE_DISK_SLICE        1
00043 
00044 struct  diskslice {
00045         u_long  ds_offset;              /* starting sector */
00046         u_long  ds_size;                /* number of sectors */
00047         int     ds_type;                /* (foreign) slice type */
00048 #ifdef PC98
00049         int     ds_subtype;             /* sub slice type */
00050         u_char  ds_name[16];            /* slice name */
00051 #endif
00052         struct disklabel *ds_label;     /* BSD label, if any */
00053         void    *ds_dev;                /* devfs token for raw whole slice */
00054 #ifdef MAXPARTITIONS                    /* XXX don't depend on disklabel.h */
00055 #if MAXPARTITIONS !=    8               /* but check consistency if possible */
00056 #error "inconsistent MAXPARTITIONS"
00057 #endif
00058 #else
00059 #define MAXPARTITIONS   8
00060 #endif
00061         void    *ds_devs[MAXPARTITIONS];        /* XXX s.b. in label */
00062         u_char  ds_openmask;            /* devs open */
00063         u_char  ds_wlabel;              /* nonzero if label is writable */
00064 };
00065 
00066 struct diskslices {
00067         struct cdevsw *dss_cdevsw;      /* for containing device */
00068         int     dss_first_bsd_slice;    /* COMPATIBILITY_SLICE is mapped here */
00069         u_int   dss_nslices;            /* actual dimension of dss_slices[] */
00070         u_int   dss_oflags;             /* copy of flags for "first" open */
00071         int     dss_secmult;            /* block to sector multiplier */
00072         int     dss_secshift;           /* block to sector shift (or -1) */
00073         int     dss_secsize;            /* sector size */
00074         struct diskslice
00075                 dss_slices[MAX_SLICES]; /* actually usually less */
00076 };
00077 
00078 #ifdef _KERNEL
00079 
00080 /* Flags for dsopen(). */
00081 #define DSO_NOLABELS    1
00082 #define DSO_ONESLICE    2
00083 #define DSO_COMPATLABEL 4
00084 
00085 #define dsgetlabel(dev, ssp)    (ssp->dss_slices[dkslice(dev)].ds_label)
00086 
00087 struct buf;
00088 struct disklabel;
00089 
00090 int     dscheck __P((struct buf *bp, struct diskslices *ssp));
00091 void    dsclose __P((dev_t dev, int mode, struct diskslices *ssp));
00092 void    dsgone __P((struct diskslices **sspp));
00093 int     dsinit __P((dev_t dev, struct disklabel *lp,
00094                      struct diskslices **sspp));
00095 int     dsioctl __P((dev_t dev, u_long cmd, caddr_t data,
00096                      int flags, struct diskslices **sspp));
00097 int     dsisopen __P((struct diskslices *ssp));
00098 struct diskslices *dsmakeslicestruct __P((int nslices, struct disklabel *lp));
00099 char    *dsname __P((dev_t dev, int unit, int slice, int part,
00100                      char *partname));
00101 int     dsopen __P((dev_t dev, int mode, u_int flags,
00102                     struct diskslices **sspp, struct disklabel *lp));
00103 int     dssize __P((dev_t dev, struct diskslices **sspp));
00104 
00105 #endif /* _KERNEL */
00106 
00107 #endif /* !_SYS_DISKSLICE_H_ */

Generated on Wed Apr 28 17:49:33 2004 for Ubixos by doxygen 1.3.3