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/geom/part/g_part.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  * Copyright (c) 2006-2008 Marcel Moolenaar
    3  * All rights reserved.
    4  *
    5  * Redistribution and use in source and binary forms, with or without
    6  * modification, are permitted provided that the following conditions
    7  * are met:
    8  *
    9  * 1. Redistributions of source code must retain the above copyright
   10  *    notice, this list of conditions and the following disclaimer.
   11  * 2. Redistributions in binary form must reproduce the above copyright
   12  *    notice, this list of conditions and the following disclaimer in the
   13  *    documentation and/or other materials provided with the distribution.
   14  *
   15  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
   16  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   17  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
   18  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
   19  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
   20  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
   21  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
   22  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
   23  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
   24  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
   25  *
   26  * $FreeBSD: releng/8.0/sys/geom/part/g_part.h 188705 2009-02-17 04:12:10Z marcel $
   27  */
   28 
   29 #ifndef _GEOM_PART_H_
   30 #define _GEOM_PART_H_
   31 
   32 #define G_PART_TRACE(args)      g_trace args
   33 
   34 #define G_PART_PROBE_PRI_LOW    -10
   35 #define G_PART_PROBE_PRI_NORM   -5
   36 #define G_PART_PROBE_PRI_HIGH   0
   37 
   38 enum g_part_alias {
   39         G_PART_ALIAS_APPLE_HFS,         /* An HFS file system entry. */
   40         G_PART_ALIAS_EFI,               /* A EFI system partition entry. */
   41         G_PART_ALIAS_FREEBSD,           /* A BSD labeled partition entry. */
   42         G_PART_ALIAS_FREEBSD_BOOT,      /* A FreeBSD boot partition entry. */
   43         G_PART_ALIAS_FREEBSD_SWAP,      /* A swap partition entry. */
   44         G_PART_ALIAS_FREEBSD_UFS,       /* A UFS/UFS2 file system entry. */
   45         G_PART_ALIAS_FREEBSD_VINUM,     /* A Vinum partition entry. */
   46         G_PART_ALIAS_FREEBSD_ZFS,       /* A ZFS file system entry. */
   47         G_PART_ALIAS_MBR,               /* A MBR (extended) partition entry. */
   48         /* Keep the following last */
   49         G_PART_ALIAS_COUNT
   50 };
   51 
   52 const char *g_part_alias_name(enum g_part_alias);
   53 
   54 /* G_PART scheme (KOBJ class). */
   55 struct g_part_scheme {
   56         KOBJ_CLASS_FIELDS;
   57         size_t          gps_entrysz;
   58         int             gps_minent;
   59         int             gps_maxent;
   60         int             gps_bootcodesz;
   61         TAILQ_ENTRY(g_part_scheme) scheme_list;
   62 };
   63 
   64 struct g_part_entry {
   65         LIST_ENTRY(g_part_entry) gpe_entry;
   66         struct g_provider *gpe_pp;      /* Corresponding provider. */
   67         off_t           gpe_offset;     /* Byte offset. */
   68         quad_t          gpe_start;      /* First LBA of partition. */
   69         quad_t          gpe_end;        /* Last LBA of partition. */
   70         int             gpe_index;
   71         int             gpe_created:1;  /* Entry is newly created. */
   72         int             gpe_deleted:1;  /* Entry has been deleted. */
   73         int             gpe_modified:1; /* Entry has been modified. */
   74         int             gpe_internal:1; /* Entry is not a used entry. */
   75 };
   76 
   77 /* G_PART table (KOBJ instance). */
   78 struct g_part_table {
   79         KOBJ_FIELDS;
   80         struct g_part_scheme *gpt_scheme;
   81         struct g_geom   *gpt_gp;
   82         LIST_HEAD(, g_part_entry) gpt_entry;
   83         quad_t          gpt_first;      /* First allocatable LBA */
   84         quad_t          gpt_last;       /* Last allocatable LBA */
   85         int             gpt_entries;
   86         /*
   87          * gpt_smhead and gpt_smtail are bitmaps representing the first
   88          * 32 sectors on the disk (gpt_smhead) and the last 32 sectors
   89          * on the disk (gpt_smtail). These maps are used by the commit
   90          * verb to clear sectors previously used by a scheme after the
   91          * partitioning scheme has been destroyed.
   92          */
   93         uint32_t        gpt_smhead;
   94         uint32_t        gpt_smtail;
   95         /*
   96          * gpt_sectors and gpt_heads are the fixed or synchesized number
   97          * of sectors per track and heads (resp) that make up a disks
   98          * geometry. This is to support partitioning schemes as well as
   99          * file systems that work on a geometry. The MBR scheme and the
  100          * MS-DOS (FAT) file system come to mind.
  101          * We keep track of whether the geometry is fixed or synchesized
  102          * so that a partitioning scheme can correct the synthesized
  103          * geometry, based on the on-disk metadata.
  104          */
  105         uint32_t        gpt_sectors;
  106         uint32_t        gpt_heads;
  107 
  108         int             gpt_depth;      /* Sub-partitioning level. */
  109         int             gpt_isleaf:1;   /* Cannot be sub-partitioned. */
  110         int             gpt_created:1;  /* Newly created. */
  111         int             gpt_modified:1; /* Table changes have been made. */
  112         int             gpt_opened:1;   /* Permissions obtained. */
  113         int             gpt_fixgeom:1;  /* Geometry is fixed. */
  114 };
  115 
  116 struct g_part_entry *g_part_new_entry(struct g_part_table *, int, quad_t,
  117     quad_t);
  118 
  119 enum g_part_ctl {
  120         G_PART_CTL_NONE,
  121         G_PART_CTL_ADD,
  122         G_PART_CTL_BOOTCODE,
  123         G_PART_CTL_COMMIT,
  124         G_PART_CTL_CREATE,
  125         G_PART_CTL_DELETE,
  126         G_PART_CTL_DESTROY,
  127         G_PART_CTL_MODIFY,
  128         G_PART_CTL_MOVE,
  129         G_PART_CTL_RECOVER,
  130         G_PART_CTL_RESIZE,
  131         G_PART_CTL_SET,
  132         G_PART_CTL_UNDO,
  133         G_PART_CTL_UNSET
  134 };
  135 
  136 /* G_PART ctlreq parameters. */
  137 #define G_PART_PARM_ENTRIES     0x0001
  138 #define G_PART_PARM_FLAGS       0x0002
  139 #define G_PART_PARM_GEOM        0x0004
  140 #define G_PART_PARM_INDEX       0x0008
  141 #define G_PART_PARM_LABEL       0x0010
  142 #define G_PART_PARM_OUTPUT      0x0020
  143 #define G_PART_PARM_PROVIDER    0x0040
  144 #define G_PART_PARM_SCHEME      0x0080
  145 #define G_PART_PARM_SIZE        0x0100
  146 #define G_PART_PARM_START       0x0200
  147 #define G_PART_PARM_TYPE        0x0400
  148 #define G_PART_PARM_VERSION     0x0800
  149 #define G_PART_PARM_BOOTCODE    0x1000
  150 #define G_PART_PARM_ATTRIB      0x2000
  151 
  152 struct g_part_parms {
  153         unsigned int    gpp_parms;
  154         unsigned int    gpp_entries;
  155         const char      *gpp_flags;
  156         struct g_geom   *gpp_geom;
  157         unsigned int    gpp_index;
  158         const char      *gpp_label;
  159         struct g_provider *gpp_provider;
  160         struct g_part_scheme *gpp_scheme;
  161         quad_t          gpp_size;
  162         quad_t          gpp_start;
  163         const char      *gpp_type;
  164         unsigned int    gpp_version;
  165         const void      *gpp_codeptr;
  166         unsigned int    gpp_codesize;
  167         const char      *gpp_attrib;
  168 };
  169 
  170 void g_part_geometry_heads(off_t, u_int, off_t *, u_int *);
  171 
  172 int g_part_modevent(module_t, int, struct g_part_scheme *);
  173 
  174 #define G_PART_SCHEME_DECLARE(name)                             \
  175     static int name##_modevent(module_t mod, int tp, void *d)   \
  176     {                                                           \
  177         return (g_part_modevent(mod, tp, d));                   \
  178     }                                                           \
  179     static moduledata_t name##_mod = {                          \
  180         #name,                                                  \
  181         name##_modevent,                                        \
  182         &name##_scheme                                          \
  183     };                                                          \
  184     DECLARE_MODULE(name, name##_mod, SI_SUB_DRIVERS, SI_ORDER_ANY)
  185 
  186 #endif /* !_GEOM_PART_H_ */

Cache object: 0379c7c748c8136db75ac628ff3b400d


[ 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.