1
0
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:
Andrey V. Elsukov 2014-05-04 16:43:57 +00:00
parent a9d0ed68b3
commit 0dd7f00cee
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=265331
3 changed files with 18 additions and 3 deletions

View File

@ -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;

View File

@ -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,

View File

@ -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);