diff options
author | trasz <trasz@FreeBSD.org> | 2012-07-20 17:51:20 +0000 |
---|---|---|
committer | trasz <trasz@FreeBSD.org> | 2012-07-20 17:51:20 +0000 |
commit | b5f0adea7ec536dacd50afce9becd46adb2a6a98 (patch) | |
tree | fef52163cab79465deef9e85fd2d82404810dcce /sys/geom/part | |
parent | d3f835fa9f88ae58d80ad7d18ae2172ae39f69b1 (diff) | |
download | FreeBSD-src-b5f0adea7ec536dacd50afce9becd46adb2a6a98.zip FreeBSD-src-b5f0adea7ec536dacd50afce9becd46adb2a6a98.tar.gz |
Make it possible to resize opened partitions.
Sponsored by: FreeBSD Foundation
Diffstat (limited to 'sys/geom/part')
-rw-r--r-- | sys/geom/part/g_part.c | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/sys/geom/part/g_part.c b/sys/geom/part/g_part.c index 8d86c4a..45ab5ce 100644 --- a/sys/geom/part/g_part.c +++ b/sys/geom/part/g_part.c @@ -1257,6 +1257,7 @@ g_part_ctl_resize(struct gctl_req *req, struct g_part_parms *gpp) struct sbuf *sb; quad_t end; int error; + off_t mediasize; gp = gpp->gpp_geom; G_PART_TRACE((G_T_TOPOLOGY, "%s(%s)", __func__, gp->name)); @@ -1301,8 +1302,11 @@ g_part_ctl_resize(struct gctl_req *req, struct g_part_parms *gpp) pp = entry->gpe_pp; if ((g_debugflags & 16) == 0 && (pp->acr > 0 || pp->acw > 0 || pp->ace > 0)) { - gctl_error(req, "%d", EBUSY); - return (EBUSY); + if (entry->gpe_end - entry->gpe_start + 1 > gpp->gpp_size) { + /* Deny shrinking of an opened partition. */ + gctl_error(req, "%d", EBUSY); + return (EBUSY); + } } error = G_PART_RESIZE(table, entry, gpp); @@ -1315,8 +1319,9 @@ g_part_ctl_resize(struct gctl_req *req, struct g_part_parms *gpp) entry->gpe_modified = 1; /* update mediasize of changed provider */ - pp->mediasize = (entry->gpe_end - entry->gpe_start + 1) * + mediasize = (entry->gpe_end - entry->gpe_start + 1) * pp->sectorsize; + g_resize_provider(pp, mediasize); /* Provide feedback if so requested. */ if (gpp->gpp_parms & G_PART_PARM_OUTPUT) { |