Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/netbsd-1-5]: src/sbin/disklabel Pullup 1.13-1.15 [christos]:
details: https://anonhg.NetBSD.org/src/rev/3bdbb8d112cc
branches: netbsd-1-5
changeset: 489880:3bdbb8d112cc
user: tv <tv%NetBSD.org@localhost>
date: Wed Oct 18 02:53:09 2000 +0000
description:
Pullup 1.13-1.15 [christos]:
supported disk types printout, sizeof parentheses, better error messages.
diffstat:
sbin/disklabel/interact.c | 274 +++++++++++++++++++++++++++++++--------------
1 files changed, 187 insertions(+), 87 deletions(-)
diffs (truncated from 512 to 300 lines):
diff -r cd506af1929b -r 3bdbb8d112cc sbin/disklabel/interact.c
--- a/sbin/disklabel/interact.c Wed Oct 18 02:52:44 2000 +0000
+++ b/sbin/disklabel/interact.c Wed Oct 18 02:53:09 2000 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: interact.c,v 1.13 1999/12/17 13:06:49 abs Exp $ */
+/* $NetBSD: interact.c,v 1.13.4.1 2000/10/18 02:53:09 tv Exp $ */
/*
* Copyright (c) 1997 Christos Zoulas. All rights reserved.
@@ -31,7 +31,7 @@
#include <sys/cdefs.h>
#ifndef lint
-__RCSID("$NetBSD: interact.c,v 1.13 1999/12/17 13:06:49 abs Exp $");
+__RCSID("$NetBSD: interact.c,v 1.13.4.1 2000/10/18 02:53:09 tv Exp $");
#endif /* lint */
#include <sys/param.h>
@@ -58,10 +58,10 @@
static void cmd_name __P((struct disklabel *, char *, int));
static int runcmd __P((char *, struct disklabel *, int));
static int getinput __P((const char *, const char *, const char *, char *));
+static int alphacmp __P((const void *, const void *));
static void defnum __P((char *, struct disklabel *, int));
+static void dumpnames __P((const char *, const char * const *, size_t));
static int getnum __P((char *, int, struct disklabel *));
-static void deffstypename __P((char *, int));
-static int getfstypename __P((const char *));
static int rounding = 0; /* sector rounding */
static int chaining = 0; /* make partitions contiguous */
@@ -111,7 +111,6 @@
i = getinput(":", "Automatically adjust partitions",
chaining ? "yes" : "no", line);
-
if (i <= 0)
return;
@@ -156,30 +155,37 @@
{
char line[BUFSIZ];
char def[BUFSIZ];
- const char * const *cpp;
- const char *t;
int v, i;
u_int32_t u;
printf("# Current values:\n");
showinfo(stdout, lp);
- /* d_typename */
+ /* d_type */
for (;;) {
- strncpy(def, lp->d_typename, sizeof(def));
- def[sizeof(def) - 1] = '\0';
- i = getinput(":", "Disk type", def, line);
- if (i <= 0)
+ i = lp->d_type;
+ if (i < 0 || i >= DKMAXTYPES)
+ i = 0;
+ snprintf(def, sizeof(def), "%s", dktypenames[i]);
+ i = getinput(":", "Disk type [?]", def, line);
+ if (i == -1)
+ return;
+ else if (i == 0)
break;
- cpp = dktypenames;
- for (; cpp < &dktypenames[DKMAXTYPES]; cpp++)
- if ((t = *cpp) && !strcmp(t, line)) {
- lp->d_type = cpp - dktypenames;
+ if (!strcmp(line, "?")) {
+ dumpnames("Supported disk types", dktypenames,
+ DKMAXTYPES);
+ continue;
+ }
+ for (i = 0; i < DKMAXTYPES; i++) {
+ if (!strcasecmp(dktypenames[i], line)) {
+ lp->d_type = i;
goto done_typename;
}
+ }
v = atoi(line);
if ((unsigned)v >= DKMAXTYPES) {
- warnx("unknown disk type: %s", line);
+ warnx("Unknown disk type: %s", line);
continue;
}
lp->d_type = v;
@@ -187,17 +193,28 @@
break;
}
+ /* d_typename */
+ snprintf(def, sizeof(def), "%.*s",
+ (int) sizeof(lp->d_typename), lp->d_typename);
+ i = getinput(":", "Disk name", def, line);
+ if (i == -1)
+ return;
+ else if (i == 1)
+ (void) strncpy(lp->d_typename, line, sizeof(lp->d_typename));
+
/* d_packname */
cmd_name(lp, s, fd);
/* d_npartitions */
for (;;) {
- snprintf(def, sizeof def, "%u", lp->d_npartitions);
+ snprintf(def, sizeof(def), "%u", lp->d_npartitions);
i = getinput(":", "Number of partitions", def, line);
- if (i <= 0)
+ if (i == -1)
+ return;
+ else if (i == 0)
break;
if (sscanf(line, "%u", &u) != 1) {
- printf("Invalid sector size `%s'\n", line);
+ printf("Invalid number of partitions `%s'\n", line);
continue;
}
lp->d_npartitions = u;
@@ -206,9 +223,11 @@
/* d_secsize */
for (;;) {
- snprintf(def, sizeof def, "%u", lp->d_secsize);
+ snprintf(def, sizeof(def), "%u", lp->d_secsize);
i = getinput(":", "Sector size (bytes)", def, line);
- if (i <= 0)
+ if (i == -1)
+ return;
+ else if (i == 0)
break;
if (sscanf(line, "%u", &u) != 1) {
printf("Invalid sector size `%s'\n", line);
@@ -220,12 +239,14 @@
/* d_nsectors */
for (;;) {
- snprintf(def, sizeof def, "%u", lp->d_nsectors);
+ snprintf(def, sizeof(def), "%u", lp->d_nsectors);
i = getinput(":", "Number of sectors per track", def, line);
- if (i <= 0)
+ if (i == -1)
+ return;
+ else if (i == 0)
break;
if (sscanf(line, "%u", &u) != 1) {
- printf("Invalid number of sector `%s'\n", line);
+ printf("Invalid number of sectors `%s'\n", line);
continue;
}
lp->d_nsectors = u;
@@ -234,9 +255,11 @@
/* d_ntracks */
for (;;) {
- snprintf(def, sizeof def, "%u", lp->d_ntracks);
+ snprintf(def, sizeof(def), "%u", lp->d_ntracks);
i = getinput(":", "Number of tracks per cylinder", def, line);
- if (i <= 0)
+ if (i == -1)
+ return;
+ else if (i == 0)
break;
if (sscanf(line, "%u", &u) != 1) {
printf("Invalid number of tracks `%s'\n", line);
@@ -248,12 +271,15 @@
/* d_secpercyl */
for (;;) {
- snprintf(def, sizeof def, "%u", lp->d_secpercyl);
+ snprintf(def, sizeof(def), "%u", lp->d_secpercyl);
i = getinput(":", "Number of sectors/cylinder", def, line);
- if (i <= 0)
+ if (i == -1)
+ return;
+ else if (i == 0)
break;
if (sscanf(line, "%u", &u) != 1) {
- printf("Invalid number of sector/cylinder `%s'\n", line);
+ printf("Invalid number of sector/cylinder `%s'\n",
+ line);
continue;
}
lp->d_secpercyl = u;
@@ -262,9 +288,11 @@
/* d_ncylinders */
for (;;) {
- snprintf(def, sizeof def, "%u", lp->d_ncylinders);
+ snprintf(def, sizeof(def), "%u", lp->d_ncylinders);
i = getinput(":", "Total number of cylinders", def, line);
- if (i <= 0)
+ if (i == -1)
+ return;
+ else if (i == 0)
break;
if (sscanf(line, "%u", &u) != 1) {
printf("Invalid sector size `%s'\n", line);
@@ -276,12 +304,14 @@
/* d_secperunit */
for (;;) {
- snprintf(def, sizeof def, "%u", lp->d_secperunit);
+ snprintf(def, sizeof(def), "%u", lp->d_secperunit);
i = getinput(":", "Total number of sectors", def, line);
- if (i <= 0)
+ if (i == -1)
+ return;
+ else if (i == 0)
break;
if (sscanf(line, "%u", &u) != 1) {
- printf("Invalid number of sector `%s'\n", line);
+ printf("Invalid number of sectors `%s'\n", line);
continue;
}
lp->d_secperunit = u;
@@ -292,13 +322,14 @@
/* d_interleave */
for (;;) {
- snprintf(def, sizeof def, "%u", lp->d_interleave);
+ snprintf(def, sizeof(def), "%u", lp->d_interleave);
i = getinput(":", "Hardware sectors interleave", def, line);
-
- if (i <= 0)
+ if (i == -1)
+ return;
+ else if (i == 0)
break;
if (sscanf(line, "%u", &u) != 1) {
- printf("Invalid sector size `%s'\n", line);
+ printf("Invalid sector interleave `%s'\n", line);
continue;
}
lp->d_interleave = u;
@@ -307,12 +338,14 @@
/* d_trackskew */
for (;;) {
- snprintf(def, sizeof def, "%u", lp->d_trackskew);
+ snprintf(def, sizeof(def), "%u", lp->d_trackskew);
i = getinput(":", "Sector 0 skew, per track", def, line);
- if (i <= 0)
+ if (i == -1)
+ return;
+ else if (i == 0)
break;
if (sscanf(line, "%u", &u) != 1) {
- printf("Invalid sector size `%s'\n", line);
+ printf("Invalid track sector skew `%s'\n", line);
continue;
}
lp->d_trackskew = u;
@@ -321,12 +354,14 @@
/* d_cylskew */
for (;;) {
- snprintf(def, sizeof def, "%u", lp->d_cylskew);
+ snprintf(def, sizeof(def), "%u", lp->d_cylskew);
i = getinput(":", "Sector 0 skew, per cylinder", def, line);
- if (i <= 0)
+ if (i == -1)
+ return;
+ else if (i == 0)
break;
if (sscanf(line, "%u", &u) != 1) {
- printf("Invalid sector size `%s'\n", line);
+ printf("Invalid cylinder sector `%s'\n", line);
continue;
}
lp->d_cylskew = u;
@@ -335,12 +370,14 @@
/* d_headswitch */
for (;;) {
- snprintf(def, sizeof def, "%u", lp->d_headswitch);
+ snprintf(def, sizeof(def), "%u", lp->d_headswitch);
i = getinput(":", "Head switch time (usec)", def, line);
- if (i <= 0)
+ if (i == -1)
+ return;
+ else if (i == 0)
break;
if (sscanf(line, "%u", &u) != 1) {
- printf("Invalid sector size `%s'\n", line);
+ printf("Invalid head switch time `%s'\n", line);
continue;
}
lp->d_headswitch = u;
@@ -349,18 +386,19 @@
/* d_trkseek */
for (;;) {
- snprintf(def, sizeof def, "%u", lp->d_trkseek);
+ snprintf(def, sizeof(def), "%u", lp->d_trkseek);
i = getinput(":", "Track seek time (usec)", def, line);
- if (i <= 0)
+ if (i == -1)
Home |
Main Index |
Thread Index |
Old Index