summaryrefslogtreecommitdiff
path: root/sbin/disklabel
diff options
context:
space:
mode:
authorTheo de Raadt <deraadt@cvs.openbsd.org>2009-03-29 05:37:14 +0000
committerTheo de Raadt <deraadt@cvs.openbsd.org>2009-03-29 05:37:14 +0000
commitf18cf4b433e70cc12e7ebacebc3b94cda031ee6e (patch)
treef0b7136448ab07e93b32386a906d056576ec86f5 /sbin/disklabel
parenta8e015d4201b83f7fa0892ac113809adda0babdd (diff)
otto points out that the -v printing changes are incompatible with the
expectation that -R will read the output of disklabel. I suspect we will find another way to do this; ok otto
Diffstat (limited to 'sbin/disklabel')
-rw-r--r--sbin/disklabel/disklabel.c123
-rw-r--r--sbin/disklabel/editor.c10
-rw-r--r--sbin/disklabel/extern.h6
3 files changed, 61 insertions, 78 deletions
diff --git a/sbin/disklabel/disklabel.c b/sbin/disklabel/disklabel.c
index f1cc4fd36d3..b72db749acb 100644
--- a/sbin/disklabel/disklabel.c
+++ b/sbin/disklabel/disklabel.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: disklabel.c,v 1.142 2009/03/28 16:27:24 krw Exp $ */
+/* $OpenBSD: disklabel.c,v 1.143 2009/03/29 05:37:13 deraadt 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.142 2009/03/28 16:27:24 krw Exp $";
+static const char rcsid[] = "$OpenBSD: disklabel.c,v 1.143 2009/03/29 05:37:13 deraadt Exp $";
#endif /* not lint */
#include <sys/param.h>
@@ -292,8 +292,7 @@ main(int argc, char *argv[])
if (tflag)
makedisktab(stdout, lp);
else
- display(stdout, lp, NULL, print_unit,
- (verbose ? SHOW_PHYSINFO : 0) | SHOW_PARTINFO);
+ display(stdout, lp, NULL, print_unit, 1);
error = checklabel(lp);
break;
case RESTORE:
@@ -597,24 +596,20 @@ findopenbsd(int f, off_t mbroff, struct dos_partition **first, int *n)
}
switch (dp[part].dp_typ) {
case DOSPTYP_OPENBSD:
- if (verbose)
- fprintf(stderr, "# Inside MBR partition %d: "
- "type %02X start %u size %u\n",
- part, dp[part].dp_typ,
- letoh32(dp[part].dp_start),
- letoh32(dp[part].dp_size));
+ fprintf(stderr, "# Inside MBR partition %d: "
+ "type %02X start %u size %u\n",
+ part, dp[part].dp_typ,
+ letoh32(dp[part].dp_start), letoh32(dp[part].dp_size));
bcopy(&dp[part], &res, sizeof(struct dos_partition));
res.dp_start =
htole32((off_t)letoh32(res.dp_start) + mbroff);
return (&res);
case DOSPTYP_EXTEND:
case DOSPTYP_EXTENDL:
- if (verbose)
- fprintf(stderr, "# Extended partition %d: "
- "type %02X start %u size %u\n",
- part, dp[part].dp_typ,
- letoh32(dp[part].dp_start),
- letoh32(dp[part].dp_size));
+ fprintf(stderr, "# Extended partition %d: "
+ "type %02X start %u size %u\n",
+ part, dp[part].dp_typ,
+ letoh32(dp[part].dp_start), letoh32(dp[part].dp_size));
start = letoh32(dp[part].dp_start) + mbroff;
p = findopenbsd(f, start, NULL, n);
if (p != NULL)
@@ -1016,69 +1011,63 @@ display_partition(FILE *f, struct disklabel *lp, char **mp, int i,
}
void
-display(FILE *f, struct disklabel *lp, char **mp, char unit, int opts)
+display(FILE *f, struct disklabel *lp, char **mp, char unit, int all)
{
int i, j;
double d;
unit = toupper(unit);
+ fprintf(f, "# %s:\n", specname);
- if (opts & SHOW_PHYSINFO) {
- fprintf(f, "# %s:\n", specname);
- if ((unsigned) lp->d_type < DKMAXTYPES)
- fprintf(f, "type: %s\n", dktypenames[lp->d_type]);
- else
- fprintf(f, "type: %d\n", lp->d_type);
- fprintf(f, "disk: %.*s\n", (int)sizeof(lp->d_typename),
- lp->d_typename);
- fprintf(f, "label: %.*s\n", (int)sizeof(lp->d_packname),
- lp->d_packname);
- fprintf(f, "flags:");
- if (lp->d_flags & D_BADSECT)
- fprintf(f, " badsect");
- if (lp->d_flags & D_VENDOR)
- fprintf(f, " vendor");
- putc('\n', f);
-
- fprintf(f, "bytes/sector: %u\n", lp->d_secsize);
- fprintf(f, "sectors/track: %u\n", lp->d_nsectors);
- fprintf(f, "tracks/cylinder: %u\n", lp->d_ntracks);
- fprintf(f, "sectors/cylinder: %u\n", lp->d_secpercyl);
- fprintf(f, "cylinders: %u\n", lp->d_ncylinders);
- d = scale(DL_GETDSIZE(lp), unit, lp);
- if (d < 0)
- fprintf(f, "total sectors: %llu\n", DL_GETDSIZE(lp));
- else
- fprintf(f, "total bytes: %.*f%c\n", unit == 'B' ? 0 : 1,
- d, unit);
-
- fprintf(f, "rpm: %hu\n", lp->d_rpm);
- fprintf(f, "interleave: %hu\n", lp->d_interleave);
- fprintf(f, "trackskew: %hu\n", lp->d_trackskew);
- fprintf(f, "cylinderskew: %hu\n", lp->d_cylskew);
- fprintf(f, "headswitch: %u\t\t# microseconds\n",
- lp->d_headswitch);
- fprintf(f, "track-to-track seek: %u\t# microseconds\n",
- lp->d_trkseek);
- fprintf(f, "drivedata: ");
- for (i = NDDATA - 1; i >= 0; i--)
- if (lp->d_drivedata[i])
- break;
- if (i < 0)
- i = 0;
- for (j = 0; j <= i; j++)
- fprintf(f, "%d ", lp->d_drivedata[j]);
- fprintf(f, "\n");
- }
-
- if (opts & SHOW_PARTINFO) {
+ if ((unsigned) lp->d_type < DKMAXTYPES)
+ fprintf(f, "type: %s\n", dktypenames[lp->d_type]);
+ else
+ fprintf(f, "type: %d\n", lp->d_type);
+ fprintf(f, "disk: %.*s\n", (int)sizeof(lp->d_typename), lp->d_typename);
+ fprintf(f, "label: %.*s\n", (int)sizeof(lp->d_packname), lp->d_packname);
+ fprintf(f, "flags:");
+ if (lp->d_flags & D_BADSECT)
+ fprintf(f, " badsect");
+ if (lp->d_flags & D_VENDOR)
+ fprintf(f, " vendor");
+ putc('\n', f);
+
+ fprintf(f, "bytes/sector: %u\n", lp->d_secsize);
+ fprintf(f, "sectors/track: %u\n", lp->d_nsectors);
+ fprintf(f, "tracks/cylinder: %u\n", lp->d_ntracks);
+ fprintf(f, "sectors/cylinder: %u\n", lp->d_secpercyl);
+ fprintf(f, "cylinders: %u\n", lp->d_ncylinders);
+ d = scale(DL_GETDSIZE(lp), unit, lp);
+ if (d < 0)
+ fprintf(f, "total sectors: %llu\n", DL_GETDSIZE(lp));
+ else
+ fprintf(f, "total bytes: %.*f%c\n", unit == 'B' ? 0 : 1,
+ d, unit);
+
+ fprintf(f, "rpm: %hu\n", lp->d_rpm);
+ fprintf(f, "interleave: %hu\n", lp->d_interleave);
+ fprintf(f, "trackskew: %hu\n", lp->d_trackskew);
+ fprintf(f, "cylinderskew: %hu\n", lp->d_cylskew);
+ fprintf(f, "headswitch: %u\t\t# microseconds\n",
+ lp->d_headswitch);
+ fprintf(f, "track-to-track seek: %u\t# microseconds\n",
+ lp->d_trkseek);
+ fprintf(f, "drivedata: ");
+ for (i = NDDATA - 1; i >= 0; i--)
+ if (lp->d_drivedata[i])
+ break;
+ if (i < 0)
+ i = 0;
+ for (j = 0; j <= i; j++)
+ fprintf(f, "%d ", lp->d_drivedata[j]);
+ fprintf(f, "\n");
+ if (all) {
fprintf(f, "\n%hu partitions:\n", lp->d_npartitions);
fprintf(f, "# %16.16s %16.16s fstype [fsize bsize cpg]\n",
"size", "offset");
for (i = 0; i < lp->d_npartitions; i++)
display_partition(f, lp, mp, i, unit);
}
-
fflush(f);
}
diff --git a/sbin/disklabel/editor.c b/sbin/disklabel/editor.c
index 17806e5f016..baf72f5337b 100644
--- a/sbin/disklabel/editor.c
+++ b/sbin/disklabel/editor.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: editor.c,v 1.181 2009/03/28 17:50:05 deraadt Exp $ */
+/* $OpenBSD: editor.c,v 1.182 2009/03/29 05:37:13 deraadt 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.181 2009/03/28 17:50:05 deraadt Exp $";
+static char rcsid[] = "$OpenBSD: editor.c,v 1.182 2009/03/29 05:37:13 deraadt Exp $";
#endif /* not lint */
#include <sys/types.h>
@@ -288,8 +288,7 @@ editor(struct disklabel *lp, int f, char *dev, char *fstabfile, int aflag)
break;
case 'l':
- display(stdout, &label, mountpoints, arg ? *arg : 0,
- SHOW_PHYSINFO);
+ display(stdout, &label, mountpoints, arg ? *arg : 0, 0);
break;
case 'M': {
@@ -373,8 +372,7 @@ editor(struct disklabel *lp, int f, char *dev, char *fstabfile, int aflag)
if ((fp = fopen(arg, "w")) == NULL) {
warn("cannot open %s", arg);
} else {
- display(fp, &label, NULL, 0, SHOW_PHYSINFO |
- SHOW_PARTINFO);
+ display(fp, &label, NULL, 0, 1);
(void)fclose(fp);
}
break;
diff --git a/sbin/disklabel/extern.h b/sbin/disklabel/extern.h
index 74daf49ee80..1e3ec76e123 100644
--- a/sbin/disklabel/extern.h
+++ b/sbin/disklabel/extern.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: extern.h,v 1.10 2009/03/28 16:27:24 krw Exp $ */
+/* $OpenBSD: extern.h,v 1.11 2009/03/29 05:37:13 deraadt Exp $ */
/*
* Copyright (c) 2003 Theo de Raadt <deraadt@openbsd.org>
@@ -16,10 +16,6 @@
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
-/* Display options. */
-#define SHOW_PHYSINFO 0x1
-#define SHOW_PARTINFO 0x2
-
u_short dkcksum(struct disklabel *);
int checklabel(struct disklabel *);
double scale(u_int64_t, char, struct disklabel *);