diff options
author | Theo de Raadt <deraadt@cvs.openbsd.org> | 2005-01-19 15:48:21 +0000 |
---|---|---|
committer | Theo de Raadt <deraadt@cvs.openbsd.org> | 2005-01-19 15:48:21 +0000 |
commit | 3d950ae7b18a74e68d00f7aa1aeedc0de767a37f (patch) | |
tree | 9a9f84b4c929cc44515b66e7b11577924a0b040d /sbin/fdisk/cmd.c | |
parent | 32ae4c7606813925856a8f6d568185dce44029ef (diff) |
add a swap primitive; ok various, will be polished after by tom
Diffstat (limited to 'sbin/fdisk/cmd.c')
-rw-r--r-- | sbin/fdisk/cmd.c | 44 |
1 files changed, 43 insertions, 1 deletions
diff --git a/sbin/fdisk/cmd.c b/sbin/fdisk/cmd.c index beb47b9f35b..435b8a56b7b 100644 --- a/sbin/fdisk/cmd.c +++ b/sbin/fdisk/cmd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cmd.c,v 1.37 2004/11/06 18:57:59 otto Exp $ */ +/* $OpenBSD: cmd.c,v 1.38 2005/01/19 15:48:20 deraadt Exp $ */ /* * Copyright (c) 1997 Tobias Weingartner @@ -95,6 +95,48 @@ Xdisk(cmd_t *cmd, disk_t *disk, mbr_t *mbr, mbr_t *tt, int offset) /* ARGSUSED */ int +Xswap(cmd_t *cmd, disk_t *disk, mbr_t *mbr, mbr_t *tt, int offset) +{ + int pf, pt, ret; + prt_t pp; + + ret = CMD_CONT; + + if (!isdigit(cmd->args[0])) { + printf("Invalid argument: %s <from partition number>\n", + cmd->cmd); + return (ret); + } + + pf = atoi(cmd->args); + if (pf < 0 || pf > 3) { + printf("Invalid partition number %d.\n", pf); + return (ret); + } + + pt = ask_num("Swap with what paritition?", ASK_DEC, + -1, 0, 3, NULL); + if (pt < 0 || pt > 3) { + printf("Invalid partition number %d.\n", pt); + return (ret); + } + + if (pt == pf) { + printf("%d same partition as %d, doing nothing.\n", pt, pf); + return (ret); + } + + pp = mbr->part[pt]; + mbr->part[pt] = mbr->part[pf]; + mbr->part[pf] = pp; + + ret = CMD_DIRTY; + return (ret); +} + + +/* ARGSUSED */ +int Xedit(cmd_t *cmd, disk_t *disk, mbr_t *mbr, mbr_t *tt, int offset) { int pn, num, ret; |