summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sbin/fdisk/cmd.c42
-rw-r--r--sbin/fdisk/cmd.h3
-rw-r--r--sbin/fdisk/fdisk.87
-rw-r--r--sbin/fdisk/user.c3
4 files changed, 51 insertions, 4 deletions
diff --git a/sbin/fdisk/cmd.c b/sbin/fdisk/cmd.c
index db341992bdc..2bbfbfe9230 100644
--- a/sbin/fdisk/cmd.c
+++ b/sbin/fdisk/cmd.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: cmd.c,v 1.26 2000/07/01 21:49:12 mickey Exp $ */
+/* $OpenBSD: cmd.c,v 1.27 2001/01/01 21:05:33 angelos Exp $ */
/*
* Copyright (c) 1997 Tobias Weingartner
@@ -193,6 +193,46 @@ Xedit(cmd, disk, mbr, tt, offset)
}
int
+Xsetpid(cmd, disk, mbr, tt, offset)
+ cmd_t *cmd;
+ disk_t *disk;
+ mbr_t *mbr;
+ mbr_t *tt;
+ int offset;
+{
+ int pn, num, ret;
+ prt_t *pp;
+
+ ret = CMD_CONT;
+
+ if (!isdigit(cmd->args[0])) {
+ printf("Invalid argument: %s <partition number>\n", cmd->cmd);
+ return (ret);
+ }
+ pn = atoi(cmd->args);
+
+ if (pn < 0 || pn > 3) {
+ printf("Invalid partition number.\n");
+ return (ret);
+ }
+
+ /* Print out current table entry */
+ pp = &mbr->part[pn];
+ PRT_print(0, NULL);
+ PRT_print(pn, pp);
+
+#define EDIT(p, f, v, n, m, h) \
+ if ((num = ask_num(p, f, v, n, m, h)) != v) \
+ ret = CMD_DIRTY; \
+ v = num;
+
+ /* Ask for partition type */
+ EDIT("Partition id ('0' to disable) ", ASK_HEX, pp->id, 0, 0xFF, PRT_printall);
+
+#undef EDIT
+ return (ret);
+}
+int
Xselect(cmd, disk, mbr, tt, offset)
cmd_t *cmd;
disk_t *disk;
diff --git a/sbin/fdisk/cmd.h b/sbin/fdisk/cmd.h
index 73ae93889dc..2620742ff3a 100644
--- a/sbin/fdisk/cmd.h
+++ b/sbin/fdisk/cmd.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: cmd.h,v 1.4 1997/10/16 10:35:06 deraadt Exp $ */
+/* $OpenBSD: cmd.h,v 1.5 2001/01/01 21:05:33 angelos Exp $ */
/*
* Copyright (c) 1997 Tobias Weingartner
@@ -66,6 +66,7 @@ int Xreinit __P((cmd_t *, disk_t *, mbr_t *, mbr_t *, int));
int Xdisk __P((cmd_t *, disk_t *, mbr_t *, mbr_t *, int));
int Xmanual __P((cmd_t *, disk_t *, mbr_t *, mbr_t *, int));
int Xedit __P((cmd_t *, disk_t *, mbr_t *, mbr_t *, int));
+int Xsetpid __P((cmd_t *, disk_t *, mbr_t *, mbr_t *, int));
int Xselect __P((cmd_t *, disk_t *, mbr_t *, mbr_t *, int));
int Xprint __P((cmd_t *, disk_t *, mbr_t *, mbr_t *, int));
int Xwrite __P((cmd_t *, disk_t *, mbr_t *, mbr_t *, int));
diff --git a/sbin/fdisk/fdisk.8 b/sbin/fdisk/fdisk.8
index db3cb4a65b5..48ab1c2eeb4 100644
--- a/sbin/fdisk/fdisk.8
+++ b/sbin/fdisk/fdisk.8
@@ -1,4 +1,4 @@
-.\" $OpenBSD: fdisk.8,v 1.33 2000/11/09 17:52:54 aaron Exp $
+.\" $OpenBSD: fdisk.8,v 1.34 2001/01/01 21:05:34 angelos Exp $
.\"
.\" Copyright (c) 1997 Tobias Weingartner
.\" All rights reserved.
@@ -207,6 +207,11 @@ Edit a given table entry in the memory copy of
the current boot block.
You may edit either in BIOS geometry mode,
or in sector offsets and sizes.
+.It Em setpid
+Change the partition
+identifier of the given partition table entry.
+This command is particularly useful for reassigning
+an existing partition to OpenBSD.
.It Em flag
Make the given partition table entry bootable.
Only one entry can be marked bootable.
diff --git a/sbin/fdisk/user.c b/sbin/fdisk/user.c
index 8a5bf7a0c91..248e9844a75 100644
--- a/sbin/fdisk/user.c
+++ b/sbin/fdisk/user.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: user.c,v 1.15 2000/09/12 00:17:47 deraadt Exp $ */
+/* $OpenBSD: user.c,v 1.16 2001/01/01 21:05:34 angelos Exp $ */
/*
* Copyright (c) 1997 Tobias Weingartner
@@ -52,6 +52,7 @@ static cmd_table_t cmd_table[] = {
{"help", Xhelp, "Command help list"},
{"manual", Xmanual, "Show entire OpenBSD man page for fdisk"},
{"reinit", Xreinit, "Re-initialize loaded MBR (to defaults)"},
+ {"setpid", Xsetpid, "Set the identifier of a given table entry"},
{"disk", Xdisk, "Edit current drive stats"},
{"edit", Xedit, "Edit given table entry"},
{"flag", Xflag, "Flag given table entry as bootable"},