Changeset View
Changeset View
Standalone View
Standalone View
sys/geom/part/g_part_gpt.c
Show First 20 Lines • Show All 48 Lines • ▼ Show 20 Lines | |||||
#include <geom/geom.h> | #include <geom/geom.h> | ||||
#include <geom/geom_int.h> | #include <geom/geom_int.h> | ||||
#include <geom/part/g_part.h> | #include <geom/part/g_part.h> | ||||
#include "g_part_if.h" | #include "g_part_if.h" | ||||
FEATURE(geom_part_gpt, "GEOM partitioning class for GPT partitions support"); | FEATURE(geom_part_gpt, "GEOM partitioning class for GPT partitions support"); | ||||
SYSCTL_DECL(_kern_geom_part); | |||||
static SYSCTL_NODE(_kern_geom_part, OID_AUTO, gpt, CTLFLAG_RW, 0, | |||||
"GEOM_PART_GPT GUID Partition Table"); | |||||
static u_int allow_nesting = 0; | |||||
SYSCTL_UINT(_kern_geom_part_gpt, OID_AUTO, allow_nesting, | |||||
CTLFLAG_RWTUN, &allow_nesting, 0, "Allow GPT to be nested inside other schemes"); | |||||
CTASSERT(offsetof(struct gpt_hdr, padding) == 92); | CTASSERT(offsetof(struct gpt_hdr, padding) == 92); | ||||
CTASSERT(sizeof(struct gpt_ent) == 128); | CTASSERT(sizeof(struct gpt_ent) == 128); | ||||
#define EQUUID(a,b) (memcmp(a, b, sizeof(struct uuid)) == 0) | #define EQUUID(a,b) (memcmp(a, b, sizeof(struct uuid)) == 0) | ||||
#define MBRSIZE 512 | #define MBRSIZE 512 | ||||
enum gpt_elt { | enum gpt_elt { | ||||
▲ Show 20 Lines • Show All 582 Lines • ▼ Show 20 Lines | |||||
static int | static int | ||||
g_part_gpt_create(struct g_part_table *basetable, struct g_part_parms *gpp) | g_part_gpt_create(struct g_part_table *basetable, struct g_part_parms *gpp) | ||||
{ | { | ||||
struct g_provider *pp; | struct g_provider *pp; | ||||
struct g_part_gpt_table *table; | struct g_part_gpt_table *table; | ||||
size_t tblsz; | size_t tblsz; | ||||
/* We don't nest, which means that our depth should be 0. */ | /* Our depth should be 0 unless nesting was explicitly enabled. */ | ||||
if (basetable->gpt_depth != 0) | if (!allow_nesting && basetable->gpt_depth != 0) | ||||
imp: comment update | |||||
return (ENXIO); | return (ENXIO); | ||||
table = (struct g_part_gpt_table *)basetable; | table = (struct g_part_gpt_table *)basetable; | ||||
pp = gpp->gpp_provider; | pp = gpp->gpp_provider; | ||||
tblsz = howmany(basetable->gpt_entries * sizeof(struct gpt_ent), | tblsz = howmany(basetable->gpt_entries * sizeof(struct gpt_ent), | ||||
pp->sectorsize); | pp->sectorsize); | ||||
if (pp->sectorsize < MBRSIZE || | if (pp->sectorsize < MBRSIZE || | ||||
pp->mediasize < (3 + 2 * tblsz + basetable->gpt_entries) * | pp->mediasize < (3 + 2 * tblsz + basetable->gpt_entries) * | ||||
▲ Show 20 Lines • Show All 144 Lines • ▼ Show 20 Lines | |||||
} | } | ||||
static int | static int | ||||
g_part_gpt_probe(struct g_part_table *table, struct g_consumer *cp) | g_part_gpt_probe(struct g_part_table *table, struct g_consumer *cp) | ||||
{ | { | ||||
struct g_provider *pp; | struct g_provider *pp; | ||||
u_char *buf; | u_char *buf; | ||||
int error, index, pri, res; | int error, index, pri, res; | ||||
/* We don't nest, which means that our depth should be 0. */ | /* Our depth should be 0 unless nesting was explicitly enabled. */ | ||||
Done Inline Actionscomment update. imp: comment update. | |||||
if (table->gpt_depth != 0) | if (!allow_nesting && table->gpt_depth != 0) | ||||
return (ENXIO); | return (ENXIO); | ||||
pp = cp->provider; | pp = cp->provider; | ||||
/* | /* | ||||
* Sanity-check the provider. Since the first sector on the provider | * Sanity-check the provider. Since the first sector on the provider | ||||
* must be a PMBR and a PMBR is 512 bytes large, the sector size | * must be a PMBR and a PMBR is 512 bytes large, the sector size | ||||
* must be at least 512 bytes. Also, since the theoretical minimum | * must be at least 512 bytes. Also, since the theoretical minimum | ||||
▲ Show 20 Lines • Show All 584 Lines • Show Last 20 Lines |
comment update