mirror of
https://git.FreeBSD.org/src.git
synced 2024-12-15 10:17:20 +00:00
Prevent an unexpected shrinking on resizing due to alignment for MBR,
PC98 and VTOC8 schemes. Reported by: jmg MFC after: 1 week
This commit is contained in:
parent
a9d0ed68b3
commit
0dd7f00cee
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=265331
@ -42,6 +42,7 @@ __FBSDID("$FreeBSD$");
|
||||
#include <sys/systm.h>
|
||||
#include <sys/sysctl.h>
|
||||
#include <geom/geom.h>
|
||||
#include <geom/geom_int.h>
|
||||
#include <geom/part/g_part.h>
|
||||
|
||||
#include "g_part_if.h"
|
||||
@ -353,7 +354,11 @@ g_part_mbr_resize(struct g_part_table *basetable,
|
||||
size = gpp->gpp_size;
|
||||
if (mbr_align(basetable, NULL, &size) != 0)
|
||||
return (EINVAL);
|
||||
|
||||
/* XXX: prevent unexpected shrinking. */
|
||||
pp = baseentry->gpe_pp;
|
||||
if ((g_debugflags & 16) == 0 && size < gpp->gpp_size &&
|
||||
(pp->acr > 0 || pp->acw > 0 || pp->ace > 0))
|
||||
return (EBUSY);
|
||||
entry = (struct g_part_mbr_entry *)baseentry;
|
||||
baseentry->gpe_end = baseentry->gpe_start + size - 1;
|
||||
entry->ent.dp_size = size;
|
||||
|
@ -42,6 +42,7 @@ __FBSDID("$FreeBSD$");
|
||||
#include <sys/systm.h>
|
||||
#include <sys/sysctl.h>
|
||||
#include <geom/geom.h>
|
||||
#include <geom/geom_int.h>
|
||||
#include <geom/part/g_part.h>
|
||||
|
||||
#include "g_part_if.h"
|
||||
@ -360,7 +361,11 @@ g_part_pc98_resize(struct g_part_table *basetable,
|
||||
size = gpp->gpp_size;
|
||||
if (pc98_align(basetable, NULL, &size) != 0)
|
||||
return (EINVAL);
|
||||
|
||||
/* XXX: prevent unexpected shrinking. */
|
||||
pp = baseentry->gpe_pp;
|
||||
if ((g_debugflags & 0x10) == 0 && size < gpp->gpp_size &&
|
||||
(pp->acr > 0 || pp->acw > 0 || pp->ace > 0))
|
||||
return (EBUSY);
|
||||
entry = (struct g_part_pc98_entry *)baseentry;
|
||||
baseentry->gpe_end = baseentry->gpe_start + size - 1;
|
||||
pc98_set_chs(basetable, baseentry->gpe_end, &entry->ent.dp_ecyl,
|
||||
|
@ -42,6 +42,7 @@ __FBSDID("$FreeBSD$");
|
||||
#include <sys/sysctl.h>
|
||||
#include <sys/vtoc.h>
|
||||
#include <geom/geom.h>
|
||||
#include <geom/geom_int.h>
|
||||
#include <geom/part/g_part.h>
|
||||
|
||||
#include "g_part_if.h"
|
||||
@ -367,7 +368,11 @@ g_part_vtoc8_resize(struct g_part_table *basetable,
|
||||
size = gpp->gpp_size;
|
||||
if (vtoc8_align(table, NULL, &size) != 0)
|
||||
return (EINVAL);
|
||||
|
||||
/* XXX: prevent unexpected shrinking. */
|
||||
pp = entry->gpe_pp;
|
||||
if ((g_debugflags & 0x10) == 0 && size < gpp->gpp_size &&
|
||||
(pp->acr > 0 || pp->acw > 0 || pp->ace > 0))
|
||||
return (EBUSY);
|
||||
entry->gpe_end = entry->gpe_start + size - 1;
|
||||
be32enc(&table->vtoc.map[entry->gpe_index - 1].nblks, size);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user