summaryrefslogtreecommitdiff
path: root/sbin/fdisk/cmd.c
diff options
context:
space:
mode:
authorAngelos D. Keromytis <angelos@cvs.openbsd.org>2001-01-01 21:05:35 +0000
committerAngelos D. Keromytis <angelos@cvs.openbsd.org>2001-01-01 21:05:35 +0000
commit7cc6100cd1df1e31e79298997610251bd707cb06 (patch)
tree5198be0146a51f2f44bf26bc02aa0264c37ce25a /sbin/fdisk/cmd.c
parent15c2b2b1b01b6d61b15ec724308940f29c3b54eb (diff)
New command "setpid", just changes the ID of a partition (no other
parameters editing) -- vassilip@dsl.cis.upenn.edu
Diffstat (limited to 'sbin/fdisk/cmd.c')
-rw-r--r--sbin/fdisk/cmd.c42
1 files changed, 41 insertions, 1 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;