summaryrefslogtreecommitdiff
path: root/sbin
diff options
context:
space:
mode:
authorJoel Sing <jsing@cvs.openbsd.org>2010-04-28 17:26:47 +0000
committerJoel Sing <jsing@cvs.openbsd.org>2010-04-28 17:26:47 +0000
commit2059f1017be4abf146b1713ff4dc36d232deb871 (patch)
tree96ef6b72753bffd5fdf73dbe64d1f832888239dd /sbin
parenta32f2c23a0de7d5b9e38b3e9cf200f955dec3329 (diff)
Add a new 'i' command to the disklabel interactive editor, allowing the
disklabel UID to be changed. ok krw@ marco@
Diffstat (limited to 'sbin')
-rw-r--r--sbin/disklabel/disklabel.88
-rw-r--r--sbin/disklabel/editor.c41
2 files changed, 43 insertions, 6 deletions
diff --git a/sbin/disklabel/disklabel.8 b/sbin/disklabel/disklabel.8
index e230286beec..c4b8a0f8abb 100644
--- a/sbin/disklabel/disklabel.8
+++ b/sbin/disklabel/disklabel.8
@@ -1,4 +1,4 @@
-.\" $OpenBSD: disklabel.8,v 1.92 2010/04/21 06:56:57 jmc Exp $
+.\" $OpenBSD: disklabel.8,v 1.93 2010/04/28 17:26:46 jsing 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 21 2010 $
+.Dd $Mdocdate: April 28 2010 $
.Dt DISKLABEL 8
.Os
.Sh NAME
@@ -388,6 +388,10 @@ thinks (the
geometry is simply what the label said before
.Nm
made any changes).
+.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
+disklabel is written to disk.
.It Cm l Op Ar unit
Print the disk label header.
.It Cm M
diff --git a/sbin/disklabel/editor.c b/sbin/disklabel/editor.c
index 85362641e2a..b7473df7471 100644
--- a/sbin/disklabel/editor.c
+++ b/sbin/disklabel/editor.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: editor.c,v 1.235 2010/04/23 15:25:21 jsing Exp $ */
+/* $OpenBSD: editor.c,v 1.236 2010/04/28 17:26:46 jsing Exp $ */
/*
* Copyright (c) 1997-2000 Todd C. Miller <Todd.Miller@courtesan.com>
@@ -129,6 +129,7 @@ struct partition **sort_partitions(struct disklabel *);
void getdisktype(struct disklabel *, char *, char *);
void find_bounds(struct disklabel *);
void set_bounds(struct disklabel *);
+void set_uid(struct disklabel *);
struct diskchunk *free_chunks(struct disklabel *);
void mpcopy(char **, char **);
int micmp(const void *, const void *);
@@ -288,6 +289,10 @@ editor(struct disklabel *lp, int f)
set_geometry(&label, disk_geop, lp, arg);
break;
+ case 'i':
+ set_uid(&label);
+ break;
+
case 'm':
editor_modify(&label, arg);
break;
@@ -1596,6 +1601,33 @@ set_bounds(struct disklabel *lp)
}
/*
+ * Allow user to interactively change disklabel UID.
+ */
+void
+set_uid(struct disklabel *lp)
+{
+ u_int uid[8];
+ char *s;
+ int i;
+
+ printf("The disklabel UID is currently: ");
+ uid_print(stdout, lp);
+ printf("\n");
+
+ do {
+ s = getstring("uid", "The disklabel UID, given as a 16 "
+ "character hexadecimal string.", NULL);
+ if (strlen(s) == 0) {
+ fputs("Command aborted\n", stderr);
+ return;
+ }
+ i = uid_parse(lp, s);
+ if (i != 0)
+ fputs("Invalid UID entered.\n", stderr);
+ } while (i != 0);
+}
+
+/*
* Return a list of the "chunks" of free space available
*/
struct diskchunk *
@@ -1706,9 +1738,10 @@ editor_help(void)
" d [part] - delete partition U - undo all changes\n"
" e - edit drive parameters u - undo last change\n"
" g [d|u] - [d]isk or [u]ser geometry 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"
+" i - modify disklabel UID X - toggle expert mode\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"
"\t'b' (bytes), 'k' (kilobytes), 'm' (megabytes), 'g' (gigabytes)\n"