Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. =================================================================== RCS file: /ftp/cvs/cvsroot/src/sbin/gpt/resize.c,v rcsdiff: /ftp/cvs/cvsroot/src/sbin/gpt/resize.c,v: warning: Unknown phrases like `commitid ...;' are present. retrieving revision 1.22 retrieving revision 1.22.16.1 diff -u -p -r1.22 -r1.22.16.1 --- src/sbin/gpt/resize.c 2015/12/04 16:54:28 1.22 +++ src/sbin/gpt/resize.c 2019/06/10 22:05:33 1.22.16.1 @@ -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.22 2015/12/04 16:54:28 christos Exp $"); +__RCSID("$NetBSD: resize.c,v 1.22.16.1 2019/06/10 22:05:33 christos Exp $"); #endif #include @@ -52,14 +52,14 @@ __RCSID("$NetBSD: resize.c,v 1.22 2015/1 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 = { "resize", cmd_resize, resizehelp, __arraycount(resizehelp), - 0, + GPT_SYNC, }; #define usage() gpt_usage(NULL, &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;