Module Name: src Committed By: martin Date: Sun Mar 24 13:31:00 UTC 2019
Modified Files: src/sbin/gpt: gpt.8 resize.c Log Message: Add support for specifying the partition to resize via -b startsec (similar to label and other subcommands). Do not fully add gpt_find functionality here, as resizing multiple partitions in one go does not make sense. To generate a diff of this commit: cvs rdiff -u -r1.63 -r1.64 src/sbin/gpt/gpt.8 cvs rdiff -u -r1.23 -r1.24 src/sbin/gpt/resize.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sbin/gpt/gpt.8 diff -u src/sbin/gpt/gpt.8:1.63 src/sbin/gpt/gpt.8:1.64 --- src/sbin/gpt/gpt.8:1.63 Tue May 1 21:16:02 2018 +++ src/sbin/gpt/gpt.8 Sun Mar 24 13:31:00 2019 @@ -1,4 +1,4 @@ -.\" $NetBSD: gpt.8,v 1.63 2018/05/01 21:16:02 kre Exp $ +.\" $NetBSD: gpt.8,v 1.64 2019/03/24 13:31:00 martin Exp $ .\" .\" Copyright (c) 2002 Marcel Moolenaar .\" All rights reserved. @@ -26,7 +26,7 @@ .\" .\" $FreeBSD: src/sbin/gpt/gpt.8,v 1.17 2006/06/22 22:22:32 marcel Exp $ .\" -.Dd May 1, 2018 +.Dd March 24, 2019 .Dt GPT 8 .Os .Sh NAME @@ -466,7 +466,7 @@ See above for a description of these opt Partitions are removed by clearing the partition type. No other information is changed. .\" ==== resize ==== -.It Nm Ic resize Fl i Ar index Oo Fl a Ar alignment Oc \ +.It Nm Ic resize [ Fl i Ar index | Fl b Ar startsec ] Oo Fl a Ar alignment Oc \ Oo Fl s Ar size Oc The .Ic resize Index: src/sbin/gpt/resize.c diff -u src/sbin/gpt/resize.c:1.23 src/sbin/gpt/resize.c:1.24 --- src/sbin/gpt/resize.c:1.23 Tue Jul 3 03:41:24 2018 +++ src/sbin/gpt/resize.c Sun Mar 24 13:31:00 2019 @@ -33,7 +33,7 @@ __FBSDID("$FreeBSD: src/sbin/gpt/add.c,v 1.14 2006/06/22 22:05:28 marcel Exp $"); #endif #ifdef __RCSID -__RCSID("$NetBSD: resize.c,v 1.23 2018/07/03 03:41:24 jnemeth Exp $"); +__RCSID("$NetBSD: resize.c,v 1.24 2019/03/24 13:31:00 martin Exp $"); #endif #include <sys/types.h> @@ -52,7 +52,7 @@ __RCSID("$NetBSD: resize.c,v 1.23 2018/0 static int cmd_resize(gpt_t, int, char *[]); static const char *resizehelp[] = { - "-i index [-a alignment] [-s size]", + "[-i index | -b blocknr] [-a alignment] [-s size]", }; struct gpt_cmd c_resize = { @@ -131,17 +131,32 @@ static int cmd_resize(gpt_t gpt, int argc, char *argv[]) { int ch; - off_t alignment = 0, sectors, size = 0; + off_t alignment = 0, sectors, start = 0, size = 0; unsigned int entry = 0; + map_t m; - while ((ch = getopt(argc, argv, GPT_AIS)) != -1) { - if (gpt_add_ais(gpt, &alignment, &entry, &size, ch) == -1) + while ((ch = getopt(argc, argv, GPT_AIS "b:")) != -1) { + if (ch == 'b') + gpt_human_get(gpt, &start); + else if (gpt_add_ais(gpt, &alignment, &entry, &size, ch) == -1) return usage(); } if (argc != optind) return usage(); + if (start > 0) { + for (m = map_first(gpt); m != NULL; m = m->map_next) { + if (m->map_type != MAP_TYPE_GPT_PART || + m->map_index < 1) + continue; + if (start != m->map_start) + continue; + entry = m->map_index; + break; + } + } + if ((sectors = gpt_check_ais(gpt, alignment, entry, size)) == -1) return -1;