Claus Assmann <[email protected]> wrote:

>AFAICT the "percentage of disk" is optional

disklabel(8) says:

| A template for the automatic allocation can be passed to disklabel using
| the -T option.  The template consists of one line per partition, with
| each line giving mountpoint, min-max size range, and percentage of disk,
| space-separated.  Max can be unlimited by specifying '*'.  If only
| mountpoint and min size are given, the partition is created with that
| exact size.

Which means that percentages are optional unless sizes are specified as
min-max, which makes a lot of sense:  you either specify the amount of
space you want to allocate for particular partition, or you specify the
percentage of disk you want it to cover and provide minimum and maximum
limits.

>Index: editor.c
>===================================================================
>RCS file: cvs/src/sbin/disklabel/editor.c,v
>retrieving revision 1.303
>diff -u -r1.303 editor.c
>--- editor.c   2 Sep 2016 10:47:17 -0000       1.303
>+++ editor.c   3 Oct 2016 22:56:55 -0000
>@@ -2388,6 +2388,7 @@
>   sa = &(alloc_table[0].table[idx]);
>   idx++;
>
>+              sa->rate = 0;

So basically you set the partition size to 0% of disk, forcing disklabel
to pick the lower limit.  Why would you want to specify the upper limit
then?

It would probably make more sense to do something like this instead:

Index: sbin/disklabel//editor.c
===================================================================
RCS file: /var/cvs/src/sbin/disklabel/editor.c,v
retrieving revision 1.303
diff -u -p -r1.303 editor.c
--- sbin/disklabel//editor.c    2 Sep 2016 10:47:17 -0000       1.303
+++ sbin/disklabel//editor.c    4 Oct 2016 01:06:39 -0000
@@ -2397,6 +2397,8 @@ parse_autotable(char *filename)
                if ((t = get_token(&buf, &len)) != NULL &&
                    parse_pct(t, &sa->rate) == -1)
                        errx(1, "%s: parse error on line %u", filename, idx);
+               else if (&sa->maxsz)
+                       errx(1, "%s: parse error on line %u", filename, idx);
                if (sa->minsz > sa->maxsz)
                        errx(1, "%s: min size > max size on line %u", filename,
                            idx);

Reply via email to