Make the sectorsize a property of providers so we can include it in the XML
output. Sponsored by: DARPA & NAI Labs
This commit is contained in:
parent
930f6f2f6d
commit
48444d6262
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=105542
@ -254,6 +254,7 @@ g_bde_create(struct g_createargs *ga)
|
||||
g_topology_lock();
|
||||
pp = g_new_providerf(gp, gp->name);
|
||||
pp->mediasize = sc->mediasize;
|
||||
pp->sectorsize = sc->sectorsize;
|
||||
g_error_provider(pp, 0);
|
||||
g_topology_unlock();
|
||||
break;
|
||||
|
@ -169,6 +169,7 @@ struct g_provider {
|
||||
TAILQ_ENTRY(g_provider) orphan;
|
||||
int index;
|
||||
off_t mediasize;
|
||||
u_int sectorsize;
|
||||
};
|
||||
|
||||
/*
|
||||
|
@ -369,6 +369,7 @@ g_bsd_modify(struct g_geom *gp, struct disklabel *dl)
|
||||
error = g_slice_config(gp, i, G_SLICE_CONFIG_CHECK,
|
||||
(off_t)ppp->p_offset * dl->d_secsize,
|
||||
(off_t)ppp->p_size * dl->d_secsize,
|
||||
dl->d_secsize,
|
||||
"%s%c", gp->name, 'a' + i);
|
||||
if (error) {
|
||||
g_topology_unlock();
|
||||
@ -382,6 +383,7 @@ g_bsd_modify(struct g_geom *gp, struct disklabel *dl)
|
||||
g_slice_config(gp, i, G_SLICE_CONFIG_SET,
|
||||
(off_t)ppp->p_offset * dl->d_secsize,
|
||||
(off_t)ppp->p_size * dl->d_secsize,
|
||||
dl->d_secsize,
|
||||
"%s%c", gp->name, 'a' + i);
|
||||
}
|
||||
return (0);
|
||||
|
@ -99,6 +99,7 @@ g_disk_access(struct g_provider *pp, int r, int w, int e)
|
||||
error = 0;
|
||||
}
|
||||
pp->mediasize = dp->d_mediasize;
|
||||
pp->sectorsize = dp->d_sectorsize;
|
||||
return (error);
|
||||
}
|
||||
|
||||
|
@ -146,6 +146,7 @@ g_conf_provider(struct sbuf *sb, struct g_provider *pp)
|
||||
sbuf_printf(sb, "\t <name>%s</name>\n", pp->name);
|
||||
sbuf_printf(sb, "\t <mediasize>%jd</mediasize>\n",
|
||||
(intmax_t)pp->mediasize);
|
||||
sbuf_printf(sb, "\t <sectorsize>%u</sectorsize>\n", pp->sectorsize);
|
||||
if (pp->geom->dumpconf) {
|
||||
sbuf_printf(sb, "\t <config>\n");
|
||||
pp->geom->dumpconf(sb, "\t ", pp->geom, NULL, pp);
|
||||
|
@ -226,6 +226,7 @@ g_gpt_taste(struct g_class *mp, struct g_provider *pp, int insist)
|
||||
(void)g_slice_addslice(gp, i,
|
||||
ent->ent_lba_start * secsz,
|
||||
(1 + ent->ent_lba_end - ent->ent_lba_start) * secsz,
|
||||
secsz,
|
||||
"%s%c%d", gp->name, ps, i + 1);
|
||||
g_topology_unlock();
|
||||
npart++;
|
||||
|
@ -242,8 +242,9 @@ g_mbr_taste(struct g_class *mp, struct g_provider *pp, int insist)
|
||||
ms->type[i] = dp[i].dp_typ;
|
||||
g_topology_lock();
|
||||
pp2 = g_slice_addslice(gp, i,
|
||||
((off_t)dp[i].dp_start) << 9ULL,
|
||||
((off_t)dp[i].dp_size) << 9ULL,
|
||||
(off_t)dp[i].dp_start << 9ULL,
|
||||
(off_t)dp[i].dp_size << 9ULL,
|
||||
sectorsize,
|
||||
"%ss%d", gp->name, i + 1);
|
||||
g_topology_unlock();
|
||||
}
|
||||
@ -378,6 +379,7 @@ g_mbrext_taste(struct g_class *mp, struct g_provider *pp, int insist __unused)
|
||||
pp2 = g_slice_addslice(gp, slice,
|
||||
(((off_t)dp[0].dp_start) << 9ULL) + off,
|
||||
((off_t)dp[0].dp_size) << 9ULL,
|
||||
sectorsize,
|
||||
"%*.*s%d",
|
||||
strlen(gp->name) - 1,
|
||||
strlen(gp->name) - 1,
|
||||
|
@ -162,6 +162,7 @@ g_pc98_taste(struct g_class *mp, struct g_provider *pp, int flags)
|
||||
g_topology_lock();
|
||||
pp2 = g_slice_addslice(gp, i,
|
||||
start, length,
|
||||
sectorsize,
|
||||
"%ss%d", pp->name, 1 + i);
|
||||
g_topology_unlock();
|
||||
g_error_provider(pp2, 0);
|
||||
|
@ -118,7 +118,6 @@ g_slice_access(struct g_provider *pp, int dr, int dw, int de)
|
||||
if ((cp->acr + dr) == 0 && (cp->acw + dw) == 0 && (cp->ace + de) == 1)
|
||||
de--;
|
||||
error = g_access_rel(cp, dr, dw, de);
|
||||
pp->mediasize = gsp->slices[pp->index].length;
|
||||
return (error);
|
||||
}
|
||||
|
||||
@ -228,7 +227,7 @@ g_slice_dumpconf(struct sbuf *sb, char *indent, struct g_geom *gp, struct g_cons
|
||||
}
|
||||
|
||||
int
|
||||
g_slice_config(struct g_geom *gp, int index, int how, off_t offset, off_t length, char *fmt, ...)
|
||||
g_slice_config(struct g_geom *gp, int index, int how, off_t offset, off_t length, u_int sectorsize, char *fmt, ...)
|
||||
{
|
||||
struct g_provider *pp;
|
||||
struct g_slicer *gsp;
|
||||
@ -261,6 +260,7 @@ g_slice_config(struct g_geom *gp, int index, int how, off_t offset, off_t length
|
||||
return (0);
|
||||
gsl->length = length;
|
||||
gsl->offset = offset;
|
||||
gsl->sectorsize = sectorsize;
|
||||
if (length != 0 && pp != NULL)
|
||||
return (0);
|
||||
if (length == 0 && pp == NULL)
|
||||
@ -277,6 +277,8 @@ g_slice_config(struct g_geom *gp, int index, int how, off_t offset, off_t length
|
||||
sbuf_finish(sb);
|
||||
pp = g_new_providerf(gp, sbuf_data(sb));
|
||||
pp->index = index;
|
||||
pp->mediasize = gsl->length;
|
||||
pp->sectorsize = gsl->sectorsize;
|
||||
gsl->provider = pp;
|
||||
gsp->nprovider++;
|
||||
g_error_provider(pp, 0);
|
||||
@ -285,7 +287,7 @@ g_slice_config(struct g_geom *gp, int index, int how, off_t offset, off_t length
|
||||
}
|
||||
|
||||
struct g_provider *
|
||||
g_slice_addslice(struct g_geom *gp, int index, off_t offset, off_t length, char *fmt, ...)
|
||||
g_slice_addslice(struct g_geom *gp, int index, off_t offset, off_t length, u_int sectorsize, char *fmt, ...)
|
||||
{
|
||||
struct g_provider *pp;
|
||||
struct g_slicer *gsp;
|
||||
@ -305,6 +307,9 @@ g_slice_addslice(struct g_geom *gp, int index, off_t offset, off_t length, char
|
||||
gsp->slices[index].length = length;
|
||||
gsp->slices[index].offset = offset;
|
||||
gsp->slices[index].provider = pp;
|
||||
gsp->slices[index].sectorsize = sectorsize;
|
||||
pp->mediasize = gsp->slices[index].length;
|
||||
pp->sectorsize = gsp->slices[index].sectorsize;
|
||||
sbuf_delete(sb);
|
||||
return(pp);
|
||||
}
|
||||
|
@ -41,6 +41,7 @@
|
||||
struct g_slice {
|
||||
off_t offset;
|
||||
off_t length;
|
||||
u_int sectorsize;
|
||||
struct g_provider *provider;
|
||||
};
|
||||
|
||||
@ -57,8 +58,8 @@ struct g_slicer {
|
||||
};
|
||||
|
||||
g_dumpconf_t g_slice_dumpconf;
|
||||
struct g_provider * g_slice_addslice(struct g_geom *gp, int index, off_t offset, off_t length, char *fmt, ...);
|
||||
int g_slice_config(struct g_geom *gp, int index, int how, off_t offset, off_t length, char *fmt, ...);
|
||||
struct g_provider * g_slice_addslice(struct g_geom *gp, int index, off_t offset, off_t length, u_int sectorsize, char *fmt, ...);
|
||||
int g_slice_config(struct g_geom *gp, int index, int how, off_t offset, off_t length, u_int sectorsize, char *fmt, ...);
|
||||
#define G_SLICE_CONFIG_CHECK 0
|
||||
#define G_SLICE_CONFIG_SET 1
|
||||
#define G_SLICE_CONFIG_FORCE 2
|
||||
|
@ -172,6 +172,7 @@ g_sunlabel_taste(struct g_class *mp, struct g_provider *pp, int flags)
|
||||
pp2 = g_slice_addslice(gp, i,
|
||||
((off_t)v * csize) << 9ULL,
|
||||
((off_t)u) << 9ULL,
|
||||
sectorsize,
|
||||
"%s%c", pp->name, 'a' + i);
|
||||
g_topology_unlock();
|
||||
g_error_provider(pp2, 0);
|
||||
|
Loading…
Reference in New Issue
Block a user