diff options
author | Kenneth R Westerback <krw@cvs.openbsd.org> | 2009-04-12 01:01:25 +0000 |
---|---|---|
committer | Kenneth R Westerback <krw@cvs.openbsd.org> | 2009-04-12 01:01:25 +0000 |
commit | db99ae7bc6a8f746a89ac788bd929c672852d6cd (patch) | |
tree | 3a88091a4fc3e0b2a33139edfecca813cec4f84f /sbin | |
parent | 0e41e97f9b074560ad86a21e01248507ea1cd528 (diff) |
When auto-allocating, check the size of the disk and display
offset/size information in MB if the disk is <10G, and in GB
otherwise. '-p' will override this default.
Diffstat (limited to 'sbin')
-rw-r--r-- | sbin/disklabel/disklabel.c | 6 | ||||
-rw-r--r-- | sbin/disklabel/editor.c | 11 | ||||
-rw-r--r-- | sbin/disklabel/extern.h | 3 |
3 files changed, 14 insertions, 6 deletions
diff --git a/sbin/disklabel/disklabel.c b/sbin/disklabel/disklabel.c index 6561885b78b..7b6ca373533 100644 --- a/sbin/disklabel/disklabel.c +++ b/sbin/disklabel/disklabel.c @@ -1,4 +1,4 @@ -/* $OpenBSD: disklabel.c,v 1.150 2009/04/11 23:57:56 krw Exp $ */ +/* $OpenBSD: disklabel.c,v 1.151 2009/04/12 01:01:24 krw Exp $ */ /* * Copyright (c) 1987, 1993 @@ -39,7 +39,7 @@ static const char copyright[] = #endif /* not lint */ #ifndef lint -static const char rcsid[] = "$OpenBSD: disklabel.c,v 1.150 2009/04/11 23:57:56 krw Exp $"; +static const char rcsid[] = "$OpenBSD: disklabel.c,v 1.151 2009/04/12 01:01:24 krw Exp $"; #endif /* not lint */ #include <sys/param.h> @@ -109,6 +109,7 @@ int dflag; int tflag; int verbose; int donothing; +char print_unit; #ifdef DOSLABEL struct dos_partition *dosdp; /* DOS partition, if found */ @@ -140,7 +141,6 @@ main(int argc, char *argv[]) { int ch, f, writeable, error = 0; struct disklabel *lp; - char print_unit = 0; FILE *t; while ((ch = getopt(argc, argv, "ABEf:NRWb:cdenp:s:tvw")) != -1) diff --git a/sbin/disklabel/editor.c b/sbin/disklabel/editor.c index 48fbc431569..1b40da801f9 100644 --- a/sbin/disklabel/editor.c +++ b/sbin/disklabel/editor.c @@ -1,4 +1,4 @@ -/* $OpenBSD: editor.c,v 1.190 2009/04/11 23:57:56 krw Exp $ */ +/* $OpenBSD: editor.c,v 1.191 2009/04/12 01:01:24 krw Exp $ */ /* * Copyright (c) 1997-2000 Todd C. Miller <Todd.Miller@courtesan.com> @@ -17,7 +17,7 @@ */ #ifndef lint -static char rcsid[] = "$OpenBSD: editor.c,v 1.190 2009/04/11 23:57:56 krw Exp $"; +static char rcsid[] = "$OpenBSD: editor.c,v 1.191 2009/04/12 01:01:24 krw Exp $"; #endif /* not lint */ #include <sys/types.h> @@ -475,6 +475,13 @@ editor_allocspace(struct disklabel *lp) /* How big is the OpenBSD portion of the disk? */ find_bounds(lp); + if (print_unit == '\0') { + if (DL_BLKTOSEC(lp, MEG(10 * 1024)) > (ending_sector - + starting_sector)) + print_unit = 'm'; + else + print_unit = 'g'; + } cylsecs = lp->d_secpercyl; xtrasecs = totsecs = editor_countfree(lp); diff --git a/sbin/disklabel/extern.h b/sbin/disklabel/extern.h index 8de8d5dc753..b37d819778d 100644 --- a/sbin/disklabel/extern.h +++ b/sbin/disklabel/extern.h @@ -1,4 +1,4 @@ -/* $OpenBSD: extern.h,v 1.13 2009/04/11 16:54:28 krw Exp $ */ +/* $OpenBSD: extern.h,v 1.14 2009/04/12 01:01:24 krw Exp $ */ /* * Copyright (c) 2003 Theo de Raadt <deraadt@openbsd.org> @@ -32,6 +32,7 @@ extern char *mountpoints[MAXPARTITIONS]; extern int donothing; extern int dflag; extern int verbose; +extern char print_unit; #ifdef DOSLABEL extern struct dos_partition *dosdp; /* DOS partition, if found */ |