mirror of
https://git.hardenedbsd.org/hardenedbsd/HardenedBSD.git
synced 2024-12-20 15:26:43 +01:00
Remove "magicspace". It looks good on paper, it doesn't work in practice.
Sponsored by: DARPA & NAI Labs.
This commit is contained in:
parent
469113b2d7
commit
4fbd12689a
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=103009
@ -61,8 +61,6 @@ struct g_event;
|
||||
struct thread;
|
||||
struct bio;
|
||||
struct sbuf;
|
||||
struct g_magicspaces;
|
||||
|
||||
|
||||
typedef struct g_geom * g_create_geom_t (struct g_class *mp,
|
||||
struct g_provider *pp, char *name);
|
||||
@ -123,7 +121,6 @@ struct g_geom {
|
||||
void *softc;
|
||||
struct g_event *event;
|
||||
unsigned flags;
|
||||
struct g_magicspaces *magicspaces;
|
||||
#define G_GEOM_WITHER 1
|
||||
};
|
||||
|
||||
@ -174,33 +171,6 @@ struct g_provider {
|
||||
off_t mediasize;
|
||||
};
|
||||
|
||||
/*
|
||||
* Some methods may implement various "magic spaces", this is reserved
|
||||
* or magic areas on the disk, set a side for various and sundry purposes.
|
||||
* A good example is the BSD disklabel and boot code on i386 which occupies
|
||||
* a total of four magic spaces: boot1, the disklabel, the padding behind
|
||||
* the disklabel and boot2. The reason we don't simply tell people to
|
||||
* write the appropriate stuff on the underlying device is that (some of)
|
||||
* the magic spaces might be real-time modifiable. It is for instance
|
||||
* possible to change a disklabel while partitions are open, provided
|
||||
* the open partitions do not get trampled in the process.
|
||||
*/
|
||||
|
||||
struct g_magicspace {
|
||||
char name[8];
|
||||
off_t offset;
|
||||
u_int len;
|
||||
u_int flags;
|
||||
};
|
||||
|
||||
struct g_magicspaces {
|
||||
uintptr_t geom_id;
|
||||
char class[8];
|
||||
uint nmagic;
|
||||
uint nspace;
|
||||
struct g_magicspace *magicspace;
|
||||
};
|
||||
|
||||
/* geom_dump.c */
|
||||
void g_hexdump(void *ptr, int length);
|
||||
void g_trace(int level, char *, ...);
|
||||
@ -224,7 +194,6 @@ void g_silence(void);
|
||||
int g_access_abs(struct g_consumer *cp, int read, int write, int exclusive);
|
||||
int g_access_rel(struct g_consumer *cp, int read, int write, int exclusive);
|
||||
void g_add_class(struct g_class *mp);
|
||||
int g_add_magicspace(struct g_geom *gp, const char *name, off_t start, u_int len, u_int flags);
|
||||
int g_attach(struct g_consumer *cp, struct g_provider *pp);
|
||||
struct g_geom *g_create_geomf(char *class, struct g_provider *, char *fmt, ...);
|
||||
void g_destroy_consumer(struct g_consumer *cp);
|
||||
|
@ -338,20 +338,8 @@ g_bsd_taste(struct g_class *mp, struct g_provider *pp, int flags)
|
||||
error, (long long)mediasize);
|
||||
}
|
||||
error = g_bsd_try(gsp, cp, secsize, ms, secsize);
|
||||
if (!error) {
|
||||
g_add_magicspace(gp, "boot1", 0, 512, 0);
|
||||
g_add_magicspace(gp, "label", 512, 276, 0);
|
||||
g_add_magicspace(gp, "fill0", 748, 236, 0);
|
||||
g_add_magicspace(gp, "boot2", 1024, 7168, 0);
|
||||
}
|
||||
if (error) {
|
||||
if (error)
|
||||
error = g_bsd_try(gsp, cp, secsize, ms, 64);
|
||||
if (!error) {
|
||||
g_add_magicspace(gp, "fill0", 0, 64, 0);
|
||||
g_add_magicspace(gp, "label", 64, 276, 0);
|
||||
g_add_magicspace(gp, "fill1", 340, 172, 0);
|
||||
}
|
||||
}
|
||||
if (error)
|
||||
break;
|
||||
dl = &ms->ondisk;
|
||||
|
@ -157,30 +157,11 @@ g_conf_geom(struct sbuf *sb, struct g_geom *gp, struct g_provider *pp, struct g_
|
||||
{
|
||||
struct g_consumer *cp2;
|
||||
struct g_provider *pp2;
|
||||
struct g_magicspace *gsp;
|
||||
u_int u;
|
||||
|
||||
sbuf_printf(sb, " <geom id=\"%p\">\n", gp);
|
||||
sbuf_printf(sb, " <class ref=\"%p\"/>\n", gp->class);
|
||||
sbuf_printf(sb, " <name>%s</name>\n", gp->name);
|
||||
sbuf_printf(sb, " <rank>%d</rank>\n", gp->rank);
|
||||
if (gp->magicspaces) {
|
||||
for (u = 0; u < gp->magicspaces->nmagic; u++) {
|
||||
gsp = &gp->magicspaces->magicspace[u];
|
||||
if (gsp->len == 0 || gsp->name == NULL)
|
||||
continue;
|
||||
sbuf_printf(sb, " <magicspace>\n");
|
||||
sbuf_printf(sb, " <name>%.8s</name>\n",
|
||||
gsp->name);
|
||||
sbuf_printf(sb, " <offset>%lld</offset>\n",
|
||||
(long long)gsp->offset);
|
||||
sbuf_printf(sb, " <length>%u</length>\n",
|
||||
gsp->len);
|
||||
sbuf_printf(sb, " <flags>%u</flags>\n",
|
||||
gsp->flags);
|
||||
sbuf_printf(sb, " </magicspace>\n");
|
||||
}
|
||||
}
|
||||
if (gp->dumpconf) {
|
||||
sbuf_printf(sb, " <config>\n");
|
||||
gp->dumpconf(sb, "\t", gp, NULL, NULL);
|
||||
|
@ -251,9 +251,6 @@ g_mbr_taste(struct g_class *mp, struct g_provider *pp, int insist)
|
||||
g_topology_lock();
|
||||
error = g_access_rel(cp, -1, 0, 0);
|
||||
if (npart > 0) {
|
||||
g_add_magicspace(gp, "boot", 0, DOSPARTOFF, 0);
|
||||
g_add_magicspace(gp, "mbr", DOSPARTOFF, 4 * 16, 0);
|
||||
g_add_magicspace(gp, "magic", 510, 2, 0);
|
||||
LIST_FOREACH(pp, &gp->provider, provider)
|
||||
g_error_provider(pp, 0);
|
||||
return (gp);
|
||||
|
@ -114,46 +114,6 @@ g_new_geomf(struct g_class *mp, char *fmt, ...)
|
||||
return (gp);
|
||||
}
|
||||
|
||||
/*
|
||||
* Add a magic space to a geom. There is no locking here because nobody
|
||||
* should be modifying these except the geom itself during configuration,
|
||||
* so it cannot go away while we fiddling it.
|
||||
* For now, no provision exists for removing magic spaces or for changing
|
||||
* them on the fly.
|
||||
*/
|
||||
|
||||
int
|
||||
g_add_magicspace(struct g_geom *gp, const char *name, off_t start, u_int len, u_int flags)
|
||||
{
|
||||
int i;
|
||||
struct g_magicspaces *msps;
|
||||
struct g_magicspace *msp, *msp2;
|
||||
|
||||
if (gp->magicspaces == NULL) {
|
||||
msps = g_malloc(sizeof *gp->magicspaces, M_WAITOK | M_ZERO);
|
||||
msps->geom_id = (uintptr_t)gp;
|
||||
strncpy(msps->class, gp->class->name, sizeof msps->class);
|
||||
gp->magicspaces = msps;
|
||||
}
|
||||
msps = gp->magicspaces;
|
||||
if (msps->nmagic >= msps->nspace) {
|
||||
i = msps->nspace + 1;
|
||||
msp = g_malloc(sizeof(*msp) * i, M_WAITOK | M_ZERO);
|
||||
bcopy(msps->magicspace, msp, sizeof(*msp) * msps->nmagic);
|
||||
msp2 = msps->magicspace;
|
||||
msps->magicspace = msp;
|
||||
if (msp2 != NULL)
|
||||
g_free(msp2);
|
||||
msps->nspace = i;
|
||||
}
|
||||
msp = &msps->magicspace[msps->nmagic++];
|
||||
strncpy(msp->name, name, sizeof msp->name);
|
||||
msp->offset = start;
|
||||
msp->len = len;
|
||||
msp->flags = flags;
|
||||
return (0);
|
||||
}
|
||||
|
||||
void
|
||||
g_destroy_geom(struct g_geom *gp)
|
||||
{
|
||||
@ -169,10 +129,6 @@ g_destroy_geom(struct g_geom *gp)
|
||||
gp->name, LIST_FIRST(&gp->consumer)));
|
||||
LIST_REMOVE(gp, geom);
|
||||
TAILQ_REMOVE(&geoms, gp, geoms);
|
||||
if (gp->magicspaces) {
|
||||
g_free(gp->magicspaces->magicspace);
|
||||
g_free(gp->magicspaces);
|
||||
}
|
||||
g_free(gp->name);
|
||||
g_free(gp);
|
||||
}
|
||||
|
@ -179,10 +179,8 @@ g_sunlabel_taste(struct g_class *mp, struct g_provider *pp, int flags)
|
||||
}
|
||||
g_topology_lock();
|
||||
error = g_access_rel(cp, -1, 0, 0);
|
||||
if (npart > 0) {
|
||||
g_add_magicspace(gp, "label", 0, 512, 0);
|
||||
if (npart > 0)
|
||||
return (gp);
|
||||
}
|
||||
g_std_spoiled(cp);
|
||||
return (NULL);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user