diff options
author | Kenneth R Westerback <krw@cvs.openbsd.org> | 2023-05-13 18:13:43 +0000 |
---|---|---|
committer | Kenneth R Westerback <krw@cvs.openbsd.org> | 2023-05-13 18:13:43 +0000 |
commit | c3fea3e9c4eaf987efff30685231d472cddfb9b7 (patch) | |
tree | 0eae81f6b7dd2e31d29e4a78431ad95b90f4bcb6 /sbin/disklabel | |
parent | ca88671d354393bfccf2b205d421b1b8b8a4a300 (diff) |
In the absence of the 'disktype' command line parameter always
use the d_type value provided by the kernel when creating,
editing or printing a disklabel.
i.e. treat d_type as disk geometry is treated, reflecting
current reality as opposed to historical data.
Diffstat (limited to 'sbin/disklabel')
-rw-r--r-- | sbin/disklabel/disklabel.8 | 6 | ||||
-rw-r--r-- | sbin/disklabel/disklabel.c | 24 | ||||
-rw-r--r-- | sbin/disklabel/editor.c | 117 |
3 files changed, 13 insertions, 134 deletions
diff --git a/sbin/disklabel/disklabel.8 b/sbin/disklabel/disklabel.8 index 389f1ec9a8c..8c7735eb6b1 100644 --- a/sbin/disklabel/disklabel.8 +++ b/sbin/disklabel/disklabel.8 @@ -1,4 +1,4 @@ -.\" $OpenBSD: disklabel.8,v 1.154 2023/04/27 14:19:28 krw Exp $ +.\" $OpenBSD: disklabel.8,v 1.155 2023/05/13 18:13:42 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: April 27 2023 $ +.Dd $Mdocdate: May 13 2023 $ .Dt DISKLABEL 8 .Os .Sh NAME @@ -353,7 +353,7 @@ Delete an existing partition (or to delete all partitions). If no partition is specified, the user will be prompted for one. .It Cm e -Edit disk type, e.g. 'SCSI', and label description, e.g. 'UMIS RPJTJ256MED'. +Edit label description, e.g. 'UMIS RPJTJ256MED'. .It Cm i Change the disklabel UID, specified as a 16-character hexadecimal string. If set to all zeros, a new UID will automatically be allocated when the diff --git a/sbin/disklabel/disklabel.c b/sbin/disklabel/disklabel.c index 7d7e4396b87..de1f28030f4 100644 --- a/sbin/disklabel/disklabel.c +++ b/sbin/disklabel/disklabel.c @@ -1,4 +1,4 @@ -/* $OpenBSD: disklabel.c,v 1.248 2023/05/06 15:07:02 krw Exp $ */ +/* $OpenBSD: disklabel.c,v 1.249 2023/05/13 18:13:42 krw Exp $ */ /* * Copyright (c) 1987, 1993 @@ -354,6 +354,7 @@ readlabel(int f) lab.d_ntracks = dl.d_ntracks; lab.d_secpercyl = dl.d_secpercyl; lab.d_ncylinders = dl.d_ncylinders; + lab.d_type = dl.d_type; } } @@ -840,24 +841,6 @@ getasciilabel(FILE *f, struct disklabel *lp) continue; } *tp++ = '\0', tp = skip(tp); - if (!strcmp(cp, "type")) { - if (tp == NULL) - tp = "unknown"; - else if (strcasecmp(tp, "IDE") == 0) - tp = "ESDI"; - cpp = dktypenames; - for (; cpp < &dktypenames[DKMAXTYPES]; cpp++) - if ((s = *cpp) && !strcasecmp(s, tp)) { - lp->d_type = cpp - dktypenames; - goto next; - } - v = GETNUM(lp->d_type, tp, 0, &errstr); - if (errstr || v >= DKMAXTYPES) - warnx("line %d: warning, unknown disk type: %s", - lineno, tp); - lp->d_type = v; - continue; - } if (!strcmp(cp, "flags")) { for (v = 0; (cp = tp) && *cp != '\0';) { tp = word(cp); @@ -919,7 +902,8 @@ getasciilabel(FILE *f, struct disklabel *lp) !strcmp(cp, "sectors/track") || !strcmp(cp, "sectors/cylinder") || !strcmp(cp, "tracks/cylinder") || - !strcmp(cp, "cylinders")) + !strcmp(cp, "cylinders") || + !strcmp(cp, "type")) continue; if ('a' <= *cp && *cp <= 'z' && cp[1] == '\0') { diff --git a/sbin/disklabel/editor.c b/sbin/disklabel/editor.c index d813adde53f..eb1bbc35675 100644 --- a/sbin/disklabel/editor.c +++ b/sbin/disklabel/editor.c @@ -1,4 +1,4 @@ -/* $OpenBSD: editor.c,v 1.404 2023/04/27 14:19:28 krw Exp $ */ +/* $OpenBSD: editor.c,v 1.405 2023/05/13 18:13:42 krw Exp $ */ /* * Copyright (c) 1997-2000 Todd C. Miller <millert@openbsd.org> @@ -136,7 +136,7 @@ struct alloc_table alloc_table_default[] = { struct alloc_table *alloc_table = alloc_table_default; int alloc_table_nitems = 4; -void edit_parms(struct disklabel *); +void edit_packname(struct disklabel *); void editor_resize(struct disklabel *, const char *); void editor_add(struct disklabel *, const char *); void editor_change(struct disklabel *, const char *); @@ -153,7 +153,6 @@ int getpartno(const struct disklabel *, const char *, const char *); int has_overlap(struct disklabel *); int partition_cmp(const void *, const void *); const struct partition **sort_partitions(const struct disklabel *, int); -void getdisktype(struct disklabel *, const char *, char *); void find_bounds(const struct disklabel *); void set_bounds(struct disklabel *); void set_duid(struct disklabel *); @@ -202,10 +201,6 @@ editor(int f) !(tmpmountpoints = calloc(MAXPARTITIONS, sizeof(char *)))) errx(4, "out of memory"); - /* Don't allow disk type of "unknown" */ - getdisktype(&newlab, "You need to specify a type for this disk.", - specname); - /* How big is the OpenBSD portion of the disk? */ find_bounds(&newlab); @@ -310,7 +305,7 @@ editor(int f) break; case 'e': - edit_parms(&newlab); + edit_packname(&newlab); break; case 'i': @@ -1229,41 +1224,12 @@ done: } void -edit_parms(struct disklabel *lp) +edit_packname(struct disklabel *lp) { char *p; - u_int64_t ui; struct disklabel oldlabel = *lp; - printf("Changing disk type and label description for %s:\n", specname); - - /* disk type */ - for (;;) { - p = getstring("disk type", - "What kind of disk is this? Usually SCSI, ESDI, ST506, or " - "floppy (use ESDI for IDE).", dktypenames[lp->d_type]); - if (p == NULL) - return; - if (strcasecmp(p, "IDE") == 0) - ui = DTYPE_ESDI; - else - for (ui = 1; ui < DKMAXTYPES && strcasecmp(p, - dktypenames[ui]); ui++) - ; - if (ui < DKMAXTYPES) { - break; - } else { - printf("\"%s\" is not a valid disk type.\n", p); - fputs("Valid types are: ", stdout); - for (ui = 1; ui < DKMAXTYPES; ui++) { - printf("\"%s\"", dktypenames[ui]); - if (ui < DKMAXTYPES - 1) - fputs(", ", stdout); - } - putchar('\n'); - } - } - lp->d_type = ui; + printf("Changing label description for %s:\n", specname); /* pack/label id */ p = getstring("label name", @@ -1303,77 +1269,6 @@ sort_partitions(const struct disklabel *lp, int ignore) } /* - * Get a valid disk type if necessary. - */ -void -getdisktype(struct disklabel *lp, const char *banner, char *dev) -{ - int i; - char *s; - const char *def = "SCSI"; - const struct dtypes { - const char *dev; - const char *type; - } dtypes[] = { - { "sd", "SCSI" }, - { "wd", "IDE" }, - { "fd", "FLOPPY" }, - { "vnd", "VND" }, - }; - - if ((s = basename(dev)) != NULL) { - if (*s == 'r') - s++; - i = strcspn(s, "0123456789"); - s[i] = '\0'; - dev = s; - for (i = 0; i < nitems(dtypes); i++) { - if (strcmp(dev, dtypes[i].dev) == 0) { - def = dtypes[i].type; - break; - } - } - } - - if (lp->d_type > DKMAXTYPES || lp->d_type == 0) { - puts(banner); - puts("Possible values are:"); - printf("\"IDE\", "); - for (i = 1; i < DKMAXTYPES; i++) { - printf("\"%s\"", dktypenames[i]); - if (i < DKMAXTYPES - 1) - fputs(", ", stdout); - } - putchar('\n'); - - for (;;) { - s = getstring("Disk type", - "What kind of disk is this? Usually SCSI, IDE, " - "ESDI, ST506, or floppy.", def); - if (s == NULL) - continue; - if (strcasecmp(s, "IDE") == 0) { - lp->d_type = DTYPE_ESDI; - return; - } - for (i = 1; i < DKMAXTYPES; i++) - if (strcasecmp(s, dktypenames[i]) == 0) { - lp->d_type = i; - return; - } - printf("\"%s\" is not a valid disk type.\n", s); - fputs("Valid types are: ", stdout); - for (i = 1; i < DKMAXTYPES; i++) { - printf("\"%s\"", dktypenames[i]); - if (i < DKMAXTYPES - 1) - fputs(", ", stdout); - } - putchar('\n'); - } - } -} - -/* * Get beginning and ending sectors of the OpenBSD portion of the disk * from the user. */ @@ -1547,7 +1442,7 @@ editor_help(void) " c [part] - change partition size r - display free space\n" " D - reset label to default s [path] - save label to file\n" " d [part] - delete partition U - undo all changes\n" -" e - edit type and label name u - undo last change\n" +" e - edit label description u - undo last change\n" " i - modify disklabel UID w - write label to disk\n" " l [unit] - print disk label header x - exit & lose changes\n" " M - disklabel(8) man page z - delete all partitions\n" |