g_part.h (9199c09a159c4e3e98c212d4eec1edc5252d9e33) g_part.h (1d3aed33e8fe3530c44df6fb4a6d196684566bf9)
1/*-
1/*-
2 * Copyright (c) 2006-2008 Marcel Moolenaar
2 * Copyright (c) 2006, 2007 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.

--- 20 unchanged lines hidden (view full) ---

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
38enum g_part_alias {
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.

--- 20 unchanged lines hidden (view full) ---

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
38enum g_part_alias {
39 G_PART_ALIAS_APPLE_BOOT, /* An Apple boot partition entry. */
40 G_PART_ALIAS_APPLE_HFS, /* An HFS+ file system entry. */
41 G_PART_ALIAS_APPLE_LABEL, /* An Apple label partition entry. */
42 G_PART_ALIAS_APPLE_RAID, /* An Apple RAID partition entry. */
43 G_PART_ALIAS_APPLE_RAID_OFFLINE,/* An Apple RAID (offline) part entry.*/
44 G_PART_ALIAS_APPLE_TV_RECOVERY, /* An Apple TV recovery part entry. */
45 G_PART_ALIAS_APPLE_UFS, /* An Apple UFS partition entry. */
46 G_PART_ALIAS_EFI, /* A EFI system partition entry. */
47 G_PART_ALIAS_FREEBSD, /* A BSD labeled partition entry. */
39 G_PART_ALIAS_EFI, /* A EFI system partition entry. */
40 G_PART_ALIAS_FREEBSD, /* A BSD labeled partition entry. */
48 G_PART_ALIAS_FREEBSD_BOOT, /* A FreeBSD boot partition entry. */
49 G_PART_ALIAS_FREEBSD_SWAP, /* A swap partition entry. */
50 G_PART_ALIAS_FREEBSD_UFS, /* A UFS/UFS2 file system entry. */
51 G_PART_ALIAS_FREEBSD_VINUM, /* A Vinum partition entry. */
41 G_PART_ALIAS_FREEBSD_SWAP, /* A swap partition entry. */
42 G_PART_ALIAS_FREEBSD_UFS, /* A UFS/UFS2 file system entry. */
43 G_PART_ALIAS_FREEBSD_VINUM, /* A Vinum partition entry. */
52 G_PART_ALIAS_FREEBSD_ZFS, /* A ZFS file system entry. */
53 G_PART_ALIAS_MBR, /* A MBR (extended) partition entry. */
44 G_PART_ALIAS_MBR, /* A MBR (extended) partition entry. */
54 G_PART_ALIAS_LINUX_DATA, /* A Linux data partition entry. */
55 G_PART_ALIAS_LINUX_LVM, /* A Linux LVM partition entry. */
56 G_PART_ALIAS_LINUX_RAID, /* A Linux RAID partition entry. */
57 G_PART_ALIAS_LINUX_SWAP, /* A Linux swap partition entry. */
58 G_PART_ALIAS_MS_BASIC_DATA, /* A Microsoft Data part. entry. */
59 G_PART_ALIAS_MS_LDM_DATA, /* A Microsoft LDM Data part. entry. */
60 G_PART_ALIAS_MS_LDM_METADATA, /* A Microsoft LDM Metadata entry. */
61 G_PART_ALIAS_MS_RESERVED, /* A Microsoft Reserved part. entry. */
62 G_PART_ALIAS_NETBSD_CCD, /* A NetBSD CCD partition entry. */
63 G_PART_ALIAS_NETBSD_CGD, /* A NetBSD CGD partition entry. */
64 G_PART_ALIAS_NETBSD_FFS, /* A NetBSD FFS partition entry. */
65 G_PART_ALIAS_NETBSD_RAID, /* A NetBSD RAID partition entry. */
66 G_PART_ALIAS_NETBSD_SWAP, /* A NetBSD swap partition entry. */
67 G_PART_ALIAS_NETBSD_LFS, /* A NetBSD LFS partition entry. */
68 /* Keep the following last */
69 G_PART_ALIAS_COUNT
70};
71
72const char *g_part_alias_name(enum g_part_alias);
73
74/* G_PART scheme (KOBJ class). */
75struct g_part_scheme {
76 KOBJ_CLASS_FIELDS;
77 size_t gps_entrysz;
78 int gps_minent;
79 int gps_maxent;
45 /* Keep the following last */
46 G_PART_ALIAS_COUNT
47};
48
49const char *g_part_alias_name(enum g_part_alias);
50
51/* G_PART scheme (KOBJ class). */
52struct g_part_scheme {
53 KOBJ_CLASS_FIELDS;
54 size_t gps_entrysz;
55 int gps_minent;
56 int gps_maxent;
80 int gps_bootcodesz;
81 TAILQ_ENTRY(g_part_scheme) scheme_list;
82};
57};
58#define G_PART_SCHEME_DECLARE(s) DATA_SET(g_part_scheme_set, s)
83
84struct g_part_entry {
85 LIST_ENTRY(g_part_entry) gpe_entry;
86 struct g_provider *gpe_pp; /* Corresponding provider. */
87 off_t gpe_offset; /* Byte offset. */
88 quad_t gpe_start; /* First LBA of partition. */
89 quad_t gpe_end; /* Last LBA of partition. */
90 int gpe_index;
91 int gpe_created:1; /* Entry is newly created. */
92 int gpe_deleted:1; /* Entry has been deleted. */
93 int gpe_modified:1; /* Entry has been modified. */
59
60struct g_part_entry {
61 LIST_ENTRY(g_part_entry) gpe_entry;
62 struct g_provider *gpe_pp; /* Corresponding provider. */
63 off_t gpe_offset; /* Byte offset. */
64 quad_t gpe_start; /* First LBA of partition. */
65 quad_t gpe_end; /* Last LBA of partition. */
66 int gpe_index;
67 int gpe_created:1; /* Entry is newly created. */
68 int gpe_deleted:1; /* Entry has been deleted. */
69 int gpe_modified:1; /* Entry has been modified. */
94 int gpe_internal:1; /* Entry is not a used entry. */
95};
96
97/* G_PART table (KOBJ instance). */
98struct g_part_table {
99 KOBJ_FIELDS;
100 struct g_part_scheme *gpt_scheme;
101 struct g_geom *gpt_gp;
102 LIST_HEAD(, g_part_entry) gpt_entry;

--- 4 unchanged lines hidden (view full) ---

107 * gpt_smhead and gpt_smtail are bitmaps representing the first
108 * 32 sectors on the disk (gpt_smhead) and the last 32 sectors
109 * on the disk (gpt_smtail). These maps are used by the commit
110 * verb to clear sectors previously used by a scheme after the
111 * partitioning scheme has been destroyed.
112 */
113 uint32_t gpt_smhead;
114 uint32_t gpt_smtail;
70};
71
72/* G_PART table (KOBJ instance). */
73struct g_part_table {
74 KOBJ_FIELDS;
75 struct g_part_scheme *gpt_scheme;
76 struct g_geom *gpt_gp;
77 LIST_HEAD(, g_part_entry) gpt_entry;

--- 4 unchanged lines hidden (view full) ---

82 * gpt_smhead and gpt_smtail are bitmaps representing the first
83 * 32 sectors on the disk (gpt_smhead) and the last 32 sectors
84 * on the disk (gpt_smtail). These maps are used by the commit
85 * verb to clear sectors previously used by a scheme after the
86 * partitioning scheme has been destroyed.
87 */
88 uint32_t gpt_smhead;
89 uint32_t gpt_smtail;
115 /*
116 * gpt_sectors and gpt_heads are the fixed or synchesized number
117 * of sectors per track and heads (resp) that make up a disks
118 * geometry. This is to support partitioning schemes as well as
119 * file systems that work on a geometry. The MBR scheme and the
120 * MS-DOS (FAT) file system come to mind.
121 * We keep track of whether the geometry is fixed or synchesized
122 * so that a partitioning scheme can correct the synthesized
123 * geometry, based on the on-disk metadata.
124 */
125 uint32_t gpt_sectors;
126 uint32_t gpt_heads;
127
128 int gpt_depth; /* Sub-partitioning level. */
129 int gpt_isleaf:1; /* Cannot be sub-partitioned. */
130 int gpt_created:1; /* Newly created. */
131 int gpt_modified:1; /* Table changes have been made. */
132 int gpt_opened:1; /* Permissions obtained. */
90
91 int gpt_depth; /* Sub-partitioning level. */
92 int gpt_isleaf:1; /* Cannot be sub-partitioned. */
93 int gpt_created:1; /* Newly created. */
94 int gpt_modified:1; /* Table changes have been made. */
95 int gpt_opened:1; /* Permissions obtained. */
133 int gpt_fixgeom:1; /* Geometry is fixed. */
134};
135
136struct g_part_entry *g_part_new_entry(struct g_part_table *, int, quad_t,
137 quad_t);
138
96};
97
98struct g_part_entry *g_part_new_entry(struct g_part_table *, int, quad_t,
99 quad_t);
100
139enum g_part_ctl {
140 G_PART_CTL_NONE,
141 G_PART_CTL_ADD,
142 G_PART_CTL_BOOTCODE,
143 G_PART_CTL_COMMIT,
144 G_PART_CTL_CREATE,
145 G_PART_CTL_DELETE,
146 G_PART_CTL_DESTROY,
147 G_PART_CTL_MODIFY,
148 G_PART_CTL_MOVE,
149 G_PART_CTL_RECOVER,
150 G_PART_CTL_RESIZE,
151 G_PART_CTL_SET,
152 G_PART_CTL_UNDO,
153 G_PART_CTL_UNSET
154};
155
156/* G_PART ctlreq parameters. */
157#define G_PART_PARM_ENTRIES 0x0001
158#define G_PART_PARM_FLAGS 0x0002
159#define G_PART_PARM_GEOM 0x0004
160#define G_PART_PARM_INDEX 0x0008
161#define G_PART_PARM_LABEL 0x0010
101/* G_PART ctlreq parameters. */
102#define G_PART_PARM_ENTRIES 0x0001
103#define G_PART_PARM_FLAGS 0x0002
104#define G_PART_PARM_GEOM 0x0004
105#define G_PART_PARM_INDEX 0x0008
106#define G_PART_PARM_LABEL 0x0010
162#define G_PART_PARM_OUTPUT 0x0020
163#define G_PART_PARM_PROVIDER 0x0040
164#define G_PART_PARM_SCHEME 0x0080
165#define G_PART_PARM_SIZE 0x0100
166#define G_PART_PARM_START 0x0200
167#define G_PART_PARM_TYPE 0x0400
168#define G_PART_PARM_VERSION 0x0800
169#define G_PART_PARM_BOOTCODE 0x1000
170#define G_PART_PARM_ATTRIB 0x2000
107#define G_PART_PARM_PROVIDER 0x0020
108#define G_PART_PARM_REQUEST 0x0040
109#define G_PART_PARM_RESPONSE 0x0080
110#define G_PART_PARM_SCHEME 0x0100
111#define G_PART_PARM_SIZE 0x0200
112#define G_PART_PARM_START 0x0400
113#define G_PART_PARM_TYPE 0x0800
171
172struct g_part_parms {
173 unsigned int gpp_parms;
174 unsigned int gpp_entries;
175 const char *gpp_flags;
176 struct g_geom *gpp_geom;
177 unsigned int gpp_index;
178 const char *gpp_label;
179 struct g_provider *gpp_provider;
114
115struct g_part_parms {
116 unsigned int gpp_parms;
117 unsigned int gpp_entries;
118 const char *gpp_flags;
119 struct g_geom *gpp_geom;
120 unsigned int gpp_index;
121 const char *gpp_label;
122 struct g_provider *gpp_provider;
123 const char *gpp_request;
180 struct g_part_scheme *gpp_scheme;
181 quad_t gpp_size;
182 quad_t gpp_start;
183 const char *gpp_type;
124 struct g_part_scheme *gpp_scheme;
125 quad_t gpp_size;
126 quad_t gpp_start;
127 const char *gpp_type;
184 unsigned int gpp_version;
185 const void *gpp_codeptr;
186 unsigned int gpp_codesize;
187 const char *gpp_attrib;
188};
189
128};
129
190void g_part_geometry_heads(off_t, u_int, off_t *, u_int *);
191
192int g_part_modevent(module_t, int, struct g_part_scheme *);
193
194#define G_PART_SCHEME_DECLARE(name) \
195 static int name##_modevent(module_t mod, int tp, void *d) \
196 { \
197 return (g_part_modevent(mod, tp, d)); \
198 } \
199 static moduledata_t name##_mod = { \
200 #name, \
201 name##_modevent, \
202 &name##_scheme \
203 }; \
204 DECLARE_MODULE(name, name##_mod, SI_SUB_DRIVERS, SI_ORDER_ANY)
205
206#endif /* !_GEOM_PART_H_ */
130#endif /* !_GEOM_PART_H_ */