diff options
author | Kenneth R Westerback <krw@cvs.openbsd.org> | 2008-01-08 23:46:55 +0000 |
---|---|---|
committer | Kenneth R Westerback <krw@cvs.openbsd.org> | 2008-01-08 23:46:55 +0000 |
commit | 9c95283c1b2ab03e520f6232d860f7dcb18efbda (patch) | |
tree | 7acc2ec588664f32646457ffe848f688d9217e80 /sbin | |
parent | d0ba60855ee0dc7fc5c75a0bdf9e24f33ab1b5e7 (diff) |
Beef up the (r)ecalculate command in -E mode by having it display the
details of the free space it calculates. Gives an easy way to see all
the chunks of free sectors on the disk.
ok beck@
Diffstat (limited to 'sbin')
-rw-r--r-- | sbin/disklabel/disklabel.8 | 7 | ||||
-rw-r--r-- | sbin/disklabel/editor.c | 32 |
2 files changed, 25 insertions, 14 deletions
diff --git a/sbin/disklabel/disklabel.8 b/sbin/disklabel/disklabel.8 index 2575f643170..2864073d2c7 100644 --- a/sbin/disklabel/disklabel.8 +++ b/sbin/disklabel/disklabel.8 @@ -1,4 +1,4 @@ -.\" $OpenBSD: disklabel.8,v 1.64 2007/12/16 14:58:27 sobrado Exp $ +.\" $OpenBSD: disklabel.8,v 1.65 2008/01/08 23:46:54 krw Exp $ .\" $NetBSD: disklabel.8,v 1.9 1995/03/18 14:54:38 cgd Exp $ .\" .\" Copyright (c) 1987, 1988, 1991, 1993 @@ -33,7 +33,7 @@ .\" .\" @(#)disklabel.8 8.2 (Berkeley) 4/19/94 .\" -.Dd $Mdocdate: December 16 2007 $ +.Dd $Mdocdate: January 8 2008 $ .Dt DISKLABEL 8 .Os .Sh NAME @@ -425,7 +425,8 @@ If any changes have been made, the user will be asked whether or not to save the changes to the on-disk label. .It Cm r Recalculate free space. -This option should really not be necessary under normal circumstances. +This command displays all the free areas on the disk and the total +number of free sectors. .It Cm s Op Ar path Save the label to a file in .Tn ASCII diff --git a/sbin/disklabel/editor.c b/sbin/disklabel/editor.c index ff93512fee8..d75f33e8f14 100644 --- a/sbin/disklabel/editor.c +++ b/sbin/disklabel/editor.c @@ -1,4 +1,4 @@ -/* $OpenBSD: editor.c,v 1.148 2008/01/08 13:12:26 krw Exp $ */ +/* $OpenBSD: editor.c,v 1.149 2008/01/08 23:46:54 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.148 2008/01/08 13:12:26 krw Exp $"; +static char rcsid[] = "$OpenBSD: editor.c,v 1.149 2008/01/08 23:46:54 krw Exp $"; #endif /* not lint */ #include <sys/types.h> @@ -344,11 +344,22 @@ editor(struct disklabel *lp, int f, char *dev, char *fstabfile) /* NOTREACHED */ break; - case 'r': - /* Recalculate free space */ - editor_countfree(&label, &freesectors); - puts("Recalculated free space."); - break; + case 'r': { + struct diskchunk *chunks; + int i; + /* Recalculate & display free space. */ + editor_countfree(&label, &freesectors); + chunks = free_chunks(&label); + for (i = 0; chunks[i].start != 0 || chunks[i].stop != 0; + i++) + fprintf(stderr, "Free sectors: %16llu - %16llu " + "(%16llu)\n", + chunks[i].start, chunks[i].stop - 1, + chunks[i].stop - chunks[i].start); + fprintf(stderr, "Total free sectors: %llu.\n", + freesectors); + break; + } case 's': if (arg == NULL) { @@ -1579,9 +1590,8 @@ editor_help(char *arg) break; case 'r': puts( -"The 'r' command is used to recalculate the free space available. This option\n" -"should really not be necessary under normal circumstances but can be useful if\n" -"disklabel gets confused.\n"); +"The 'r' command is used to recalculate and display details about\n" +"the available free space.\n"); break; case 'u': puts( @@ -1636,7 +1646,7 @@ editor_help(char *arg) puts("\tn [part] - set the mount point for a partition."); puts("\tp [unit] - print label."); puts("\tq - quit and save changes."); - puts("\tr - recalculate free space."); + puts("\tr - recalculate & display free space details."); puts("\ts [path] - save label to file."); puts("\tu - undo last change."); puts("\tw - write label to disk."); |