-.\" $OpenBSD: disklabel.8,v 1.153 2023/02/20 14:16:59 krw Exp $
+.\" $OpenBSD: disklabel.8,v 1.154 2023/04/27 14:19:28 krw Exp $
.\" $NetBSD: disklabel.8,v 1.9 1995/03/18 14:54:38 cgd Exp $
.\"
.\" Copyright (c) 1987, 1988, 1991, 1993
.\"
.\" @(#)disklabel.8 8.2 (Berkeley) 4/19/94
.\"
-.Dd $Mdocdate: February 20 2023 $
+.Dd $Mdocdate: April 27 2023 $
.Dt DISKLABEL 8
.Os
.Sh NAME
is the name of the disk being edited,
.Sq *
means that the in-memory copy of the partition table has been modified but
-not yet written to disk and the
-.Sq >
-is replaced by
-.Sq #
-when the editor is in expert mode.
+not yet written to disk.
.Pp
Some commands or prompts take an optional unit.
Available units are
This option allows
the user to change the filesystem type, starting offset, partition size,
and mount point for the specified partition.
-If expert mode is enabled (see
-.Cm X
-below), then block fragment size, block size, and cylinders per group
-can also be modified.
-Note that not all parameters are configurable for
-.Pf non- Bx
-partitions.
.It Cm n Op Ar part
Name the mount point for an existing partition.
If no partition is specified, the user will be prompted for one.
.It Cm w
Write the label to disk.
This option will commit any changes to the on-disk label.
-.It Cm X
-Toggle
-.Dq expert mode .
-By default, some settings are reserved for experts only
-(such as the block and fragment size on ffs partitions).
-While in expert mode the command line prompt will end
-with
-.Ql #
-instead of
-.Ql > .
.It Cm x
Exit the editor without saving any changes to the on-disk label.
.It Cm z
-/* $OpenBSD: editor.c,v 1.403 2023/02/18 15:22:40 miod Exp $ */
+/* $OpenBSD: editor.c,v 1.404 2023/04/27 14:19:28 krw Exp $ */
/*
* Copyright (c) 1997-2000 Todd C. Miller <millert@openbsd.org>
static u_int64_t starting_sector;
static u_int64_t ending_sector;
-static int expert;
static int resizeok;
/*
puts("Label editor (enter '?' for help at any prompt)");
for (;;) {
- fprintf(stdout, "%s%s%c ", dkname,
- (memcmp(&lab, &newlab, sizeof(newlab)) == 0) ? "" : "*",
- (expert == 0) ? '>' : '#');
+ fprintf(stdout, "%s%s> ", dkname,
+ (memcmp(&lab, &newlab, sizeof(newlab)) == 0) ? "" : "*");
if (fgets(buf, sizeof(buf), stdin) == NULL) {
putchar('\n');
buf[0] = 'q';
warn("DIOCGPDINFO");
newlab = lastlabel;
} else {
- int oquiet = quiet, oexpert = expert;
+ int oquiet = quiet;
aflag = 1;
- quiet = expert = 0;
+ quiet = 0;
editor_allocspace(&newlab);
quiet = oquiet;
- expert = oexpert;
}
break;
case 'a':
}
break;
- case 'X':
- expert = !expert;
- printf("%s expert mode\n", expert ? "Entering" :
- "Exiting");
- break;
-
case 'x':
goto done;
break;
" d [part] - delete partition U - undo all changes\n"
" e - edit type and label name u - undo last change\n"
" i - modify disklabel UID w - write label to disk\n"
-" l [unit] - print disk label header X - toggle expert mode\n"
-" M - disklabel(8) man page x - exit & lose changes\n"
-" m [part] - modify partition z - delete all partitions\n"
+" l [unit] - print disk label header x - exit & lose changes\n"
+" M - disklabel(8) man page z - delete all partitions\n"
+" m [part] - modify partition\n"
"\n"
"Suffixes can be used to indicate units other than sectors:\n"
" 'b' (bytes), 'k' (kilobytes), 'm' (megabytes), 'g' (gigabytes) 't' (terabytes)\n"
return (1);
}
- if (expert == 1 && quiet == 0 && ui != DL_GETPOFFSET(pp))
- printf("offset rounded to sector %llu\n", DL_GETPOFFSET(pp));
-
return (0);
}
return (1);
}
- if (expert == 1 && quiet == 0 && ui != DL_GETPSIZE(pp))
- printf("size rounded to %llu sectors\n", DL_GETPSIZE(pp));
-
return (0);
}
int
get_cpg(struct disklabel *lp, int partno)
{
- u_int64_t ui;
struct partition *pp = &lp->d_partitions[partno];
if (pp->p_fstype != FS_BSDFFS)
if (pp->p_cpg == 0)
pp->p_cpg = 1;
- if (expert == 0)
- return (0);
-
- for (;;) {
- ui = getnumber("cpg", "Size of partition in fs blocks.",
- pp->p_cpg, USHRT_MAX);
- if (ui == CMD_ABORTED)
- return (1);
- else if (ui == CMD_BADVALUE)
- ; /* Try again. */
- else
- break;
- }
- pp->p_cpg = ui;
return (0);
}
get_fsize(struct disklabel *lp, int partno)
{
struct partition *pp = &lp->d_partitions[partno];
- u_int64_t ui, bytes;
+ u_int64_t bytes;
u_int32_t frag, fsize;
if (pp->p_fstype != FS_BSDFFS)
pp->p_fragblock = DISKLABELV1_FFS_FRAGBLOCK(fsize, frag);
}
- if (expert == 0)
- return (0);
-
- for (;;) {
- ui = getnumber("fragment size",
- "Size of ffs block fragments. A multiple of the disk "
- "sector-size.", fsize, UINT32_MAX);
- if (ui == CMD_ABORTED)
- return (1);
- else if (ui == CMD_BADVALUE)
- ; /* Try again. */
- else if (ui < lp->d_secsize || (ui % lp->d_secsize) != 0)
- fprintf(stderr, "Error: fragment size must be a "
- "multiple of the disk sector size (%d)\n",
- lp->d_secsize);
- else
- break;
- }
- if (ui == 0)
- puts("Zero fragment size implies zero block size");
- pp->p_fragblock = DISKLABELV1_FFS_FRAGBLOCK(ui, frag);
return (0);
}
int
get_bsize(struct disklabel *lp, int partno)
{
- u_int64_t ui, frag, fsize;
struct partition opp, *pp = &lp->d_partitions[partno];
u_int64_t offsetalign, sizealign;
- char *p;
if (pp->p_fstype != FS_BSDFFS)
return (0);
if (pp->p_fragblock == 0)
return (1);
- opp = *pp;
- if (expert == 0)
- goto align;
-
- fsize = DISKLABELV1_FFS_FSIZE(pp->p_fragblock);
- frag = DISKLABELV1_FFS_FRAG(pp->p_fragblock);
-
- for (;;) {
- ui = getnumber("block size",
- "Size of ffs blocks. 1, 2, 4 or 8 times ffs fragment size.",
- fsize * frag, UINT32_MAX);
-
- /* sanity checks */
- if (ui == CMD_ABORTED)
- return (1);
- else if (ui == CMD_BADVALUE)
- ; /* Try again. */
- else if (ui < getpagesize())
- fprintf(stderr,
- "Error: block size must be at least as big "
- "as page size (%d).\n", getpagesize());
- else if (ui < fsize || (fsize != ui && fsize * 2 != ui &&
- fsize * 4 != ui && fsize * 8 != ui))
- fprintf(stderr, "Error: block size must be 1, 2, 4 or "
- "8 times fragment size (%llu).\n",
- (unsigned long long) fsize);
- else
- break;
- }
- frag = ui / fsize;
- pp->p_fragblock = DISKLABELV1_FFS_FRAGBLOCK(fsize, frag);
-
-#ifdef SUN_CYLCHECK
- return (0);
-#endif
- p = getstring("Align partition to block size",
- "Round the partition offset and size to multiples of bsize?", "y");
- if (*p == 'n' || *p == 'N')
- return (0);
-
-align:
#ifdef SUN_CYLCHECK
return (0);
#endif
+ opp = *pp;
sizealign = (DISKLABELV1_FFS_FRAG(pp->p_fragblock) *
DISKLABELV1_FFS_FSIZE(pp->p_fragblock)) / lp->d_secsize;
offsetalign = 1;
return (1);
}
- if (expert == 1 && quiet == 0 &&
- DL_GETPOFFSET(&opp) != DL_GETPOFFSET(pp))
- printf("offset rounded to sector %llu\n", DL_GETPOFFSET(pp));
- if (expert == 1 && quiet == 0 && DL_GETPSIZE(&opp) != DL_GETPSIZE(pp))
- printf("size rounded to %llu sectors\n", DL_GETPSIZE(pp));
-
return (0);
}