diff options
author | Kenneth R Westerback <krw@cvs.openbsd.org> | 2012-01-19 15:51:12 +0000 |
---|---|---|
committer | Kenneth R Westerback <krw@cvs.openbsd.org> | 2012-01-19 15:51:12 +0000 |
commit | aa3423ed8a7e215cdca5ce2bc59ba334919c7742 (patch) | |
tree | 517a9defb67d374a8a0146bb2f6c118d6294321c /sbin | |
parent | 1c95517f7857bb581b0ca2d044482836248d3db7 (diff) |
Even 'X'perts should not be able to use the built in editor to
create ffs partitions with invalid fsize and bsize values newfs
will croak on. However, they should be able to set them to whatever
consistent values they want, not just make them smaller.
Also tweak some verbiage.
Diffstat (limited to 'sbin')
-rw-r--r-- | sbin/disklabel/editor.c | 30 |
1 files changed, 15 insertions, 15 deletions
diff --git a/sbin/disklabel/editor.c b/sbin/disklabel/editor.c index 55414e40762..91fe25a0a80 100644 --- a/sbin/disklabel/editor.c +++ b/sbin/disklabel/editor.c @@ -1,4 +1,4 @@ -/* $OpenBSD: editor.c,v 1.264 2012/01/17 15:20:40 krw Exp $ */ +/* $OpenBSD: editor.c,v 1.265 2012/01/19 15:51:11 krw Exp $ */ /* * Copyright (c) 1997-2000 Todd C. Miller <Todd.Miller@courtesan.com> @@ -1989,14 +1989,18 @@ get_fsize(struct disklabel *lp, int partno) for (;;) { ui = getuint(lp, "fragment size", - "Size of fs block fragments. Usually 2048 or 512.", - fsize, fsize, 0, 0); + "Size of ffs block fragments. A multiple of the disk " + "sector-size.", fsize, ULLONG_MAX-2, 0, 0); if (ui == ULLONG_MAX - 1) { fputs("Command aborted\n", stderr); - return(1); - } else if (ui == ULLONG_MAX) + return (1); + } else if (ui == ULLONG_MAX) { fputs("Invalid entry\n", stderr); - else + } else if (ui < lp->d_secsize || (ui % lp->d_secsize) != 0) { + fprintf(stderr, "Error: fragment size must be a " + "multiple of the disk sector size (%d)\n", + lp->d_secsize); + } else break; } if (ui == 0) @@ -2027,9 +2031,8 @@ get_bsize(struct disklabel *lp, int partno) for (;;) { ui = getuint(lp, "block size", - "Size of filesystem blocks. Usually 16384 or 4096.", - fsize * frag, fsize * frag, - 0, 0); + "Size of ffs blocks. A multiple of the ffs fragment size.", + fsize * frag, ULLONG_MAX - 2, 0, 0); /* sanity checks */ if (ui == ULLONG_MAX - 1) { @@ -2041,12 +2044,9 @@ get_bsize(struct disklabel *lp, int partno) fprintf(stderr, "Error: block size must be at least as big " "as page size (%d).\n", getpagesize()); - else if (ui % fsize != 0) - fputs("Error: block size must be a multiple of the " - "fragment size.\n", stderr); - else if (ui / fsize < 1) - fputs("Error: block size must be at least as big as " - "fragment size.\n", stderr); + else if (ui < fsize || (ui % fsize) != 0) + fprintf(stderr, "Error: block size must be a multiple " + "of the fragment size (%d).\n", fsize); else break; } |